From patchwork Fri Feb 6 08:48:04 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: 437101 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 1DDE5140273 for ; Fri, 6 Feb 2015 19:50:59 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CAC74B818; Fri, 6 Feb 2015 09:50:05 +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 unlVlbWY7GgZ; Fri, 6 Feb 2015 09:50:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2B0DC4B7D0; Fri, 6 Feb 2015 09:50:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99982A7420 for ; Fri, 6 Feb 2015 09:50:02 +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 4D4wj1eB0UQ1 for ; Fri, 6 Feb 2015 09:50:02 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (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 DC90B4B836 for ; Fri, 6 Feb 2015 09:49:54 +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 t168npGe028672; Fri, 6 Feb 2015 02:49:51 -0600 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id t168novi021800; Fri, 6 Feb 2015 02:49:50 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.224.2; Fri, 6 Feb 2015 02:49:50 -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 t168mN0q007034; Fri, 6 Feb 2015 02:49:47 -0600 From: Kishon Vijay Abraham I To: , , , , , , Date: Fri, 6 Feb 2015 14:18:04 +0530 Message-ID: <1423212497-11970-28-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1423212497-11970-1-git-send-email-kishon@ti.com> References: <1423212497-11970-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Cc: nsekhar@ti.com, kishon@ti.com Subject: [U-Boot] [u-boot 27/40] dwc3: dwc3-omap: add support for multiple dwc3-omap 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 omap controllers. This gives uboot the capability to control multiple dwc3 omap controllers. Signed-off-by: Kishon Vijay Abraham I Reviewed-by: Lukasz Majewski --- drivers/usb/dwc3/dwc3-omap.c | 26 ++++++++++++++++++++------ include/dwc3-omap-uboot.h | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c index 30d7210..c8275c7 100644 --- a/drivers/usb/dwc3/dwc3-omap.c +++ b/drivers/usb/dwc3/dwc3-omap.c @@ -119,9 +119,11 @@ struct dwc3_omap { u32 irq0_offset; u32 dma_status:1; + struct list_head list; + u32 index; }; -struct dwc3_omap *omap; +static LIST_HEAD(dwc3_omap_list); static inline u32 dwc3_omap_readl(void __iomem *base, u32 offset) { @@ -363,12 +365,14 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev) { u32 reg; struct device *dev; + struct dwc3_omap *omap; omap = devm_kzalloc(dev, sizeof(*omap), GFP_KERNEL); if (!omap) return -ENOMEM; omap->base = omap_dev->base; + omap->index = omap_dev->index; dwc3_omap_map_offset(omap); dwc3_omap_set_utmi_mode(omap, omap_dev->utmi_mode); @@ -380,6 +384,7 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev) dwc3_omap_set_mailbox(omap, omap_dev->vbus_id_status); dwc3_omap_enable_irqs(omap); + list_add_tail(&omap->list, &dwc3_omap_list); return 0; } @@ -389,16 +394,25 @@ int dwc3_omap_uboot_init(struct dwc3_omap_device *omap_dev) * @index: index of this controller * * Performs cleanup of memory allocated in dwc3_omap_uboot_init - * (equivalent to dwc3_omap_remove in linux). + * (equivalent to dwc3_omap_remove in linux). index of _this_ controller + * should be passed and should match with the index passed in + * dwc3_omap_device during init. * * Generally called from board file. */ -void dwc3_omap_uboot_exit(void) +void dwc3_omap_uboot_exit(int index) { - dwc3_omap_disable_irqs(omap); - kfree(omap); + struct dwc3_omap *omap = NULL; - return 0; + list_for_each_entry(omap, &dwc3_omap_list, list) { + if (omap->index != index) + continue; + + dwc3_omap_disable_irqs(omap); + list_del(&omap->list); + kfree(omap); + break; + } } MODULE_ALIAS("platform:omap-dwc3"); diff --git a/include/dwc3-omap-uboot.h b/include/dwc3-omap-uboot.h index 99f8f38..29f02f8 100644 --- a/include/dwc3-omap-uboot.h +++ b/include/dwc3-omap-uboot.h @@ -21,10 +21,11 @@ enum omap_dwc3_vbus_id_status { struct dwc3_omap_device { void *base; + int index; enum dwc3_omap_utmi_mode utmi_mode; enum omap_dwc3_vbus_id_status vbus_id_status; }; int dwc3_omap_uboot_init(struct dwc3_omap_device *dev); -void dwc3_omap_uboot_exit(void); +void dwc3_omap_uboot_exit(int index); #endif /* __DWC3_OMAP_UBOOT_H_ */