0106-Build-i2c_gpio-module-and-add-a-device-tree-overlay-.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. From 75803fb0ecf8fcb8e2803feb8ee4b8e3d274c835 Mon Sep 17 00:00:00 2001
  2. From: Alistair Buxton <a.j.buxton@gmail.com>
  3. Date: Sun, 1 Nov 2015 22:27:56 +0000
  4. Subject: [PATCH 106/381] Build i2c_gpio module and add a device tree overlay
  5. to configure it.
  6. ---
  7. arch/arm/boot/dts/overlays/Makefile | 1 +
  8. arch/arm/boot/dts/overlays/README | 13 +++++++++++-
  9. arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts | 28 +++++++++++++++++++++++++
  10. arch/arm/configs/bcm2709_defconfig | 1 +
  11. arch/arm/configs/bcmrpi_defconfig | 1 +
  12. 5 files changed, 43 insertions(+), 1 deletion(-)
  13. create mode 100644 arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
  14. --- a/arch/arm/boot/dts/overlays/Makefile
  15. +++ b/arch/arm/boot/dts/overlays/Makefile
  16. @@ -25,6 +25,7 @@ dtb-$(RPI_DT_OVERLAYS) += hifiberry-digi
  17. dtb-$(RPI_DT_OVERLAYS) += hy28a-overlay.dtb
  18. dtb-$(RPI_DT_OVERLAYS) += hy28b-overlay.dtb
  19. dtb-$(RPI_DT_OVERLAYS) += i2c-rtc-overlay.dtb
  20. +dtb-$(RPI_DT_OVERLAYS) += i2c-gpio-overlay.dtb
  21. dtb-$(RPI_DT_OVERLAYS) += i2s-mmap-overlay.dtb
  22. dtb-$(RPI_DT_OVERLAYS) += iqaudio-dac-overlay.dtb
  23. dtb-$(RPI_DT_OVERLAYS) += iqaudio-dacplus-overlay.dtb
  24. --- a/arch/arm/boot/dts/overlays/README
  25. +++ b/arch/arm/boot/dts/overlays/README
  26. @@ -287,9 +287,20 @@ Params: speed Display
  27. ledgpio GPIO used to control backlight
  28. +Name: i2c-gpio
  29. +Info: Adds support for software i2c controller on gpio pins
  30. +Load: dtoverlay=i2c-gpio,<param>=<val>
  31. +Params: i2c_gpio_sda GPIO used for I2C data (default "23")
  32. +
  33. + i2c_gpio_scl GPIO used for I2C clock (default "24")
  34. +
  35. + i2c_gpio_delay_us Clock delay in microseconds
  36. + (default "2" = ~100kHz)
  37. +
  38. +
  39. Name: i2c-rtc
  40. Info: Adds support for a number of I2C Real Time Clock devices
  41. -Load: dtoverlay=i2c-rtc,<param>
  42. +Load: dtoverlay=i2c-rtc,<param>=<val>
  43. Params: ds1307 Select the DS1307 device
  44. ds3231 Select the DS3231 device
  45. --- /dev/null
  46. +++ b/arch/arm/boot/dts/overlays/i2c-gpio-overlay.dts
  47. @@ -0,0 +1,28 @@
  48. +// Overlay for i2c_gpio bitbanging host bus.
  49. +/dts-v1/;
  50. +/plugin/;
  51. +
  52. +/ {
  53. + compatible = "brcm,bcm2708";
  54. +
  55. + fragment@0 {
  56. + target-path = "/";
  57. + __overlay__ {
  58. + i2c_gpio: i2c@0 {
  59. + compatible = "i2c-gpio";
  60. + gpios = <&gpio 23 0 /* sda */
  61. + &gpio 24 0 /* scl */
  62. + >;
  63. + i2c-gpio,delay-us = <2>; /* ~100 kHz */
  64. + #address-cells = <1>;
  65. + #size-cells = <0>;
  66. + };
  67. + };
  68. + };
  69. + __overrides__ {
  70. + i2c_gpio_sda = <&i2c_gpio>,"gpios:4";
  71. + i2c_gpio_scl = <&i2c_gpio>,"gpios:16";
  72. + i2c_gpio_delay_us = <&i2c_gpio>,"i2c-gpio,delay-us:0";
  73. + };
  74. +};
  75. +
  76. --- a/arch/arm/configs/bcm2709_defconfig
  77. +++ b/arch/arm/configs/bcm2709_defconfig
  78. @@ -595,6 +595,7 @@ CONFIG_RAW_DRIVER=y
  79. CONFIG_I2C=y
  80. CONFIG_I2C_CHARDEV=m
  81. CONFIG_I2C_BCM2708=m
  82. +CONFIG_I2C_GPIO=m
  83. CONFIG_SPI=y
  84. CONFIG_SPI_BCM2835=m
  85. CONFIG_SPI_SPIDEV=y
  86. --- a/arch/arm/configs/bcmrpi_defconfig
  87. +++ b/arch/arm/configs/bcmrpi_defconfig
  88. @@ -588,6 +588,7 @@ CONFIG_RAW_DRIVER=y
  89. CONFIG_I2C=y
  90. CONFIG_I2C_CHARDEV=m
  91. CONFIG_I2C_BCM2708=m
  92. +CONFIG_I2C_GPIO=m
  93. CONFIG_SPI=y
  94. CONFIG_SPI_BCM2835=m
  95. CONFIG_SPI_SPIDEV=y