aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9261_devices.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91/at91sam9261_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 3576595b4941..64979a9023c2 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -14,7 +14,9 @@
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
19#include <linux/fb.h>
18#include <video/atmel_lcdc.h> 20#include <video/atmel_lcdc.h>
19 21
20#include <asm/arch/board.h> 22#include <asm/arch/board.h>
@@ -275,7 +277,40 @@ void __init at91_add_device_nand(struct at91_nand_data *data) {}
275 * TWI (i2c) 277 * TWI (i2c)
276 * -------------------------------------------------------------------- */ 278 * -------------------------------------------------------------------- */
277 279
278#if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) 280/*
281 * Prefer the GPIO code since the TWI controller isn't robust
282 * (gets overruns and underruns under load) and can only issue
283 * repeated STARTs in one scenario (the driver doesn't yet handle them).
284 */
285#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
286
287static struct i2c_gpio_platform_data pdata = {
288 .sda_pin = AT91_PIN_PA7,
289 .sda_is_open_drain = 1,
290 .scl_pin = AT91_PIN_PA8,
291 .scl_is_open_drain = 1,
292 .udelay = 2, /* ~100 kHz */
293};
294
295static struct platform_device at91sam9261_twi_device = {
296 .name = "i2c-gpio",
297 .id = -1,
298 .dev.platform_data = &pdata,
299};
300
301void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
302{
303 at91_set_GPIO_periph(AT91_PIN_PA7, 1); /* TWD (SDA) */
304 at91_set_multi_drive(AT91_PIN_PA7, 1);
305
306 at91_set_GPIO_periph(AT91_PIN_PA8, 1); /* TWCK (SCL) */
307 at91_set_multi_drive(AT91_PIN_PA8, 1);
308
309 i2c_register_board_info(0, devices, nr_devices);
310 platform_device_register(&at91sam9261_twi_device);
311}
312
313#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
279 314
280static struct resource twi_resources[] = { 315static struct resource twi_resources[] = {
281 [0] = { 316 [0] = {
@@ -297,7 +332,7 @@ static struct platform_device at91sam9261_twi_device = {
297 .num_resources = ARRAY_SIZE(twi_resources), 332 .num_resources = ARRAY_SIZE(twi_resources),
298}; 333};
299 334
300void __init at91_add_device_i2c(void) 335void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
301{ 336{
302 /* pins used for TWI interface */ 337 /* pins used for TWI interface */
303 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */ 338 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
@@ -306,10 +341,11 @@ void __init at91_add_device_i2c(void)
306 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */ 341 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */
307 at91_set_multi_drive(AT91_PIN_PA8, 1); 342 at91_set_multi_drive(AT91_PIN_PA8, 1);
308 343
344 i2c_register_board_info(0, devices, nr_devices);
309 platform_device_register(&at91sam9261_twi_device); 345 platform_device_register(&at91sam9261_twi_device);
310} 346}
311#else 347#else
312void __init at91_add_device_i2c(void) {} 348void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
313#endif 349#endif
314 350
315 351