Skip to contentSkip to conversation

thermal: rcar: Add missing clock handling

PATCH In review Geert Uytterhoeven 10 participants 27 messages Jan 7, 2014 – Feb 24, 2014

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover thermal: rcar: Add missing clock handling

Hi all,

This patch series fixes a problem when the thermal-rcar device is instantiated from the device tree on the r8a7791-based Koelsch development board. The driver fails during initialization with:

rcar_thermal e61f0000.thermal: thermal sensor was broken

This does not happen when using legacy platform devices.

This series was tested using Koelsch reference (DT) and non-reference (legacy) kernel configurations. It was not tested on r8a7790/Lager (which is very similar).

[1/4] ARM: shmobile: r8a7791: Add thermal clock in device tree [2/4] ARM: shmobile: r8a7790: Add thermal clock in device tree [3/4] thermal: rcar: Add missing clock handling [4/4] thermal: rcar: Spelling s/delaye/delay/g

Thanks for your comments!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#1 lore raw

PATCH 1/4 ARM: shmobile: r8a7791: Add thermal clock in device tree

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

---
 arch/arm/boot/dts/r8a7791.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/r8a7791.dtsi +1 -0
index d8dbf7e7b6a9..3233041d8a44 100644
@@ -151,6 +151,7 @@
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupt-parent = <&gic>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp5_clks R8A7791_CLK_THERMAL>;
 	};
 
 	timer {
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/4 ARM: shmobile: r8a7791: Add thermal clock in device tree

Hi Geert,

Thank you for the patch.

Quoted 5 lines · On Tuesday 07 January 2014 19:57:13 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

Quoted 16 lines
---
 arch/arm/boot/dts/r8a7791.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/r8a7791.dtsi +1 -0
index d8dbf7e7b6a9..3233041d8a44 100644
@@ -151,6 +151,7 @@
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupt-parent = <&gic>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp5_clks R8A7791_CLK_THERMAL>;
 	};
 
 	timer {
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH 1/4 ARM: shmobile: r8a7791: Add thermal clock in device tree

Quoted 4 lines · Laurent Pinchart

Hi Geert,

Thank you for the patch.

Quoted 8 lines
Quoted 5 lines · On Tuesday 07 January 2014 19:57:13 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

Thanks, I will queue this up.

#4 lore raw

PATCH 1/4 ARM: shmobile: r8a7791: add IIC0/1 clock macros

In reply to Geert Uytterhoeven

From: Wolfram Sang <[email protected]>

---
 include/dt-bindings/clock/r8a7791-clock.h | 2 ++
 1 file changed, 2 insertions(+)
include/dt-bindings/clock/r8a7791-clock.h +2 -0
index 30f82f2..9aa60f4 100644
@@ -55,6 +55,8 @@
 #define R8A7791_CLK_CMT1		29
 #define R8A7791_CLK_USBDMAC0		30
 #define R8A7791_CLK_USBDMAC1		31
+#define R8A7791_CLK_IIC0		18
+#define R8A7791_CLK_IIC1		23
 
 /* MSTP5 */
 #define R8A7791_CLK_THERMAL		22
Signature · 1 line
1.8.5.1
#5 lore raw

Re: [PATCH 1/4] ARM: shmobile: r8a7791: add IIC0/1 clock macros

In reply to Geert Uytterhoeven

Hi Wolfram,

Thank you for the patch.

Quoted 12 lines · On Sunday 23 February 2014 13:40:21 Wolfram Sang wrote:

From: Wolfram Sang <[email protected]>

---
 include/dt-bindings/clock/r8a7791-clock.h | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/include/dt-bindings/clock/r8a7791-clock.h index 30f82f2..9aa60f4 100644

include/dt-bindings/clock/r8a7791-clock.h line 59

Quoted 5 lines
include/dt-bindings/clock/r8a7791-clock.h +2 -0
@@ -55,6 +55,8 @@
 #define R8A7791_CLK_CMT1		29
 #define R8A7791_CLK_USBDMAC0		30
 #define R8A7791_CLK_USBDMAC1		31
+#define R8A7791_CLK_IIC0		18
+#define R8A7791_CLK_IIC1		23

Could you please keep the entries sorted by value ?

Quoted 2 lines
include/dt-bindings/clock/r8a7791-clock.h +0 -0
 /* MSTP5 */
 #define R8A7791_CLK_THERMAL		22
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

Re: [PATCH 1/4] ARM: shmobile: r8a7791: add IIC0/1 clock macros

In reply to Geert Uytterhoeven
Quoted 12 lines · Laurent Pinchart

Hi Wolfram,

Thank you for the patch.

Quoted 7 lines · On Sunday 23 February 2014 13:40:21 Wolfram Sang wrote:

From: Wolfram Sang <[email protected]>

---
 include/dt-bindings/clock/r8a7791-clock.h | 2 ++
 1 file changed, 2 insertions(+)
Quoted 12 lines

include/dt-bindings/clock/r8a7791-clock.h line 59

Quoted 10 lines
(quoted diff) +0 -0

b/include/dt-bindings/clock/r8a7791-clock.h index 30f82f2..9aa60f4 100644

include/dt-bindings/clock/r8a7791-clock.h +2 -0
@@ -55,6 +55,8 @@
 #define R8A7791_CLK_CMT1		29
 #define R8A7791_CLK_USBDMAC0		30
 #define R8A7791_CLK_USBDMAC1		31
+#define R8A7791_CLK_IIC0		18
+#define R8A7791_CLK_IIC1		23

Could you please keep the entries sorted by value ?

Ehrm, yes, sure. Very weird, I am pretty sure I looked for the sorting and thought I found a chornological one. Will fix.

#7 lore raw

PATCH 2/4 ARM: shmobile: r8a7790: Add thermal clock in device tree

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

---
 arch/arm/boot/dts/r8a7790.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/r8a7790.dtsi +1 -0
index f48487c2a970..b53834e6a55f 100644
@@ -168,6 +168,7 @@
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupt-parent = <&gic>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
 	};
 
 	timer {
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH 2/4 ARM: shmobile: r8a7790: Add thermal clock in device tree

Hi Geert,

Thank you for the patch.

Quoted 5 lines · On Tuesday 07 January 2014 19:57:14 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

Quoted 16 lines
---
 arch/arm/boot/dts/r8a7790.dtsi |    1 +
 1 file changed, 1 insertion(+)
arch/arm/boot/dts/r8a7790.dtsi +1 -0
index f48487c2a970..b53834e6a55f 100644
@@ -168,6 +168,7 @@
 		reg = <0 0xe61f0000 0 0x14>, <0 0xe61f0100 0 0x38>;
 		interrupt-parent = <&gic>;
 		interrupts = <0 69 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp5_clks R8A7790_CLK_THERMAL>;
 	};
 
 	timer {
Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

PATCH 2/4 ARM: shmobile: r8a7790: Add thermal clock in device tree

Quoted 4 lines · Laurent Pinchart

Hi Geert,

Thank you for the patch.

Quoted 8 lines
Quoted 5 lines · On Tuesday 07 January 2014 19:57:14 Geert Uytterhoeven wrote:

From: Geert Uytterhoeven <[email protected]>

Add the missing thermal MSTP clock to the thermal device node.

Thanks, I will queue this up.

#10 lore raw

PATCH 2/4 ARM: shmobile: r8a7790: add audio clock

In reply to Geert Uytterhoeven

From: Kuninori Morimoto <[email protected]>

Current audio clock doesn't have dependency to device/driver, but, it is not good design for DT support.
To avoid branch merge conflict issue,
it uses this load map, and this patch is 1) part.
1) add old/new style clock in platform
2) add new style clock method in driver
3) remove old tyle clock from platform

---
 arch/arm/boot/dts/r8a7790.dtsi         |   23 +++++++++++++++++++++++
 arch/arm/mach-shmobile/clock-r8a7790.c |   20 ++++++++++++++++++++
 2 files changed, 43 insertions(+)
arch/arm/boot/dts/r8a7790.dtsi +23 -0
index 3cc834b..b4f0cd5 100644
@@ -414,6 +414,29 @@
 			clock-output-names = "extal";
 		};
 
+		/*
+		 * The external audio clocks are configured as 0 Hz fixed frequency clocks by
+		 * default. Boards that provide audio clocks should override them.
+		 */
+		audio_clk_a: audio_clk_a {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "audio_clk_a";
+		};
+		audio_clk_b: audio_clk_b {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "audio_clk_b";
+		};
+		audio_clk_c: audio_clk_c {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <0>;
+			clock-output-names = "audio_clk_c";
+		};
+
 		/* Special CPG clocks */
 		cpg_clocks: cpg_clocks@e6150000 {
 			compatible = "renesas,r8a7790-cpg-clocks",
arch/arm/mach-shmobile/clock-r8a7790.c +20 -0
index f25b43a..77fd456 100644
@@ -91,6 +91,15 @@ static struct clk main_clk = {
 	.ops	= &followparent_clk_ops,
 };
 
+static struct clk audio_clk_a = {
+};
+
+static struct clk audio_clk_b = {
+};
+
+static struct clk audio_clk_c = {
+};
+
 /*
  * clock ratio of these clock will be updated
  * on r8a7790_clock_init()
@@ -124,6 +133,9 @@ SH_FIXED_RATIO_CLK_SET(ddr_clk,			pll3_clk,	1, 8);
 SH_FIXED_RATIO_CLK_SET(mp_clk,			pll1_div2_clk,	1, 15);
 
 static struct clk *main_clks[] = {
+	&audio_clk_a,
+	&audio_clk_b,
+	&audio_clk_c,
 	&extal_clk,
 	&extal_div2_clk,
 	&main_clk,
@@ -266,6 +278,10 @@ static struct clk mstp_clks[MSTP_NR] = {
 static struct clk_lookup lookups[] = {
 
 	/* main clocks */
+	CLKDEV_CON_ID("audio_clk_a",	&audio_clk_a),
+	CLKDEV_CON_ID("audio_clk_b",	&audio_clk_b),
+	CLKDEV_CON_ID("audio_clk_c",	&audio_clk_c),
+	CLKDEV_CON_ID("audio_clk_internal",	&m2_clk),
 	CLKDEV_CON_ID("extal",		&extal_clk),
 	CLKDEV_CON_ID("extal_div2",	&extal_div2_clk),
 	CLKDEV_CON_ID("main",		&main_clk),
@@ -353,6 +369,10 @@ static struct clk_lookup lookups[] = {
 	CLKDEV_ICK_ID("du.0", "rcar-du-r8a7790", &mstp_clks[MSTP724]),
 	CLKDEV_ICK_ID("du.1", "rcar-du-r8a7790", &mstp_clks[MSTP723]),
 	CLKDEV_ICK_ID("du.2", "rcar-du-r8a7790", &mstp_clks[MSTP722]),
+	CLKDEV_ICK_ID("clk_a", "rcar_sound", &audio_clk_a),
+	CLKDEV_ICK_ID("clk_b", "rcar_sound", &audio_clk_b),
+	CLKDEV_ICK_ID("clk_c", "rcar_sound", &audio_clk_c),
+	CLKDEV_ICK_ID("clk_i", "rcar_sound", &m2_clk),
 	CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP1015]),
 	CLKDEV_ICK_ID("ssi.1", "rcar_sound", &mstp_clks[MSTP1014]),
 	CLKDEV_ICK_ID("ssi.2", "rcar_sound", &mstp_clks[MSTP1013]),
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

When using DT to instantiate the rcar-thermal device, it prints the following error:

rcar_thermal e61f0000.thermal: thermal sensor was broken

Explicitly request and enable the thermal clock to fix this.

---
 drivers/thermal/rcar_thermal.c |   40 +++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)
drivers/thermal/rcar_thermal.c +33 -7
index 88f92e1a9944..a5629500723a 100644
@@ -17,6 +17,7 @@
  *  with this program; if not, write to the Free Software Foundation, Inc.,
  *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/irq.h>
@@ -53,6 +54,7 @@ struct rcar_thermal_common {
 	struct device *dev;
 	struct list_head head;
 	spinlock_t lock;
+	struct clk *clk;
 };
 
 struct rcar_thermal_priv {
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 	spin_lock_init(&common->lock);
 	common->dev = dev;
 
+	common->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(common->clk)) {
+		dev_err(&pdev->dev, "cannot get clock\n");
+		return PTR_ERR(common->clk);
+	}
+
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
+	}
+
+	clk_enable(common->clk);
+
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);
 
 	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (irq) {
-		int ret;
+		int ret2;
 
 		/*
 		 * platform has IRQ support.
 		 * Then, drier use common register
 		 */
 
-		ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
-				       dev_name(dev), common);
-		if (ret) {
+		ret2 = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
+					dev_name(dev), common);
+		if (ret2) {
 			dev_err(dev, "irq request failed\n ");
-			return ret;
+			ret = ret2;
+			goto error_unpm;
 		}
 
 		/*
@@ -402,8 +419,10 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		 */
 		res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
 		common->base = devm_ioremap_resource(dev, res);
-		if (IS_ERR(common->base))
-			return PTR_ERR(common->base);
+		if (IS_ERR(common->base)) {
+			ret = PTR_ERR(common->base);
+			goto error_unpm;
+		}
 
 		/* enable temperature comparation */
 		rcar_thermal_common_write(common, ENR, 0x00030303);
@@ -465,9 +484,13 @@ error_unregister:
 			rcar_thermal_irq_disable(priv);
 	}
 
+error_unpm:
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
+	clk_disable(common->clk);
+	clk_unprepare(common->clk);
+
 	return ret;
 }
 
@@ -486,6 +509,9 @@ static int rcar_thermal_remove(struct platform_device *pdev)
 	pm_runtime_put_sync(dev);
 	pm_runtime_disable(dev);
 
+	clk_disable(common->clk);
+	clk_unprepare(common->clk);
+
 	return 0;
 }
 
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Hello.

Quoted 18 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

When using DT to instantiate the rcar-thermal device, it prints the following error:

rcar_thermal e61f0000.thermal: thermal sensor was broken

Explicitly request and enable the thermal clock to fix this.

---
  drivers/thermal/rcar_thermal.c |   40 +++++++++++++++++++++++++++++++++-------
  1 file changed, 33 insertions(+), 7 deletions(-)
drivers/thermal/rcar_thermal.c +0 -0
index 88f92e1a9944..a5629500723a 100644

[...]

Quoted 1 line
drivers/thermal/rcar_thermal.c +0 -0
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev)

[...]

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 396

Quoted 8 lines
drivers/thermal/rcar_thermal.c +8 -0
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
+	}
+
+	clk_enable(common->clk);
+

Why not just clk_prepare_enable()?

[...]

drivers/thermal/rcar_thermal.c error_unregister: · line 493

Quoted 11 lines
drivers/thermal/rcar_thermal.c +4 -0
@@ -465,9 +484,13 @@ error_unregister:
  			rcar_thermal_irq_disable(priv);
  	}
 
+error_unpm:
  	pm_runtime_put_sync(dev);
  	pm_runtime_disable(dev);
 
+	clk_disable(common->clk);
+	clk_unprepare(common->clk);
+

Why not just clk_disable_unprepare()?

drivers/thermal/rcar_thermal.c static int rcar_thermal_remove(struct platform_device *pdev) · line 514

Quoted 10 lines
drivers/thermal/rcar_thermal.c +3 -0
  	return ret;
  }
 
@@ -486,6 +509,9 @@ static int rcar_thermal_remove(struct platform_device *pdev)
  	pm_runtime_put_sync(dev);
  	pm_runtime_disable(dev);
 
+	clk_disable(common->clk);
+	clk_unprepare(common->clk);
+

Likewise.

WBR, Sergei

#13 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven
Quoted 11 lines · Geert Uytterhoeven
drivers/thermal/rcar_thermal.c +6 -0
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 	spin_lock_init(&common->lock);
 	common->dev = dev;
 
+	common->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(common->clk)) {
+		dev_err(&pdev->dev, "cannot get clock\n");
+		return PTR_ERR(common->clk);
+	}
+

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 10 lines
drivers/thermal/rcar_thermal.c +8 -0
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
+	}
+
+	clk_enable(common->clk);
+
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);

clk_enable() can fail, too, so you should check its return value

virtually yours
Gerhard Sittig

Signature · 3 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
#14 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Quoted 16 lines · Gerhard Sittig
Quoted 15 lines · Geert Uytterhoeven
drivers/thermal/rcar_thermal.c +10 -0
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev)
  	spin_lock_init(&common->lock);
  	common->dev = dev;
 
+	common->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(common->clk)) {
+		dev_err(&pdev->dev, "cannot get clock\n");
+		return PTR_ERR(common->clk);
+	}
+
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
Quoted 8 lines

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 6 lines
drivers/thermal/rcar_thermal.c +4 -0
+	}
+
+	clk_enable(common->clk);
+
  	pm_runtime_enable(dev);
  	pm_runtime_get_sync(dev);

clk_enable() can fail, too, so you should check its return value

Also, if you enable the pm-runtime then the device clock is actually handled by the common pm-clock framework.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#15 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven

Hi Geert

Quoted 6 lines
drivers/thermal/rcar_thermal.c +6 -0
+	common->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(common->clk)) {
+		dev_err(&pdev->dev, "cannot get clock\n");
+		return PTR_ERR(common->clk);
+	}
+

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 10 lines
drivers/thermal/rcar_thermal.c +8 -0
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
+	}
+
+	clk_enable(common->clk);
+
 	pm_runtime_enable(dev);
 	pm_runtime_get_sync(dev);

You can use "dev" instead of "&pdev->dev" :)

And this patch seems strange for me. pm_runtime_xxx() is doing same things.
If it didn't work, wrong place is not driver, clock side ?

#16 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Quoted 12 lines · Kuninori Morimoto
Quoted 12 lines
drivers/thermal/rcar_thermal.c +12 -0
+     common->clk = devm_clk_get(&pdev->dev, NULL);
+     if (IS_ERR(common->clk)) {
+             dev_err(&pdev->dev, "cannot get clock\n");
+             return PTR_ERR(common->clk);
+     }
+
+     ret = clk_prepare(common->clk);
+     if (ret < 0) {
+             dev_err(&pdev->dev, "unable to prepare clock\n");
+             return ret;
+     }
+
Quoted 8 lines

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 4 lines
drivers/thermal/rcar_thermal.c +2 -0
+     clk_enable(common->clk);
+
      pm_runtime_enable(dev);
      pm_runtime_get_sync(dev);

And this patch seems strange for me. pm_runtime_xxx() is doing same things.
If it didn't work, wrong place is not driver, clock side ?

That's an interesting observation...

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#17 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Hi Morimoto-san,

Quoted 23 lines · Geert Uytterhoeven
Quoted 12 lines · Kuninori Morimoto
Quoted 12 lines
drivers/thermal/rcar_thermal.c +12 -0
+     common->clk = devm_clk_get(&pdev->dev, NULL);
+     if (IS_ERR(common->clk)) {
+             dev_err(&pdev->dev, "cannot get clock\n");
+             return PTR_ERR(common->clk);
+     }
+
+     ret = clk_prepare(common->clk);
+     if (ret < 0) {
+             dev_err(&pdev->dev, "unable to prepare clock\n");
+             return ret;
+     }
+
Quoted 8 lines

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 4 lines
drivers/thermal/rcar_thermal.c +2 -0
+     clk_enable(common->clk);
+
      pm_runtime_enable(dev);
      pm_runtime_get_sync(dev);

And this patch seems strange for me. pm_runtime_xxx() is doing same things.
If it didn't work, wrong place is not driver, clock side ?

Quoted 1 line

That's an interesting observation...

You were right. After applying both of "ARM: shmobile: compile drivers/sh for CONFIG_ARCH_SHMOBILE_MULTI" and "power: clock_ops.c: fixup clk prepare/unprepare count" from Ben Dooks the issue went away.

So my patch can be dropped.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#18 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Hi Geert

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

And this patch seems strange for me. pm_runtime_xxx() is doing same things.
If it didn't work, wrong place is not driver, clock side ?

(snipO

Quoted 3 lines

You were right. After applying both of "ARM: shmobile: compile drivers/sh for CONFIG_ARCH_SHMOBILE_MULTI" and "power: clock_ops.c: fixup clk prepare/unprepare count" from Ben Dooks the issue went away.

Nice !
Thank you for your help :)

Best regards
---
Kuninori Morimoto

#19 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven
Quoted 27 lines · Geert Uytterhoeven

Hi Morimoto-san,

Quoted 23 lines · Geert Uytterhoeven
Quoted 20 lines · Kuninori Morimoto
Quoted 6 lines
drivers/thermal/rcar_thermal.c +6 -0
+     common->clk = devm_clk_get(&pdev->dev, NULL);
+     if (IS_ERR(common->clk)) {
+             dev_err(&pdev->dev, "cannot get clock\n");
+             return PTR_ERR(common->clk);
+     }
+

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 398

Quoted 10 lines
drivers/thermal/rcar_thermal.c +8 -0
+     ret = clk_prepare(common->clk);
+     if (ret < 0) {
+             dev_err(&pdev->dev, "unable to prepare clock\n");
+             return ret;
+     }
+
+     clk_enable(common->clk);
+
      pm_runtime_enable(dev);
      pm_runtime_get_sync(dev);

And this patch seems strange for me. pm_runtime_xxx() is doing same things.
If it didn't work, wrong place is not driver, clock side ?

Quoted 5 lines
Quoted 1 line

That's an interesting observation...

You were right. After applying both of "ARM: shmobile: compile drivers/sh for CONFIG_ARCH_SHMOBILE_MULTI" and "power: clock_ops.c: fixup clk prepare/unprepare count" from Ben Dooks the issue went away.

There seems to be some lively discussion around Ben's patch.

Quoted 1 line

So my patch can be dropped.

I have marked this patch as Rejected accordingly.

#20 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven
Quoted 66 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

When using DT to instantiate the rcar-thermal device, it prints the following error:

rcar_thermal e61f0000.thermal: thermal sensor was broken

Explicitly request and enable the thermal clock to fix this.

---
  drivers/thermal/rcar_thermal.c |   40 +++++++++++++++++++++++++++++++++-------
  1 file changed, 33 insertions(+), 7 deletions(-)
drivers/thermal/rcar_thermal.c +17 -2
index 88f92e1a9944..a5629500723a 100644
@@ -17,6 +17,7 @@
   *  with this program; if not, write to the Free Software Foundation, Inc.,
   *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
   */
+#include <linux/clk.h>
  #include <linux/delay.h>
  #include <linux/err.h>
  #include <linux/irq.h>
@@ -53,6 +54,7 @@ struct rcar_thermal_common {
  	struct device *dev;
  	struct list_head head;
  	spinlock_t lock;
+	struct clk *clk;
  };
 
  struct rcar_thermal_priv {
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device *pdev)
  	spin_lock_init(&common->lock);
  	common->dev = dev;
 
+	common->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(common->clk)) {
+		dev_err(&pdev->dev, "cannot get clock\n");
+		return PTR_ERR(common->clk);
+	}
+
+	ret = clk_prepare(common->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "unable to prepare clock\n");
+		return ret;
+	}
+
+	clk_enable(common->clk);
+
  	pm_runtime_enable(dev);
  	pm_runtime_get_sync(dev);
 
  	irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  	if (irq) {
-		int ret;
+		int ret2;
 
  		/*
  		 * platform has IRQ support.
  		 * Then, drier use common register
  		 */
 
-		ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,

drivers/thermal/rcar_thermal.c static int rcar_thermal_probe(struct platform_device *pdev) · line 415

Quoted 10 lines
drivers/thermal/rcar_thermal.c +5 -3
-				       dev_name(dev), common);
-		if (ret) {
+		ret2 = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
+					dev_name(dev), common);
+		if (ret2) {
  			dev_err(dev, "irq request failed\n ");
-			return ret;
+			ret = ret2;
+			goto error_unpm;
  		}

I'd suggest not renaming ret2 and just use the original ret.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius
#21 lore raw

PATCH 3/4 thermal: rcar: Add missing clock handling

Quoted 32 lines · Ben Dooks
Quoted 32 lines
drivers/thermal/rcar_thermal.c +15 -1
@@ -378,23 +380,38 @@ static int rcar_thermal_probe(struct platform_device
 *pdev)
        spin_lock_init(&common->lock);
        common->dev = dev;
 
+       common->clk = devm_clk_get(&pdev->dev, NULL);
+       if (IS_ERR(common->clk)) {
+               dev_err(&pdev->dev, "cannot get clock\n");
+               return PTR_ERR(common->clk);
+       }
+
+       ret = clk_prepare(common->clk);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "unable to prepare clock\n");
+               return ret;
+       }
+
+       clk_enable(common->clk);
+
        pm_runtime_enable(dev);
        pm_runtime_get_sync(dev);
 
        irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
        if (irq) {
-               int ret;
+               int ret2;
 
                /*
                 * platform has IRQ support.
                 * Then, drier use common register
                 */
 
Quoted 15 lines
Quoted 12 lines
drivers/thermal/rcar_thermal.c +5 -4
-               ret = devm_request_irq(dev, irq->start, rcar_thermal_irq,
 0,
-                                      dev_name(dev), common);
-               if (ret) {
+               ret2 = devm_request_irq(dev, irq->start, rcar_thermal_irq,
 0,
+                                       dev_name(dev), common);
+               if (ret2) {
                        dev_err(dev, "irq request failed\n ");
-                       return ret;
+                       ret = ret2;
+                       goto error_unpm;
Quoted 1 line
                }

I'd suggest not renaming ret2 and just use the original ret.

I did that because the for loop after that block depends on ret still being -ENODEV. Upon closer look, I did break that myself by assigning it the return value of clk_prepare().
So I'll use the original ret, and reset it to -ENODEV before the for loop (unless we manage to fix it in pm_runtime_*()).

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#22 lore raw

PATCH 4/4 thermal: rcar: Spelling s/delaye/delay/g

In reply to Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

---
 drivers/thermal/rcar_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/rcar_thermal.c +1 -1
index a5629500723a..32d591087307 100644
@@ -427,7 +427,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		/* enable temperature comparation */
 		rcar_thermal_common_write(common, ENR, 0x00030303);
 
-		idle = 0; /* polling delaye is not needed */
+		idle = 0; /* polling delay is not needed */
 	}
 
 	for (i = 0;; i++) {
Signature · 1 line
1.7.9.5
#23 lore raw

PATCH 4/4 thermal: rcar: Spelling s/delaye/delay/g

Quoted 4 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

Quoted 20 lines
---
 drivers/thermal/rcar_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/rcar_thermal.c +1 -1
index a5629500723a..32d591087307 100644
@@ -427,7 +427,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		/* enable temperature comparation */
 		rcar_thermal_common_write(common, ENR, 0x00030303);
 
-		idle = 0; /* polling delaye is not needed */
+		idle = 0; /* polling delay is not needed */
 	}
 
 	for (i = 0;; i++) {
Signature · 1 line
1.7.9.5
reviewer Applied
#24 lore raw

PATCH 4/4 thermal: rcar: Spelling s/delaye/delay/g

In reply to Geert Uytterhoeven
Quoted 4 lines · Geert Uytterhoeven

From: Geert Uytterhoeven <[email protected]>

applied.

thanks,
rui

Quoted 17 lines
---
 drivers/thermal/rcar_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/rcar_thermal.c +1 -1
index a5629500723a..32d591087307 100644
@@ -427,7 +427,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 		/* enable temperature comparation */
 		rcar_thermal_common_write(common, ENR, 0x00030303);
 
-		idle = 0; /* polling delaye is not needed */
+		idle = 0; /* polling delay is not needed */
 	}
 
 	for (i = 0;; i++) {
#25 lore raw

cover thermal: rcar: Add missing clock handling

In reply to Geert Uytterhoeven
Quoted 1 line · Geert Uytterhoeven

Hi all,

Hi Geert,

Quoted 4 lines

This patch series fixes a problem when the thermal-rcar device is instantiated from the device tree on the r8a7791-based Koelsch development board. The driver fails during initialization with:

I think explicitly acquiring the clocks should not be needed. Could you please try the patches from the following series instead?

http://marc.info/?l=linux-sh&m=138823255807611&w=2

Thanks,
Val.

Quoted 32 lines

rcar_thermal e61f0000.thermal: thermal sensor was broken

This does not happen when using legacy platform devices.

This series was tested using Koelsch reference (DT) and non-reference (legacy) kernel configurations. It was not tested on r8a7790/Lager (which is very similar).

[1/4] ARM: shmobile: r8a7791: Add thermal clock in device tree [2/4] ARM: shmobile: r8a7790: Add thermal clock in device tree [3/4] thermal: rcar: Add missing clock handling [4/4] thermal: rcar: Spelling s/delaye/delay/g

Thanks for your comments!

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw

cover thermal: rcar: Add missing clock handling

Hi Valentine,

Quoted 10 lines · Valentine
Quoted 3 lines · Geert Uytterhoeven

This patch series fixes a problem when the thermal-rcar device is instantiated from the device tree on the r8a7791-based Koelsch development board. The driver fails during initialization with:

I think explicitly acquiring the clocks should not be needed. Could you please try the patches from the following series instead?

http://marc.info/?l=linux-sh&m=138823255807611&w=2

I already had these applied, and the problem persists.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds