0064-Adding-Device-Tree-support-for-some-RPi-audio-cards.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. From 5f17e24bea60b696815d2c6cb578e1e23f61cd57 Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Wed, 12 Nov 2014 17:07:02 +0000
  4. Subject: [PATCH 064/114] Adding Device Tree support for some RPi audio cards
  5. ---
  6. arch/arm/boot/dts/Makefile | 2 +
  7. arch/arm/boot/dts/bcm2708-rpi-b-plus.dts | 81 +++++++++++++++++++++++++
  8. arch/arm/boot/dts/bcm2708-rpi-b.dts | 19 +++++-
  9. arch/arm/boot/dts/bcm2708.dtsi | 18 ++++--
  10. arch/arm/boot/dts/hifiberry-dac-overlay.dts | 34 +++++++++++
  11. arch/arm/boot/dts/hifiberry-dacplus-overlay.dts | 39 ++++++++++++
  12. arch/arm/boot/dts/hifiberry-digi-overlay.dts | 39 ++++++++++++
  13. arch/arm/boot/dts/iqaudio-dac-overlay.dts | 39 ++++++++++++
  14. arch/arm/boot/dts/iqaudio-dacplus-overlay.dts | 39 ++++++++++++
  15. sound/soc/bcm/hifiberry_dac.c | 22 +++++++
  16. sound/soc/bcm/hifiberry_dacplus.c | 22 +++++++
  17. sound/soc/bcm/hifiberry_digi.c | 22 +++++++
  18. sound/soc/bcm/iqaudio-dac.c | 16 +++++
  19. sound/soc/codecs/pcm5102a.c | 7 +++
  20. 14 files changed, 393 insertions(+), 6 deletions(-)
  21. create mode 100644 arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
  22. create mode 100644 arch/arm/boot/dts/hifiberry-dac-overlay.dts
  23. create mode 100644 arch/arm/boot/dts/hifiberry-dacplus-overlay.dts
  24. create mode 100644 arch/arm/boot/dts/hifiberry-digi-overlay.dts
  25. create mode 100644 arch/arm/boot/dts/iqaudio-dac-overlay.dts
  26. create mode 100644 arch/arm/boot/dts/iqaudio-dacplus-overlay.dts
  27. --- a/arch/arm/boot/dts/Makefile
  28. +++ b/arch/arm/boot/dts/Makefile
  29. @@ -54,6 +54,7 @@ dtb-$(CONFIG_ARCH_AT91) += at91-sama5d4e
  30. dtb-$(CONFIG_ARCH_ATLAS6) += atlas6-evb.dtb
  31. dtb-$(CONFIG_ARCH_AXXIA) += axm5516-amarillo.dtb
  32. dtb-$(CONFIG_BCM2708_DT) += bcm2708-rpi-b.dtb
  33. +dtb-$(CONFIG_BCM2708_DT) += bcm2708-rpi-b-plus.dtb
  34. dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
  35. dtb-$(CONFIG_ARCH_BCM_5301X) += bcm4708-netgear-r6250.dtb
  36. dtb-$(CONFIG_ARCH_BCM_63XX) += bcm963138dvt.dtb
  37. @@ -520,6 +521,7 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt6589-aq
  38. targets += dtbs dtbs_install
  39. targets += $(dtb-y)
  40. +
  41. endif
  42. # *.dtb used to be generated in the directory above. Clean out the
  43. --- /dev/null
  44. +++ b/arch/arm/boot/dts/bcm2708-rpi-b-plus.dts
  45. @@ -0,0 +1,81 @@
  46. +/dts-v1/;
  47. +
  48. +/include/ "bcm2708.dtsi"
  49. +
  50. +/ {
  51. + compatible = "brcm,bcm2708";
  52. + model = "Raspberry Pi Model B+";
  53. +
  54. + aliases {
  55. + spi0 = &spi0;
  56. + i2c0 = &i2c0;
  57. + i2c1 = &i2c1;
  58. + i2s = &i2s;
  59. + gpio = &gpio;
  60. + sound = &sound;
  61. + };
  62. +
  63. + sound: sound {
  64. + };
  65. +};
  66. +
  67. +&gpio {
  68. + spi0_pins: spi0_pins {
  69. + brcm,pins = <7 8 9 10 11>;
  70. + brcm,function = <4>; /* alt0 */
  71. + };
  72. +
  73. + i2c0_pins: i2c0 {
  74. + brcm,pins = <0 1>;
  75. + brcm,function = <4>;
  76. + };
  77. +
  78. + i2c1_pins: i2c1 {
  79. + brcm,pins = <2 3>;
  80. + brcm,function = <4>;
  81. + };
  82. +
  83. + i2s_pins: i2s {
  84. + brcm,pins = <18 19 20 21>;
  85. + brcm,function = <4>; /* alt0 */
  86. + };
  87. +};
  88. +
  89. +&spi0 {
  90. + pinctrl-names = "default";
  91. + pinctrl-0 = <&spi0_pins>;
  92. +
  93. + spidev@0{
  94. + compatible = "spidev";
  95. + reg = <0>; /* CE0 */
  96. + #address-cells = <1>;
  97. + #size-cells = <0>;
  98. + spi-max-frequency = <500000>;
  99. + };
  100. +
  101. + spidev@1{
  102. + compatible = "spidev";
  103. + reg = <1>; /* CE1 */
  104. + #address-cells = <1>;
  105. + #size-cells = <0>;
  106. + spi-max-frequency = <500000>;
  107. + };
  108. +};
  109. +
  110. +&i2c0 {
  111. + pinctrl-names = "default";
  112. + pinctrl-0 = <&i2c0_pins>;
  113. + clock-frequency = <100000>;
  114. +};
  115. +
  116. +&i2c1 {
  117. + pinctrl-names = "default";
  118. + pinctrl-0 = <&i2c1_pins>;
  119. + clock-frequency = <100000>;
  120. +};
  121. +
  122. +&i2s {
  123. + #sound-dai-cells = <0>;
  124. + pinctrl-names = "default";
  125. + pinctrl-0 = <&i2s_pins>;
  126. +};
  127. --- a/arch/arm/boot/dts/bcm2708-rpi-b.dts
  128. +++ b/arch/arm/boot/dts/bcm2708-rpi-b.dts
  129. @@ -4,12 +4,18 @@
  130. / {
  131. compatible = "brcm,bcm2708";
  132. - model = "Raspberry Pi";
  133. + model = "Raspberry Pi Model B";
  134. aliases {
  135. spi0 = &spi0;
  136. i2c0 = &i2c0;
  137. i2c1 = &i2c1;
  138. + i2s = &i2s;
  139. + gpio = &gpio;
  140. + sound = &sound;
  141. + };
  142. +
  143. + sound: sound {
  144. };
  145. };
  146. @@ -28,6 +34,11 @@
  147. brcm,pins = <2 3>;
  148. brcm,function = <4>;
  149. };
  150. +
  151. + i2s_pins: i2s {
  152. + brcm,pins = <28 29 30 31>;
  153. + brcm,function = <4>; /* alt0 */
  154. + };
  155. };
  156. &spi0 {
  157. @@ -62,3 +73,9 @@
  158. pinctrl-0 = <&i2c1_pins>;
  159. clock-frequency = <100000>;
  160. };
  161. +
  162. +&i2s {
  163. + #sound-dai-cells = <0>;
  164. + pinctrl-names = "default";
  165. + pinctrl-0 = <&i2s_pins>;
  166. +};
  167. --- a/arch/arm/boot/dts/bcm2708.dtsi
  168. +++ b/arch/arm/boot/dts/bcm2708.dtsi
  169. @@ -7,11 +7,8 @@
  170. interrupt-parent = <&intc>;
  171. chosen {
  172. - /*
  173. - bootargs must be 1024 characters long because the
  174. - VC bootloader can't expand it
  175. - */
  176. - bootargs = "console=ttyAMA0 ";
  177. + /* No padding required - the boot loader can do that. */
  178. + bootargs = "";
  179. };
  180. soc {
  181. @@ -39,6 +36,17 @@
  182. #interrupt-cells = <2>;
  183. };
  184. + i2s: i2s@7e203000 {
  185. + compatible = "brcm,bcm2708-i2s";
  186. + reg = <0x7e203000 0x20>,
  187. + <0x7e101098 0x02>;
  188. +
  189. + //dmas = <&dma 2>,
  190. + // <&dma 3>;
  191. + dma-names = "tx", "rx";
  192. + status = "disabled";
  193. + };
  194. +
  195. spi0: spi@7e204000 {
  196. compatible = "brcm,bcm2708-spi";
  197. reg = <0x7e204000 0x1000>;
  198. --- /dev/null
  199. +++ b/arch/arm/boot/dts/hifiberry-dac-overlay.dts
  200. @@ -0,0 +1,34 @@
  201. +// Definitions for HiFiBerry DAC
  202. +/dts-v1/;
  203. +/plugin/;
  204. +
  205. +/ {
  206. + compatible = "brcm,bcm2708";
  207. +
  208. + fragment@0 {
  209. + target = <&sound>;
  210. + __overlay__ {
  211. + compatible = "hifiberry,hifiberry-dac";
  212. + i2s-controller = <&i2s>;
  213. + status = "okay";
  214. + };
  215. + };
  216. +
  217. + fragment@1 {
  218. + target = <&i2s>;
  219. + __overlay__ {
  220. + status = "okay";
  221. + };
  222. + };
  223. +
  224. + fragment@2 {
  225. + target-path = "/";
  226. + __overlay__ {
  227. + pcm5102a-codec {
  228. + #sound-dai-cells = <0>;
  229. + compatible = "ti,pcm5102a";
  230. + status = "okay";
  231. + };
  232. + };
  233. + };
  234. +};
  235. --- /dev/null
  236. +++ b/arch/arm/boot/dts/hifiberry-dacplus-overlay.dts
  237. @@ -0,0 +1,39 @@
  238. +// Definitions for HiFiBerry DAC+
  239. +/dts-v1/;
  240. +/plugin/;
  241. +
  242. +/ {
  243. + compatible = "brcm,bcm2708";
  244. +
  245. + fragment@0 {
  246. + target = <&sound>;
  247. + __overlay__ {
  248. + compatible = "hifiberry,hifiberry-dacplus";
  249. + i2s-controller = <&i2s>;
  250. + status = "okay";
  251. + };
  252. + };
  253. +
  254. + fragment@1 {
  255. + target = <&i2s>;
  256. + __overlay__ {
  257. + status = "okay";
  258. + };
  259. + };
  260. +
  261. + fragment@2 {
  262. + target = <&i2c1>;
  263. + __overlay__ {
  264. + #address-cells = <1>;
  265. + #size-cells = <0>;
  266. + status = "okay";
  267. +
  268. + pcm5122@4d {
  269. + #sound-dai-cells = <0>;
  270. + compatible = "ti,pcm5122";
  271. + reg = <0x4d>;
  272. + status = "okay";
  273. + };
  274. + };
  275. + };
  276. +};
  277. --- /dev/null
  278. +++ b/arch/arm/boot/dts/hifiberry-digi-overlay.dts
  279. @@ -0,0 +1,39 @@
  280. +// Definitions for HiFiBerry Digi
  281. +/dts-v1/;
  282. +/plugin/;
  283. +
  284. +/ {
  285. + compatible = "brcm,bcm2708";
  286. +
  287. + fragment@0 {
  288. + target = <&sound>;
  289. + __overlay__ {
  290. + compatible = "hifiberry,hifiberry-digi";
  291. + i2s-controller = <&i2s>;
  292. + status = "okay";
  293. + };
  294. + };
  295. +
  296. + fragment@1 {
  297. + target = <&i2s>;
  298. + __overlay__ {
  299. + status = "okay";
  300. + };
  301. + };
  302. +
  303. + fragment@2 {
  304. + target = <&i2c1>;
  305. + __overlay__ {
  306. + #address-cells = <1>;
  307. + #size-cells = <0>;
  308. + status = "okay";
  309. +
  310. + wm8804@3b {
  311. + #sound-dai-cells = <0>;
  312. + compatible = "wlf,wm8804";
  313. + reg = <0x3b>;
  314. + status = "okay";
  315. + };
  316. + };
  317. + };
  318. +};
  319. --- /dev/null
  320. +++ b/arch/arm/boot/dts/iqaudio-dac-overlay.dts
  321. @@ -0,0 +1,39 @@
  322. +// Definitions for IQaudIO DAC
  323. +/dts-v1/;
  324. +/plugin/;
  325. +
  326. +/ {
  327. + compatible = "brcm,bcm2708";
  328. +
  329. + fragment@0 {
  330. + target = <&sound>;
  331. + __overlay__ {
  332. + compatible = "iqaudio,iqaudio-dac";
  333. + i2s-controller = <&i2s>;
  334. + status = "okay";
  335. + };
  336. + };
  337. +
  338. + fragment@1 {
  339. + target = <&i2s>;
  340. + __overlay__ {
  341. + status = "okay";
  342. + };
  343. + };
  344. +
  345. + fragment@2 {
  346. + target = <&i2c1>;
  347. + __overlay__ {
  348. + #address-cells = <1>;
  349. + #size-cells = <0>;
  350. + status = "okay";
  351. +
  352. + pcm5122@4c {
  353. + #sound-dai-cells = <0>;
  354. + compatible = "ti,pcm5122";
  355. + reg = <0x4c>;
  356. + status = "okay";
  357. + };
  358. + };
  359. + };
  360. +};
  361. --- /dev/null
  362. +++ b/arch/arm/boot/dts/iqaudio-dacplus-overlay.dts
  363. @@ -0,0 +1,39 @@
  364. +// Definitions for IQaudIO DAC+
  365. +/dts-v1/;
  366. +/plugin/;
  367. +
  368. +/ {
  369. + compatible = "brcm,bcm2708";
  370. +
  371. + fragment@0 {
  372. + target = <&sound>;
  373. + __overlay__ {
  374. + compatible = "iqaudio,iqaudio-dac";
  375. + i2s-controller = <&i2s>;
  376. + status = "okay";
  377. + };
  378. + };
  379. +
  380. + fragment@1 {
  381. + target = <&i2s>;
  382. + __overlay__ {
  383. + status = "okay";
  384. + };
  385. + };
  386. +
  387. + fragment@2 {
  388. + target = <&i2c1>;
  389. + __overlay__ {
  390. + #address-cells = <1>;
  391. + #size-cells = <0>;
  392. + status = "okay";
  393. +
  394. + pcm5122@4c {
  395. + #sound-dai-cells = <0>;
  396. + compatible = "ti,pcm5122";
  397. + reg = <0x4c>;
  398. + status = "okay";
  399. + };
  400. + };
  401. + };
  402. +};
  403. --- a/sound/soc/bcm/hifiberry_dac.c
  404. +++ b/sound/soc/bcm/hifiberry_dac.c
  405. @@ -72,6 +72,21 @@ static int snd_rpi_hifiberry_dac_probe(s
  406. int ret = 0;
  407. snd_rpi_hifiberry_dac.dev = &pdev->dev;
  408. +
  409. + if (pdev->dev.of_node) {
  410. + struct device_node *i2s_node;
  411. + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dac_dai[0];
  412. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  413. + "i2s-controller", 0);
  414. +
  415. + if (i2s_node) {
  416. + dai->cpu_dai_name = NULL;
  417. + dai->cpu_of_node = i2s_node;
  418. + dai->platform_name = NULL;
  419. + dai->platform_of_node = i2s_node;
  420. + }
  421. + }
  422. +
  423. ret = snd_soc_register_card(&snd_rpi_hifiberry_dac);
  424. if (ret)
  425. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
  426. @@ -84,10 +99,17 @@ static int snd_rpi_hifiberry_dac_remove(
  427. return snd_soc_unregister_card(&snd_rpi_hifiberry_dac);
  428. }
  429. +static const struct of_device_id snd_rpi_hifiberry_dac_of_match[] = {
  430. + { .compatible = "hifiberry,hifiberry-dac", },
  431. + {},
  432. +};
  433. +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dac_of_match);
  434. +
  435. static struct platform_driver snd_rpi_hifiberry_dac_driver = {
  436. .driver = {
  437. .name = "snd-hifiberry-dac",
  438. .owner = THIS_MODULE,
  439. + .of_match_table = snd_rpi_hifiberry_dac_of_match,
  440. },
  441. .probe = snd_rpi_hifiberry_dac_probe,
  442. .remove = snd_rpi_hifiberry_dac_remove,
  443. --- a/sound/soc/bcm/hifiberry_dacplus.c
  444. +++ b/sound/soc/bcm/hifiberry_dacplus.c
  445. @@ -90,6 +90,21 @@ static int snd_rpi_hifiberry_dacplus_pro
  446. int ret = 0;
  447. snd_rpi_hifiberry_dacplus.dev = &pdev->dev;
  448. +
  449. + if (pdev->dev.of_node) {
  450. + struct device_node *i2s_node;
  451. + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_dacplus_dai[0];
  452. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  453. + "i2s-controller", 0);
  454. +
  455. + if (i2s_node) {
  456. + dai->cpu_dai_name = NULL;
  457. + dai->cpu_of_node = i2s_node;
  458. + dai->platform_name = NULL;
  459. + dai->platform_of_node = i2s_node;
  460. + }
  461. + }
  462. +
  463. ret = snd_soc_register_card(&snd_rpi_hifiberry_dacplus);
  464. if (ret)
  465. dev_err(&pdev->dev,
  466. @@ -103,10 +118,17 @@ static int snd_rpi_hifiberry_dacplus_rem
  467. return snd_soc_unregister_card(&snd_rpi_hifiberry_dacplus);
  468. }
  469. +static const struct of_device_id snd_rpi_hifiberry_dacplus_of_match[] = {
  470. + { .compatible = "hifiberry,hifiberry-dacplus", },
  471. + {},
  472. +};
  473. +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_dacplus_of_match);
  474. +
  475. static struct platform_driver snd_rpi_hifiberry_dacplus_driver = {
  476. .driver = {
  477. .name = "snd-rpi-hifiberry-dacplus",
  478. .owner = THIS_MODULE,
  479. + .of_match_table = snd_rpi_hifiberry_dacplus_of_match,
  480. },
  481. .probe = snd_rpi_hifiberry_dacplus_probe,
  482. .remove = snd_rpi_hifiberry_dacplus_remove,
  483. --- a/sound/soc/bcm/hifiberry_digi.c
  484. +++ b/sound/soc/bcm/hifiberry_digi.c
  485. @@ -125,6 +125,21 @@ static int snd_rpi_hifiberry_digi_probe(
  486. int ret = 0;
  487. snd_rpi_hifiberry_digi.dev = &pdev->dev;
  488. +
  489. + if (pdev->dev.of_node) {
  490. + struct device_node *i2s_node;
  491. + struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_digi_dai[0];
  492. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  493. + "i2s-controller", 0);
  494. +
  495. + if (i2s_node) {
  496. + dai->cpu_dai_name = NULL;
  497. + dai->cpu_of_node = i2s_node;
  498. + dai->platform_name = NULL;
  499. + dai->platform_of_node = i2s_node;
  500. + }
  501. + }
  502. +
  503. ret = snd_soc_register_card(&snd_rpi_hifiberry_digi);
  504. if (ret)
  505. dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
  506. @@ -137,10 +152,17 @@ static int snd_rpi_hifiberry_digi_remove
  507. return snd_soc_unregister_card(&snd_rpi_hifiberry_digi);
  508. }
  509. +static const struct of_device_id snd_rpi_hifiberry_digi_of_match[] = {
  510. + { .compatible = "hifiberry,hifiberry-digi", },
  511. + {},
  512. +};
  513. +MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_digi_of_match);
  514. +
  515. static struct platform_driver snd_rpi_hifiberry_digi_driver = {
  516. .driver = {
  517. .name = "snd-hifiberry-digi",
  518. .owner = THIS_MODULE,
  519. + .of_match_table = snd_rpi_hifiberry_digi_of_match,
  520. },
  521. .probe = snd_rpi_hifiberry_digi_probe,
  522. .remove = snd_rpi_hifiberry_digi_remove,
  523. --- a/sound/soc/bcm/iqaudio-dac.c
  524. +++ b/sound/soc/bcm/iqaudio-dac.c
  525. @@ -76,6 +76,21 @@ static int snd_rpi_iqaudio_dac_probe(str
  526. int ret = 0;
  527. snd_rpi_iqaudio_dac.dev = &pdev->dev;
  528. +
  529. + if (pdev->dev.of_node) {
  530. + struct device_node *i2s_node;
  531. + struct snd_soc_dai_link *dai = &snd_rpi_iqaudio_dac_dai[0];
  532. + i2s_node = of_parse_phandle(pdev->dev.of_node,
  533. + "i2s-controller", 0);
  534. +
  535. + if (i2s_node) {
  536. + dai->cpu_dai_name = NULL;
  537. + dai->cpu_of_node = i2s_node;
  538. + dai->platform_name = NULL;
  539. + dai->platform_of_node = i2s_node;
  540. + }
  541. + }
  542. +
  543. ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);
  544. if (ret)
  545. dev_err(&pdev->dev,
  546. @@ -93,6 +108,7 @@ static const struct of_device_id iqaudio
  547. { .compatible = "iqaudio,iqaudio-dac", },
  548. {},
  549. };
  550. +MODULE_DEVICE_TABLE(of, iqaudio_of_match);
  551. static struct platform_driver snd_rpi_iqaudio_dac_driver = {
  552. .driver = {
  553. --- a/sound/soc/codecs/pcm5102a.c
  554. +++ b/sound/soc/codecs/pcm5102a.c
  555. @@ -47,12 +47,19 @@ static int pcm5102a_remove(struct platfo
  556. return 0;
  557. }
  558. +static const struct of_device_id pcm5102a_of_match[] = {
  559. + { .compatible = "ti,pcm5102a", },
  560. + { }
  561. +};
  562. +MODULE_DEVICE_TABLE(of, pcm5102a_of_match);
  563. +
  564. static struct platform_driver pcm5102a_codec_driver = {
  565. .probe = pcm5102a_probe,
  566. .remove = pcm5102a_remove,
  567. .driver = {
  568. .name = "pcm5102a-codec",
  569. .owner = THIS_MODULE,
  570. + .of_match_table = pcm5102a_of_match,
  571. },
  572. };