From patchwork Wed Jul 18 13:45:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivek Gautam X-Patchwork-Id: 1210961 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 EF4463FCFC for ; Wed, 18 Jul 2012 13:38:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrUMv-0008UX-Uq; Wed, 18 Jul 2012 13:32:46 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SrULJ-0008PC-7z for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2012 13:31:12 +0000 Received: from epcpsbgm2.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M7C00LWOYVBJBE0@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2012 22:30:55 +0900 (KST) X-AuditID: cbfee61b-b7f566d000005c8a-3f-5006ba8fcd4e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id FE.3D.23690.F8AB6005; Wed, 18 Jul 2012 22:30:55 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M7C00MXCYV9WD70@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 18 Jul 2012 22:30:55 +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] EXYNOS4: USB: Generalising setup-usb-phy driver for exynos Date: Wed, 18 Jul 2012 19:15:21 +0530 Message-id: <1342619128-25013-2-git-send-email-gautam.vivek@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1342619128-25013-1-git-send-email-gautam.vivek@samsung.com> References: <1342619128-25013-1-git-send-email-gautam.vivek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCJMWRmVeSWpSXmKPExsVy+t9jQd3+XWwBBtsOylpsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6MbTufMhdcEq3o3riWpYHxpGAXIyeHhICJRPORt8wQtpjEhXvr 2boYuTiEBKYzSjx9/ZARwtnAJLHheS8TSBWbgK5E09tdYAkRga+MEie/rmMGcZgFljJKbN3Z ygZSJSzgL7H/TCsLiM0ioCqx8vBusDivgIfEt3dtUPsUJFqXHWIHsTkFPCWuztgIFhcCqnk9 YyrzBEbeBYwMqxhFUwuSC4qT0nON9IoTc4tL89L1kvNzNzGC/f5MegfjqgaLQ4wCHIxKPLwR wHAQYk0sK67MPcQowcGsJMLrvw0oxJuSWFmVWpQfX1Sak1p8iFGag0VJnNfE+6u/kEB6Yklq dmpqQWoRTJaJg1OqgZGT8/ORu4d39v1SDnwafqhk3nG3E6e/vj7jZZ/sFV8hcH7XjwM21Yau 0mdfuTp3ca4tu/3n9+J5O+/Pf2VV88n4aNRV3SaeiBecG/99UYuYHO/68cO34v9XbyesOXK7 4PiflkdOy18WT9ijpF85/cikrTtKV+Z3ndmY9I37vd2DDpu3jZMfnfhyUYmlOCPRUIu5qDgR AEzKSmT3AQAA 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.24 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 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 diff --git a/arch/arm/mach-exynos/setup-usb-phy.c b/arch/arm/mach-exynos/setup-usb-phy.c index b81cc56..bfc1367 100644 --- a/arch/arm/mach-exynos/setup-usb-phy.c +++ b/arch/arm/mach-exynos/setup-usb-phy.c @@ -26,10 +26,31 @@ 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) +struct clk *exynos_usb_clock_enable(struct platform_device *pdev) +{ + struct clk *usb_clk = NULL; + int err = 0; + + if (!usb_clk) { + 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 +101,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 +142,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 +186,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);