diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-03-02 07:44:23 -0500 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-03-15 11:31:14 -0400 |
commit | eb5e76ffd4e626655944e99bb85b07e17172620d (patch) | |
tree | a94577e3cec09878e09c098b32b8731b2389be1b /arch/arm | |
parent | 2b11ea5bf2fe4b79f9388d2eaf5d84713eb44a4c (diff) |
ARM: at91: add pmc DT support
Specified the main Oscillator via clock binding.
This will allow to do not hardcode it anymore in the DT board at 12MHz.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/boot/dts/at91sam9g20.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9g45.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9m10g45ek.dts | 11 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9x5.dtsi | 5 | ||||
-rw-r--r-- | arch/arm/boot/dts/at91sam9x5cm.dtsi | 11 | ||||
-rw-r--r-- | arch/arm/boot/dts/usb_a9g20.dts | 11 | ||||
-rw-r--r-- | arch/arm/mach-at91/clock.c | 56 | ||||
-rw-r--r-- | arch/arm/mach-at91/generic.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-at91/setup.c | 3 |
9 files changed, 101 insertions, 7 deletions
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi index a885a30d1c82..dd5d114a0e1d 100644 --- a/arch/arm/boot/dts/at91sam9g20.dtsi +++ b/arch/arm/boot/dts/at91sam9g20.dtsi | |||
@@ -59,6 +59,11 @@ | |||
59 | reg = <0xfffff000 0x200>; | 59 | reg = <0xfffff000 0x200>; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | pmc: pmc@fffffc00 { | ||
63 | compatible = "atmel,at91rm9200-pmc"; | ||
64 | reg = <0xfffffc00 0x100>; | ||
65 | }; | ||
66 | |||
62 | pit: timer@fffffd30 { | 67 | pit: timer@fffffd30 { |
63 | compatible = "atmel,at91sam9260-pit"; | 68 | compatible = "atmel,at91sam9260-pit"; |
64 | reg = <0xfffffd30 0xf>; | 69 | reg = <0xfffffd30 0xf>; |
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi index 92fe5a5c0eee..621a329307d6 100644 --- a/arch/arm/boot/dts/at91sam9g45.dtsi +++ b/arch/arm/boot/dts/at91sam9g45.dtsi | |||
@@ -60,6 +60,11 @@ | |||
60 | reg = <0xfffff000 0x200>; | 60 | reg = <0xfffff000 0x200>; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | pmc: pmc@fffffc00 { | ||
64 | compatible = "atmel,at91rm9200-pmc"; | ||
65 | reg = <0xfffffc00 0x100>; | ||
66 | }; | ||
67 | |||
63 | pit: timer@fffffd30 { | 68 | pit: timer@fffffd30 { |
64 | compatible = "atmel,at91sam9260-pit"; | 69 | compatible = "atmel,at91sam9260-pit"; |
65 | reg = <0xfffffd30 0xf>; | 70 | reg = <0xfffffd30 0xf>; |
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts index fd4531135431..a8958241f1d7 100644 --- a/arch/arm/boot/dts/at91sam9m10g45ek.dts +++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts | |||
@@ -21,6 +21,17 @@ | |||
21 | reg = <0x70000000 0x4000000>; | 21 | reg = <0x70000000 0x4000000>; |
22 | }; | 22 | }; |
23 | 23 | ||
24 | clocks { | ||
25 | #address-cells = <1>; | ||
26 | #size-cells = <1>; | ||
27 | ranges; | ||
28 | |||
29 | main_clock: clock@0 { | ||
30 | compatible = "atmel,osc", "fixed-clock"; | ||
31 | clock-frequency = <12000000>; | ||
32 | }; | ||
33 | }; | ||
34 | |||
24 | ahb { | 35 | ahb { |
25 | apb { | 36 | apb { |
26 | dbgu: serial@ffffee00 { | 37 | dbgu: serial@ffffee00 { |
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index f0104f4e6ab4..3855843fc038 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi | |||
@@ -58,6 +58,11 @@ | |||
58 | reg = <0xfffff000 0x200>; | 58 | reg = <0xfffff000 0x200>; |
59 | }; | 59 | }; |
60 | 60 | ||
61 | pmc: pmc@fffffc00 { | ||
62 | compatible = "atmel,at91rm9200-pmc"; | ||
63 | reg = <0xfffffc00 0x100>; | ||
64 | }; | ||
65 | |||
61 | pit: timer@fffffe30 { | 66 | pit: timer@fffffe30 { |
62 | compatible = "atmel,at91sam9260-pit"; | 67 | compatible = "atmel,at91sam9260-pit"; |
63 | reg = <0xfffffe30 0xf>; | 68 | reg = <0xfffffe30 0xf>; |
diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi index 5b37033bed56..67936f83c694 100644 --- a/arch/arm/boot/dts/at91sam9x5cm.dtsi +++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi | |||
@@ -12,6 +12,17 @@ | |||
12 | reg = <0x20000000 0x8000000>; | 12 | reg = <0x20000000 0x8000000>; |
13 | }; | 13 | }; |
14 | 14 | ||
15 | clocks { | ||
16 | #address-cells = <1>; | ||
17 | #size-cells = <1>; | ||
18 | ranges; | ||
19 | |||
20 | main_clock: clock@0 { | ||
21 | compatible = "atmel,osc", "fixed-clock"; | ||
22 | clock-frequency = <12000000>; | ||
23 | }; | ||
24 | }; | ||
25 | |||
15 | ahb { | 26 | ahb { |
16 | nand0: nand@40000000 { | 27 | nand0: nand@40000000 { |
17 | nand-bus-width = <8>; | 28 | nand-bus-width = <8>; |
diff --git a/arch/arm/boot/dts/usb_a9g20.dts b/arch/arm/boot/dts/usb_a9g20.dts index 0ea90b5be512..73f1dc48f307 100644 --- a/arch/arm/boot/dts/usb_a9g20.dts +++ b/arch/arm/boot/dts/usb_a9g20.dts | |||
@@ -20,6 +20,17 @@ | |||
20 | reg = <0x20000000 0x4000000>; | 20 | reg = <0x20000000 0x4000000>; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | clocks { | ||
24 | #address-cells = <1>; | ||
25 | #size-cells = <1>; | ||
26 | ranges; | ||
27 | |||
28 | main_clock: clock@0 { | ||
29 | compatible = "atmel,osc", "fixed-clock"; | ||
30 | clock-frequency = <12000000>; | ||
31 | }; | ||
32 | }; | ||
33 | |||
23 | ahb { | 34 | ahb { |
24 | apb { | 35 | apb { |
25 | dbgu: serial@fffff200 { | 36 | dbgu: serial@fffff200 { |
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c index be51ca7f694d..a0f4d7424cdc 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
24 | #include <linux/clk.h> | 24 | #include <linux/clk.h> |
25 | #include <linux/io.h> | 25 | #include <linux/io.h> |
26 | #include <linux/of_address.h> | ||
26 | 27 | ||
27 | #include <mach/hardware.h> | 28 | #include <mach/hardware.h> |
28 | #include <mach/at91_pmc.h> | 29 | #include <mach/at91_pmc.h> |
@@ -671,16 +672,12 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock) | |||
671 | uhpck.rate_hz /= 1 + ((at91_pmc_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); | 672 | uhpck.rate_hz /= 1 + ((at91_pmc_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); |
672 | } | 673 | } |
673 | 674 | ||
674 | int __init at91_clock_init(unsigned long main_clock) | 675 | static int __init at91_pmc_init(unsigned long main_clock) |
675 | { | 676 | { |
676 | unsigned tmp, freq, mckr; | 677 | unsigned tmp, freq, mckr; |
677 | int i; | 678 | int i; |
678 | int pll_overclock = false; | 679 | int pll_overclock = false; |
679 | 680 | ||
680 | at91_pmc_base = ioremap(AT91_PMC, 256); | ||
681 | if (!at91_pmc_base) | ||
682 | panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC); | ||
683 | |||
684 | /* | 681 | /* |
685 | * When the bootloader initialized the main oscillator correctly, | 682 | * When the bootloader initialized the main oscillator correctly, |
686 | * there's no problem using the cycle counter. But if it didn't, | 683 | * there's no problem using the cycle counter. But if it didn't, |
@@ -802,6 +799,55 @@ int __init at91_clock_init(unsigned long main_clock) | |||
802 | return 0; | 799 | return 0; |
803 | } | 800 | } |
804 | 801 | ||
802 | #if defined(CONFIG_OF) | ||
803 | static struct of_device_id pmc_ids[] = { | ||
804 | { .compatible = "atmel,at91rm9200-pmc" }, | ||
805 | { /*sentinel*/ } | ||
806 | }; | ||
807 | |||
808 | static struct of_device_id osc_ids[] = { | ||
809 | { .compatible = "atmel,osc" }, | ||
810 | { /*sentinel*/ } | ||
811 | }; | ||
812 | |||
813 | int __init at91_dt_clock_init(void) | ||
814 | { | ||
815 | struct device_node *np; | ||
816 | u32 main_clock = 0; | ||
817 | |||
818 | np = of_find_matching_node(NULL, pmc_ids); | ||
819 | if (!np) | ||
820 | panic("unable to find compatible pmc node in dtb\n"); | ||
821 | |||
822 | at91_pmc_base = of_iomap(np, 0); | ||
823 | if (!at91_pmc_base) | ||
824 | panic("unable to map pmc cpu registers\n"); | ||
825 | |||
826 | of_node_put(np); | ||
827 | |||
828 | /* retrieve the freqency of fixed clocks from device tree */ | ||
829 | np = of_find_matching_node(NULL, osc_ids); | ||
830 | if (np) { | ||
831 | u32 rate; | ||
832 | if (!of_property_read_u32(np, "clock-frequency", &rate)) | ||
833 | main_clock = rate; | ||
834 | } | ||
835 | |||
836 | of_node_put(np); | ||
837 | |||
838 | return at91_pmc_init(main_clock); | ||
839 | } | ||
840 | #endif | ||
841 | |||
842 | int __init at91_clock_init(unsigned long main_clock) | ||
843 | { | ||
844 | at91_pmc_base = ioremap(AT91_PMC, 256); | ||
845 | if (!at91_pmc_base) | ||
846 | panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC); | ||
847 | |||
848 | return at91_pmc_init(main_clock); | ||
849 | } | ||
850 | |||
805 | /* | 851 | /* |
806 | * Several unused clocks may be active. Turn them off. | 852 | * Several unused clocks may be active. Turn them off. |
807 | */ | 853 | */ |
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index d5f5083880f1..dd9b346c451d 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h | |||
@@ -53,6 +53,7 @@ extern void __init at91sam9rl_set_console_clock(int id); | |||
53 | extern void __init at91sam9g45_set_console_clock(int id); | 53 | extern void __init at91sam9g45_set_console_clock(int id); |
54 | #ifdef CONFIG_AT91_PMC_UNIT | 54 | #ifdef CONFIG_AT91_PMC_UNIT |
55 | extern int __init at91_clock_init(unsigned long main_clock); | 55 | extern int __init at91_clock_init(unsigned long main_clock); |
56 | extern int __init at91_dt_clock_init(void); | ||
56 | #else | 57 | #else |
57 | static int inline at91_clock_init(unsigned long main_clock) { return 0; } | 58 | static int inline at91_clock_init(unsigned long main_clock) { return 0; } |
58 | #endif | 59 | #endif |
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c index c0bd5a625695..d7abc25f6c64 100644 --- a/arch/arm/mach-at91/setup.c +++ b/arch/arm/mach-at91/setup.c | |||
@@ -292,9 +292,8 @@ void __init at91_dt_initialize(void) | |||
292 | /* temporary until have the ramc binding*/ | 292 | /* temporary until have the ramc binding*/ |
293 | at91_boot_soc.ioremap_registers(); | 293 | at91_boot_soc.ioremap_registers(); |
294 | 294 | ||
295 | /* temporary until have the pmc binding */ | ||
296 | /* Init clock subsystem */ | 295 | /* Init clock subsystem */ |
297 | at91_clock_init(12000000); | 296 | at91_dt_clock_init(); |
298 | 297 | ||
299 | /* Register the processor-specific clocks */ | 298 | /* Register the processor-specific clocks */ |
300 | at91_boot_soc.register_clocks(); | 299 | at91_boot_soc.register_clocks(); |