]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/arm/mach-at91/at91sam9rl_devices.c
Atmel: move console default platform_device to serial driver
[mv-sheeva.git] / arch / arm / mach-at91 / at91sam9rl_devices.c
index 628eb566d60ce2e5b7620e903417b010aede16fd..eda72e83037dc7dd176c859e7f4ad874a9506a75 100644 (file)
@@ -20,6 +20,7 @@
 #include <mach/board.h>
 #include <mach/at91sam9rl.h>
 #include <mach/at91sam9rl_matrix.h>
+#include <mach/at91_matrix.h>
 #include <mach/at91sam9_smc.h>
 #include <mach/at_hdmac.h>
 
 #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
 static u64 hdmac_dmamask = DMA_BIT_MASK(32);
 
-static struct at_dma_platform_data atdma_pdata = {
-       .nr_channels    = 2,
-};
-
 static struct resource hdmac_resources[] = {
        [0] = {
-               .start  = AT91_BASE_SYS + AT91_DMA,
-               .end    = AT91_BASE_SYS + AT91_DMA + SZ_512 - 1,
+               .start  = AT91SAM9RL_BASE_DMA,
+               .end    = AT91SAM9RL_BASE_DMA + SZ_512 - 1,
                .flags  = IORESOURCE_MEM,
        },
        [2] = {
@@ -51,12 +48,11 @@ static struct resource hdmac_resources[] = {
 };
 
 static struct platform_device at_hdmac_device = {
-       .name           = "at_hdmac",
+       .name           = "at91sam9rl_dma",
        .id             = -1,
        .dev            = {
                                .dma_mask               = &hdmac_dmamask,
                                .coherent_dma_mask      = DMA_BIT_MASK(32),
-                               .platform_data          = &atdma_pdata,
        },
        .resource       = hdmac_resources,
        .num_resources  = ARRAY_SIZE(hdmac_resources),
@@ -64,7 +60,6 @@ static struct platform_device at_hdmac_device = {
 
 void __init at91_add_device_hdmac(void)
 {
-       dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);
        platform_device_register(&at_hdmac_device);
 }
 #else
@@ -147,7 +142,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data)
        usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
        memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
 
-       if (data && data->vbus_pin > 0) {
+       if (data && gpio_is_valid(data->vbus_pin)) {
                at91_set_gpio_input(data->vbus_pin, 0);
                at91_set_deglitch(data->vbus_pin, 1);
                usba_udc_data.pdata.vbus_pin = data->vbus_pin;
@@ -201,13 +196,13 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
                return;
 
        /* input/irq */
-       if (data->det_pin) {
+       if (gpio_is_valid(data->det_pin)) {
                at91_set_gpio_input(data->det_pin, 1);
                at91_set_deglitch(data->det_pin, 1);
        }
-       if (data->wp_pin)
+       if (gpio_is_valid(data->wp_pin))
                at91_set_gpio_input(data->wp_pin, 1);
-       if (data->vcc_pin)
+       if (gpio_is_valid(data->vcc_pin))
                at91_set_gpio_output(data->vcc_pin, 0);
 
        /* CLK */
@@ -248,8 +243,8 @@ static struct resource nand_resources[] = {
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
-               .start  = AT91_BASE_SYS + AT91_ECC,
-               .end    = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
+               .start  = AT91SAM9RL_BASE_ECC,
+               .end    = AT91SAM9RL_BASE_ECC + SZ_512 - 1,
                .flags  = IORESOURCE_MEM,
        }
 };
@@ -271,19 +266,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
        if (!data)
                return;
 
-       csa = at91_sys_read(AT91_MATRIX_EBICSA);
-       at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
+       csa = at91_matrix_read(AT91_MATRIX_EBICSA);
+       at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
 
        /* enable pin */
-       if (data->enable_pin)
+       if (gpio_is_valid(data->enable_pin))
                at91_set_gpio_output(data->enable_pin, 1);
 
        /* ready/busy pin */
-       if (data->rdy_pin)
+       if (gpio_is_valid(data->rdy_pin))
                at91_set_gpio_input(data->rdy_pin, 1);
 
        /* card detect pin */
-       if (data->det_pin)
+       if (gpio_is_valid(data->det_pin))
                at91_set_gpio_input(data->det_pin, 1);
 
        at91_set_A_periph(AT91_PIN_PB4, 0);             /* NANDOE */
@@ -483,7 +478,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
        at91_set_A_periph(AT91_PIN_PD4, 0);     /* AC97RX */
 
        /* reset */
-       if (data->reset_pin)
+       if (gpio_is_valid(data->reset_pin))
                at91_set_gpio_output(data->reset_pin, 0);
 
        ac97_data = *data;
@@ -685,8 +680,10 @@ static void __init at91_add_device_rtc(void) {}
 
 static struct resource rtt_resources[] = {
        {
-               .start  = AT91_BASE_SYS + AT91_RTT,
-               .end    = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
+               .start  = AT91SAM9RL_BASE_RTT,
+               .end    = AT91SAM9RL_BASE_RTT + SZ_16 - 1,
+               .flags  = IORESOURCE_MEM,
+       }, {
                .flags  = IORESOURCE_MEM,
        }
 };
@@ -695,11 +692,32 @@ static struct platform_device at91sam9rl_rtt_device = {
        .name           = "at91_rtt",
        .id             = 0,
        .resource       = rtt_resources,
-       .num_resources  = ARRAY_SIZE(rtt_resources),
 };
 
+#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
+static void __init at91_add_device_rtt_rtc(void)
+{
+       at91sam9rl_rtt_device.name = "rtc-at91sam9";
+       /*
+        * The second resource is needed:
+        * GPBR will serve as the storage for RTC time offset
+        */
+       at91sam9rl_rtt_device.num_resources = 2;
+       rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
+                                4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
+       rtt_resources[1].end = rtt_resources[1].start + 3;
+}
+#else
+static void __init at91_add_device_rtt_rtc(void)
+{
+       /* Only one resource is needed: RTT not used as RTC */
+       at91sam9rl_rtt_device.num_resources = 1;
+}
+#endif
+
 static void __init at91_add_device_rtt(void)
 {
+       at91_add_device_rtt_rtc();
        platform_device_register(&at91sam9rl_rtt_device);
 }
 
@@ -709,10 +727,19 @@ static void __init at91_add_device_rtt(void)
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
+static struct resource wdt_resources[] = {
+       {
+               .start  = AT91SAM9RL_BASE_WDT,
+               .end    = AT91SAM9RL_BASE_WDT + SZ_16 - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
 static struct platform_device at91sam9rl_wdt_device = {
        .name           = "at91_wdt",
        .id             = -1,
-       .num_resources  = 0,
+       .resource       = wdt_resources,
+       .num_resources  = ARRAY_SIZE(wdt_resources),
 };
 
 static void __init at91_add_device_watchdog(void)
@@ -908,8 +935,8 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
 #if defined(CONFIG_SERIAL_ATMEL)
 static struct resource dbgu_resources[] = {
        [0] = {
-               .start  = AT91_BASE_SYS + AT91_DBGU,
-               .end    = AT91_BASE_SYS + AT91_DBGU + SZ_512 - 1,
+               .start  = AT91SAM9RL_BASE_DBGU,
+               .end    = AT91SAM9RL_BASE_DBGU + SZ_512 - 1,
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
@@ -1125,7 +1152,6 @@ static inline void configure_usart3_pins(unsigned pins)
 }
 
 static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART];  /* the UARTs to use */
-struct platform_device *atmel_default_console_device;  /* the serial console device */
 
 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
 {