From patchwork Mon Nov 12 03:20:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lubomir Rintel X-Patchwork-Id: 10678087 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 0988E13BF for ; Mon, 12 Nov 2018 03:26:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB97A2A14F for ; Mon, 12 Nov 2018 03:26:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF07D2A154; Mon, 12 Nov 2018 03:26:25 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW 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 EDD822A14F for ; Mon, 12 Nov 2018 03:26:24 +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=Zdl2LP0xUyqEzD hKg0mt2PA5R8yNdlzA6ay8GzfaW2prlGv+8nfDsOp60X422fiusxy3GEEpoB0EZLaOppzEO/rSBS+ CbzIbs8lffmFCZkCQggZqcpQ3gFiH3Va75GOL+3oLtjvPiG2n3mM73vOhBkSYVXCyTtVX15aN64CR CrId71wNbfX8Q0y1jYFkIWRapPWG1rUeR6F5gznIPUwn9IMI0JX9ZKWtZkg4OJQGQTKy6m7AAZ8z4 9Jp4qCvjo/z8HLmR4rtjTcL1se50TwrWhzb0grrYH6A/CSAcdRaBD+Aw+2VIyRWo9008UzKIS6+p9 a7wXSxDmjnhj2cFUSdHw==; 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 1gM2rZ-0003pi-JK; Mon, 12 Nov 2018 03:26:09 +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 1gM2nQ-0007G5-Aj for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Nov 2018 03:21:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=N8ogNcY9JYb2L2Ei+0TAfIYjrd ZJbM/P58W9o1eu9GDrpgBOTTOiUmfCXWPwQjNHhFuidMUgp62TAIwDwdODRg2PjTsqnx6TKbiNDT0 3wGMF/z9ZU1Yiq4Yxv+yYCuI0YcUKwkq6X08BUt9WquwsD22HjFY59EF4NtVbTeORZONhh2CN/tAR sWZOL8Gfa6blAFMYXlVxuV5l+lhzpThldoDIX/PVkyH+MuVuk3xTtVyAolAdrSXt1gdgN7gbta0e1 hPgRw6J/O/N8HJ/+O4DOe5Cb2oGbRQ0E03R1ogWRtYBxirWEEW0TIQZox6mrlABtbFw5XXy4wG+bH jQ9bA0Wg==; Received: from shell.v3.sk ([90.176.6.54]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gM2nN-0005ze-1I for linux-arm-kernel@lists.infradead.org; Mon, 12 Nov 2018 03:21:50 +0000 Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 3E7E0C6A2B; Mon, 12 Nov 2018 04:21:38 +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 PVXWGAwv_t7r; Mon, 12 Nov 2018 04:21:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zimbra.v3.sk (Postfix) with ESMTP id 6B1E5C6A2F; Mon, 12 Nov 2018 04:20:50 +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 yB4Oi2-F2oTk; Mon, 12 Nov 2018 04:20:48 +0100 (CET) Received: from belphegor.lan (ip-89-102-31-34.net.upcbroadband.cz [89.102.31.34]) by zimbra.v3.sk (Postfix) with ESMTPSA id AD298C6A39; Mon, 12 Nov 2018 04:20:40 +0100 (CET) From: Lubomir Rintel To: Eric Miao , Haojian Zhuang Subject: [PATCH v3 18/18] USB: gadget: mv-udc: use phy-pxa-usb Date: Mon, 12 Nov 2018 04:20:27 +0100 Message-Id: <20181112032027.653931-19-lkundrak@v3.sk> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181112032027.653931-1-lkundrak@v3.sk> References: <20181112032027.653931-1-lkundrak@v3.sk> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181112_032149_229390_02FFFB4B X-CRM114-Status: GOOD ( 15.17 ) 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: Lubomir Rintel , Robert Jarzmik , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King 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);