aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9260_devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/at91sam9260_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index ffd3154c1e54..3091bf47d8c9 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -13,6 +13,7 @@
13#include <asm/mach/map.h> 13#include <asm/mach/map.h>
14 14
15#include <linux/platform_device.h> 15#include <linux/platform_device.h>
16#include <linux/i2c-gpio.h>
16 17
17#include <asm/arch/board.h> 18#include <asm/arch/board.h>
18#include <asm/arch/gpio.h> 19#include <asm/arch/gpio.h>
@@ -352,7 +353,41 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {}
352 * TWI (i2c) 353 * TWI (i2c)
353 * -------------------------------------------------------------------- */ 354 * -------------------------------------------------------------------- */
354 355
355#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) 356/*
357 * Prefer the GPIO code since the TWI controller isn't robust
358 * (gets overruns and underruns under load) and can only issue
359 * repeated STARTs in one scenario (the driver doesn't yet handle them).
360 */
361
362#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
363
364static struct i2c_gpio_platform_data pdata = {
365 .sda_pin = AT91_PIN_PA23,
366 .sda_is_open_drain = 1,
367 .scl_pin = AT91_PIN_PA24,
368 .scl_is_open_drain = 1,
369 .udelay = 2, /* ~100 kHz */
370};
371
372static struct platform_device at91sam9260_twi_device = {
373 .name = "i2c-gpio",
374 .id = -1,
375 .dev.platform_data = &pdata,
376};
377
378void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
379{
380 at91_set_GPIO_periph(AT91_PIN_PA23, 1); /* TWD (SDA) */
381 at91_set_multi_drive(AT91_PIN_PA23, 1);
382
383 at91_set_GPIO_periph(AT91_PIN_PA24, 1); /* TWCK (SCL) */
384 at91_set_multi_drive(AT91_PIN_PA24, 1);
385
386 i2c_register_board_info(0, devices, nr_devices);
387 platform_device_register(&at91sam9260_twi_device);
388}
389
390#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
356 391
357static struct resource twi_resources[] = { 392static struct resource twi_resources[] = {
358 [0] = { 393 [0] = {
@@ -374,7 +409,7 @@ static struct platform_device at91sam9260_twi_device = {
374 .num_resources = ARRAY_SIZE(twi_resources), 409 .num_resources = ARRAY_SIZE(twi_resources),
375}; 410};
376 411
377void __init at91_add_device_i2c(void) 412void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
378{ 413{
379 /* pins used for TWI interface */ 414 /* pins used for TWI interface */
380 at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */ 415 at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */
@@ -383,10 +418,11 @@ void __init at91_add_device_i2c(void)
383 at91_set_A_periph(AT91_PIN_PA24, 0); /* TWCK */ 418 at91_set_A_periph(AT91_PIN_PA24, 0); /* TWCK */
384 at91_set_multi_drive(AT91_PIN_PA24, 1); 419 at91_set_multi_drive(AT91_PIN_PA24, 1);
385 420
421 i2c_register_board_info(0, devices, nr_devices);
386 platform_device_register(&at91sam9260_twi_device); 422 platform_device_register(&at91sam9260_twi_device);
387} 423}
388#else 424#else
389void __init at91_add_device_i2c(void) {} 425void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
390#endif 426#endif
391 427
392 428