diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-02-02 01:27:07 -0500 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2011-05-25 11:04:34 -0400 |
commit | bd60299594fb1d28ae66563c9e76a0b89b0412cf (patch) | |
tree | be57b42058328220a29a03ab68970a3b2a12949d /arch/arm | |
parent | 1b021a3b23a40be89c4f3fbe6f4696aa15141f26 (diff) |
at91: switch to CLKDEV_LOOKUP
we do not change the clock naming convention so does not need to switch
the AVR32 yet
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Patrice Vilchez <patrice.vilchez@atmel.com>
Diffstat (limited to 'arch/arm')
22 files changed, 372 insertions, 202 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7275009686e6..5fd0be92f70b 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
@@ -294,6 +294,7 @@ config ARCH_AT91 | |||
294 | bool "Atmel AT91" | 294 | bool "Atmel AT91" |
295 | select ARCH_REQUIRE_GPIOLIB | 295 | select ARCH_REQUIRE_GPIOLIB |
296 | select HAVE_CLK | 296 | select HAVE_CLK |
297 | select CLKDEV_LOOKUP | ||
297 | help | 298 | help |
298 | This enables support for systems based on the Atmel AT91RM9200, | 299 | This enables support for systems based on the Atmel AT91RM9200, |
299 | AT91SAM9 and AT91CAP9 processors. | 300 | AT91SAM9 and AT91CAP9 processors. |
diff --git a/arch/arm/mach-at91/at572d940hf.c b/arch/arm/mach-at91/at572d940hf.c index bacd3764b6c5..d06990777ffe 100644 --- a/arch/arm/mach-at91/at572d940hf.c +++ b/arch/arm/mach-at91/at572d940hf.c | |||
@@ -205,6 +205,21 @@ static struct clk *periph_clocks[] __initdata = { | |||
205 | /* irq0 .. irq2 */ | 205 | /* irq0 .. irq2 */ |
206 | }; | 206 | }; |
207 | 207 | ||
208 | static struct clk_lookup periph_clocks_lookups[] = { | ||
209 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
210 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
211 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), | ||
212 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), | ||
213 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), | ||
214 | }; | ||
215 | |||
216 | static struct clk_lookup usart_clocks_lookups[] = { | ||
217 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
218 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
219 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
220 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
221 | }; | ||
222 | |||
208 | /* | 223 | /* |
209 | * The five programmable clocks. | 224 | * The five programmable clocks. |
210 | * You must configure pin multiplexing to bring these signals out. | 225 | * You must configure pin multiplexing to bring these signals out. |
@@ -262,6 +277,11 @@ static void __init at572d940hf_register_clocks(void) | |||
262 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 277 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
263 | clk_register(periph_clocks[i]); | 278 | clk_register(periph_clocks[i]); |
264 | 279 | ||
280 | clkdev_add_table(periph_clocks_lookups, | ||
281 | ARRAY_SIZE(periph_clocks_lookups)); | ||
282 | clkdev_add_table(usart_clocks_lookups, | ||
283 | ARRAY_SIZE(usart_clocks_lookups)); | ||
284 | |||
265 | clk_register(&pck0); | 285 | clk_register(&pck0); |
266 | clk_register(&pck1); | 286 | clk_register(&pck1); |
267 | clk_register(&pck2); | 287 | clk_register(&pck2); |
@@ -272,6 +292,18 @@ static void __init at572d940hf_register_clocks(void) | |||
272 | clk_register(&hck1); | 292 | clk_register(&hck1); |
273 | } | 293 | } |
274 | 294 | ||
295 | static struct clk_lookup console_clock_lookup; | ||
296 | |||
297 | void __init at572d940hf_set_console_clock(int id) | ||
298 | { | ||
299 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
300 | return; | ||
301 | |||
302 | console_clock_lookup.con_id = "usart"; | ||
303 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
304 | clkdev_add(&console_clock_lookup); | ||
305 | } | ||
306 | |||
275 | /* -------------------------------------------------------------------- | 307 | /* -------------------------------------------------------------------- |
276 | * GPIO | 308 | * GPIO |
277 | * -------------------------------------------------------------------- */ | 309 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at572d940hf_devices.c b/arch/arm/mach-at91/at572d940hf_devices.c index e52c8e078b0f..14863b8e7e6a 100644 --- a/arch/arm/mach-at91/at572d940hf_devices.c +++ b/arch/arm/mach-at91/at572d940hf_devices.c | |||
@@ -532,7 +532,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
532 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | 532 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
533 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ | 533 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
534 | 534 | ||
535 | at91_clock_associate("spi0_clk", &at572d940hf_spi0_device.dev, "spi_clk"); | ||
536 | platform_device_register(&at572d940hf_spi0_device); | 535 | platform_device_register(&at572d940hf_spi0_device); |
537 | } | 536 | } |
538 | if (enable_spi1) { | 537 | if (enable_spi1) { |
@@ -540,7 +539,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
540 | at91_set_A_periph(AT91_PIN_PC1, 0); /* SPI1_MOSI */ | 539 | at91_set_A_periph(AT91_PIN_PC1, 0); /* SPI1_MOSI */ |
541 | at91_set_A_periph(AT91_PIN_PC2, 0); /* SPI1_SPCK */ | 540 | at91_set_A_periph(AT91_PIN_PC2, 0); /* SPI1_SPCK */ |
542 | 541 | ||
543 | at91_clock_associate("spi1_clk", &at572d940hf_spi1_device.dev, "spi_clk"); | ||
544 | platform_device_register(&at572d940hf_spi1_device); | 542 | platform_device_register(&at572d940hf_spi1_device); |
545 | } | 543 | } |
546 | } | 544 | } |
@@ -587,10 +585,6 @@ static struct platform_device at572d940hf_tcb_device = { | |||
587 | 585 | ||
588 | static void __init at91_add_device_tc(void) | 586 | static void __init at91_add_device_tc(void) |
589 | { | 587 | { |
590 | /* this chip has a separate clock and irq for each TC channel */ | ||
591 | at91_clock_associate("tc0_clk", &at572d940hf_tcb_device.dev, "t0_clk"); | ||
592 | at91_clock_associate("tc1_clk", &at572d940hf_tcb_device.dev, "t1_clk"); | ||
593 | at91_clock_associate("tc2_clk", &at572d940hf_tcb_device.dev, "t2_clk"); | ||
594 | platform_device_register(&at572d940hf_tcb_device); | 588 | platform_device_register(&at572d940hf_tcb_device); |
595 | } | 589 | } |
596 | #else | 590 | #else |
@@ -828,22 +822,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
828 | case 0: /* DBGU */ | 822 | case 0: /* DBGU */ |
829 | pdev = &at572d940hf_dbgu_device; | 823 | pdev = &at572d940hf_dbgu_device; |
830 | configure_dbgu_pins(); | 824 | configure_dbgu_pins(); |
831 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
832 | break; | 825 | break; |
833 | case AT572D940HF_ID_US0: | 826 | case AT572D940HF_ID_US0: |
834 | pdev = &at572d940hf_uart0_device; | 827 | pdev = &at572d940hf_uart0_device; |
835 | configure_usart0_pins(pins); | 828 | configure_usart0_pins(pins); |
836 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
837 | break; | 829 | break; |
838 | case AT572D940HF_ID_US1: | 830 | case AT572D940HF_ID_US1: |
839 | pdev = &at572d940hf_uart1_device; | 831 | pdev = &at572d940hf_uart1_device; |
840 | configure_usart1_pins(pins); | 832 | configure_usart1_pins(pins); |
841 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
842 | break; | 833 | break; |
843 | case AT572D940HF_ID_US2: | 834 | case AT572D940HF_ID_US2: |
844 | pdev = &at572d940hf_uart2_device; | 835 | pdev = &at572d940hf_uart2_device; |
845 | configure_usart2_pins(pins); | 836 | configure_usart2_pins(pins); |
846 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
847 | break; | 837 | break; |
848 | default: | 838 | default: |
849 | return; | 839 | return; |
@@ -857,8 +847,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
857 | 847 | ||
858 | void __init at91_set_serial_console(unsigned portnr) | 848 | void __init at91_set_serial_console(unsigned portnr) |
859 | { | 849 | { |
860 | if (portnr < ATMEL_MAX_UART) | 850 | if (portnr < ATMEL_MAX_UART) { |
861 | atmel_default_console_device = at91_uarts[portnr]; | 851 | atmel_default_console_device = at91_uarts[portnr]; |
852 | at572d940hf_set_console_clock(portnr); | ||
853 | } | ||
862 | } | 854 | } |
863 | 855 | ||
864 | void __init at91_add_device_serial(void) | 856 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c index 69df2bb4a703..17fae4a42ab5 100644 --- a/arch/arm/mach-at91/at91cap9.c +++ b/arch/arm/mach-at91/at91cap9.c | |||
@@ -222,6 +222,25 @@ static struct clk *periph_clocks[] __initdata = { | |||
222 | // irq0 .. irq1 | 222 | // irq0 .. irq1 |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static struct clk_lookup periph_clocks_lookups[] = { | ||
226 | CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), | ||
227 | CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), | ||
228 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk), | ||
229 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk), | ||
230 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
231 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
232 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), | ||
233 | CLKDEV_CON_DEV_ID("ssc", "ssc.0", &ssc0_clk), | ||
234 | CLKDEV_CON_DEV_ID("ssc", "ssc.1", &ssc1_clk), | ||
235 | }; | ||
236 | |||
237 | static struct clk_lookup usart_clocks_lookups[] = { | ||
238 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
239 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
240 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
241 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
242 | }; | ||
243 | |||
225 | /* | 244 | /* |
226 | * The four programmable clocks. | 245 | * The four programmable clocks. |
227 | * You must configure pin multiplexing to bring these signals out. | 246 | * You must configure pin multiplexing to bring these signals out. |
@@ -258,12 +277,29 @@ static void __init at91cap9_register_clocks(void) | |||
258 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 277 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
259 | clk_register(periph_clocks[i]); | 278 | clk_register(periph_clocks[i]); |
260 | 279 | ||
280 | clkdev_add_table(periph_clocks_lookups, | ||
281 | ARRAY_SIZE(periph_clocks_lookups)); | ||
282 | clkdev_add_table(usart_clocks_lookups, | ||
283 | ARRAY_SIZE(usart_clocks_lookups)); | ||
284 | |||
261 | clk_register(&pck0); | 285 | clk_register(&pck0); |
262 | clk_register(&pck1); | 286 | clk_register(&pck1); |
263 | clk_register(&pck2); | 287 | clk_register(&pck2); |
264 | clk_register(&pck3); | 288 | clk_register(&pck3); |
265 | } | 289 | } |
266 | 290 | ||
291 | static struct clk_lookup console_clock_lookup; | ||
292 | |||
293 | void __init at91cap9_set_console_clock(int id) | ||
294 | { | ||
295 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
296 | return; | ||
297 | |||
298 | console_clock_lookup.con_id = "usart"; | ||
299 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
300 | clkdev_add(&console_clock_lookup); | ||
301 | } | ||
302 | |||
267 | /* -------------------------------------------------------------------- | 303 | /* -------------------------------------------------------------------- |
268 | * GPIO | 304 | * GPIO |
269 | * -------------------------------------------------------------------- */ | 305 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c index ffda9099f6fa..cd850ed6f335 100644 --- a/arch/arm/mach-at91/at91cap9_devices.c +++ b/arch/arm/mach-at91/at91cap9_devices.c | |||
@@ -181,10 +181,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data) | |||
181 | 181 | ||
182 | /* Pullup pin is handled internally by USB device peripheral */ | 182 | /* Pullup pin is handled internally by USB device peripheral */ |
183 | 183 | ||
184 | /* Clocks */ | ||
185 | at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); | ||
186 | at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); | ||
187 | |||
188 | platform_device_register(&at91_usba_udc_device); | 184 | platform_device_register(&at91_usba_udc_device); |
189 | } | 185 | } |
190 | #else | 186 | #else |
@@ -355,7 +351,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | |||
355 | } | 351 | } |
356 | 352 | ||
357 | mmc0_data = *data; | 353 | mmc0_data = *data; |
358 | at91_clock_associate("mci0_clk", &at91cap9_mmc0_device.dev, "mci_clk"); | ||
359 | platform_device_register(&at91cap9_mmc0_device); | 354 | platform_device_register(&at91cap9_mmc0_device); |
360 | } else { /* MCI1 */ | 355 | } else { /* MCI1 */ |
361 | /* CLK */ | 356 | /* CLK */ |
@@ -373,7 +368,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | |||
373 | } | 368 | } |
374 | 369 | ||
375 | mmc1_data = *data; | 370 | mmc1_data = *data; |
376 | at91_clock_associate("mci1_clk", &at91cap9_mmc1_device.dev, "mci_clk"); | ||
377 | platform_device_register(&at91cap9_mmc1_device); | 371 | platform_device_register(&at91cap9_mmc1_device); |
378 | } | 372 | } |
379 | } | 373 | } |
@@ -614,7 +608,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
614 | at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | 608 | at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
615 | at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ | 609 | at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
616 | 610 | ||
617 | at91_clock_associate("spi0_clk", &at91cap9_spi0_device.dev, "spi_clk"); | ||
618 | platform_device_register(&at91cap9_spi0_device); | 611 | platform_device_register(&at91cap9_spi0_device); |
619 | } | 612 | } |
620 | if (enable_spi1) { | 613 | if (enable_spi1) { |
@@ -622,7 +615,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
622 | at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */ | 615 | at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */ |
623 | at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */ | 616 | at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */ |
624 | 617 | ||
625 | at91_clock_associate("spi1_clk", &at91cap9_spi1_device.dev, "spi_clk"); | ||
626 | platform_device_register(&at91cap9_spi1_device); | 618 | platform_device_register(&at91cap9_spi1_device); |
627 | } | 619 | } |
628 | } | 620 | } |
@@ -659,8 +651,6 @@ static struct platform_device at91cap9_tcb_device = { | |||
659 | 651 | ||
660 | static void __init at91_add_device_tc(void) | 652 | static void __init at91_add_device_tc(void) |
661 | { | 653 | { |
662 | /* this chip has one clock and irq for all three TC channels */ | ||
663 | at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk"); | ||
664 | platform_device_register(&at91cap9_tcb_device); | 654 | platform_device_register(&at91cap9_tcb_device); |
665 | } | 655 | } |
666 | #else | 656 | #else |
@@ -1001,12 +991,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
1001 | case AT91CAP9_ID_SSC0: | 991 | case AT91CAP9_ID_SSC0: |
1002 | pdev = &at91cap9_ssc0_device; | 992 | pdev = &at91cap9_ssc0_device; |
1003 | configure_ssc0_pins(pins); | 993 | configure_ssc0_pins(pins); |
1004 | at91_clock_associate("ssc0_clk", &pdev->dev, "ssc"); | ||
1005 | break; | 994 | break; |
1006 | case AT91CAP9_ID_SSC1: | 995 | case AT91CAP9_ID_SSC1: |
1007 | pdev = &at91cap9_ssc1_device; | 996 | pdev = &at91cap9_ssc1_device; |
1008 | configure_ssc1_pins(pins); | 997 | configure_ssc1_pins(pins); |
1009 | at91_clock_associate("ssc1_clk", &pdev->dev, "ssc"); | ||
1010 | break; | 998 | break; |
1011 | default: | 999 | default: |
1012 | return; | 1000 | return; |
@@ -1205,22 +1193,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1205 | case 0: /* DBGU */ | 1193 | case 0: /* DBGU */ |
1206 | pdev = &at91cap9_dbgu_device; | 1194 | pdev = &at91cap9_dbgu_device; |
1207 | configure_dbgu_pins(); | 1195 | configure_dbgu_pins(); |
1208 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1209 | break; | 1196 | break; |
1210 | case AT91CAP9_ID_US0: | 1197 | case AT91CAP9_ID_US0: |
1211 | pdev = &at91cap9_uart0_device; | 1198 | pdev = &at91cap9_uart0_device; |
1212 | configure_usart0_pins(pins); | 1199 | configure_usart0_pins(pins); |
1213 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1214 | break; | 1200 | break; |
1215 | case AT91CAP9_ID_US1: | 1201 | case AT91CAP9_ID_US1: |
1216 | pdev = &at91cap9_uart1_device; | 1202 | pdev = &at91cap9_uart1_device; |
1217 | configure_usart1_pins(pins); | 1203 | configure_usart1_pins(pins); |
1218 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1219 | break; | 1204 | break; |
1220 | case AT91CAP9_ID_US2: | 1205 | case AT91CAP9_ID_US2: |
1221 | pdev = &at91cap9_uart2_device; | 1206 | pdev = &at91cap9_uart2_device; |
1222 | configure_usart2_pins(pins); | 1207 | configure_usart2_pins(pins); |
1223 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1224 | break; | 1208 | break; |
1225 | default: | 1209 | default: |
1226 | return; | 1210 | return; |
@@ -1234,8 +1218,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1234 | 1218 | ||
1235 | void __init at91_set_serial_console(unsigned portnr) | 1219 | void __init at91_set_serial_console(unsigned portnr) |
1236 | { | 1220 | { |
1237 | if (portnr < ATMEL_MAX_UART) | 1221 | if (portnr < ATMEL_MAX_UART) { |
1238 | atmel_default_console_device = at91_uarts[portnr]; | 1222 | atmel_default_console_device = at91_uarts[portnr]; |
1223 | at91cap9_set_console_clock(portnr); | ||
1224 | } | ||
1239 | } | 1225 | } |
1240 | 1226 | ||
1241 | void __init at91_add_device_serial(void) | 1227 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c index 164a98ed8888..d3638bd994da 100644 --- a/arch/arm/mach-at91/at91rm9200.c +++ b/arch/arm/mach-at91/at91rm9200.c | |||
@@ -191,6 +191,26 @@ static struct clk *periph_clocks[] __initdata = { | |||
191 | // irq0 .. irq6 | 191 | // irq0 .. irq6 |
192 | }; | 192 | }; |
193 | 193 | ||
194 | static struct clk_lookup periph_clocks_lookups[] = { | ||
195 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), | ||
196 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), | ||
197 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), | ||
198 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), | ||
199 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), | ||
200 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), | ||
201 | CLKDEV_CON_DEV_ID("ssc", "ssc.0", &ssc0_clk), | ||
202 | CLKDEV_CON_DEV_ID("ssc", "ssc.1", &ssc1_clk), | ||
203 | CLKDEV_CON_DEV_ID("ssc", "ssc.2", &ssc2_clk), | ||
204 | }; | ||
205 | |||
206 | static struct clk_lookup usart_clocks_lookups[] = { | ||
207 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
208 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
209 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
210 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
211 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), | ||
212 | }; | ||
213 | |||
194 | /* | 214 | /* |
195 | * The four programmable clocks. | 215 | * The four programmable clocks. |
196 | * You must configure pin multiplexing to bring these signals out. | 216 | * You must configure pin multiplexing to bring these signals out. |
@@ -227,12 +247,29 @@ static void __init at91rm9200_register_clocks(void) | |||
227 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 247 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
228 | clk_register(periph_clocks[i]); | 248 | clk_register(periph_clocks[i]); |
229 | 249 | ||
250 | clkdev_add_table(periph_clocks_lookups, | ||
251 | ARRAY_SIZE(periph_clocks_lookups)); | ||
252 | clkdev_add_table(usart_clocks_lookups, | ||
253 | ARRAY_SIZE(usart_clocks_lookups)); | ||
254 | |||
230 | clk_register(&pck0); | 255 | clk_register(&pck0); |
231 | clk_register(&pck1); | 256 | clk_register(&pck1); |
232 | clk_register(&pck2); | 257 | clk_register(&pck2); |
233 | clk_register(&pck3); | 258 | clk_register(&pck3); |
234 | } | 259 | } |
235 | 260 | ||
261 | static struct clk_lookup console_clock_lookup; | ||
262 | |||
263 | void __init at91rm9200_set_console_clock(int id) | ||
264 | { | ||
265 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
266 | return; | ||
267 | |||
268 | console_clock_lookup.con_id = "usart"; | ||
269 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
270 | clkdev_add(&console_clock_lookup); | ||
271 | } | ||
272 | |||
236 | /* -------------------------------------------------------------------- | 273 | /* -------------------------------------------------------------------- |
237 | * GPIO | 274 | * GPIO |
238 | * -------------------------------------------------------------------- */ | 275 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 761559e589a3..a0ba475be04c 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c | |||
@@ -644,15 +644,7 @@ static struct platform_device at91rm9200_tcb1_device = { | |||
644 | 644 | ||
645 | static void __init at91_add_device_tc(void) | 645 | static void __init at91_add_device_tc(void) |
646 | { | 646 | { |
647 | /* this chip has a separate clock and irq for each TC channel */ | ||
648 | at91_clock_associate("tc0_clk", &at91rm9200_tcb0_device.dev, "t0_clk"); | ||
649 | at91_clock_associate("tc1_clk", &at91rm9200_tcb0_device.dev, "t1_clk"); | ||
650 | at91_clock_associate("tc2_clk", &at91rm9200_tcb0_device.dev, "t2_clk"); | ||
651 | platform_device_register(&at91rm9200_tcb0_device); | 647 | platform_device_register(&at91rm9200_tcb0_device); |
652 | |||
653 | at91_clock_associate("tc3_clk", &at91rm9200_tcb1_device.dev, "t0_clk"); | ||
654 | at91_clock_associate("tc4_clk", &at91rm9200_tcb1_device.dev, "t1_clk"); | ||
655 | at91_clock_associate("tc5_clk", &at91rm9200_tcb1_device.dev, "t2_clk"); | ||
656 | platform_device_register(&at91rm9200_tcb1_device); | 648 | platform_device_register(&at91rm9200_tcb1_device); |
657 | } | 649 | } |
658 | #else | 650 | #else |
@@ -849,17 +841,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
849 | case AT91RM9200_ID_SSC0: | 841 | case AT91RM9200_ID_SSC0: |
850 | pdev = &at91rm9200_ssc0_device; | 842 | pdev = &at91rm9200_ssc0_device; |
851 | configure_ssc0_pins(pins); | 843 | configure_ssc0_pins(pins); |
852 | at91_clock_associate("ssc0_clk", &pdev->dev, "ssc"); | ||
853 | break; | 844 | break; |
854 | case AT91RM9200_ID_SSC1: | 845 | case AT91RM9200_ID_SSC1: |
855 | pdev = &at91rm9200_ssc1_device; | 846 | pdev = &at91rm9200_ssc1_device; |
856 | configure_ssc1_pins(pins); | 847 | configure_ssc1_pins(pins); |
857 | at91_clock_associate("ssc1_clk", &pdev->dev, "ssc"); | ||
858 | break; | 848 | break; |
859 | case AT91RM9200_ID_SSC2: | 849 | case AT91RM9200_ID_SSC2: |
860 | pdev = &at91rm9200_ssc2_device; | 850 | pdev = &at91rm9200_ssc2_device; |
861 | configure_ssc2_pins(pins); | 851 | configure_ssc2_pins(pins); |
862 | at91_clock_associate("ssc2_clk", &pdev->dev, "ssc"); | ||
863 | break; | 852 | break; |
864 | default: | 853 | default: |
865 | return; | 854 | return; |
@@ -1115,27 +1104,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1115 | case 0: /* DBGU */ | 1104 | case 0: /* DBGU */ |
1116 | pdev = &at91rm9200_dbgu_device; | 1105 | pdev = &at91rm9200_dbgu_device; |
1117 | configure_dbgu_pins(); | 1106 | configure_dbgu_pins(); |
1118 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1119 | break; | 1107 | break; |
1120 | case AT91RM9200_ID_US0: | 1108 | case AT91RM9200_ID_US0: |
1121 | pdev = &at91rm9200_uart0_device; | 1109 | pdev = &at91rm9200_uart0_device; |
1122 | configure_usart0_pins(pins); | 1110 | configure_usart0_pins(pins); |
1123 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1124 | break; | 1111 | break; |
1125 | case AT91RM9200_ID_US1: | 1112 | case AT91RM9200_ID_US1: |
1126 | pdev = &at91rm9200_uart1_device; | 1113 | pdev = &at91rm9200_uart1_device; |
1127 | configure_usart1_pins(pins); | 1114 | configure_usart1_pins(pins); |
1128 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1129 | break; | 1115 | break; |
1130 | case AT91RM9200_ID_US2: | 1116 | case AT91RM9200_ID_US2: |
1131 | pdev = &at91rm9200_uart2_device; | 1117 | pdev = &at91rm9200_uart2_device; |
1132 | configure_usart2_pins(pins); | 1118 | configure_usart2_pins(pins); |
1133 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1134 | break; | 1119 | break; |
1135 | case AT91RM9200_ID_US3: | 1120 | case AT91RM9200_ID_US3: |
1136 | pdev = &at91rm9200_uart3_device; | 1121 | pdev = &at91rm9200_uart3_device; |
1137 | configure_usart3_pins(pins); | 1122 | configure_usart3_pins(pins); |
1138 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1139 | break; | 1123 | break; |
1140 | default: | 1124 | default: |
1141 | return; | 1125 | return; |
@@ -1149,8 +1133,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1149 | 1133 | ||
1150 | void __init at91_set_serial_console(unsigned portnr) | 1134 | void __init at91_set_serial_console(unsigned portnr) |
1151 | { | 1135 | { |
1152 | if (portnr < ATMEL_MAX_UART) | 1136 | if (portnr < ATMEL_MAX_UART) { |
1153 | atmel_default_console_device = at91_uarts[portnr]; | 1137 | atmel_default_console_device = at91_uarts[portnr]; |
1138 | at91rm9200_set_console_clock(portnr); | ||
1139 | } | ||
1154 | } | 1140 | } |
1155 | 1141 | ||
1156 | void __init at91_add_device_serial(void) | 1142 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c index 5430669d7462..7d606b04d313 100644 --- a/arch/arm/mach-at91/at91sam9260.c +++ b/arch/arm/mach-at91/at91sam9260.c | |||
@@ -231,6 +231,28 @@ static struct clk *periph_clocks[] __initdata = { | |||
231 | // irq0 .. irq2 | 231 | // irq0 .. irq2 |
232 | }; | 232 | }; |
233 | 233 | ||
234 | static struct clk_lookup periph_clocks_lookups[] = { | ||
235 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
236 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
237 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), | ||
238 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), | ||
239 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), | ||
240 | CLKDEV_CON_DEV_ID("t3_clk", "atmel_tcb.1", &tc3_clk), | ||
241 | CLKDEV_CON_DEV_ID("t4_clk", "atmel_tcb.1", &tc4_clk), | ||
242 | CLKDEV_CON_DEV_ID("t5_clk", "atmel_tcb.1", &tc5_clk), | ||
243 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk), | ||
244 | }; | ||
245 | |||
246 | static struct clk_lookup usart_clocks_lookups[] = { | ||
247 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
248 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
249 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
250 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
251 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), | ||
252 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.5", &usart4_clk), | ||
253 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.6", &usart5_clk), | ||
254 | }; | ||
255 | |||
234 | /* | 256 | /* |
235 | * The two programmable clocks. | 257 | * The two programmable clocks. |
236 | * You must configure pin multiplexing to bring these signals out. | 258 | * You must configure pin multiplexing to bring these signals out. |
@@ -255,10 +277,27 @@ static void __init at91sam9260_register_clocks(void) | |||
255 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 277 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
256 | clk_register(periph_clocks[i]); | 278 | clk_register(periph_clocks[i]); |
257 | 279 | ||
280 | clkdev_add_table(periph_clocks_lookups, | ||
281 | ARRAY_SIZE(periph_clocks_lookups)); | ||
282 | clkdev_add_table(usart_clocks_lookups, | ||
283 | ARRAY_SIZE(usart_clocks_lookups)); | ||
284 | |||
258 | clk_register(&pck0); | 285 | clk_register(&pck0); |
259 | clk_register(&pck1); | 286 | clk_register(&pck1); |
260 | } | 287 | } |
261 | 288 | ||
289 | static struct clk_lookup console_clock_lookup; | ||
290 | |||
291 | void __init at91sam9260_set_console_clock(int id) | ||
292 | { | ||
293 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
294 | return; | ||
295 | |||
296 | console_clock_lookup.con_id = "usart"; | ||
297 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
298 | clkdev_add(&console_clock_lookup); | ||
299 | } | ||
300 | |||
262 | /* -------------------------------------------------------------------- | 301 | /* -------------------------------------------------------------------- |
263 | * GPIO | 302 | * GPIO |
264 | * -------------------------------------------------------------------- */ | 303 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 6f8ec8d16d5a..1fdeb9058a76 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
@@ -609,7 +609,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
609 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | 609 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
610 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI1_SPCK */ | 610 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI1_SPCK */ |
611 | 611 | ||
612 | at91_clock_associate("spi0_clk", &at91sam9260_spi0_device.dev, "spi_clk"); | ||
613 | platform_device_register(&at91sam9260_spi0_device); | 612 | platform_device_register(&at91sam9260_spi0_device); |
614 | } | 613 | } |
615 | if (enable_spi1) { | 614 | if (enable_spi1) { |
@@ -617,7 +616,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
617 | at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI1_MOSI */ | 616 | at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI1_MOSI */ |
618 | at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI1_SPCK */ | 617 | at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI1_SPCK */ |
619 | 618 | ||
620 | at91_clock_associate("spi1_clk", &at91sam9260_spi1_device.dev, "spi_clk"); | ||
621 | platform_device_register(&at91sam9260_spi1_device); | 619 | platform_device_register(&at91sam9260_spi1_device); |
622 | } | 620 | } |
623 | } | 621 | } |
@@ -694,15 +692,7 @@ static struct platform_device at91sam9260_tcb1_device = { | |||
694 | 692 | ||
695 | static void __init at91_add_device_tc(void) | 693 | static void __init at91_add_device_tc(void) |
696 | { | 694 | { |
697 | /* this chip has a separate clock and irq for each TC channel */ | ||
698 | at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk"); | ||
699 | at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk"); | ||
700 | at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk"); | ||
701 | platform_device_register(&at91sam9260_tcb0_device); | 695 | platform_device_register(&at91sam9260_tcb0_device); |
702 | |||
703 | at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk"); | ||
704 | at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk"); | ||
705 | at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk"); | ||
706 | platform_device_register(&at91sam9260_tcb1_device); | 696 | platform_device_register(&at91sam9260_tcb1_device); |
707 | } | 697 | } |
708 | #else | 698 | #else |
@@ -820,7 +810,6 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
820 | case AT91SAM9260_ID_SSC: | 810 | case AT91SAM9260_ID_SSC: |
821 | pdev = &at91sam9260_ssc_device; | 811 | pdev = &at91sam9260_ssc_device; |
822 | configure_ssc_pins(pins); | 812 | configure_ssc_pins(pins); |
823 | at91_clock_associate("ssc_clk", &pdev->dev, "pclk"); | ||
824 | break; | 813 | break; |
825 | default: | 814 | default: |
826 | return; | 815 | return; |
@@ -1145,37 +1134,30 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1145 | case 0: /* DBGU */ | 1134 | case 0: /* DBGU */ |
1146 | pdev = &at91sam9260_dbgu_device; | 1135 | pdev = &at91sam9260_dbgu_device; |
1147 | configure_dbgu_pins(); | 1136 | configure_dbgu_pins(); |
1148 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1149 | break; | 1137 | break; |
1150 | case AT91SAM9260_ID_US0: | 1138 | case AT91SAM9260_ID_US0: |
1151 | pdev = &at91sam9260_uart0_device; | 1139 | pdev = &at91sam9260_uart0_device; |
1152 | configure_usart0_pins(pins); | 1140 | configure_usart0_pins(pins); |
1153 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1154 | break; | 1141 | break; |
1155 | case AT91SAM9260_ID_US1: | 1142 | case AT91SAM9260_ID_US1: |
1156 | pdev = &at91sam9260_uart1_device; | 1143 | pdev = &at91sam9260_uart1_device; |
1157 | configure_usart1_pins(pins); | 1144 | configure_usart1_pins(pins); |
1158 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1159 | break; | 1145 | break; |
1160 | case AT91SAM9260_ID_US2: | 1146 | case AT91SAM9260_ID_US2: |
1161 | pdev = &at91sam9260_uart2_device; | 1147 | pdev = &at91sam9260_uart2_device; |
1162 | configure_usart2_pins(pins); | 1148 | configure_usart2_pins(pins); |
1163 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1164 | break; | 1149 | break; |
1165 | case AT91SAM9260_ID_US3: | 1150 | case AT91SAM9260_ID_US3: |
1166 | pdev = &at91sam9260_uart3_device; | 1151 | pdev = &at91sam9260_uart3_device; |
1167 | configure_usart3_pins(pins); | 1152 | configure_usart3_pins(pins); |
1168 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1169 | break; | 1153 | break; |
1170 | case AT91SAM9260_ID_US4: | 1154 | case AT91SAM9260_ID_US4: |
1171 | pdev = &at91sam9260_uart4_device; | 1155 | pdev = &at91sam9260_uart4_device; |
1172 | configure_usart4_pins(); | 1156 | configure_usart4_pins(); |
1173 | at91_clock_associate("usart4_clk", &pdev->dev, "usart"); | ||
1174 | break; | 1157 | break; |
1175 | case AT91SAM9260_ID_US5: | 1158 | case AT91SAM9260_ID_US5: |
1176 | pdev = &at91sam9260_uart5_device; | 1159 | pdev = &at91sam9260_uart5_device; |
1177 | configure_usart5_pins(); | 1160 | configure_usart5_pins(); |
1178 | at91_clock_associate("usart5_clk", &pdev->dev, "usart"); | ||
1179 | break; | 1161 | break; |
1180 | default: | 1162 | default: |
1181 | return; | 1163 | return; |
@@ -1189,8 +1171,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1189 | 1171 | ||
1190 | void __init at91_set_serial_console(unsigned portnr) | 1172 | void __init at91_set_serial_console(unsigned portnr) |
1191 | { | 1173 | { |
1192 | if (portnr < ATMEL_MAX_UART) | 1174 | if (portnr < ATMEL_MAX_UART) { |
1193 | atmel_default_console_device = at91_uarts[portnr]; | 1175 | atmel_default_console_device = at91_uarts[portnr]; |
1176 | at91sam9260_set_console_clock(portnr); | ||
1177 | } | ||
1194 | } | 1178 | } |
1195 | 1179 | ||
1196 | void __init at91_add_device_serial(void) | 1180 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c index e3bafaebe010..c1483168c97a 100644 --- a/arch/arm/mach-at91/at91sam9261.c +++ b/arch/arm/mach-at91/at91sam9261.c | |||
@@ -178,6 +178,24 @@ static struct clk *periph_clocks[] __initdata = { | |||
178 | // irq0 .. irq2 | 178 | // irq0 .. irq2 |
179 | }; | 179 | }; |
180 | 180 | ||
181 | static struct clk_lookup periph_clocks_lookups[] = { | ||
182 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
183 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
184 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), | ||
185 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), | ||
186 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc1_clk), | ||
187 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), | ||
188 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), | ||
189 | CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), | ||
190 | }; | ||
191 | |||
192 | static struct clk_lookup usart_clocks_lookups[] = { | ||
193 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
194 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
195 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
196 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
197 | }; | ||
198 | |||
181 | /* | 199 | /* |
182 | * The four programmable clocks. | 200 | * The four programmable clocks. |
183 | * You must configure pin multiplexing to bring these signals out. | 201 | * You must configure pin multiplexing to bring these signals out. |
@@ -228,6 +246,11 @@ static void __init at91sam9261_register_clocks(void) | |||
228 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 246 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
229 | clk_register(periph_clocks[i]); | 247 | clk_register(periph_clocks[i]); |
230 | 248 | ||
249 | clkdev_add_table(periph_clocks_lookups, | ||
250 | ARRAY_SIZE(periph_clocks_lookups)); | ||
251 | clkdev_add_table(usart_clocks_lookups, | ||
252 | ARRAY_SIZE(usart_clocks_lookups)); | ||
253 | |||
231 | clk_register(&pck0); | 254 | clk_register(&pck0); |
232 | clk_register(&pck1); | 255 | clk_register(&pck1); |
233 | clk_register(&pck2); | 256 | clk_register(&pck2); |
@@ -237,6 +260,18 @@ static void __init at91sam9261_register_clocks(void) | |||
237 | clk_register(&hck1); | 260 | clk_register(&hck1); |
238 | } | 261 | } |
239 | 262 | ||
263 | static struct clk_lookup console_clock_lookup; | ||
264 | |||
265 | void __init at91sam9261_set_console_clock(int id) | ||
266 | { | ||
267 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
268 | return; | ||
269 | |||
270 | console_clock_lookup.con_id = "usart"; | ||
271 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
272 | clkdev_add(&console_clock_lookup); | ||
273 | } | ||
274 | |||
240 | /* -------------------------------------------------------------------- | 275 | /* -------------------------------------------------------------------- |
241 | * GPIO | 276 | * GPIO |
242 | * -------------------------------------------------------------------- */ | 277 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 8792f9bfb6b0..3eb4538fceeb 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c | |||
@@ -426,7 +426,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
426 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | 426 | at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
427 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ | 427 | at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
428 | 428 | ||
429 | at91_clock_associate("spi0_clk", &at91sam9261_spi0_device.dev, "spi_clk"); | ||
430 | platform_device_register(&at91sam9261_spi0_device); | 429 | platform_device_register(&at91sam9261_spi0_device); |
431 | } | 430 | } |
432 | if (enable_spi1) { | 431 | if (enable_spi1) { |
@@ -434,7 +433,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
434 | at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */ | 433 | at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */ |
435 | at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */ | 434 | at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */ |
436 | 435 | ||
437 | at91_clock_associate("spi1_clk", &at91sam9261_spi1_device.dev, "spi_clk"); | ||
438 | platform_device_register(&at91sam9261_spi1_device); | 436 | platform_device_register(&at91sam9261_spi1_device); |
439 | } | 437 | } |
440 | } | 438 | } |
@@ -581,10 +579,6 @@ static struct platform_device at91sam9261_tcb_device = { | |||
581 | 579 | ||
582 | static void __init at91_add_device_tc(void) | 580 | static void __init at91_add_device_tc(void) |
583 | { | 581 | { |
584 | /* this chip has a separate clock and irq for each TC channel */ | ||
585 | at91_clock_associate("tc0_clk", &at91sam9261_tcb_device.dev, "t0_clk"); | ||
586 | at91_clock_associate("tc1_clk", &at91sam9261_tcb_device.dev, "t1_clk"); | ||
587 | at91_clock_associate("tc2_clk", &at91sam9261_tcb_device.dev, "t2_clk"); | ||
588 | platform_device_register(&at91sam9261_tcb_device); | 582 | platform_device_register(&at91sam9261_tcb_device); |
589 | } | 583 | } |
590 | #else | 584 | #else |
@@ -786,17 +780,14 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
786 | case AT91SAM9261_ID_SSC0: | 780 | case AT91SAM9261_ID_SSC0: |
787 | pdev = &at91sam9261_ssc0_device; | 781 | pdev = &at91sam9261_ssc0_device; |
788 | configure_ssc0_pins(pins); | 782 | configure_ssc0_pins(pins); |
789 | at91_clock_associate("ssc0_clk", &pdev->dev, "pclk"); | ||
790 | break; | 783 | break; |
791 | case AT91SAM9261_ID_SSC1: | 784 | case AT91SAM9261_ID_SSC1: |
792 | pdev = &at91sam9261_ssc1_device; | 785 | pdev = &at91sam9261_ssc1_device; |
793 | configure_ssc1_pins(pins); | 786 | configure_ssc1_pins(pins); |
794 | at91_clock_associate("ssc1_clk", &pdev->dev, "pclk"); | ||
795 | break; | 787 | break; |
796 | case AT91SAM9261_ID_SSC2: | 788 | case AT91SAM9261_ID_SSC2: |
797 | pdev = &at91sam9261_ssc2_device; | 789 | pdev = &at91sam9261_ssc2_device; |
798 | configure_ssc2_pins(pins); | 790 | configure_ssc2_pins(pins); |
799 | at91_clock_associate("ssc2_clk", &pdev->dev, "pclk"); | ||
800 | break; | 791 | break; |
801 | default: | 792 | default: |
802 | return; | 793 | return; |
@@ -995,22 +986,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
995 | case 0: /* DBGU */ | 986 | case 0: /* DBGU */ |
996 | pdev = &at91sam9261_dbgu_device; | 987 | pdev = &at91sam9261_dbgu_device; |
997 | configure_dbgu_pins(); | 988 | configure_dbgu_pins(); |
998 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
999 | break; | 989 | break; |
1000 | case AT91SAM9261_ID_US0: | 990 | case AT91SAM9261_ID_US0: |
1001 | pdev = &at91sam9261_uart0_device; | 991 | pdev = &at91sam9261_uart0_device; |
1002 | configure_usart0_pins(pins); | 992 | configure_usart0_pins(pins); |
1003 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1004 | break; | 993 | break; |
1005 | case AT91SAM9261_ID_US1: | 994 | case AT91SAM9261_ID_US1: |
1006 | pdev = &at91sam9261_uart1_device; | 995 | pdev = &at91sam9261_uart1_device; |
1007 | configure_usart1_pins(pins); | 996 | configure_usart1_pins(pins); |
1008 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1009 | break; | 997 | break; |
1010 | case AT91SAM9261_ID_US2: | 998 | case AT91SAM9261_ID_US2: |
1011 | pdev = &at91sam9261_uart2_device; | 999 | pdev = &at91sam9261_uart2_device; |
1012 | configure_usart2_pins(pins); | 1000 | configure_usart2_pins(pins); |
1013 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1014 | break; | 1001 | break; |
1015 | default: | 1002 | default: |
1016 | return; | 1003 | return; |
@@ -1024,8 +1011,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1024 | 1011 | ||
1025 | void __init at91_set_serial_console(unsigned portnr) | 1012 | void __init at91_set_serial_console(unsigned portnr) |
1026 | { | 1013 | { |
1027 | if (portnr < ATMEL_MAX_UART) | 1014 | if (portnr < ATMEL_MAX_UART) { |
1028 | atmel_default_console_device = at91_uarts[portnr]; | 1015 | atmel_default_console_device = at91_uarts[portnr]; |
1016 | at91sam9261_set_console_clock(portnr); | ||
1017 | } | ||
1029 | } | 1018 | } |
1030 | 1019 | ||
1031 | void __init at91_add_device_serial(void) | 1020 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c index 6a085fedf6a3..dc28477d14ff 100644 --- a/arch/arm/mach-at91/at91sam9263.c +++ b/arch/arm/mach-at91/at91sam9263.c | |||
@@ -199,6 +199,23 @@ static struct clk *periph_clocks[] __initdata = { | |||
199 | // irq0 .. irq1 | 199 | // irq0 .. irq1 |
200 | }; | 200 | }; |
201 | 201 | ||
202 | static struct clk_lookup periph_clocks_lookups[] = { | ||
203 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), | ||
204 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), | ||
205 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk), | ||
206 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk), | ||
207 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
208 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
209 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), | ||
210 | }; | ||
211 | |||
212 | static struct clk_lookup usart_clocks_lookups[] = { | ||
213 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
214 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
215 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
216 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
217 | }; | ||
218 | |||
202 | /* | 219 | /* |
203 | * The four programmable clocks. | 220 | * The four programmable clocks. |
204 | * You must configure pin multiplexing to bring these signals out. | 221 | * You must configure pin multiplexing to bring these signals out. |
@@ -235,12 +252,29 @@ static void __init at91sam9263_register_clocks(void) | |||
235 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 252 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
236 | clk_register(periph_clocks[i]); | 253 | clk_register(periph_clocks[i]); |
237 | 254 | ||
255 | clkdev_add_table(periph_clocks_lookups, | ||
256 | ARRAY_SIZE(periph_clocks_lookups)); | ||
257 | clkdev_add_table(usart_clocks_lookups, | ||
258 | ARRAY_SIZE(usart_clocks_lookups)); | ||
259 | |||
238 | clk_register(&pck0); | 260 | clk_register(&pck0); |
239 | clk_register(&pck1); | 261 | clk_register(&pck1); |
240 | clk_register(&pck2); | 262 | clk_register(&pck2); |
241 | clk_register(&pck3); | 263 | clk_register(&pck3); |
242 | } | 264 | } |
243 | 265 | ||
266 | static struct clk_lookup console_clock_lookup; | ||
267 | |||
268 | void __init at91sam9263_set_console_clock(int id) | ||
269 | { | ||
270 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
271 | return; | ||
272 | |||
273 | console_clock_lookup.con_id = "usart"; | ||
274 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
275 | clkdev_add(&console_clock_lookup); | ||
276 | } | ||
277 | |||
244 | /* -------------------------------------------------------------------- | 278 | /* -------------------------------------------------------------------- |
245 | * GPIO | 279 | * GPIO |
246 | * -------------------------------------------------------------------- */ | 280 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index 47a9f965bbb5..ffe081b77ed0 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -308,7 +308,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | |||
308 | } | 308 | } |
309 | 309 | ||
310 | mmc0_data = *data; | 310 | mmc0_data = *data; |
311 | at91_clock_associate("mci0_clk", &at91sam9263_mmc0_device.dev, "mci_clk"); | ||
312 | platform_device_register(&at91sam9263_mmc0_device); | 311 | platform_device_register(&at91sam9263_mmc0_device); |
313 | } else { /* MCI1 */ | 312 | } else { /* MCI1 */ |
314 | /* CLK */ | 313 | /* CLK */ |
@@ -339,7 +338,6 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | |||
339 | } | 338 | } |
340 | 339 | ||
341 | mmc1_data = *data; | 340 | mmc1_data = *data; |
342 | at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); | ||
343 | platform_device_register(&at91sam9263_mmc1_device); | 341 | platform_device_register(&at91sam9263_mmc1_device); |
344 | } | 342 | } |
345 | } | 343 | } |
@@ -686,7 +684,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
686 | at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | 684 | at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ |
687 | at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ | 685 | at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
688 | 686 | ||
689 | at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk"); | ||
690 | platform_device_register(&at91sam9263_spi0_device); | 687 | platform_device_register(&at91sam9263_spi0_device); |
691 | } | 688 | } |
692 | if (enable_spi1) { | 689 | if (enable_spi1) { |
@@ -694,7 +691,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
694 | at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */ | 691 | at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */ |
695 | at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */ | 692 | at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */ |
696 | 693 | ||
697 | at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk"); | ||
698 | platform_device_register(&at91sam9263_spi1_device); | 694 | platform_device_register(&at91sam9263_spi1_device); |
699 | } | 695 | } |
700 | } | 696 | } |
@@ -941,8 +937,6 @@ static struct platform_device at91sam9263_tcb_device = { | |||
941 | 937 | ||
942 | static void __init at91_add_device_tc(void) | 938 | static void __init at91_add_device_tc(void) |
943 | { | 939 | { |
944 | /* this chip has one clock and irq for all three TC channels */ | ||
945 | at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk"); | ||
946 | platform_device_register(&at91sam9263_tcb_device); | 940 | platform_device_register(&at91sam9263_tcb_device); |
947 | } | 941 | } |
948 | #else | 942 | #else |
@@ -1171,12 +1165,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
1171 | case AT91SAM9263_ID_SSC0: | 1165 | case AT91SAM9263_ID_SSC0: |
1172 | pdev = &at91sam9263_ssc0_device; | 1166 | pdev = &at91sam9263_ssc0_device; |
1173 | configure_ssc0_pins(pins); | 1167 | configure_ssc0_pins(pins); |
1174 | at91_clock_associate("ssc0_clk", &pdev->dev, "pclk"); | ||
1175 | break; | 1168 | break; |
1176 | case AT91SAM9263_ID_SSC1: | 1169 | case AT91SAM9263_ID_SSC1: |
1177 | pdev = &at91sam9263_ssc1_device; | 1170 | pdev = &at91sam9263_ssc1_device; |
1178 | configure_ssc1_pins(pins); | 1171 | configure_ssc1_pins(pins); |
1179 | at91_clock_associate("ssc1_clk", &pdev->dev, "pclk"); | ||
1180 | break; | 1172 | break; |
1181 | default: | 1173 | default: |
1182 | return; | 1174 | return; |
@@ -1376,22 +1368,18 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1376 | case 0: /* DBGU */ | 1368 | case 0: /* DBGU */ |
1377 | pdev = &at91sam9263_dbgu_device; | 1369 | pdev = &at91sam9263_dbgu_device; |
1378 | configure_dbgu_pins(); | 1370 | configure_dbgu_pins(); |
1379 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1380 | break; | 1371 | break; |
1381 | case AT91SAM9263_ID_US0: | 1372 | case AT91SAM9263_ID_US0: |
1382 | pdev = &at91sam9263_uart0_device; | 1373 | pdev = &at91sam9263_uart0_device; |
1383 | configure_usart0_pins(pins); | 1374 | configure_usart0_pins(pins); |
1384 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1385 | break; | 1375 | break; |
1386 | case AT91SAM9263_ID_US1: | 1376 | case AT91SAM9263_ID_US1: |
1387 | pdev = &at91sam9263_uart1_device; | 1377 | pdev = &at91sam9263_uart1_device; |
1388 | configure_usart1_pins(pins); | 1378 | configure_usart1_pins(pins); |
1389 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1390 | break; | 1379 | break; |
1391 | case AT91SAM9263_ID_US2: | 1380 | case AT91SAM9263_ID_US2: |
1392 | pdev = &at91sam9263_uart2_device; | 1381 | pdev = &at91sam9263_uart2_device; |
1393 | configure_usart2_pins(pins); | 1382 | configure_usart2_pins(pins); |
1394 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1395 | break; | 1383 | break; |
1396 | default: | 1384 | default: |
1397 | return; | 1385 | return; |
@@ -1405,8 +1393,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1405 | 1393 | ||
1406 | void __init at91_set_serial_console(unsigned portnr) | 1394 | void __init at91_set_serial_console(unsigned portnr) |
1407 | { | 1395 | { |
1408 | if (portnr < ATMEL_MAX_UART) | 1396 | if (portnr < ATMEL_MAX_UART) { |
1409 | atmel_default_console_device = at91_uarts[portnr]; | 1397 | atmel_default_console_device = at91_uarts[portnr]; |
1398 | at91sam9263_set_console_clock(portnr); | ||
1399 | } | ||
1410 | } | 1400 | } |
1411 | 1401 | ||
1412 | void __init at91_add_device_serial(void) | 1402 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c index 024e456b943f..2bb6ff9af1c7 100644 --- a/arch/arm/mach-at91/at91sam9g45.c +++ b/arch/arm/mach-at91/at91sam9g45.c | |||
@@ -184,22 +184,6 @@ static struct clk vdec_clk = { | |||
184 | .type = CLK_TYPE_PERIPHERAL, | 184 | .type = CLK_TYPE_PERIPHERAL, |
185 | }; | 185 | }; |
186 | 186 | ||
187 | /* One additional fake clock for ohci */ | ||
188 | static struct clk ohci_clk = { | ||
189 | .name = "ohci_clk", | ||
190 | .pmc_mask = 0, | ||
191 | .type = CLK_TYPE_PERIPHERAL, | ||
192 | .parent = &uhphs_clk, | ||
193 | }; | ||
194 | |||
195 | /* One additional fake clock for second TC block */ | ||
196 | static struct clk tcb1_clk = { | ||
197 | .name = "tcb1_clk", | ||
198 | .pmc_mask = 0, | ||
199 | .type = CLK_TYPE_PERIPHERAL, | ||
200 | .parent = &tcb0_clk, | ||
201 | }; | ||
202 | |||
203 | static struct clk *periph_clocks[] __initdata = { | 187 | static struct clk *periph_clocks[] __initdata = { |
204 | &pioA_clk, | 188 | &pioA_clk, |
205 | &pioB_clk, | 189 | &pioB_clk, |
@@ -228,8 +212,30 @@ static struct clk *periph_clocks[] __initdata = { | |||
228 | &udphs_clk, | 212 | &udphs_clk, |
229 | &mmc1_clk, | 213 | &mmc1_clk, |
230 | // irq0 | 214 | // irq0 |
231 | &ohci_clk, | 215 | }; |
232 | &tcb1_clk, | 216 | |
217 | static struct clk_lookup periph_clocks_lookups[] = { | ||
218 | /* One additional fake clock for ohci */ | ||
219 | CLKDEV_CON_ID("ohci_clk", &uhphs_clk), | ||
220 | CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci.0", &uhphs_clk), | ||
221 | CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), | ||
222 | CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), | ||
223 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk), | ||
224 | CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk), | ||
225 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), | ||
226 | CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), | ||
227 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk), | ||
228 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk), | ||
229 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), | ||
230 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), | ||
231 | }; | ||
232 | |||
233 | static struct clk_lookup usart_clocks_lookups[] = { | ||
234 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
235 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
236 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
237 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
238 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), | ||
233 | }; | 239 | }; |
234 | 240 | ||
235 | /* | 241 | /* |
@@ -256,6 +262,11 @@ static void __init at91sam9g45_register_clocks(void) | |||
256 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 262 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
257 | clk_register(periph_clocks[i]); | 263 | clk_register(periph_clocks[i]); |
258 | 264 | ||
265 | clkdev_add_table(periph_clocks_lookups, | ||
266 | ARRAY_SIZE(periph_clocks_lookups)); | ||
267 | clkdev_add_table(usart_clocks_lookups, | ||
268 | ARRAY_SIZE(usart_clocks_lookups)); | ||
269 | |||
259 | if (cpu_is_at91sam9m10() || cpu_is_at91sam9m11()) | 270 | if (cpu_is_at91sam9m10() || cpu_is_at91sam9m11()) |
260 | clk_register(&vdec_clk); | 271 | clk_register(&vdec_clk); |
261 | 272 | ||
@@ -263,6 +274,18 @@ static void __init at91sam9g45_register_clocks(void) | |||
263 | clk_register(&pck1); | 274 | clk_register(&pck1); |
264 | } | 275 | } |
265 | 276 | ||
277 | static struct clk_lookup console_clock_lookup; | ||
278 | |||
279 | void __init at91sam9g45_set_console_clock(int id) | ||
280 | { | ||
281 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
282 | return; | ||
283 | |||
284 | console_clock_lookup.con_id = "usart"; | ||
285 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
286 | clkdev_add(&console_clock_lookup); | ||
287 | } | ||
288 | |||
266 | /* -------------------------------------------------------------------- | 289 | /* -------------------------------------------------------------------- |
267 | * GPIO | 290 | * GPIO |
268 | * -------------------------------------------------------------------- */ | 291 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index eee27eed9133..05674865bc21 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
@@ -180,7 +180,6 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) | |||
180 | } | 180 | } |
181 | 181 | ||
182 | usbh_ehci_data = *data; | 182 | usbh_ehci_data = *data; |
183 | at91_clock_associate("uhphs_clk", &at91_usbh_ehci_device.dev, "ehci_clk"); | ||
184 | platform_device_register(&at91_usbh_ehci_device); | 183 | platform_device_register(&at91_usbh_ehci_device); |
185 | } | 184 | } |
186 | #else | 185 | #else |
@@ -266,10 +265,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data) | |||
266 | 265 | ||
267 | /* Pullup pin is handled internally by USB device peripheral */ | 266 | /* Pullup pin is handled internally by USB device peripheral */ |
268 | 267 | ||
269 | /* Clocks */ | ||
270 | at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); | ||
271 | at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); | ||
272 | |||
273 | platform_device_register(&at91_usba_udc_device); | 268 | platform_device_register(&at91_usba_udc_device); |
274 | } | 269 | } |
275 | #else | 270 | #else |
@@ -478,7 +473,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) | |||
478 | } | 473 | } |
479 | 474 | ||
480 | mmc0_data = *data; | 475 | mmc0_data = *data; |
481 | at91_clock_associate("mci0_clk", &at91sam9g45_mmc0_device.dev, "mci_clk"); | ||
482 | platform_device_register(&at91sam9g45_mmc0_device); | 476 | platform_device_register(&at91sam9g45_mmc0_device); |
483 | 477 | ||
484 | } else { /* MCI1 */ | 478 | } else { /* MCI1 */ |
@@ -504,7 +498,6 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) | |||
504 | } | 498 | } |
505 | 499 | ||
506 | mmc1_data = *data; | 500 | mmc1_data = *data; |
507 | at91_clock_associate("mci1_clk", &at91sam9g45_mmc1_device.dev, "mci_clk"); | ||
508 | platform_device_register(&at91sam9g45_mmc1_device); | 501 | platform_device_register(&at91sam9g45_mmc1_device); |
509 | 502 | ||
510 | } | 503 | } |
@@ -801,7 +794,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
801 | at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */ | 794 | at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */ |
802 | at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */ | 795 | at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */ |
803 | 796 | ||
804 | at91_clock_associate("spi0_clk", &at91sam9g45_spi0_device.dev, "spi_clk"); | ||
805 | platform_device_register(&at91sam9g45_spi0_device); | 797 | platform_device_register(&at91sam9g45_spi0_device); |
806 | } | 798 | } |
807 | if (enable_spi1) { | 799 | if (enable_spi1) { |
@@ -809,7 +801,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
809 | at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */ | 801 | at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */ |
810 | at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */ | 802 | at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */ |
811 | 803 | ||
812 | at91_clock_associate("spi1_clk", &at91sam9g45_spi1_device.dev, "spi_clk"); | ||
813 | platform_device_register(&at91sam9g45_spi1_device); | 804 | platform_device_register(&at91sam9g45_spi1_device); |
814 | } | 805 | } |
815 | } | 806 | } |
@@ -999,10 +990,7 @@ static struct platform_device at91sam9g45_tcb1_device = { | |||
999 | 990 | ||
1000 | static void __init at91_add_device_tc(void) | 991 | static void __init at91_add_device_tc(void) |
1001 | { | 992 | { |
1002 | /* this chip has one clock and irq for all six TC channels */ | ||
1003 | at91_clock_associate("tcb0_clk", &at91sam9g45_tcb0_device.dev, "t0_clk"); | ||
1004 | platform_device_register(&at91sam9g45_tcb0_device); | 993 | platform_device_register(&at91sam9g45_tcb0_device); |
1005 | at91_clock_associate("tcb1_clk", &at91sam9g45_tcb1_device.dev, "t0_clk"); | ||
1006 | platform_device_register(&at91sam9g45_tcb1_device); | 994 | platform_device_register(&at91sam9g45_tcb1_device); |
1007 | } | 995 | } |
1008 | #else | 996 | #else |
@@ -1286,12 +1274,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
1286 | case AT91SAM9G45_ID_SSC0: | 1274 | case AT91SAM9G45_ID_SSC0: |
1287 | pdev = &at91sam9g45_ssc0_device; | 1275 | pdev = &at91sam9g45_ssc0_device; |
1288 | configure_ssc0_pins(pins); | 1276 | configure_ssc0_pins(pins); |
1289 | at91_clock_associate("ssc0_clk", &pdev->dev, "pclk"); | ||
1290 | break; | 1277 | break; |
1291 | case AT91SAM9G45_ID_SSC1: | 1278 | case AT91SAM9G45_ID_SSC1: |
1292 | pdev = &at91sam9g45_ssc1_device; | 1279 | pdev = &at91sam9g45_ssc1_device; |
1293 | configure_ssc1_pins(pins); | 1280 | configure_ssc1_pins(pins); |
1294 | at91_clock_associate("ssc1_clk", &pdev->dev, "pclk"); | ||
1295 | break; | 1281 | break; |
1296 | default: | 1282 | default: |
1297 | return; | 1283 | return; |
@@ -1533,27 +1519,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1533 | case 0: /* DBGU */ | 1519 | case 0: /* DBGU */ |
1534 | pdev = &at91sam9g45_dbgu_device; | 1520 | pdev = &at91sam9g45_dbgu_device; |
1535 | configure_dbgu_pins(); | 1521 | configure_dbgu_pins(); |
1536 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1537 | break; | 1522 | break; |
1538 | case AT91SAM9G45_ID_US0: | 1523 | case AT91SAM9G45_ID_US0: |
1539 | pdev = &at91sam9g45_uart0_device; | 1524 | pdev = &at91sam9g45_uart0_device; |
1540 | configure_usart0_pins(pins); | 1525 | configure_usart0_pins(pins); |
1541 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1542 | break; | 1526 | break; |
1543 | case AT91SAM9G45_ID_US1: | 1527 | case AT91SAM9G45_ID_US1: |
1544 | pdev = &at91sam9g45_uart1_device; | 1528 | pdev = &at91sam9g45_uart1_device; |
1545 | configure_usart1_pins(pins); | 1529 | configure_usart1_pins(pins); |
1546 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1547 | break; | 1530 | break; |
1548 | case AT91SAM9G45_ID_US2: | 1531 | case AT91SAM9G45_ID_US2: |
1549 | pdev = &at91sam9g45_uart2_device; | 1532 | pdev = &at91sam9g45_uart2_device; |
1550 | configure_usart2_pins(pins); | 1533 | configure_usart2_pins(pins); |
1551 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1552 | break; | 1534 | break; |
1553 | case AT91SAM9G45_ID_US3: | 1535 | case AT91SAM9G45_ID_US3: |
1554 | pdev = &at91sam9g45_uart3_device; | 1536 | pdev = &at91sam9g45_uart3_device; |
1555 | configure_usart3_pins(pins); | 1537 | configure_usart3_pins(pins); |
1556 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1557 | break; | 1538 | break; |
1558 | default: | 1539 | default: |
1559 | return; | 1540 | return; |
@@ -1567,8 +1548,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1567 | 1548 | ||
1568 | void __init at91_set_serial_console(unsigned portnr) | 1549 | void __init at91_set_serial_console(unsigned portnr) |
1569 | { | 1550 | { |
1570 | if (portnr < ATMEL_MAX_UART) | 1551 | if (portnr < ATMEL_MAX_UART) { |
1571 | atmel_default_console_device = at91_uarts[portnr]; | 1552 | atmel_default_console_device = at91_uarts[portnr]; |
1553 | at91sam9g45_set_console_clock(portnr); | ||
1554 | } | ||
1572 | } | 1555 | } |
1573 | 1556 | ||
1574 | void __init at91_add_device_serial(void) | 1557 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c index 67c869783c7e..1a40f16b66c8 100644 --- a/arch/arm/mach-at91/at91sam9rl.c +++ b/arch/arm/mach-at91/at91sam9rl.c | |||
@@ -190,6 +190,24 @@ static struct clk *periph_clocks[] __initdata = { | |||
190 | // irq0 | 190 | // irq0 |
191 | }; | 191 | }; |
192 | 192 | ||
193 | static struct clk_lookup periph_clocks_lookups[] = { | ||
194 | CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc.0", &utmi_clk), | ||
195 | CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc.0", &udphs_clk), | ||
196 | CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), | ||
197 | CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), | ||
198 | CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), | ||
199 | CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), | ||
200 | CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), | ||
201 | }; | ||
202 | |||
203 | static struct clk_lookup usart_clocks_lookups[] = { | ||
204 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck), | ||
205 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk), | ||
206 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk), | ||
207 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk), | ||
208 | CLKDEV_CON_DEV_ID("usart", "atmel_usart.4", &usart3_clk), | ||
209 | }; | ||
210 | |||
193 | /* | 211 | /* |
194 | * The two programmable clocks. | 212 | * The two programmable clocks. |
195 | * You must configure pin multiplexing to bring these signals out. | 213 | * You must configure pin multiplexing to bring these signals out. |
@@ -214,10 +232,27 @@ static void __init at91sam9rl_register_clocks(void) | |||
214 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) | 232 | for (i = 0; i < ARRAY_SIZE(periph_clocks); i++) |
215 | clk_register(periph_clocks[i]); | 233 | clk_register(periph_clocks[i]); |
216 | 234 | ||
235 | clkdev_add_table(periph_clocks_lookups, | ||
236 | ARRAY_SIZE(periph_clocks_lookups)); | ||
237 | clkdev_add_table(usart_clocks_lookups, | ||
238 | ARRAY_SIZE(usart_clocks_lookups)); | ||
239 | |||
217 | clk_register(&pck0); | 240 | clk_register(&pck0); |
218 | clk_register(&pck1); | 241 | clk_register(&pck1); |
219 | } | 242 | } |
220 | 243 | ||
244 | static struct clk_lookup console_clock_lookup; | ||
245 | |||
246 | void __init at91sam9rl_set_console_clock(int id) | ||
247 | { | ||
248 | if (id >= ARRAY_SIZE(usart_clocks_lookups)) | ||
249 | return; | ||
250 | |||
251 | console_clock_lookup.con_id = "usart"; | ||
252 | console_clock_lookup.clk = usart_clocks_lookups[id].clk; | ||
253 | clkdev_add(&console_clock_lookup); | ||
254 | } | ||
255 | |||
221 | /* -------------------------------------------------------------------- | 256 | /* -------------------------------------------------------------------- |
222 | * GPIO | 257 | * GPIO |
223 | * -------------------------------------------------------------------- */ | 258 | * -------------------------------------------------------------------- */ |
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index d194b085848e..c296045f2b6a 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c | |||
@@ -155,10 +155,6 @@ void __init at91_add_device_usba(struct usba_platform_data *data) | |||
155 | 155 | ||
156 | /* Pullup pin is handled internally by USB device peripheral */ | 156 | /* Pullup pin is handled internally by USB device peripheral */ |
157 | 157 | ||
158 | /* Clocks */ | ||
159 | at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk"); | ||
160 | at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk"); | ||
161 | |||
162 | platform_device_register(&at91_usba_udc_device); | 158 | platform_device_register(&at91_usba_udc_device); |
163 | } | 159 | } |
164 | #else | 160 | #else |
@@ -605,10 +601,6 @@ static struct platform_device at91sam9rl_tcb_device = { | |||
605 | 601 | ||
606 | static void __init at91_add_device_tc(void) | 602 | static void __init at91_add_device_tc(void) |
607 | { | 603 | { |
608 | /* this chip has a separate clock and irq for each TC channel */ | ||
609 | at91_clock_associate("tc0_clk", &at91sam9rl_tcb_device.dev, "t0_clk"); | ||
610 | at91_clock_associate("tc1_clk", &at91sam9rl_tcb_device.dev, "t1_clk"); | ||
611 | at91_clock_associate("tc2_clk", &at91sam9rl_tcb_device.dev, "t2_clk"); | ||
612 | platform_device_register(&at91sam9rl_tcb_device); | 604 | platform_device_register(&at91sam9rl_tcb_device); |
613 | } | 605 | } |
614 | #else | 606 | #else |
@@ -892,12 +884,10 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) | |||
892 | case AT91SAM9RL_ID_SSC0: | 884 | case AT91SAM9RL_ID_SSC0: |
893 | pdev = &at91sam9rl_ssc0_device; | 885 | pdev = &at91sam9rl_ssc0_device; |
894 | configure_ssc0_pins(pins); | 886 | configure_ssc0_pins(pins); |
895 | at91_clock_associate("ssc0_clk", &pdev->dev, "pclk"); | ||
896 | break; | 887 | break; |
897 | case AT91SAM9RL_ID_SSC1: | 888 | case AT91SAM9RL_ID_SSC1: |
898 | pdev = &at91sam9rl_ssc1_device; | 889 | pdev = &at91sam9rl_ssc1_device; |
899 | configure_ssc1_pins(pins); | 890 | configure_ssc1_pins(pins); |
900 | at91_clock_associate("ssc1_clk", &pdev->dev, "pclk"); | ||
901 | break; | 891 | break; |
902 | default: | 892 | default: |
903 | return; | 893 | return; |
@@ -1147,27 +1137,22 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1147 | case 0: /* DBGU */ | 1137 | case 0: /* DBGU */ |
1148 | pdev = &at91sam9rl_dbgu_device; | 1138 | pdev = &at91sam9rl_dbgu_device; |
1149 | configure_dbgu_pins(); | 1139 | configure_dbgu_pins(); |
1150 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1151 | break; | 1140 | break; |
1152 | case AT91SAM9RL_ID_US0: | 1141 | case AT91SAM9RL_ID_US0: |
1153 | pdev = &at91sam9rl_uart0_device; | 1142 | pdev = &at91sam9rl_uart0_device; |
1154 | configure_usart0_pins(pins); | 1143 | configure_usart0_pins(pins); |
1155 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1156 | break; | 1144 | break; |
1157 | case AT91SAM9RL_ID_US1: | 1145 | case AT91SAM9RL_ID_US1: |
1158 | pdev = &at91sam9rl_uart1_device; | 1146 | pdev = &at91sam9rl_uart1_device; |
1159 | configure_usart1_pins(pins); | 1147 | configure_usart1_pins(pins); |
1160 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1161 | break; | 1148 | break; |
1162 | case AT91SAM9RL_ID_US2: | 1149 | case AT91SAM9RL_ID_US2: |
1163 | pdev = &at91sam9rl_uart2_device; | 1150 | pdev = &at91sam9rl_uart2_device; |
1164 | configure_usart2_pins(pins); | 1151 | configure_usart2_pins(pins); |
1165 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1166 | break; | 1152 | break; |
1167 | case AT91SAM9RL_ID_US3: | 1153 | case AT91SAM9RL_ID_US3: |
1168 | pdev = &at91sam9rl_uart3_device; | 1154 | pdev = &at91sam9rl_uart3_device; |
1169 | configure_usart3_pins(pins); | 1155 | configure_usart3_pins(pins); |
1170 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1171 | break; | 1156 | break; |
1172 | default: | 1157 | default: |
1173 | return; | 1158 | return; |
@@ -1181,8 +1166,10 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | |||
1181 | 1166 | ||
1182 | void __init at91_set_serial_console(unsigned portnr) | 1167 | void __init at91_set_serial_console(unsigned portnr) |
1183 | { | 1168 | { |
1184 | if (portnr < ATMEL_MAX_UART) | 1169 | if (portnr < ATMEL_MAX_UART) { |
1185 | atmel_default_console_device = at91_uarts[portnr]; | 1170 | atmel_default_console_device = at91_uarts[portnr]; |
1171 | at91sam9rl_set_console_clock(portnr); | ||
1172 | } | ||
1186 | } | 1173 | } |
1187 | 1174 | ||
1188 | void __init at91_add_device_serial(void) | 1175 | void __init at91_add_device_serial(void) |
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c index ad3ec85b2790..56ba3bd035ae 100644 --- a/arch/arm/mach-at91/at91x40.c +++ b/arch/arm/mach-at91/at91x40.c | |||
@@ -37,11 +37,6 @@ unsigned long clk_get_rate(struct clk *clk) | |||
37 | return AT91X40_MASTER_CLOCK; | 37 | return AT91X40_MASTER_CLOCK; |
38 | } | 38 | } |
39 | 39 | ||
40 | struct clk *clk_get(struct device *dev, const char *id) | ||
41 | { | ||
42 | return NULL; | ||
43 | } | ||
44 | |||
45 | void __init at91x40_initialize(unsigned long main_clock) | 40 | void __init at91x40_initialize(unsigned long main_clock) |
46 | { | 41 | { |
47 | at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) | 42 | at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) |
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c index 9113da6845f1..ac103cbdbf35 100644 --- a/arch/arm/mach-at91/clock.c +++ b/arch/arm/mach-at91/clock.c | |||
@@ -163,7 +163,7 @@ static struct clk udpck = { | |||
163 | .parent = &pllb, | 163 | .parent = &pllb, |
164 | .mode = pmc_sys_mode, | 164 | .mode = pmc_sys_mode, |
165 | }; | 165 | }; |
166 | static struct clk utmi_clk = { | 166 | struct clk utmi_clk = { |
167 | .name = "utmi_clk", | 167 | .name = "utmi_clk", |
168 | .parent = &main_clk, | 168 | .parent = &main_clk, |
169 | .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */ | 169 | .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */ |
@@ -182,7 +182,7 @@ static struct clk uhpck = { | |||
182 | * memory, interfaces to on-chip peripherals, the AIC, and sometimes more | 182 | * memory, interfaces to on-chip peripherals, the AIC, and sometimes more |
183 | * (e.g baud rate generation). It's sourced from one of the primary clocks. | 183 | * (e.g baud rate generation). It's sourced from one of the primary clocks. |
184 | */ | 184 | */ |
185 | static struct clk mck = { | 185 | struct clk mck = { |
186 | .name = "mck", | 186 | .name = "mck", |
187 | .pmc_mask = AT91_PMC_MCKRDY, /* in PMC_SR */ | 187 | .pmc_mask = AT91_PMC_MCKRDY, /* in PMC_SR */ |
188 | }; | 188 | }; |
@@ -215,43 +215,6 @@ static struct clk __init *at91_css_to_clk(unsigned long css) | |||
215 | return NULL; | 215 | return NULL; |
216 | } | 216 | } |
217 | 217 | ||
218 | /* | ||
219 | * Associate a particular clock with a function (eg, "uart") and device. | ||
220 | * The drivers can then request the same 'function' with several different | ||
221 | * devices and not care about which clock name to use. | ||
222 | */ | ||
223 | void __init at91_clock_associate(const char *id, struct device *dev, const char *func) | ||
224 | { | ||
225 | struct clk *clk = clk_get(NULL, id); | ||
226 | |||
227 | if (!dev || !clk || !IS_ERR(clk_get(dev, func))) | ||
228 | return; | ||
229 | |||
230 | clk->function = func; | ||
231 | clk->dev = dev; | ||
232 | } | ||
233 | |||
234 | /* clocks cannot be de-registered no refcounting necessary */ | ||
235 | struct clk *clk_get(struct device *dev, const char *id) | ||
236 | { | ||
237 | struct clk *clk; | ||
238 | |||
239 | list_for_each_entry(clk, &clocks, node) { | ||
240 | if (strcmp(id, clk->name) == 0) | ||
241 | return clk; | ||
242 | if (clk->function && (dev == clk->dev) && strcmp(id, clk->function) == 0) | ||
243 | return clk; | ||
244 | } | ||
245 | |||
246 | return ERR_PTR(-ENOENT); | ||
247 | } | ||
248 | EXPORT_SYMBOL(clk_get); | ||
249 | |||
250 | void clk_put(struct clk *clk) | ||
251 | { | ||
252 | } | ||
253 | EXPORT_SYMBOL(clk_put); | ||
254 | |||
255 | static void __clk_enable(struct clk *clk) | 218 | static void __clk_enable(struct clk *clk) |
256 | { | 219 | { |
257 | if (clk->parent) | 220 | if (clk->parent) |
@@ -498,32 +461,38 @@ postcore_initcall(at91_clk_debugfs_init); | |||
498 | /*------------------------------------------------------------------------*/ | 461 | /*------------------------------------------------------------------------*/ |
499 | 462 | ||
500 | /* Register a new clock */ | 463 | /* Register a new clock */ |
464 | static void __init at91_clk_add(struct clk *clk) | ||
465 | { | ||
466 | list_add_tail(&clk->node, &clocks); | ||
467 | |||
468 | clk->cl.con_id = clk->name; | ||
469 | clk->cl.clk = clk; | ||
470 | clkdev_add(&clk->cl); | ||
471 | } | ||
472 | |||
501 | int __init clk_register(struct clk *clk) | 473 | int __init clk_register(struct clk *clk) |
502 | { | 474 | { |
503 | if (clk_is_peripheral(clk)) { | 475 | if (clk_is_peripheral(clk)) { |
504 | if (!clk->parent) | 476 | if (!clk->parent) |
505 | clk->parent = &mck; | 477 | clk->parent = &mck; |
506 | clk->mode = pmc_periph_mode; | 478 | clk->mode = pmc_periph_mode; |
507 | list_add_tail(&clk->node, &clocks); | ||
508 | } | 479 | } |
509 | else if (clk_is_sys(clk)) { | 480 | else if (clk_is_sys(clk)) { |
510 | clk->parent = &mck; | 481 | clk->parent = &mck; |
511 | clk->mode = pmc_sys_mode; | 482 | clk->mode = pmc_sys_mode; |
512 | |||
513 | list_add_tail(&clk->node, &clocks); | ||
514 | } | 483 | } |
515 | #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS | 484 | #ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS |
516 | else if (clk_is_programmable(clk)) { | 485 | else if (clk_is_programmable(clk)) { |
517 | clk->mode = pmc_sys_mode; | 486 | clk->mode = pmc_sys_mode; |
518 | init_programmable_clock(clk); | 487 | init_programmable_clock(clk); |
519 | list_add_tail(&clk->node, &clocks); | ||
520 | } | 488 | } |
521 | #endif | 489 | #endif |
522 | 490 | ||
491 | at91_clk_add(clk); | ||
492 | |||
523 | return 0; | 493 | return 0; |
524 | } | 494 | } |
525 | 495 | ||
526 | |||
527 | /*------------------------------------------------------------------------*/ | 496 | /*------------------------------------------------------------------------*/ |
528 | 497 | ||
529 | static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg) | 498 | static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg) |
@@ -754,19 +723,19 @@ int __init at91_clock_init(unsigned long main_clock) | |||
754 | 723 | ||
755 | /* Register the PMC's standard clocks */ | 724 | /* Register the PMC's standard clocks */ |
756 | for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) | 725 | for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) |
757 | list_add_tail(&standard_pmc_clocks[i]->node, &clocks); | 726 | at91_clk_add(standard_pmc_clocks[i]); |
758 | 727 | ||
759 | if (cpu_has_pllb()) | 728 | if (cpu_has_pllb()) |
760 | list_add_tail(&pllb.node, &clocks); | 729 | at91_clk_add(&pllb); |
761 | 730 | ||
762 | if (cpu_has_uhp()) | 731 | if (cpu_has_uhp()) |
763 | list_add_tail(&uhpck.node, &clocks); | 732 | at91_clk_add(&uhpck); |
764 | 733 | ||
765 | if (cpu_has_udpfs()) | 734 | if (cpu_has_udpfs()) |
766 | list_add_tail(&udpck.node, &clocks); | 735 | at91_clk_add(&udpck); |
767 | 736 | ||
768 | if (cpu_has_utmi()) | 737 | if (cpu_has_utmi()) |
769 | list_add_tail(&utmi_clk.node, &clocks); | 738 | at91_clk_add(&utmi_clk); |
770 | 739 | ||
771 | /* MCK and CPU clock are "always on" */ | 740 | /* MCK and CPU clock are "always on" */ |
772 | clk_enable(&mck); | 741 | clk_enable(&mck); |
diff --git a/arch/arm/mach-at91/clock.h b/arch/arm/mach-at91/clock.h index 6cf4b78e175d..c2e63e47dcbe 100644 --- a/arch/arm/mach-at91/clock.h +++ b/arch/arm/mach-at91/clock.h | |||
@@ -6,6 +6,8 @@ | |||
6 | * published by the Free Software Foundation. | 6 | * published by the Free Software Foundation. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/clkdev.h> | ||
10 | |||
9 | #define CLK_TYPE_PRIMARY 0x1 | 11 | #define CLK_TYPE_PRIMARY 0x1 |
10 | #define CLK_TYPE_PLL 0x2 | 12 | #define CLK_TYPE_PLL 0x2 |
11 | #define CLK_TYPE_PROGRAMMABLE 0x4 | 13 | #define CLK_TYPE_PROGRAMMABLE 0x4 |
@@ -16,8 +18,7 @@ | |||
16 | struct clk { | 18 | struct clk { |
17 | struct list_head node; | 19 | struct list_head node; |
18 | const char *name; /* unique clock name */ | 20 | const char *name; /* unique clock name */ |
19 | const char *function; /* function of the clock */ | 21 | struct clk_lookup cl; |
20 | struct device *dev; /* device associated with function */ | ||
21 | unsigned long rate_hz; | 22 | unsigned long rate_hz; |
22 | struct clk *parent; | 23 | struct clk *parent; |
23 | u32 pmc_mask; | 24 | u32 pmc_mask; |
@@ -29,3 +30,18 @@ struct clk { | |||
29 | 30 | ||
30 | 31 | ||
31 | extern int __init clk_register(struct clk *clk); | 32 | extern int __init clk_register(struct clk *clk); |
33 | extern struct clk mck; | ||
34 | extern struct clk utmi_clk; | ||
35 | |||
36 | #define CLKDEV_CON_ID(_id, _clk) \ | ||
37 | { \ | ||
38 | .con_id = _id, \ | ||
39 | .clk = _clk, \ | ||
40 | } | ||
41 | |||
42 | #define CLKDEV_CON_DEV_ID(_con_id, _dev_id, _clk) \ | ||
43 | { \ | ||
44 | .con_id = _con_id, \ | ||
45 | .dev_id = _dev_id, \ | ||
46 | .clk = _clk, \ | ||
47 | } | ||
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h index 50d46fa9ddb6..ecba94ee520b 100644 --- a/arch/arm/mach-at91/generic.h +++ b/arch/arm/mach-at91/generic.h | |||
@@ -8,6 +8,8 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/clkdev.h> | ||
12 | |||
11 | /* Map io */ | 13 | /* Map io */ |
12 | extern void __init at91rm9200_map_io(void); | 14 | extern void __init at91rm9200_map_io(void); |
13 | extern void __init at91sam9260_map_io(void); | 15 | extern void __init at91sam9260_map_io(void); |
@@ -50,8 +52,20 @@ extern struct sys_timer at91x40_timer; | |||
50 | 52 | ||
51 | /* Clocks */ | 53 | /* Clocks */ |
52 | extern int __init at91_clock_init(unsigned long main_clock); | 54 | extern int __init at91_clock_init(unsigned long main_clock); |
55 | /* | ||
56 | * function to specify the clock of the default console. As we do not | ||
57 | * use the device/driver bus, the dev_name is not intialize. So we need | ||
58 | * to link the clock to a specific con_id only "usart" | ||
59 | */ | ||
60 | extern void __init at91rm9200_set_console_clock(int id); | ||
61 | extern void __init at91sam9260_set_console_clock(int id); | ||
62 | extern void __init at91sam9261_set_console_clock(int id); | ||
63 | extern void __init at91sam9263_set_console_clock(int id); | ||
64 | extern void __init at91sam9rl_set_console_clock(int id); | ||
65 | extern void __init at91sam9g45_set_console_clock(int id); | ||
66 | extern void __init at91cap9_set_console_clock(int id); | ||
67 | extern void __init at572d940hf_set_console_clock(int id); | ||
53 | struct device; | 68 | struct device; |
54 | extern void __init at91_clock_associate(const char *id, struct device *dev, const char *func); | ||
55 | 69 | ||
56 | /* Power Management */ | 70 | /* Power Management */ |
57 | extern void at91_irq_suspend(void); | 71 | extern void at91_irq_suspend(void); |
diff --git a/arch/arm/mach-at91/include/mach/clkdev.h b/arch/arm/mach-at91/include/mach/clkdev.h new file mode 100644 index 000000000000..04b37a89801c --- /dev/null +++ b/arch/arm/mach-at91/include/mach/clkdev.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __ASM_MACH_CLKDEV_H | ||
2 | #define __ASM_MACH_CLKDEV_H | ||
3 | |||
4 | #define __clk_get(clk) ({ 1; }) | ||
5 | #define __clk_put(clk) do { } while (0) | ||
6 | |||
7 | #endif | ||