ARM: at91/usbh: fix overcurrent gpio setup
[platform/adaptation/renesas_rcar/renesas_kernel.git] / arch / arm / mach-at91 / at91sam9261_devices.c
index 11e9fa8..cd604aa 100644 (file)
@@ -72,7 +72,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
 
        /* Enable overcurrent notification */
        for (i = 0; i < data->ports; i++) {
-               if (data->overcurrent_pin[i])
+               if (gpio_is_valid(data->overcurrent_pin[i]))
                        at91_set_gpio_input(data->overcurrent_pin[i], 1);
        }
 
@@ -285,7 +285,7 @@ static struct i2c_gpio_platform_data pdata = {
 
 static struct platform_device at91sam9261_twi_device = {
        .name                   = "i2c-gpio",
-       .id                     = -1,
+       .id                     = 0,
        .dev.platform_data      = &pdata,
 };
 
@@ -317,20 +317,26 @@ static struct resource twi_resources[] = {
 };
 
 static struct platform_device at91sam9261_twi_device = {
-       .name           = "at91_i2c",
-       .id             = -1,
+       .id             = 0,
        .resource       = twi_resources,
        .num_resources  = ARRAY_SIZE(twi_resources),
 };
 
 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
 {
+       /* IP version is not the same on 9261 and g10 */
+       if (cpu_is_at91sam9g10()) {
+               at91sam9261_twi_device.name = "i2c-at91sam9g10";
+               /* I2C PIO must not be configured as open-drain on this chip */
+       } else {
+               at91sam9261_twi_device.name = "i2c-at91sam9261";
+               at91_set_multi_drive(AT91_PIN_PA7, 1);
+               at91_set_multi_drive(AT91_PIN_PA8, 1);
+       }
+
        /* pins used for TWI interface */
        at91_set_A_periph(AT91_PIN_PA7, 0);             /* TWD */
-       at91_set_multi_drive(AT91_PIN_PA7, 1);
-
        at91_set_A_periph(AT91_PIN_PA8, 0);             /* TWCK */
-       at91_set_multi_drive(AT91_PIN_PA8, 1);
 
        i2c_register_board_info(0, devices, nr_devices);
        platform_device_register(&at91sam9261_twi_device);