From patchwork Mon Feb 23 13:10:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 442486 X-Patchwork-Delegate: l.majewski@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A624014012C for ; Tue, 24 Feb 2015 00:21:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B1AB4B14B; Mon, 23 Feb 2015 14:19:11 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pTZbJw-6v3ht; Mon, 23 Feb 2015 14:19:11 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AB2CC4B5CD; Mon, 23 Feb 2015 14:19:04 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B5C44A044 for ; Mon, 23 Feb 2015 14:11:46 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bs_PJT1RqaXI for ; Mon, 23 Feb 2015 14:11:46 +0100 (CET) X-policyd-weight: SBL_XBL_SPAMHAUS=SKIP(-1.5) NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 IX_MANITU=ERR(0) (only DNSBL check requested) Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by theia.denx.de (Postfix) with ESMTPS id 0D6F74B5D0 for ; Mon, 23 Feb 2015 14:11:39 +0100 (CET) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id t1NDBVZC030700; Mon, 23 Feb 2015 07:11:31 -0600 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t1NDBUo2031084; Mon, 23 Feb 2015 07:11:30 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.224.2; Mon, 23 Feb 2015 07:11:30 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t1NDAQgC012678; Mon, 23 Feb 2015 07:11:28 -0600 From: Kishon Vijay Abraham I To: , , , Date: Mon, 23 Feb 2015 18:40:05 +0530 Message-ID: <1424697023-26696-23-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1424697023-26696-1-git-send-email-kishon@ti.com> References: <1424697023-26696-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Cc: kishon@ti.com, nsekhar@ti.com, rogerq@ti.com Subject: [U-Boot] [u-boot PATCH v2 22/40] dwc3: core: add support for multiple dwc3 controllers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Added support for multiple dwc3 controllers. This gives uboot the capability to control multiple dwc3 controllers. Signed-off-by: Kishon Vijay Abraham I Reviewed-by: Lukasz Majewski --- drivers/usb/dwc3/core.c | 32 ++++++++++++++++++++++++-------- drivers/usb/dwc3/core.h | 4 ++++ include/dwc3-uboot.h | 3 ++- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 58c3bfd..bd34dbd 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -29,7 +29,7 @@ #include "linux-compat.h" -struct dwc3 *dwc; +static LIST_HEAD(dwc3_list); /* -------------------------------------------------------------------------- */ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) @@ -612,6 +612,7 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc) */ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) { + struct dwc3 *dwc; struct device *dev; u8 lpm_nyet_threshold; u8 tx_de_emphasis; @@ -678,6 +679,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->hird_threshold = hird_threshold | (dwc->is_utmi_l1_suspend << 4); + dwc->index = dwc3_dev->index; + dwc3_cache_hwparams(dwc); ret = dwc3_alloc_event_buffers(dwc, DWC3_EVENT_BUFFERS_SIZE); @@ -710,6 +713,8 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) if (ret) goto err2; + list_add_tail(&dwc->list, &dwc3_list); + return 0; err2: @@ -729,17 +734,28 @@ err0: * @index: index of this controller * * Performs cleanup of memory allocated in dwc3_uboot_init and other misc - * cleanups (equivalent to dwc3_remove in linux). + * cleanups (equivalent to dwc3_remove in linux). index of _this_ controller + * should be passed and should match with the index passed in + * dwc3_device during init. * * Generally called from board file. */ -void dwc3_uboot_exit() +void dwc3_uboot_exit(int index) { - dwc3_core_exit_mode(dwc); - dwc3_event_buffers_cleanup(dwc); - dwc3_free_event_buffers(dwc); - dwc3_core_exit(dwc); - kfree(dwc->mem); + struct dwc3 *dwc; + + list_for_each_entry(dwc, &dwc3_list, list) { + if (dwc->index != index) + continue; + + dwc3_core_exit_mode(dwc); + dwc3_event_buffers_cleanup(dwc); + dwc3_free_event_buffers(dwc); + dwc3_core_exit(dwc); + list_del(&dwc->list); + kfree(dwc->mem); + break; + } } MODULE_ALIAS("platform:dwc3"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 0d507c1..c5debf7 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -695,6 +695,8 @@ struct dwc3_scratchpad_array { * 1 - -3.5dB de-emphasis * 2 - No de-emphasis * 3 - Reserved + * @index: index of _this_ controller + * @list: to maintain the list of dwc3 controllers */ struct dwc3 { struct usb_ctrlrequest *ctrl_req; @@ -811,6 +813,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + int index; + struct list_head list; }; /* -------------------------------------------------------------------------- */ diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h index 6d1b42a..272a020 100644 --- a/include/dwc3-uboot.h +++ b/include/dwc3-uboot.h @@ -33,8 +33,9 @@ struct dwc3_device { unsigned dis_u2_susphy_quirk; unsigned tx_de_emphasis_quirk; unsigned tx_de_emphasis; + int index; }; int dwc3_uboot_init(struct dwc3_device *dev); -void dwc3_uboot_exit(void); +void dwc3_uboot_exit(int index); #endif /* __DWC3_UBOOT_H_ */