]> 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 b77121f27f34378f97d742ab5b9132269db8b9b8..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>
 #include <asm/arch/gpio.h>
 
 #include "generic.h"
 
-#define SZ_512 0x00000200
-#define SZ_256 0x00000100
-#define SZ_16  0x00000010
 
 /* --------------------------------------------------------------------
  *  USB Host
  * -------------------------------------------------------------------- */
 
 #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[] = {
@@ -52,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,
@@ -135,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[] = {
@@ -156,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,
@@ -209,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[] = {
@@ -230,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,
@@ -255,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,
@@ -422,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] = {
@@ -444,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 */
@@ -453,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
 
 
@@ -465,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] = {
@@ -485,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),
@@ -511,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),
@@ -572,6 +608,241 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
 #endif
 
 
+/* --------------------------------------------------------------------
+ *  AC97
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
+static u64 ac97_dmamask = DMA_BIT_MASK(32);
+static struct atmel_ac97_data ac97_data;
+
+static struct resource ac97_resources[] = {
+       [0] = {
+               .start  = AT91SAM9263_BASE_AC97C,
+               .end    = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9263_ID_AC97C,
+               .end    = AT91SAM9263_ID_AC97C,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91sam9263_ac97_device = {
+       .name           = "ac97c",
+       .id             = 1,
+       .dev            = {
+                               .dma_mask               = &ac97_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &ac97_data,
+       },
+       .resource       = ac97_resources,
+       .num_resources  = ARRAY_SIZE(ac97_resources),
+};
+
+void __init at91_add_device_ac97(struct atmel_ac97_data *data)
+{
+       if (!data)
+               return;
+
+       at91_set_A_periph(AT91_PIN_PB0, 0);     /* AC97FS */
+       at91_set_A_periph(AT91_PIN_PB1, 0);     /* AC97CK */
+       at91_set_A_periph(AT91_PIN_PB2, 0);     /* AC97TX */
+       at91_set_A_periph(AT91_PIN_PB3, 0);     /* AC97RX */
+
+       /* reset */
+       if (data->reset_pin)
+               at91_set_gpio_output(data->reset_pin, 0);
+
+       ac97_data = *ek_data;
+       platform_device_register(&at91sam9263_ac97_device);
+}
+#else
+void __init at91_add_device_ac97(struct atmel_ac97_data *data) {}
+#endif
+
+
+/* --------------------------------------------------------------------
+ *  LCD Controller
+ * -------------------------------------------------------------------- */
+
+#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
+static u64 lcdc_dmamask = DMA_BIT_MASK(32);
+static struct atmel_lcdfb_info lcdc_data;
+
+static struct resource lcdc_resources[] = {
+       [0] = {
+               .start  = AT91SAM9263_LCDC_BASE,
+               .end    = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = AT91SAM9263_ID_LCDC,
+               .end    = AT91SAM9263_ID_LCDC,
+               .flags  = IORESOURCE_IRQ,
+       },
+};
+
+static struct platform_device at91_lcdc_device = {
+       .name           = "atmel_lcdfb",
+       .id             = 0,
+       .dev            = {
+                               .dma_mask               = &lcdc_dmamask,
+                               .coherent_dma_mask      = DMA_BIT_MASK(32),
+                               .platform_data          = &lcdc_data,
+       },
+       .resource       = lcdc_resources,
+       .num_resources  = ARRAY_SIZE(lcdc_resources),
+};
+
+void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
+{
+       if (!data)
+               return;
+
+       at91_set_A_periph(AT91_PIN_PC1, 0);     /* LCDHSYNC */
+       at91_set_A_periph(AT91_PIN_PC2, 0);     /* LCDDOTCK */
+       at91_set_A_periph(AT91_PIN_PC3, 0);     /* LCDDEN */
+       at91_set_B_periph(AT91_PIN_PB9, 0);     /* LCDCC */
+       at91_set_A_periph(AT91_PIN_PC6, 0);     /* LCDD2 */
+       at91_set_A_periph(AT91_PIN_PC7, 0);     /* LCDD3 */
+       at91_set_A_periph(AT91_PIN_PC8, 0);     /* LCDD4 */
+       at91_set_A_periph(AT91_PIN_PC9, 0);     /* LCDD5 */
+       at91_set_A_periph(AT91_PIN_PC10, 0);    /* LCDD6 */
+       at91_set_A_periph(AT91_PIN_PC11, 0);    /* LCDD7 */
+       at91_set_A_periph(AT91_PIN_PC14, 0);    /* LCDD10 */
+       at91_set_A_periph(AT91_PIN_PC15, 0);    /* LCDD11 */
+       at91_set_A_periph(AT91_PIN_PC16, 0);    /* LCDD12 */
+       at91_set_B_periph(AT91_PIN_PC12, 0);    /* LCDD13 */
+       at91_set_A_periph(AT91_PIN_PC18, 0);    /* LCDD14 */
+       at91_set_A_periph(AT91_PIN_PC19, 0);    /* LCDD15 */
+       at91_set_A_periph(AT91_PIN_PC22, 0);    /* LCDD18 */
+       at91_set_A_periph(AT91_PIN_PC23, 0);    /* LCDD19 */
+       at91_set_A_periph(AT91_PIN_PC24, 0);    /* LCDD20 */
+       at91_set_B_periph(AT91_PIN_PC17, 0);    /* LCDD21 */
+       at91_set_A_periph(AT91_PIN_PC26, 0);    /* LCDD22 */
+       at91_set_A_periph(AT91_PIN_PC27, 0);    /* LCDD23 */
+
+       lcdc_data = *data;
+       platform_device_register(&at91_lcdc_device);
+}
+#else
+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
  * -------------------------------------------------------------------- */
@@ -619,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),
@@ -654,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),
@@ -691,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),
@@ -728,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),
@@ -747,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)
@@ -812,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;
 }