Skip to contentSkip to conversation

clk: sunxi: gates support

PATCH Superseded Emilio López 5 participants 37 messages Mar 22, 2013 – Apr 5, 2013

Subsystems (5)
lore
Share & tools
lore

Emilio López

author maintainer
#0 lore raw

cover clk: sunxi: gates support

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Thanks,

Emilio

Emilio L?pez (6):
clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates
arm: sunxi: Add clock definitions for AXI, AHB, APB0, APB1 gates
arm: sunxi: use the right clock phandles for UARTs
pinctrl: sunxi: add clock support
arm: sunxi: Add clock to pinctrl node
clk: sunxi: drop CLK_IGNORE_UNUSED

 Documentation/devicetree/bindings/clock/sunxi.txt | 108 +++++++++++++++++++++-
 arch/arm/boot/dts/sun4i-a10.dtsi                  |  13 +--
 arch/arm/boot/dts/sun5i-a13.dtsi                  |   1 +
 arch/arm/boot/dts/sunxi.dtsi                      |  53 ++++++++++-
 drivers/clk/sunxi/clk-sunxi.c                     |  98 +++++++++++++++++++-
 drivers/pinctrl/pinctrl-sunxi.c                   |   8 ++
 6 files changed, 267 insertions(+), 14 deletions(-)
Signature · 1 line
1.8.2
author maintainer
#1 lore raw

PATCH 1/6 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

This patchset adds DT support for all the AXI, AHB, APB0 and APB1 gates present on sunxi SoCs.

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 108 +++++++++++++++++++++-
 drivers/clk/sunxi/clk-sunxi.c                     |  90 +++++++++++++++++-
 2 files changed, 196 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +107 -1
index b23cfbd..c5432c4 100644
@@ -10,15 +10,23 @@ Required properties:
 	"allwinner,sunxi-pll1-clk" - for the main PLL clock
 	"allwinner,sunxi-cpu-clk" - for the CPU multiplexer clock
 	"allwinner,sunxi-axi-clk" - for the sunxi AXI clock
+	"allwinner,sunxi-axi-gates-clk" - for the AXI gates
 	"allwinner,sunxi-ahb-clk" - for the sunxi AHB clock
+	"allwinner,sunxi-ahb-gates-clk" - for the AHB gates
 	"allwinner,sunxi-apb0-clk" - for the sunxi APB0 clock
+	"allwinner,sunxi-apb0-gates-clk" - for the APB0 gates
 	"allwinner,sunxi-apb1-clk" - for the sunxi APB1 clock
 	"allwinner,sunxi-apb1-mux-clk" - for the sunxi APB1 clock muxing
+	"allwinner,sunxi-apb1-gates-clk" - for the APB1 gates
 
 Required properties for all clocks:
 - reg : shall be the control register address for the clock.
 - clocks : shall be the input parent clock(s) phandle for the clock
-- #clock-cells : from common clock binding; shall be set to 0.
+- #clock-cells : from common clock binding; shall be set to 0 except for
+	"allwinner,sunxi-*-gates-clk" where it shall be set to 1
+
+Additionally, "allwinner,sunxi-*-gates-clk" clocks require:
+- clock-output-names : the corresponding gate names that the clock controls
 
 For example:
 
@@ -42,3 +50,101 @@ cpu: cpu at 01c20054 {
 	reg = <0x01c20054 0x4>;
 	clocks = <&osc32k>, <&osc24M>, <&pll1>;
 };
+
+
+
+Gate clock outputs
+
+The "allwinner,sunxi-*-gates-clk" clocks provide several gatable outputs;
+their corresponding offsets are listed below:
+
+  * AXI gates ("allwinner,sunxi-axi-gates-clk")
+
+    DRAM                                                                0
+
+  * AHB gates ("allwinner,sunxi-ahb-gates-clk")
+
+    USB0                                                                0
+    EHCI0                                                               1
+    OHCI0                                                               2*
+    EHCI1                                                               3
+    OHCI1                                                               4*
+    SS                                                                  5
+    DMA                                                                 6
+    BIST                                                                7
+    MMC0                                                                8
+    MMC1                                                                9
+    MMC2                                                                10
+    MMC3                                                                11
+    MS                                                                  12**
+    NAND                                                                13
+    SDRAM                                                               14
+
+    ACE                                                                 16
+    EMAC                                                                17
+    TS                                                                  18
+
+    SPI0                                                                20
+    SPI1                                                                21
+    SPI2                                                                22
+    SPI3                                                                23
+    PATA                                                                24
+    SATA                                                                25**
+    GPS                                                                 26*
+
+    VE                                                                  32
+    TVD                                                                 33
+    TVE0                                                                34
+    TVE1                                                                35
+    LCD0                                                                36
+    LCD1                                                                37
+
+    CSI0                                                                40
+    CSI1                                                                41
+
+    HDMI                                                                43
+    DE_BE0                                                              44
+    DE_BE1                                                              45
+    DE_FE0                                                              46
+    DE_FE1                                                              47
+
+    MP                                                                  50
+
+    MALI400                                                             52
+
+  * APB0 gates ("allwinner,sunxi-apb0-gates-clk")
+
+    CODEC                                                               0
+    SPDIF                                                               1*
+    AC97                                                                2
+    IIS                                                                 3
+
+    PIO                                                                 5
+    IR0                                                                 6
+    IR1                                                                 7
+
+    KEYPAD                                                              10
+
+  * APB1 gates ("allwinner,sunxi-apb1-gates-clk")
+
+    TWI0                                                                0
+    TWI1                                                                1
+    TWI2                                                                2
+
+    CAN                                                                 4
+    SCR                                                                 5
+    PS20                                                                6
+    PS21                                                                7
+
+    UART0                                                               16
+    UART1                                                               17
+    UART2                                                               18
+    UART3                                                               19
+    UART4                                                               20
+    UART5                                                               21
+    UART6                                                               22
+    UART7                                                               23
+
+Notation:
+ [*]:  The datasheet didn't mention these, but they are present on AW code
+ [**]: The datasheet had this marked as "NC" but they are used on AW code
drivers/clk/sunxi/clk-sunxi.c +88 -0

104 lines not on this page · raw message

Signature · 1 line
1.8.2
#2 lore raw

PATCH v2 1/6 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Hi Emilio,

I have a few comments below,

Le 22/03/2013 15:20, Emilio L?pez a ?crit :

Quoted 15 lines

This patchset adds DT support for all the AXI, AHB, APB0 and APB1 gates present on sunxi SoCs.

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 108 +++++++++++++++++++++-
 drivers/clk/sunxi/clk-sunxi.c                     |  90 +++++++++++++++++-
 2 files changed, 196 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +0 -0
index b23cfbd..c5432c4 100644
@@ -10,15 +10,23 @@ Required properties:
 	"allwinner,sunxi-pll1-clk" - for the main PLL clock

Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +4 -0
 	"allwinner,sunxi-cpu-clk" - for the CPU multiplexer clock
 	"allwinner,sunxi-axi-clk" - for the sunxi AXI clock
+	"allwinner,sunxi-axi-gates-clk" - for the AXI gates
 	"allwinner,sunxi-ahb-clk" - for the sunxi AHB clock
+	"allwinner,sunxi-ahb-gates-clk" - for the AHB gates
 	"allwinner,sunxi-apb0-clk" - for the sunxi APB0 clock
+	"allwinner,sunxi-apb0-gates-clk" - for the APB0 gates
 	"allwinner,sunxi-apb1-clk" - for the sunxi APB1 clock
 	"allwinner,sunxi-apb1-mux-clk" - for the sunxi APB1 clock muxing
+	"allwinner,sunxi-apb1-gates-clk" - for the APB1 gates

It has been pointed to me that the usual way of dealing with compatible IPs in several generation of SoC in device tree is usually to use the oldest SoC name to support it, and not some generic term like we use.

I'm currently struggling while doing some work on the A31, where some IPs differ in a significant way from the A10/A13, and we can't just use sunxi anymore.

I have a patchset that renames every other IP we have doing this, but could you rename your compatible strings to allwinner,sun4i* as a first patch for the already existing clocks, and use that prefix in the following patches as well? Moreover, since it has been mostly tested on an A10, if the IP came to differ to some aspect in the A13, it will make our life easier as well.

Quoted 39 lines
Documentation/devicetree/bindings/clock/sunxi.txt +27 -1
 Required properties for all clocks:
 - reg : shall be the control register address for the clock.
 - clocks : shall be the input parent clock(s) phandle for the clock
-- #clock-cells : from common clock binding; shall be set to 0.
+- #clock-cells : from common clock binding; shall be set to 0 except for
+	"allwinner,sunxi-*-gates-clk" where it shall be set to 1
+
+Additionally, "allwinner,sunxi-*-gates-clk" clocks require:
+- clock-output-names : the corresponding gate names that the clock controls
 
 For example:
 
@@ -42,3 +50,101 @@ cpu: cpu at 01c20054 {
 	reg = <0x01c20054 0x4>;
 	clocks = <&osc32k>, <&osc24M>, <&pll1>;
 };
+
+
+
+Gate clock outputs
+
+The "allwinner,sunxi-*-gates-clk" clocks provide several gatable outputs;
+their corresponding offsets are listed below:
+
+  * AXI gates ("allwinner,sunxi-axi-gates-clk")
+
+    DRAM                                                                0
+
+  * AHB gates ("allwinner,sunxi-ahb-gates-clk")
+
+    USB0                                                                0
+    EHCI0                                                               1
+    OHCI0                                                               2*
+    EHCI1                                                               3
+    OHCI1                                                               4*
+    SS                                                                  5
+    DMA                                                                 6
+    BIST                                                                7

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 84

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +10 -0
+    MMC0                                                                8
+    MMC1                                                                9
+    MMC2                                                                10
+    MMC3                                                                11
+    MS                                                                  12**
+    NAND                                                                13
+    SDRAM                                                               14
+
+    ACE                                                                 16
+    EMAC                                                                17

Hmmm, this makes me thinking that I used wemac in the pinctrl driver, and that it's not really consistent with the datasheet, what you have here, and what I did in the EMAC driver. I'll need to change that...

Quoted 38 lines
Documentation/devicetree/bindings/clock/sunxi.txt +38 -0
+    TS                                                                  18
+
+    SPI0                                                                20
+    SPI1                                                                21
+    SPI2                                                                22
+    SPI3                                                                23
+    PATA                                                                24
+    SATA                                                                25**
+    GPS                                                                 26*
+
+    VE                                                                  32
+    TVD                                                                 33
+    TVE0                                                                34
+    TVE1                                                                35
+    LCD0                                                                36
+    LCD1                                                                37
+
+    CSI0                                                                40
+    CSI1                                                                41
+
+    HDMI                                                                43
+    DE_BE0                                                              44
+    DE_BE1                                                              45
+    DE_FE0                                                              46
+    DE_FE1                                                              47
+
+    MP                                                                  50
+
+    MALI400                                                             52
+
+  * APB0 gates ("allwinner,sunxi-apb0-gates-clk")
+
+    CODEC                                                               0
+    SPDIF                                                               1*
+    AC97                                                                2
+    IIS                                                                 3
+
+    PIO                                                                 5

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 132

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +10 -0
+    IR0                                                                 6
+    IR1                                                                 7
+
+    KEYPAD                                                              10
+
+  * APB1 gates ("allwinner,sunxi-apb1-gates-clk")
+
+    TWI0                                                                0
+    TWI1                                                                1
+    TWI2                                                                2

I'd rather see here I2C. I know that it's called TWI in the datasheet, but the term I2C is more commonly used in the kernel.

Quoted 7 lines
Documentation/devicetree/bindings/clock/sunxi.txt +7 -0
+    CAN                                                                 4
+    SCR                                                                 5
+    PS20                                                                6
+    PS21                                                                7
+
+    UART0                                                               16
+    UART1                                                               17

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 150

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +10 -0
+    UART2                                                               18
+    UART3                                                               19
+    UART4                                                               20
+    UART5                                                               21
+    UART6                                                               22
+    UART7                                                               23
+
+Notation:
+ [*]:  The datasheet didn't mention these, but they are present on AW code
+ [**]: The datasheet had this marked as "NC" but they are used on AW code

I'm really happy with the general documentation, thanks for this. However, all of this is true only for the A10, could you mention it somewhere?

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author maintainer
#3 lore raw

PATCH 1/6 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Hi Maxime,

El 25/03/13 06:43, Maxime Ripard escribi?:

Quoted 39 lines

Hi Emilio,

I have a few comments below,

Le 22/03/2013 15:20, Emilio L?pez a ?crit :

Quoted 15 lines

This patchset adds DT support for all the AXI, AHB, APB0 and APB1 gates present on sunxi SoCs.

---
 Documentation/devicetree/bindings/clock/sunxi.txt | 108 +++++++++++++++++++++-
 drivers/clk/sunxi/clk-sunxi.c                     |  90 +++++++++++++++++-
 2 files changed, 196 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/clock/sunxi.txt +0 -0
index b23cfbd..c5432c4 100644
@@ -10,15 +10,23 @@ Required properties:
 	"allwinner,sunxi-pll1-clk" - for the main PLL clock

Documentation/devicetree/bindings/clock/sunxi.txt Required properties: · line 20

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +4 -0
 	"allwinner,sunxi-cpu-clk" - for the CPU multiplexer clock
 	"allwinner,sunxi-axi-clk" - for the sunxi AXI clock
+	"allwinner,sunxi-axi-gates-clk" - for the AXI gates
 	"allwinner,sunxi-ahb-clk" - for the sunxi AHB clock
+	"allwinner,sunxi-ahb-gates-clk" - for the AHB gates
 	"allwinner,sunxi-apb0-clk" - for the sunxi APB0 clock
+	"allwinner,sunxi-apb0-gates-clk" - for the APB0 gates
 	"allwinner,sunxi-apb1-clk" - for the sunxi APB1 clock
 	"allwinner,sunxi-apb1-mux-clk" - for the sunxi APB1 clock muxing
+	"allwinner,sunxi-apb1-gates-clk" - for the APB1 gates

It has been pointed to me that the usual way of dealing with compatible IPs in several generation of SoC in device tree is usually to use the oldest SoC name to support it, and not some generic term like we use.

I'm currently struggling while doing some work on the A31, where some IPs differ in a significant way from the A10/A13, and we can't just use sunxi anymore.

Quoted 6 lines

I have a patchset that renames every other IP we have doing this, but could you rename your compatible strings to allwinner,sun4i* as a first patch for the already existing clocks, and use that prefix in the following patches as well? Moreover, since it has been mostly tested on an A10, if the IP came to differ to some aspect in the A13, it will make our life easier as well.

Ok, I'll do so.

Quoted 98 lines
Quoted 40 lines
Documentation/devicetree/bindings/clock/sunxi.txt +27 -1
 Required properties for all clocks:
 - reg : shall be the control register address for the clock.
 - clocks : shall be the input parent clock(s) phandle for the clock
-- #clock-cells : from common clock binding; shall be set to 0.
+- #clock-cells : from common clock binding; shall be set to 0 except for
+	"allwinner,sunxi-*-gates-clk" where it shall be set to 1
+
+Additionally, "allwinner,sunxi-*-gates-clk" clocks require:
+- clock-output-names : the corresponding gate names that the clock controls
 
 For example:
 
@@ -42,3 +50,101 @@ cpu: cpu at 01c20054 {
 	reg = <0x01c20054 0x4>;
 	clocks = <&osc32k>, <&osc24M>, <&pll1>;
 };
+
+
+
+Gate clock outputs
+
+The "allwinner,sunxi-*-gates-clk" clocks provide several gatable outputs;
+their corresponding offsets are listed below:
+
+  * AXI gates ("allwinner,sunxi-axi-gates-clk")
+
+    DRAM                                                                0
+
+  * AHB gates ("allwinner,sunxi-ahb-gates-clk")
+
+    USB0                                                                0
+    EHCI0                                                               1
+    OHCI0                                                               2*
+    EHCI1                                                               3
+    OHCI1                                                               4*
+    SS                                                                  5
+    DMA                                                                 6
+    BIST                                                                7

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 84

Quoted 10 lines
Documentation/devicetree/bindings/clock/sunxi.txt +10 -0
+    MMC0                                                                8
+    MMC1                                                                9
+    MMC2                                                                10
+    MMC3                                                                11
+    MS                                                                  12**
+    NAND                                                                13
+    SDRAM                                                               14
+
+    ACE                                                                 16
+    EMAC                                                                17

Hmmm, this makes me thinking that I used wemac in the pinctrl driver, and that it's not really consistent with the datasheet, what you have here, and what I did in the EMAC driver. I'll need to change that...

Quoted 43 lines
Documentation/devicetree/bindings/clock/sunxi.txt +43 -0
+    TS                                                                  18
+
+    SPI0                                                                20
+    SPI1                                                                21
+    SPI2                                                                22
+    SPI3                                                                23
+    PATA                                                                24
+    SATA                                                                25**
+    GPS                                                                 26*
+
+    VE                                                                  32
+    TVD                                                                 33
+    TVE0                                                                34
+    TVE1                                                                35
+    LCD0                                                                36
+    LCD1                                                                37
+
+    CSI0                                                                40
+    CSI1                                                                41
+
+    HDMI                                                                43
+    DE_BE0                                                              44
+    DE_BE1                                                              45
+    DE_FE0                                                              46
+    DE_FE1                                                              47
+
+    MP                                                                  50
+
+    MALI400                                                             52
+
+  * APB0 gates ("allwinner,sunxi-apb0-gates-clk")
+
+    CODEC                                                               0
+    SPDIF                                                               1*
+    AC97                                                                2
+    IIS                                                                 3
+
+    PIO                                                                 5
+    IR0                                                                 6
+    IR1                                                                 7
+
+    KEYPAD                                                              10
+
Quoted 8 lines

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 132

Quoted 5 lines
Documentation/devicetree/bindings/clock/sunxi.txt +5 -0
+  * APB1 gates ("allwinner,sunxi-apb1-gates-clk")
+
+    TWI0                                                                0
+    TWI1                                                                1
+    TWI2                                                                2

I'd rather see here I2C. I know that it's called TWI in the datasheet, but the term I2C is more commonly used in the kernel.

Ok, I'll change it. Do you want me to rename the gate names on the DT too to match? ("apb1_twi0" -> "apb1_i2c0")

Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/clock/sunxi.txt +13 -0
+    CAN                                                                 4
+    SCR                                                                 5
+    PS20                                                                6
+    PS21                                                                7
+
+    UART0                                                               16
+    UART1                                                               17
+    UART2                                                               18
+    UART3                                                               19
+    UART4                                                               20
+    UART5                                                               21
+    UART6                                                               22
+    UART7                                                               23
Quoted 8 lines

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 150

Quoted 4 lines
Documentation/devicetree/bindings/clock/sunxi.txt +4 -0
+
+Notation:
+ [*]:  The datasheet didn't mention these, but they are present on AW code
+ [**]: The datasheet had this marked as "NC" but they are used on AW code

I'm really happy with the general documentation, thanks for this. However, all of this is true only for the A10, could you mention it somewhere?

I could add a note saying so. We could also rename this file to sun4i.txt and then and add a sun5i.txt with the A13 gate descriptions too; what would you prefer?

Thanks for the review,

Emilio

#4 lore raw

PATCH v2 1/6 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Le 25/03/2013 11:17, Emilio L?pez a ?crit :

Quoted 7 lines

El 25/03/13 06:43, Maxime Ripard escribi?:

Quoted 6 lines
Quoted 5 lines
Documentation/devicetree/bindings/clock/sunxi.txt +5 -0
+  * APB1 gates ("allwinner,sunxi-apb1-gates-clk")
+
+    TWI0                                                                0
+    TWI1                                                                1
+    TWI2                                                                2
Quoted 5 lines
Quoted 2 lines

I'd rather see here I2C. I know that it's called TWI in the datasheet, but the term I2C is more commonly used in the kernel.

Ok, I'll change it. Do you want me to rename the gate names on the DT too to match? ("apb1_twi0" -> "apb1_i2c0")

Yes, it would be nice.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Documentation/devicetree/bindings/clock/sunxi.txt +13 -0
+    CAN                                                                 4
+    SCR                                                                 5
+    PS20                                                                6
+    PS21                                                                7
+
+    UART0                                                               16
+    UART1                                                               17
+    UART2                                                               18
+    UART3                                                               19
+    UART4                                                               20
+    UART5                                                               21
+    UART6                                                               22
+    UART7                                                               23
Quoted 8 lines

Documentation/devicetree/bindings/clock/sunxi.txt cpu: cpu at 01c20054 { · line 150

Quoted 4 lines
Documentation/devicetree/bindings/clock/sunxi.txt +4 -0
+
+Notation:
+ [*]:  The datasheet didn't mention these, but they are present on AW code
+ [**]: The datasheet had this marked as "NC" but they are used on AW code

I'm really happy with the general documentation, thanks for this. However, all of this is true only for the A10, could you mention it somewhere?

Quoted 5 lines

I could add a note saying so. We could also rename this file to sun4i.txt and then and add a sun5i.txt with the A13 gate descriptions too; what would you prefer?

From what we've seen so far, A10 and A13 will share a lot except the

gates in the documentation, so maybe you can keep this sunxi.txt file with the generic comments, and add a note at the bottom saying to refer to either sun4i.txt or sun5i.txt files for details.

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
author maintainer
#5 lore raw

PATCH 2/6 arm: sunxi: Add clock definitions for AXI, AHB, APB0, APB1 gates

In reply to Emilio López

This commit adds the corresponding DT bindings for all the AXI, AHB, APB0 and APB1 gates.

---
 arch/arm/boot/dts/sunxi.dtsi | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
arch/arm/boot/dts/sunxi.dtsi +49 -0
index cafd393..22f0d9d 100644
@@ -80,6 +80,14 @@
 			clocks = <&cpu>;
 		};
 
+		axi_gates: axi_gates at 01c2005c {
+			#clock-cells = <1>;
+			compatible = "allwinner,sunxi-axi-gates-clk";
+			reg = <0x01c2005c 0x4>;
+			clocks = <&axi>;
+			clock-output-names = "axi_dram";
+		};
+
 		ahb: ahb at 01c20054 {
 			#clock-cells = <0>;
 			compatible = "allwinner,sunxi-ahb-clk";
@@ -87,6 +95,24 @@
 			clocks = <&axi>;
 		};
 
+		ahb_gates: ahb_gates at 01c20060 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sunxi-ahb-gates-clk";
+			reg = <0x01c20060 0x8>;
+			clocks = <&ahb>;
+			clock-output-names = "ahb_usb0", "ahb_ehci0",
+				"ahb_ohci0", "ahb_ehci1", "ahb_ohci1", "ahb_ss",
+				"ahb_dma", "ahb_bist", "ahb_mmc0", "ahb_mmc1",
+				"ahb_mmc2", "ahb_mmc3", "ahb_ms", "ahb_nand",
+				"ahb_sdram", "ahb_ace",	"ahb_emac", "ahb_ts",
+				"ahb_spi0", "ahb_spi1", "ahb_spi2", "ahb_spi3",
+				"ahb_pata", "ahb_sata", "ahb_gps", "ahb_ve",
+				"ahb_tvd", "ahb_tve0", "ahb_tve1", "ahb_lcd0",
+				"ahb_lcd1", "ahb_csi0", "ahb_csi1", "ahb_hdmi",
+				"ahb_de_be0", "ahb_de_be1", "ahb_de_fe0",
+				"ahb_de_fe1", "ahb_mp", "ahb_mali400";
+		};
+
 		apb0: apb0 at 01c20054 {
 			#clock-cells = <0>;
 			compatible = "allwinner,sunxi-apb0-clk";
@@ -94,6 +120,16 @@
 			clocks = <&ahb>;
 		};
 
+		apb0_gates: apb0_gates at 01c20068 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sunxi-apb0-gates-clk";
+			reg = <0x01c20068 0x4>;
+			clocks = <&apb0>;
+			clock-output-names = "apb0_codec", "apb0_spdif",
+				"apb0_ac97", "apb0_iis", "apb0_pio", "apb0_ir0",
+				"apb0_ir1", "apb0_keypad";
+		};
+
 		/* dummy is pll62 */
 		apb1_mux: apb1_mux at 01c20058 {
 			#clock-cells = <0>;
@@ -108,6 +144,19 @@
 			reg = <0x01c20058 0x4>;
 			clocks = <&apb1_mux>;
 		};
+
+		apb1_gates: apb1_gates at 01c2006c {
+			#clock-cells = <1>;
+			compatible = "allwinner,sunxi-apb1-gates-clk";
+			reg = <0x01c2006c 0x4>;
+			clocks = <&apb1>;
+			clock-output-names = "apb1_twi0", "apb1_twi1",
+				"apb1_twi2", "apb1_can", "apb1_scr",
+				"apb1_ps20", "apb1_ps21", "apb1_uart0",
+				"apb1_uart1", "apb1_uart2", "apb1_uart3",
+				"apb1_uart4", "apb1_uart5", "apb1_uart6",
+				"apb1_uart7";
+		};
 	};
 
 	soc {
Signature · 1 line
1.8.2
author maintainer
#6 lore raw

PATCH 3/6 arm: sunxi: use the right clock phandles for UARTs

In reply to Emilio López

All the UARTs are connected to clock gates; now that our clock driver is able to handle them, make the switch.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 12 ++++++------
 arch/arm/boot/dts/sunxi.dtsi     |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/boot/dts/sun4i-a10.dtsi +6 -6
index 68a27fc..6b3a6b2 100644
@@ -54,7 +54,7 @@
 			interrupts = <1>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 16>;
 			status = "disabled";
 		};
 
@@ -64,7 +64,7 @@
 			interrupts = <3>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 18>;
 			status = "disabled";
 		};
 
@@ -74,7 +74,7 @@
 			interrupts = <17>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 20>;
 			status = "disabled";
 		};
 
@@ -84,7 +84,7 @@
 			interrupts = <18>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 21>;
 			status = "disabled";
 		};
 
@@ -94,7 +94,7 @@
 			interrupts = <19>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 22>;
 			status = "disabled";
 		};
 
@@ -104,7 +104,7 @@
 			interrupts = <20>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 23>;
 			status = "disabled";
 		};
 	};
arch/arm/boot/dts/sunxi.dtsi +2 -2
index 22f0d9d..27a4fe2 100644
@@ -191,7 +191,7 @@
 			interrupts = <2>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 17>;
 			status = "disabled";
 		};
 
@@ -201,7 +201,7 @@
 			interrupts = <4>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 19>;
 			status = "disabled";
 		};
 	};
Signature · 1 line
1.8.2
author maintainer
#7 lore raw

PATCH 4/6 pinctrl: sunxi: add clock support

In reply to Emilio López

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

---
 drivers/pinctrl/pinctrl-sunxi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pinctrl/pinctrl-sunxi.c +8 -0
index 3e41cd1..a1e2af7 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -1917,6 +1918,7 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct sunxi_pinctrl *pctl;
 	int i, ret, last_pin;
+	struct clk *clk;
 
 	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
 	if (!pctl)
@@ -1987,6 +1989,12 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 			goto gpiochip_error;
 	}
 
+	clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(clk))
+		goto gpiochip_error;
+
+	clk_prepare_enable(clk);
+
 	dev_info(&pdev->dev, "initialized sunXi PIO driver\n");
 
 	return 0;
Signature · 1 line
1.8.2
#8 lore raw

PATCH 4/6 pinctrl: sunxi: add clock support

Quoted 5 lines · Emilio L?pez

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

Yours,
Linus Walleij

#9 lore raw

PATCH v2 4/6 pinctrl: sunxi: add clock support

Hi Linus,

Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 6 lines · Emilio L?pez
Quoted 5 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 6 lines
Quoted 1 line

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#10 lore raw

PATCH 4/6 pinctrl: sunxi: add clock support

Quoted 10 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 8 lines · Emilio L?pez
Quoted 6 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 8 lines
Quoted 4 lines

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

OK then, patch applied to the pinctrl tree, thanks!

Yours,
Linus Walleij

#11 lore raw

PATCH v2 4/6 pinctrl: sunxi: add clock support

Hi Linus,

Le 03/04/2013 13:59, Linus Walleij a ?crit :

Quoted 15 lines
Quoted 12 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 10 lines · Emilio L?pez
Quoted 6 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

OK then, patch applied to the pinctrl tree, thanks!

Ouch, the previous patches aren't applied yet by Mike, and we didn't have some comments from him about these patches, so I can't really say if the previous patches will get merge by 3.10 or not... So we will maybe end up with a broken pinctrl stuff.

Mike, do you have some comments on Emilio's patches?

If you do, we can still fix things up later by applying a slightly modified version of patches 5/6 with a clock that is already there, for it to load properly.

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

PATCH v2 4/6 pinctrl: sunxi: add clock support

Quoting Maxime Ripard (2013-04-03 14:20:37)

Quoted 32 lines

Hi Linus,

Le 03/04/2013 13:59, Linus Walleij a ?crit :

Quoted 15 lines
Quoted 12 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 10 lines · Emilio L?pez
Quoted 6 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

OK then, patch applied to the pinctrl tree, thanks!

Ouch, the previous patches aren't applied yet by Mike, and we didn't have some comments from him about these patches, so I can't really say if the previous patches will get merge by 3.10 or not... So we will maybe end up with a broken pinctrl stuff.

Quoted 6 lines

Mike, do you have some comments on Emilio's patches?

If you do, we can still fix things up later by applying a slightly modified version of patches 5/6 with a clock that is already there, for it to load properly.

Hi Maxime,

I did leave some comments a few hours ago. It would be better if the fixes could be rolled in now, but if that is somehow impossible then I don't mind taking them as-is with fixes at a later date. Just let me know.

Regards,
Mike

Quoted 7 lines

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#13 lore raw

PATCH 4/6 pinctrl: sunxi: add clock support

In reply to Maxime Ripard
Quoted 23 lines · Maxime Ripard

Le 03/04/2013 13:59, Linus Walleij a ?crit :

Quoted 22 lines
Quoted 18 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 6 lines · Emilio L?pez
Quoted 5 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 6 lines
Quoted 1 line

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

Quoted 6 lines
Quoted 1 line

OK then, patch applied to the pinctrl tree, thanks!

Ouch, the previous patches aren't applied yet by Mike, and we didn't have some comments from him about these patches, so I can't really say if the previous patches will get merge by 3.10 or not... So we will maybe end up with a broken pinctrl stuff.

This is usually why we keep patches together and merge whole series into one tree, such as ARM SoC.

Well, maybe I'll drop it then ...

Yours,
Linus Walleij

#14 lore raw

PATCH v2 4/6 pinctrl: sunxi: add clock support

Quoting Linus Walleij (2013-04-04 04:37:23)

Quoted 32 lines
Quoted 23 lines · Maxime Ripard

Le 03/04/2013 13:59, Linus Walleij a ?crit :

Quoted 22 lines
Quoted 18 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 6 lines · Emilio L?pez
Quoted 5 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 6 lines
Quoted 1 line

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

Quoted 6 lines
Quoted 1 line

OK then, patch applied to the pinctrl tree, thanks!

Ouch, the previous patches aren't applied yet by Mike, and we didn't have some comments from him about these patches, so I can't really say if the previous patches will get merge by 3.10 or not... So we will maybe end up with a broken pinctrl stuff.

Quoted 5 lines

This is usually why we keep patches together and merge whole series into one tree, such as ARM SoC.

Well, maybe I'll drop it then ...

I plan on taking in the three clk patches after getting final comments from Gregory. So maybe you do not need to drop the pinctrl patches?

Regards,
Mike

Quoted 2 lines

Yours,
Linus Walleij

#15 lore raw

PATCH 4/6 pinctrl: sunxi: add clock support

Quoted 33 lines · Mike Turquette

Quoting Linus Walleij (2013-04-04 04:37:23)

Quoted 32 lines
Quoted 29 lines · Maxime Ripard

Le 03/04/2013 13:59, Linus Walleij a ?crit :

Quoted 15 lines
Quoted 12 lines · Maxime Ripard

Hi Linus,
Le 27/03/2013 14:14, Linus Walleij a ?crit :

Quoted 10 lines · Emilio L?pez
Quoted 6 lines

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I guess you'll want to merge these as one series to some platform-specific tree, tell me if you want it merged in the pinctrl tree.

The easiest would probably be to merge this patch through your patch, with Mike taking the clock driver patches and me taking the dt ones, once we agree on the other patches.

OK then, patch applied to the pinctrl tree, thanks!

Ouch, the previous patches aren't applied yet by Mike, and we didn't have some comments from him about these patches, so I can't really say if the previous patches will get merge by 3.10 or not... So we will maybe end up with a broken pinctrl stuff.

Quoted 8 lines
Quoted 5 lines

This is usually why we keep patches together and merge whole series into one tree, such as ARM SoC.

Well, maybe I'll drop it then ...

I plan on taking in the three clk patches after getting final comments from Gregory. So maybe you do not need to drop the pinctrl patches?

No, I'm keeping it around, no problem.

Thanks Mike,
Linus Walleij

author maintainer
#16 lore raw

PATCH 5/6 arm: sunxi: Add clock to pinctrl node

In reply to Emilio López

The port controller needs the apb0_pio clock enabled to be able to work. This commit declares that on the device tree.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 1 +
 arch/arm/boot/dts/sun5i-a13.dtsi | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +1 -0
index 6b3a6b2..f640520 100644
@@ -21,6 +21,7 @@
 		pio: pinctrl at 01c20800 {
 			compatible = "allwinner,sun4i-a10-pinctrl";
 			reg = <0x01c20800 0x400>;
+			clocks = <&apb0_gates 5>;
 			gpio-controller;
 			#address-cells = <1>;
 			#size-cells = <0>;
arch/arm/boot/dts/sun5i-a13.dtsi +1 -0
index 945bfac..10ee8ee 100644
@@ -22,6 +22,7 @@
 		pio: pinctrl at 01c20800 {
 			compatible = "allwinner,sun5i-a13-pinctrl";
 			reg = <0x01c20800 0x400>;
+			clocks = <&apb0_gates 5>;
 			gpio-controller;
 			#address-cells = <1>;
 			#size-cells = <0>;
Signature · 1 line
1.8.2
author maintainer
#17 lore raw

PATCH 6/6 clk: sunxi: drop CLK_IGNORE_UNUSED

In reply to Emilio López

This flag was in place to prevent important clocks from getting gated while they had no users. Now that the UART driver supports clocks properly, we can drop this.

---
 drivers/clk/sunxi/clk-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/sunxi/clk-sunxi.c +4 -4
index 30d71f4..44c32fc 100644
@@ -41,8 +41,8 @@ static void __init sunxi_osc_clk_setup(struct device_node *node)
 
 	parent = of_clk_get_parent_name(node, 0);
 
-	clk = clk_register_gate(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-				reg, SUNXI_OSC24M_GATE, 0, &clk_lock);
+	clk = clk_register_gate(NULL, clk_name, parent, 0, reg,
+				SUNXI_OSC24M_GATE, 0, &clk_lock);
 
 	if (clk) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
@@ -198,8 +198,8 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
 
 	parent = of_clk_get_parent_name(node, 0);
 
-	clk = clk_register_factors(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-				   reg, data->table, data->getter, &clk_lock);
+	clk = clk_register_factors(NULL, clk_name, parent, 0, reg,
+				   data->table, data->getter, &clk_lock);
 
 	if (clk) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
Signature · 1 line
1.8.2
author maintainer
#18 lore raw

v2 cover clk: sunxi: gates support

In reply to Emilio López

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Patch 7 is an unrelated oneliner to remove an unnecesary kmalloc call.

The main changes from v1 are renamed compatible strings and a clarification on the documentation, see each individual patch for more details.

Thanks,

Emilio

Emilio L?pez (7):
clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates
arm: sunxi: Add clock definitions for AXI, AHB, APB0, APB1 gates
arm: sunxi: use the right clock phandles for UARTs
pinctrl: sunxi: add clock support
arm: sunxi: Add clock to pinctrl node
clk: sunxi: drop CLK_IGNORE_UNUSED
clk: sunxi: drop an unnecesary kmalloc

author maintainer
#19 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

This patchset adds DT support for all the AXI, AHB, APB0 and APB1 gates present on sunxi SoCs.

---

Changes from v1:
- renamed compatibles to sun4i
- renamed TWI -> I2C
- added note about gate availability on sun5i

 Documentation/devicetree/bindings/clock/sunxi.txt | 109 +++++++++++++++++++++-
 drivers/clk/sunxi/clk-sunxi.c                     |  88 +++++++++++++++++
 2 files changed, 196 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/clock/sunxi.txt +108 -1
index 20b8479..729f524 100644
@@ -10,15 +10,23 @@ Required properties:
 	"allwinner,sun4i-pll1-clk" - for the main PLL clock
 	"allwinner,sun4i-cpu-clk" - for the CPU multiplexer clock
 	"allwinner,sun4i-axi-clk" - for the AXI clock
+	"allwinner,sun4i-axi-gates-clk" - for the AXI gates
 	"allwinner,sun4i-ahb-clk" - for the AHB clock
+	"allwinner,sun4i-ahb-gates-clk" - for the AHB gates
 	"allwinner,sun4i-apb0-clk" - for the APB0 clock
+	"allwinner,sun4i-apb0-gates-clk" - for the APB0 gates
 	"allwinner,sun4i-apb1-clk" - for the APB1 clock
 	"allwinner,sun4i-apb1-mux-clk" - for the APB1 clock muxing
+	"allwinner,sun4i-apb1-gates-clk" - for the APB1 gates
 
 Required properties for all clocks:
 - reg : shall be the control register address for the clock.
 - clocks : shall be the input parent clock(s) phandle for the clock
-- #clock-cells : from common clock binding; shall be set to 0.
+- #clock-cells : from common clock binding; shall be set to 0 except for
+	"allwinner,sun4i-*-gates-clk" where it shall be set to 1
+
+Additionally, "allwinner,sun4i-*-gates-clk" clocks require:
+- clock-output-names : the corresponding gate names that the clock controls
 
 For example:
 
@@ -42,3 +50,102 @@ cpu: cpu at 01c20054 {
 	reg = <0x01c20054 0x4>;
 	clocks = <&osc32k>, <&osc24M>, <&pll1>;
 };
+
+
+
+Gate clock outputs
+
+The "allwinner,sun4i-*-gates-clk" clocks provide several gatable outputs;
+their corresponding offsets as present on sun4i are listed below. Note that
+some of these gates are not present on sun5i.
+
+  * AXI gates ("allwinner,sun4i-axi-gates-clk")
+
+    DRAM                                                                0
+
+  * AHB gates ("allwinner,sun4i-ahb-gates-clk")
+
+    USB0                                                                0
+    EHCI0                                                               1
+    OHCI0                                                               2*
+    EHCI1                                                               3
+    OHCI1                                                               4*
+    SS                                                                  5
+    DMA                                                                 6
+    BIST                                                                7
+    MMC0                                                                8
+    MMC1                                                                9
+    MMC2                                                                10
+    MMC3                                                                11
+    MS                                                                  12**
+    NAND                                                                13
+    SDRAM                                                               14
+
+    ACE                                                                 16
+    EMAC                                                                17
+    TS                                                                  18
+
+    SPI0                                                                20
+    SPI1                                                                21
+    SPI2                                                                22
+    SPI3                                                                23
+    PATA                                                                24
+    SATA                                                                25**
+    GPS                                                                 26*
+
+    VE                                                                  32
+    TVD                                                                 33
+    TVE0                                                                34
+    TVE1                                                                35
+    LCD0                                                                36
+    LCD1                                                                37
+
+    CSI0                                                                40
+    CSI1                                                                41
+
+    HDMI                                                                43
+    DE_BE0                                                              44
+    DE_BE1                                                              45
+    DE_FE0                                                              46
+    DE_FE1                                                              47
+
+    MP                                                                  50
+
+    MALI400                                                             52
+
+  * APB0 gates ("allwinner,sun4i-apb0-gates-clk")
+
+    CODEC                                                               0
+    SPDIF                                                               1*
+    AC97                                                                2
+    IIS                                                                 3
+
+    PIO                                                                 5
+    IR0                                                                 6
+    IR1                                                                 7
+
+    KEYPAD                                                              10
+
+  * APB1 gates ("allwinner,sun4i-apb1-gates-clk")
+
+    I2C0                                                                0
+    I2C1                                                                1
+    I2C2                                                                2
+
+    CAN                                                                 4
+    SCR                                                                 5
+    PS20                                                                6
+    PS21                                                                7
+
+    UART0                                                               16
+    UART1                                                               17
+    UART2                                                               18
+    UART3                                                               19
+    UART4                                                               20
+    UART5                                                               21
+    UART6                                                               22
+    UART7                                                               23
+
+Notation:
+ [*]:  The datasheet didn't mention these, but they are present on AW code
+ [**]: The datasheet had this marked as "NC" but they are used on AW code
drivers/clk/sunxi/clk-sunxi.c +88 -0

104 lines not on this page · raw message

Signature · 1 line
1.8.2
#20 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Quoting Emilio L?pez (2013-03-27 14:20:37)

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 305

Quoted 9 lines
drivers/clk/sunxi/clk-sunxi.c +1 -0
index d528a24..244de90 100644
@@ -302,6 +302,82 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
 }
 
 
+

A lot of white space between these functions.

Quoted 48 lines
drivers/clk/sunxi/clk-sunxi.c +48 -0
+/**
+ * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
+ */
+
+#define SUNXI_GATES_MAX_SIZE   64
+
+struct gates_data {
+       DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
+};
+
+static const __initconst struct gates_data axi_gates_data = {
+       .mask = {1},
+};
+
+static const __initconst struct gates_data ahb_gates_data = {
+       .mask = {0x7F77FFF, 0x14FB3F},
+};
+
+static const __initconst struct gates_data apb0_gates_data = {
+       .mask = {0x4EF},
+};
+
+static const __initconst struct gates_data apb1_gates_data = {
+       .mask = {0xFF00F7},
+};
+
+static void __init sunxi_gates_clk_setup(struct device_node *node,
+                                        struct gates_data *data)
+{
+       struct clk_onecell_data *clk_data;
+       const char *clk_parent;
+       const char *clk_name;
+       void *reg;
+       int qty;
+       int i = 0;
+       int j = 0;
+       int ignore;
+
+       reg = of_iomap(node, 0);
+
+       clk_parent = of_clk_get_parent_name(node, 0);
+
+       /* Worst-case size approximation and memory allocation */
+       qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
+       clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+       if (!clk_data)
+               return;
+       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 363

Quoted 10 lines
drivers/clk/sunxi/clk-sunxi.c +10 -0
+       if (!clk_data->clks) {
+               kfree(clk_data);
+               return;
+       }
+
+       for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
+               of_property_read_string_index(node, "clock-output-names",
+                                             j, &clk_name);
+
+               /* No driver claims this clock, but it should remain gated */

Should the comment read, "ungated" instead of "gated"?

Quoted 37 lines
drivers/clk/sunxi/clk-sunxi.c +26 -0
+               ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
+               clk_data->clks[i] = clk_register_gate(NULL, clk_name,
+                                                     clk_parent, ignore,
+                                                     reg + 4 * (i/32), i % 32,
+                                                     0, &clk_lock);
+               WARN_ON(IS_ERR(clk_data->clks[i]));
+
+               j++;
+       }
+
+       /* Adjust to the real max */
+       clk_data->clk_num = i;
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
        {.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
@@ -331,6 +407,15 @@ static const __initconst struct of_device_id clk_mux_match[] = {
        {}
 };
 
+/* Matches for gate clocks */
+static const __initconst struct of_device_id clk_gates_match[] = {
+       {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &axi_gates_data,},
+       {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &ahb_gates_data,},
+       {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &apb0_gates_data,},
+       {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &apb1_gates_data,},
+       {}
+};
+
 static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
                                              void *function)
 {

drivers/clk/sunxi/clk-sunxi.c void __init sunxi_init_clocks(void) · line 449

Quoted 6 lines
drivers/clk/sunxi/clk-sunxi.c +3 -0
@@ -359,4 +444,7 @@ void __init sunxi_init_clocks(void)
 
        /* Register mux clocks */
        of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
+
+       /* Register gate clocks */
+       of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);

I'm still a device tree noob, so this may be a dumb question. Can the above be converted to of_clk_init?

Regards,
Mike

Quoted 3 lines
drivers/clk/sunxi/clk-sunxi.c +0 -0
 }
Signature · 1 line
1.8.2
author maintainer
#21 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Hi Mike,

El 03/04/13 18:48, Mike Turquette escribi?:

Quoted 9 lines

Quoting Emilio L?pez (2013-03-27 14:20:37)

Quoted 8 lines
drivers/clk/sunxi/clk-sunxi.c +0 -0
index d528a24..244de90 100644
@@ -302,6 +302,82 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
 }
 
 
Quoted 3 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 305

Quoted 1 line
drivers/clk/sunxi/clk-sunxi.c +1 -0
+

A lot of white space between these functions.

All of the function blocks are separated with three spaces on the file; I thought it looked more readable that way, but I don't have any strong opinion on separation. Is there any standard for this used on the kernel?

In any case, and to keep consistency, can we handle this on a follow-up patch?

Quoted 52 lines
Quoted 52 lines
drivers/clk/sunxi/clk-sunxi.c +52 -0
+/**
+ * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
+ */
+
+#define SUNXI_GATES_MAX_SIZE   64
+
+struct gates_data {
+       DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
+};
+
+static const __initconst struct gates_data axi_gates_data = {
+       .mask = {1},
+};
+
+static const __initconst struct gates_data ahb_gates_data = {
+       .mask = {0x7F77FFF, 0x14FB3F},
+};
+
+static const __initconst struct gates_data apb0_gates_data = {
+       .mask = {0x4EF},
+};
+
+static const __initconst struct gates_data apb1_gates_data = {
+       .mask = {0xFF00F7},
+};
+
+static void __init sunxi_gates_clk_setup(struct device_node *node,
+                                        struct gates_data *data)
+{
+       struct clk_onecell_data *clk_data;
+       const char *clk_parent;
+       const char *clk_name;
+       void *reg;
+       int qty;
+       int i = 0;
+       int j = 0;
+       int ignore;
+
+       reg = of_iomap(node, 0);
+
+       clk_parent = of_clk_get_parent_name(node, 0);
+
+       /* Worst-case size approximation and memory allocation */
+       qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
+       clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+       if (!clk_data)
+               return;
+       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       if (!clk_data->clks) {
+               kfree(clk_data);
+               return;
+       }
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 363

Quoted 6 lines
drivers/clk/sunxi/clk-sunxi.c +6 -0
+
+       for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
+               of_property_read_string_index(node, "clock-output-names",
+                                             j, &clk_name);
+
+               /* No driver claims this clock, but it should remain gated */

Should the comment read, "ungated" instead of "gated"?

Indeed, good catch. Do you want me to resend the series, or can you amend this when picking the patches?

Quoted 38 lines
Quoted 38 lines
drivers/clk/sunxi/clk-sunxi.c +26 -0
+               ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
+               clk_data->clks[i] = clk_register_gate(NULL, clk_name,
+                                                     clk_parent, ignore,
+                                                     reg + 4 * (i/32), i % 32,
+                                                     0, &clk_lock);
+               WARN_ON(IS_ERR(clk_data->clks[i]));
+
+               j++;
+       }
+
+       /* Adjust to the real max */
+       clk_data->clk_num = i;
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
        {.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
@@ -331,6 +407,15 @@ static const __initconst struct of_device_id clk_mux_match[] = {
        {}
 };
 
+/* Matches for gate clocks */
+static const __initconst struct of_device_id clk_gates_match[] = {
+       {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &axi_gates_data,},
+       {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &ahb_gates_data,},
+       {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &apb0_gates_data,},
+       {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &apb1_gates_data,},
+       {}
+};
+
 static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
                                              void *function)
 {
@@ -359,4 +444,7 @@ void __init sunxi_init_clocks(void)
 
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c void __init sunxi_init_clocks(void) · line 449

Quoted 5 lines
drivers/clk/sunxi/clk-sunxi.c +3 -0
        /* Register mux clocks */
        of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
+
+       /* Register gate clocks */
+       of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);

I'm still a device tree noob, so this may be a dumb question. Can the above be converted to of_clk_init?

As far as I know, you can't, because of_clk_init doesn't allow for custom data to be passed to the functions. If we were to use of_clk_init we would need one function per clock, and it would be mostly duplicated code / wrappers. I've added Gregory on Cc, please correct me if this is not the case.

Thanks for the review,

Emilio

#22 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Quoting Emilio L?pez (2013-04-03 18:19:22)

Quoted 16 lines

Hi Mike,

El 03/04/13 18:48, Mike Turquette escribi?:

Quoted 9 lines

Quoting Emilio L?pez (2013-03-27 14:20:37)

Quoted 8 lines
drivers/clk/sunxi/clk-sunxi.c +0 -0
index d528a24..244de90 100644
@@ -302,6 +302,82 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
 }
 
 
Quoted 3 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 305

Quoted 1 line
drivers/clk/sunxi/clk-sunxi.c +1 -0
+

A lot of white space between these functions.

Quoted 7 lines

All of the function blocks are separated with three spaces on the file; I thought it looked more readable that way, but I don't have any strong opinion on separation. Is there any standard for this used on the kernel?

In any case, and to keep consistency, can we handle this on a follow-up patch?

If it's consistent throughout the file then go ahead and keep it.

Quoted 61 lines
Quoted 52 lines
Quoted 52 lines
drivers/clk/sunxi/clk-sunxi.c +52 -0
+/**
+ * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
+ */
+
+#define SUNXI_GATES_MAX_SIZE   64
+
+struct gates_data {
+       DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
+};
+
+static const __initconst struct gates_data axi_gates_data = {
+       .mask = {1},
+};
+
+static const __initconst struct gates_data ahb_gates_data = {
+       .mask = {0x7F77FFF, 0x14FB3F},
+};
+
+static const __initconst struct gates_data apb0_gates_data = {
+       .mask = {0x4EF},
+};
+
+static const __initconst struct gates_data apb1_gates_data = {
+       .mask = {0xFF00F7},
+};
+
+static void __init sunxi_gates_clk_setup(struct device_node *node,
+                                        struct gates_data *data)
+{
+       struct clk_onecell_data *clk_data;
+       const char *clk_parent;
+       const char *clk_name;
+       void *reg;
+       int qty;
+       int i = 0;
+       int j = 0;
+       int ignore;
+
+       reg = of_iomap(node, 0);
+
+       clk_parent = of_clk_get_parent_name(node, 0);
+
+       /* Worst-case size approximation and memory allocation */
+       qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
+       clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+       if (!clk_data)
+               return;
+       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       if (!clk_data->clks) {
+               kfree(clk_data);
+               return;
+       }
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 363

Quoted 6 lines
drivers/clk/sunxi/clk-sunxi.c +6 -0
+
+       for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
+               of_property_read_string_index(node, "clock-output-names",
+                                             j, &clk_name);
+
+               /* No driver claims this clock, but it should remain gated */

Should the comment read, "ungated" instead of "gated"?

Quoted 3 lines

Indeed, good catch. Do you want me to resend the series, or can you amend this when picking the patches?

I can amend it, but I don't like to get into the habit of doing that too often.

I'll wait on Gregory's response on the of_clk_init stuff before I do so.

Regards,
Mike

Quoted 56 lines
Quoted 38 lines
Quoted 38 lines
drivers/clk/sunxi/clk-sunxi.c +26 -0
+               ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
+               clk_data->clks[i] = clk_register_gate(NULL, clk_name,
+                                                     clk_parent, ignore,
+                                                     reg + 4 * (i/32), i % 32,
+                                                     0, &clk_lock);
+               WARN_ON(IS_ERR(clk_data->clks[i]));
+
+               j++;
+       }
+
+       /* Adjust to the real max */
+       clk_data->clk_num = i;
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
        {.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
@@ -331,6 +407,15 @@ static const __initconst struct of_device_id clk_mux_match[] = {
        {}
 };
 
+/* Matches for gate clocks */
+static const __initconst struct of_device_id clk_gates_match[] = {
+       {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &axi_gates_data,},
+       {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &ahb_gates_data,},
+       {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &apb0_gates_data,},
+       {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &apb1_gates_data,},
+       {}
+};
+
 static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
                                              void *function)
 {
@@ -359,4 +444,7 @@ void __init sunxi_init_clocks(void)
 
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c void __init sunxi_init_clocks(void) · line 449

Quoted 5 lines
drivers/clk/sunxi/clk-sunxi.c +3 -0
        /* Register mux clocks */
        of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
+
+       /* Register gate clocks */
+       of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);

I'm still a device tree noob, so this may be a dumb question. Can the above be converted to of_clk_init?

As far as I know, you can't, because of_clk_init doesn't allow for custom data to be passed to the functions. If we were to use of_clk_init we would need one function per clock, and it would be mostly duplicated code / wrappers. I've added Gregory on Cc, please correct me if this is not the case.

Thanks for the review,

Emilio

#23 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Quoted 92 lines · Mike Turquette

Quoting Emilio L??pez (2013-04-03 18:19:22)

Quoted 16 lines

Hi Mike,

El 03/04/13 18:48, Mike Turquette escribi??:

Quoted 9 lines

Quoting Emilio L??pez (2013-03-27 14:20:37)

Quoted 8 lines
drivers/clk/sunxi/clk-sunxi.c +0 -0
index d528a24..244de90 100644
@@ -302,6 +302,82 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
 }
 
 
Quoted 3 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 305

Quoted 1 line
drivers/clk/sunxi/clk-sunxi.c +1 -0
+

A lot of white space between these functions.

Quoted 7 lines

All of the function blocks are separated with three spaces on the file; I thought it looked more readable that way, but I don't have any strong opinion on separation. Is there any standard for this used on the kernel?

In any case, and to keep consistency, can we handle this on a follow-up patch?

If it's consistent throughout the file then go ahead and keep it.

Quoted 61 lines
Quoted 52 lines
Quoted 52 lines
drivers/clk/sunxi/clk-sunxi.c +52 -0
+/**
+ * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
+ */
+
+#define SUNXI_GATES_MAX_SIZE   64
+
+struct gates_data {
+       DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
+};
+
+static const __initconst struct gates_data axi_gates_data = {
+       .mask = {1},
+};
+
+static const __initconst struct gates_data ahb_gates_data = {
+       .mask = {0x7F77FFF, 0x14FB3F},
+};
+
+static const __initconst struct gates_data apb0_gates_data = {
+       .mask = {0x4EF},
+};
+
+static const __initconst struct gates_data apb1_gates_data = {
+       .mask = {0xFF00F7},
+};
+
+static void __init sunxi_gates_clk_setup(struct device_node *node,
+                                        struct gates_data *data)
+{
+       struct clk_onecell_data *clk_data;
+       const char *clk_parent;
+       const char *clk_name;
+       void *reg;
+       int qty;
+       int i = 0;
+       int j = 0;
+       int ignore;
+
+       reg = of_iomap(node, 0);
+
+       clk_parent = of_clk_get_parent_name(node, 0);
+
+       /* Worst-case size approximation and memory allocation */
+       qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
+       clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+       if (!clk_data)
+               return;
+       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       if (!clk_data->clks) {
+               kfree(clk_data);
+               return;
+       }
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 363

Quoted 6 lines
drivers/clk/sunxi/clk-sunxi.c +6 -0
+
+       for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
+               of_property_read_string_index(node, "clock-output-names",
+                                             j, &clk_name);
+
+               /* No driver claims this clock, but it should remain gated */

Should the comment read, "ungated" instead of "gated"?

Quoted 3 lines

Indeed, good catch. Do you want me to resend the series, or can you amend this when picking the patches?

Quoted 60 lines

I can amend it, but I don't like to get into the habit of doing that too often.

I'll wait on Gregory's response on the of_clk_init stuff before I do so.

Regards,
Mike

Quoted 52 lines
Quoted 38 lines
Quoted 38 lines
drivers/clk/sunxi/clk-sunxi.c +26 -0
+               ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
+               clk_data->clks[i] = clk_register_gate(NULL, clk_name,
+                                                     clk_parent, ignore,
+                                                     reg + 4 * (i/32), i % 32,
+                                                     0, &clk_lock);
+               WARN_ON(IS_ERR(clk_data->clks[i]));
+
+               j++;
+       }
+
+       /* Adjust to the real max */
+       clk_data->clk_num = i;
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
        {.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
@@ -331,6 +407,15 @@ static const __initconst struct of_device_id clk_mux_match[] = {
        {}
 };
 
+/* Matches for gate clocks */
+static const __initconst struct of_device_id clk_gates_match[] = {
+       {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &axi_gates_data,},
+       {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &ahb_gates_data,},
+       {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &apb0_gates_data,},
+       {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &apb1_gates_data,},
+       {}
+};
+
 static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
                                              void *function)
 {
@@ -359,4 +444,7 @@ void __init sunxi_init_clocks(void)
 
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c void __init sunxi_init_clocks(void) · line 449

Quoted 5 lines
drivers/clk/sunxi/clk-sunxi.c +3 -0
        /* Register mux clocks */
        of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
+
+       /* Register gate clocks */
+       of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);

I'm still a device tree noob, so this may be a dumb question. Can the above be converted to of_clk_init?

As far as I know, you can't, because of_clk_init doesn't allow for custom data to be passed to the functions. If we were to use of_clk_init we would need one function per clock, and it would be mostly duplicated code / wrappers. I've added Gregory on Cc, please correct me if this is not the case.

I confirm that the current implementation of of_clk_init only take setup functions. That was also the reason why we didn't use it in mvebu/clk-core.c for example.

Maybe it should be a good improvement to allow of_clk_init to receive a function _and_ data for a given node. Something like that;

typedef void (*of_clk_init_cb_t)(struct device_node *, void *data); struct clk_of_setup {
of_clk_init_cb_t clk_init_cb;
void* data;
}

void __init of_clk_init(const struct of_device_id *matches)

{
	struct device_node *np;

	if (!matches)
		matches = __clk_of_table;

	for_each_matching_node(np, matches) {
		const struct of_device_id *match = of_match_node(matches, np);
		match->clk_init_cb(np, match->data);
	}
}

I have just writen this code in this email I didn't even try to compile this code. This was just a rough idea which could be use as a base for future patch for 3.11. With a good coccinelle script it should be not too complicated.

But about this current patch, I am fine with it, and you can add my

Quoted 4 lines
Quoted 4 lines

Thanks for the review,

Emilio

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#24 lore raw

PATCH v2 1/7 clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates

Quoting Gregory CLEMENT (2013-04-04 13:45:24)

Quoted 180 lines · Mike Turquette
Quoted 92 lines

Quoting Emilio L??pez (2013-04-03 18:19:22)

Quoted 16 lines

Hi Mike,

El 03/04/13 18:48, Mike Turquette escribi??:

Quoted 9 lines

Quoting Emilio L??pez (2013-03-27 14:20:37)

Quoted 8 lines
drivers/clk/sunxi/clk-sunxi.c +0 -0
index d528a24..244de90 100644
@@ -302,6 +302,82 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,
 }
 
 
Quoted 3 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 305

Quoted 1 line
drivers/clk/sunxi/clk-sunxi.c +1 -0
+

A lot of white space between these functions.

Quoted 7 lines

All of the function blocks are separated with three spaces on the file; I thought it looked more readable that way, but I don't have any strong opinion on separation. Is there any standard for this used on the kernel?

In any case, and to keep consistency, can we handle this on a follow-up patch?

If it's consistent throughout the file then go ahead and keep it.

Quoted 61 lines
Quoted 52 lines
Quoted 52 lines
drivers/clk/sunxi/clk-sunxi.c +52 -0
+/**
+ * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks
+ */
+
+#define SUNXI_GATES_MAX_SIZE   64
+
+struct gates_data {
+       DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE);
+};
+
+static const __initconst struct gates_data axi_gates_data = {
+       .mask = {1},
+};
+
+static const __initconst struct gates_data ahb_gates_data = {
+       .mask = {0x7F77FFF, 0x14FB3F},
+};
+
+static const __initconst struct gates_data apb0_gates_data = {
+       .mask = {0x4EF},
+};
+
+static const __initconst struct gates_data apb1_gates_data = {
+       .mask = {0xFF00F7},
+};
+
+static void __init sunxi_gates_clk_setup(struct device_node *node,
+                                        struct gates_data *data)
+{
+       struct clk_onecell_data *clk_data;
+       const char *clk_parent;
+       const char *clk_name;
+       void *reg;
+       int qty;
+       int i = 0;
+       int j = 0;
+       int ignore;
+
+       reg = of_iomap(node, 0);
+
+       clk_parent = of_clk_get_parent_name(node, 0);
+
+       /* Worst-case size approximation and memory allocation */
+       qty = find_last_bit(data->mask, SUNXI_GATES_MAX_SIZE);
+       clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+       if (!clk_data)
+               return;
+       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       if (!clk_data->clks) {
+               kfree(clk_data);
+               return;
+       }
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c static void __init sunxi_divider_clk_setup(struct device_node *node, · line 363

Quoted 6 lines
drivers/clk/sunxi/clk-sunxi.c +6 -0
+
+       for_each_set_bit(i, data->mask, SUNXI_GATES_MAX_SIZE) {
+               of_property_read_string_index(node, "clock-output-names",
+                                             j, &clk_name);
+
+               /* No driver claims this clock, but it should remain gated */

Should the comment read, "ungated" instead of "gated"?

Quoted 3 lines

Indeed, good catch. Do you want me to resend the series, or can you amend this when picking the patches?

Quoted 60 lines

I can amend it, but I don't like to get into the habit of doing that too often.

I'll wait on Gregory's response on the of_clk_init stuff before I do so.

Regards,
Mike

Quoted 52 lines
Quoted 38 lines
Quoted 38 lines
drivers/clk/sunxi/clk-sunxi.c +26 -0
+               ignore = !strcmp("ahb_sdram", clk_name) ? CLK_IGNORE_UNUSED : 0;
+
+               clk_data->clks[i] = clk_register_gate(NULL, clk_name,
+                                                     clk_parent, ignore,
+                                                     reg + 4 * (i/32), i % 32,
+                                                     0, &clk_lock);
+               WARN_ON(IS_ERR(clk_data->clks[i]));
+
+               j++;
+       }
+
+       /* Adjust to the real max */
+       clk_data->clk_num = i;
+
+       of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+
 /* Matches for of_clk_init */
 static const __initconst struct of_device_id clk_match[] = {
        {.compatible = "fixed-clock", .data = of_fixed_clk_setup,},
@@ -331,6 +407,15 @@ static const __initconst struct of_device_id clk_mux_match[] = {
        {}
 };
 
+/* Matches for gate clocks */
+static const __initconst struct of_device_id clk_gates_match[] = {
+       {.compatible = "allwinner,sun4i-axi-gates-clk", .data = &axi_gates_data,},
+       {.compatible = "allwinner,sun4i-ahb-gates-clk", .data = &ahb_gates_data,},
+       {.compatible = "allwinner,sun4i-apb0-gates-clk", .data = &apb0_gates_data,},
+       {.compatible = "allwinner,sun4i-apb1-gates-clk", .data = &apb1_gates_data,},
+       {}
+};
+
 static void __init of_sunxi_table_clock_setup(const struct of_device_id *clk_match,
                                              void *function)
 {
@@ -359,4 +444,7 @@ void __init sunxi_init_clocks(void)
 
Quoted 8 lines

drivers/clk/sunxi/clk-sunxi.c void __init sunxi_init_clocks(void) · line 449

Quoted 5 lines
drivers/clk/sunxi/clk-sunxi.c +3 -0
        /* Register mux clocks */
        of_sunxi_table_clock_setup(clk_mux_match, sunxi_mux_clk_setup);
+
+       /* Register gate clocks */
+       of_sunxi_table_clock_setup(clk_gates_match, sunxi_gates_clk_setup);

I'm still a device tree noob, so this may be a dumb question. Can the above be converted to of_clk_init?

As far as I know, you can't, because of_clk_init doesn't allow for custom data to be passed to the functions. If we were to use of_clk_init we would need one function per clock, and it would be mostly duplicated code / wrappers. I've added Gregory on Cc, please correct me if this is not the case.

I confirm that the current implementation of of_clk_init only take setup functions. That was also the reason why we didn't use it in mvebu/clk-core.c for example.

Maybe it should be a good improvement to allow of_clk_init to receive a function _and_ data for a given node. Something like that;

typedef void (*of_clk_init_cb_t)(struct device_node *, void *data); struct clk_of_setup {
of_clk_init_cb_t clk_init_cb;
void* data;
}

void __init of_clk_init(const struct of_device_id *matches)

{
        struct device_node *np;

        if (!matches)
                matches = __clk_of_table;

        for_each_matching_node(np, matches) {
                const struct of_device_id *match = of_match_node(matches, np);
                match->clk_init_cb(np, match->data);
        }
}
Quoted 4 lines

I have just writen this code in this email I didn't even try to compile this code. This was just a rough idea which could be use as a base for future patch for 3.11. With a good coccinelle script it should be not too complicated.

Sure, maybe some solution can be found for 3.11.

Quoted 4 lines

But about this current patch, I am fine with it, and you can add my

Thanks. The three clock patches have been pushed to clk-next.

Regards,
Mike

Quoted 12 lines
Quoted 5 lines
Quoted 5 lines

Thanks for the review,

Emilio

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
author maintainer
#25 lore raw

PATCH v2 2/7 arm: sunxi: Add clock definitions for AXI, AHB, APB0, APB1 gates

In reply to Emilio López

This commit adds the corresponding DT bindings for all the AXI, AHB, APB0 and APB1 gates.

---

Changes from v1:
- renamed compatible strings to sun4i
- rename twi gates to i2c

 arch/arm/boot/dts/sunxi.dtsi | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
arch/arm/boot/dts/sunxi.dtsi +49 -0
index 40392de..87b2cce 100644
@@ -80,6 +80,14 @@
 			clocks = <&cpu>;
 		};
 
+		axi_gates: axi_gates at 01c2005c {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun4i-axi-gates-clk";
+			reg = <0x01c2005c 0x4>;
+			clocks = <&axi>;
+			clock-output-names = "axi_dram";
+		};
+
 		ahb: ahb at 01c20054 {
 			#clock-cells = <0>;
 			compatible = "allwinner,sun4i-ahb-clk";
@@ -87,6 +95,24 @@
 			clocks = <&axi>;
 		};
 
+		ahb_gates: ahb_gates at 01c20060 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun4i-ahb-gates-clk";
+			reg = <0x01c20060 0x8>;
+			clocks = <&ahb>;
+			clock-output-names = "ahb_usb0", "ahb_ehci0",
+				"ahb_ohci0", "ahb_ehci1", "ahb_ohci1", "ahb_ss",
+				"ahb_dma", "ahb_bist", "ahb_mmc0", "ahb_mmc1",
+				"ahb_mmc2", "ahb_mmc3", "ahb_ms", "ahb_nand",
+				"ahb_sdram", "ahb_ace",	"ahb_emac", "ahb_ts",
+				"ahb_spi0", "ahb_spi1", "ahb_spi2", "ahb_spi3",
+				"ahb_pata", "ahb_sata", "ahb_gps", "ahb_ve",
+				"ahb_tvd", "ahb_tve0", "ahb_tve1", "ahb_lcd0",
+				"ahb_lcd1", "ahb_csi0", "ahb_csi1", "ahb_hdmi",
+				"ahb_de_be0", "ahb_de_be1", "ahb_de_fe0",
+				"ahb_de_fe1", "ahb_mp", "ahb_mali400";
+		};
+
 		apb0: apb0 at 01c20054 {
 			#clock-cells = <0>;
 			compatible = "allwinner,sun4i-apb0-clk";
@@ -94,6 +120,16 @@
 			clocks = <&ahb>;
 		};
 
+		apb0_gates: apb0_gates at 01c20068 {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun4i-apb0-gates-clk";
+			reg = <0x01c20068 0x4>;
+			clocks = <&apb0>;
+			clock-output-names = "apb0_codec", "apb0_spdif",
+				"apb0_ac97", "apb0_iis", "apb0_pio", "apb0_ir0",
+				"apb0_ir1", "apb0_keypad";
+		};
+
 		/* dummy is pll62 */
 		apb1_mux: apb1_mux at 01c20058 {
 			#clock-cells = <0>;
@@ -108,6 +144,19 @@
 			reg = <0x01c20058 0x4>;
 			clocks = <&apb1_mux>;
 		};
+
+		apb1_gates: apb1_gates at 01c2006c {
+			#clock-cells = <1>;
+			compatible = "allwinner,sun4i-apb1-gates-clk";
+			reg = <0x01c2006c 0x4>;
+			clocks = <&apb1>;
+			clock-output-names = "apb1_i2c0", "apb1_i2c1",
+				"apb1_i2c2", "apb1_can", "apb1_scr",
+				"apb1_ps20", "apb1_ps21", "apb1_uart0",
+				"apb1_uart1", "apb1_uart2", "apb1_uart3",
+				"apb1_uart4", "apb1_uart5", "apb1_uart6",
+				"apb1_uart7";
+		};
 	};
 
 	soc {
Signature · 1 line
1.8.2
author maintainer
#26 lore raw

PATCH v2 3/7 arm: sunxi: use the right clock phandles for UARTs

In reply to Emilio López

All the UARTs are connected to clock gates; now that our clock driver is able to handle them, make the switch.

---

Changes from v1:
- no changes

 arch/arm/boot/dts/sun4i-a10.dtsi | 12 ++++++------
 arch/arm/boot/dts/sunxi.dtsi     |  4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)
arch/arm/boot/dts/sun4i-a10.dtsi +6 -6
index 68a27fc..6b3a6b2 100644
@@ -54,7 +54,7 @@
 			interrupts = <1>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 16>;
 			status = "disabled";
 		};
 
@@ -64,7 +64,7 @@
 			interrupts = <3>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 18>;
 			status = "disabled";
 		};
 
@@ -74,7 +74,7 @@
 			interrupts = <17>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 20>;
 			status = "disabled";
 		};
 
@@ -84,7 +84,7 @@
 			interrupts = <18>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 21>;
 			status = "disabled";
 		};
 
@@ -94,7 +94,7 @@
 			interrupts = <19>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 22>;
 			status = "disabled";
 		};
 
@@ -104,7 +104,7 @@
 			interrupts = <20>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 23>;
 			status = "disabled";
 		};
 	};
arch/arm/boot/dts/sunxi.dtsi +2 -2
index 87b2cce..a8d47e2 100644
@@ -191,7 +191,7 @@
 			interrupts = <2>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 17>;
 			status = "disabled";
 		};
 
@@ -201,7 +201,7 @@
 			interrupts = <4>;
 			reg-shift = <2>;
 			reg-io-width = <4>;
-			clocks = <&osc>;
+			clocks = <&apb1_gates 19>;
 			status = "disabled";
 		};
 	};
Signature · 1 line
1.8.2
author maintainer
#27 lore raw

PATCH v2 4/7 pinctrl: sunxi: add clock support

In reply to Emilio López

For the port controller to work, we need to enable the apb0_pio gate. This commit adds the ability to enable one clock specified on the device tree to the pinctrl driver.

---

Changes from v1:
- no changes

 drivers/pinctrl/pinctrl-sunxi.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pinctrl/pinctrl-sunxi.c +8 -0
index 3e41cd1..a1e2af7 100644
@@ -11,6 +11,7 @@
  */
 
 #include <linux/io.h>
+#include <linux/clk.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -1917,6 +1918,7 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 	struct pinctrl_pin_desc *pins;
 	struct sunxi_pinctrl *pctl;
 	int i, ret, last_pin;
+	struct clk *clk;
 
 	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
 	if (!pctl)
@@ -1987,6 +1989,12 @@ static int sunxi_pinctrl_probe(struct platform_device *pdev)
 			goto gpiochip_error;
 	}
 
+	clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(clk))
+		goto gpiochip_error;
+
+	clk_prepare_enable(clk);
+
 	dev_info(&pdev->dev, "initialized sunXi PIO driver\n");
 
 	return 0;
Signature · 1 line
1.8.2
author maintainer
#28 lore raw

PATCH v2 5/7 arm: sunxi: Add clock to pinctrl node

In reply to Emilio López

The port controller needs the apb0_pio clock enabled to be able to work. This commit declares that on the device tree.

---

Changes from v1:
- no changes

 arch/arm/boot/dts/sun4i-a10.dtsi | 1 +
 arch/arm/boot/dts/sun5i-a13.dtsi | 1 +
 2 files changed, 2 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +1 -0
index 6b3a6b2..f640520 100644
@@ -21,6 +21,7 @@
 		pio: pinctrl at 01c20800 {
 			compatible = "allwinner,sun4i-a10-pinctrl";
 			reg = <0x01c20800 0x400>;
+			clocks = <&apb0_gates 5>;
 			gpio-controller;
 			#address-cells = <1>;
 			#size-cells = <0>;
arch/arm/boot/dts/sun5i-a13.dtsi +1 -0
index 945bfac..10ee8ee 100644
@@ -22,6 +22,7 @@
 		pio: pinctrl at 01c20800 {
 			compatible = "allwinner,sun5i-a13-pinctrl";
 			reg = <0x01c20800 0x400>;
+			clocks = <&apb0_gates 5>;
 			gpio-controller;
 			#address-cells = <1>;
 			#size-cells = <0>;
Signature · 1 line
1.8.2
author maintainer
#29 lore raw

PATCH v2 6/7 clk: sunxi: drop CLK_IGNORE_UNUSED

In reply to Emilio López

This flag was in place to prevent important clocks from getting gated while they had no users. Now that the UART driver supports clocks properly, we can drop this.

---

Changes from v1:
- no changes

 drivers/clk/sunxi/clk-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/sunxi/clk-sunxi.c +4 -4
index 244de90..daa51ab 100644
@@ -41,8 +41,8 @@ static void __init sunxi_osc_clk_setup(struct device_node *node)
 
 	parent = of_clk_get_parent_name(node, 0);
 
-	clk = clk_register_gate(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-				reg, SUNXI_OSC24M_GATE, 0, &clk_lock);
+	clk = clk_register_gate(NULL, clk_name, parent, 0, reg,
+				SUNXI_OSC24M_GATE, 0, &clk_lock);
 
 	if (clk) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
@@ -198,8 +198,8 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
 
 	parent = of_clk_get_parent_name(node, 0);
 
-	clk = clk_register_factors(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-				   reg, data->table, data->getter, &clk_lock);
+	clk = clk_register_factors(NULL, clk_name, parent, 0, reg,
+				   data->table, data->getter, &clk_lock);
 
 	if (clk) {
 		of_clk_add_provider(node, of_clk_src_simple_get, clk);
Signature · 1 line
1.8.2
#30 lore raw

PATCH v2 6/7 clk: sunxi: drop CLK_IGNORE_UNUSED

Quoting Emilio L?pez (2013-03-27 14:20:42)

Quoted 5 lines

This flag was in place to prevent important clocks from getting gated while they had no users. Now that the UART driver supports clocks properly, we can drop this.

This change looks good to me.

Regards,
Mike

Quoted 36 lines

---

Changes from v1:
- no changes

 drivers/clk/sunxi/clk-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/sunxi/clk-sunxi.c +4 -4
index 244de90..daa51ab 100644
@@ -41,8 +41,8 @@ static void __init sunxi_osc_clk_setup(struct device_node *node)
 
        parent = of_clk_get_parent_name(node, 0);
 
-       clk = clk_register_gate(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-                               reg, SUNXI_OSC24M_GATE, 0, &clk_lock);
+       clk = clk_register_gate(NULL, clk_name, parent, 0, reg,
+                               SUNXI_OSC24M_GATE, 0, &clk_lock);
 
        if (clk) {
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
@@ -198,8 +198,8 @@ static void __init sunxi_factors_clk_setup(struct device_node *node,
 
        parent = of_clk_get_parent_name(node, 0);
 
-       clk = clk_register_factors(NULL, clk_name, parent, CLK_IGNORE_UNUSED,
-                                  reg, data->table, data->getter, &clk_lock);
+       clk = clk_register_factors(NULL, clk_name, parent, 0, reg,
+                                  data->table, data->getter, &clk_lock);
 
        if (clk) {
                of_clk_add_provider(node, of_clk_src_simple_get, clk);
Signature · 1 line
1.8.2
author maintainer
#31 lore raw

PATCH v2 7/7 clk: sunxi: drop an unnecesary kmalloc

In reply to Emilio López

clk_register will copy this information, so we can just use a normal array and do one less dynamic allocation.

---

Changes from v1:
- this patch was not present on v1

 drivers/clk/sunxi/clk-sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-sunxi.c +1 -1
index daa51ab..0bb0eb4 100644
@@ -232,7 +232,7 @@ static void __init sunxi_mux_clk_setup(struct device_node *node,
 {
 	struct clk *clk;
 	const char *clk_name = node->name;
-	const char **parents = kmalloc(sizeof(char *) * 5, GFP_KERNEL);
+	const char *parents[5];
 	void *reg;
 	int i = 0;
 
Signature · 1 line
1.8.2
#32 lore raw

PATCH v2 7/7 clk: sunxi: drop an unnecesary kmalloc

Quoting Emilio L?pez (2013-03-27 14:20:43)

Quoted 4 lines

clk_register will copy this information, so we can just use a normal array and do one less dynamic allocation.

Looks good to me.

Regards,
Mike

Quoted 23 lines

---

Changes from v1:
- this patch was not present on v1

 drivers/clk/sunxi/clk-sunxi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/sunxi/clk-sunxi.c +1 -1
index daa51ab..0bb0eb4 100644
@@ -232,7 +232,7 @@ static void __init sunxi_mux_clk_setup(struct device_node *node,
 {
        struct clk *clk;
        const char *clk_name = node->name;
-       const char **parents = kmalloc(sizeof(char *) * 5, GFP_KERNEL);
+       const char *parents[5];
        void *reg;
        int i = 0;
 
Signature · 1 line
1.8.2
#33 lore raw

v2 cover clk: sunxi: gates support

In reply to Emilio López

Quoting Emilio L?pez (2013-03-27 14:20:36)

Quoted 12 lines

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Quoted 8 lines

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Patch 7 is an unrelated oneliner to remove an unnecesary kmalloc call.

The main changes from v1 are renamed compatible strings and a clarification on the documentation, see each individual patch for more details.

Hi Emilio,

Which tree(s) did you want these patches to go through?

Regards,
Mike

Quoted 12 lines

Thanks,

Emilio

Emilio L?pez (7):
clk: sunxi: Add support for AXI, AHB, APB0 and APB1 gates
arm: sunxi: Add clock definitions for AXI, AHB, APB0, APB1 gates
arm: sunxi: use the right clock phandles for UARTs
pinctrl: sunxi: add clock support
arm: sunxi: Add clock to pinctrl node
clk: sunxi: drop CLK_IGNORE_UNUSED
clk: sunxi: drop an unnecesary kmalloc

author maintainer
#34 lore raw

v2 cover clk: sunxi: gates support

Hi Mike,

El 03/04/13 18:45, Mike Turquette escribi?:

Quoted 18 lines

Quoting Emilio L?pez (2013-03-27 14:20:36)

Quoted 17 lines

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Patch 7 is an unrelated oneliner to remove an unnecesary kmalloc call.

Quoted 7 lines
Quoted 3 lines

The main changes from v1 are renamed compatible strings and a clarification on the documentation, see each individual patch for more details.

Hi Emilio,

Which tree(s) did you want these patches to go through?

The rest of the clk driver is on your tree, so I think 1, 6 and 7 should go through there too, unless Maxime has any objection.

Thanks,

Emilio

#35 lore raw

v2 cover clk: sunxi: gates support

In reply to Mike Turquette

Hi Mike

Le 03/04/2013 23:45, Mike Turquette a ?crit :

Quoted 18 lines

Quoting Emilio L?pez (2013-03-27 14:20:36)

Quoted 17 lines

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Patch 7 is an unrelated oneliner to remove an unnecesary kmalloc call.

Quoted 7 lines
Quoted 3 lines

The main changes from v1 are renamed compatible strings and a clarification on the documentation, see each individual patch for more details.

Hi Emilio,

Which tree(s) did you want these patches to go through?

1, 6 and 7 are changes on the clock driver in itself that depends on the patches you have in your tree, so I guess you should take them through your tree.

2,3 and 5 are dt patches, so I'll take them, and patch 4 has already been applied by LinusW.

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#36 lore raw

v2 cover clk: sunxi: gates support

In reply to Emilio López

Hi,

Le 27/03/2013 22:20, Emilio L?pez a ?crit :

Quoted 12 lines

Hi,

This patchset adds support for the main sunxi gates; namely, those found on AXI, AHB, APB0 and APB1 clocks. The series depends on Maxime's UART rework and on the basic sunxi clock driver by me.

Patches 1 and 2 implement the actual gate support, and patch 3 switches the UARTs to use the correct gates now that they are available.

Patch 4 and 5 add clock support to our pinctrl driver, as we need to keep the pio clock running for gpio to work.

Quoted 7 lines

Patch 6 drops the ignore flags; now that we have actual clock users that will keep the important clocks running.

Patch 7 is an unrelated oneliner to remove an unnecesary kmalloc call.

The main changes from v1 are renamed compatible strings and a clarification on the documentation, see each individual patch for more details.

I merged the patches 2, 3 and 5 into my sunxi/dt-for-3.10 branch.

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com