From patchwork Wed Nov 28 17:53:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10703133 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 64AAD109C for ; Wed, 28 Nov 2018 18:33:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5587128D3A for ; Wed, 28 Nov 2018 18:33:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 49A4E28EA3; Wed, 28 Nov 2018 18:33:59 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham 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 932E828D3A for ; Wed, 28 Nov 2018 18:33:58 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=cw0c52GGzrkr9qr8pT8BKri7N7GnTqWlhyloGcgJTwI=; b=M0HVO5FF8AijLH f8/D2d9zAT2PgjHFObUOVerGx+aGpg6YHsDYMp6ePsOqK2J08Zx6tr+sF4K7n9lpVjiExx7r1TC8U eck52ZmTxNMbfUaAaXejA3QHc2UWpxTOsDc3MDP9R4WFNj3SwGcHMl2ebJqWLbubqCJWmXDlSic+f dK6T7GK+tWjUa77RPuqIU4CRTyBfXD50a7HWcKmoMG7sApV7MV8SEZYQRtHB6DHG0z2PBSUzR471+ MVRpfMW4cLXtUfKf3pW4gFlCGwb/lgBBWQ+AkmR7H1NU8QJzoaItJ3QHgsNknc7v5OkIggoeEnzTd lwFUVs7F18YnNkGGVN8w==; 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 1gS4eq-0001ai-J3; Wed, 28 Nov 2018 18:33:56 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS4eY-0001GN-7e for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Nov 2018 18:33:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type: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=wJ81DmizkmFCgIF586PwwfqhXxXdqXVECrOBs1pa2bE=; b=PFVGSAt2gsD4qQRoS7lKrWemC3 xM/EdWzPlLK7sQHlSEUUG/XTArfTw5cFj6oxENSXysdR+J97zA2IWVPOs55789lZXa1nfRr5lRYR5 84R4xTsDaLANX266/FCy5QYVpbBUA7SVYkHG2yawhKVYarwq1JRRXYObI2ASgw8Q+BzlRf4fkjIo+ r6DBGkYfZjr+vEkKGq0SljgntgASZBc0VfDVXOmhtdDeGRHP2z0F6mzDSwW/FAEObljIqHVEPWZwu j+UF5PiPDEWIk0I52E/iJdO8btjgyzRMqy7Fl22NrTVRB+q6FC++6ALVJRxYCK5Q9kEEpR9Jxu18s olBCVEZA==; Received: from shell.v3.sk ([90.176.6.54]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gS42k-0007yb-Ll for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2018 17:54:36 +0000 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id DEED199B07; Wed, 28 Nov 2018 18:54:22 +0100 (CET) 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 p1eUjYhcIjan; Wed, 28 Nov 2018 18:54:08 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 7883199B60; Wed, 28 Nov 2018 18:53:45 +0100 (CET) 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 q0tCLb9Z7Ki5; Wed, 28 Nov 2018 18:53:42 +0100 (CET) Received: from belphegor.brq.redhat.com (nat-pool-brq-t.redhat.com [213.175.37.10]) by zimbra.v3.sk (Postfix) with ESMTPSA id D2E8399B67; Wed, 28 Nov 2018 18:53:33 +0100 (CET) From: Lubomir Rintel To: arm@kernel.org, Olof Johansson , Arnd Bergmann Subject: [PATCH v4 20/20] USB: gadget: mv-udc: use phy-pxa-usb Date: Wed, 28 Nov 2018 18:53:24 +0100 Message-Id: <20181128175324.163202-21-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181128175324.163202-1-lkundrak@v3.sk> References: <20181128175324.163202-1-lkundrak@v3.sk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181128_125435_229699_158EBE88 X-CRM114-Status: GOOD ( 14.62 ) 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: Eric Miao , James Cameron , Russell King , Haojian Zhuang , linux-kernel@vger.kernel.org, Lubomir Rintel , Pavel Machek , Robert Jarzmik , linux-arm-kernel@lists.infradead.org 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/gadget/udc/mv_udc.h | 7 ++++- drivers/usb/gadget/udc/mv_udc_core.c | 38 ++++++++-------------------- 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/arch/arm/mach-mmp/devices.c b/arch/arm/mach-mmp/devices.c index eb9b3c34e90a..d925be9f14a9 100644 --- a/arch/arm/mach-mmp/devices.c +++ b/arch/arm/mach-mmp/devices.c @@ -263,21 +263,12 @@ struct platform_device pxa168_device_usb_phy = { #if IS_ENABLED(CONFIG_USB_MV_UDC) struct resource pxa168_u2o_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/gadget/udc/mv_udc.h b/drivers/usb/gadget/udc/mv_udc.h index b3f759c0962c..6f04f432964d 100644 --- a/drivers/usb/gadget/udc/mv_udc.h +++ b/drivers/usb/gadget/udc/mv_udc.h @@ -6,6 +6,9 @@ #ifndef __MV_UDC_H #define __MV_UDC_H +/* registers */ +#define U2x_CAPREGS_OFFSET 0x100 + #define VUSBHS_MAX_PORTS 8 #define DQH_ALIGNMENT 2048 @@ -174,9 +177,9 @@ struct mv_udc { struct platform_device *dev; int irq; + void __iomem *base; struct mv_cap_regs __iomem *cap_regs; struct mv_op_regs __iomem *op_regs; - void __iomem *phy_regs; unsigned int max_eps; struct mv_dqh *ep_dqh; size_t ep_dqh_size; @@ -219,6 +222,8 @@ struct mv_udc { /* some SOC has mutiple clock sources for USB*/ struct clk *clk; + + struct phy *phy; }; /* endpoint data structure */ diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index cafde053788b..35b0bde2d46f 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -1069,14 +1069,11 @@ static int mv_udc_enable_internal(struct mv_udc *udc) if (retval) return retval; - if (udc->pdata->phy_init) { - retval = udc->pdata->phy_init(udc->phy_regs); - if (retval) { - dev_err(&udc->dev->dev, - "init phy error %d\n", retval); - udc_clock_disable(udc); - return retval; - } + retval = phy_init(udc->phy); + if (retval) { + dev_err(&udc->dev->dev, "init phy error %d\n", retval); + udc_clock_disable(udc); + return retval; } udc->active = 1; @@ -1095,8 +1092,7 @@ static void mv_udc_disable_internal(struct mv_udc *udc) { if (udc->active) { dev_dbg(&udc->dev->dev, "disable udc\n"); - if (udc->pdata->phy_deinit) - udc->pdata->phy_deinit(udc->phy_regs); + phy_exit(udc->phy); udc_clock_disable(udc); udc->active = 0; } @@ -2147,30 +2143,16 @@ static int mv_udc_probe(struct platform_device *pdev) if (IS_ERR(udc->clk)) return PTR_ERR(udc->clk); - r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "capregs"); + r = platform_get_resource(udc->dev, IORESOURCE_MEM, 0); if (r == NULL) { dev_err(&pdev->dev, "no I/O memory resource defined\n"); return -ENODEV; } - udc->cap_regs = (struct mv_cap_regs __iomem *) - devm_ioremap(&pdev->dev, r->start, resource_size(r)); - if (udc->cap_regs == NULL) { - dev_err(&pdev->dev, "failed to map I/O memory\n"); - return -EBUSY; - } - - r = platform_get_resource_byname(udc->dev, IORESOURCE_MEM, "phyregs"); - if (r == NULL) { - dev_err(&pdev->dev, "no phy I/O memory resource defined\n"); - return -ENODEV; - } + udc->base = devm_ioremap(&pdev->dev, r->start, resource_size(r)); - udc->phy_regs = devm_ioremap(&pdev->dev, r->start, resource_size(r)); - if (udc->phy_regs == NULL) { - dev_err(&pdev->dev, "failed to map phy I/O memory\n"); - return -EBUSY; - } + udc->cap_regs = + (void __iomem *) ((unsigned long)udc->base + U2x_CAPREGS_OFFSET); /* we will acces controller register, so enable the clk */ retval = mv_udc_enable_internal(udc);