linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: peter.chen@freescale.com (Peter Chen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] usb: mxs-phy: Change mxs phy clock usage
Date: Thu, 10 Jan 2013 16:35:52 +0800	[thread overview]
Message-ID: <1357806954-27960-2-git-send-email-peter.chen@freescale.com> (raw)
In-Reply-To: <1357806954-27960-1-git-send-email-peter.chen@freescale.com>

As we mark mxs-phy as dummy clock for i.mx6q, we only need to
enable it at probe, this clock doesn't need to be managed
by clock framework.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/otg/mxs-phy.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/otg/mxs-phy.c b/drivers/usb/otg/mxs-phy.c
index 7630272..7dca384 100644
--- a/drivers/usb/otg/mxs-phy.c
+++ b/drivers/usb/otg/mxs-phy.c
@@ -20,6 +20,9 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #define DRIVER_NAME "mxs_phy"
 
@@ -108,6 +111,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	void __iomem *base;
 	struct clk *clk;
 	struct mxs_phy *mxs_phy;
+	struct regmap *anatop;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!res) {
@@ -146,6 +150,46 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, &mxs_phy->phy);
 
+	/*
+	 * At mx6x, USB PHY PLL and its output gate is controlled by hardware.
+	 * It just needs to open at init, if the usb device is
+	 * in suspend, it will close related PLL automatically.
+	 */
+
+	anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop");
+
+#define CTRL_SET				0x4
+#define CTRL_CLR				0x8
+
+#define BM_ANADIG_USB_PLL_480_CTRL_BYPASS		(1 << 16)
+#define BM_ANADIG_USB_PLL_480_CTRL_ENABLE		(1 << 13)
+#define BM_ANADIG_USB_PLL_480_CTRL_POWER		(1 << 12)
+#define BM_ANADIG_USB_PLL_480_CTRL_EN_USB_CLKS		(1 << 6)
+
+	if (!IS_ERR(anatop)) {
+		struct device *dev = &pdev->dev;
+		struct device_node *np = dev->of_node;
+		u32 phy_reg_offset;
+		int ret;
+
+		ret = of_property_read_u32(np, "anatop-phy-reg-offset",
+					   &phy_reg_offset);
+		if (ret) {
+			dev_err(dev, "no anatop-phy-reg-offset property set\n");
+			return -EINVAL;
+		}
+
+		regmap_write(anatop, phy_reg_offset + 0x8,
+				BM_ANADIG_USB_PLL_480_CTRL_BYPASS);
+		regmap_write(anatop, phy_reg_offset + 0x4,
+				BM_ANADIG_USB_PLL_480_CTRL_ENABLE
+				| BM_ANADIG_USB_PLL_480_CTRL_POWER
+				| BM_ANADIG_USB_PLL_480_CTRL_EN_USB_CLKS);
+
+	} else {
+		pr_warn("failed to find fsl,imx6q-anatop regmap\n");
+	}
+
 	return 0;
 }
 
-- 
1.7.0.4

  reply	other threads:[~2013-01-10  8:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10  8:35 [PATCH 1/4] ARM: dts: mxs-phy: Change mxs phy clock usage Peter Chen
2013-01-10  8:35 ` Peter Chen [this message]
2013-01-10  8:35 ` [PATCH 3/4] usb: mxs-phy: add set_suspend API Peter Chen
2013-01-10  8:35 ` [PATCH 4/4] usb: chipidea: imx: Add system suspend/resume API Peter Chen
2013-01-11  2:25 ` [PATCH 1/4] ARM: dts: mxs-phy: Change mxs phy clock usage Shawn Guo
2013-01-11  3:06   ` Chen Peter-B29397

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=1357806954-27960-2-git-send-email-peter.chen@freescale.com \
    --to=peter.chen@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).