From patchwork Sat Jul 21 10:32:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 1223621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 01289DF24C for ; Sat, 21 Jul 2012 10:32:55 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SsWwm-0005O3-Uo; Sat, 21 Jul 2012 10:30:05 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SsWv6-0004pl-0v for linux-arm-kernel@lists.infradead.org; Sat, 21 Jul 2012 10:28:24 +0000 Received: from epcpsbgm2.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M7I006SD9WXPW10@mailout4.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 21 Jul 2012 19:17:24 +0900 (KST) X-AuditID: cbfee61b-b7f566d000005c8a-4a-500a81b49ded Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 16.C9.23690.4B18A005; Sat, 21 Jul 2012 19:17:24 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M7I000KP9WQC260@mmp1.samsung.com> for linux-arm-kernel@lists.infradead.org; Sat, 21 Jul 2012 19:17:24 +0900 (KST) From: Vivek Gautam To: kgene.kim@samsung.com, l.majewski@samsung.com, kyungmin.park@samsung.com, thomas.abraham@linaro.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org, m.szyprowski@samsung.com Subject: [PATCH 1/8 v2] EXYNOS4: USB: Generalising setup-usb-phy driver for exynos Date: Sat, 21 Jul 2012 16:02:02 +0530 Message-id: <1342866729-30460-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1342866729-30460-1-git-send-email-gautam.vivek@samsung.com> References: <1342866729-30460-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd0tjVwBBsee8lhsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6Mo2dmsBQcEKtoW3CeuYFxq1AXIyeHhICJxOk921kgbDGJC/fW s3UxcnEICSxilFi19z87hLOBSeLp+ZnsIFVsAroSTW93MYIkRAS+Mkqc/LqOGcRhFtjPKPHj 8icgh4NDWCBE4uvCZJAGFgFViVvrp4A18wp4SMz9epENYp2CROuyQ2BxTgFPiZ1TPzOB2EJA NadvNDJOYORdwMiwilE0tSC5oDgpPddIrzgxt7g0L10vOT93EyPY68+kdzCuarA4xCjAwajE w8uwjDNAiDWxrLgy9xCjBAezkgjv6zKuACHelMTKqtSi/Pii0pzU4kOM0hwsSuK8Jt5f/YUE 0hNLUrNTUwtSi2CyTBycUg2McWJF7xawbOIObU6R2OX8L2Pum2fa5XEerHPTuthsDv1mT+f5 r/T+xf727X3xVy1nG13Ql+OTqOO7yrDj0veTF/6fsV50LunlnIchnsGz/nlLKK97eyyPa2Pz vcqTdfdkFjbb1Vn6nLi7RV5KtV7QbHGJ6oV/NpbPTy157SFZIb05lGnz+UO1SizFGYmGWsxF xYkAHLffMfYBAAA= X-TM-AS-MML: No X-Spam-Note: CRM114 invocation failed X-Spam-Score: -6.9 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.34 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: yulgon.kim@samsung.com, av.tikhomirov@samsung.com, prashanth.g@samsung.com, boyko.lee@samsung.com, joshi@samsung.com, a.kesavan@samsung.com, olofj@google.com, ajaykumar.rs@samsung.com 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: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This patch updates the setup-usb-phy in order to accomodate exynos5 support later. Signed-off-by: Vivek Gautam --- arch/arm/mach-exynos/setup-usb-phy.c | 54 +++++++++++++++++---------------- 1 files changed, 28 insertions(+), 26 deletions(-) diff --git a/arch/arm/mach-exynos/setup-usb-phy.c b/arch/arm/mach-exynos/setup-usb-phy.c index b81cc56..1a4ea07 100644 --- a/arch/arm/mach-exynos/setup-usb-phy.c +++ b/arch/arm/mach-exynos/setup-usb-phy.c @@ -26,10 +26,29 @@ static int exynos4_usb_host_phy_is_on(void) return (readl(EXYNOS4_PHYPWR) & PHY1_STD_ANALOG_POWERDOWN) ? 0 : 1; } -static void exynos4210_usb_phy_clkset(struct platform_device *pdev) +static struct clk *exynos_usb_clock_enable(struct platform_device *pdev) +{ + struct clk *usb_clk = NULL; + int err = 0; + + usb_clk = clk_get(&pdev->dev, "otg"); + if (IS_ERR(usb_clk)) { + dev_err(&pdev->dev, "Failed to get otg clock\n"); + return NULL; + } + + err = clk_enable(usb_clk); + if (err) { + clk_put(usb_clk); + return NULL; + } + return usb_clk; +} + +static int exynos4210_usb_phy_clkset(struct platform_device *pdev) { struct clk *xusbxti_clk; - u32 phyclk; + u32 phyclk = 0; xusbxti_clk = clk_get(&pdev->dev, "xusbxti"); if (xusbxti_clk && !IS_ERR(xusbxti_clk)) { @@ -80,6 +99,7 @@ static void exynos4210_usb_phy_clkset(struct platform_device *pdev) } clk_put(xusbxti_clk); } + return phyclk; } static int exynos4210_usb_phy0_init(struct platform_device *pdev) @@ -120,21 +140,12 @@ static int exynos4210_usb_phy1_init(struct platform_device *pdev) { struct clk *otg_clk; u32 rstcon; - int err; atomic_inc(&host_usage); - otg_clk = clk_get(&pdev->dev, "otg"); - if (IS_ERR(otg_clk)) { - dev_err(&pdev->dev, "Failed to get otg clock\n"); - return PTR_ERR(otg_clk); - } - - err = clk_enable(otg_clk); - if (err) { - clk_put(otg_clk); - return err; - } + otg_clk = exynos_usb_clock_enable(pdev); + if (otg_clk == NULL) + dev_err(&pdev->dev, "Failed to enable otg clock\n"); if (exynos4_usb_host_phy_is_on()) return 0; @@ -173,22 +184,13 @@ static int exynos4210_usb_phy1_init(struct platform_device *pdev) static int exynos4210_usb_phy1_exit(struct platform_device *pdev) { struct clk *otg_clk; - int err; if (atomic_dec_return(&host_usage) > 0) return 0; - otg_clk = clk_get(&pdev->dev, "otg"); - if (IS_ERR(otg_clk)) { - dev_err(&pdev->dev, "Failed to get otg clock\n"); - return PTR_ERR(otg_clk); - } - - err = clk_enable(otg_clk); - if (err) { - clk_put(otg_clk); - return err; - } + otg_clk = exynos_usb_clock_enable(pdev); + if (otg_clk == NULL) + dev_err(&pdev->dev, "Failed to enable otg clock\n"); writel((readl(EXYNOS4_PHYPWR) | PHY1_STD_ANALOG_POWERDOWN), EXYNOS4_PHYPWR);