]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - arch/arm/mach-at91/at91sam9260_devices.c
Atmel: move console default platform_device to serial driver
[mv-sheeva.git] / arch / arm / mach-at91 / at91sam9260_devices.c
index 629fa977497239f171d66ef47563c3da9d2b0127..df487ce83c5efc6537d8f218e5ba59f971ec8420 100644 (file)
@@ -21,6 +21,7 @@
 #include <mach/cpu.h>
 #include <mach/at91sam9260.h>
 #include <mach/at91sam9260_matrix.h>
+#include <mach/at91_matrix.h>
 #include <mach/at91sam9_smc.h>
 
 #include "generic.h"
@@ -115,7 +116,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
        if (!data)
                return;
 
-       if (data->vbus_pin) {
+       if (gpio_is_valid(data->vbus_pin)) {
                at91_set_gpio_input(data->vbus_pin, 0);
                at91_set_deglitch(data->vbus_pin, 1);
        }
@@ -136,7 +137,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
 
 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
 static u64 eth_dmamask = DMA_BIT_MASK(32);
-static struct at91_eth_data eth_data;
+static struct macb_platform_data eth_data;
 
 static struct resource eth_resources[] = {
        [0] = {
@@ -163,12 +164,12 @@ static struct platform_device at91sam9260_eth_device = {
        .num_resources  = ARRAY_SIZE(eth_resources),
 };
 
-void __init at91_add_device_eth(struct at91_eth_data *data)
+void __init at91_add_device_eth(struct macb_platform_data *data)
 {
        if (!data)
                return;
 
-       if (data->phy_irq_pin) {
+       if (gpio_is_valid(data->phy_irq_pin)) {
                at91_set_gpio_input(data->phy_irq_pin, 0);
                at91_set_deglitch(data->phy_irq_pin, 1);
        }
@@ -200,7 +201,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data)
        platform_device_register(&at91sam9260_eth_device);
 }
 #else
-void __init at91_add_device_eth(struct at91_eth_data *data) {}
+void __init at91_add_device_eth(struct macb_platform_data *data) {}
 #endif
 
 
@@ -243,13 +244,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 */
@@ -330,11 +331,11 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
        for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
                if (data->slot[i].bus_width) {
                        /* input/irq */
-                       if (data->slot[i].detect_pin) {
+                       if (gpio_is_valid(data->slot[i].detect_pin)) {
                                at91_set_gpio_input(data->slot[i].detect_pin, 1);
                                at91_set_deglitch(data->slot[i].detect_pin, 1);
                        }
-                       if (data->slot[i].wp_pin)
+                       if (gpio_is_valid(data->slot[i].wp_pin))
                                at91_set_gpio_input(data->slot[i].wp_pin, 1);
 
                        switch (i) {
@@ -399,8 +400,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  = AT91SAM9260_BASE_ECC,
+               .end    = AT91SAM9260_BASE_ECC + SZ_512 - 1,
                .flags  = IORESOURCE_MEM,
        }
 };
@@ -422,19 +423,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);
 
        nand_data = *data;
@@ -714,21 +715,45 @@ static void __init at91_add_device_tc(void) { }
 
 static struct resource rtt_resources[] = {
        {
-               .start  = AT91_BASE_SYS + AT91_RTT,
-               .end    = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
+               .start  = AT91SAM9260_BASE_RTT,
+               .end    = AT91SAM9260_BASE_RTT + SZ_16 - 1,
                .flags  = IORESOURCE_MEM,
-       }
+       }, {
+               .flags  = IORESOURCE_MEM,
+       },
 };
 
 static struct platform_device at91sam9260_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)
+{
+       at91sam9260_rtt_device.name = "rtc-at91sam9";
+       /*
+        * The second resource is needed:
+        * GPBR will serve as the storage for RTC time offset
+        */
+       at91sam9260_rtt_device.num_resources = 2;
+       rtt_resources[1].start = AT91SAM9260_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 */
+       at91sam9260_rtt_device.num_resources = 1;
+}
+#endif
+
 static void __init at91_add_device_rtt(void)
 {
+       at91_add_device_rtt_rtc();
        platform_device_register(&at91sam9260_rtt_device);
 }
 
@@ -738,10 +763,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  = AT91SAM9260_BASE_WDT,
+               .end    = AT91SAM9260_BASE_WDT + SZ_16 - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
 static struct platform_device at91sam9260_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)
@@ -837,8 +871,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  = AT91SAM9260_BASE_DBGU,
+               .end    = AT91SAM9260_BASE_DBGU + SZ_512 - 1,
                .flags  = IORESOURCE_MEM,
        },
        [1] = {
@@ -1130,7 +1164,6 @@ static inline void configure_usart5_pins(void)
 }
 
 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)
 {
@@ -1256,7 +1289,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
        if (!data)
                return;
 
-       csa = at91_sys_read(AT91_MATRIX_EBICSA);
+       csa = at91_matrix_read(AT91_MATRIX_EBICSA);
 
        switch (data->chipselect) {
        case 4:
@@ -1279,19 +1312,19 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
                return;
        }
 
-       at91_sys_write(AT91_MATRIX_EBICSA, csa);
+       at91_matrix_write(AT91_MATRIX_EBICSA, csa);
 
-       if (data->rst_pin) {
+       if (gpio_is_valid(data->rst_pin)) {
                at91_set_multi_drive(data->rst_pin, 0);
                at91_set_gpio_output(data->rst_pin, 1);
        }
 
-       if (data->irq_pin) {
+       if (gpio_is_valid(data->irq_pin)) {
                at91_set_gpio_input(data->irq_pin, 0);
                at91_set_deglitch(data->irq_pin, 1);
        }
 
-       if (data->det_pin) {
+       if (gpio_is_valid(data->det_pin)) {
                at91_set_gpio_input(data->det_pin, 0);
                at91_set_deglitch(data->det_pin, 1);
        }