diff options
Diffstat (limited to 'arch/arm/mach-at91/at91rm9200_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91rm9200_devices.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 0417c165d50d..9296833f91cc 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <asm/mach/map.h> | 14 | #include <asm/mach/map.h> |
15 | 15 | ||
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/i2c-gpio.h> | ||
17 | 18 | ||
18 | #include <asm/arch/board.h> | 19 | #include <asm/arch/board.h> |
19 | #include <asm/arch/gpio.h> | 20 | #include <asm/arch/gpio.h> |
@@ -435,7 +436,40 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {} | |||
435 | * TWI (i2c) | 436 | * TWI (i2c) |
436 | * -------------------------------------------------------------------- */ | 437 | * -------------------------------------------------------------------- */ |
437 | 438 | ||
438 | #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) | 439 | /* |
440 | * Prefer the GPIO code since the TWI controller isn't robust | ||
441 | * (gets overruns and underruns under load) and can only issue | ||
442 | * repeated STARTs in one scenario (the driver doesn't yet handle them). | ||
443 | */ | ||
444 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) | ||
445 | |||
446 | static struct i2c_gpio_platform_data pdata = { | ||
447 | .sda_pin = AT91_PIN_PA25, | ||
448 | .sda_is_open_drain = 1, | ||
449 | .scl_pin = AT91_PIN_PA26, | ||
450 | .scl_is_open_drain = 1, | ||
451 | .udelay = 2, /* ~100 kHz */ | ||
452 | }; | ||
453 | |||
454 | static struct platform_device at91rm9200_twi_device = { | ||
455 | .name = "i2c-gpio", | ||
456 | .id = -1, | ||
457 | .dev.platform_data = &pdata, | ||
458 | }; | ||
459 | |||
460 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | ||
461 | { | ||
462 | at91_set_GPIO_periph(AT91_PIN_PA25, 1); /* TWD (SDA) */ | ||
463 | at91_set_multi_drive(AT91_PIN_PA25, 1); | ||
464 | |||
465 | at91_set_GPIO_periph(AT91_PIN_PA26, 1); /* TWCK (SCL) */ | ||
466 | at91_set_multi_drive(AT91_PIN_PA26, 1); | ||
467 | |||
468 | i2c_register_board_info(0, devices, nr_devices); | ||
469 | platform_device_register(&at91rm9200_twi_device); | ||
470 | } | ||
471 | |||
472 | #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) | ||
439 | 473 | ||
440 | static struct resource twi_resources[] = { | 474 | static struct resource twi_resources[] = { |
441 | [0] = { | 475 | [0] = { |
@@ -457,7 +491,7 @@ static struct platform_device at91rm9200_twi_device = { | |||
457 | .num_resources = ARRAY_SIZE(twi_resources), | 491 | .num_resources = ARRAY_SIZE(twi_resources), |
458 | }; | 492 | }; |
459 | 493 | ||
460 | void __init at91_add_device_i2c(void) | 494 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) |
461 | { | 495 | { |
462 | /* pins used for TWI interface */ | 496 | /* pins used for TWI interface */ |
463 | at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */ | 497 | at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */ |
@@ -466,10 +500,11 @@ void __init at91_add_device_i2c(void) | |||
466 | at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */ | 500 | at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */ |
467 | at91_set_multi_drive(AT91_PIN_PA26, 1); | 501 | at91_set_multi_drive(AT91_PIN_PA26, 1); |
468 | 502 | ||
503 | i2c_register_board_info(0, devices, nr_devices); | ||
469 | platform_device_register(&at91rm9200_twi_device); | 504 | platform_device_register(&at91rm9200_twi_device); |
470 | } | 505 | } |
471 | #else | 506 | #else |
472 | void __init at91_add_device_i2c(void) {} | 507 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} |
473 | #endif | 508 | #endif |
474 | 509 | ||
475 | 510 | ||