linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kishon Vijay Abraham I <kishon@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <kishon@ti.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 21/22] phy: exynos-dp-video: Use syscon support to control pmu register
Date: Wed, 24 Sep 2014 19:17:19 +0530	[thread overview]
Message-ID: <1411566440-19169-22-git-send-email-kishon@ti.com> (raw)
In-Reply-To: <1411566440-19169-1-git-send-email-kishon@ti.com>

From: Vivek Gautam <gautam.vivek@samsung.com>

Currently the DP_PHY_ENABLE register is mapped in the driver,
and accessed to control power to the PHY.
With mfd-syscon and regmap interface available at our disposal,
it's wise to use that instead of using a 'reg' property for the
controller and allocating a memory resource for that.

To facilitate this, we have added another compatible string
for Exynso5420 SoC to acquire driver data which contains
different DP-PHY-CONTROL register offset.

Signed-off-by: Vivek Gautam <gautam.vivek@samsung.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
---
 .../devicetree/bindings/phy/samsung-phy.txt        |    7 +-
 drivers/phy/phy-exynos-dp-video.c                  |   79 +++++++++++++-------
 2 files changed, 59 insertions(+), 27 deletions(-)

diff --git a/Documentation/devicetree/bindings/phy/samsung-phy.txt b/Documentation/devicetree/bindings/phy/samsung-phy.txt
index 7a6feea..15e0f2c 100644
--- a/Documentation/devicetree/bindings/phy/samsung-phy.txt
+++ b/Documentation/devicetree/bindings/phy/samsung-phy.txt
@@ -17,8 +17,11 @@ Samsung EXYNOS SoC series Display Port PHY
 -------------------------------------------------
 
 Required properties:
-- compatible : should be "samsung,exynos5250-dp-video-phy";
-- reg : offset and length of the Display Port PHY register set;
+- compatible : should be one of the following supported values:
+	 - "samsung,exynos5250-dp-video-phy"
+	 - "samsung,exynos5420-dp-video-phy"
+- samsung,pmu-syscon: phandle for PMU system controller interface, used to
+		      control pmu registers for power isolation.
 - #phy-cells : from the generic PHY bindings, must be 0;
 
 Samsung S5P/EXYNOS SoC series USB PHY
diff --git a/drivers/phy/phy-exynos-dp-video.c b/drivers/phy/phy-exynos-dp-video.c
index 8b3026e..53f44a0 100644
--- a/drivers/phy/phy-exynos-dp-video.c
+++ b/drivers/phy/phy-exynos-dp-video.c
@@ -13,44 +13,55 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/exynos5-pmu.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/phy/phy.h>
 #include <linux/platform_device.h>
+#include <linux/regmap.h>
 
-/* DPTX_PHY_CONTROL register */
-#define EXYNOS_DPTX_PHY_ENABLE		(1 << 0)
+struct exynos_dp_video_phy_drvdata {
+	u32 phy_ctrl_offset;
+};
 
 struct exynos_dp_video_phy {
-	void __iomem *regs;
+	struct regmap *regs;
+	const struct exynos_dp_video_phy_drvdata *drvdata;
 };
 
-static int __set_phy_state(struct exynos_dp_video_phy *state, unsigned int on)
+static void exynos_dp_video_phy_pwr_isol(struct exynos_dp_video_phy *state,
+							unsigned int on)
 {
-	u32 reg;
+	unsigned int val;
+
+	if (IS_ERR(state->regs))
+		return;
 
-	reg = readl(state->regs);
-	if (on)
-		reg |= EXYNOS_DPTX_PHY_ENABLE;
-	else
-		reg &= ~EXYNOS_DPTX_PHY_ENABLE;
-	writel(reg, state->regs);
+	val = on ? 0 : EXYNOS5_PHY_ENABLE;
 
-	return 0;
+	regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
+			   EXYNOS5_PHY_ENABLE, val);
 }
 
 static int exynos_dp_video_phy_power_on(struct phy *phy)
 {
 	struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
 
-	return __set_phy_state(state, 1);
+	/* Disable power isolation on DP-PHY */
+	exynos_dp_video_phy_pwr_isol(state, 0);
+
+	return 0;
 }
 
 static int exynos_dp_video_phy_power_off(struct phy *phy)
 {
 	struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
 
-	return __set_phy_state(state, 0);
+	/* Enable power isolation on DP-PHY */
+	exynos_dp_video_phy_pwr_isol(state, 1);
+
+	return 0;
 }
 
 static struct phy_ops exynos_dp_video_phy_ops = {
@@ -59,11 +70,31 @@ static struct phy_ops exynos_dp_video_phy_ops = {
 	.owner		= THIS_MODULE,
 };
 
+static const struct exynos_dp_video_phy_drvdata exynos5250_dp_video_phy = {
+	.phy_ctrl_offset	= EXYNOS5_DPTX_PHY_CONTROL,
+};
+
+static const struct exynos_dp_video_phy_drvdata exynos5420_dp_video_phy = {
+	.phy_ctrl_offset	= EXYNOS5420_DPTX_PHY_CONTROL,
+};
+
+static const struct of_device_id exynos_dp_video_phy_of_match[] = {
+	{
+		.compatible = "samsung,exynos5250-dp-video-phy",
+		.data = &exynos5250_dp_video_phy,
+	}, {
+		.compatible = "samsung,exynos5420-dp-video-phy",
+		.data = &exynos5420_dp_video_phy,
+	},
+	{ },
+};
+MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
+
 static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 {
 	struct exynos_dp_video_phy *state;
 	struct device *dev = &pdev->dev;
-	struct resource *res;
+	const struct of_device_id *match;
 	struct phy_provider *phy_provider;
 	struct phy *phy;
 
@@ -71,11 +102,15 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 	if (!state)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-
-	state->regs = devm_ioremap_resource(dev, res);
-	if (IS_ERR(state->regs))
+	state->regs = syscon_regmap_lookup_by_phandle(dev->of_node,
+						      "samsung,pmu-syscon");
+	if (IS_ERR(state->regs)) {
+		dev_err(dev, "Failed to lookup PMU regmap\n");
 		return PTR_ERR(state->regs);
+	}
+
+	match = of_match_node(exynos_dp_video_phy_of_match, dev->of_node);
+	state->drvdata = match->data;
 
 	phy = devm_phy_create(dev, NULL, &exynos_dp_video_phy_ops, NULL);
 	if (IS_ERR(phy)) {
@@ -89,12 +124,6 @@ static int exynos_dp_video_phy_probe(struct platform_device *pdev)
 	return PTR_ERR_OR_ZERO(phy_provider);
 }
 
-static const struct of_device_id exynos_dp_video_phy_of_match[] = {
-	{ .compatible = "samsung,exynos5250-dp-video-phy" },
-	{ },
-};
-MODULE_DEVICE_TABLE(of, exynos_dp_video_phy_of_match);
-
 static struct platform_driver exynos_dp_video_phy_driver = {
 	.probe	= exynos_dp_video_phy_probe,
 	.driver = {
-- 
1.7.9.5


  parent reply	other threads:[~2014-09-24 13:48 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 13:46 [GIT PULL 00/22] PHY: for 3.18 Kishon Vijay Abraham I
2014-09-24 13:46 ` [PATCH 01/22] phy: Renesas R-Car Gen2 PHY driver Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 02/22] phy: phy-omap-control: Remove unncessary site specific OOM messages Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 03/22] phy: phy-mvebu-sata: Add missing error check for devm_kzalloc Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 04/22] phy: phy-omap-usb2: Remove unncessary site specific OOM messages Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 05/22] phy: phy-ti-pipe3: " Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 06/22] phy: phy-spear1310-miphy: " Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 07/22] phy: phy-spear1340-miphy: " Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 08/22] phy: phy-spear1310-miphy: Use module_platform_driver to register driver Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 09/22] phy: phy-spear1340-miphy: " Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 10/22] usb: phy: twl4030-usb: Remove unused irq_enabled Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 11/22] usb: phy: twl4030-usb: Simplify phy init to use runtime PM Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 12/22] usb: phy: twl4030-usb: Move code from twl4030_phy_power to the runtime PM calls Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 13/22] usb: phy: twl4030-usb: Remove asleep and rely on runtime PM Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 14/22] usb: phy: twl4030-usb: Use mutex instead of spinlock for protecting the data Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 15/22] phy: phy-stih407-usb: Add usb picoPHY driver found on stih407 SoC family Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 16/22] phy: phy-stih407-usb: Add dt documentation for USB picophy " Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 17/22] MAINTAINERS: Add phy-stih407-usb.c file to ARCH/STI architecture Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 18/22] phy: phy-stih41x-usb: Add usb phy support for STiH41x SoCs Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 19/22] phy: phy-stih41x-usb: Add dt documentation for USB phy on STiH415/6 Kishon Vijay Abraham I
2014-09-24 13:47 ` [PATCH 20/22] MAINTAINERS: Add phy-stih41x-usb.c to ARCH/STI architecture Kishon Vijay Abraham I
2014-09-24 13:47 ` Kishon Vijay Abraham I [this message]
2014-09-24 13:47 ` [PATCH 22/22] phy: remove .owner field for drivers using module_platform_driver Kishon Vijay Abraham I
2014-09-25 12:17 ` [GIT PULL 00/22] PHY: for 3.18 Greg KH
2014-09-25 12:29   ` Kishon Vijay Abraham I

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=1411566440-19169-22-git-send-email-kishon@ti.com \
    --to=kishon@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.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).