diff options
author | Andrew Victor <linux@maxim.org.za> | 2008-09-18 14:42:37 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-09-21 17:58:37 -0400 |
commit | bb1ad68b96a68e577a87ad62fe1aa26d052a52b5 (patch) | |
tree | a98d65d54a4f441329f83988ffb9bea16e7d396e /arch/arm/mach-at91 | |
parent | e505240b6a6fd47b84cfeb1272ffeacd3e0874b3 (diff) |
[ARM] 5258/1: [AT91] PWM controller initialization
Add platform_devices and configuration of the PWM controller found on
Atmel AT91CAP9, SAM9263 and SAM9RL processors.
SAM9263 support by Sedji Gaouaou.
Signed-off-by: Andrew Victor <linux@maxim.org.za>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r-- | arch/arm/mach-at91/at91cap9.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91cap9_devices.c | 54 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9263.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9263_devices.c | 53 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9rl.c | 6 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9rl_devices.c | 53 | ||||
-rw-r--r-- | arch/arm/mach-at91/include/mach/board.h | 10 |
7 files changed, 179 insertions, 9 deletions
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c index 638948c16770..0fc0adaebd58 100644 --- a/arch/arm/mach-at91/at91cap9.c +++ b/arch/arm/mach-at91/at91cap9.c | |||
@@ -141,8 +141,8 @@ static struct clk tcb_clk = { | |||
141 | .pmc_mask = 1 << AT91CAP9_ID_TCB, | 141 | .pmc_mask = 1 << AT91CAP9_ID_TCB, |
142 | .type = CLK_TYPE_PERIPHERAL, | 142 | .type = CLK_TYPE_PERIPHERAL, |
143 | }; | 143 | }; |
144 | static struct clk pwmc_clk = { | 144 | static struct clk pwm_clk = { |
145 | .name = "pwmc_clk", | 145 | .name = "pwm_clk", |
146 | .pmc_mask = 1 << AT91CAP9_ID_PWMC, | 146 | .pmc_mask = 1 << AT91CAP9_ID_PWMC, |
147 | .type = CLK_TYPE_PERIPHERAL, | 147 | .type = CLK_TYPE_PERIPHERAL, |
148 | }; | 148 | }; |
@@ -207,7 +207,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
207 | &ssc1_clk, | 207 | &ssc1_clk, |
208 | &ac97_clk, | 208 | &ac97_clk, |
209 | &tcb_clk, | 209 | &tcb_clk, |
210 | &pwmc_clk, | 210 | &pwm_clk, |
211 | &macb_clk, | 211 | &macb_clk, |
212 | &aestdes_clk, | 212 | &aestdes_clk, |
213 | &adc_clk, | 213 | &adc_clk, |
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c index abb4aac8fa98..5ebd4273d353 100644 --- a/arch/arm/mach-at91/at91cap9_devices.c +++ b/arch/arm/mach-at91/at91cap9_devices.c | |||
@@ -719,6 +719,60 @@ static void __init at91_add_device_watchdog(void) {} | |||
719 | 719 | ||
720 | 720 | ||
721 | /* -------------------------------------------------------------------- | 721 | /* -------------------------------------------------------------------- |
722 | * PWM | ||
723 | * --------------------------------------------------------------------*/ | ||
724 | |||
725 | #if defined(CONFIG_ATMEL_PWM) | ||
726 | static u32 pwm_mask; | ||
727 | |||
728 | static struct resource pwm_resources[] = { | ||
729 | [0] = { | ||
730 | .start = AT91CAP9_BASE_PWMC, | ||
731 | .end = AT91CAP9_BASE_PWMC + SZ_16K - 1, | ||
732 | .flags = IORESOURCE_MEM, | ||
733 | }, | ||
734 | [1] = { | ||
735 | .start = AT91CAP9_ID_PWMC, | ||
736 | .end = AT91CAP9_ID_PWMC, | ||
737 | .flags = IORESOURCE_IRQ, | ||
738 | }, | ||
739 | }; | ||
740 | |||
741 | static struct platform_device at91cap9_pwm0_device = { | ||
742 | .name = "atmel_pwm", | ||
743 | .id = -1, | ||
744 | .dev = { | ||
745 | .platform_data = &pwm_mask, | ||
746 | }, | ||
747 | .resource = pwm_resources, | ||
748 | .num_resources = ARRAY_SIZE(pwm_resources), | ||
749 | }; | ||
750 | |||
751 | void __init at91_add_device_pwm(u32 mask) | ||
752 | { | ||
753 | if (mask & (1 << AT91_PWM0)) | ||
754 | at91_set_A_periph(AT91_PIN_PB19, 1); /* enable PWM0 */ | ||
755 | |||
756 | if (mask & (1 << AT91_PWM1)) | ||
757 | at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */ | ||
758 | |||
759 | if (mask & (1 << AT91_PWM2)) | ||
760 | at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */ | ||
761 | |||
762 | if (mask & (1 << AT91_PWM3)) | ||
763 | at91_set_B_periph(AT91_PIN_PA11, 1); /* enable PWM3 */ | ||
764 | |||
765 | pwm_mask = mask; | ||
766 | |||
767 | platform_device_register(&at91cap9_pwm0_device); | ||
768 | } | ||
769 | #else | ||
770 | void __init at91_add_device_pwm(u32 mask) {} | ||
771 | #endif | ||
772 | |||
773 | |||
774 | |||
775 | /* -------------------------------------------------------------------- | ||
722 | * AC97 | 776 | * AC97 |
723 | * -------------------------------------------------------------------- */ | 777 | * -------------------------------------------------------------------- */ |
724 | 778 | ||
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c index 80bfab5680e2..ada4b6769107 100644 --- a/arch/arm/mach-at91/at91sam9263.c +++ b/arch/arm/mach-at91/at91sam9263.c | |||
@@ -129,8 +129,8 @@ static struct clk tcb_clk = { | |||
129 | .pmc_mask = 1 << AT91SAM9263_ID_TCB, | 129 | .pmc_mask = 1 << AT91SAM9263_ID_TCB, |
130 | .type = CLK_TYPE_PERIPHERAL, | 130 | .type = CLK_TYPE_PERIPHERAL, |
131 | }; | 131 | }; |
132 | static struct clk pwmc_clk = { | 132 | static struct clk pwm_clk = { |
133 | .name = "pwmc_clk", | 133 | .name = "pwm_clk", |
134 | .pmc_mask = 1 << AT91SAM9263_ID_PWMC, | 134 | .pmc_mask = 1 << AT91SAM9263_ID_PWMC, |
135 | .type = CLK_TYPE_PERIPHERAL, | 135 | .type = CLK_TYPE_PERIPHERAL, |
136 | }; | 136 | }; |
@@ -187,7 +187,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
187 | &ssc1_clk, | 187 | &ssc1_clk, |
188 | &ac97_clk, | 188 | &ac97_clk, |
189 | &tcb_clk, | 189 | &tcb_clk, |
190 | &pwmc_clk, | 190 | &pwm_clk, |
191 | &macb_clk, | 191 | &macb_clk, |
192 | &twodge_clk, | 192 | &twodge_clk, |
193 | &udc_clk, | 193 | &udc_clk, |
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index c93992f55dc9..8b884083f76d 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -886,6 +886,59 @@ static void __init at91_add_device_watchdog(void) {} | |||
886 | 886 | ||
887 | 887 | ||
888 | /* -------------------------------------------------------------------- | 888 | /* -------------------------------------------------------------------- |
889 | * PWM | ||
890 | * --------------------------------------------------------------------*/ | ||
891 | |||
892 | #if defined(CONFIG_ATMEL_PWM) | ||
893 | static u32 pwm_mask; | ||
894 | |||
895 | static struct resource pwm_resources[] = { | ||
896 | [0] = { | ||
897 | .start = AT91SAM9263_BASE_PWMC, | ||
898 | .end = AT91SAM9263_BASE_PWMC + SZ_16K - 1, | ||
899 | .flags = IORESOURCE_MEM, | ||
900 | }, | ||
901 | [1] = { | ||
902 | .start = AT91SAM9263_ID_PWMC, | ||
903 | .end = AT91SAM9263_ID_PWMC, | ||
904 | .flags = IORESOURCE_IRQ, | ||
905 | }, | ||
906 | }; | ||
907 | |||
908 | static struct platform_device at91sam9263_pwm0_device = { | ||
909 | .name = "atmel_pwm", | ||
910 | .id = -1, | ||
911 | .dev = { | ||
912 | .platform_data = &pwm_mask, | ||
913 | }, | ||
914 | .resource = pwm_resources, | ||
915 | .num_resources = ARRAY_SIZE(pwm_resources), | ||
916 | }; | ||
917 | |||
918 | void __init at91_add_device_pwm(u32 mask) | ||
919 | { | ||
920 | if (mask & (1 << AT91_PWM0)) | ||
921 | at91_set_B_periph(AT91_PIN_PB7, 1); /* enable PWM0 */ | ||
922 | |||
923 | if (mask & (1 << AT91_PWM1)) | ||
924 | at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */ | ||
925 | |||
926 | if (mask & (1 << AT91_PWM2)) | ||
927 | at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */ | ||
928 | |||
929 | if (mask & (1 << AT91_PWM3)) | ||
930 | at91_set_B_periph(AT91_PIN_PB29, 1); /* enable PWM3 */ | ||
931 | |||
932 | pwm_mask = mask; | ||
933 | |||
934 | platform_device_register(&at91sam9263_pwm0_device); | ||
935 | } | ||
936 | #else | ||
937 | void __init at91_add_device_pwm(u32 mask) {} | ||
938 | #endif | ||
939 | |||
940 | |||
941 | /* -------------------------------------------------------------------- | ||
889 | * SSC -- Synchronous Serial Controller | 942 | * SSC -- Synchronous Serial Controller |
890 | * -------------------------------------------------------------------- */ | 943 | * -------------------------------------------------------------------- */ |
891 | 944 | ||
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c index 556bddf35b45..252e954b49fd 100644 --- a/arch/arm/mach-at91/at91sam9rl.c +++ b/arch/arm/mach-at91/at91sam9rl.c | |||
@@ -131,8 +131,8 @@ static struct clk tc2_clk = { | |||
131 | .pmc_mask = 1 << AT91SAM9RL_ID_TC2, | 131 | .pmc_mask = 1 << AT91SAM9RL_ID_TC2, |
132 | .type = CLK_TYPE_PERIPHERAL, | 132 | .type = CLK_TYPE_PERIPHERAL, |
133 | }; | 133 | }; |
134 | static struct clk pwmc_clk = { | 134 | static struct clk pwm_clk = { |
135 | .name = "pwmc_clk", | 135 | .name = "pwm_clk", |
136 | .pmc_mask = 1 << AT91SAM9RL_ID_PWMC, | 136 | .pmc_mask = 1 << AT91SAM9RL_ID_PWMC, |
137 | .type = CLK_TYPE_PERIPHERAL, | 137 | .type = CLK_TYPE_PERIPHERAL, |
138 | }; | 138 | }; |
@@ -180,7 +180,7 @@ static struct clk *periph_clocks[] __initdata = { | |||
180 | &tc0_clk, | 180 | &tc0_clk, |
181 | &tc1_clk, | 181 | &tc1_clk, |
182 | &tc2_clk, | 182 | &tc2_clk, |
183 | &pwmc_clk, | 183 | &pwm_clk, |
184 | &tsc_clk, | 184 | &tsc_clk, |
185 | &dma_clk, | 185 | &dma_clk, |
186 | &udphs_clk, | 186 | &udphs_clk, |
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index 620886341fb5..3f9fed4902b8 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c | |||
@@ -592,6 +592,59 @@ static void __init at91_add_device_watchdog(void) {} | |||
592 | 592 | ||
593 | 593 | ||
594 | /* -------------------------------------------------------------------- | 594 | /* -------------------------------------------------------------------- |
595 | * PWM | ||
596 | * --------------------------------------------------------------------*/ | ||
597 | |||
598 | #if defined(CONFIG_ATMEL_PWM) | ||
599 | static u32 pwm_mask; | ||
600 | |||
601 | static struct resource pwm_resources[] = { | ||
602 | [0] = { | ||
603 | .start = AT91SAM9RL_BASE_PWMC, | ||
604 | .end = AT91SAM9RL_BASE_PWMC + SZ_16K - 1, | ||
605 | .flags = IORESOURCE_MEM, | ||
606 | }, | ||
607 | [1] = { | ||
608 | .start = AT91SAM9RL_ID_PWMC, | ||
609 | .end = AT91SAM9RL_ID_PWMC, | ||
610 | .flags = IORESOURCE_IRQ, | ||
611 | }, | ||
612 | }; | ||
613 | |||
614 | static struct platform_device at91sam9rl_pwm0_device = { | ||
615 | .name = "atmel_pwm", | ||
616 | .id = -1, | ||
617 | .dev = { | ||
618 | .platform_data = &pwm_mask, | ||
619 | }, | ||
620 | .resource = pwm_resources, | ||
621 | .num_resources = ARRAY_SIZE(pwm_resources), | ||
622 | }; | ||
623 | |||
624 | void __init at91_add_device_pwm(u32 mask) | ||
625 | { | ||
626 | if (mask & (1 << AT91_PWM0)) | ||
627 | at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM0 */ | ||
628 | |||
629 | if (mask & (1 << AT91_PWM1)) | ||
630 | at91_set_B_periph(AT91_PIN_PB9, 1); /* enable PWM1 */ | ||
631 | |||
632 | if (mask & (1 << AT91_PWM2)) | ||
633 | at91_set_B_periph(AT91_PIN_PD5, 1); /* enable PWM2 */ | ||
634 | |||
635 | if (mask & (1 << AT91_PWM3)) | ||
636 | at91_set_B_periph(AT91_PIN_PD8, 1); /* enable PWM3 */ | ||
637 | |||
638 | pwm_mask = mask; | ||
639 | |||
640 | platform_device_register(&at91sam9rl_pwm0_device); | ||
641 | } | ||
642 | #else | ||
643 | void __init at91_add_device_pwm(u32 mask) {} | ||
644 | #endif | ||
645 | |||
646 | |||
647 | /* -------------------------------------------------------------------- | ||
595 | * SSC -- Synchronous Serial Controller | 648 | * SSC -- Synchronous Serial Controller |
596 | * -------------------------------------------------------------------- */ | 649 | * -------------------------------------------------------------------- */ |
597 | 650 | ||
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h index acd60f2a0724..9df4608b5f6a 100644 --- a/arch/arm/mach-at91/include/mach/board.h +++ b/arch/arm/mach-at91/include/mach/board.h | |||
@@ -133,6 +133,16 @@ struct atmel_uart_data { | |||
133 | extern void __init at91_add_device_serial(void); | 133 | extern void __init at91_add_device_serial(void); |
134 | 134 | ||
135 | /* | 135 | /* |
136 | * PWM | ||
137 | */ | ||
138 | #define AT91_PWM0 0 | ||
139 | #define AT91_PWM1 1 | ||
140 | #define AT91_PWM2 2 | ||
141 | #define AT91_PWM3 3 | ||
142 | |||
143 | extern void __init at91_add_device_pwm(u32 mask); | ||
144 | |||
145 | /* | ||
136 | * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC | 146 | * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC |
137 | * platform devices. Their SSC ID is part of their configuration data, | 147 | * platform devices. Their SSC ID is part of their configuration data, |
138 | * along with information about which SSC signals they should use. | 148 | * along with information about which SSC signals they should use. |