diff options
author | Andrew Victor <andrew@sanpeople.com> | 2007-11-19 07:47:20 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-11-26 14:40:47 -0500 |
commit | f230d3f53d72d05bcb5666ab7e2eccd49c8b3a15 (patch) | |
tree | 0d06454868ca879f06a268de71beb0b1ba6a08d7 /arch/arm/mach-at91/at91sam9260_devices.c | |
parent | a95c729b7484d2bbb9ab6beef4865641e73deb99 (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/at91sam9260_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 42 |
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 | |||
364 | static 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 | |||
372 | static struct platform_device at91sam9260_twi_device = { | ||
373 | .name = "i2c-gpio", | ||
374 | .id = -1, | ||
375 | .dev.platform_data = &pdata, | ||
376 | }; | ||
377 | |||
378 | void __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 | ||
357 | static struct resource twi_resources[] = { | 392 | static 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 | ||
377 | void __init at91_add_device_i2c(void) | 412 | void __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 |
389 | void __init at91_add_device_i2c(void) {} | 425 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} |
390 | #endif | 426 | #endif |
391 | 427 | ||
392 | 428 | ||