]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-at91/at91sam9263_devices.c
[ARM] 4753/1: [AT91] Use DMA_BIT_MASK
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91 / at91sam9263_devices.c
index f924bd5017de19ef1efac43b5dc125fdcc65ee13..9bdcf45defcf3841e0b3cae8dc36f2b050a983ec 100644 (file)
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 
+#include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
+#include <linux/i2c-gpio.h>
 
+#include <linux/fb.h>
 #include <video/atmel_lcdc.h>
 
 #include <asm/arch/board.h>
@@ -30,7 +33,7 @@
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
-static u64 ohci_dmamask = 0xffffffffUL;
+static u64 ohci_dmamask = DMA_BIT_MASK(32);
 static struct at91_usbh_data usbh_data;
 
 static struct resource usbh_resources[] = {
@@ -51,7 +54,7 @@ static struct platform_device at91_usbh_device = {
        .id             = -1,
        .dev            = {
                                .dma_mask               = &ohci_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &usbh_data,
        },
        .resource       = usbh_resources,
@@ -134,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 = 0xffffffffUL;
+static u64 eth_dmamask = DMA_BIT_MASK(32);
 static struct at91_eth_data eth_data;
 
 static struct resource eth_resources[] = {
@@ -155,7 +158,7 @@ static struct platform_device at91sam9263_eth_device = {
        .id             = -1,
        .dev            = {
                                .dma_mask               = &eth_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &eth_data,
        },
        .resource       = eth_resources,
@@ -208,7 +211,7 @@ void __init at91_add_device_eth(struct at91_eth_data *data) {}
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
-static u64 mmc_dmamask = 0xffffffffUL;
+static u64 mmc_dmamask = DMA_BIT_MASK(32);
 static struct at91_mmc_data mmc0_data, mmc1_data;
 
 static struct resource mmc0_resources[] = {
@@ -229,7 +232,7 @@ static struct platform_device at91sam9263_mmc0_device = {
        .id             = 0,
        .dev            = {
                                .dma_mask               = &mmc_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &mmc0_data,
        },
        .resource       = mmc0_resources,
@@ -254,7 +257,7 @@ static struct platform_device at91sam9263_mmc1_device = {
        .id             = 1,
        .dev            = {
                                .dma_mask               = &mmc_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &mmc1_data,
        },
        .resource       = mmc1_resources,
@@ -421,7 +424,40 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {}
  *  TWI (i2c)
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
+/*
+ * Prefer the GPIO code since the TWI controller isn't robust
+ * (gets overruns and underruns under load) and can only issue
+ * repeated STARTs in one scenario (the driver doesn't yet handle them).
+ */
+#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
+
+static struct i2c_gpio_platform_data pdata = {
+       .sda_pin                = AT91_PIN_PB4,
+       .sda_is_open_drain      = 1,
+       .scl_pin                = AT91_PIN_PB5,
+       .scl_is_open_drain      = 1,
+       .udelay                 = 2,            /* ~100 kHz */
+};
+
+static struct platform_device at91sam9263_twi_device = {
+       .name                   = "i2c-gpio",
+       .id                     = -1,
+       .dev.platform_data      = &pdata,
+};
+
+void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
+{
+       at91_set_GPIO_periph(AT91_PIN_PB4, 1);          /* TWD (SDA) */
+       at91_set_multi_drive(AT91_PIN_PB4, 1);
+
+       at91_set_GPIO_periph(AT91_PIN_PB5, 1);          /* TWCK (SCL) */
+       at91_set_multi_drive(AT91_PIN_PB5, 1);
+
+       i2c_register_board_info(0, devices, nr_devices);
+       platform_device_register(&at91sam9263_twi_device);
+}
+
+#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
 
 static struct resource twi_resources[] = {
        [0] = {
@@ -443,7 +479,7 @@ static struct platform_device at91sam9263_twi_device = {
        .num_resources  = ARRAY_SIZE(twi_resources),
 };
 
-void __init at91_add_device_i2c(void)
+void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
 {
        /* pins used for TWI interface */
        at91_set_A_periph(AT91_PIN_PB4, 0);             /* TWD */
@@ -452,10 +488,11 @@ void __init at91_add_device_i2c(void)
        at91_set_A_periph(AT91_PIN_PB5, 0);             /* TWCK */
        at91_set_multi_drive(AT91_PIN_PB5, 1);
 
+       i2c_register_board_info(0, devices, nr_devices);
        platform_device_register(&at91sam9263_twi_device);
 }
 #else
-void __init at91_add_device_i2c(void) {}
+void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
 #endif
 
 
@@ -464,7 +501,7 @@ void __init at91_add_device_i2c(void) {}
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
-static u64 spi_dmamask = 0xffffffffUL;
+static u64 spi_dmamask = DMA_BIT_MASK(32);
 
 static struct resource spi0_resources[] = {
        [0] = {
@@ -484,7 +521,7 @@ static struct platform_device at91sam9263_spi0_device = {
        .id             = 0,
        .dev            = {
                                .dma_mask               = &spi_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
        },
        .resource       = spi0_resources,
        .num_resources  = ARRAY_SIZE(spi0_resources),
@@ -510,7 +547,7 @@ static struct platform_device at91sam9263_spi1_device = {
        .id             = 1,
        .dev            = {
                                .dma_mask               = &spi_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
        },
        .resource       = spi1_resources,
        .num_resources  = ARRAY_SIZE(spi1_resources),
@@ -576,7 +613,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
-static u64 ac97_dmamask = 0xffffffffUL;
+static u64 ac97_dmamask = DMA_BIT_MASK(32);
 static struct atmel_ac97_data ac97_data;
 
 static struct resource ac97_resources[] = {
@@ -597,7 +634,7 @@ static struct platform_device at91sam9263_ac97_device = {
        .id             = 1,
        .dev            = {
                                .dma_mask               = &ac97_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &ac97_data,
        },
        .resource       = ac97_resources,
@@ -631,7 +668,7 @@ void __init at91_add_device_ac97(struct atmel_ac97_data *data) {}
  * -------------------------------------------------------------------- */
 
 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
-static u64 lcdc_dmamask = 0xffffffffUL;
+static u64 lcdc_dmamask = DMA_BIT_MASK(32);
 static struct atmel_lcdfb_info lcdc_data;
 
 static struct resource lcdc_resources[] = {
@@ -652,7 +689,7 @@ static struct platform_device at91_lcdc_device = {
        .id             = 0,
        .dev            = {
                                .dma_mask               = &lcdc_dmamask,
-                               .coherent_dma_mask      = 0xffffffff,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
                                .platform_data          = &lcdc_data,
        },
        .resource       = lcdc_resources,
@@ -695,6 +732,117 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
 #endif
 
 
+/* --------------------------------------------------------------------
+ *  Image Sensor Interface
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
+
+struct resource isi_resources[] = {
+       [0] = {
+               .start  = AT91SAM9263_BASE_ISI,
+               .end    = AT91SAM9263_BASE_ISI + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9263_ID_ISI,
+               .end    = AT91SAM9263_ID_ISI,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9263_isi_device = {
+       .name           = "at91_isi",
+       .id             = -1,
+       .resource       = isi_resources,
+       .num_resources  = ARRAY_SIZE(isi_resources),
+};
+
+void __init at91_add_device_isi(void)
+{
+       at91_set_A_periph(AT91_PIN_PE0, 0);     /* ISI_D0 */
+       at91_set_A_periph(AT91_PIN_PE1, 0);     /* ISI_D1 */
+       at91_set_A_periph(AT91_PIN_PE2, 0);     /* ISI_D2 */
+       at91_set_A_periph(AT91_PIN_PE3, 0);     /* ISI_D3 */
+       at91_set_A_periph(AT91_PIN_PE4, 0);     /* ISI_D4 */
+       at91_set_A_periph(AT91_PIN_PE5, 0);     /* ISI_D5 */
+       at91_set_A_periph(AT91_PIN_PE6, 0);     /* ISI_D6 */
+       at91_set_A_periph(AT91_PIN_PE7, 0);     /* ISI_D7 */
+       at91_set_A_periph(AT91_PIN_PE8, 0);     /* ISI_PCK */
+       at91_set_A_periph(AT91_PIN_PE9, 0);     /* ISI_HSYNC */
+       at91_set_A_periph(AT91_PIN_PE10, 0);    /* ISI_VSYNC */
+       at91_set_B_periph(AT91_PIN_PE11, 0);    /* ISI_MCK (PCK3) */
+       at91_set_B_periph(AT91_PIN_PE12, 0);    /* ISI_PD8 */
+       at91_set_B_periph(AT91_PIN_PE13, 0);    /* ISI_PD9 */
+       at91_set_B_periph(AT91_PIN_PE14, 0);    /* ISI_PD10 */
+       at91_set_B_periph(AT91_PIN_PE15, 0);    /* ISI_PD11 */
+}
+#else
+void __init at91_add_device_isi(void) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  RTT
+ * -------------------------------------------------------------------- */
+
+static struct resource rtt0_resources[] = {
+       {
+               .start  = AT91_BASE_SYS + AT91_RTT0,
+               .end    = AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
+static struct platform_device at91sam9263_rtt0_device = {
+       .name           = "at91_rtt",
+       .id             = 0,
+       .resource       = rtt0_resources,
+       .num_resources  = ARRAY_SIZE(rtt0_resources),
+};
+
+static struct resource rtt1_resources[] = {
+       {
+               .start  = AT91_BASE_SYS + AT91_RTT1,
+               .end    = AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1,
+               .flags  = IORESOURCE_MEM,
+       }
+};
+
+static struct platform_device at91sam9263_rtt1_device = {
+       .name           = "at91_rtt",
+       .id             = 1,
+       .resource       = rtt1_resources,
+       .num_resources  = ARRAY_SIZE(rtt1_resources),
+};
+
+static void __init at91_add_device_rtt(void)
+{
+       platform_device_register(&at91sam9263_rtt0_device);
+       platform_device_register(&at91sam9263_rtt1_device);
+}
+
+
+/* --------------------------------------------------------------------
+ *  Watchdog
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
+static struct platform_device at91sam9263_wdt_device = {
+       .name           = "at91_wdt",
+       .id             = -1,
+       .num_resources  = 0,
+};
+
+static void __init at91_add_device_watchdog(void)
+{
+       platform_device_register(&at91sam9263_wdt_device);
+}
+#else
+static void __init at91_add_device_watchdog(void) {}
+#endif
+
+
 /* --------------------------------------------------------------------
  *  LEDs
  * -------------------------------------------------------------------- */
@@ -742,12 +890,15 @@ static struct atmel_uart_data dbgu_data = {
        .regs           = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
 };
 
+static u64 dbgu_dmamask = DMA_BIT_MASK(32);
+
 static struct platform_device at91sam9263_dbgu_device = {
        .name           = "atmel_usart",
        .id             = 0,
        .dev            = {
-                               .platform_data  = &dbgu_data,
-                               .coherent_dma_mask = 0xffffffff,
+                               .dma_mask               = &dbgu_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &dbgu_data,
        },
        .resource       = dbgu_resources,
        .num_resources  = ARRAY_SIZE(dbgu_resources),
@@ -777,12 +928,15 @@ static struct atmel_uart_data uart0_data = {
        .use_dma_rx     = 1,
 };
 
+static u64 uart0_dmamask = DMA_BIT_MASK(32);
+
 static struct platform_device at91sam9263_uart0_device = {
        .name           = "atmel_usart",
        .id             = 1,
        .dev            = {
-                               .platform_data  = &uart0_data,
-                               .coherent_dma_mask = 0xffffffff,
+                               .dma_mask               = &uart0_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &uart0_data,
        },
        .resource       = uart0_resources,
        .num_resources  = ARRAY_SIZE(uart0_resources),
@@ -814,12 +968,15 @@ static struct atmel_uart_data uart1_data = {
        .use_dma_rx     = 1,
 };
 
+static u64 uart1_dmamask = DMA_BIT_MASK(32);
+
 static struct platform_device at91sam9263_uart1_device = {
        .name           = "atmel_usart",
        .id             = 2,
        .dev            = {
-                               .platform_data  = &uart1_data,
-                               .coherent_dma_mask = 0xffffffff,
+                               .dma_mask               = &uart1_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &uart1_data,
        },
        .resource       = uart1_resources,
        .num_resources  = ARRAY_SIZE(uart1_resources),
@@ -851,12 +1008,15 @@ static struct atmel_uart_data uart2_data = {
        .use_dma_rx     = 1,
 };
 
+static u64 uart2_dmamask = DMA_BIT_MASK(32);
+
 static struct platform_device at91sam9263_uart2_device = {
        .name           = "atmel_usart",
        .id             = 3,
        .dev            = {
-                               .platform_data  = &uart2_data,
-                               .coherent_dma_mask = 0xffffffff,
+                               .dma_mask               = &uart2_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &uart2_data,
        },
        .resource       = uart2_resources,
        .num_resources  = ARRAY_SIZE(uart2_resources),
@@ -870,7 +1030,7 @@ static inline void configure_usart2_pins(void)
        at91_set_B_periph(AT91_PIN_PD6, 0);             /* CTS2 */
 }
 
-struct platform_device *at91_uarts[ATMEL_MAX_UART];    /* the UARTs to use */
+static struct platform_device *at91_uarts[ATMEL_MAX_UART];     /* the UARTs to use */
 struct platform_device *atmel_default_console_device;  /* the serial console device */
 
 void __init at91_init_serial(struct at91_uart_config *config)
@@ -935,6 +1095,8 @@ void __init at91_add_device_serial(void) {}
  */
 static int __init at91_add_standard_devices(void)
 {
+       at91_add_device_rtt();
+       at91_add_device_watchdog();
        return 0;
 }