From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754693Ab2LJKZs (ORCPT ); Mon, 10 Dec 2012 05:25:48 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:59200 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753118Ab2LJKV2 (ORCPT ); Mon, 10 Dec 2012 05:21:28 -0500 From: Roger Quadros To: , , CC: , , , , , , , , Subject: [PATCH v4 13/23] mfd: omap-usb-host: know about number of ports from revision register Date: Mon, 10 Dec 2012 12:20:23 +0200 Message-ID: <1355134833-5199-14-git-send-email-rogerq@ti.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1355134833-5199-1-git-send-email-rogerq@ti.com> References: <1355134833-5199-1-git-send-email-rogerq@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The revision register should tell us how many ports are present. Signed-off-by: Roger Quadros --- drivers/mfd/omap-usb-host.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c index 13a3e8c..9c23a08 100644 --- a/drivers/mfd/omap-usb-host.c +++ b/drivers/mfd/omap-usb-host.c @@ -92,6 +92,8 @@ struct usbhs_hcd_omap { + int nports; + struct clk *xclk60mhsp1_ck; struct clk *xclk60mhsp2_ck; struct clk *utmi_p1_fck; @@ -354,8 +356,6 @@ static void omap_usbhs_init(struct device *dev) pm_runtime_get_sync(dev); spin_lock_irqsave(&omap->lock, flags); - omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); - dev_dbg(dev, "OMAP UHH_REVISION 0x%x\n", omap->usbhs_rev); reg = usbhs_read(omap->uhh_base, OMAP_UHH_HOSTCONFIG); /* setup ULPI bypass and burst configurations */ @@ -488,8 +488,32 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) pm_runtime_enable(dev); + platform_set_drvdata(pdev, omap); + pm_runtime_get_sync(dev); - for (i = 0; i < OMAP3_HS_USB_PORTS; i++) + omap->usbhs_rev = usbhs_read(omap->uhh_base, OMAP_UHH_REVISION); + + /* we need to call runtime suspend before we update omap->nports + * to prevent unbalanced clk_disable() + */ + pm_runtime_put_sync(dev); + + switch (omap->usbhs_rev) { + case OMAP_USBHS_REV1: + omap->nports = 3; + break; + case OMAP_USBHS_REV2: + omap->nports = 2; + break; + default: + omap->nports = OMAP3_HS_USB_PORTS; + dev_dbg(dev, + "USB HOST Rev : 0x%d not recognized, assuming %d ports\n", + omap->usbhs_rev, omap->nports); + break; + } + + for (i = 0; i < omap->nports; i++) if (is_ehci_phy_mode(i) || is_ehci_tll_mode(i) || is_ehci_hsic_mode(i)) { omap->ehci_logic_fck = clk_get(dev, "ehci_logic_fck"); @@ -579,8 +603,6 @@ static int __devinit usbhs_omap_probe(struct platform_device *pdev) "failed error:%d\n", ret); } - platform_set_drvdata(pdev, omap); - omap_usbhs_init(dev); ret = omap_usbhs_alloc_children(pdev); if (ret) { -- 1.7.4.1