Skip to contentSkip to conversation

clocksource: sh_cmt: DT binding rework V2

PATCH Superseded Magnus Damm 4 participants 19 messages Sep 17, 2015 – Sep 21, 2015

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover clocksource: sh_cmt: DT binding rework V2

clocksource: sh_cmt: DT binding rework V2

[PATCH v2 01/11] devicetree: bindings: Remove sh7372 CMT binding [PATCH v2 02/11] clocksource: sh_cmt: Use 0x3f mask for SH_CMT_48BIT case [PATCH v2 03/11] devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings [PATCH v2 04/11] clocksource: sh_cmt: Support separate R-Car Gen2 CMT0/1 [PATCH v2 05/11] devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings [PATCH v2 06/11] ARM: shmobile: Update CMT compat string users in DTS [PATCH v2 07/11] devicetree: bindings: Deprecate property, update example [PATCH v2 08/11] ARM: shmobile: Remove CMT renesas,channels-mask from DTS [PATCH v2 09/11] devicetree: bindings: Remove unused 32-bit CMT bindings [PATCH v2 10/11] clocksource: sh_cmt: Remove unused 32-bit CMT bindings [PATCH v2 11/11] devicetree: bindings: Remove deprecated properties

This series reworks the CMT DT bindings to try to deal with the following:
- R-Car Gen2 CMT0 and CMT1 hardware instances are not identical
- The property renesas,channels-mask is not enough to describe the difference
- DT should describe the hardware, not the software implementation
- Not all documented DT bindings are actually used

Without these patches the binding "renesas,cmt-48-gen2" is used for both CMT0 and CMT1 on R-Car Gen2 SoCs. CMT0 and CMT1 are currently seen by the Linux device driver as compatible hardware, and the device-specific property "renesas,channels-mask" is used to point out some of the hardware configuration differences. Since the driver is not feature complete only some differences are described and when diving into the data sheet we can see that:

1) CMT0 is not 48-bit at all, instead it only supports 32-bit counters.
2) Some channels of CMT1 are 48-bit, some 32-bit.
3) A couple of CMT1 channels have even more features.

It turns out that none of the above differences are described in our current DT files. And since we use the same compat string for CMT0 and CMT1 the driver itself cannot enable features specific only to CMT1 without first updating the DTS. So this series is ground work for future feature patches.

It seems that we have two choices if we want to support CMT1 features:
A) Keep existing DT bindings, add more properties for CMT1
B) Rework the compatible strings and keep configuration in the driver

Judging by above it seems that DT update is inevitable. In my mind it is rather painful to update the DT so I'd like to minimize the number of updates and let the majority of the changes only happen in the driver. And since we should really describe hardware in DT but driver features tend to be implemented incrementally then B) seems like a good fit to me.

I wouldn't mind going with A) but to be honest I must say that the existing compat string "renesas,cmt-48-gen2" is just too confusing with "48" (when CMT0 is 32bit-only) and also "gen2" (used without product line R-Car).

Because of that I've gone with B) and reworked the bindings to separate CMT0 from CMT1 and keep channel configuration in the device driver.

While at it I've deprecated "renesas,channels-mask" and the old DT compat strings. Per-SoC compat strings have also been reworked, but are not left around documented as deprecated since they were never used by the driver.

Comments are very welcome! If all are in favor then it would be good to merge patch 1-5 first and patch 6-8 later once 1-5 are in. Old DTBs are left working but treated as low-feature CMT0. New DTBs including patch 6 will not work on old kernels.

V2 patch series fixes patch 1-2 and adds patches 9, 10, 11. Patch 9 and 10 cleans up r8a7740 and sh73a0 bindings. Patch 11 removes deprecated properties as proposed by Laurent.

Many thanks to Geert and Laurent for feedback!

---

Written against renesas-drivers-2015-09-15-v4.3-rc1

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   85 ++++++---------
 arch/arm/boot/dts/r8a73a4.dtsi                          |    5 
 arch/arm/boot/dts/r8a7740.dtsi                          |    3 
 arch/arm/boot/dts/r8a7790.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7791.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7793.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7794.dtsi                          |   10 -
 arch/arm/boot/dts/sh73a0.dtsi                           |    3 
 drivers/clocksource/sh_cmt.c                            |   54 ++++++---
 9 files changed, 85 insertions(+), 105 deletions(-)
#1 lore raw

PATCH v2 1/11 devicetree: bindings: Remove sh7372 CMT binding

From: Magnus Damm <[email protected]>

Remove the sh7372 CMT compat string to reduce maintenance burden.

It should be fine to break DT compatibility because:
1) The sh7372 SoC support has been removed from upstream
2) The sh7372 CMT DT binding was never part of upstream DTS
3) The CMT driver never matches on the sh7372 binding

---

Changes since V1:
- Removed all references to sh7372
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +3 -9
@@ -14,32 +14,26 @@ Required Properties:
   - compatible: must contain one or more of the following:
     - "renesas,cmt-32-r8a7740" for the r8a7740 32-bit CMT
 		(CMT0)
-    - "renesas,cmt-32-sh7372" for the sh7372 32-bit CMT
-		(CMT0)
     - "renesas,cmt-32-sh73a0" for the sh73a0 32-bit CMT
 		(CMT0)
     - "renesas,cmt-32" for all 32-bit CMT without fast clock support
-		(CMT0 on sh7372, sh73a0 and r8a7740)
+		(CMT0 on sh73a0 and r8a7740)
 		This is a fallback for the above renesas,cmt-32-* entries.
 
     - "renesas,cmt-32-fast-r8a7740" for the r8a7740 32-bit CMT with fast
 		clock support (CMT[234])
-    - "renesas,cmt-32-fast-sh7372" for the sh7372 32-bit CMT with fast
-		clock support (CMT[234])
     - "renesas,cmt-32-fast-sh73a0" for the sh73A0 32-bit CMT with fast
 		clock support (CMT[234])
     - "renesas,cmt-32-fast" for all 32-bit CMT with fast clock support
-		(CMT[234] on sh7372, sh73a0 and r8a7740)
+		(CMT[234] on sh73a0 and r8a7740)
 		This is a fallback for the above renesas,cmt-32-fast-* entries.
 
-    - "renesas,cmt-48-sh7372" for the sh7372 48-bit CMT
-		(CMT1)
     - "renesas,cmt-48-sh73a0" for the sh73A0 48-bit CMT
 		(CMT1)
     - "renesas,cmt-48-r8a7740" for the r8a7740 48-bit CMT
 		(CMT1)
     - "renesas,cmt-48" for all non-second generation 48-bit CMT
-		(CMT1 on sh7372, sh73a0 and r8a7740)
+		(CMT1 on sh73a0 and r8a7740)
 		This is a fallback for the above renesas,cmt-48-* entries.
 
     - "renesas,cmt-48-r8a73a4" for the r8a73a4 48-bit CMT
#2 lore raw

PATCH v2 2/11 clocksource: sh_cmt: Use 0x3f mask for SH_CMT_48BIT case

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Always use 0x3f as channel mask for the SH_CMT_48BIT type of devices. Once this patch is applied the "renesas,channels-mask" property will be ignored by the driver for older devices matching SH_CMT_48BIT. In the future when all CMT types store channel mask in the driver then we will be able to deprecate and remove "renesas,channels-mask" from DTS.

---

Changes since V1:
- Fixed compile error - thanks Geert!
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

drivers/clocksource/sh_cmt.c | 14 +++++++++++---

 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/clocksource/sh_cmt.c +11 -3
@@ -74,6 +74,8 @@ enum sh_cmt_model {
 struct sh_cmt_info {
 	enum sh_cmt_model model;
 
+	unsigned long channels_mask;
+
 	unsigned long width; /* 16 or 32 bit version of hardware block */
 	unsigned long overflow_bit;
 	unsigned long clear_bits;
@@ -212,6 +214,7 @@ static const struct sh_cmt_info sh_cmt_i
 	},
 	[SH_CMT_48BIT] = {
 		.model = SH_CMT_48BIT,
+		.channels_mask = 0x3f,
 		.width = 32,
 		.overflow_bit = SH_CMT32_CMCSR_CMF,
 		.clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
@@ -972,9 +975,14 @@ static int sh_cmt_setup(struct sh_cmt_de
 		id = of_match_node(sh_cmt_of_table, pdev->dev.of_node);
 		cmt->info = id->data;
 
-		ret = sh_cmt_parse_dt(cmt);
-		if (ret < 0)
-			return ret;
+		/* prefer in-driver channel configuration over DT */
+		if (cmt->info->channels_mask) {
+			cmt->hw_channels = cmt->info->channels_mask;
+		} else {
+			ret = sh_cmt_parse_dt(cmt);
+			if (ret < 0)
+				return ret;
+		}
 	} else if (pdev->dev.platform_data) {
 		struct sh_timer_config *cfg = pdev->dev.platform_data;
 		const struct platform_device_id *id = pdev->id_entry;
#3 lore raw

PATCH v2 3/11 devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add documentation for new separate CMT0 and CMT1 DT compatible strings for R-Car Gen2. These compat strings allow us to enable CMT1-specific features in the driver. The old compat strings will be deprecated in the not so distant future.

---

Changes since V1:
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |    3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +3 -0
@@ -36,6 +36,9 @@ Required Properties:
 		(CMT1 on sh73a0 and r8a7740)
 		This is a fallback for the above renesas,cmt-48-* entries.
 
+    - "renesas,cmt0-rcar-gen2" for 32-bit CMT0 devices included in R-Car Gen2.
+    - "renesas,cmt1-rcar-gen2" for 48-bit CMT1 devices included in R-Car Gen2.
+
     - "renesas,cmt-48-r8a73a4" for the r8a73a4 48-bit CMT
 		(CMT[01])
     - "renesas,cmt-48-r8a7790" for the r8a7790 48-bit CMT
#4 lore raw

PATCH v2 4/11 clocksource: sh_cmt: Support separate R-Car Gen2 CMT0/1

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Add support for the new R-Car Gen2 CMT0 and CMT1 bindings. Support for the old DT binding is still kept around, however devices using such binding will be treated as a low-feature CMT0 device. If users want to make use of CMT1-specific features then they need to update their DTBs. No special CMT1-specific features are however implemented by his patch, only DT bindings are redone as groundwork for future feature patches.

---

Changes since V1:
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 drivers/clocksource/sh_cmt.c |   38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)
drivers/clocksource/sh_cmt.c +27 -11
@@ -39,16 +39,16 @@ struct sh_cmt_device;
  * SoC but also on the particular instance. The following table lists the main
  * characteristics of those flavours.
  *
- *			16B	32B	32B-F	48B	48B-2
+ *			16B	32B	32B-F	48B	R-Car Gen2
  * -----------------------------------------------------------------------------
  * Channels		2	1/4	1	6	2/8
  * Control Width	16	16	16	16	32
  * Counter Width	16	32	32	32/48	32/48
  * Shared Start/Stop	Y	Y	Y	Y	N
  *
- * The 48-bit gen2 version has a per-channel start/stop register located in the
- * channel registers block. All other versions have a shared start/stop register
- * located in the global space.
+ * The r8a73a4 / R-Car Gen2 version has a per-channel start/stop register
+ * located in the channel registers block. All other versions have a shared
+ * start/stop register located in the global space.
  *
  * Channels are indexed from 0 to N-1 in the documentation. The channel index
  * infers the start/stop bit position in the control register and the channel
@@ -68,7 +68,8 @@ enum sh_cmt_model {
 	SH_CMT_32BIT,
 	SH_CMT_32BIT_FAST,
 	SH_CMT_48BIT,
-	SH_CMT_48BIT_GEN2,
+	SH_CMT0_RCAR_GEN2,
+	SH_CMT1_RCAR_GEN2,
 };
 
 struct sh_cmt_info {
@@ -223,8 +224,20 @@ static const struct sh_cmt_info sh_cmt_i
 		.read_count = sh_cmt_read32,
 		.write_count = sh_cmt_write32,
 	},
-	[SH_CMT_48BIT_GEN2] = {
-		.model = SH_CMT_48BIT_GEN2,
+	[SH_CMT0_RCAR_GEN2] = {
+		.model = SH_CMT0_RCAR_GEN2,
+		.channels_mask = 0x60,
+		.width = 32,
+		.overflow_bit = SH_CMT32_CMCSR_CMF,
+		.clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
+		.read_control = sh_cmt_read32,
+		.write_control = sh_cmt_write32,
+		.read_count = sh_cmt_read32,
+		.write_count = sh_cmt_write32,
+	},
+	[SH_CMT1_RCAR_GEN2] = {
+		.model = SH_CMT1_RCAR_GEN2,
+		.channels_mask = 0xff,
 		.width = 32,
 		.overflow_bit = SH_CMT32_CMCSR_CMF,
 		.clear_bits = ~(SH_CMT32_CMCSR_CMF | SH_CMT32_CMCSR_OVF),
@@ -867,6 +880,7 @@ static int sh_cmt_setup_channel(struct s
 	ch->cmt = cmt;
 	ch->index = index;
 	ch->hwidx = hwidx;
+	ch->timer_bit = hwidx;
 
 	/*
 	 * Compute the address of the channel control register block. For the
@@ -888,9 +902,11 @@ static int sh_cmt_setup_channel(struct s
 		 */
 		ch->ioctrl = cmt->mapbase + 0x40;
 		break;
-	case SH_CMT_48BIT_GEN2:
+	case SH_CMT0_RCAR_GEN2:
+	case SH_CMT1_RCAR_GEN2:
 		ch->iostart = cmt->mapbase + ch->hwidx * 0x100;
 		ch->ioctrl = ch->iostart + 0x10;
+		ch->timer_bit = 0;
 		break;
 	}
 
@@ -902,8 +918,6 @@ static int sh_cmt_setup_channel(struct s
 	ch->match_value = ch->max_match_value;
 	raw_spin_lock_init(&ch->lock);
 
-	ch->timer_bit = cmt->info->model == SH_CMT_48BIT_GEN2 ? 0 : ch->hwidx;
-
 	ret = sh_cmt_register(ch, dev_name(&cmt->pdev->dev),
 			      clockevent, clocksource);
 	if (ret) {
@@ -946,7 +960,9 @@ static const struct of_device_id sh_cmt_
 	{ .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
 	{ .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
 	{ .compatible = "renesas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
-	{ .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT_48BIT_GEN2] },
+	{ .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
+	{ .compatible = "renesas,cmt0-rcar-gen2", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
+	{ .compatible = "renesas,cmt1-rcar-gen2", .data = &sh_cmt_info[SH_CMT1_RCAR_GEN2] },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
#5 lore raw

PATCH v2 5/11 devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Update SoC-specific bindings for r8a73a4 and R-Car Gen2 CMT0 and CMT1.

---

Changes since V1:
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   26 ++++++++-------
 1 file changed, 15 insertions(+), 11 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +15 -11
@@ -36,20 +36,24 @@ Required Properties:
 		(CMT1 on sh73a0 and r8a7740)
 		This is a fallback for the above renesas,cmt-48-* entries.
 
+    - "renesas,cmt0-r8a73a4" for the 32-bit CMT0 device included in r8a73a4.
+    - "renesas,cmt1-r8a73a4" for the 48-bit CMT1 device included in r8a73a4.
+    - "renesas,cmt0-r8a7790" for the 32-bit CMT0 device included in r8a7790.
+    - "renesas,cmt1-r8a7790" for the 48-bit CMT1 device included in r8a7790.
+    - "renesas,cmt0-r8a7791" for the 32-bit CMT0 device included in r8a7791.
+    - "renesas,cmt1-r8a7791" for the 48-bit CMT1 device included in r8a7791.
+    - "renesas,cmt0-r8a7793" for the 32-bit CMT0 device included in r8a7793.
+    - "renesas,cmt1-r8a7793" for the 48-bit CMT1 device included in r8a7793.
+    - "renesas,cmt0-r8a7794" for the 32-bit CMT0 device included in r8a7794.
+    - "renesas,cmt1-r8a7794" for the 48-bit CMT1 device included in r8a7794.
+
     - "renesas,cmt0-rcar-gen2" for 32-bit CMT0 devices included in R-Car Gen2.
     - "renesas,cmt1-rcar-gen2" for 48-bit CMT1 devices included in R-Car Gen2.
+		These are fallbacks for r8a73a4 and all the R-Car Gen2
+		entries	listed above.
 
-    - "renesas,cmt-48-r8a73a4" for the r8a73a4 48-bit CMT
-		(CMT[01])
-    - "renesas,cmt-48-r8a7790" for the r8a7790 48-bit CMT
-		(CMT[01])
-    - "renesas,cmt-48-r8a7791" for the r8a7791 48-bit CMT
-		(CMT[01])
-    - "renesas,cmt-48-gen2" for all second generation 48-bit CMT
-		(CMT[01] on r8a73a4, r8a7790 and r8a7791)
-		This is a fallback for the renesas,cmt-48-r8a73a4,
-		renesas,cmt-48-r8a7790 and renesas,cmt-48-r8a7791 entries.
-
+    - "renesas,cmt-48-gen2" is <deprecated>, use "renesas,cmt[01]-*" instead.
+    
   - reg: base address and length of the registers block for the timer module.
   - interrupts: interrupt-specifier for the timer, one per channel.
   - clocks: a list of phandle + clock-specifier pairs, one for each entry
#6 lore raw

PATCH v2 6/11 ARM: shmobile: Update CMT compat string users in DTS

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Use recently updated r8a73a4 and R-Car Gen2 CMT0 and CMT1 compat strings.

With this change in place we can keep device-specific configuration in the driver and the driver can be able to support CMT1 specific features.

---

Changes since V1:
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 arch/arm/boot/dts/r8a73a4.dtsi |    2 +-
 arch/arm/boot/dts/r8a7790.dtsi |    4 ++--
 arch/arm/boot/dts/r8a7791.dtsi |    4 ++--
 arch/arm/boot/dts/r8a7793.dtsi |    4 ++--
 arch/arm/boot/dts/r8a7794.dtsi |    4 ++--
 5 files changed, 9 insertions(+), 9 deletions(-)
arch/arm/boot/dts/r8a73a4.dtsi +1 -1
@@ -114,7 +114,7 @@
 	};
 
 	cmt1: timer@e6130000 {
-		compatible = "renesas,cmt-48-r8a73a4", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt1-r8a73a4", "renesas,cmt1-rcar-gen2";
 		reg = <0 0xe6130000 0 0x1004>;
 		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp3_clks R8A73A4_CLK_CMT1>;
arch/arm/boot/dts/r8a7790.dtsi +2 -2
@@ -219,7 +219,7 @@
 	};
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt0-r8a7790", "renesas,cmt0-rcar-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
@@ -233,7 +233,7 @@
 	};
 
 	cmt1: timer@e6130000 {
-		compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt1-r8a7790", "renesas,cmt1-rcar-gen2";
 		reg = <0 0xe6130000 0 0x1004>;
 		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
arch/arm/boot/dts/r8a7791.dtsi +2 -2
@@ -202,7 +202,7 @@
 	};
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-r8a7791", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt0-r8a7791", "renesas,cmt0-rcar-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
@@ -216,7 +216,7 @@
 	};
 
 	cmt1: timer@e6130000 {
-		compatible = "renesas,cmt-48-r8a7791", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt1-r8a7791", "renesas,cmt1-rcar-gen2";
 		reg = <0 0xe6130000 0 0x1004>;
 		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
arch/arm/boot/dts/r8a7793.dtsi +2 -2
@@ -62,7 +62,7 @@
 	};
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-r8a7793", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt0-r8a7793", "renesas,cmt0-rcar-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
@@ -76,7 +76,7 @@
 	};
 
 	cmt1: timer@e6130000 {
-		compatible = "renesas,cmt-48-r8a7793", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt1-r8a7793", "renesas,cmt1-rcar-gen2";
 		reg = <0 0xe6130000 0 0x1004>;
 		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
arch/arm/boot/dts/r8a7794.dtsi +2 -2
@@ -154,7 +154,7 @@
 	};
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt0-r8a7794", "renesas,cmt0-rcar-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 143 IRQ_TYPE_LEVEL_HIGH>;
@@ -168,7 +168,7 @@
 	};
 
 	cmt1: timer@e6130000 {
-		compatible = "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt1-r8a7794", "renesas,cmt1-rcar-gen2";
 		reg = <0 0xe6130000 0 0x1004>;
 		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
#7 lore raw

PATCH v2 7/11 devicetree: bindings: Deprecate property, update example

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Deprecate "renesas,channels-mask" and update the r8a7790 CMT example.

---

Changes since V1:
- Added Acked-by and Tested-by from Geert
- Added Acked-by from Laurent

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   24 ++++++++++-----
 1 file changed, 17 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +17 -7
@@ -60,21 +60,31 @@ Required Properties:
     in clock-names.
   - clock-names: must contain "fck" for the functional clock.
 
-  - renesas,channels-mask: bitmask of the available channels.
+  - renesas,channels-mask: <deprecated>, information kept in device driver.
 
 
-Example: R8A7790 (R-Car H2) CMT0 node
-
-	CMT0 on R8A7790 implements hardware channels 5 and 6 only and names
-	them channels 0 and 1 in the documentation.
+Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
 
 	cmt0: timer@ffca0000 {
-		compatible = "renesas,cmt-48-r8a7790", "renesas,cmt-48-gen2";
+		compatible = "renesas,cmt0-r8a7790", "renesas,cmt0-rcar-gen2";
 		reg = <0 0xffca0000 0 0x1004>;
 		interrupts = <0 142 IRQ_TYPE_LEVEL_HIGH>,
 			     <0 142 IRQ_TYPE_LEVEL_HIGH>;
 		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
 		clock-names = "fck";
+	};
 
-		renesas,channels-mask = <0x60>;
+	cmt1: timer@e6130000 {
+		compatible = "renesas,cmt1-r8a7790", "renesas,cmt1-rcar-gen2";
+		reg = <0 0xe6130000 0 0x1004>;
+		interrupts = <0 120 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 121 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 122 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 123 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 124 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 125 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 126 IRQ_TYPE_LEVEL_HIGH>,
+			     <0 127 IRQ_TYPE_LEVEL_HIGH>;
+		clocks = <&mstp3_clks R8A7790_CLK_CMT1>;
+		clock-names = "fck";
 	};
#8 lore raw

PATCH v2 8/11 ARM: shmobile: Remove CMT renesas,channels-mask from DTS

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Update the DTS to remove the now deprecated "renesas,channels-mask" property.

The channel information is now kept in the device driver and can easily be determined based on the compat string.

---

Changes since V1:
- Rebased on top of power-domain changes
- Added Acked-by and Tested-by from Geert

 arch/arm/boot/dts/r8a73a4.dtsi |    3 ---
 arch/arm/boot/dts/r8a7740.dtsi |    3 ---
 arch/arm/boot/dts/r8a7790.dtsi |    6 ------
 arch/arm/boot/dts/r8a7791.dtsi |    6 ------
 arch/arm/boot/dts/r8a7793.dtsi |    6 ------
 arch/arm/boot/dts/r8a7794.dtsi |    6 ------
 arch/arm/boot/dts/sh73a0.dtsi  |    3 ---
 7 files changed, 33 deletions(-)
arch/arm/boot/dts/r8a73a4.dtsi +0 -3
@@ -120,9 +120,6 @@
 		clocks = <&mstp3_clks R8A73A4_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&pd_c5>;
-
-		renesas,channels-mask = <0xff>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/r8a7740.dtsi +0 -3
@@ -60,9 +60,6 @@
 		clocks = <&mstp3_clks R8A7740_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&pd_c5>;
-
-		renesas,channels-mask = <0x3f>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/r8a7790.dtsi +0 -6
@@ -226,9 +226,6 @@
 		clocks = <&mstp1_clks R8A7790_CLK_CMT0>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0x60>;
-
 		status = "disabled";
 	};
 
@@ -246,9 +243,6 @@
 		clocks = <&mstp3_clks R8A7790_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0xff>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/r8a7791.dtsi +0 -6
@@ -209,9 +209,6 @@
 		clocks = <&mstp1_clks R8A7791_CLK_CMT0>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0x60>;
-
 		status = "disabled";
 	};
 
@@ -229,9 +226,6 @@
 		clocks = <&mstp3_clks R8A7791_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0xff>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/r8a7793.dtsi +0 -6
@@ -69,9 +69,6 @@
 		clocks = <&mstp1_clks R8A7793_CLK_CMT0>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0x60>;
-
 		status = "disabled";
 	};
 
@@ -89,9 +86,6 @@
 		clocks = <&mstp3_clks R8A7793_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0xff>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/r8a7794.dtsi +0 -6
@@ -161,9 +161,6 @@
 		clocks = <&mstp1_clks R8A7794_CLK_CMT0>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0x60>;
-
 		status = "disabled";
 	};
 
@@ -181,9 +178,6 @@
 		clocks = <&mstp3_clks R8A7794_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&cpg_clocks>;
-
-		renesas,channels-mask = <0xff>;
-
 		status = "disabled";
 	};
 
arch/arm/boot/dts/sh73a0.dtsi +0 -3
@@ -84,9 +84,6 @@
 		clocks = <&mstp3_clks SH73A0_CLK_CMT1>;
 		clock-names = "fck";
 		power-domains = <&pd_c5>;
-
-		renesas,channels-mask = <0x3f>;
-
 		status = "disabled";
 	};
 
#9 lore raw

PATCH v2 9/11 devicetree: bindings: Remove unused 32-bit CMT bindings

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

---

Changes since V1:
- New patch

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   16 ---------------
 1 file changed, 16 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +0 -16
@@ -12,22 +12,6 @@ datasheets.
 Required Properties:
 
   - compatible: must contain one or more of the following:
-    - "renesas,cmt-32-r8a7740" for the r8a7740 32-bit CMT
-		(CMT0)
-    - "renesas,cmt-32-sh73a0" for the sh73a0 32-bit CMT
-		(CMT0)
-    - "renesas,cmt-32" for all 32-bit CMT without fast clock support
-		(CMT0 on sh73a0 and r8a7740)
-		This is a fallback for the above renesas,cmt-32-* entries.
-
-    - "renesas,cmt-32-fast-r8a7740" for the r8a7740 32-bit CMT with fast
-		clock support (CMT[234])
-    - "renesas,cmt-32-fast-sh73a0" for the sh73A0 32-bit CMT with fast
-		clock support (CMT[234])
-    - "renesas,cmt-32-fast" for all 32-bit CMT with fast clock support
-		(CMT[234] on sh73a0 and r8a7740)
-		This is a fallback for the above renesas,cmt-32-fast-* entries.
-
     - "renesas,cmt-48-sh73a0" for the sh73A0 48-bit CMT
 		(CMT1)
     - "renesas,cmt-48-r8a7740" for the r8a7740 48-bit CMT
#13 lore raw

PATCH v2 10/11 clocksource: sh_cmt: Remove unused 32-bit CMT bindings

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

---

Changes since V1:
- New patch

 drivers/clocksource/sh_cmt.c |    2 --
 1 file changed, 2 deletions(-)
drivers/clocksource/sh_cmt.c +0 -2
@@ -957,8 +957,6 @@ static const struct platform_device_id s
 MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
 
 static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
-	{ .compatible = "renesas,cmt-32", .data = &sh_cmt_info[SH_CMT_32BIT] },
-	{ .compatible = "renesas,cmt-32-fast", .data = &sh_cmt_info[SH_CMT_32BIT_FAST] },
 	{ .compatible = "renesas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
 	{ .compatible = "renesas,cmt-48-gen2", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
 	{ .compatible = "renesas,cmt0-rcar-gen2", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
#15 lore raw

PATCH v2 11/11 devicetree: bindings: Remove deprecated properties

In reply to Magnus Damm

From: Magnus Damm <[email protected]>

The deprecated DT properies are part of the GIT history, no need to keep them around any longer.

---

Changes since V1:
- New patch

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |    4 ----
 1 file changed, 4 deletions(-)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +0 -4
@@ -35,8 +35,6 @@ Required Properties:
     - "renesas,cmt1-rcar-gen2" for 48-bit CMT1 devices included in R-Car Gen2.
 		These are fallbacks for r8a73a4 and all the R-Car Gen2
 		entries	listed above.
-
-    - "renesas,cmt-48-gen2" is <deprecated>, use "renesas,cmt[01]-*" instead.
     
   - reg: base address and length of the registers block for the timer module.
   - interrupts: interrupt-specifier for the timer, one per channel.
@@ -44,8 +42,6 @@ Required Properties:
     in clock-names.
   - clock-names: must contain "fck" for the functional clock.
 
-  - renesas,channels-mask: <deprecated>, information kept in device driver.
-
 
 Example: R8A7790 (R-Car H2) CMT0 and CMT1 nodes
 
Acked-by on v2 9/11
#10 lore raw

Re: [PATCH v2 09/11] devicetree: bindings: Remove unused 32-bit CMT bindings

In reply to Magnus Damm
Quoted 8 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

Acked-by on v2 10/11
#14 lore raw

Re: [PATCH v2 10/11] clocksource: sh_cmt: Remove unused 32-bit CMT bindings

In reply to Magnus Damm
Quoted 8 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

Acked-by on v2 11/11
#16 lore raw

Re: [PATCH v2 11/11] devicetree: bindings: Remove deprecated properties

In reply to Magnus Damm
Quoted 3 lines · Magnus Damm

From: Magnus Damm <[email protected]>

The deprecated DT properies are part of the GIT history,

properties

Quoted 1 line

no need to keep them around any longer.

They're still in the driver because in-the-field R-Car Gen2 DTSes use them, right? You may add a comment in the driver, to prevent a janitor from re-adding them to the bindings.

Quoted 1 line

Nevertheless

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

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

Re: [PATCH v2 11/11] devicetree: bindings: Remove deprecated properties

Hi Geert,

Quoted 6 lines · Geert Uytterhoeven
Quoted 3 lines · Magnus Damm

From: Magnus Damm <[email protected]>

The deprecated DT properies are part of the GIT history,

properties

Oops!

Quoted 5 lines
Quoted 1 line

no need to keep them around any longer.

They're still in the driver because in-the-field R-Car Gen2 DTSes use them, right? You may add a comment in the driver, to prevent a janitor from re-adding them to the bindings.

Yes, good idea!

Quoted 4 lines
Quoted 1 line

Nevertheless

Thank you!

/ magnus

#11 lore raw

Re: [PATCH v2 09/11] devicetree: bindings: Remove unused 32-bit CMT bindings

In reply to Magnus Damm

Hello.

Quoted 6 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

Nit: "32-bit" repeated twice.

Quoted 1 line

[...]

MBR, Sergei

#12 lore raw

Re: [PATCH v2 09/11] devicetree: bindings: Remove unused 32-bit CMT bindings

Hi Sergei,

Quoted 6 lines · Sergei Shtylyov

Hello.

Quoted 2 lines · Magnus Damm

From: Magnus Damm <[email protected]>

Quoted 7 lines
Quoted 4 lines

Remove the 32-bit CMT compat strings to reduce maintenance burden.

It should be fine to break DT compatibility because the 32-bit 32-bit CMT DT binding was never part of any upstream DTS file.

Nit: "32-bit" repeated twice.

Oops, will fix, thanks for reporting!

Cheers,

/ magnus

maintainer Acked-by on the v2 series
#18 lore raw
In reply to Magnus Damm
Quoted 40 lines · Magnus Damm

clocksource: sh_cmt: DT binding rework V2

[PATCH v2 01/11] devicetree: bindings: Remove sh7372 CMT binding [PATCH v2 02/11] clocksource: sh_cmt: Use 0x3f mask for SH_CMT_48BIT case [PATCH v2 03/11] devicetree: bindings: R-Car Gen2 CMT0 and CMT1 bindings [PATCH v2 04/11] clocksource: sh_cmt: Support separate R-Car Gen2 CMT0/1 [PATCH v2 05/11] devicetree: bindings: r8a73a4 and R-Car Gen2 CMT bindings [PATCH v2 06/11] ARM: shmobile: Update CMT compat string users in DTS [PATCH v2 07/11] devicetree: bindings: Deprecate property, update example [PATCH v2 08/11] ARM: shmobile: Remove CMT renesas,channels-mask from DTS [PATCH v2 09/11] devicetree: bindings: Remove unused 32-bit CMT bindings [PATCH v2 10/11] clocksource: sh_cmt: Remove unused 32-bit CMT bindings [PATCH v2 11/11] devicetree: bindings: Remove deprecated properties

This series reworks the CMT DT bindings to try to deal with the following:
- R-Car Gen2 CMT0 and CMT1 hardware instances are not identical
- The property renesas,channels-mask is not enough to describe the difference
- DT should describe the hardware, not the software implementation
- Not all documented DT bindings are actually used

Without these patches the binding "renesas,cmt-48-gen2" is used for both CMT0 and CMT1 on R-Car Gen2 SoCs. CMT0 and CMT1 are currently seen by the Linux device driver as compatible hardware, and the device-specific property "renesas,channels-mask" is used to point out some of the hardware configuration differences. Since the driver is not feature complete only some differences are described and when diving into the data sheet we can see that:

1) CMT0 is not 48-bit at all, instead it only supports 32-bit counters.
2) Some channels of CMT1 are 48-bit, some 32-bit.
3) A couple of CMT1 channels have even more features.

It turns out that none of the above differences are described in our current DT files. And since we use the same compat string for CMT0 and CMT1 the driver itself cannot enable features specific only to CMT1 without first updating the DTS. So this series is ground work for future feature patches.

It seems that we have two choices if we want to support CMT1 features:
A) Keep existing DT bindings, add more properties for CMT1
B) Rework the compatible strings and keep configuration in the driver

Quoted 5 lines

Judging by above it seems that DT update is inevitable. In my mind it is rather painful to update the DT so I'd like to minimize the number of updates and let the majority of the changes only happen in the driver. And since we should really describe hardware in DT but driver features tend to be implemented incrementally then B) seems like a good fit to me.

Agreed.

For 1, 3. 5, 7, 9, 11:

Quoted 46 lines

I wouldn't mind going with A) but to be honest I must say that the existing compat string "renesas,cmt-48-gen2" is just too confusing with "48" (when CMT0 is 32bit-only) and also "gen2" (used without product line R-Car).

Because of that I've gone with B) and reworked the bindings to separate CMT0 from CMT1 and keep channel configuration in the device driver.

While at it I've deprecated "renesas,channels-mask" and the old DT compat strings. Per-SoC compat strings have also been reworked, but are not left around documented as deprecated since they were never used by the driver.

Comments are very welcome! If all are in favor then it would be good to merge patch 1-5 first and patch 6-8 later once 1-5 are in. Old DTBs are left working but treated as low-feature CMT0. New DTBs including patch 6 will not work on old kernels.

V2 patch series fixes patch 1-2 and adds patches 9, 10, 11. Patch 9 and 10 cleans up r8a7740 and sh73a0 bindings. Patch 11 removes deprecated properties as proposed by Laurent.

Many thanks to Geert and Laurent for feedback!

---

Written against renesas-drivers-2015-09-15-v4.3-rc1

 Documentation/devicetree/bindings/timer/renesas,cmt.txt |   85 ++++++---------
 arch/arm/boot/dts/r8a73a4.dtsi                          |    5 
 arch/arm/boot/dts/r8a7740.dtsi                          |    3 
 arch/arm/boot/dts/r8a7790.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7791.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7793.dtsi                          |   10 -
 arch/arm/boot/dts/r8a7794.dtsi                          |   10 -
 arch/arm/boot/dts/sh73a0.dtsi                           |    3 
 drivers/clocksource/sh_cmt.c                            |   54 ++++++---
 9 files changed, 85 insertions(+), 105 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html