]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-at91/at91rm9200_devices.c
[ARM] 4650/1: AT91: New-style init of I2C, support for i2c-gpio
[linux-2.6-omap-h63xx.git] / arch / arm / mach-at91 / at91rm9200_devices.c
index 2624a4f22d612391aad930a9696795893f654f98..9296833f91ccd576c7c5dbbacffbf94cb7a28518 100644 (file)
@@ -14,6 +14,7 @@
 #include <asm/mach/map.h>
 
 #include <linux/platform_device.h>
+#include <linux/i2c-gpio.h>
 
 #include <asm/arch/board.h>
 #include <asm/arch/gpio.h>
@@ -22,9 +23,6 @@
 
 #include "generic.h"
 
-#define SZ_512 0x00000200
-#define SZ_256 0x00000100
-#define SZ_16  0x00000010
 
 /* --------------------------------------------------------------------
  *  USB Host
@@ -438,7 +436,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_PA25,
+       .sda_is_open_drain      = 1,
+       .scl_pin                = AT91_PIN_PA26,
+       .scl_is_open_drain      = 1,
+       .udelay                 = 2,            /* ~100 kHz */
+};
+
+static struct platform_device at91rm9200_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_PA25, 1);         /* TWD (SDA) */
+       at91_set_multi_drive(AT91_PIN_PA25, 1);
+
+       at91_set_GPIO_periph(AT91_PIN_PA26, 1);         /* TWCK (SCL) */
+       at91_set_multi_drive(AT91_PIN_PA26, 1);
+
+       i2c_register_board_info(0, devices, nr_devices);
+       platform_device_register(&at91rm9200_twi_device);
+}
+
+#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
 
 static struct resource twi_resources[] = {
        [0] = {
@@ -460,7 +491,7 @@ static struct platform_device at91rm9200_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_PA25, 0);            /* TWD */
@@ -469,10 +500,11 @@ void __init at91_add_device_i2c(void)
        at91_set_A_periph(AT91_PIN_PA26, 0);            /* TWCK */
        at91_set_multi_drive(AT91_PIN_PA26, 1);
 
+       i2c_register_board_info(0, devices, nr_devices);
        platform_device_register(&at91rm9200_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
 
 
@@ -480,7 +512,7 @@ void __init at91_add_device_i2c(void) {}
  *  SPI
  * -------------------------------------------------------------------- */
 
-#if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE)
+#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
 static u64 spi_dmamask = 0xffffffffUL;
 
 static struct resource spi_resources[] = {
@@ -497,7 +529,7 @@ static struct resource spi_resources[] = {
 };
 
 static struct platform_device at91rm9200_spi_device = {
-       .name           = "at91_spi",
+       .name           = "atmel_spi",
        .id             = 0,
        .dev            = {
                                .dma_mask               = &spi_dmamask,
@@ -525,18 +557,14 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
                else
                        cs_pin = spi_standard_cs[devices[i].chip_select];
 
-#ifdef CONFIG_SPI_AT91_MANUAL_CS
+               /* enable chip-select pin */
                at91_set_gpio_output(cs_pin, 1);
-#else
-               at91_set_A_periph(cs_pin, 0);
-#endif
 
                /* pass chip-select pin to driver */
                devices[i].controller_data = (void *) cs_pin;
        }
 
        spi_register_board_info(devices, nr_devices);
-       at91_clock_associate("spi_clk", &at91rm9200_spi_device.dev, "spi");
        platform_device_register(&at91rm9200_spi_device);
 }
 #else