aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91rm9200_devices.c
diff options
context:
space:
mode:
authorAndrew Victor <andrew@sanpeople.com>2007-11-19 07:47:20 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-11-26 14:40:47 -0500
commitf230d3f53d72d05bcb5666ab7e2eccd49c8b3a15 (patch)
tree0d06454868ca879f06a268de71beb0b1ba6a08d7 /arch/arm/mach-at91/at91rm9200_devices.c
parenta95c729b7484d2bbb9ab6beef4865641e73deb99 (diff)
[ARM] 4650/1: AT91: New-style init of I2C, support for i2c-gpio
The AT91 I2C driver is currently marked as "broken" due to hardware issues. This patch enables AT91-based platforms to also use the bitbanged GPIO for I2C. This updates platform setup logic (setting up an i2c-gpio device using the same pins as the i2c-at91 device, unless only the BROKEN driver is enabled). Also make use of the new-style initialization of I2C devices using i2c_register_board_info(). Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91/at91rm9200_devices.c')
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c41
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
446static 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
454static struct platform_device at91rm9200_twi_device = {
455 .name = "i2c-gpio",
456 .id = -1,
457 .dev.platform_data = &pdata,
458};
459
460void __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
440static struct resource twi_resources[] = { 474static 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
460void __init at91_add_device_i2c(void) 494void __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
472void __init at91_add_device_i2c(void) {} 507void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
473#endif 508#endif
474 509
475 510