From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966375AbdDZTYI (ORCPT ); Wed, 26 Apr 2017 15:24:08 -0400 Received: from smtprelay.synopsys.com ([198.182.47.9]:38202 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966295AbdDZTXj (ORCPT ); Wed, 26 Apr 2017 15:23:39 -0400 Date: Wed, 26 Apr 2017 23:23:13 +0400 Message-ID: <90a20e29194bda542a6d9c4fa2f5b0abeb3aa22e.1493234662.git.sevaka@synopsys.com> In-Reply-To: References: From: Sevak Arakelyan Subject: [PATCH 4/4] usb: dwc2: gadget: Separate non-periodic and periodic FIFO inits To: John Youn , Felipe Balbi , "Greg Kroah-Hartman" , , CC: Sevak Arakelyan MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.13.184.19] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Separate dwc2_hsotg_init_fifo function into 2 different functions, for periodic and non-periodic FIFOs. Initialization of non-periodic FIFOs must be done after soft or USB resets, while initialization of periodic FIFOs must be done only after soft reset. Signed-off-by: Sevak Arakelyan --- drivers/usb/dwc2/gadget.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 574562a0286d..0bf42a0a3213 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -285,10 +285,9 @@ int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) } /** - * dwc2_hsotg_init_fifo - initialise non-periodic FIFOs - * @hsotg: The device instance. + * dwc2_hsotg_init_periodic_fifos - initialize periodic FIFOs */ -static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) +static void dwc2_hsotg_init_periodic_fifos(struct dwc2_hsotg *hsotg) { unsigned int ep; unsigned int addr; @@ -303,27 +302,12 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) WARN_ON(hsotg->fifo_map); hsotg->fifo_map = 0; - /* set RX/NPTX FIFO sizes */ - dwc2_writel(hsotg->params.g_rx_fifo_size, hsotg->regs + GRXFSIZ); - dwc2_writel((hsotg->params.g_rx_fifo_size << FIFOSIZE_STARTADDR_SHIFT) | - (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT), - hsotg->regs + GNPTXFSIZ); - /* - * arange all the rest of the TX FIFOs, as some versions of this - * block have overlapping default addresses. This also ensures - * that if the settings have been changed, then they are set to - * known values. + * Arange periodic TX FIFOs to correctly calculated values. + * Start at the end of the GNPTXFSIZ. */ - - /* start at the end of the GNPTXFSIZ, rounded up */ addr = hsotg->params.g_rx_fifo_size + hsotg->params.g_np_tx_fifo_size; - /* - * Configure fifos sizes from provided configuration and assign - * them to endpoints dynamically according to maxpacket size value of - * given endpoint. - */ fifo_count = dwc2_hsotg_tx_fifo_count(hsotg); for (ep = 1; ep <= fifo_count; ep++) { @@ -340,6 +324,21 @@ static void dwc2_hsotg_init_fifo(struct dwc2_hsotg *hsotg) dwc2_writel(hsotg->hw_params.total_fifo_size | addr << GDFIFOCFG_EPINFOBASE_SHIFT, hsotg->regs + GDFIFOCFG); +} + +/** + * dwc2_hsotg_init_non_periodic_fifos - initialize non-periodic FIFOs + */ +static void dwc2_hsotg_init_non_periodic_fifos(struct dwc2_hsotg *hsotg) +{ + if (!hsotg->params.enable_dynamic_fifo) + return; + + /* set RX/NPTX FIFO sizes */ + dwc2_writel(hsotg->params.g_rx_fifo_size, hsotg->regs + GRXFSIZ); + dwc2_writel((hsotg->params.g_rx_fifo_size << FIFOSIZE_STARTADDR_SHIFT) | + (hsotg->params.g_np_tx_fifo_size << FIFOSIZE_DEPTH_SHIFT), + hsotg->regs + GNPTXFSIZ); /* * Chapter 2.1.1 of the Programming Guide - The TxFIFOs and the RxFIFO @@ -3269,10 +3268,13 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, } dwc2_writel(usbcfg, hsotg->regs + GUSBCFG); - dwc2_hsotg_init_fifo(hsotg); + dwc2_hsotg_init_non_periodic_fifos(hsotg); + + if (!is_usb_reset) { + dwc2_hsotg_init_periodic_fifos(hsotg); - if (!is_usb_reset) __orr32(hsotg->regs + DCTL, DCTL_SFTDISCON); + } dcfg |= DCFG_EPMISCNT(1); -- 2.11.0