aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9263_devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/at91sam9263_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index f924bd5017de..ac329a98e959 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -13,7 +13,9 @@
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
18#include <linux/fb.h>
17#include <video/atmel_lcdc.h> 19#include <video/atmel_lcdc.h>
18 20
19#include <asm/arch/board.h> 21#include <asm/arch/board.h>
@@ -421,7 +423,40 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {}
421 * TWI (i2c) 423 * TWI (i2c)
422 * -------------------------------------------------------------------- */ 424 * -------------------------------------------------------------------- */
423 425
424#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) 426/*
427 * Prefer the GPIO code since the TWI controller isn't robust
428 * (gets overruns and underruns under load) and can only issue
429 * repeated STARTs in one scenario (the driver doesn't yet handle them).
430 */
431#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
432
433static struct i2c_gpio_platform_data pdata = {
434 .sda_pin = AT91_PIN_PB4,
435 .sda_is_open_drain = 1,
436 .scl_pin = AT91_PIN_PB5,
437 .scl_is_open_drain = 1,
438 .udelay = 2, /* ~100 kHz */
439};
440
441static struct platform_device at91sam9263_twi_device = {
442 .name = "i2c-gpio",
443 .id = -1,
444 .dev.platform_data = &pdata,
445};
446
447void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
448{
449 at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
450 at91_set_multi_drive(AT91_PIN_PB4, 1);
451
452 at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
453 at91_set_multi_drive(AT91_PIN_PB5, 1);
454
455 i2c_register_board_info(0, devices, nr_devices);
456 platform_device_register(&at91sam9263_twi_device);
457}
458
459#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
425 460
426static struct resource twi_resources[] = { 461static struct resource twi_resources[] = {
427 [0] = { 462 [0] = {
@@ -443,7 +478,7 @@ static struct platform_device at91sam9263_twi_device = {
443 .num_resources = ARRAY_SIZE(twi_resources), 478 .num_resources = ARRAY_SIZE(twi_resources),
444}; 479};
445 480
446void __init at91_add_device_i2c(void) 481void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
447{ 482{
448 /* pins used for TWI interface */ 483 /* pins used for TWI interface */
449 at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */ 484 at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
@@ -452,10 +487,11 @@ void __init at91_add_device_i2c(void)
452 at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */ 487 at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
453 at91_set_multi_drive(AT91_PIN_PB5, 1); 488 at91_set_multi_drive(AT91_PIN_PB5, 1);
454 489
490 i2c_register_board_info(0, devices, nr_devices);
455 platform_device_register(&at91sam9263_twi_device); 491 platform_device_register(&at91sam9263_twi_device);
456} 492}
457#else 493#else
458void __init at91_add_device_i2c(void) {} 494void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
459#endif 495#endif
460 496
461 497