Skip to contentSkip to conversation

rtc: omap: Add support for regulator supply

PATCH Superseded Lokesh Vutla 4 participants 15 messages Oct 24, 2014 – Oct 28, 2014

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover rtc: omap: Add support for regulator supply

This series adds support for regulator supply.

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 at 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 |  3 +++
 drivers/rtc/Kconfig                                |  6 ++---
 drivers/rtc/rtc-omap.c                             | 30 +++++++++++++++++++---
 3 files changed, 33 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/3 rtc: omap: use module_platform_driver

module_platform_driver_probe() prevents driver from requesting probe deferral. So using module_platform_drive() to support probe deferral.
And also removing .owner field which is set by module_platform_driver.

---
 drivers/rtc/rtc-omap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-omap.c +3 -3
index e74750f..d9bb5e7 100644
@@ -477,7 +477,7 @@ static const struct of_device_id omap_rtc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
 
-static int __init omap_rtc_probe(struct platform_device *pdev)
+static int omap_rtc_probe(struct platform_device *pdev)
 {
 	struct omap_rtc	*rtc;
 	struct resource	*res;
@@ -708,18 +708,18 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
 }
 
 static struct platform_driver omap_rtc_driver = {
+	.probe		= omap_rtc_probe,
 	.remove		= __exit_p(omap_rtc_remove),
 	.shutdown	= omap_rtc_shutdown,
 	.driver		= {
 		.name	= "omap_rtc",
-		.owner	= THIS_MODULE,
 		.pm	= &omap_rtc_pm_ops,
 		.of_match_table = omap_rtc_of_match,
 	},
 	.id_table	= omap_rtc_id_table,
 };
 
-module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe);
+module_platform_driver(omap_rtc_driver);
 
 MODULE_ALIAS("platform:omap_rtc");
 MODULE_AUTHOR("George G. Davis (and others)");
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/3 rtc: omap: use module_platform_driver

Quoted 5 lines · Lokesh Vutla

module_platform_driver_probe() prevents driver from requesting probe deferral. So using module_platform_drive() to support probe deferral.
And also removing .owner field which is set by module_platform_driver.

Quoted 38 lines
---
 drivers/rtc/rtc-omap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-omap.c +3 -3
index e74750f..d9bb5e7 100644
@@ -477,7 +477,7 @@ static const struct of_device_id omap_rtc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
 
-static int __init omap_rtc_probe(struct platform_device *pdev)
+static int omap_rtc_probe(struct platform_device *pdev)
 {
 	struct omap_rtc	*rtc;
 	struct resource	*res;
@@ -708,18 +708,18 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
 }
 
 static struct platform_driver omap_rtc_driver = {
+	.probe		= omap_rtc_probe,
 	.remove		= __exit_p(omap_rtc_remove),
 	.shutdown	= omap_rtc_shutdown,
 	.driver		= {
 		.name	= "omap_rtc",
-		.owner	= THIS_MODULE,
 		.pm	= &omap_rtc_pm_ops,
 		.of_match_table = omap_rtc_of_match,
 	},
 	.id_table	= omap_rtc_id_table,
 };
 
-module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe);
+module_platform_driver(omap_rtc_driver);
 
 MODULE_ALIAS("platform:omap_rtc");
 MODULE_AUTHOR("George G. Davis (and others)");
#3 lore raw

PATCH v3 1/3 rtc: omap: use module_platform_driver

In reply to Lokesh Vutla
Quoted 5 lines · Lokesh Vutla

module_platform_driver_probe() prevents driver from requesting probe deferral. So using module_platform_drive() to support probe deferral.
And also removing .owner field which is set by module_platform_driver.

Quoted 41 lines
---
 drivers/rtc/rtc-omap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-omap.c +3 -3
index e74750f..d9bb5e7 100644
@@ -477,7 +477,7 @@ static const struct of_device_id omap_rtc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, omap_rtc_of_match);
 
-static int __init omap_rtc_probe(struct platform_device *pdev)
+static int omap_rtc_probe(struct platform_device *pdev)
 {
 	struct omap_rtc	*rtc;
 	struct resource	*res;
@@ -708,18 +708,18 @@ static void omap_rtc_shutdown(struct platform_device *pdev)
 }
 
 static struct platform_driver omap_rtc_driver = {
+	.probe		= omap_rtc_probe,
 	.remove		= __exit_p(omap_rtc_remove),
 	.shutdown	= omap_rtc_shutdown,
 	.driver		= {
 		.name	= "omap_rtc",
-		.owner	= THIS_MODULE,
 		.pm	= &omap_rtc_pm_ops,
 		.of_match_table = omap_rtc_of_match,
 	},
 	.id_table	= omap_rtc_id_table,
 };
 
-module_platform_driver_probe(omap_rtc_driver, omap_rtc_probe);
+module_platform_driver(omap_rtc_driver);
 
 MODULE_ALIAS("platform:omap_rtc");
 MODULE_AUTHOR("George G. Davis (and others)");
Signature · 1 line
1.9.1
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141024/6d30b913/attachment.sig>
#4 lore raw

PATCH v3 2/3 rtc: omap: Update Kconfig for OMAP RTC

In reply to Lokesh Vutla

From: Tero Kristo <[email protected]>

RTC is present in AM43xx and DRA7xx also. Updating the Kconfig to depend on ARCH_OMAP or ARCH_DAVINCI

---
 drivers/rtc/Kconfig | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/Kconfig +3 -3
index 94ae179..8dfcb1b 100644
@@ -1001,11 +1001,11 @@ config RTC_DRV_IMXDI
 	   will be called "rtc-imxdi".
 
 config RTC_DRV_OMAP
-	tristate "TI OMAP1"
-	depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX || SOC_AM33XX
+	tristate "TI OMAP Real Time Clock"
+	depends on ARCH_OMAP || ARCH_DAVINCI
 	help
 	  Say "yes" here to support the on chip real time clock
-	  present on TI OMAP1, AM33xx and DA8xx/OMAP-L13x.
+	  present on TI OMAP1, AM33xx, DA8xx/OMAP-L13x, AM43xx and DRA7xx.
 
 	  This driver can also be built as a module, if so, module
 	  will be called rtc-omap.
Signature · 1 line
1.9.1
#5 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

In reply to Lokesh Vutla

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.

---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +3 -0
index 750efd4..e7ad12b 100644
@@ -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 at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +24 -0
index d9bb5e7..61fe630 100644
@@ -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;
 }
 
Signature · 1 line
1.9.1
#6 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

Quoted 15 lines · Lokesh Vutla

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.

---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +0 -0
index 750efd4..e7ad12b 100644

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
@@ -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:

No need to repeat the "Optional Properties" header.

Quoted 31 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +2 -0
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +27,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +2 -0
index d9bb5e7..61fe630 100644
@@ -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)

drivers/rtc/rtc-omap.c static int omap_rtc_probe(struct platform_device *pdev) · line 519

Quoted 2 lines
drivers/rtc/rtc-omap.c +0 -0
@@ -516,6 +518,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rtc);

Also could you move the regulator allocation before this platform_set_drvdata when resending? It's not required, but that call sort of separates the allocations from the device initialisation currently.

Quoted 30 lines
drivers/rtc/rtc-omap.c +19 -0
+	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;
 }
 

drivers/rtc/rtc-omap.c static int __exit omap_rtc_remove(struct platform_device *pdev) · line 677

Quoted 8 lines
drivers/rtc/rtc-omap.c +3 -0
@@ -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;
 }

Looks good otherwise. Feel free to add

Thanks,
Johan

#7 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

Quoted 11 lines · Johan Hovold
Quoted 10 lines · Lokesh Vutla

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.

---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Quoted 11 lines

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 18

Quoted 9 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
index 750efd4..e7ad12b 100644
@@ -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:

No need to repeat the "Optional Properties" header.

Oops sorry. will remove it.

Quoted 33 lines
Quoted 33 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +2 -0
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +27,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +2 -0
index d9bb5e7..61fe630 100644
@@ -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)
 
Quoted 6 lines

drivers/rtc/rtc-omap.c static int omap_rtc_probe(struct platform_device *pdev) · line 519

Quoted 1 line
drivers/rtc/rtc-omap.c +0 -0
 	platform_set_drvdata(pdev, rtc);

Also could you move the regulator allocation before this platform_set_drvdata when resending? It's not required, but that call sort of separates the allocations from the device initialisation currently.

Okay.

Thanks and regards,
Lokesh

Quoted 47 lines
Quoted 31 lines
drivers/rtc/rtc-omap.c +19 -0
+	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;
 }
 

drivers/rtc/rtc-omap.c static int __exit omap_rtc_remove(struct platform_device *pdev) · line 677

Quoted 8 lines
drivers/rtc/rtc-omap.c +3 -0
@@ -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;
 }

Looks good otherwise. Feel free to add

Thanks,
Johan

#8 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

In reply to Johan Hovold

Hi,

Quoted 103 lines · Johan Hovold
Quoted 15 lines · Lokesh Vutla

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.

---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +0 -0
index 750efd4..e7ad12b 100644

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
@@ -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:

No need to repeat the "Optional Properties" header.

Quoted 31 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +2 -0
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +27,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +2 -0
index d9bb5e7..61fe630 100644
@@ -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)

drivers/rtc/rtc-omap.c static int omap_rtc_probe(struct platform_device *pdev) · line 519

Quoted 2 lines
drivers/rtc/rtc-omap.c +0 -0
@@ -516,6 +518,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rtc);

Also could you move the regulator allocation before this platform_set_drvdata when resending? It's not required, but that call sort of separates the allocations from the device initialisation currently.

Quoted 30 lines
drivers/rtc/rtc-omap.c +19 -0
+	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;
 }
 

drivers/rtc/rtc-omap.c static int __exit omap_rtc_remove(struct platform_device *pdev) · line 677

Quoted 8 lines
drivers/rtc/rtc-omap.c +3 -0
@@ -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;
 }

Looks good otherwise. Feel free to add

Quoted 1 line

Conditional on Johan's comments:

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141024/bb81654e/attachment.sig>
#9 lore raw

PATCH v4 3/3 rtc: omap: Support regulator supply for RTC

In reply to Lokesh Vutla

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.

---
Changes since v3:
- Removed extra Optional properties header.
- Moved regulator get before platform_set_drvdatai() as suggested by Johan

 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  2 ++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +2 -0
index 750efd4..42ff41f 100644
@@ -15,6 +15,7 @@ Required properties:
 Optional properties:
 - ti,system-power-controller: whether the rtc is controlling the system power
   through pmic_power_en
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +26,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +24 -0
index d9bb5e7..7f1b527 100644
@@ -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)
@@ -514,6 +516,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->base))
 		return PTR_ERR(rtc->base);
 
+	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;
+		}
+	}
+
 	platform_set_drvdata(pdev, rtc);
 
 	/* Enable the clock/module so that we can access the registers */
@@ -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;
 }
 
Signature · 1 line
1.9.1
#10 lore raw

PATCH v4 3/3 rtc: omap: Support regulator supply for RTC

Quoted 6 lines · Lokesh Vutla

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.

oh sorry, there was already a new version:

Quoted 93 lines

---
Changes since v3:
- Removed extra Optional properties header.
- Moved regulator get before platform_set_drvdatai() as suggested by Johan

 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  2 ++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 26 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +2 -0
index 750efd4..42ff41f 100644
@@ -15,6 +15,7 @@ Required properties:
 Optional properties:
 - ti,system-power-controller: whether the rtc is controlling the system power
   through pmic_power_en
+- vrtc-supply: phandle to the regulator device tree node if needed
 
 Example:
 
@@ -25,4 +26,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +24 -0
index d9bb5e7..7f1b527 100644
@@ -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)
@@ -514,6 +516,22 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->base))
 		return PTR_ERR(rtc->base);
 
+	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;
+		}
+	}
+
 	platform_set_drvdata(pdev, rtc);
 
 	/* Enable the clock/module so that we can access the registers */
@@ -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;
 }
 
Signature · 1 line
1.9.1
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141024/83b072f8/attachment-0001.sig>
#11 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

In reply to Lokesh Vutla
Quoted 1 line · Lokesh Vutla

On some Soc's RTC is powered by an external power regulator.

SoC ? -> could you rephrase this to indicate "certain SoCs such as DRA7, RTC is an independent voltage domain of it's own and on platforms such as DRA7-evm, this may be supplied by individual regulator on it's own.

Quoted 2 lines

e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a power regulator.

Question ofcourse is what voltage would you like that regulator to be at? As you are aware, certain LDOs and SMPS can drive varying voltage and just enable/disable would do just the default voltage of the SMPS/LDO, right? OR am i missing something here?

Quoted 12 lines
---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +0 -0
index 750efd4..e7ad12b 100644

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
@@ -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:

^^ already commented on..

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 19

Quoted 1 line
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
+- vrtc-supply: phandle to the regulator device tree node if needed

"phandle to supply regulator" ? since it is optional, "if needed" is redundant?

Quoted 35 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
 Example:
 
@@ -25,4 +27,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +4 -0
index d9bb5e7..61fe630 100644
@@ -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)) {

drivers/rtc/rtc-omap.c static int omap_rtc_probe(struct platform_device *pdev) · line 532

Quoted 10 lines
drivers/rtc/rtc-omap.c +10 -0
+		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");

would be nice to print the result as well - since it helps debug from log a little easier.

Signature · 2 lines
Regards,
Nishanth Menon
#12 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

Quoted 7 lines · Nishanth Menon
Quoted 1 line · Lokesh Vutla

On some Soc's RTC is powered by an external power regulator.

SoC ? -> could you rephrase this to indicate "certain SoCs such as DRA7, RTC is an independent voltage domain of it's own and on platforms such as DRA7-evm, this may be supplied by individual regulator on it's own.

Quoted 7 lines
Quoted 2 lines

e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a power regulator.

Question ofcourse is what voltage would you like that regulator to be at? As you are aware, certain LDOs and SMPS can drive varying voltage and just enable/disable would do just the default voltage of the SMPS/LDO, right? OR am i missing something here?

just pass the correct voltage through DTS as we do for all other regulators ? It's only tricky when we have a range of acceptable voltages but for RTC, IIRC, it's always a set voltage (1.0V or 1.8V).

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141024/9f6a78a9/attachment.sig>
#13 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

Quoted 11 lines · Felipe Balbi
Quoted 10 lines · Nishanth Menon
Quoted 1 line · Lokesh Vutla

On some Soc's RTC is powered by an external power regulator.

SoC ? -> could you rephrase this to indicate "certain SoCs such as DRA7, RTC is an independent voltage domain of it's own and on platforms such as DRA7-evm, this may be supplied by individual regulator on it's own.

Quoted 2 lines

e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a power regulator.

Quoted 9 lines
Quoted 4 lines

Question ofcourse is what voltage would you like that regulator to be at? As you are aware, certain LDOs and SMPS can drive varying voltage and just enable/disable would do just the default voltage of the SMPS/LDO, right? OR am i missing something here?

just pass the correct voltage through DTS as we do for all other regulators ? It's only tricky when we have a range of acceptable voltages but for RTC, IIRC, it's always a set voltage (1.0V or 1.8V).

you mean min=max=1.8V board constraint - sure it will work, except I might expect to see that in the example? OR expect the driver to explicitly set it.

Signature · 2 lines
Regards,
Nishanth Menon
#14 lore raw

PATCH v3 3/3 rtc: omap: Support regulator supply for RTC

In reply to Nishanth Menon
Quoted 6 lines · Nishanth Menon
Quoted 1 line · Lokesh Vutla

On some Soc's RTC is powered by an external power regulator.

SoC ? -> could you rephrase this to indicate "certain SoCs such as DRA7, RTC is an independent voltage domain of it's own and on platforms such as DRA7-evm, this may be supplied by individual regulator on it's own.

Ok. will do it.

Quoted 8 lines
Quoted 3 lines

e.g. RTC on DRA7 SoC. Make the OMAP RTC driver support a power regulator.

Question ofcourse is what voltage would you like that regulator to be at? As you are aware, certain LDOs and SMPS can drive varying voltage and just enable/disable would do just the default voltage of the SMPS/LDO, right? OR am i missing something here?

Yes I agree that enable/disable would just do the default voltage of SMPS/LDO. If default voltage needs to be changed, driver should explicitly call regulator_set_voltage. Currently this is missing. Ill update and repost it. Thanks for pointing it out.

Quoted 19 lines
Quoted 13 lines
---
 Documentation/devicetree/bindings/rtc/rtc-omap.txt |  3 +++
 drivers/rtc/rtc-omap.c                             | 24 ++++++++++++++++++++++
 2 files changed, 27 insertions(+)
Documentation/devicetree/bindings/rtc/rtc-omap.txt +0 -0
index 750efd4..e7ad12b 100644

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 18

Quoted 4 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
@@ -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:

^^ already commented on..

Quoted 4 lines

Documentation/devicetree/bindings/rtc/rtc-omap.txt Required properties: · line 19

Quoted 1 line
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
+- vrtc-supply: phandle to the regulator device tree node if needed

"phandle to supply regulator" ? since it is optional, "if needed" is redundant?

Okay. will update it in next version.

Quoted 34 lines
Quoted 34 lines
Documentation/devicetree/bindings/rtc/rtc-omap.txt +1 -0
 Example:
 
@@ -25,4 +27,5 @@ rtc at 1c23000 {
 		      19>;
 	interrupt-parent = <&intc>;
 	ti,system-power-controller;
+	vrtc-supply = <&ldo9_reg>;
 };
drivers/rtc/rtc-omap.c +2 -0
index d9bb5e7..61fe630 100644
@@ -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);
 
Quoted 15 lines

drivers/rtc/rtc-omap.c static int omap_rtc_probe(struct platform_device *pdev) · line 532

Quoted 12 lines
drivers/rtc/rtc-omap.c +12 -0
+	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");

would be nice to print the result as well - since it helps debug from log a little easier.

Will update it in next version.

Thanks and regards,
Lokesh

Quoted 3 lines