0576-Add-overlay-for-mcp3008-adc-1818.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. From f6a9afad8ed6521991c138caf7f20fd5222c2a5a Mon Sep 17 00:00:00 2001
  2. From: Scott Ellis <scott@jumpnowtek.com>
  3. Date: Fri, 27 Jan 2017 06:42:42 -0500
  4. Subject: [PATCH] Add overlay for mcp3008 adc (#1818)
  5. Some example usage:
  6. SPI0.0
  7. dtparam=spi=on
  8. dtoverlay=mcp3008:spi0-0-present
  9. SPI0.1
  10. dtparam=spi=on
  11. dtoverlay=mcp3008:spi0-1-present
  12. SPI0.0 and SPI0.1
  13. dtparam=spi=on
  14. dtoverlay=mcp3008:spi0-0-present,spi0-1-present
  15. SPI1.0
  16. dtparam=spi=on
  17. dtoverlay=spi1-1cs
  18. dtoverlay=mcp3008:spi1-0-present
  19. SPI1.2
  20. dtparam=spi=on
  21. dtoverlay=spi1-1cs:cs0_pin=16
  22. dtoverlay=mcp3008:spi1-0-present
  23. SPI1.0 and SPI1.1
  24. dtoverlay=spi1-2cs
  25. dtoverlay=mcp3008:spi1-0-present,spi1-1-present
  26. Changing the speed
  27. SPI0.0
  28. dtparam=spi=on
  29. dtoverlay=mcp3008:spi0-0-present,spi0-0-speed=2000000
  30. ---
  31. arch/arm/boot/dts/overlays/Makefile | 1 +
  32. arch/arm/boot/dts/overlays/README | 9 ++
  33. arch/arm/boot/dts/overlays/mcp3008-overlay.dts | 205 +++++++++++++++++++++++++
  34. 3 files changed, 215 insertions(+)
  35. create mode 100755 arch/arm/boot/dts/overlays/mcp3008-overlay.dts
  36. --- a/arch/arm/boot/dts/overlays/Makefile
  37. +++ b/arch/arm/boot/dts/overlays/Makefile
  38. @@ -57,6 +57,7 @@ dtbo-$(RPI_DT_OVERLAYS) += mcp23017.dtbo
  39. dtbo-$(RPI_DT_OVERLAYS) += mcp23s17.dtbo
  40. dtbo-$(RPI_DT_OVERLAYS) += mcp2515-can0.dtbo
  41. dtbo-$(RPI_DT_OVERLAYS) += mcp2515-can1.dtbo
  42. +dtbo-$(RPI_DT_OVERLAYS) += mcp3008.dtbo
  43. dtbo-$(RPI_DT_OVERLAYS) += mmc.dtbo
  44. dtbo-$(RPI_DT_OVERLAYS) += mz61581.dtbo
  45. dtbo-$(RPI_DT_OVERLAYS) += pi3-act-led.dtbo
  46. --- a/arch/arm/boot/dts/overlays/README
  47. +++ b/arch/arm/boot/dts/overlays/README
  48. @@ -736,6 +736,15 @@ Params: oscillator Clock fr
  49. interrupt GPIO for interrupt signal
  50. +Name: mcp3008
  51. +Info: Configures MCP3008 A/D converters
  52. + For devices on spi1 or spi2, the interfaces should be enabled
  53. + with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
  54. +Load: dtoverlay=mcp3008,<param>[=<val>]
  55. +Params: spi<n>-<m>-present boolean, configure device at spi<n>, cs<m>
  56. + spi<n>-<m>-speed integer, set the spi bus speed for this device
  57. +
  58. +
  59. Name: mmc
  60. Info: Selects the bcm2835-mmc SD/MMC driver, optionally with overclock
  61. Load: dtoverlay=mmc,<param>=<val>
  62. --- /dev/null
  63. +++ b/arch/arm/boot/dts/overlays/mcp3008-overlay.dts
  64. @@ -0,0 +1,205 @@
  65. +/*
  66. + * Device tree overlay for Microchip mcp3008 10-Bit A/D Converters
  67. + */
  68. +
  69. +/dts-v1/;
  70. +/plugin/;
  71. +
  72. +/ {
  73. + compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
  74. +
  75. + fragment@0 {
  76. + target = <&spidev0>;
  77. + __dormant__ {
  78. + status = "disabled";
  79. + };
  80. + };
  81. +
  82. + fragment@1 {
  83. + target = <&spidev1>;
  84. + __dormant__ {
  85. + status = "disabled";
  86. + };
  87. + };
  88. +
  89. + fragment@2 {
  90. + target-path = "spi1/spidev@0";
  91. + __dormant__ {
  92. + status = "disabled";
  93. + };
  94. + };
  95. +
  96. + fragment@3 {
  97. + target-path = "spi1/spidev@1";
  98. + __dormant__ {
  99. + status = "disabled";
  100. + };
  101. + };
  102. +
  103. + fragment@4 {
  104. + target-path = "spi1/spidev@2";
  105. + __dormant__ {
  106. + status = "disabled";
  107. + };
  108. + };
  109. +
  110. + fragment@5 {
  111. + target-path = "spi2/spidev@0";
  112. + __dormant__ {
  113. + status = "disabled";
  114. + };
  115. + };
  116. +
  117. + fragment@6 {
  118. + target-path = "spi2/spidev@1";
  119. + __dormant__ {
  120. + status = "disabled";
  121. + };
  122. + };
  123. +
  124. + fragment@7 {
  125. + target-path = "spi2/spidev@2";
  126. + __dormant__ {
  127. + status = "disabled";
  128. + };
  129. + };
  130. +
  131. + fragment@8 {
  132. + target = <&spi0>;
  133. + __dormant__ {
  134. + status = "okay";
  135. + #address-cells = <1>;
  136. + #size-cells = <0>;
  137. +
  138. + mcp3008_00: mcp3008@0 {
  139. + compatible = "mcp3008";
  140. + reg = <0>;
  141. + spi-max-frequency = <1600000>;
  142. + };
  143. + };
  144. + };
  145. +
  146. + fragment@9 {
  147. + target = <&spi0>;
  148. + __dormant__ {
  149. + status = "okay";
  150. + #address-cells = <1>;
  151. + #size-cells = <0>;
  152. +
  153. + mcp3008_01: mcp3008@1 {
  154. + compatible = "mcp3008";
  155. + reg = <1>;
  156. + spi-max-frequency = <1600000>;
  157. + };
  158. + };
  159. + };
  160. +
  161. + fragment@10 {
  162. + target = <&spi1>;
  163. + __dormant__ {
  164. + status = "okay";
  165. + #address-cells = <1>;
  166. + #size-cells = <0>;
  167. +
  168. + mcp3008_10: mcp3008@0 {
  169. + compatible = "mcp3008";
  170. + reg = <0>;
  171. + spi-max-frequency = <1600000>;
  172. + };
  173. + };
  174. + };
  175. +
  176. + fragment@11 {
  177. + target = <&spi1>;
  178. + __dormant__ {
  179. + status = "okay";
  180. + #address-cells = <1>;
  181. + #size-cells = <0>;
  182. +
  183. + mcp3008_11: mcp3008@1 {
  184. + compatible = "mcp3008";
  185. + reg = <1>;
  186. + spi-max-frequency = <1600000>;
  187. + };
  188. + };
  189. + };
  190. +
  191. + fragment@12 {
  192. + target = <&spi1>;
  193. + __dormant__ {
  194. + status = "okay";
  195. + #address-cells = <1>;
  196. + #size-cells = <0>;
  197. +
  198. + mcp3008_12: mcp3008@2 {
  199. + compatible = "mcp3008";
  200. + reg = <2>;
  201. + spi-max-frequency = <1600000>;
  202. + };
  203. + };
  204. + };
  205. +
  206. + fragment@13 {
  207. + target = <&spi2>;
  208. + __dormant__ {
  209. + status = "okay";
  210. + #address-cells = <1>;
  211. + #size-cells = <0>;
  212. +
  213. + mcp3008_20: mcp3008@0 {
  214. + compatible = "mcp3008";
  215. + reg = <0>;
  216. + spi-max-frequency = <1600000>;
  217. + };
  218. + };
  219. + };
  220. +
  221. + fragment@14 {
  222. + target = <&spi2>;
  223. + __dormant__ {
  224. + status = "okay";
  225. + #address-cells = <1>;
  226. + #size-cells = <0>;
  227. +
  228. + mcp3008_21: mcp3008@1 {
  229. + compatible = "mcp3008";
  230. + reg = <1>;
  231. + spi-max-frequency = <1600000>;
  232. + };
  233. + };
  234. + };
  235. +
  236. + fragment@15 {
  237. + target = <&spi2>;
  238. + __dormant__ {
  239. + status = "okay";
  240. + #address-cells = <1>;
  241. + #size-cells = <0>;
  242. +
  243. + mcp3008_22: mcp3008@2 {
  244. + compatible = "mcp3008";
  245. + reg = <2>;
  246. + spi-max-frequency = <1600000>;
  247. + };
  248. + };
  249. + };
  250. +
  251. + __overrides__ {
  252. + spi0-0-present = <0>, "+0+8";
  253. + spi0-1-present = <0>, "+1+9";
  254. + spi1-0-present = <0>, "+2+10";
  255. + spi1-1-present = <0>, "+3+11";
  256. + spi1-2-present = <0>, "+4+12";
  257. + spi2-0-present = <0>, "+5+13";
  258. + spi2-1-present = <0>, "+6+14";
  259. + spi2-2-present = <0>, "+7+15";
  260. + spi0-0-speed = <&mcp3008_00>, "spi-max-frequency:0";
  261. + spi0-1-speed = <&mcp3008_01>, "spi-max-frequency:0";
  262. + spi1-0-speed = <&mcp3008_10>, "spi-max-frequency:0";
  263. + spi1-1-speed = <&mcp3008_11>, "spi-max-frequency:0";
  264. + spi1-2-speed = <&mcp3008_12>, "spi-max-frequency:0";
  265. + spi2-0-speed = <&mcp3008_20>, "spi-max-frequency:0";
  266. + spi2-1-speed = <&mcp3008_21>, "spi-max-frequency:0";
  267. + spi2-2-speed = <&mcp3008_22>, "spi-max-frequency:0";
  268. + };
  269. +};