ARM: at91: moving at91 to the common clk framework
Subsystems (4)
cover ARM: at91: moving at91 to the common clk framework
This patch implements at91 pmc clks using the the common clk framework. This implementation is only used for dt boards and is tightly linked with device tree support (requires "DT clock binding support" patch).
What's missing :
* UTMI and USB (Host and Device) clk drivers.
* Devce tree binding documentation
* Atmel drivers port to the commonc clk framework:
* use clk_prepare_enable instead of clk_enable.
* use of_clk_get instead of clk_get when dt is enabled.
I'd like to have some feedback on the implementation and dt binding before adding the missing stuffs.
Best Regards,
Boris
Boris BREZILLON (5):
at91: Add at91 PMC registers definitions.
at91: Move at91 PMC clks to the common clk framework.
at91: disable specific soc clock init function if COMMON_CLK is
selected.
at91: add pmc clks definition into device tree (at91sam9260, 9g20).
at91: Modify board_dt init sequence to use PMC common clk
implementation.
arch/arm/boot/dts/at91sam9260.dtsi | 299 ++++++++++++++++++++- arch/arm/boot/dts/at91sam9g20.dtsi | 44 +++ arch/arm/mach-at91/Kconfig | 1 + arch/arm/mach-at91/Makefile | 5 +- arch/arm/mach-at91/at91sam9260.c | 9 +- arch/arm/mach-at91/board-dt.c | 72 ++++- arch/arm/mach-at91/include/mach/at91_pmc.h | 5 + arch/arm/mach-at91/pmc-master.c | 401 ++++++++++++++++++++++++++++ arch/arm/mach-at91/pmc-osc.c | 165 ++++++++++++ arch/arm/mach-at91/pmc-periph.c | 111 ++++++++ arch/arm/mach-at91/pmc-pll.c | 371 +++++++++++++++++++++++++ arch/arm/mach-at91/pmc-prog.c | 194 ++++++++++++++ arch/arm/mach-at91/pmc-sys.c | 81 ++++++ arch/arm/mach-at91/pmc.c | 260 ++++++++++++++++++ arch/arm/mach-at91/pmc.h | 70 +++++ arch/arm/mach-at91/setup.c | 8 +- 16 files changed, 2087 insertions(+), 9 deletions(-) create mode 100644 arch/arm/mach-at91/pmc-master.c create mode 100644 arch/arm/mach-at91/pmc-osc.c create mode 100644 arch/arm/mach-at91/pmc-periph.c create mode 100644 arch/arm/mach-at91/pmc-pll.c create mode 100644 arch/arm/mach-at91/pmc-prog.c create mode 100644 arch/arm/mach-at91/pmc-sys.c create mode 100644 arch/arm/mach-at91/pmc.c create mode 100644 arch/arm/mach-at91/pmc.h
Signature · 1 line
1.7.9.5
PATCH 1/5 ARM: at91: Add PMC registers definitions.
This patch adds definition of SOSCSEL bit used by pmc-osc.c to know which kind of oscilator is used (internal RC => drift).
This patch adds ICPLLR definition used in pll config.
--- arch/arm/mach-at91/include/mach/at91_pmc.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/mach-at91/include/mach/at91_pmc.h +5 -0
@@ -149,6 +149,7 @@ extern void __iomem *at91_pmc_base;#define AT91_PMC_LOCKB (1 << 2)/* PLLB Lock */ #define AT91_PMC_MCKRDY (1 << 3)/* Master Clock */ #define AT91_PMC_LOCKU (1 << 6)/* UPLL Lock [some SAM9] */ +#define AT91_PMC_SOSCSEL (1 << 7)/* Slow osc external selction */ #define AT91_PMC_PCK0RDY (1 << 8)/* Programmable Clock 0 */ #define AT91_PMC_PCK1RDY (1 << 9)/* Programmable Clock 1 */ #define AT91_PMC_PCK2RDY (1 << 10)/* Programmable Clock 2 */
@@ -158,6 +159,10 @@ extern void __iomem *at91_pmc_base;#define AT91_PMC_CFDEV (1 << 18)/* Clock Failure Detector Event [some SAM9] */ #define AT91_PMC_IMR 0x6c/* Interrupt Mask Register */ +#define AT91_PMC_PLLICPR 0x80/* PLL Charge Pump Current Register */ +#define AT91_PMC_ICPLLA (1 << 0)/* ICPLLA Flag */ +#define AT91_PMC_ICPLLB (1 << 16)/* ICPLLA Flag */ +#define AT91_PMC_PROT 0xe4/* Write Protect Mode Register [some SAM9] */ #define AT91_PMC_WPEN (0x1 << 0)/* Write Protect Enable */ #define AT91_PMC_WPKEY (0xffffff << 8)/* Write Protect Key */
Signature · 1 line
1.7.9.5
PATCH 2/5 ARM: at91: Implementation of PMC clks using the common clk framework.
In reply to Boris BREZILLONThis patchs implements the PMC clks using the common clk framework. Some clks are not implemented yet (UTMI, USB host, USB device).
--- arch/arm/mach-at91/Kconfig | 1 + arch/arm/mach-at91/Makefile | 5 +- arch/arm/mach-at91/pmc-master.c | 401 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-at91/pmc-osc.c | 165 ++++++++++++++++ arch/arm/mach-at91/pmc-periph.c | 111 +++++++++++ arch/arm/mach-at91/pmc-pll.c | 371 ++++++++++++++++++++++++++++++++++++ arch/arm/mach-at91/pmc-prog.c | 194 +++++++++++++++++++ arch/arm/mach-at91/pmc-sys.c | 81 ++++++++ arch/arm/mach-at91/pmc.c | 260 +++++++++++++++++++++++++ arch/arm/mach-at91/pmc.h | 70 +++++++ 10 files changed, 1658 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-at91/pmc-master.c create mode 100644 arch/arm/mach-at91/pmc-osc.c create mode 100644 arch/arm/mach-at91/pmc-periph.c create mode 100644 arch/arm/mach-at91/pmc-pll.c create mode 100644 arch/arm/mach-at91/pmc-prog.c create mode 100644 arch/arm/mach-at91/pmc-sys.c create mode 100644 arch/arm/mach-at91/pmc.c create mode 100644 arch/arm/mach-at91/pmc.h
arch/arm/mach-at91/Kconfig +1 -0
@@ -489,6 +489,7 @@ comment "Generic Board Type" config MACH_AT91SAM_DT bool "Atmel AT91SAM Evaluation Kits with device-tree support" select USE_OF + select COMMON_CLK help Select this if you want to experiment device-tree with an Atmel Evaluation Kit.
arch/arm/mach-at91/Makefile +4 -1
@@ -6,8 +6,11 @@ obj-y := irq.o gpio.o setup.o obj-m := obj-n := obj- := - +ifeq ($(CONFIG_COMMON_CLK),y) +obj-$(CONFIG_AT91_PMC_UNIT) += pmc-osc.o pmc-pll.o pmc-master.o pmc-sys.o pmc-periph.o pmc-prog.o pmc.o +else obj-$(CONFIG_AT91_PMC_UNIT) += clock.o +endif obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o obj-$(CONFIG_SOC_AT91SAM9) += at91sam926x_time.o sam9_smc.o
arch/arm/mach-at91/pmc-master.c new file +401 -0
401 lines not on this page · raw message
arch/arm/mach-at91/pmc-osc.c new file +165 -0
165 lines not on this page · raw message
arch/arm/mach-at91/pmc-periph.c new file +111 -0
111 lines not on this page · raw message
arch/arm/mach-at91/pmc-pll.c new file +371 -0
371 lines not on this page · raw message
arch/arm/mach-at91/pmc-prog.c new file +194 -0
194 lines not on this page · raw message
arch/arm/mach-at91/pmc-sys.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-at91/pmc.c new file +260 -0
260 lines not on this page · raw message
arch/arm/mach-at91/pmc.h new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/5 ARM: at91: Implementation of PMC clks using the common clk framework.
Quoted 5 lines · Boris BREZILLON
arch/arm/mach-at91/Makefile +0
-0
arch/arm/mach-at91/Makefile obj-y := irq.o gpio.o setup.o · line 13
Quoted 9 lines
arch/arm/mach-at91/Makefile +4
-1@@ -6,8 +6,11 @@ obj-y := irq.o gpio.o setup.o obj-m := obj-n := obj- := - +ifeq ($(CONFIG_COMMON_CLK),y) +obj-$(CONFIG_AT91_PMC_UNIT) += pmc-osc.o pmc-pll.o pmc-master.o pmc-sys.o pmc-periph.o pmc-prog.o pmc.o +else obj-$(CONFIG_AT91_PMC_UNIT) += clock.o +endif
Hi Boris,
Looks like the old platform clock code is not removed in this series. Is this just a work in progress or do you want to merge in AT91 support for common clk while leaving the old clock code merged in?
Regards,
Mike
PATCH 2/5 ARM: at91: Implementation of PMC clks using the common clk framework.
Quoted 18 lines · Mike Turquette
Quoted 5 lines · Boris BREZILLON
arch/arm/mach-at91/Makefile +0
-0arch/arm/mach-at91/Makefile obj-y := irq.o gpio.o setup.o · line 13
Quoted 9 lines
arch/arm/mach-at91/Makefile +4
-1@@ -6,8 +6,11 @@ obj-y := irq.o gpio.o setup.o obj-m := obj-n := obj- := - +ifeq ($(CONFIG_COMMON_CLK),y) +obj-$(CONFIG_AT91_PMC_UNIT) += pmc-osc.o pmc-pll.o pmc-master.o pmc-sys.o pmc-periph.o pmc-prog.o pmc.o +else obj-$(CONFIG_AT91_PMC_UNIT) += clock.o +endifHi Boris,
Quoted 4 lines
Looks like the old platform clock code is not removed in this series. Is this just a work in progress or do you want to merge in AT91 support for common clk while leaving the old clock code merged in?
This is a work in progress.
I'd like to have more reviews from at91 maitainers before removing the old at91 clock implementation.
Do you have some comments on other parts of this patch serie (it's been a month and nobody reviewed it yet)?
Quoted 7 lines
Regards,
Mike_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/5 ARM: at91: disable specific soc clock init functions
In reply to Boris BREZILLON--- arch/arm/mach-at91/at91sam9260.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm/mach-at91/at91sam9260.c +8 -1
@@ -25,13 +25,17 @@#include "soc.h" #include "generic.h" +#ifndef CONFIG_COMMON_CLK #include "clock.h" +#else +#include <linux/clk.h> +#endif #include "sam9_smc.h" /* -------------------------------------------------------------------- * Clocks * -------------------------------------------------------------------- */ - +#ifndef CONFIG_COMMON_CLK /* * The peripheral clocks. */
@@ -267,6 +271,7 @@ static void __init at91sam9260_register_clocks(void)clk_register (&pck0); clk_register(&pck1); } +#endif /* -------------------------------------------------------------------- * GPIO
@@ -382,6 +387,8 @@ struct at91_init_soc __initdata at91sam9260_soc = { .map_io = at91sam9260_map_io, .default_irq_priority = at91sam9260_default_irq_priority, .ioremap_registers = at91sam9260_ioremap_registers, +#ifndef CONFIG_COMMON_CLK .register_clocks = at91sam9260_register_clocks, +#endif .init = at91sam9260_initialize, };
Signature · 1 line
1.7.9.5
PATCH 4/5 ARM: at91: add pmc clks definition into device tree
In reply to Boris BREZILLONThis patch defines some clks for at91sam9260 and sam9g20 SoC. All peripherals clocks are not defined yet (only usart, GPIO).
--- arch/arm/boot/dts/at91sam9260.dtsi | 299 +++++++++++++++++++++++++++++++++++- arch/arm/boot/dts/at91sam9g20.dtsi | 44 ++++++ 2 files changed, 342 insertions(+), 1 deletion(-)
arch/arm/boot/dts/at91sam9260.dtsi +298 -1
@@ -64,8 +64,305 @@ }; pmc: pmc at fffffc00 { - compatible = "atmel,at91rm9200-pmc"; + compatible = "atmel,at91-pmc"; + #address-cells = <1>; + #size-cells = <0>; reg = <0xfffffc00 0x100>; + interrupts = <1 4>; + + capabilities = <0xf031f77 0x1>; /* SC{ER,DR,SR}, PC{ER,DR,SR}, MOR, + MCFR, PLL{AR,BR}, MCKR, PCK{0,1}, + I{ER,DR,SR,MR}, PLLICPR */ + + + slow: osc at 0 { + compatible = "atmel,at91-pmc-slow", "fixed-rate"; + reg = <0>; + clock-frequency = <32768>; + #clock-cells = <0>; + clock-output-names = "slow"; + + characteristics { + output = <22000 42000>; + }; + }; + + main: osc at 1 { + compatible = "atmel,at91-pmc-main", "fixed-rate"; + reg = <1>; + + #clock-cells = <0>; + clock-output-names = "main"; + + characteristics { + output = <3000000 20000000>; + }; + }; + + plla: pll at 0 { + compatible = "atmel,at91-pmc-pll"; + reg = <0>; + + #clock-cells = <0>; + clocks = <&main>; + clock-output-names = "plla"; + + mask = <0xf8000000>; + + characteristics { + input = <1000000 32000000>; + output = < + 0 0 /* icpll = 0, out = 0 => no such conf*/ + 0 0 /* icpll = 0, out = 1 => no such conf*/ + 0 0 /* icpll = 0, out = 2 => no such conf*/ + 0 0 /* icpll = 0, out = 3 => no such conf*/ + 80000000 160000000 /* icpll = 1, out = 0 => 80 to 160MHz */ + 0 0 /* icpll = 1, out = 1 => no such conf*/ + 150000000 240000000 /* icpll = 1, out = 2 => 80 to 160MHz */ + 0 0 /* icpll = 1, out = 3 => no such conf*/ + >; + }; + + }; + + pllb: pll at 1 { + compatible = "atmel,at91-pmc-pll"; + reg = <1>; + + #clock-cells = <0>; + clocks = <&main>; + clock-output-names = "pllb"; + + mask = <0xf8000000>; + + characteristics { + input = <1000000 32000000>; + output = < + 0 0 /* icpll = 0, out = 0 => no such conf*/ + 0 0 /* icpll = 0, out = 1 => no such conf*/ + 0 0 /* icpll = 0, out = 2 => no such conf*/ + 0 0 /* icpll = 0, out = 3 => no such conf*/ + 80000000 160000000 /* icpll = 1, out = 0 => 80 to 160MHz */ + 0 0 /* icpll = 1, out = 1 => no such conf*/ + 150000000 240000000 /* icpll = 1, out = 2 => 80 to 160MHz */ + 0 0 /* icpll = 0, out = 3 => no such conf*/ + >; + }; + + }; + + pres: master at 0 { + compatible = "atmel,at91-pmc-pres"; + offset = <0x2>; + + #clock-cells = <0>; + clocks = <&slow>, <&main>, <&plla>, <&pllb>; + clock-output-names = "pres"; + }; + + master: master at 1 { + compatible = "atmel,at91-pmc-master"; + divisors = <1 2 4 6>; + + #clock-cells = <0>; + clocks = <&pres>; + clock-output-names = "mck"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "mck"; + }; + + lookup at 1 { + compatible = "clk-lookup"; + condid = "usart"; + devid = "fffff200.serial"; + }; + + characteristics { + output = <0 94500000>; /* master clock range at 1.65V*/ + }; + + }; + + proc: sys at 0 { + compatible = "atmel,at91-pmc-proc"; + divisor; + + #clock-cells = <0>; + clocks = <&pres>; + clock-output-names = "proc"; + + characteristics { + output = <0 189000000>; /* proc clock range at 1.65V*/ + }; + + }; + + prog0: sys at 8 { + compatible = "atmel,at91-pmc-prog", "atmel,at91-pmc-sys"; + reg = <8>; + css-length = <2>; + pres-offset = <2>; + + #clock-cells = <0>; + clocks = <&slow>, <&main>, <&plla>, <&pllb>; + clock-output-names = "prog0"; + + }; + + prog1: sys at 9 { + compatible = "atmel,at91-pmc-prog", "atmel,at91-pmc-sys"; + reg = <9>; + css-length = <2>; + pres-offset = <2>; + + #clock-cells = <0>; + clocks = <&slow>, <&main>, <&plla>, <&pllb>; + clock-output-names = "prog1"; + + }; + + usart0ck: periph at 6 { + compatible = "atmel,at91-pmc-periph"; + reg = <6>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffb0000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffb0000.serial"; + }; + }; + + usart1ck: periph at 7 { + compatible = "atmel,at91-pmc-periph"; + reg = <7>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffb4000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffb4000.serial"; + }; + }; + + usart2ck: periph at 8 { + compatible = "atmel,at91-pmc-periph"; + reg = <8>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffb8000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffb8000.serial"; + }; + }; + + usart3ck: periph at 23 { + compatible = "atmel,at91-pmc-periph"; + reg = <23>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffd0000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffd0000.serial"; + }; + }; + + usart4ck: periph at 24 { + compatible = "atmel,at91-pmc-periph"; + reg = <24>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffd4000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffd4000.serial"; + }; + }; + + usart5ck: periph at 25 { + compatible = "atmel,at91-pmc-periph"; + reg = <25>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "fffd8000.serial"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "usart"; + devid = "fffd8000.serial"; + }; + }; + + pioAck: periph at 2 { + compatible = "atmel,at91-pmc-periph"; + reg = <2>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "pioA"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "pioA"; + }; + }; + + pioBck: periph at 3 { + compatible = "atmel,at91-pmc-periph"; + reg = <3>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "pioB"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "pioB"; + }; + }; + + pioCck: periph at 4 { + compatible = "atmel,at91-pmc-periph"; + reg = <4>; + + #clock-cells = <0>; + clocks = <&master>; + + clock-output-names = "pioC"; + + lookup at 0 { + compatible = "clk-lookup"; + conid = "pioC"; + }; + }; }; rstc at fffffd00 {
arch/arm/boot/dts/at91sam9g20.dtsi +44 -0
48 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 5/5 ARM: at91: Modify board_dt init sequence
In reply to Boris BREZILLONThis patch modifies the init sequence defined by board_dt machine. PMC common clk implementation needs the slab allocator to be up => late_time_init. GPIO needs the GPIO periph clks => after clk inits.
GPIO irq init needs the GPIO chips => after GPIO inits.
--- arch/arm/mach-at91/board-dt.c | 72 +++++++++++++++++++++++++++++++++++++++-- arch/arm/mach-at91/setup.c | 8 ++--- 2 files changed, 74 insertions(+), 6 deletions(-)
arch/arm/mach-at91/board-dt.c +70 -2
@@ -22,6 +22,7 @@#include <asm/mach/arch.h> #include <asm/mach/map.h> #include <asm/mach/irq.h> +#include <asm/mach/time.h> #include "generic.h"
@@ -29,6 +30,11 @@static const struct of_device_id irq_of_match[]__initconst = { { .compatible ="atmel,at91rm9200-aic" , .data = at91_aic_of_init }, + {/*sentinel*/ } +}; + +static const struct of_device_id gpio_irq_of_match[]__initconst = { + { .compatible ="atmel,at91rm9200-gpio" , .data = at91_gpio_of_irq_setup }, { .compatible ="atmel,at91sam9x5-gpio" , .data = at91_gpio_of_irq_setup }, {/*sentinel*/ }
@@ -49,11 +55,73 @@ static const char *at91_dt_board_compat[] __initdata = {NULL }; +static void __init at91_dt_late_time_init (void ); + +static void __init at91_dt_timer_init (void ) { + late_time_init = at91_dt_late_time_init; +} + +struct sys_timer at91_dt_timer = { + .init = at91_dt_timer_init, +}; + +extern void __init at91_pmc_of_init (struct device_node *np); + +static const struct of_device_id clk_of_match[]__initconst = { + + { .compatible ="atmel,at91-pmc" , .data = at91_pmc_of_init }, + {/*sentinel*/ } +}; + +static const struct of_device_id timer_of_match[]__initconst = { + + { .compatible ="atmel,at91sam9260-pit" , .data = &at91sam926x_timer }, + {/*sentinel*/ } +}; + +static void __init at91_dt_late_time_init (void ) { +struct device_node *np =NULL ; +const struct of_device_id *match; +struct sys_timer *timer; +void (*init_fn) (struct device_node *np); + + np =of_find_matching_node (NULL , clk_of_match); +if (!np) +panic ("unable to find compatible clock controller node in dtb\n" ); + + match =of_match_node (clk_of_match, np); + init_fn = match->data; +init_fn (np); + +of_node_put (np); + +at91_dt_initialize (); + +of_irq_init (gpio_irq_of_match); + + np =of_find_matching_node (NULL , timer_of_match); +if (!np) +panic ("unable to find compatible sys timer node in dtb\n" ); + + match =of_match_node (timer_of_match, np); + + timer = match->data; + timer->init (); + at91_dt_timer.suspend = timer->suspend; + at91_dt_timer.resume = timer->resume; +#ifdef CONFIG_ARCH_USES_GETTIMEOFFSET + at91_dt_timer.offset = timer->offset; +#endif + +of_node_put (np); +} + +DT_MACHINE_START (at91sam_dt,"Atmel AT91SAM (Device Tree)" )/* Maintainer: Atmel */ - .timer = &at91sam926x_timer, + .timer = &at91_dt_timer, .map_io = at91_map_io, - .init_early = at91_dt_initialize, +/* .init_early = at91_dt_initialize, */ .init_irq = at91_dt_init_irq, .init_machine = at91_dt_device_init, .dt_compat = at91_dt_board_compat,
arch/arm/mach-at91/setup.c +4 -4
@@ -435,15 +435,14 @@ void __init at91_dt_initialize(void)at91_dt_shdwc ();/* Init clock subsystem */ -at91_dt_clock_init (); +/*at91_dt_clock_init();*/ /* Register the processor-specific clocks */ - at91_boot_soc.register_clocks (); +/*at91_boot_soc.register_clocks();*/ at91_boot_soc.init(); } -#endif - +#else void __init at91_initialize (unsigned long main_clock) { at91_boot_soc.ioremap_registers ();
@@ -456,3 +455,4 @@ void __init at91_initialize(unsigned long main_clock) at91_boot_soc.init(); } +#endif
Signature · 1 line
1.7.9.5