From patchwork Wed Aug 22 20:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10573261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D98F139B for ; Wed, 22 Aug 2018 20:58:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C9562BCBA for ; Wed, 22 Aug 2018 20:58:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20C172BCC6; Wed, 22 Aug 2018 20:58:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF14D2BCBA for ; Wed, 22 Aug 2018 20:58:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AW0QVd84pc153+JVXWkv+/xnrqYhWtLy92GWAYEDIic=; b=tvEVTihRrj+o/V0PjMaWHY8i82 iyHAq7w/wFiOuXnhmzX1tmzUAfWv/h+RjOZQg67QltXifDL0EDCRD1rWlZX5vcop9qINreAlYiFX3 yNIBhFoo++jFbHShw484ze1/p4L7g2xPpzfcELDY36aomwfgybVDcD1YbaFc5opGdqhiyjVC/yEnW AIVauTdJ8OJqo3AG000L1GzKNvHD1sSLJkWxGt09/56XV/NR7kev6AYVf8DqUC/EKtj5JEEJqFBec jkHOUNsd0Yi/3hI6XzygcX8QQBdbKkyRqqWgqlSZsf12BC7X6qcyvSIkQmCG5LTqqiE4Ru6iZglT7 an+ZozMQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsaCY-0008Fh-JL; Wed, 22 Aug 2018 20:58:02 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsaCO-0007yE-NE for linux-arm-kernel@bombadil.infradead.org; Wed, 22 Aug 2018 20:57:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kcbf/srDSpiVd3m4qvfD+1By0lnckKmj2FTrfatlRi4=; b=BcHyf1UeLIucGz75fHMhx6zR2 l9YGS6BlJZBHgJ7ZwANdyqhOrDTUUVTGdq2fF2Q/XwSYwWrlEByWxHYEKHhYWxeGvMGPRFr/8EoIF HsTEGmqr/hU6QQ9QBT/rOjZ5NKisjAI1YNV5JCwBblaWkGJL0E+yjV4D/6UfY5Kq3tEI0fgRwHfMI BMoOyYBCASnQ3M5sMALIEgW2d1yB3px7xRna0FSjtKqjHu/zP31QV0gY08LLTqbQnbQBcGynqk9Z1 WHkdsZ9xYra3dEGEjhnkvNOgneexjjAb0U8sm4qv86uanea42wVb0fAgOGWUN3G4xYPoNnzAg9bHi fEyRkgi5w==; Received: from shell.v3.sk ([90.176.6.54]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsZyu-0003YS-2j for linux-arm-kernel@lists.infradead.org; Wed, 22 Aug 2018 20:43:58 +0000 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 533C9B5B8D; Wed, 22 Aug 2018 22:43:38 +0200 (CEST) Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 8A3fa56tQZLn; Wed, 22 Aug 2018 22:43:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 91DB1B5238; Wed, 22 Aug 2018 22:43:16 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.v3.sk Received: from shell.v3.sk ([127.0.0.1]) by localhost (zimbra.v3.sk [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lyhnl9b2p60P; Wed, 22 Aug 2018 22:43:14 +0200 (CEST) Received: from odvarok.lan (ip-89-102-31-34.net.upcbroadband.cz [89.102.31.34]) by zimbra.v3.sk (Postfix) with ESMTPSA id 3582EB5B93; Wed, 22 Aug 2018 22:43:13 +0200 (CEST) From: Lubomir Rintel To: linux-kernel@vger.kernel.org Subject: [PATCH 08/14] USB: EHCI: ehci-mv: use phy-pxa-usb Date: Wed, 22 Aug 2018 22:43:01 +0200 Message-Id: <20180822204307.13251-9-lkundrak@v3.sk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822204307.13251-1-lkundrak@v3.sk> References: <20180822204307.13251-1-lkundrak@v3.sk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180822_214356_276132_EBD76FAA X-CRM114-Status: GOOD ( 18.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Eric Miao , Greg Kroah-Hartman , linux-usb@vger.kernel.org, Haojian Zhuang , Kishon Vijay Abraham I , Lubomir Rintel , Rob Herring , Alan Stern , 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-Virus-Scanned: ClamAV using ClamSMTP Use a proper PHY driver, instead of hooks to a board support package. Signed-off-by: Lubomir Rintel --- arch/arm/mach-mmp/devices.c | 11 +--------- drivers/usb/host/ehci-mv.c | 44 ++++++++++++++++++------------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c index d162fabd38e7..822b8be042b9 100644 --- a/arch/arm/mach-mmp/devices.c +++ b/arch/arm/mach-mmp/devices.c @@ -298,21 +298,12 @@ struct platform_device pxa168_device_u2o = { #if IS_ENABLED(CONFIG_USB_EHCI_MV_U2O) struct resource pxa168_u2oehci_resources[] = { - /* regbase */ [0] = { - .start = PXA168_U2O_REGBASE + U2x_CAPREGS_OFFSET, + .start = PXA168_U2O_REGBASE, .end = PXA168_U2O_REGBASE + USB_REG_RANGE, .flags = IORESOURCE_MEM, - .name = "capregs", }, - /* phybase */ [1] = { - .start = PXA168_U2O_PHYBASE, - .end = PXA168_U2O_PHYBASE + USB_PHY_RANGE, - .flags = IORESOURCE_MEM, - .name = "phyregs", - }, - [2] = { .start = IRQ_PXA168_USB1, .end = IRQ_PXA168_USB1, .flags = IORESOURCE_IRQ, diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index 705d1b43b2dd..43b300c90875 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c @@ -18,6 +18,9 @@ #include "ehci.h" +/* registers */ +#define U2x_CAPREGS_OFFSET 0x100 + #define CAPLENGTH_MASK (0xff) #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv) @@ -26,13 +29,14 @@ struct ehci_hcd_mv { /* Which mode does this ehci running OTG/Host ? */ int mode; - void __iomem *phy_regs; + void __iomem *base; void __iomem *cap_regs; void __iomem *op_regs; struct usb_phy *otg; struct mv_usb_platform_data *pdata; + struct phy *phy; struct clk *clk; }; @@ -49,22 +53,13 @@ static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) { - int retval; - ehci_clock_enable(ehci_mv); - if (ehci_mv->pdata->phy_init) { - retval = ehci_mv->pdata->phy_init(ehci_mv->phy_regs); - if (retval) - return retval; - } - - return 0; + return phy_init(ehci_mv->phy); } static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv) { - if (ehci_mv->pdata->phy_deinit) - ehci_mv->pdata->phy_deinit(ehci_mv->phy_regs); + phy_exit(ehci_mv->phy); ehci_clock_disable(ehci_mv); } @@ -121,6 +116,14 @@ static int mv_ehci_probe(struct platform_device *pdev) ehci_mv = hcd_to_ehci_hcd_mv(hcd); ehci_mv->pdata = pdata; + ehci_mv->phy = devm_phy_get(&pdev->dev, "usb"); + if (IS_ERR(ehci_mv->phy)) { + retval = PTR_ERR(ehci_mv->phy); + if (retval != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to get phy.\n"); + goto err_put_hcd; + } + ehci_mv->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(ehci_mv->clk)) { dev_err(&pdev->dev, "error getting clock\n"); @@ -128,17 +131,12 @@ static int mv_ehci_probe(struct platform_device *pdev) goto err_put_hcd; } - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phyregs"); - ehci_mv->phy_regs = devm_ioremap_resource(&pdev->dev, r); - if (IS_ERR(ehci_mv->phy_regs)) { - retval = PTR_ERR(ehci_mv->phy_regs); - goto err_put_hcd; - } - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "capregs"); - ehci_mv->cap_regs = devm_ioremap_resource(&pdev->dev, r); - if (IS_ERR(ehci_mv->cap_regs)) { - retval = PTR_ERR(ehci_mv->cap_regs); + + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + ehci_mv->base = devm_ioremap_resource(&pdev->dev, r); + if (IS_ERR(ehci_mv->base)) { + retval = PTR_ERR(ehci_mv->base); goto err_put_hcd; } @@ -148,6 +146,8 @@ static int mv_ehci_probe(struct platform_device *pdev) goto err_put_hcd; } + ehci_mv->cap_regs = + (void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET); offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK; ehci_mv->op_regs = (void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset);