[ARM] 5258/1: [AT91] PWM controller initialization
authorAndrew Victor <linux@maxim.org.za>
Thu, 18 Sep 2008 18:42:37 +0000 (19:42 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 21 Sep 2008 21:58:37 +0000 (22:58 +0100)
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>
arch/arm/mach-at91/at91cap9.c
arch/arm/mach-at91/at91cap9_devices.c
arch/arm/mach-at91/at91sam9263.c
arch/arm/mach-at91/at91sam9263_devices.c
arch/arm/mach-at91/at91sam9rl.c
arch/arm/mach-at91/at91sam9rl_devices.c
arch/arm/mach-at91/include/mach/board.h

index 638948c..0fc0ada 100644 (file)
@@ -141,8 +141,8 @@ static struct clk tcb_clk = {
        .pmc_mask       = 1 << AT91CAP9_ID_TCB,
        .type           = CLK_TYPE_PERIPHERAL,
 };
-static struct clk pwmc_clk = {
-       .name           = "pwmc_clk",
+static struct clk pwm_clk = {
+       .name           = "pwm_clk",
        .pmc_mask       = 1 << AT91CAP9_ID_PWMC,
        .type           = CLK_TYPE_PERIPHERAL,
 };
@@ -207,7 +207,7 @@ static struct clk *periph_clocks[] __initdata = {
        &ssc1_clk,
        &ac97_clk,
        &tcb_clk,
-       &pwmc_clk,
+       &pwm_clk,
        &macb_clk,
        &aestdes_clk,
        &adc_clk,
index abb4aac..5ebd427 100644 (file)
@@ -719,6 +719,60 @@ static void __init at91_add_device_watchdog(void) {}
 
 
 /* --------------------------------------------------------------------
+ *  PWM
+ * --------------------------------------------------------------------*/
+
+#if defined(CONFIG_ATMEL_PWM)
+static u32 pwm_mask;
+
+static struct resource pwm_resources[] = {
+       [0] = {
+               .start  = AT91CAP9_BASE_PWMC,
+               .end    = AT91CAP9_BASE_PWMC + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91CAP9_ID_PWMC,
+               .end    = AT91CAP9_ID_PWMC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91cap9_pwm0_device = {
+       .name   = "atmel_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data          = &pwm_mask,
+       },
+       .resource       = pwm_resources,
+       .num_resources  = ARRAY_SIZE(pwm_resources),
+};
+
+void __init at91_add_device_pwm(u32 mask)
+{
+       if (mask & (1 << AT91_PWM0))
+               at91_set_A_periph(AT91_PIN_PB19, 1);    /* enable PWM0 */
+
+       if (mask & (1 << AT91_PWM1))
+               at91_set_B_periph(AT91_PIN_PB8, 1);     /* enable PWM1 */
+
+       if (mask & (1 << AT91_PWM2))
+               at91_set_B_periph(AT91_PIN_PC29, 1);    /* enable PWM2 */
+
+       if (mask & (1 << AT91_PWM3))
+               at91_set_B_periph(AT91_PIN_PA11, 1);    /* enable PWM3 */
+
+       pwm_mask = mask;
+
+       platform_device_register(&at91cap9_pwm0_device);
+}
+#else
+void __init at91_add_device_pwm(u32 mask) {}
+#endif
+
+
+
+/* --------------------------------------------------------------------
  *  AC97
  * -------------------------------------------------------------------- */
 
index 80bfab5..ada4b67 100644 (file)
@@ -129,8 +129,8 @@ static struct clk tcb_clk = {
        .pmc_mask       = 1 << AT91SAM9263_ID_TCB,
        .type           = CLK_TYPE_PERIPHERAL,
 };
-static struct clk pwmc_clk = {
-       .name           = "pwmc_clk",
+static struct clk pwm_clk = {
+       .name           = "pwm_clk",
        .pmc_mask       = 1 << AT91SAM9263_ID_PWMC,
        .type           = CLK_TYPE_PERIPHERAL,
 };
@@ -187,7 +187,7 @@ static struct clk *periph_clocks[] __initdata = {
        &ssc1_clk,
        &ac97_clk,
        &tcb_clk,
-       &pwmc_clk,
+       &pwm_clk,
        &macb_clk,
        &twodge_clk,
        &udc_clk,
index c93992f..8b88408 100644 (file)
@@ -886,6 +886,59 @@ static void __init at91_add_device_watchdog(void) {}
 
 
 /* --------------------------------------------------------------------
+ *  PWM
+ * --------------------------------------------------------------------*/
+
+#if defined(CONFIG_ATMEL_PWM)
+static u32 pwm_mask;
+
+static struct resource pwm_resources[] = {
+       [0] = {
+               .start  = AT91SAM9263_BASE_PWMC,
+               .end    = AT91SAM9263_BASE_PWMC + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9263_ID_PWMC,
+               .end    = AT91SAM9263_ID_PWMC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9263_pwm0_device = {
+       .name   = "atmel_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data          = &pwm_mask,
+       },
+       .resource       = pwm_resources,
+       .num_resources  = ARRAY_SIZE(pwm_resources),
+};
+
+void __init at91_add_device_pwm(u32 mask)
+{
+       if (mask & (1 << AT91_PWM0))
+               at91_set_B_periph(AT91_PIN_PB7, 1);     /* enable PWM0 */
+
+       if (mask & (1 << AT91_PWM1))
+               at91_set_B_periph(AT91_PIN_PB8, 1);     /* enable PWM1 */
+
+       if (mask & (1 << AT91_PWM2))
+               at91_set_B_periph(AT91_PIN_PC29, 1);    /* enable PWM2 */
+
+       if (mask & (1 << AT91_PWM3))
+               at91_set_B_periph(AT91_PIN_PB29, 1);    /* enable PWM3 */
+
+       pwm_mask = mask;
+
+       platform_device_register(&at91sam9263_pwm0_device);
+}
+#else
+void __init at91_add_device_pwm(u32 mask) {}
+#endif
+
+
+/* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
index 556bddf..252e954 100644 (file)
@@ -131,8 +131,8 @@ static struct clk tc2_clk = {
        .pmc_mask       = 1 << AT91SAM9RL_ID_TC2,
        .type           = CLK_TYPE_PERIPHERAL,
 };
-static struct clk pwmc_clk = {
-       .name           = "pwmc_clk",
+static struct clk pwm_clk = {
+       .name           = "pwm_clk",
        .pmc_mask       = 1 << AT91SAM9RL_ID_PWMC,
        .type           = CLK_TYPE_PERIPHERAL,
 };
@@ -180,7 +180,7 @@ static struct clk *periph_clocks[] __initdata = {
        &tc0_clk,
        &tc1_clk,
        &tc2_clk,
-       &pwmc_clk,
+       &pwm_clk,
        &tsc_clk,
        &dma_clk,
        &udphs_clk,
index 6208863..3f9fed4 100644 (file)
@@ -592,6 +592,59 @@ static void __init at91_add_device_watchdog(void) {}
 
 
 /* --------------------------------------------------------------------
+ *  PWM
+ * --------------------------------------------------------------------*/
+
+#if defined(CONFIG_ATMEL_PWM)
+static u32 pwm_mask;
+
+static struct resource pwm_resources[] = {
+       [0] = {
+               .start  = AT91SAM9RL_BASE_PWMC,
+               .end    = AT91SAM9RL_BASE_PWMC + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9RL_ID_PWMC,
+               .end    = AT91SAM9RL_ID_PWMC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9rl_pwm0_device = {
+       .name   = "atmel_pwm",
+       .id     = -1,
+       .dev    = {
+               .platform_data          = &pwm_mask,
+       },
+       .resource       = pwm_resources,
+       .num_resources  = ARRAY_SIZE(pwm_resources),
+};
+
+void __init at91_add_device_pwm(u32 mask)
+{
+       if (mask & (1 << AT91_PWM0))
+               at91_set_B_periph(AT91_PIN_PB8, 1);     /* enable PWM0 */
+
+       if (mask & (1 << AT91_PWM1))
+               at91_set_B_periph(AT91_PIN_PB9, 1);     /* enable PWM1 */
+
+       if (mask & (1 << AT91_PWM2))
+               at91_set_B_periph(AT91_PIN_PD5, 1);     /* enable PWM2 */
+
+       if (mask & (1 << AT91_PWM3))
+               at91_set_B_periph(AT91_PIN_PD8, 1);     /* enable PWM3 */
+
+       pwm_mask = mask;
+
+       platform_device_register(&at91sam9rl_pwm0_device);
+}
+#else
+void __init at91_add_device_pwm(u32 mask) {}
+#endif
+
+
+/* --------------------------------------------------------------------
  *  SSC -- Synchronous Serial Controller
  * -------------------------------------------------------------------- */
 
index acd60f2..9df4608 100644 (file)
@@ -133,6 +133,16 @@ struct atmel_uart_data {
 extern void __init at91_add_device_serial(void);
 
 /*
+ * PWM
+ */
+#define AT91_PWM0      0
+#define AT91_PWM1      1
+#define AT91_PWM2      2
+#define AT91_PWM3      3
+
+extern void __init at91_add_device_pwm(u32 mask);
+
+/*
  * SSC -- accessed through ssc_request(id).  Drivers don't bind to SSC
  * platform devices.  Their SSC ID is part of their configuration data,
  * along with information about which SSC signals they should use.