Skip to contentSkip to conversation

ARM: tegra: convert device tree files to use CLK defines

PATCH Superseded Hiroshi Doyu 3 participants 12 messages Feb 14, 2013 – Feb 21, 2013

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ARM: tegra: convert device tree files to use CLK defines

Hi,

With new dtc+cpp feature, we can get rid of magic numbers in dts* files. To get rid of Tegra clock magic number, the following patches were created with a script run as below. This can be applied for Tegra114 clock as well.

for x in 20 30; do

    cat drivers/clk/tegra/clk-tegra$x.c | enum2define.py \
    	> arch/arm/boot/dts/tegra$x-car.h 2>/tmp/tegra$x-car.sed
    sed -i -f /tmp/tegra$x-car.sed \
    	Documentation/devicetree/bindings/clock/nvidia\,tegra$x-car.txt \
	arch/arm/boot/dts/*

done

We plan to share those DT header files with kernel source later[1].

This series depends on:

[PATCH 0/9] ARM: tegra: use new dtc+cpp feature
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-February/149613.html

v1:
http://lists.infradead.org/pipermail/linux-arm-kernel/2013-February/149672.html

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2013-February/149804.html

Hiroshi Doyu (4):
ARM: tegra20: create a DT header defining CLK IDs
ARM: tegra20: convert device tree files to use CLK defines
ARM: tegra30: create a DT header defining CLK IDs
ARM: tegra30: convert device tree files to use CLK defines

 .../bindings/clock/nvidia,tegra20-car.txt          |    2 +-
 .../bindings/clock/nvidia,tegra30-car.txt          |    2 +-
 arch/arm/boot/dts/tegra20-car.h                    |  114 +++++++++++++
 arch/arm/boot/dts/tegra20-paz00.dtsp               |    2 +-
 arch/arm/boot/dts/tegra20.dtsip                    |   85 +++++-----
 arch/arm/boot/dts/tegra30-car.h                    |  171 ++++++++++++++++++++
 arch/arm/boot/dts/tegra30.dtsip                    |   87 +++++-----
 7 files changed, 375 insertions(+), 88 deletions(-)
 create mode 100644 arch/arm/boot/dts/tegra20-car.h
 create mode 100644 arch/arm/boot/dts/tegra30-car.h

--
1.7.9.5

#1 lore raw

PATCH v2 1/4 ARM: tegra20: create a DT header defining CLK IDs

To replace magic number in tegra_car:

- clocks = <&tegra_car 28>;
+ clocks = <&tegra_car CLK_HOST1X>;

---
 arch/arm/boot/dts/tegra20-car.h |  114 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 114 insertions(+)
 create mode 100644 arch/arm/boot/dts/tegra20-car.h
arch/arm/boot/dts/tegra20-car.h new file +114 -0
new file mode 100644
index 0000000..0659414
@@ -0,0 +1,114 @@
+#define CLK_CPU 0
+#define CLK_AC97 3
+#define CLK_RTC 4
+#define CLK_TIMER 5
+#define CLK_UARTA 6
+#define CLK_GPIO 8
+#define CLK_SDMMC2 9
+#define CLK_I2S1 11
+#define CLK_I2C1 12
+#define CLK_NDFLASH 13
+#define CLK_SDMMC1 14
+#define CLK_SDMMC4 15
+#define CLK_TWC 16
+#define CLK_PWM 17
+#define CLK_I2S2 18
+#define CLK_EPP 19
+#define CLK_GR2D 21
+#define CLK_USBD 22
+#define CLK_ISP 23
+#define CLK_GR3D 24
+#define CLK_IDE 25
+#define CLK_DISP2 26
+#define CLK_DISP1 27
+#define CLK_HOST1X 28
+#define CLK_VCP 29
+#define CLK_CACHE2 31
+#define CLK_MEM 32
+#define CLK_AHBDMA 33
+#define CLK_APBDMA 34
+#define CLK_KBC 36
+#define CLK_STAT_MON 37
+#define CLK_PMC 38
+#define CLK_FUSE 39
+#define CLK_KFUSE 40
+#define CLK_SBC1 41
+#define CLK_NOR 42
+#define CLK_SPI 43
+#define CLK_SBC2 44
+#define CLK_XIO 45
+#define CLK_SBC3 46
+#define CLK_DVC 47
+#define CLK_DSI 48
+#define CLK_MIPI 50
+#define CLK_HDMI 51
+#define CLK_CSI 52
+#define CLK_TVDAC 53
+#define CLK_I2C2 54
+#define CLK_UARTC 55
+#define CLK_EMC 57
+#define CLK_USB2 58
+#define CLK_USB3 59
+#define CLK_MPE 60
+#define CLK_VDE 61
+#define CLK_BSEA 62
+#define CLK_BSEV 63
+#define CLK_SPEEDO 64
+#define CLK_UARTD 65
+#define CLK_UARTE 66
+#define CLK_I2C3 67
+#define CLK_SBC4 68
+#define CLK_SDMMC3 69
+#define CLK_PEX 70
+#define CLK_OWR 71
+#define CLK_AFI 72
+#define CLK_CSITE 73
+#define CLK_PCIE_XCLK 74
+#define CLK_AVPUCQ 75
+#define CLK_LA 76
+#define CLK_IRAMA 84
+#define CLK_IRAMB 85
+#define CLK_IRAMC 86
+#define CLK_IRAMD 87
+#define CLK_CRAM2 88
+#define CLK_AUDIO_2X 89
+#define CLK_CLK_D 90
+#define CLK_CSUS 92
+#define CLK_CDEV1 93
+#define CLK_CDEV2 94
+#define CLK_UARTB 96
+#define CLK_VFIR 97
+#define CLK_SPDIF_IN 98
+#define CLK_SPDIF_OUT 99
+#define CLK_VI 100
+#define CLK_VI_SENSOR 101
+#define CLK_TVO 102
+#define CLK_CVE 103
+#define CLK_OSC 104
+#define CLK_CLK_32K 105
+#define CLK_CLK_M 106
+#define CLK_SCLK 107
+#define CLK_CCLK 108
+#define CLK_HCLK 109
+#define CLK_PCLK 110
+#define CLK_BLINK 111
+#define CLK_PLL_A 112
+#define CLK_PLL_A_OUT0 113
+#define CLK_PLL_C 114
+#define CLK_PLL_C_OUT1 115
+#define CLK_PLL_D 116
+#define CLK_PLL_D_OUT0 117
+#define CLK_PLL_E 118
+#define CLK_PLL_M 119
+#define CLK_PLL_M_OUT1 120
+#define CLK_PLL_P 121
+#define CLK_PLL_P_OUT1 122
+#define CLK_PLL_P_OUT2 123
+#define CLK_PLL_P_OUT3 124
+#define CLK_PLL_P_OUT4 125
+#define CLK_PLL_U 126
+#define CLK_PLL_X 127
+#define CLK_AUDIO 128
+#define CLK_PLL_REF 129
+#define CLK_TWD 130
+#define CLK_CLK_MAX 131
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

arch/arm/boot/dts/tegra20-car.h

Quoted 6 lines · Hiroshi Doyu

To replace magic number in tegra_car:

(quoted diff) +1 -1
-               clocks = <&tegra_car 28>;
+               clocks = <&tegra_car CLK_HOST1X>;
arch/arm/boot/dts/tegra20-car.h +0 -0

Sorry, forgot a couple small comments the last time around.

This file should probably have some header indicating which binding it describes, rather like the GPIO header in my patch series.

Quoted 1 line

+#define CLK_CPU 0

I'd suggest naming that TEGRA20_CLK_CPU, so that the various different clock headers don't conflict. It's not too likely that more than one of the /Tegra/ clock headers will be included at once, but it doesn't seem that unlikely that a board file could end up having a Tegra clock header included plus various other clock headers for some other chip that has some clock outputs.

Oh, and I don't think you updated e.g. nvidia,tegra20-car.txt to remove the list of clocks.

BTW, I assume this patch includes the changes from my recent "clk:
tegra: fix driver to match DT binding" and anything else similar that's in the most recent Tegra for-next?

#3 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

Stephen Warren <[email protected]> wrote @ Thu, 14 Feb 2013 21:15:28 +0100:

Quoted 2 lines

Oh, and I don't think you updated e.g. nvidia,tegra20-car.txt to remove the list of clocks.

Not yet removed. I think that this could be done with the patch which allows kernel source to include DT header files.

Quoted 3 lines

BTW, I assume this patch includes the changes from my recent "clk:
tegra: fix driver to match DT binding" and anything else similar that's in the most recent Tegra for-next?

Of course not, that's a little bit too recent.

I'll rerun my script against the laste Tegra for-next and post them as v3(inc. Tegra114)

#4 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

Quoted 7 lines · Hiroshi Doyu

Stephen Warren <[email protected]> wrote @ Thu, 14 Feb 2013 21:15:28 +0100:

Quoted 2 lines

Oh, and I don't think you updated e.g. nvidia,tegra20-car.txt to remove the list of clocks.

Not yet removed. I think that this could be done with the patch which allows kernel source to include DT header files.

By defining the header file, you're really causing that header to be part of the binding definition. I think we should move the code from the binding .txt file to the header, rather than duplicating it and then removing it. The kernel doesn't include the binding .txt file right now, so I don't see any correlation with making it include the header vs. when we remove the list from the binding document.

#5 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

In reply to Stephen Warren
Quoted 13 lines · Stephen Warren

arch/arm/boot/dts/tegra20-car.h

Quoted 6 lines · Hiroshi Doyu

To replace magic number in tegra_car:

(quoted diff) +1 -1
-               clocks = <&tegra_car 28>;
+               clocks = <&tegra_car CLK_HOST1X>;
arch/arm/boot/dts/tegra20-car.h +0 -0

Sorry, forgot a couple small comments the last time around.

This file should probably have some header indicating which binding it describes, rather like the GPIO header in my patch series.

Quoted 9 lines
Quoted 1 line

+#define CLK_CPU 0

I'd suggest naming that TEGRA20_CLK_CPU, so that the various different clock headers don't conflict. It's not too likely that more than one of the /Tegra/ clock headers will be included at once, but it doesn't seem that unlikely that a board file could end up having a Tegra clock header included plus various other clock headers for some other chip that has some clock outputs.

I would suggest removing this clock. It's not actually implemented in the CCF and rather useless. If you would gate the CPU clock from the CPU by writing to this register, how would you ungate it? :) Note that this would gate the clock to all CPUs.

Cheers,

Peter.

#6 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

Quoted 24 lines · Peter De Schrijver
Quoted 13 lines · Stephen Warren

arch/arm/boot/dts/tegra20-car.h

Quoted 6 lines · Hiroshi Doyu

To replace magic number in tegra_car:

(quoted diff) +1 -1
-               clocks = <&tegra_car 28>;
+               clocks = <&tegra_car CLK_HOST1X>;
arch/arm/boot/dts/tegra20-car.h +0 -0

Sorry, forgot a couple small comments the last time around.

This file should probably have some header indicating which binding it describes, rather like the GPIO header in my patch series.

Quoted 9 lines
Quoted 1 line

+#define CLK_CPU 0

I'd suggest naming that TEGRA20_CLK_CPU, so that the various different clock headers don't conflict. It's not too likely that more than one of the /Tegra/ clock headers will be included at once, but it doesn't seem that unlikely that a board file could end up having a Tegra clock header included plus various other clock headers for some other chip that has some clock outputs.

Quoted 4 lines

I would suggest removing this clock. It's not actually implemented in the CCF and rather useless. If you would gate the CPU clock from the CPU by writing to this register, how would you ungate it? :) Note that this would gate the clock to all CPUs.

(Note that my comment was re: all clocks, not just that one clock)

Can't the PMC or flow-controller ungate the clock based on some event? Either way, that clock definition exists in HW, right? So I don't think there's actually any harm in including the definition in the binding even if we never implement/use it.

#7 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

On Fri, Feb 15, 2013 at 05:45:45PM +0100, Stephen Warren wrote:

...

Quoted 8 lines
Quoted 4 lines

I would suggest removing this clock. It's not actually implemented in the CCF and rather useless. If you would gate the CPU clock from the CPU by writing to this register, how would you ungate it? :) Note that this would gate the clock to all CPUs.

(Note that my comment was re: all clocks, not just that one clock)

Can't the PMC or flow-controller ungate the clock based on some event?

I don't think the flow-controller controls this gate. The usual way of clockgating a core is to execute a WFI instruction. That will trigger clockgating the core, unless the flow-controller has been programmed to do something else. The flow-controller will ungate the clock when there is an interrupt.

Quoted 3 lines

Either way, that clock definition exists in HW, right? So I don't think there's actually any harm in including the definition in the binding even if we never implement/use it.

The clock definition seems to exist in HW yes, the corresponding resetbit however is marked as 'reserved' in the Tegra114 documentation.

Cheers,

Peter.

#8 lore raw

Re: [v2 1/4] ARM: tegra20: create a DT header defining CLK IDs

Quoted 19 lines · Peter De Schrijver

On Fri, Feb 15, 2013 at 05:45:45PM +0100, Stephen Warren wrote:

...

Quoted 8 lines
Quoted 4 lines

I would suggest removing this clock. It's not actually implemented in the CCF and rather useless. If you would gate the CPU clock from the CPU by writing to this register, how would you ungate it? :) Note that this would gate the clock to all CPUs.

(Note that my comment was re: all clocks, not just that one clock)

Can't the PMC or flow-controller ungate the clock based on some event?

I don't think the flow-controller controls this gate. The usual way of clockgating a core is to execute a WFI instruction. That will trigger clockgating the core, unless the flow-controller has been programmed to do something else. The flow-controller will ungate the clock when there is an interrupt.

Quoted 6 lines
Quoted 3 lines

Either way, that clock definition exists in HW, right? So I don't think there's actually any harm in including the definition in the binding even if we never implement/use it.

The clock definition seems to exist in HW yes, the corresponding resetbit however is marked as 'reserved' in the Tegra114 documentation.

Apparently from Tegra114 onwards, this bit no longer exists. In previous chips, it is just turned by the bootloader running on the AVP and stays on from there on. So at least for Tegra114 I think we remove this clock from the DT binding.

Cheers,

Peter.

#9 lore raw

PATCH v2 2/4 ARM: tegra20: convert device tree files to use CLK defines

In reply to Hiroshi Doyu

Replace magic number in tegra_car:

- clocks = <&tegra_car 28>;
+ clocks = <&tegra_car CLK_HOST1X>;

---
 .../bindings/clock/nvidia,tegra20-car.txt          |    2 +-
 arch/arm/boot/dts/tegra20-paz00.dtsp               |    2 +-
 arch/arm/boot/dts/tegra20.dtsip                    |   85 ++++++++++----------
 3 files changed, 45 insertions(+), 44 deletions(-)
Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt +1 -1
index 0921fac..8ceb8ce 100644
@@ -172,7 +172,7 @@ Example SoC include file:
 	};
 
 	usb@c5004000 {
-		clocks = <&tegra_car 58>; /* usb2 */
+		clocks = <&tegra_car CLK_USB2>; /* usb2 */
 	};
 };
 
arch/arm/boot/dts/tegra20-paz00.dtsp +1 -1
index e63473b..047ebda 100644
@@ -277,7 +277,7 @@
 		clock-frequency = <80000>;
 		request-gpios = <&gpio TEGRA_GPIO(V, 2) GPIO_ACTIVE_HIGH>;
 		slave-addr = <138>;
-		clocks = <&tegra_car 67>, <&tegra_car 124>;
+		clocks = <&tegra_car CLK_I2C3>, <&tegra_car CLK_PLL_P_OUT3>;
 		clock-names = "div-clk", "fast-clk";
 	};
 
arch/arm/boot/dts/tegra20.dtsip +43 -42

342 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v2 3/4 ARM: tegra30: create a DT header defining CLK IDs

In reply to Hiroshi Doyu

To replace magic number in tegra_car:

- clocks = <&tegra_car 28>;
+ clocks = <&tegra_car CLK_HOST1X>;

---
 arch/arm/boot/dts/tegra30-car.h |  171 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 171 insertions(+)
 create mode 100644 arch/arm/boot/dts/tegra30-car.h
arch/arm/boot/dts/tegra30-car.h new file +171 -0
new file mode 100644
index 0000000..96af7b3
@@ -0,0 +1,171 @@
+#define CLK_CPU 0
+#define CLK_RTC 4
+#define CLK_TIMER 5
+#define CLK_UARTA 6
+#define CLK_GPIO 8
+#define CLK_SDMMC2 9
+#define CLK_I2S1 11
+#define CLK_I2C1 12
+#define CLK_NDFLASH 13
+#define CLK_SDMMC1 14
+#define CLK_SDMMC4 15
+#define CLK_PWM 17
+#define CLK_I2S2 18
+#define CLK_EPP 19
+#define CLK_GR2D 21
+#define CLK_USBD 22
+#define CLK_ISP 23
+#define CLK_GR3D 24
+#define CLK_DISP2 26
+#define CLK_DISP1 27
+#define CLK_HOST1X 28
+#define CLK_VCP 29
+#define CLK_I2S0 30
+#define CLK_COP_CACHE 31
+#define CLK_MC 32
+#define CLK_AHBDMA 33
+#define CLK_APBDMA 34
+#define CLK_KBC 36
+#define CLK_STATMON 37
+#define CLK_PMC 38
+#define CLK_KFUSE 40
+#define CLK_SBC1 41
+#define CLK_NOR 42
+#define CLK_SBC2 44
+#define CLK_SBC3 46
+#define CLK_I2C5 47
+#define CLK_DSIA 48
+#define CLK_MIPI 50
+#define CLK_HDMI 51
+#define CLK_CSI 52
+#define CLK_TVDAC 53
+#define CLK_I2C2 54
+#define CLK_UARTC 55
+#define CLK_EMC 57
+#define CLK_USB2 58
+#define CLK_USB3 59
+#define CLK_MPE 60
+#define CLK_VDE 61
+#define CLK_BSEA 62
+#define CLK_BSEV 63
+#define CLK_SPEEDO 64
+#define CLK_UARTD 65
+#define CLK_UARTE 66
+#define CLK_I2C3 67
+#define CLK_SBC4 68
+#define CLK_SDMMC3 69
+#define CLK_PCIE 70
+#define CLK_OWR 71
+#define CLK_AFI 72
+#define CLK_CSITE 73
+#define CLK_PCIEX 74
+#define CLK_AVPUCQ 75
+#define CLK_LA 76
+#define CLK_DTV 79
+#define CLK_NDSPEED 80
+#define CLK_I2C_SLOW 81
+#define CLK_DSIB 82
+#define CLK_IRAMA 84
+#define CLK_IRAMB 85
+#define CLK_IRAMC 86
+#define CLK_IRAMD 87
+#define CLK_CRAM2 88
+#define CLK_AUDIO_2X 90
+#define CLK_CSUS 92
+#define CLK_CDEV1 93
+#define CLK_CDEV2 94
+#define CLK_CPU_G 96
+#define CLK_CPU_LP 97
+#define CLK_GR3D2 98
+#define CLK_MSELECT 99
+#define CLK_TSENSOR 100
+#define CLK_I2S3 101
+#define CLK_I2S4 102
+#define CLK_I2C4 103
+#define CLK_SBC5 104
+#define CLK_SBC6 105
+#define CLK_D_AUDIO 106
+#define CLK_APBIF 107
+#define CLK_DAM0 108
+#define CLK_DAM1 109
+#define CLK_DAM2 110
+#define CLK_HDA2CODEC_2X 111
+#define CLK_ATOMICS 112
+#define CLK_AUDIO0_2X 113
+#define CLK_AUDIO1_2X 114
+#define CLK_AUDIO2_2X 115
+#define CLK_AUDIO3_2X 116
+#define CLK_AUDIO4_2X 117
+#define CLK_SPDIF_2X 118
+#define CLK_ACTMON 119
+#define CLK_EXTERN1 120
+#define CLK_EXTERN2 121
+#define CLK_EXTERN3 122
+#define CLK_SATA_OOB 123
+#define CLK_SATA 124
+#define CLK_HDA 125
+#define CLK_SE 127
+#define CLK_HDA2HDMI 128
+#define CLK_SATA_COLD 129
+#define CLK_UARTB 160
+#define CLK_VFIR 161
+#define CLK_SPDIF_OUT 162
+#define CLK_SPDIF_IN 163
+#define CLK_VI 164
+#define CLK_VI_SENSOR 165
+#define CLK_FUSE 166
+#define CLK_FUSE_BURN 167
+#define CLK_CVE 168
+#define CLK_TVO 169
+#define CLK_CLK_32K 170
+#define CLK_CLK_M 171
+#define CLK_CLK_M_DIV2 172
+#define CLK_CLK_M_DIV4 173
+#define CLK_PLL_REF 174
+#define CLK_PLL_C 175
+#define CLK_PLL_C_OUT1 176
+#define CLK_PLL_M 177
+#define CLK_PLL_M_OUT1 178
+#define CLK_PLL_P 179
+#define CLK_PLL_P_OUT1 180
+#define CLK_PLL_P_OUT2 181
+#define CLK_PLL_P_OUT3 182
+#define CLK_PLL_P_OUT4 183
+#define CLK_PLL_A 184
+#define CLK_PLL_A_OUT0 185
+#define CLK_PLL_D 186
+#define CLK_PLL_D_OUT0 187
+#define CLK_PLL_D2 188
+#define CLK_PLL_D2_OUT0 189
+#define CLK_PLL_U 190
+#define CLK_PLL_X 191
+#define CLK_PLL_X_OUT0 192
+#define CLK_PLL_E 193
+#define CLK_SPDIF_IN_SYNC 194
+#define CLK_I2S0_SYNC 195
+#define CLK_I2S1_SYNC 196
+#define CLK_I2S2_SYNC 197
+#define CLK_I2S3_SYNC 198
+#define CLK_I2S4_SYNC 199
+#define CLK_VIMCLK_SYNC 200
+#define CLK_AUDIO0 201
+#define CLK_AUDIO1 202
+#define CLK_AUDIO2 203
+#define CLK_AUDIO3 204
+#define CLK_AUDIO4 205
+#define CLK_SPDIF 206
+#define CLK_CLK_OUT_1 207
+#define CLK_CLK_OUT_2 208
+#define CLK_CLK_OUT_3 209
+#define CLK_SCLK 210
+#define CLK_BLINK 211
+#define CLK_CCLK_G 212
+#define CLK_CCLK_LP 213
+#define CLK_TWD 214
+#define CLK_CML0 215
+#define CLK_CML1 216
+#define CLK_I2CSLOW 217
+#define CLK_HCLK 218
+#define CLK_PCLK 219
+#define CLK_CLK_OUT_1_MUX 300
+#define CLK_CLK_MAX 301
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH v2 4/4 ARM: tegra30: convert device tree files to use CLK defines

In reply to Hiroshi Doyu

Replace magic number in tegra_car:

- clocks = <&tegra_car 28>;
+ clocks = <&tegra_car CLK_HOST1X>;

---
 .../bindings/clock/nvidia,tegra30-car.txt          |    2 +-
 arch/arm/boot/dts/tegra30.dtsip                    |   87 ++++++++++----------
 2 files changed, 45 insertions(+), 44 deletions(-)
Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt +1 -1
index f3da3be..bc9660b 100644
@@ -229,7 +229,7 @@ Example SoC include file:
 	};
 
 	usb@c5004000 {
-		clocks = <&tegra_car 58>; /* usb2 */
+		clocks = <&tegra_car CLK_USB2>; /* usb2 */
 	};
 };
 
arch/arm/boot/dts/tegra30.dtsip +44 -43

333 lines not on this page · raw message

Signature · 1 line
1.7.9.5