From patchwork Mon Jan 14 14:16:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 1972241 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id A7F463FC85 for ; Mon, 14 Jan 2013 14:23:13 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tukte-0005Rx-7G; Mon, 14 Jan 2013 14:20:18 +0000 Received: from tx2ehsobe001.messaging.microsoft.com ([65.55.88.11] helo=tx2outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TuktV-0005On-Ar for linux-arm-kernel@lists.infradead.org; Mon, 14 Jan 2013 14:20:10 +0000 Received: from mail276-tx2-R.bigfish.com (10.9.14.248) by TX2EHSOBE012.bigfish.com (10.9.40.32) with Microsoft SMTP Server id 14.1.225.23; Mon, 14 Jan 2013 14:20:07 +0000 Received: from mail276-tx2 (localhost [127.0.0.1]) by mail276-tx2-R.bigfish.com (Postfix) with ESMTP id A2766DE0469; Mon, 14 Jan 2013 14:20:07 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1ee6h1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1155h) Received: from mail276-tx2 (localhost.localdomain [127.0.0.1]) by mail276-tx2 (MessageSwitch) id 1358173186791806_20358; Mon, 14 Jan 2013 14:19:46 +0000 (UTC) Received: from TX2EHSMHS005.bigfish.com (unknown [10.9.14.247]) by mail276-tx2.bigfish.com (Postfix) with ESMTP id BB7EAAC004E; Mon, 14 Jan 2013 14:19:46 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS005.bigfish.com (10.9.99.105) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 14 Jan 2013 14:16:23 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.2.318.3; Mon, 14 Jan 2013 14:16:22 +0000 Received: from localhost.localdomain (nchen-desktop.ap.freescale.net [10.192.242.40]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r0EEGAXU020382; Mon, 14 Jan 2013 07:16:19 -0700 From: Peter Chen To: , , , , Subject: [PATCH v4 2/3] usb: fsl_mxc_udc: replace MX35_IO_ADDRESS to ioremap Date: Mon, 14 Jan 2013 22:16:08 +0800 Message-ID: <1358172969-14898-3-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1358172969-14898-1-git-send-email-peter.chen@freescale.com> References: <1358172969-14898-1-git-send-email-peter.chen@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130114_092009_586040_32AB757D X-CRM114-Status: GOOD ( 14.60 ) X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [65.55.88.11 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-usb@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org As mach/hardware.h is deleted, we can't visit platform code at driver. It has no phy driver to combine with this controller, so it has to use ioremap to map phy address as a workaround. Signed-off-by: Peter Chen --- drivers/usb/gadget/fsl_mxc_udc.c | 27 +++++++++++++++++++++------ drivers/usb/gadget/fsl_udc_core.c | 4 +++- drivers/usb/gadget/fsl_usb2_udc.h | 4 ++-- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/fsl_mxc_udc.c b/drivers/usb/gadget/fsl_mxc_udc.c index 6df45f7..e505d60 100644 --- a/drivers/usb/gadget/fsl_mxc_udc.c +++ b/drivers/usb/gadget/fsl_mxc_udc.c @@ -23,7 +23,8 @@ static struct clk *mxc_per_clk; static struct clk *mxc_ipg_clk; /* workaround ENGcm09152 for i.MX35 */ -#define USBPHYCTRL_OTGBASE_OFFSET 0x608 +#define MX35_USBPHYCTRL_OFFSET 0x600 +#define USBPHYCTRL_OTGBASE_OFFSET 0x8 #define USBPHYCTRL_EVDO (1 << 23) int fsl_udc_clk_init(enum fsl_udc_type devtype, struct platform_device *pdev) @@ -77,28 +78,42 @@ eclkrate: return ret; } -void fsl_udc_clk_finalize(enum fsl_udc_type devtype, +int fsl_udc_clk_finalize(enum fsl_udc_type devtype, struct platform_device *pdev) { struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data; + int ret = 0; + if (devtype == IMX35_UDC) { unsigned int v; + struct resource *res = platform_get_resource + (pdev, IORESOURCE_MEM, 0); + void __iomem *phy_regs = ioremap(res->start + + MX35_USBPHYCTRL_OFFSET, 512); + if (!phy_regs) { + dev_err(&pdev->dev, "ioremap for phy address fails\n"); + ret = -EINVAL; + goto ioremap_err; + } /* workaround ENGcm09152 for i.MX35 */ if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) { - v = readl(MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + - USBPHYCTRL_OTGBASE_OFFSET)); + v = readl(phy_regs + USBPHYCTRL_OTGBASE_OFFSET); writel(v | USBPHYCTRL_EVDO, - MX35_IO_ADDRESS(MX35_USB_BASE_ADDR + - USBPHYCTRL_OTGBASE_OFFSET)); + phy_regs + USBPHYCTRL_OTGBASE_OFFSET); } + + iounmap(phy_regs); } +ioremap_err: /* ULPI transceivers don't need usbpll */ if (pdata->phy_mode == FSL_USB2_PHY_ULPI) { clk_disable_unprepare(mxc_per_clk); mxc_per_clk = NULL; } + + return ret; } void fsl_udc_clk_release(void) diff --git a/drivers/usb/gadget/fsl_udc_core.c b/drivers/usb/gadget/fsl_udc_core.c index c32119b..4391d49 100644 --- a/drivers/usb/gadget/fsl_udc_core.c +++ b/drivers/usb/gadget/fsl_udc_core.c @@ -2544,7 +2544,9 @@ static int __init fsl_udc_probe(struct platform_device *pdev) dr_controller_setup(udc_controller); } - fsl_udc_clk_finalize(udc_controller->devtype, pdev); + ret = fsl_udc_clk_finalize(udc_controller->devtype, pdev); + if (ret) + goto err_free_irq; /* Setup gadget structure */ udc_controller->gadget.ops = &fsl_gadget_ops; diff --git a/drivers/usb/gadget/fsl_usb2_udc.h b/drivers/usb/gadget/fsl_usb2_udc.h index bc1f6d0..7ead5f7 100644 --- a/drivers/usb/gadget/fsl_usb2_udc.h +++ b/drivers/usb/gadget/fsl_usb2_udc.h @@ -594,7 +594,7 @@ static inline struct ep_queue_head *get_qh_by_ep(struct fsl_ep *ep) struct platform_device; #ifdef CONFIG_ARCH_MXC int fsl_udc_clk_init(enum fsl_udc_type devtype, struct platform_device *pdev); -void fsl_udc_clk_finalize(enum fsl_udc_type devtype, +int fsl_udc_clk_finalize(enum fsl_udc_type devtype, struct platform_device *pdev); void fsl_udc_clk_release(void); #else @@ -603,7 +603,7 @@ static inline int fsl_udc_clk_init(enum fsl_udc_type devtype, { return 0; } -static inline void fsl_udc_clk_finalize(enum fsl_udc_type devtype, +static inline int fsl_udc_clk_finalize(enum fsl_udc_type devtype, struct platform_device *pdev) { }