1
0

0004-grasshopper-i2c.patch 2.3 KB

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