linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/7] add device tree support for mxc rtc
@ 2015-07-03 23:15 Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 1/7] imx31: add a second rtc clock Philippe Reynes
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

This serie add the device tree support for the mxc rtc driver.
To do this, three steps are required :
- define two rtc clocks for imx31 and imx35
- enhance mxc rtc driver to use two clocks (rtc and ipg)
- add device tree support to mxc rtc driver

Changelog:
v4: (thanks Alexandre Belloni)
- add prepare_clock for rtc clock
- split apf27: dt: enable support in two patches
v3: (thanks Fabio Estevam)
- fix typo in imx35 clock comment
v2: (thanks Shawn Guo and Alexandre Belloni)
- add a second clock to imx35
- split the add of clock in a separate patches
- split the dt documentation in a separate patch

Philippe Reynes (7):
  imx31: add a second rtc clock
  imx35: define two clocks for rtc
  rtc: mxc: use a second rtc clock
  rtc: mxc: add support of device tree
  dt-binding: document the binding for mxc rtc
  imx27: dt: add support of internal rtc
  apf27: dt: enable support of internal rtc

 Documentation/devicetree/bindings/rtc/rtc-mxc.txt |   27 +++++++++
 arch/arm/boot/dts/imx27-apf27.dts                 |    4 ++
 arch/arm/boot/dts/imx27.dtsi                      |   10 ++++
 drivers/clk/imx/clk-imx31.c                       |    3 +-
 drivers/clk/imx/clk-imx35.c                       |    6 ++-
 drivers/rtc/rtc-mxc.c                             |   60 ++++++++++++++++-----
 6 files changed, 94 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc.txt

-- 
1.7.4.4


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

* [PATCH v4 1/7] imx31: add a second rtc clock
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 2/7] imx35: define two clocks for rtc Philippe Reynes
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

The mxc rtc driver needs two clock.
It was defined only one clock, so we
define the second clock.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/clk/imx/clk-imx31.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/clk/imx/clk-imx31.c b/drivers/clk/imx/clk-imx31.c
index fe66c40..01da40d 100644
--- a/drivers/clk/imx/clk-imx31.c
+++ b/drivers/clk/imx/clk-imx31.c
@@ -147,7 +147,8 @@ int __init mx31_clocks_init(unsigned long fref)
 	clk_register_clkdev(clk[cspi3_gate], NULL, "imx31-cspi.2");
 	clk_register_clkdev(clk[pwm_gate], "pwm", NULL);
 	clk_register_clkdev(clk[wdog_gate], NULL, "imx2-wdt.0");
-	clk_register_clkdev(clk[rtc_gate], NULL, "imx21-rtc");
+	clk_register_clkdev(clk[ckil], "rtc", "imx21-rtc");
+	clk_register_clkdev(clk[rtc_gate], "ipg", "imx21-rtc");
 	clk_register_clkdev(clk[epit1_gate], "epit", NULL);
 	clk_register_clkdev(clk[epit2_gate], "epit", NULL);
 	clk_register_clkdev(clk[nfc], NULL, "imx27-nand.0");
-- 
1.7.4.4


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

* [PATCH v4 2/7] imx35: define two clocks for rtc
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 1/7] imx31: add a second rtc clock Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 3/7] rtc: mxc: use a second rtc clock Philippe Reynes
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

The imx35 don't define clocks for rtc.
This patch add two clocks, as needed
by the mxc rtc driver.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/clk/imx/clk-imx35.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/clk/imx/clk-imx35.c b/drivers/clk/imx/clk-imx35.c
index 69138ba..c5052b6 100644
--- a/drivers/clk/imx/clk-imx35.c
+++ b/drivers/clk/imx/clk-imx35.c
@@ -66,7 +66,7 @@ static const char *std_sel[] = {"ppll", "arm"};
 static const char *ipg_per_sel[] = {"ahb_per_div", "arm_per_div"};
 
 enum mx35_clks {
-	ckih, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
+	ckih, ckil, mpll, ppll, mpll_075, arm, hsp, hsp_div, hsp_sel, ahb, ipg,
 	arm_per_div, ahb_per_div, ipg_per, uart_sel, uart_div, esdhc_sel,
 	esdhc1_div, esdhc2_div, esdhc3_div, spdif_sel, spdif_div_pre,
 	spdif_div_post, ssi_sel, ssi1_div_pre, ssi1_div_post, ssi2_div_pre,
@@ -107,6 +107,7 @@ int __init mx35_clocks_init(void)
 	}
 
 	clk[ckih] = imx_clk_fixed("ckih", 24000000);
+	clk[ckil] = imx_clk_fixed("ckih", 32768);
 	clk[mpll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "mpll", "ckih", base + MX35_CCM_MPCTL);
 	clk[ppll] = imx_clk_pllv1(IMX_PLLV1_IMX35, "ppll", "ckih", base + MX35_CCM_PPCTL);
 
@@ -258,6 +259,9 @@ int __init mx35_clocks_init(void)
 	clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.1");
 	clk_register_clkdev(clk[uart3_gate], "per", "imx21-uart.2");
 	clk_register_clkdev(clk[ipg], "ipg", "imx21-uart.2");
+	/* i.mx35 has the i.mx21 type rtc */
+	clk_register_clkdev(clk[ckil], "rtc", "imx21-rtc");
+	clk_register_clkdev(clk[rtc_gate], "ipg", "imx21-rtc");
 	clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0");
 	clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0");
 	clk_register_clkdev(clk[usbotg_gate], "ahb", "mxc-ehci.0");
-- 
1.7.4.4


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

* [PATCH v4 3/7] rtc: mxc: use a second rtc clock
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 1/7] imx31: add a second rtc clock Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 2/7] imx35: define two clocks for rtc Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-14 21:49   ` [rtc-linux] " Alexandre Belloni
  2015-07-03 23:15 ` [PATCH v4 4/7] rtc: mxc: add support of device tree Philippe Reynes
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

The mxc RTC needs two clocks, one for the input
reference, and one for the IP. But this driver
was only using one clock (for the reference).
This patch add the second clock (for the IP).

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/rtc/rtc-mxc.c |   41 ++++++++++++++++++++++++++++-------------
 1 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 5fc292c..4ce7e21 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -79,7 +79,8 @@ struct rtc_plat_data {
 	struct rtc_device *rtc;
 	void __iomem *ioaddr;
 	int irq;
-	struct clk *clk;
+	struct clk *clk_rtc;
+	struct clk *clk_ipg;
 	struct rtc_time g_rtc_alarm;
 	enum imx_rtc_type devtype;
 };
@@ -373,17 +374,28 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(pdata->ioaddr))
 		return PTR_ERR(pdata->ioaddr);
 
-	pdata->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(pdata->clk)) {
-		dev_err(&pdev->dev, "unable to get clock!\n");
-		return PTR_ERR(pdata->clk);
+	pdata->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
+	if (IS_ERR(pdata->clk_ipg)) {
+		dev_err(&pdev->dev, "unable to get ipg clock!\n");
+		return PTR_ERR(pdata->clk_ipg);
 	}
 
-	ret = clk_prepare_enable(pdata->clk);
+	ret = clk_prepare_enable(pdata->clk_ipg);
 	if (ret)
 		return ret;
 
-	rate = clk_get_rate(pdata->clk);
+	pdata->clk_rtc = devm_clk_get(&pdev->dev, "rtc");
+	if (IS_ERR(pdata->clk_rtc)) {
+		dev_err(&pdev->dev, "unable to get rtc clock!\n");
+		ret = PTR_ERR(pdata->clk_rtc);
+		goto exit_put_clk_ipg;
+	}
+
+	ret = clk_prepare_enable(pdata->clk_rtc);
+	if (ret)
+		goto exit_put_clk_ipg;
+
+	rate = clk_get_rate(pdata->clk_rtc);
 
 	if (rate == 32768)
 		reg = RTC_INPUT_CLK_32768HZ;
@@ -394,7 +406,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 	else {
 		dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate);
 		ret = -EINVAL;
-		goto exit_put_clk;
+		goto exit_put_clk_rtc;
 	}
 
 	reg |= RTC_ENABLE_BIT;
@@ -402,7 +414,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 	if (((readw(pdata->ioaddr + RTC_RTCCTL)) & RTC_ENABLE_BIT) == 0) {
 		dev_err(&pdev->dev, "hardware module can't be enabled!\n");
 		ret = -EIO;
-		goto exit_put_clk;
+		goto exit_put_clk_rtc;
 	}
 
 	platform_set_drvdata(pdev, pdata);
@@ -424,15 +436,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 				  THIS_MODULE);
 	if (IS_ERR(rtc)) {
 		ret = PTR_ERR(rtc);
-		goto exit_put_clk;
+		goto exit_put_clk_rtc;
 	}
 
 	pdata->rtc = rtc;
 
 	return 0;
 
-exit_put_clk:
-	clk_disable_unprepare(pdata->clk);
+exit_put_clk_rtc:
+	clk_disable_unprepare(pdata->clk_rtc);
+exit_put_clk_ipg:
+	clk_disable_unprepare(pdata->clk_ipg);
 
 	return ret;
 }
@@ -441,7 +455,8 @@ static int mxc_rtc_remove(struct platform_device *pdev)
 {
 	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
 
-	clk_disable_unprepare(pdata->clk);
+	clk_disable_unprepare(pdata->clk_rtc);
+	clk_disable_unprepare(pdata->clk_ipg);
 
 	return 0;
 }
-- 
1.7.4.4


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

* [PATCH v4 4/7] rtc: mxc: add support of device tree
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
                   ` (2 preceding siblings ...)
  2015-07-03 23:15 ` [PATCH v4 3/7] rtc: mxc: use a second rtc clock Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-14 21:52   ` [rtc-linux] " Alexandre Belloni
  2015-07-03 23:15 ` [PATCH v4 5/7] dt-binding: document the binding for mxc rtc Philippe Reynes
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

Add device tree support for the mxc rtc driver.

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 drivers/rtc/rtc-mxc.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
index 4ce7e21..4191a87 100644
--- a/drivers/rtc/rtc-mxc.c
+++ b/drivers/rtc/rtc-mxc.c
@@ -16,6 +16,8 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #define RTC_INPUT_CLK_32768HZ	(0x00 << 5)
 #define RTC_INPUT_CLK_32000HZ	(0x01 << 5)
@@ -98,6 +100,15 @@ static const struct platform_device_id imx_rtc_devtype[] = {
 };
 MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
 
+#ifdef CONFIG_OF
+static const struct of_device_id imx_rtc_dt_ids[] = {
+	{ .compatible = "fsl,imx1-rtc", .data = (const void *)IMX1_RTC },
+	{ .compatible = "fsl,imx21-rtc", .data = (const void *)IMX21_RTC },
+	{}
+};
+MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids);
+#endif
+
 static inline int is_imx1_rtc(struct rtc_plat_data *data)
 {
 	return data->devtype == IMX1_RTC;
@@ -362,12 +373,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
 	u32 reg;
 	unsigned long rate;
 	int ret;
+	const struct of_device_id *of_id;
 
 	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
 
-	pdata->devtype = pdev->id_entry->driver_data;
+	of_id = of_match_device(imx_rtc_dt_ids, &pdev->dev);
+	if (of_id)
+		pdata->devtype = (enum imx_rtc_type)of_id->data;
+	else
+		pdata->devtype = pdev->id_entry->driver_data;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
@@ -488,6 +504,7 @@ static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
 static struct platform_driver mxc_rtc_driver = {
 	.driver = {
 		   .name	= "mxc_rtc",
+		   .of_match_table = of_match_ptr(imx_rtc_dt_ids),
 		   .pm		= &mxc_rtc_pm_ops,
 	},
 	.id_table = imx_rtc_devtype,
-- 
1.7.4.4


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

* [PATCH v4 5/7] dt-binding: document the binding for mxc rtc
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
                   ` (3 preceding siblings ...)
  2015-07-03 23:15 ` [PATCH v4 4/7] rtc: mxc: add support of device tree Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-09 14:26   ` Shawn Guo
  2015-07-10 19:58   ` Rob Herring
  2015-07-03 23:15 ` [PATCH v4 6/7] imx27: dt: add support of internal rtc Philippe Reynes
  2015-07-03 23:15 ` [PATCH v4 7/7] apf27: dt: enable " Philippe Reynes
  6 siblings, 2 replies; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	devicetree

This adds documentation of device tree bindings for the
mxc rtc.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: Kumar Gala <galak@codeaurora.org>
Cc: devicetree@vger.kernel.org
Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 Documentation/devicetree/bindings/rtc/rtc-mxc.txt |   27 +++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc.txt

diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc.txt b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
new file mode 100644
index 0000000..5505493
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
@@ -0,0 +1,27 @@
+* Real Time Clock of the i.MX SoCs
+
+RTC controller for the i.MX SoCs
+
+Required properties:
+- compatible: Should be "fsl,imx1-rtc" or "fsl,imx21-rtc".
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: IRQ line for the RTC.
+- clocks: should contain two entries:
+  * one for the input reference
+  * one for the the SoC RTC
+- clock-names: should contain:
+  * "rtc" for the input reference clock
+  * "ipg" for the SoC RTC clock
+
+Example:
+
+rtc@10007000 {
+	compatible = "fsl,imx21-rtc";
+	reg = <0x10007000 0x1000>;
+	interrupts = <22>;
+	clocks = <&clks IMX27_CLK_CKIL>,
+	       	 <&clks IMX27_CLK_RTC_IPG_GATE>;
+	clock-names = "rtc, "ipg";
+	status = "disabled";
+};
-- 
1.7.4.4


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

* [PATCH v4 6/7] imx27: dt: add support of internal rtc
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
                   ` (4 preceding siblings ...)
  2015-07-03 23:15 ` [PATCH v4 5/7] dt-binding: document the binding for mxc rtc Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  2015-07-09 14:32   ` Shawn Guo
  2015-07-03 23:15 ` [PATCH v4 7/7] apf27: dt: enable " Philippe Reynes
  6 siblings, 1 reply; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

Add support of internal rtc on imx27.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 arch/arm/boot/dts/imx27.dtsi |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
index b69be5c..38e6e84 100644
--- a/arch/arm/boot/dts/imx27.dtsi
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -144,6 +144,16 @@
 				clock-names = "ipg", "per";
 			};
 
+			rtc: rtc@10007000 {
+				compatible = "fsl,imx21-rtc";
+				reg = <0x10007000 0x1000>;
+				interrupts = <22>;
+				clocks = <&clks IMX27_CLK_CKIL>,
+					 <&clks IMX27_CLK_RTC_IPG_GATE>;
+				clock-names = "rtc", "ipg";
+				status = "disabled";
+			};
+
 			kpp: kpp@10008000 {
 				compatible = "fsl,imx27-kpp", "fsl,imx21-kpp";
 				reg = <0x10008000 0x1000>;
-- 
1.7.4.4


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

* [PATCH v4 7/7] apf27: dt: enable support of internal rtc
  2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
                   ` (5 preceding siblings ...)
  2015-07-03 23:15 ` [PATCH v4 6/7] imx27: dt: add support of internal rtc Philippe Reynes
@ 2015-07-03 23:15 ` Philippe Reynes
  6 siblings, 0 replies; 13+ messages in thread
From: Philippe Reynes @ 2015-07-03 23:15 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, shawn.guo, kernel, linux
  Cc: linux-arm-kernel, linux-kernel, rtc-linux, Philippe Reynes

Enable support of internal rtc on armadeus apf27.

Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
---
 arch/arm/boot/dts/imx27-apf27.dts |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx27-apf27.dts b/arch/arm/boot/dts/imx27-apf27.dts
index 73aae4f..590d37a 100644
--- a/arch/arm/boot/dts/imx27-apf27.dts
+++ b/arch/arm/boot/dts/imx27-apf27.dts
@@ -122,3 +122,7 @@
 		reg = <0x800000 0xf800000>;
 	};
 };
+
+&rtc {
+	status = "okay";
+};
-- 
1.7.4.4


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

* Re: [PATCH v4 5/7] dt-binding: document the binding for mxc rtc
  2015-07-03 23:15 ` [PATCH v4 5/7] dt-binding: document the binding for mxc rtc Philippe Reynes
@ 2015-07-09 14:26   ` Shawn Guo
  2015-07-10 19:58   ` Rob Herring
  1 sibling, 0 replies; 13+ messages in thread
From: Shawn Guo @ 2015-07-09 14:26 UTC (permalink / raw)
  To: Philippe Reynes
  Cc: a.zummo, alexandre.belloni, shawn.guo, kernel, linux,
	linux-arm-kernel, linux-kernel, rtc-linux, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree

On Sat, Jul 04, 2015 at 01:15:18AM +0200, Philippe Reynes wrote:
> This adds documentation of device tree bindings for the
> mxc rtc.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Pawel Moll <pawel.moll@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
> Cc: Kumar Gala <galak@codeaurora.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> ---
>  Documentation/devicetree/bindings/rtc/rtc-mxc.txt |   27 +++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc.txt
> 
> diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc.txt b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
> new file mode 100644
> index 0000000..5505493
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
> @@ -0,0 +1,27 @@
> +* Real Time Clock of the i.MX SoCs
> +
> +RTC controller for the i.MX SoCs
> +
> +Required properties:
> +- compatible: Should be "fsl,imx1-rtc" or "fsl,imx21-rtc".
> +- reg: physical base address of the controller and length of memory mapped
> +  region.
> +- interrupts: IRQ line for the RTC.
> +- clocks: should contain two entries:
> +  * one for the input reference
> +  * one for the the SoC RTC
> +- clock-names: should contain:
> +  * "rtc" for the input reference clock

Would it be better to use "ref" here?

Shawn

> +  * "ipg" for the SoC RTC clock
> +
> +Example:
> +
> +rtc@10007000 {
> +	compatible = "fsl,imx21-rtc";
> +	reg = <0x10007000 0x1000>;
> +	interrupts = <22>;
> +	clocks = <&clks IMX27_CLK_CKIL>,
> +	       	 <&clks IMX27_CLK_RTC_IPG_GATE>;
> +	clock-names = "rtc, "ipg";
> +	status = "disabled";
> +};
> -- 
> 1.7.4.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

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

* Re: [PATCH v4 6/7] imx27: dt: add support of internal rtc
  2015-07-03 23:15 ` [PATCH v4 6/7] imx27: dt: add support of internal rtc Philippe Reynes
@ 2015-07-09 14:32   ` Shawn Guo
  0 siblings, 0 replies; 13+ messages in thread
From: Shawn Guo @ 2015-07-09 14:32 UTC (permalink / raw)
  To: Philippe Reynes
  Cc: a.zummo, alexandre.belloni, shawn.guo, kernel, linux, rtc-linux,
	linux-kernel, linux-arm-kernel

On Sat, Jul 04, 2015 at 01:15:19AM +0200, Philippe Reynes wrote:
> Add support of internal rtc on imx27.
> 
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> ---
>  arch/arm/boot/dts/imx27.dtsi |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
> index b69be5c..38e6e84 100644
> --- a/arch/arm/boot/dts/imx27.dtsi
> +++ b/arch/arm/boot/dts/imx27.dtsi
> @@ -144,6 +144,16 @@
>  				clock-names = "ipg", "per";
>  			};
>  
> +			rtc: rtc@10007000 {
> +				compatible = "fsl,imx21-rtc";
> +				reg = <0x10007000 0x1000>;
> +				interrupts = <22>;
> +				clocks = <&clks IMX27_CLK_CKIL>,
> +					 <&clks IMX27_CLK_RTC_IPG_GATE>;
> +				clock-names = "rtc", "ipg";
> +				status = "disabled";

It has neither pin-out nor board level configuration.  For such device,
it makes more sense to drop status = "disabled" and enable the device by
default.  The bonus point would be that patch #7 in the series can be
saved.

Shawn

> +			};
> +
>  			kpp: kpp@10008000 {
>  				compatible = "fsl,imx27-kpp", "fsl,imx21-kpp";
>  				reg = <0x10008000 0x1000>;
> -- 
> 1.7.4.4
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> 

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

* Re: [PATCH v4 5/7] dt-binding: document the binding for mxc rtc
  2015-07-03 23:15 ` [PATCH v4 5/7] dt-binding: document the binding for mxc rtc Philippe Reynes
  2015-07-09 14:26   ` Shawn Guo
@ 2015-07-10 19:58   ` Rob Herring
  1 sibling, 0 replies; 13+ messages in thread
From: Rob Herring @ 2015-07-10 19:58 UTC (permalink / raw)
  To: Philippe Reynes
  Cc: Alessandro Zummo, Alexandre Belloni, Shawn Guo, kernel,
	Russell King - ARM Linux, linux-arm-kernel, linux-kernel,
	rtc-linux, Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell,
	Kumar Gala, devicetree

On Fri, Jul 3, 2015 at 6:15 PM, Philippe Reynes <tremyfr@gmail.com> wrote:
> This adds documentation of device tree bindings for the
> mxc rtc.
>
> Cc: Rob Herring <robh+dt@kernel.org>

Ack.

One typo below.

> Cc: Pawel Moll <pawel.moll@arm.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
> Cc: Kumar Gala <galak@codeaurora.org>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
> ---
>  Documentation/devicetree/bindings/rtc/rtc-mxc.txt |   27 +++++++++++++++++++++
>  1 files changed, 27 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/rtc/rtc-mxc.txt
>
> diff --git a/Documentation/devicetree/bindings/rtc/rtc-mxc.txt b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
> new file mode 100644
> index 0000000..5505493
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/rtc/rtc-mxc.txt
> @@ -0,0 +1,27 @@
> +* Real Time Clock of the i.MX SoCs
> +
> +RTC controller for the i.MX SoCs
> +
> +Required properties:
> +- compatible: Should be "fsl,imx1-rtc" or "fsl,imx21-rtc".
> +- reg: physical base address of the controller and length of memory mapped
> +  region.
> +- interrupts: IRQ line for the RTC.
> +- clocks: should contain two entries:
> +  * one for the input reference
> +  * one for the the SoC RTC
> +- clock-names: should contain:
> +  * "rtc" for the input reference clock
> +  * "ipg" for the SoC RTC clock
> +
> +Example:
> +
> +rtc@10007000 {
> +       compatible = "fsl,imx21-rtc";
> +       reg = <0x10007000 0x1000>;
> +       interrupts = <22>;
> +       clocks = <&clks IMX27_CLK_CKIL>,
> +                <&clks IMX27_CLK_RTC_IPG_GATE>;
> +       clock-names = "rtc, "ipg";

Missing ".

> +       status = "disabled";
> +};
> --
> 1.7.4.4
>

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

* Re: [rtc-linux] [PATCH v4 3/7] rtc: mxc: use a second rtc clock
  2015-07-03 23:15 ` [PATCH v4 3/7] rtc: mxc: use a second rtc clock Philippe Reynes
@ 2015-07-14 21:49   ` Alexandre Belloni
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandre Belloni @ 2015-07-14 21:49 UTC (permalink / raw)
  To: Philippe Reynes
  Cc: a.zummo, shawn.guo, kernel, linux, linux-arm-kernel,
	linux-kernel, rtc-linux

On 04/07/2015 at 01:15:16 +0200, Philippe Reynes wrote :
> The mxc RTC needs two clocks, one for the input
> reference, and one for the IP. But this driver
> was only using one clock (for the reference).
> This patch add the second clock (for the IP).
> 
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>

Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

I don't really care how the clocks are named, feel free to rename them
and keep that ack.

> ---
>  drivers/rtc/rtc-mxc.c |   41 ++++++++++++++++++++++++++++-------------
>  1 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
> index 5fc292c..4ce7e21 100644
> --- a/drivers/rtc/rtc-mxc.c
> +++ b/drivers/rtc/rtc-mxc.c
> @@ -79,7 +79,8 @@ struct rtc_plat_data {
>  	struct rtc_device *rtc;
>  	void __iomem *ioaddr;
>  	int irq;
> -	struct clk *clk;
> +	struct clk *clk_rtc;
> +	struct clk *clk_ipg;
>  	struct rtc_time g_rtc_alarm;
>  	enum imx_rtc_type devtype;
>  };
> @@ -373,17 +374,28 @@ static int mxc_rtc_probe(struct platform_device *pdev)
>  	if (IS_ERR(pdata->ioaddr))
>  		return PTR_ERR(pdata->ioaddr);
>  
> -	pdata->clk = devm_clk_get(&pdev->dev, NULL);
> -	if (IS_ERR(pdata->clk)) {
> -		dev_err(&pdev->dev, "unable to get clock!\n");
> -		return PTR_ERR(pdata->clk);
> +	pdata->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
> +	if (IS_ERR(pdata->clk_ipg)) {
> +		dev_err(&pdev->dev, "unable to get ipg clock!\n");
> +		return PTR_ERR(pdata->clk_ipg);
>  	}
>  
> -	ret = clk_prepare_enable(pdata->clk);
> +	ret = clk_prepare_enable(pdata->clk_ipg);
>  	if (ret)
>  		return ret;
>  
> -	rate = clk_get_rate(pdata->clk);
> +	pdata->clk_rtc = devm_clk_get(&pdev->dev, "rtc");
> +	if (IS_ERR(pdata->clk_rtc)) {
> +		dev_err(&pdev->dev, "unable to get rtc clock!\n");
> +		ret = PTR_ERR(pdata->clk_rtc);
> +		goto exit_put_clk_ipg;
> +	}
> +
> +	ret = clk_prepare_enable(pdata->clk_rtc);
> +	if (ret)
> +		goto exit_put_clk_ipg;
> +
> +	rate = clk_get_rate(pdata->clk_rtc);
>  
>  	if (rate == 32768)
>  		reg = RTC_INPUT_CLK_32768HZ;
> @@ -394,7 +406,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
>  	else {
>  		dev_err(&pdev->dev, "rtc clock is not valid (%lu)\n", rate);
>  		ret = -EINVAL;
> -		goto exit_put_clk;
> +		goto exit_put_clk_rtc;
>  	}
>  
>  	reg |= RTC_ENABLE_BIT;
> @@ -402,7 +414,7 @@ static int mxc_rtc_probe(struct platform_device *pdev)
>  	if (((readw(pdata->ioaddr + RTC_RTCCTL)) & RTC_ENABLE_BIT) == 0) {
>  		dev_err(&pdev->dev, "hardware module can't be enabled!\n");
>  		ret = -EIO;
> -		goto exit_put_clk;
> +		goto exit_put_clk_rtc;
>  	}
>  
>  	platform_set_drvdata(pdev, pdata);
> @@ -424,15 +436,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
>  				  THIS_MODULE);
>  	if (IS_ERR(rtc)) {
>  		ret = PTR_ERR(rtc);
> -		goto exit_put_clk;
> +		goto exit_put_clk_rtc;
>  	}
>  
>  	pdata->rtc = rtc;
>  
>  	return 0;
>  
> -exit_put_clk:
> -	clk_disable_unprepare(pdata->clk);
> +exit_put_clk_rtc:
> +	clk_disable_unprepare(pdata->clk_rtc);
> +exit_put_clk_ipg:
> +	clk_disable_unprepare(pdata->clk_ipg);
>  
>  	return ret;
>  }
> @@ -441,7 +455,8 @@ static int mxc_rtc_remove(struct platform_device *pdev)
>  {
>  	struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
>  
> -	clk_disable_unprepare(pdata->clk);
> +	clk_disable_unprepare(pdata->clk_rtc);
> +	clk_disable_unprepare(pdata->clk_ipg);
>  
>  	return 0;
>  }
> -- 
> 1.7.4.4
> 
> -- 
> -- 
> You received this message because you are subscribed to "rtc-linux".
> Membership options at http://groups.google.com/group/rtc-linux .
> Please read http://groups.google.com/group/rtc-linux/web/checklist
> before submitting a driver.
> --- 
> You received this message because you are subscribed to the Google Groups "rtc-linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* Re: [rtc-linux] [PATCH v4 4/7] rtc: mxc: add support of device tree
  2015-07-03 23:15 ` [PATCH v4 4/7] rtc: mxc: add support of device tree Philippe Reynes
@ 2015-07-14 21:52   ` Alexandre Belloni
  0 siblings, 0 replies; 13+ messages in thread
From: Alexandre Belloni @ 2015-07-14 21:52 UTC (permalink / raw)
  To: Philippe Reynes
  Cc: a.zummo, shawn.guo, kernel, linux, linux-arm-kernel,
	linux-kernel, rtc-linux

On 04/07/2015 at 01:15:17 +0200, Philippe Reynes wrote :
> Add device tree support for the mxc rtc driver.
> 
> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>

That patch should go after 5/7 to avoid a checkpatch warning.

> ---
>  drivers/rtc/rtc-mxc.c |   19 ++++++++++++++++++-
>  1 files changed, 18 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c
> index 4ce7e21..4191a87 100644
> --- a/drivers/rtc/rtc-mxc.c
> +++ b/drivers/rtc/rtc-mxc.c
> @@ -16,6 +16,8 @@
>  #include <linux/interrupt.h>
>  #include <linux/platform_device.h>
>  #include <linux/clk.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
>  
>  #define RTC_INPUT_CLK_32768HZ	(0x00 << 5)
>  #define RTC_INPUT_CLK_32000HZ	(0x01 << 5)
> @@ -98,6 +100,15 @@ static const struct platform_device_id imx_rtc_devtype[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, imx_rtc_devtype);
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id imx_rtc_dt_ids[] = {
> +	{ .compatible = "fsl,imx1-rtc", .data = (const void *)IMX1_RTC },
> +	{ .compatible = "fsl,imx21-rtc", .data = (const void *)IMX21_RTC },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, imx_rtc_dt_ids);
> +#endif
> +
>  static inline int is_imx1_rtc(struct rtc_plat_data *data)
>  {
>  	return data->devtype == IMX1_RTC;
> @@ -362,12 +373,17 @@ static int mxc_rtc_probe(struct platform_device *pdev)
>  	u32 reg;
>  	unsigned long rate;
>  	int ret;
> +	const struct of_device_id *of_id;
>  
>  	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>  	if (!pdata)
>  		return -ENOMEM;
>  
> -	pdata->devtype = pdev->id_entry->driver_data;
> +	of_id = of_match_device(imx_rtc_dt_ids, &pdev->dev);
> +	if (of_id)
> +		pdata->devtype = (enum imx_rtc_type)of_id->data;
> +	else
> +		pdata->devtype = pdev->id_entry->driver_data;
>  
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	pdata->ioaddr = devm_ioremap_resource(&pdev->dev, res);
> @@ -488,6 +504,7 @@ static SIMPLE_DEV_PM_OPS(mxc_rtc_pm_ops, mxc_rtc_suspend, mxc_rtc_resume);
>  static struct platform_driver mxc_rtc_driver = {
>  	.driver = {
>  		   .name	= "mxc_rtc",
> +		   .of_match_table = of_match_ptr(imx_rtc_dt_ids),
>  		   .pm		= &mxc_rtc_pm_ops,
>  	},
>  	.id_table = imx_rtc_devtype,
> -- 
> 1.7.4.4
> 
> -- 
> -- 
> You received this message because you are subscribed to "rtc-linux".
> Membership options at http://groups.google.com/group/rtc-linux .
> Please read http://groups.google.com/group/rtc-linux/web/checklist
> before submitting a driver.
> --- 
> You received this message because you are subscribed to the Google Groups "rtc-linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

end of thread, other threads:[~2015-07-14 21:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-03 23:15 [PATCH v4 0/7] add device tree support for mxc rtc Philippe Reynes
2015-07-03 23:15 ` [PATCH v4 1/7] imx31: add a second rtc clock Philippe Reynes
2015-07-03 23:15 ` [PATCH v4 2/7] imx35: define two clocks for rtc Philippe Reynes
2015-07-03 23:15 ` [PATCH v4 3/7] rtc: mxc: use a second rtc clock Philippe Reynes
2015-07-14 21:49   ` [rtc-linux] " Alexandre Belloni
2015-07-03 23:15 ` [PATCH v4 4/7] rtc: mxc: add support of device tree Philippe Reynes
2015-07-14 21:52   ` [rtc-linux] " Alexandre Belloni
2015-07-03 23:15 ` [PATCH v4 5/7] dt-binding: document the binding for mxc rtc Philippe Reynes
2015-07-09 14:26   ` Shawn Guo
2015-07-10 19:58   ` Rob Herring
2015-07-03 23:15 ` [PATCH v4 6/7] imx27: dt: add support of internal rtc Philippe Reynes
2015-07-09 14:32   ` Shawn Guo
2015-07-03 23:15 ` [PATCH v4 7/7] apf27: dt: enable " Philippe Reynes

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