devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V4 0/3] rtc: omap: Add support for regulator supply
@ 2014-10-28  9:58 Lokesh Vutla
  2014-10-28  9:58 ` [PATCH V4 1/3] rtc: omap: use module_platform_driver Lokesh Vutla
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Lokesh Vutla @ 2014-10-28  9:58 UTC (permalink / raw)
  To: rtc-linux, linux-omap
  Cc: johan, tony, balbi, akpm, nsekhar, t-kristo, j-keerthy,
	linux-arm-kernel, devicetree, nm, lokeshvutla

This series adds support for regulator supply.

Changes since V3:
- Removed extra Optional properties header.
- Moved regulator get before platform_set_drvdata().
- Updated commit message for Patch 3/3.
- Added new dt properties for min and max voltages if default voltage needs to be changed.

Changes since v2:
 - Rebased on top of Johan Hovold's recent rtc cleanup series[1]
 - Addressed Johan Hovold's comments.

[1] https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg748519.html
Lokesh Vutla (2):
  rtc: omap: use module_platform_driver
  rtc: omap: Support regulator supply for RTC

Tero Kristo (1):
  rtc: omap: Update Kconfig for OMAP RTC

 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  6 +++
 drivers/rtc/Kconfig                                |  6 +--
 drivers/rtc/rtc-omap.c                             | 47 ++++++++++++++++++++--
 3 files changed, 52 insertions(+), 7 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 9+ messages in thread
* [PATCH V3 3/3] rtc: omap: Support regulator supply for RTC
@ 2014-10-24  4:53 Lokesh Vutla
  2014-10-24  8:07 ` [PATCH V4 " Lokesh Vutla
  0 siblings, 1 reply; 9+ messages in thread
From: Lokesh Vutla @ 2014-10-24  4:53 UTC (permalink / raw)
  To: rtc-linux, linux-omap, a.zummo, johan
  Cc: tony, bcousson, balbi, akpm, linux, nsekhar, t-kristo, j-keerthy,
	linux-arm-kernel, devicetree, lokeshvutla

On some Soc's RTC is powered by an external power regulator.
e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a
power regulator.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
index 750efd4..e7ad12b 100644
--- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt
+++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt
@@ -15,6 +15,8 @@ Required properties:
 Optional properties:
 - ti,system-power-controller: whether the rtc is controlling the system power
   through pmic_power_en
+Optional Properties:
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +27,5 @@ rtc@1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index d9bb5e7..61fe630 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -25,6 +25,7 @@
 #include <linux/of_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/io.h>
+#include <linux/regulator/consumer.h>
 
 /*
  * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock
@@ -134,6 +135,7 @@ struct omap_rtc {
 	u8 interrupts_reg;
 	bool is_pmic_controller;
 	const struct omap_rtc_device_type *type;
+	struct regulator *supply;
 };
 
 static inline u8 rtc_read(struct omap_rtc *rtc, unsigned int reg)
@@ -516,6 +518,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rtc);
 
+	rtc->supply = devm_regulator_get_optional(&pdev->dev, "vrtc");
+	if (IS_ERR(rtc->supply)) {
+		if (PTR_ERR(rtc->supply) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+
+		rtc->supply = NULL;
+	}
+
+	if (rtc->supply) {
+		ret = regulator_enable(rtc->supply);
+		if (ret) {
+			dev_err(&pdev->dev, "regulator enable failed\n");
+			return ret;
+		}
+	}
+
 	/* Enable the clock/module so that we can access the registers */
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_get_sync(&pdev->dev);
@@ -624,6 +642,9 @@ err:
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
+	if (rtc->supply)
+		regulator_disable(rtc->supply);
+
 	return ret;
 }
 
@@ -649,6 +670,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
+	if (rtc->supply)
+		regulator_disable(rtc->supply);
+
 	return 0;
 }
 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-10-28 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28  9:58 [PATCH V4 0/3] rtc: omap: Add support for regulator supply Lokesh Vutla
2014-10-28  9:58 ` [PATCH V4 1/3] rtc: omap: use module_platform_driver Lokesh Vutla
2014-10-28  9:58 ` [PATCH V4 2/3] rtc: omap: Update Kconfig for OMAP RTC Lokesh Vutla
2014-10-28  9:58 ` [PATCH V4 3/3] rtc: omap: Support regulator supply for RTC Lokesh Vutla
     [not found]   ` <1414490332-14856-4-git-send-email-lokeshvutla-l0cyMroinI0@public.gmane.org>
2014-10-28 14:02     ` Nishanth Menon
2014-10-28 15:01   ` Felipe Balbi
2014-10-28 15:11     ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2014-10-24  4:53 [PATCH V3 " Lokesh Vutla
2014-10-24  8:07 ` [PATCH V4 " Lokesh Vutla
2014-10-24 15:40   ` Felipe Balbi

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).