mbox series

[v2,00/22] clk: at91: Rework DT bindings

Message ID 20181016142200.19741-1-alexandre.belloni@bootlin.com (mailing list archive)
Headers show
Series clk: at91: Rework DT bindings | expand

Message

Alexandre Belloni Oct. 16, 2018, 2:21 p.m. UTC
This is the promised rework of the at91 PMC clocks driver. It is mainly
necessary to remove the DTC warnings but it also complies with the CCF
rule that there should be one node per controller instead of one node
per clock.

This only handles the PMC, I'm planning to also rework the SCKC bindings
later (without breaking the DT ABI).

The series is based on top of v4.19-rc1.

The first two patches are actually fixes and may be considered for this
cycle.

I'll take the device tree changes through the at91 tree as DT backward
compatibility is working.

Changes in v2:
 - Add at91sam926x and at91sam9rl drivers
 - use CLK_OF_DECLARE_DRIVER
 - Add helpers to allocate for the proper number of clocks
 - Collected Rob's acks

Alexandre Belloni (22):
  clk: at91: audio-pll: fix audio pmc type
  clk: at91: generated: SSCs don't have a gclk
  clk: at91: h32mx: separate registration from DT parsing
  clk: at91: audio-pll: separate registration from DT parsing
  clk: at91: generated: set audio_pll_allowed in
    at91_clk_register_generated()
  clk: at91: allow clock registration from C code
  clk: at91: add pmc_data struct and helpers
  dt-bindings: clk: at91: Document new PMC binding
  clk: at91: add new DT lookup function
  clk: at91: add sama5d4 pmc driver
  clk: at91: add sama5d2 PMC driver
  clk: at91: add at91sam9260 PMC driver
  clk: at91: add at91sam9x5 PMCs driver
  clk: at91: add at91sam9rl PMC driver
  clk: at91: move DT compatibility code to its own file
  ARM: dts: at91: sama5d4: switch to new clock bindings
  ARM: dts: at91: sama5d2: switch to new binding
  ARM: dts: at91: at91sam9260: switch to new clock bindings
  ARM: dts: at91: at91sam9261: switch to new clock bindings
  ARM: dts: at91: at91sam9263: switch to new clock bindings
  ARM: dts: at91: at91sam9x5: switch to new clock bindings
  ARM: dts: at91: at91sam9rl: switch to new clock bindings

 .../devicetree/bindings/clock/at91-clock.txt  | 516 +---------
 arch/arm/boot/dts/at91-sama5d27_som1_ek.dts   |  12 +-
 arch/arm/boot/dts/at91-sama5d2_ptc_ek.dts     |   2 +-
 arch/arm/boot/dts/at91-sama5d2_xplained.dts   |   4 +-
 arch/arm/boot/dts/at91-sama5d4ek.dts          |   2 +-
 arch/arm/boot/dts/at91sam9260.dtsi            | 308 +-----
 arch/arm/boot/dts/at91sam9261.dtsi            | 287 +-----
 arch/arm/boot/dts/at91sam9263.dtsi            | 315 +-----
 arch/arm/boot/dts/at91sam9g15.dtsi            |   4 +
 arch/arm/boot/dts/at91sam9g20.dtsi            |  23 +-
 arch/arm/boot/dts/at91sam9g25.dtsi            |   4 +
 arch/arm/boot/dts/at91sam9g25ek.dts           |   4 +-
 arch/arm/boot/dts/at91sam9g35.dtsi            |   4 +
 arch/arm/boot/dts/at91sam9rl.dtsi             | 239 +----
 arch/arm/boot/dts/at91sam9x25.dtsi            |   4 +
 arch/arm/boot/dts/at91sam9x35.dtsi            |   4 +
 arch/arm/boot/dts/at91sam9x5.dtsi             | 326 +-----
 arch/arm/boot/dts/at91sam9x5_can.dtsi         |  18 +-
 arch/arm/boot/dts/at91sam9x5_isi.dtsi         |  11 +-
 arch/arm/boot/dts/at91sam9x5_lcd.dtsi         |  19 +-
 arch/arm/boot/dts/at91sam9x5_macb0.dtsi       |  11 +-
 arch/arm/boot/dts/at91sam9x5_macb1.dtsi       |  11 +-
 arch/arm/boot/dts/at91sam9x5_usart3.dtsi      |  11 +-
 arch/arm/boot/dts/sama5d2.dtsi                | 642 +-----------
 arch/arm/boot/dts/sama5d4.dtsi                | 535 +---------
 drivers/clk/at91/Makefile                     |   5 +-
 drivers/clk/at91/at91sam9260.c                | 494 +++++++++
 drivers/clk/at91/at91sam9rl.c                 | 171 ++++
 drivers/clk/at91/at91sam9x5.c                 | 309 ++++++
 drivers/clk/at91/clk-audio-pll.c              | 107 +-
 drivers/clk/at91/clk-generated.c              |  81 +-
 drivers/clk/at91/clk-h32mx.c                  |  22 +-
 drivers/clk/at91/clk-i2s-mux.c                |  40 +-
 drivers/clk/at91/clk-main.c                   | 112 +-
 drivers/clk/at91/clk-master.c                 |  99 +-
 drivers/clk/at91/clk-peripheral.c             |  81 +-
 drivers/clk/at91/clk-pll.c                    | 187 +---
 drivers/clk/at91/clk-plldiv.c                 |  27 +-
 drivers/clk/at91/clk-programmable.c           |  81 +-
 drivers/clk/at91/clk-slow.c                   |  32 +-
 drivers/clk/at91/clk-smd.c                    |  34 +-
 drivers/clk/at91/clk-system.c                 |  39 +-
 drivers/clk/at91/clk-usb.c                    |  94 +-
 drivers/clk/at91/clk-utmi.c                   |  45 +-
 drivers/clk/at91/dt-compat.c                  | 961 ++++++++++++++++++
 drivers/clk/at91/pmc.c                        |  78 ++
 drivers/clk/at91/pmc.h                        | 159 +++
 drivers/clk/at91/sama5d2.c                    | 336 ++++++
 drivers/clk/at91/sama5d4.c                    | 264 +++++
 include/dt-bindings/clock/at91.h              |  15 +
 50 files changed, 3185 insertions(+), 4004 deletions(-)
 create mode 100644 drivers/clk/at91/at91sam9260.c
 create mode 100644 drivers/clk/at91/at91sam9rl.c
 create mode 100644 drivers/clk/at91/at91sam9x5.c
 create mode 100644 drivers/clk/at91/dt-compat.c
 create mode 100644 drivers/clk/at91/sama5d2.c
 create mode 100644 drivers/clk/at91/sama5d4.c

Comments

Stephen Boyd Oct. 17, 2018, 4:50 p.m. UTC | #1
Quoting Alexandre Belloni (2018-10-16 07:21:38)
> This is the promised rework of the at91 PMC clocks driver. It is mainly
> necessary to remove the DTC warnings but it also complies with the CCF
> rule that there should be one node per controller instead of one node
> per clock.
> 
> This only handles the PMC, I'm planning to also rework the SCKC bindings
> later (without breaking the DT ABI).
> 
> The series is based on top of v4.19-rc1.
> 
> The first two patches are actually fixes and may be considered for this
> cycle.
> 
> I'll take the device tree changes through the at91 tree as DT backward
> compatibility is working.
> 

I get the following warnings and errors from my auto checker script:

ERROR: need consistent spacing around '+' (ctx:WxV)
#167: FILE: drivers/clk/at91/sama5d4.c:137:
+       sama5d4_pmc = pmc_data_allocate(PMC_MCK2 +1,
                                                 ^

drivers/clk/at91/clk-i2s-mux.c:49:15: warning: symbol 'at91_clk_i2s_mux_register' was not declared. Should it be static?
drivers/clk/at91/clk-audio-pll.c:447:15: warning: symbol 'at91_clk_register_audio_pll_frac' was not declared. Should it be static?
drivers/clk/at91/clk-audio-pll.c:477:15: warning: symbol 'at91_clk_register_audio_pll_pad' was not declared. Should it be static?
drivers/clk/at91/clk-audio-pll.c:508:15: warning: symbol 'at91_clk_register_audio_pll_pmc' was not declared. Should it be static?
drivers/clk/at91/sama5d4.c:123 sama5d4_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/sama5d4.c:129 sama5d4_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/sama5d2.c:140 sama5d2_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/sama5d2.c:146 sama5d2_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9x5.c:132 at91sam9x5_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9x5.c:138 at91sam9x5_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9rl.c:76 at91sam9rl_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9rl.c:82 at91sam9rl_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9260.c:341 at91sam926x_pmc_setup() warn: unsigned 'i' is never less than zero.
drivers/clk/at91/at91sam9260.c:347 at91sam926x_pmc_setup() warn: unsigned 'i' is never less than zero.

I fixed them with the below patch, that I'll squash into the right
place. Things look good!

diff --git a/drivers/clk/at91/at91sam9260.c b/drivers/clk/at91/at91sam9260.c
index 49aeee6c31a6..b1af5a395423 100644
--- a/drivers/clk/at91/at91sam9260.c
+++ b/drivers/clk/at91/at91sam9260.c
@@ -334,7 +334,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
 	const char *slck_name;
 	struct regmap *regmap;
 	struct clk_hw *hw;
-	unsigned int i;
+	int i;
 	bool bypass;
 
 	i = of_property_match_string(np, "clock-names", "slow_xtal");
diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c
index 5532fba5825b..5aeef68b4bdd 100644
--- a/drivers/clk/at91/at91sam9rl.c
+++ b/drivers/clk/at91/at91sam9rl.c
@@ -70,7 +70,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
 	const char *parent_names[6];
 	struct regmap *regmap;
 	struct clk_hw *hw;
-	unsigned int i;
+	int i;
 
 	i = of_property_match_string(np, "clock-names", "slow_clk");
 	if (i < 0)
diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c
index 3cdf227ce159..2fe225a697df 100644
--- a/drivers/clk/at91/at91sam9x5.c
+++ b/drivers/clk/at91/at91sam9x5.c
@@ -125,7 +125,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
 	const char *parent_names[6];
 	struct regmap *regmap;
 	struct clk_hw *hw;
-	unsigned int i;
+	int i;
 	bool bypass;
 
 	i = of_property_match_string(np, "clock-names", "slow_clk");
diff --git a/drivers/clk/at91/clk-audio-pll.c b/drivers/clk/at91/clk-audio-pll.c
index 96e3c6405351..36d77146a3bd 100644
--- a/drivers/clk/at91/clk-audio-pll.c
+++ b/drivers/clk/at91/clk-audio-pll.c
@@ -43,6 +43,8 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
+#include "pmc.h"
+
 #define AUDIO_PLL_DIV_FRAC	BIT(22)
 #define AUDIO_PLL_ND_MAX	(AT91_PMC_AUDIO_PLL_ND_MASK >> \
 					AT91_PMC_AUDIO_PLL_ND_OFFSET)
diff --git a/drivers/clk/at91/clk-i2s-mux.c b/drivers/clk/at91/clk-i2s-mux.c
index dfdffa5409e6..fe6ce172b8b0 100644
--- a/drivers/clk/at91/clk-i2s-mux.c
+++ b/drivers/clk/at91/clk-i2s-mux.c
@@ -14,6 +14,8 @@
 
 #include <soc/at91/atmel-sfr.h>
 
+#include "pmc.h"
+
 struct clk_i2s_mux {
 	struct clk_hw hw;
 	struct regmap *regmap;
diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
index 07f1f1d613ff..d69ad96fe988 100644
--- a/drivers/clk/at91/sama5d2.c
+++ b/drivers/clk/at91/sama5d2.c
@@ -133,7 +133,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
 	const char *parent_names[6];
 	struct regmap *regmap, *regmap_sfr;
 	struct clk_hw *hw;
-	unsigned int i;
+	int i;
 	bool bypass;
 
 	i = of_property_match_string(np, "clock-names", "slow_clk");
diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c
index 64b9f438f73b..e358be7f6c8d 100644
--- a/drivers/clk/at91/sama5d4.c
+++ b/drivers/clk/at91/sama5d4.c
@@ -116,7 +116,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 	const char *parent_names[5];
 	struct regmap *regmap;
 	struct clk_hw *hw;
-	unsigned int i;
+	int i;
 	bool bypass;
 
 	i = of_property_match_string(np, "clock-names", "slow_clk");
@@ -134,7 +134,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
 	if (IS_ERR(regmap))
 		return;
 
-	sama5d4_pmc = pmc_data_allocate(PMC_MCK2 +1,
+	sama5d4_pmc = pmc_data_allocate(PMC_MCK2 + 1,
 					nck(sama5d4_systemck),
 					nck(sama5d4_periph32ck), 0);
 	if (!sama5d4_pmc)
Alexandre Belloni Oct. 17, 2018, 5:27 p.m. UTC | #2
On 17/10/2018 09:50:20-0700, Stephen Boyd wrote:
> Quoting Alexandre Belloni (2018-10-16 07:21:38)
> > This is the promised rework of the at91 PMC clocks driver. It is mainly
> > necessary to remove the DTC warnings but it also complies with the CCF
> > rule that there should be one node per controller instead of one node
> > per clock.
> > 
> > This only handles the PMC, I'm planning to also rework the SCKC bindings
> > later (without breaking the DT ABI).
> > 
> > The series is based on top of v4.19-rc1.
> > 
> > The first two patches are actually fixes and may be considered for this
> > cycle.
> > 
> > I'll take the device tree changes through the at91 tree as DT backward
> > compatibility is working.
> > 
> 
> I get the following warnings and errors from my auto checker script:
> 
> ERROR: need consistent spacing around '+' (ctx:WxV)
> #167: FILE: drivers/clk/at91/sama5d4.c:137:
> +       sama5d4_pmc = pmc_data_allocate(PMC_MCK2 +1,
>                                                  ^
> 
> drivers/clk/at91/clk-i2s-mux.c:49:15: warning: symbol 'at91_clk_i2s_mux_register' was not declared. Should it be static?
> drivers/clk/at91/clk-audio-pll.c:447:15: warning: symbol 'at91_clk_register_audio_pll_frac' was not declared. Should it be static?
> drivers/clk/at91/clk-audio-pll.c:477:15: warning: symbol 'at91_clk_register_audio_pll_pad' was not declared. Should it be static?
> drivers/clk/at91/clk-audio-pll.c:508:15: warning: symbol 'at91_clk_register_audio_pll_pmc' was not declared. Should it be static?
> drivers/clk/at91/sama5d4.c:123 sama5d4_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/sama5d4.c:129 sama5d4_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/sama5d2.c:140 sama5d2_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/sama5d2.c:146 sama5d2_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9x5.c:132 at91sam9x5_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9x5.c:138 at91sam9x5_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9rl.c:76 at91sam9rl_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9rl.c:82 at91sam9rl_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9260.c:341 at91sam926x_pmc_setup() warn: unsigned 'i' is never less than zero.
> drivers/clk/at91/at91sam9260.c:347 at91sam926x_pmc_setup() warn: unsigned 'i' is never less than zero.
> 
> I fixed them with the below patch, that I'll squash into the right
> place. Things look good!
> 

The patch seems good to me.

> diff --git a/drivers/clk/at91/at91sam9260.c b/drivers/clk/at91/at91sam9260.c
> index 49aeee6c31a6..b1af5a395423 100644
> --- a/drivers/clk/at91/at91sam9260.c
> +++ b/drivers/clk/at91/at91sam9260.c
> @@ -334,7 +334,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
>  	const char *slck_name;
>  	struct regmap *regmap;
>  	struct clk_hw *hw;
> -	unsigned int i;
> +	int i;
>  	bool bypass;
>  
>  	i = of_property_match_string(np, "clock-names", "slow_xtal");
> diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c
> index 5532fba5825b..5aeef68b4bdd 100644
> --- a/drivers/clk/at91/at91sam9rl.c
> +++ b/drivers/clk/at91/at91sam9rl.c
> @@ -70,7 +70,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
>  	const char *parent_names[6];
>  	struct regmap *regmap;
>  	struct clk_hw *hw;
> -	unsigned int i;
> +	int i;
>  
>  	i = of_property_match_string(np, "clock-names", "slow_clk");
>  	if (i < 0)
> diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c
> index 3cdf227ce159..2fe225a697df 100644
> --- a/drivers/clk/at91/at91sam9x5.c
> +++ b/drivers/clk/at91/at91sam9x5.c
> @@ -125,7 +125,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
>  	const char *parent_names[6];
>  	struct regmap *regmap;
>  	struct clk_hw *hw;
> -	unsigned int i;
> +	int i;
>  	bool bypass;
>  
>  	i = of_property_match_string(np, "clock-names", "slow_clk");
> diff --git a/drivers/clk/at91/clk-audio-pll.c b/drivers/clk/at91/clk-audio-pll.c
> index 96e3c6405351..36d77146a3bd 100644
> --- a/drivers/clk/at91/clk-audio-pll.c
> +++ b/drivers/clk/at91/clk-audio-pll.c
> @@ -43,6 +43,8 @@
>  #include <linux/regmap.h>
>  #include <linux/slab.h>
>  
> +#include "pmc.h"
> +
>  #define AUDIO_PLL_DIV_FRAC	BIT(22)
>  #define AUDIO_PLL_ND_MAX	(AT91_PMC_AUDIO_PLL_ND_MASK >> \
>  					AT91_PMC_AUDIO_PLL_ND_OFFSET)
> diff --git a/drivers/clk/at91/clk-i2s-mux.c b/drivers/clk/at91/clk-i2s-mux.c
> index dfdffa5409e6..fe6ce172b8b0 100644
> --- a/drivers/clk/at91/clk-i2s-mux.c
> +++ b/drivers/clk/at91/clk-i2s-mux.c
> @@ -14,6 +14,8 @@
>  
>  #include <soc/at91/atmel-sfr.h>
>  
> +#include "pmc.h"
> +
>  struct clk_i2s_mux {
>  	struct clk_hw hw;
>  	struct regmap *regmap;
> diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
> index 07f1f1d613ff..d69ad96fe988 100644
> --- a/drivers/clk/at91/sama5d2.c
> +++ b/drivers/clk/at91/sama5d2.c
> @@ -133,7 +133,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
>  	const char *parent_names[6];
>  	struct regmap *regmap, *regmap_sfr;
>  	struct clk_hw *hw;
> -	unsigned int i;
> +	int i;
>  	bool bypass;
>  
>  	i = of_property_match_string(np, "clock-names", "slow_clk");
> diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c
> index 64b9f438f73b..e358be7f6c8d 100644
> --- a/drivers/clk/at91/sama5d4.c
> +++ b/drivers/clk/at91/sama5d4.c
> @@ -116,7 +116,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
>  	const char *parent_names[5];
>  	struct regmap *regmap;
>  	struct clk_hw *hw;
> -	unsigned int i;
> +	int i;
>  	bool bypass;
>  
>  	i = of_property_match_string(np, "clock-names", "slow_clk");
> @@ -134,7 +134,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
>  	if (IS_ERR(regmap))
>  		return;
>  
> -	sama5d4_pmc = pmc_data_allocate(PMC_MCK2 +1,
> +	sama5d4_pmc = pmc_data_allocate(PMC_MCK2 + 1,
>  					nck(sama5d4_systemck),
>  					nck(sama5d4_periph32ck), 0);
>  	if (!sama5d4_pmc)