devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Gautam <gautam.vivek@samsung.com>
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
Cc: a.kesavan@samsung.com, yulgon.kim@samsung.com,
	boyko.lee@samsung.com, av.tikhomirov@samsung.com,
	joshi@samsung.com, olofj@google.com, prashanth.g@samsung.com
Subject: [PATCH 1/8] EXYNOS4: USB: Generalising setup-usb-phy driver for exynos
Date: Wed, 18 Jul 2012 19:15:21 +0530	[thread overview]
Message-ID: <1342619128-25013-2-git-send-email-gautam.vivek@samsung.com> (raw)
In-Reply-To: <1342619128-25013-1-git-send-email-gautam.vivek@samsung.com>

This patch updates the setup-usb-phy in order to accomodate
exynos5 support later.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>

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);
-- 
1.7.0.4

  reply	other threads:[~2012-07-18 13:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 13:45 [PATCH 0/8] EXYNOS5: USB: Add USB 2.0 and USB 3.0 support for exynos5 Vivek Gautam
2012-07-18 13:45 ` Vivek Gautam [this message]
2012-07-19  4:23   ` [PATCH 1/8] EXYNOS4: USB: Generalising setup-usb-phy driver for exynos Pankaj Jangra
2012-07-18 13:45 ` [PATCH 2/8] ARM: EXYNOS5: Add machine data for USB 2.0 Vivek Gautam
2012-07-18 13:45 ` [PATCH 3/8] ARM: EXYNOS5: Add OHCI device from device tree Vivek Gautam
2012-07-19  4:06   ` Sachin Kamat
2012-07-18 13:45 ` [PATCH 4/8] ARM: EXYNOS5: Add EHCI " Vivek Gautam
2012-07-18 13:45 ` [PATCH 5/8] ARM: EXYNOS5: Add PHY initialization code for usb 2.0 Vivek Gautam
2012-07-18 13:45 ` [PATCH 6/8] ARM: EXYNOS5: Add machine data for USB3.0 Vivek Gautam
2012-07-18 13:45 ` [PATCH 7/8] ARM: EXYNOS5: Add XHCI device from device tree Vivek Gautam
2012-07-18 13:45 ` [PATCH 8/8] ARM: EXYNOS5: Add PHY initialization code for usb 3.0 Vivek Gautam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342619128-25013-2-git-send-email-gautam.vivek@samsung.com \
    --to=gautam.vivek@samsung.com \
    --cc=a.kesavan@samsung.com \
    --cc=av.tikhomirov@samsung.com \
    --cc=boyko.lee@samsung.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=joshi@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=l.majewski@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=olofj@google.com \
    --cc=prashanth.g@samsung.com \
    --cc=thomas.abraham@linaro.org \
    --cc=yulgon.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).