From patchwork Tue Mar 15 22:37:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 8592881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E95009F6E1 for ; Tue, 15 Mar 2016 22:49:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 006F1203AD for ; Tue, 15 Mar 2016 22:49:23 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0CAFA203AC for ; Tue, 15 Mar 2016 22:49:22 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1afxbw-00031h-Ji; Tue, 15 Mar 2016 22:38:44 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1afxbi-0002vL-UH for linux-arm-kernel@lists.infradead.org; Tue, 15 Mar 2016 22:38:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From; bh=p0wtVDtAWmocvSIy3WVzRHbO8eiuXngXlDUx6bSvxaU=; b=CJd+6uic8DxNJ b5utvxv7StvxMS0U9o3XVQL6JdVcTWrYVs1KZpVbkSgEa+GmySqBr0zy5IDDJc+IQynPCFYZ1pRQP tofsfwI/cR3oHrP60+xQFz5K4fcXywXOWOIiXS4DSvY7cBWlE9EKB0y4OqrObIYhQu/BLKpO0LZPk Xayk5pgI79TIBNP0F+MKzeQ02KYDZtzpOIQnSEpSe2Xx7nceNNRxwD5nsx1AWCklu04wlA6bVhLn0 FvuSgeGc8c15V45ajLsnd9H+6hZwCzg8Vcxz+hN1nxlPLhSSJLlHtKzjrOT2tueCzpXFxnBRtvQAr gz9xPggz/pVpQ7qKV178g==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:36508 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.86_1) (envelope-from ) id 1afxbN-001vEs-Ho; Tue, 15 Mar 2016 18:38:09 -0400 From: David Lechner To: Sekhar Nori , Kevin Hilman , Alan Stern , Bin Liu , Petr Kulhavy Subject: [PATCH 4/5] usb: ohci-da8xx: Remove clock code that references mach Date: Tue, 15 Mar 2016 17:37:52 -0500 Message-Id: <1458081473-8223-4-git-send-email-david@lechnology.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1458081473-8223-1-git-send-email-david@lechnology.com> References: <1458081473-8223-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160315_153831_173304_F41C4F71 X-CRM114-Status: GOOD ( 12.28 ) X-Spam-Score: -2.0 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Russell King , David Lechner , Sergei Shtylyov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RDNS_NONE,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Including mach/* is frowned upon in device drivers, so get rid of it. This replaces usb20_clk with usb11_phy_clk that represents the 48MHz usb phy clock. The interaction with the usb20 (musb) subsystem does no belong here and has been implemented in da830.c/da850.c with the rest of the da8xx clock code. Signed-off-by: David Lechner --- drivers/usb/host/ohci-da8xx.c | 81 ++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 43 deletions(-) diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index e5c33bc..37fa3fb 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c @@ -16,57 +16,43 @@ #include #include -#include #include #ifndef CONFIG_ARCH_DAVINCI_DA8XX #error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." #endif -#define CFGCHIP2 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG) +#define USB1SUSPENDM (1 << 7) static struct clk *usb11_clk; -static struct clk *usb20_clk; +static struct clk *usb11_phy_clk; +static __iomem u32 *cfgchip2; /* Over-current indicator change bitmask */ static volatile u16 ocic_mask; -static void ohci_da8xx_clock(int on) +static void ohci_da8xx_enable(void) { - u32 cfgchip2; - - cfgchip2 = __raw_readl(CFGCHIP2); - if (on) { - clk_enable(usb11_clk); - - /* - * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we - * need to enable the USB 2.0 module clocking, start its PHY, - * and not allow it to stop the clock during USB 2.0 suspend. - */ - if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) { - clk_enable(usb20_clk); - - cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN); - cfgchip2 |= CFGCHIP2_PHY_PLLON; - __raw_writel(cfgchip2, CFGCHIP2); - - pr_info("Waiting for USB PHY clock good...\n"); - while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD)) - cpu_relax(); - } + u32 val; - /* Enable USB 1.1 PHY */ - cfgchip2 |= CFGCHIP2_USB1SUSPENDM; - } else { - clk_disable(usb11_clk); - if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) - clk_disable(usb20_clk); + clk_prepare_enable(usb11_clk); + clk_prepare_enable(usb11_phy_clk); - /* Disable USB 1.1 PHY */ - cfgchip2 &= ~CFGCHIP2_USB1SUSPENDM; - } - __raw_writel(cfgchip2, CFGCHIP2); + val = __raw_readl(cfgchip2); + val |= USB1SUSPENDM; + __raw_writel(val, cfgchip2); +} + +static void ohci_da8xx_disable(void) +{ + u32 val; + + val = __raw_readl(cfgchip2); + val &= ~USB1SUSPENDM; + __raw_writel(val, cfgchip2); + + clk_disable_unprepare(usb11_phy_clk); + clk_disable_unprepare(usb11_clk); } /* @@ -92,7 +78,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd) dev_dbg(dev, "starting USB controller\n"); - ohci_da8xx_clock(1); + ohci_da8xx_enable(); /* * DA8xx only have 1 port connected to the pins but the HC root hub @@ -129,7 +115,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd) static void ohci_da8xx_stop(struct usb_hcd *hcd) { ohci_stop(hcd); - ohci_da8xx_clock(0); + ohci_da8xx_disable(); } static int ohci_da8xx_start(struct usb_hcd *hcd) @@ -304,9 +290,9 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, if (IS_ERR(usb11_clk)) return PTR_ERR(usb11_clk); - usb20_clk = devm_clk_get(&pdev->dev, "usb20"); - if (IS_ERR(usb20_clk)) - return PTR_ERR(usb20_clk); + usb11_phy_clk = devm_clk_get(&pdev->dev, "usb11_phy"); + if (IS_ERR(usb11_phy_clk)) + return PTR_ERR(usb11_phy_clk); hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); if (!hcd) @@ -316,11 +302,20 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, hcd->regs = devm_ioremap_resource(&pdev->dev, mem); if (IS_ERR(hcd->regs)) { error = PTR_ERR(hcd->regs); + dev_err(&pdev->dev, "failed to map ohci.\n"); goto err; } hcd->rsrc_start = mem->start; hcd->rsrc_len = resource_size(mem); + mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); + cfgchip2 = devm_ioremap_resource(&pdev->dev, mem); + if (IS_ERR(cfgchip2)) { + error = PTR_ERR(cfgchip2); + dev_err(&pdev->dev, "failed to map cfgchip2.\n"); + goto err; + } + ohci_hcd_init(hcd_to_ohci(hcd)); irq = platform_get_irq(pdev, 0); @@ -397,7 +392,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev, if (ret) return ret; - ohci_da8xx_clock(0); + ohci_da8xx_disable(); hcd->state = HC_STATE_SUSPENDED; return ret; @@ -412,7 +407,7 @@ static int ohci_da8xx_resume(struct platform_device *dev) msleep(5); ohci->next_statechange = jiffies; - ohci_da8xx_clock(1); + ohci_da8xx_enable(); dev->dev.power.power_state = PMSG_ON; usb_hcd_resume_root_hub(hcd); return 0;