Skip to contentSkip to conversation

ARM: at91: Add support for configurable main clock frequency.

PATCH New Boris BREZILLON 2 participants 2 messages Mar 1, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: at91: Add support for configurable main clock frequency.

This patch provides main clock frequency configuration from device tree definition.

If the "main-clock" attribute of pmc node is not specified it takes 12MHz as default value.

With this patch we can add board support using a different main clock frequency (our custom board is using a 18,432MHz main clock).

---
 arch/arm/boot/dts/at91sam9g20.dtsi |    5 +++++
 arch/arm/mach-at91/board-dt.c      |   21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/at91sam9g20.dtsi
index 07603b8..da253b2 100644

arch/arm/boot/dts/at91sam9g20.dtsi +5 -0
@@ -46,6 +46,11 @@
 			#size-cells = <1>;
 			ranges;
 
+			pmc {
+				compatible = "atmel,at91-pmc";
+				reg = <0xfffffc00 0x100>;
+			};
+
 			aic: interrupt-controller at fffff000 {
 				#interrupt-cells = <1>;
 				compatible = "atmel,at91rm9200-aic";
arch/arm/mach-at91/board-dt.c +20 -1
index bb6b434..c64a3b0 100644
@@ -33,11 +33,30 @@
 #include "sam9_smc.h"
 #include "generic.h"
 
+static const struct of_device_id pmc_of_match[] __initconst = {
+	{ .compatible = "atmel,at91-pmc" },
+	{},
+};
 
 static void __init ek_init_early(void)
 {
+	struct device_node *node;
+	unsigned long main_clock = 12000000;
+
+	node = of_find_matching_node(NULL, pmc_of_match);
+
+	if (node) {
+		const __be32 *ip;
+		ip = of_get_property(node, "main-clock", NULL);
+		if (ip) {
+			main_clock = be32_to_cpup(ip);
+		}
+		of_node_put(node);
+	}
+
+
 	/* Initialize processor: 12.000 MHz crystal */
-	at91_initialize(12000000);
+	at91_initialize(main_clock);
 
 	/* DGBU on ttyS0. (Rx & Tx only) */
 	at91_register_uart(0, 0, 0);
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 ARM: at91: Add support for configurable main clock frequency.

Quoted 9 lines · Boris BREZILLON

This patch provides main clock frequency configuration from device tree definition.

If the "main-clock" attribute of pmc node is not specified it takes 12MHz as default value.

With this patch we can add board support using a different main clock frequency (our custom board is using a 18,432MHz main clock).

This is not the right way you need to define a fixed clock

and the pmc is at91rm9200 compatible

You did do the Documentation either

wait a few I'll send it's support

Best Regards,
J.