1
0

0003-grasshopper-enable-i2c-gpio.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/setup.c linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/setup.c
  2. --- linux-4.7.3/arch/avr32/boards/grasshopper/setup.c 2016-09-14 10:48:53.403638569 +0200
  3. +++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/setup.c 2016-09-14 11:40:15.735513299 +0200
  4. @@ -129,6 +129,28 @@
  5. };
  6. #endif
  7. +/* I2C/TWI */
  8. +#ifdef CONFIG_I2C
  9. +static struct i2c_gpio_platform_data i2c_gpio_data = {
  10. + .sda_pin = GPIO_PIN_PA(6),
  11. + .scl_pin = GPIO_PIN_PA(7),
  12. + .sda_is_open_drain = 1,
  13. + .scl_is_open_drain = 1,
  14. + .udelay = 2, /* close to 100 kHz */
  15. +};
  16. +
  17. +static struct platform_device i2c_gpio_device = {
  18. + .name = "i2c-gpio",
  19. + .id = 0,
  20. + .dev = {
  21. + .platform_data = &i2c_gpio_data,
  22. + },
  23. +};
  24. +
  25. +static struct i2c_board_info i2c_info[] = {
  26. +};
  27. +#endif
  28. +
  29. /* MCI */
  30. #ifdef CONFIG_MMC_ATMELMCI
  31. static struct mci_platform_data __initdata mci0_data = {
  32. @@ -168,6 +190,22 @@
  33. ATMEL_LCDC_PRI_CONTROL | ATMEL_LCDC_PRI_24BIT);
  34. #endif
  35. + // I2C / TWI
  36. +#ifdef CONFIG_I2C
  37. + /* all these i2c/smbus pins should have external pullups for
  38. + * open-drain sharing among all I2C devices. SDA and SCL do;
  39. + * PB28/EXTINT3 doesn't; it should be SMBALERT# (for PMBus),
  40. + * but it's not available off-board.
  41. + */
  42. + at32_select_periph(GPIO_PIOB_BASE, 1 << 28, 0, AT32_GPIOF_PULLUP);
  43. + at32_select_gpio(i2c_gpio_data.sda_pin,
  44. + AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
  45. + at32_select_gpio(i2c_gpio_data.scl_pin,
  46. + AT32_GPIOF_MULTIDRV | AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
  47. + platform_device_register(&i2c_gpio_device);
  48. + i2c_register_board_info(0, i2c_info, ARRAY_SIZE(i2c_info));
  49. +#endif
  50. +
  51. #ifdef CONFIG_MMC_ATMELMCI
  52. // at32_add_device_mci(0, &mci0_data); /* MMC/SD */
  53. #endif