Skip to contentSkip to conversation

AT91 SAMA7 SoC Clock Adjustments

PATCH Superseded [email protected] 2 participants 8 messages Mar 25, 2025 – May 1, 2025

Subsystems (3)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#7 lore raw

PATCH v2 4/4 ARM: dts: microchip: sama7g5: Adjust clock xtal phandle

In reply to [email protected]

From: Ryan Wanner <[email protected]>

Adjust clock xtal phandles to match the new xtal phandle formatting.

---
 arch/arm/boot/dts/microchip/at91-sama7g5ek.dts | 18 ++++++++----------
 arch/arm/boot/dts/microchip/sama7g5.dtsi       |  4 ++--
 2 files changed, 10 insertions(+), 12 deletions(-)
arch/arm/boot/dts/microchip/at91-sama7g5ek.dts +8 -10
index 2543599013b1..79bf58f8c02e 100644
@@ -35,16 +35,6 @@ aliases {
 		i2c2 = &i2c9;
 	};
 
-	clocks {
-		slow_xtal {
-			clock-frequency = <32768>;
-		};
-
-		main_xtal {
-			clock-frequency = <24000000>;
-		};
-	};
-
 	gpio-keys {
 		compatible = "gpio-keys";
 
@@ -512,6 +502,10 @@ spi11: spi@400 {
 	};
 };
 
+&main_xtal {
+	clock-frequency = <24000000>;
+};
+
 &gmac0 {
 	#address-cells = <1>;
 	#size-cells = <0>;
@@ -917,3 +911,7 @@ &vddout25 {
 	vin-supply = <&vdd_3v3>;
 	status = "okay";
 };
+
+&slow_xtal {
+	clock-frequency = <32768>;
+};
arch/arm/boot/dts/microchip/sama7g5.dtsi +2 -2
index 17bcdcf0cf4a..250c9e98a8bb 100644
@@ -117,12 +117,12 @@ map1 {
 	};
 
 	clocks {
-		slow_xtal: slow_xtal {
+		slow_xtal: clock-slowxtal {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 		};
 
-		main_xtal: main_xtal {
+		main_xtal: clock-mainxtal {
 			compatible = "fixed-clock";
 			#clock-cells = <0>;
 		};
Signature · 1 line
2.43.0
#0 lore raw

v2 cover AT91 SAMA7 SoC Clock Adjustments

From: Ryan Wanner <[email protected]>

This set has clock system adjustments for the AT91 clock system for sama7 SoC family.

The first is to adjust the slow clock driver to account for the updated DT node-naming for clocks and xtals and ensuring the driver is still backwards compatible.

The second and third are adding a missing clk_hw struct that are not added into parent_data struct causing a incorrect parent for main_osc for both sama7d65 and sama7g54 SoCs.

The last patch updates the device tree phandle formatting for the sama7g54 SoC.

Changes v1 -> v2:
- Add clk_hw struct to parent_data adjustment for the sama7g5.c driver.
- Add correction to sama7g54 dtsi main xtal phandles.

Ryan Wanner (4):
clk: at91: sckc: Fix parent_data struct for slow osc
clk: at91: sama7d65: Add missing clk_hw to parent_data
clk: at91: sama7g5: Add missing clk_hw to parent_data
ARM: dts: microchip: sama7g5: Adjust clock xtal phandle

 arch/arm/boot/dts/microchip/at91-sama7g5ek.dts | 18 ++++++++----------
 arch/arm/boot/dts/microchip/sama7g5.dtsi       |  4 ++--
 drivers/clk/at91/sama7d65.c                    |  1 +
 drivers/clk/at91/sama7g5.c                     |  1 +
 drivers/clk/at91/sckc.c                        | 12 ++++++------
 5 files changed, 18 insertions(+), 18 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/4 clk: at91: sckc: Fix parent_data struct for slow osc

From: Ryan Wanner <[email protected]>

The slow xtal is not described correctly as a parent, the driver looks for a "slow_xtal" string which is incorrect and will not work with the new formating of xtals.

To avoid this and keep this driver backwards compatible the parent_data.fw_name is replaced with parent_data.name and the original parent_data.name is replaced with parent_data.index. Using the index is safe due to the driver requiring only 1 xtal.

Fixes 8aa1db9ccee0e ("clk: at91: sckc: switch to parent_data/parent_hw")
---
 drivers/clk/at91/sckc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/at91/sckc.c +6 -6
index 021d1b412af4..952a805b6f7e 100644
@@ -374,7 +374,7 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
 	const char *xtal_name;
 	struct clk_hw *slow_rc, *slow_osc, *slowck;
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	const struct clk_hw *parent_hws[2];
 	bool bypass;
@@ -407,7 +407,7 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
 	if (!xtal_name)
 		goto unregister_slow_rc;
 
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 
 	slow_osc = at91_clk_register_slow_osc(regbase, "slow_osc",
 					      &parent_data, 1200000, bypass, bits);
@@ -476,7 +476,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
 	const char *xtal_name;
 	const struct clk_hw *parent_hws[2];
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	bool bypass;
 	int ret;
@@ -494,7 +494,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
 	if (!xtal_name)
 		goto unregister_slow_rc;
 
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 	bypass = of_property_read_bool(np, "atmel,osc-bypass");
 	slow_osc = at91_clk_register_slow_osc(regbase, "slow_osc",
 					      &parent_data, 5000000, bypass,
@@ -592,7 +592,7 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
 	const char *xtal_name;
 	const struct clk_hw *parent_hws[2];
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	int ret;
 
@@ -609,7 +609,7 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
 	xtal_name = of_clk_get_parent_name(np, 0);
 	if (!xtal_name)
 		goto unregister_slow_rc;
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 
 	osc = kzalloc(sizeof(*osc), GFP_KERNEL);
 	if (!osc)
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 2/4 clk: at91: sama7d65: Add missing clk_hw to parent_data

In reply to [email protected]

From: Ryan Wanner <[email protected]>

The main_xtal clk_hw struct is not passed into parent_data.hw causing an issue with main_osc parent. Passing the main_xtal struct into the parent_data struct will ensure the correct parent structure.

---
 drivers/clk/at91/sama7d65.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/at91/sama7d65.c +1 -0
index a5d40df8b2f2..08306261c9c7 100644
@@ -1138,6 +1138,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
 
 	parent_data.name = main_xtal_name;
 	parent_data.fw_name = main_xtal_name;
+	parent_data.hw = main_xtal_hw;
 	main_osc_hw = at91_clk_register_main_osc(regmap, "main_osc", NULL,
 						 &parent_data, bypass);
 	if (IS_ERR(main_osc_hw))
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 3/4 clk: at91: sama7g5: Add missing clk_hw to parent_data

In reply to [email protected]

From: Ryan Wanner <[email protected]>

The main_xtal clk_hw struct is not passed into parent_data.hw causing an issue with main_osc parent. Passing the main_xtal struct into the parent_data struct will ensure the correct parent structure.

---
 drivers/clk/at91/sama7g5.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/at91/sama7g5.c +1 -0
index 8385badc1c70..ac51d006ba99 100644
@@ -1017,6 +1017,7 @@ static void __init sama7g5_pmc_setup(struct device_node *np)
 
 	parent_data.name = main_xtal_name;
 	parent_data.fw_name = main_xtal_name;
+	parent_data.hw = main_xtal_hw;
 	main_osc_hw = at91_clk_register_main_osc(regmap, "main_osc", NULL,
 						 &parent_data, bypass);
 	if (IS_ERR(main_osc_hw))
Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH v2 2/4] clk: at91: sama7d65: Add missing clk_hw to parent_data

In reply to [email protected]

Hi, Ryan,

Quoted 4 lines · On 25.03.2025 17:55, [email protected] wrote:

From: Ryan Wanner <[email protected]>

The main_xtal clk_hw struct is not passed into parent_data.hw causing an issue with main_osc parent.

Can you please describe the issue?

Quoted 13 lines

Passing the main_xtal struct into the
parent_data struct will ensure the correct parent structure.

---
 drivers/clk/at91/sama7d65.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/at91/sama7d65.c +0 -0
index a5d40df8b2f2..08306261c9c7 100644

drivers/clk/at91/sama7d65.c static void __init sama7d65_pmc_setup(struct device_node *np) · line 1141

Quoted 4 lines
drivers/clk/at91/sama7d65.c +1 -0
@@ -1138,6 +1138,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
 
 	parent_data.name = main_xtal_name;
 	parent_data.fw_name = main_xtal_name;
+	parent_data.hw = main_xtal_hw;

I think, from time to time, you can still hit some random failure as the parent_data.index is still not initialized. I think the problem may be solved by doing something like:

- static struct clk_parent_data parent_data;
+ static struct clk_parent_data parent_data = {0};

Can you please check with this?

Thank you,
Claudiu

Quoted 3 lines
drivers/clk/at91/sama7d65.c +0 -0
 	main_osc_hw = at91_clk_register_main_osc(regmap, "main_osc", NULL,
 						 &parent_data, bypass);
 	if (IS_ERR(main_osc_hw))
maintainer
#2 lore raw

Re: [PATCH v2 1/4] clk: at91: sckc: Fix parent_data struct for slow osc

In reply to [email protected]
Quoted 6 lines · On 25.03.2025 17:55, [email protected] wrote:

From: Ryan Wanner <[email protected]>

The slow xtal is not described correctly as a parent, the driver looks for a "slow_xtal" string which is incorrect and will not work with the new formating of xtals.

Quoted 7 lines

To avoid this and keep this driver backwards compatible the parent_data.fw_name is replaced with parent_data.name and the original parent_data.name is replaced with parent_data.index. Using the index is safe due to the driver requiring only 1 xtal.

Fixes 8aa1db9ccee0e ("clk: at91: sckc: switch to parent_data/parent_hw")

No need for this empty line.

Quoted 63 lines
---
 drivers/clk/at91/sckc.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/clk/at91/sckc.c +6 -6
index 021d1b412af4..952a805b6f7e 100644
@@ -374,7 +374,7 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
 	const char *xtal_name;
 	struct clk_hw *slow_rc, *slow_osc, *slowck;
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	const struct clk_hw *parent_hws[2];
 	bool bypass;
@@ -407,7 +407,7 @@ static void __init at91sam9x5_sckc_register(struct device_node *np,
 	if (!xtal_name)
 		goto unregister_slow_rc;
 
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 
 	slow_osc = at91_clk_register_slow_osc(regbase, "slow_osc",
 					      &parent_data, 1200000, bypass, bits);
@@ -476,7 +476,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
 	const char *xtal_name;
 	const struct clk_hw *parent_hws[2];
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	bool bypass;
 	int ret;
@@ -494,7 +494,7 @@ static void __init of_sam9x60_sckc_setup(struct device_node *np)
 	if (!xtal_name)
 		goto unregister_slow_rc;
 
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 	bypass = of_property_read_bool(np, "atmel,osc-bypass");
 	slow_osc = at91_clk_register_slow_osc(regbase, "slow_osc",
 					      &parent_data, 5000000, bypass,
@@ -592,7 +592,7 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
 	const char *xtal_name;
 	const struct clk_hw *parent_hws[2];
 	static struct clk_parent_data parent_data = {
-		.name = "slow_xtal",
+		.index = 0,
 	};
 	int ret;
 
@@ -609,7 +609,7 @@ static void __init of_sama5d4_sckc_setup(struct device_node *np)
 	xtal_name = of_clk_get_parent_name(np, 0);
 	if (!xtal_name)
 		goto unregister_slow_rc;
-	parent_data.fw_name = xtal_name;
+	parent_data.name = xtal_name;
 
 	osc = kzalloc(sizeof(*osc), GFP_KERNEL);
 	if (!osc)
#5 lore raw

Re: [PATCH v2 2/4] clk: at91: sama7d65: Add missing clk_hw to parent_data

In reply to Claudiu Beznea
Quoted 37 lines · Claudiu Beznea

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi, Ryan,

Quoted 4 lines · On 25.03.2025 17:55, [email protected] wrote:

From: Ryan Wanner <[email protected]>

The main_xtal clk_hw struct is not passed into parent_data.hw causing an issue with main_osc parent.

Can you please describe the issue?

Quoted 13 lines

Passing the main_xtal struct into the
parent_data struct will ensure the correct parent structure.

---
 drivers/clk/at91/sama7d65.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clk/at91/sama7d65.c +0 -0
index a5d40df8b2f2..08306261c9c7 100644

drivers/clk/at91/sama7d65.c static void __init sama7d65_pmc_setup(struct device_node *np) · line 1141

Quoted 4 lines
drivers/clk/at91/sama7d65.c +1 -0
@@ -1138,6 +1138,7 @@ static void __init sama7d65_pmc_setup(struct device_node *np)
 
      parent_data.name = main_xtal_name;
      parent_data.fw_name = main_xtal_name;
+     parent_data.hw = main_xtal_hw;

I think, from time to time, you can still hit some random failure as the parent_data.index is still not initialized. I think the problem may be solved by doing something like:

(quoted diff) +1 -1
-       static struct clk_parent_data parent_data;
+       static struct clk_parent_data parent_data = {0};
Quoted 1 line

Can you please check with this?

Yes I will check on this and test it.

Best,
Ryan

Quoted 9 lines

Thank you,
Claudiu

Quoted 3 lines
drivers/clk/at91/sama7d65.c +0 -0
      main_osc_hw = at91_clk_register_main_osc(regmap, "main_osc", NULL,
                                               &parent_data, bypass);
      if (IS_ERR(main_osc_hw))