diff options
Diffstat (limited to 'arch/avr32/mach-at32ap/at32ap7000.c')
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap7000.c | 70 |
1 files changed, 69 insertions, 1 deletions
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c index 472703f90c22..56db45b99a0f 100644 --- a/arch/avr32/mach-at32ap/at32ap7000.c +++ b/arch/avr32/mach-at32ap/at32ap7000.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <asm/arch/sm.h> | 18 | #include <asm/arch/sm.h> |
19 | 19 | ||
20 | #include "clock.h" | 20 | #include "clock.h" |
21 | #include "hmatrix.h" | ||
21 | #include "pio.h" | 22 | #include "pio.h" |
22 | #include "sm.h" | 23 | #include "sm.h" |
23 | 24 | ||
@@ -416,7 +417,15 @@ struct platform_device at32_sm_device = { | |||
416 | .resource = sm_resource, | 417 | .resource = sm_resource, |
417 | .num_resources = ARRAY_SIZE(sm_resource), | 418 | .num_resources = ARRAY_SIZE(sm_resource), |
418 | }; | 419 | }; |
419 | DEV_CLK(pclk, at32_sm, pbb, 0); | 420 | static struct clk at32_sm_pclk = { |
421 | .name = "pclk", | ||
422 | .dev = &at32_sm_device.dev, | ||
423 | .parent = &pbb_clk, | ||
424 | .mode = pbb_clk_mode, | ||
425 | .get_rate = pbb_clk_get_rate, | ||
426 | .users = 1, | ||
427 | .index = 0, | ||
428 | }; | ||
420 | 429 | ||
421 | static struct resource intc0_resource[] = { | 430 | static struct resource intc0_resource[] = { |
422 | PBMEM(0xfff00400), | 431 | PBMEM(0xfff00400), |
@@ -442,6 +451,7 @@ static struct clk hramc_clk = { | |||
442 | .mode = hsb_clk_mode, | 451 | .mode = hsb_clk_mode, |
443 | .get_rate = hsb_clk_get_rate, | 452 | .get_rate = hsb_clk_get_rate, |
444 | .users = 1, | 453 | .users = 1, |
454 | .index = 3, | ||
445 | }; | 455 | }; |
446 | 456 | ||
447 | static struct resource smc0_resource[] = { | 457 | static struct resource smc0_resource[] = { |
@@ -467,6 +477,57 @@ static struct clk pico_clk = { | |||
467 | }; | 477 | }; |
468 | 478 | ||
469 | /* -------------------------------------------------------------------- | 479 | /* -------------------------------------------------------------------- |
480 | * HMATRIX | ||
481 | * -------------------------------------------------------------------- */ | ||
482 | |||
483 | static struct clk hmatrix_clk = { | ||
484 | .name = "hmatrix_clk", | ||
485 | .parent = &pbb_clk, | ||
486 | .mode = pbb_clk_mode, | ||
487 | .get_rate = pbb_clk_get_rate, | ||
488 | .index = 2, | ||
489 | .users = 1, | ||
490 | }; | ||
491 | #define HMATRIX_BASE ((void __iomem *)0xfff00800) | ||
492 | |||
493 | #define hmatrix_readl(reg) \ | ||
494 | __raw_readl((HMATRIX_BASE) + HMATRIX_##reg) | ||
495 | #define hmatrix_writel(reg,value) \ | ||
496 | __raw_writel((value), (HMATRIX_BASE) + HMATRIX_##reg) | ||
497 | |||
498 | /* | ||
499 | * Set bits in the HMATRIX Special Function Register (SFR) used by the | ||
500 | * External Bus Interface (EBI). This can be used to enable special | ||
501 | * features like CompactFlash support, NAND Flash support, etc. on | ||
502 | * certain chipselects. | ||
503 | */ | ||
504 | static inline void set_ebi_sfr_bits(u32 mask) | ||
505 | { | ||
506 | u32 sfr; | ||
507 | |||
508 | clk_enable(&hmatrix_clk); | ||
509 | sfr = hmatrix_readl(SFR4); | ||
510 | sfr |= mask; | ||
511 | hmatrix_writel(SFR4, sfr); | ||
512 | clk_disable(&hmatrix_clk); | ||
513 | } | ||
514 | |||
515 | /* -------------------------------------------------------------------- | ||
516 | * System Timer/Counter (TC) | ||
517 | * -------------------------------------------------------------------- */ | ||
518 | static struct resource at32_systc0_resource[] = { | ||
519 | PBMEM(0xfff00c00), | ||
520 | IRQ(22), | ||
521 | }; | ||
522 | struct platform_device at32_systc0_device = { | ||
523 | .name = "systc", | ||
524 | .id = 0, | ||
525 | .resource = at32_systc0_resource, | ||
526 | .num_resources = ARRAY_SIZE(at32_systc0_resource), | ||
527 | }; | ||
528 | DEV_CLK(pclk, at32_systc0, pbb, 3); | ||
529 | |||
530 | /* -------------------------------------------------------------------- | ||
470 | * PIO | 531 | * PIO |
471 | * -------------------------------------------------------------------- */ | 532 | * -------------------------------------------------------------------- */ |
472 | 533 | ||
@@ -514,6 +575,8 @@ void __init at32_add_system_devices(void) | |||
514 | platform_device_register(&smc0_device); | 575 | platform_device_register(&smc0_device); |
515 | platform_device_register(&pdc_device); | 576 | platform_device_register(&pdc_device); |
516 | 577 | ||
578 | platform_device_register(&at32_systc0_device); | ||
579 | |||
517 | platform_device_register(&pio0_device); | 580 | platform_device_register(&pio0_device); |
518 | platform_device_register(&pio1_device); | 581 | platform_device_register(&pio1_device); |
519 | platform_device_register(&pio2_device); | 582 | platform_device_register(&pio2_device); |
@@ -950,6 +1013,7 @@ struct clk *at32_clock_list[] = { | |||
950 | &pbb_clk, | 1013 | &pbb_clk, |
951 | &at32_sm_pclk, | 1014 | &at32_sm_pclk, |
952 | &at32_intc0_pclk, | 1015 | &at32_intc0_pclk, |
1016 | &hmatrix_clk, | ||
953 | &ebi_clk, | 1017 | &ebi_clk, |
954 | &hramc_clk, | 1018 | &hramc_clk, |
955 | &smc0_pclk, | 1019 | &smc0_pclk, |
@@ -962,6 +1026,7 @@ struct clk *at32_clock_list[] = { | |||
962 | &pio2_mck, | 1026 | &pio2_mck, |
963 | &pio3_mck, | 1027 | &pio3_mck, |
964 | &pio4_mck, | 1028 | &pio4_mck, |
1029 | &at32_systc0_pclk, | ||
965 | &atmel_usart0_usart, | 1030 | &atmel_usart0_usart, |
966 | &atmel_usart1_usart, | 1031 | &atmel_usart1_usart, |
967 | &atmel_usart2_usart, | 1032 | &atmel_usart2_usart, |
@@ -1024,6 +1089,9 @@ void __init at32_clock_init(void) | |||
1024 | for (i = 0; i < ARRAY_SIZE(at32_clock_list); i++) { | 1089 | for (i = 0; i < ARRAY_SIZE(at32_clock_list); i++) { |
1025 | struct clk *clk = at32_clock_list[i]; | 1090 | struct clk *clk = at32_clock_list[i]; |
1026 | 1091 | ||
1092 | if (clk->users == 0) | ||
1093 | continue; | ||
1094 | |||
1027 | if (clk->mode == &cpu_clk_mode) | 1095 | if (clk->mode == &cpu_clk_mode) |
1028 | cpu_mask |= 1 << clk->index; | 1096 | cpu_mask |= 1 << clk->index; |
1029 | else if (clk->mode == &hsb_clk_mode) | 1097 | else if (clk->mode == &hsb_clk_mode) |