0527-Support-for-Blokas-Labs-pisound-board.patch 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. From 1c20ff1871ce0edc2d4c71a1eb4591cb4e8912e9 Mon Sep 17 00:00:00 2001
  2. From: gtrainavicius <gtrainavicius@users.noreply.github.com>
  3. Date: Sun, 23 Oct 2016 12:06:53 +0300
  4. Subject: [PATCH] Support for Blokas Labs pisound board
  5. ---
  6. .../devicetree/bindings/vendor-prefixes.txt | 1 +
  7. arch/arm/boot/dts/overlays/Makefile | 1 +
  8. arch/arm/boot/dts/overlays/README | 6 +
  9. arch/arm/boot/dts/overlays/pisound-overlay.dts | 114 +++
  10. arch/arm/configs/bcm2709_defconfig | 1 +
  11. arch/arm/configs/bcmrpi_defconfig | 1 +
  12. sound/soc/bcm/Kconfig | 6 +
  13. sound/soc/bcm/Makefile | 2 +
  14. sound/soc/bcm/pisound.c | 987 +++++++++++++++++++++
  15. 9 files changed, 1119 insertions(+)
  16. create mode 100644 arch/arm/boot/dts/overlays/pisound-overlay.dts
  17. create mode 100644 sound/soc/bcm/pisound.c
  18. --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
  19. +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
  20. @@ -34,6 +34,7 @@ avago Avago Technologies
  21. avia avia semiconductor
  22. avic Shanghai AVIC Optoelectronics Co., Ltd.
  23. axis Axis Communications AB
  24. +blokaslabs Vilniaus Blokas UAB
  25. bosch Bosch Sensortec GmbH
  26. boundary Boundary Devices Inc.
  27. brcm Broadcom Corporation
  28. --- a/arch/arm/boot/dts/overlays/Makefile
  29. +++ b/arch/arm/boot/dts/overlays/Makefile
  30. @@ -62,6 +62,7 @@ dtbo-$(RPI_DT_OVERLAYS) += pi3-disable-b
  31. dtbo-$(RPI_DT_OVERLAYS) += pi3-miniuart-bt.dtbo
  32. dtbo-$(RPI_DT_OVERLAYS) += piscreen.dtbo
  33. dtbo-$(RPI_DT_OVERLAYS) += piscreen2r.dtbo
  34. +dtbo-$(RPI_DT_OVERLAYS) += pisound.dtbo
  35. dtbo-$(RPI_DT_OVERLAYS) += pitft22.dtbo
  36. dtbo-$(RPI_DT_OVERLAYS) += pitft28-capacitive.dtbo
  37. dtbo-$(RPI_DT_OVERLAYS) += pitft28-resistive.dtbo
  38. --- a/arch/arm/boot/dts/overlays/README
  39. +++ b/arch/arm/boot/dts/overlays/README
  40. @@ -808,6 +808,12 @@ Params: speed Display
  41. xohms Touchpanel sensitivity (X-plate resistance)
  42. +Name: pisound
  43. +Info: Configures the Blokas Labs pisound card
  44. +Load: dtoverlay=pisound
  45. +Params: <None>
  46. +
  47. +
  48. Name: pitft22
  49. Info: Adafruit PiTFT 2.2" screen
  50. Load: dtoverlay=pitft22,<param>=<val>
  51. --- /dev/null
  52. +++ b/arch/arm/boot/dts/overlays/pisound-overlay.dts
  53. @@ -0,0 +1,114 @@
  54. +/*
  55. + * pisound Linux kernel module.
  56. + * Copyright (C) 2016 Vilniaus Blokas UAB, http://blokas.io/pisound
  57. + *
  58. + * This program is free software; you can redistribute it and/or
  59. + * modify it under the terms of the GNU General Public License
  60. + * as published by the Free Software Foundation; version 2 of the
  61. + * License.
  62. + *
  63. + * This program is distributed in the hope that it will be useful,
  64. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  65. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  66. + * GNU General Public License for more details.
  67. + *
  68. + * You should have received a copy of the GNU General Public License
  69. + * along with this program; if not, write to the Free Software
  70. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  71. + */
  72. +
  73. +/dts-v1/;
  74. +/plugin/;
  75. +
  76. +#include <dt-bindings/gpio/gpio.h>
  77. +
  78. +/ {
  79. + compatible = "brcm,bcm2708";
  80. +
  81. + fragment@0 {
  82. + target = <&sound>;
  83. + __overlay__ {
  84. + compatible = "blokaslabs,pisound";
  85. + i2s-controller = <&i2s>;
  86. + status = "okay";
  87. +
  88. + pinctrl-0 = <&pisound_button_pins>;
  89. +
  90. + osr-gpios =
  91. + <&gpio 13 GPIO_ACTIVE_HIGH>,
  92. + <&gpio 26 GPIO_ACTIVE_HIGH>,
  93. + <&gpio 16 GPIO_ACTIVE_HIGH>;
  94. +
  95. + reset-gpios =
  96. + <&gpio 12 GPIO_ACTIVE_HIGH>,
  97. + <&gpio 24 GPIO_ACTIVE_HIGH>;
  98. +
  99. + data_available-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>;
  100. +
  101. + button-gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
  102. + };
  103. + };
  104. +
  105. + fragment@1 {
  106. + target = <&gpio>;
  107. + __overlay__ {
  108. + pinctrl-names = "default";
  109. + pinctrl-0 = <&pisound_button_pins>;
  110. +
  111. + pisound_button_pins: pisound_button_pins {
  112. + brcm,pins = <17>;
  113. + brcm,function = <0>; // Input
  114. + brcm,pull = <2>; // Pull-Up
  115. + };
  116. + };
  117. + };
  118. +
  119. + fragment@2 {
  120. + target = <&i2s>;
  121. + __overlay__ {
  122. + status = "okay";
  123. + };
  124. + };
  125. +
  126. + fragment@3 {
  127. + target-path = "/";
  128. + __overlay__ {
  129. + pcm5102a-codec {
  130. + #sound-dai-cells = <0>;
  131. + compatible = "ti,pcm5102a";
  132. + status = "okay";
  133. + };
  134. + };
  135. + };
  136. +
  137. + fragment@4 {
  138. + target = <&spi0>;
  139. + __overlay__ {
  140. + status = "okay";
  141. +
  142. + spidev@0{
  143. + status = "disabled";
  144. + };
  145. +
  146. + spidev@1{
  147. + status = "okay";
  148. + };
  149. + };
  150. + };
  151. +
  152. + fragment@5 {
  153. + target = <&spi0>;
  154. + __overlay__ {
  155. + #address-cells = <1>;
  156. + #size-cells = <0>;
  157. +
  158. + pisound_spi: pisound_spi@0{
  159. + compatible = "blokaslabs,pisound-spi";
  160. + reg = <0>;
  161. + pinctrl-names = "default";
  162. + pinctrl-0 = <&spi0_pins>;
  163. + spi-max-frequency = <1000000>;
  164. + };
  165. + };
  166. + };
  167. +};
  168. --- a/arch/arm/configs/bcm2709_defconfig
  169. +++ b/arch/arm/configs/bcm2709_defconfig
  170. @@ -880,6 +880,7 @@ CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
  171. CONFIG_SND_DIGIDAC1_SOUNDCARD=m
  172. CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO=m
  173. CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m
  174. +CONFIG_SND_PISOUND=m
  175. CONFIG_SND_SOC_ADAU1701=m
  176. CONFIG_SND_SOC_WM8804_I2C=m
  177. CONFIG_SND_SIMPLE_CARD=m
  178. --- a/arch/arm/configs/bcmrpi_defconfig
  179. +++ b/arch/arm/configs/bcmrpi_defconfig
  180. @@ -872,6 +872,7 @@ CONFIG_SND_AUDIOINJECTOR_PI_SOUNDCARD=m
  181. CONFIG_SND_DIGIDAC1_SOUNDCARD=m
  182. CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO=m
  183. CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC=m
  184. +CONFIG_SND_PISOUND=m
  185. CONFIG_SND_SOC_ADAU1701=m
  186. CONFIG_SND_SOC_WM8804_I2C=m
  187. CONFIG_SND_SIMPLE_CARD=m
  188. --- a/sound/soc/bcm/Kconfig
  189. +++ b/sound/soc/bcm/Kconfig
  190. @@ -121,3 +121,9 @@ config SND_BCM2708_SOC_ALLO_PIANO_DAC
  191. select SND_SOC_PCM512x_I2C
  192. help
  193. Say Y or M if you want to add support for Allo Piano DAC.
  194. +
  195. +config SND_PISOUND
  196. + tristate "Support for Blokas Labs pisound"
  197. + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
  198. + help
  199. + Say Y or M if you want to add support for Blokas Labs pisound.
  200. --- a/sound/soc/bcm/Makefile
  201. +++ b/sound/soc/bcm/Makefile
  202. @@ -20,6 +20,7 @@ snd-soc-audioinjector-pi-soundcard-objs
  203. snd-soc-digidac1-soundcard-objs := digidac1-soundcard.o
  204. snd-soc-dionaudio-loco-objs := dionaudio_loco.o
  205. snd-soc-allo-piano-dac-objs := allo-piano-dac.o
  206. +snd-soc-pisound-objs := pisound.o
  207. obj-$(CONFIG_SND_BCM2708_SOC_ADAU1977_ADC) += snd-soc-adau1977-adc.o
  208. obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
  209. @@ -37,3 +38,4 @@ obj-$(CONFIG_SND_AUDIOINJECTOR_PI_SOUNDC
  210. obj-$(CONFIG_SND_DIGIDAC1_SOUNDCARD) += snd-soc-digidac1-soundcard.o
  211. obj-$(CONFIG_SND_BCM2708_SOC_DIONAUDIO_LOCO) += snd-soc-dionaudio-loco.o
  212. obj-$(CONFIG_SND_BCM2708_SOC_ALLO_PIANO_DAC) += snd-soc-allo-piano-dac.o
  213. +obj-$(CONFIG_SND_PISOUND) += snd-soc-pisound.o
  214. --- /dev/null
  215. +++ b/sound/soc/bcm/pisound.c
  216. @@ -0,0 +1,987 @@
  217. +/*
  218. + * pisound Linux kernel module.
  219. + * Copyright (C) 2016 Vilniaus Blokas UAB, http://blokas.io/pisound
  220. + *
  221. + * This program is free software; you can redistribute it and/or
  222. + * modify it under the terms of the GNU General Public License
  223. + * as published by the Free Software Foundation; version 2 of the
  224. + * License.
  225. + *
  226. + * This program is distributed in the hope that it will be useful,
  227. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  228. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  229. + * GNU General Public License for more details.
  230. + *
  231. + * You should have received a copy of the GNU General Public License
  232. + * along with this program; if not, write to the Free Software
  233. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  234. + * MA 02110-1301, USA.
  235. + */
  236. +
  237. +#include <linux/init.h>
  238. +#include <linux/module.h>
  239. +#include <linux/platform_device.h>
  240. +#include <linux/gpio.h>
  241. +#include <linux/kobject.h>
  242. +#include <linux/sysfs.h>
  243. +#include <linux/delay.h>
  244. +#include <linux/spi/spi.h>
  245. +#include <linux/interrupt.h>
  246. +#include <linux/kfifo.h>
  247. +
  248. +#include <sound/core.h>
  249. +#include <sound/pcm.h>
  250. +#include <sound/pcm_params.h>
  251. +#include <sound/soc.h>
  252. +#include <sound/jack.h>
  253. +#include <sound/rawmidi.h>
  254. +#include <sound/asequencer.h>
  255. +
  256. +static int pisnd_spi_init(struct device *dev);
  257. +static void pisnd_spi_uninit(void);
  258. +
  259. +static void pisnd_spi_send(uint8_t val);
  260. +static uint8_t pisnd_spi_recv(uint8_t *buffer, uint8_t length);
  261. +
  262. +typedef void (*pisnd_spi_recv_cb)(void *data);
  263. +static void pisnd_spi_set_callback(pisnd_spi_recv_cb cb, void *data);
  264. +
  265. +static const char *pisnd_spi_get_serial(void);
  266. +static const char *pisnd_spi_get_id(void);
  267. +static const char *pisnd_spi_get_version(void);
  268. +
  269. +static int pisnd_midi_init(struct snd_card *card);
  270. +static void pisnd_midi_uninit(void);
  271. +
  272. +#define PISOUND_LOG_PREFIX "pisound: "
  273. +
  274. +#ifdef DEBUG
  275. +# define printd(...) pr_alert(PISOUND_LOG_PREFIX __VA_ARGS__)
  276. +#else
  277. +# define printd(...) do {} while (0)
  278. +#endif
  279. +
  280. +#define printe(...) pr_err(PISOUND_LOG_PREFIX __VA_ARGS__)
  281. +#define printi(...) pr_info(PISOUND_LOG_PREFIX __VA_ARGS__)
  282. +
  283. +static int pisnd_output_open(struct snd_rawmidi_substream *substream)
  284. +{
  285. + return 0;
  286. +}
  287. +
  288. +static int pisnd_output_close(struct snd_rawmidi_substream *substream)
  289. +{
  290. + return 0;
  291. +}
  292. +
  293. +static void pisnd_output_trigger(
  294. + struct snd_rawmidi_substream *substream,
  295. + int up
  296. + )
  297. +{
  298. + uint8_t data;
  299. +
  300. + if (!up)
  301. + return;
  302. +
  303. + while (snd_rawmidi_transmit_peek(substream, &data, 1)) {
  304. + pisnd_spi_send(data);
  305. + snd_rawmidi_transmit_ack(substream, 1);
  306. + }
  307. +}
  308. +
  309. +static void pisnd_output_drain(struct snd_rawmidi_substream *substream)
  310. +{
  311. + uint8_t data;
  312. +
  313. + while (snd_rawmidi_transmit_peek(substream, &data, 1)) {
  314. + pisnd_spi_send(data);
  315. +
  316. + snd_rawmidi_transmit_ack(substream, 1);
  317. + }
  318. +}
  319. +
  320. +static int pisnd_input_open(struct snd_rawmidi_substream *substream)
  321. +{
  322. + return 0;
  323. +}
  324. +
  325. +static int pisnd_input_close(struct snd_rawmidi_substream *substream)
  326. +{
  327. + return 0;
  328. +}
  329. +
  330. +static void pisnd_midi_recv_callback(void *substream)
  331. +{
  332. + uint8_t data[128];
  333. + uint8_t n = 0;
  334. +
  335. + while ((n = pisnd_spi_recv(data, sizeof(data)))) {
  336. + int res = snd_rawmidi_receive(substream, data, n);
  337. + (void)res;
  338. + printd("midi recv 0x%02x, res = %d\n", data, res);
  339. + }
  340. +}
  341. +
  342. +static void pisnd_input_trigger(struct snd_rawmidi_substream *substream, int up)
  343. +{
  344. + if (up) {
  345. + pisnd_spi_set_callback(pisnd_midi_recv_callback, substream);
  346. + pisnd_midi_recv_callback(substream);
  347. + } else {
  348. + pisnd_spi_set_callback(NULL, NULL);
  349. + }
  350. +}
  351. +
  352. +static struct snd_rawmidi *g_rmidi;
  353. +
  354. +static struct snd_rawmidi_ops pisnd_output_ops = {
  355. + .open = pisnd_output_open,
  356. + .close = pisnd_output_close,
  357. + .trigger = pisnd_output_trigger,
  358. + .drain = pisnd_output_drain,
  359. +};
  360. +
  361. +static struct snd_rawmidi_ops pisnd_input_ops = {
  362. + .open = pisnd_input_open,
  363. + .close = pisnd_input_close,
  364. + .trigger = pisnd_input_trigger,
  365. +};
  366. +
  367. +static void pisnd_get_port_info(
  368. + struct snd_rawmidi *rmidi,
  369. + int number,
  370. + struct snd_seq_port_info *seq_port_info
  371. + )
  372. +{
  373. + seq_port_info->type =
  374. + SNDRV_SEQ_PORT_TYPE_MIDI_GENERIC |
  375. + SNDRV_SEQ_PORT_TYPE_HARDWARE |
  376. + SNDRV_SEQ_PORT_TYPE_PORT;
  377. + seq_port_info->midi_voices = 0;
  378. +}
  379. +
  380. +static struct snd_rawmidi_global_ops pisnd_global_ops = {
  381. + .get_port_info = pisnd_get_port_info,
  382. +};
  383. +
  384. +static int pisnd_midi_init(struct snd_card *card)
  385. +{
  386. + int err = snd_rawmidi_new(card, "pisound MIDI", 0, 1, 1, &g_rmidi);
  387. +
  388. + if (err < 0) {
  389. + printe("snd_rawmidi_new failed: %d\n", err);
  390. + return err;
  391. + }
  392. +
  393. + strcpy(g_rmidi->name, "pisound MIDI ");
  394. + strcat(g_rmidi->name, pisnd_spi_get_serial());
  395. +
  396. + g_rmidi->info_flags =
  397. + SNDRV_RAWMIDI_INFO_OUTPUT |
  398. + SNDRV_RAWMIDI_INFO_INPUT |
  399. + SNDRV_RAWMIDI_INFO_DUPLEX;
  400. +
  401. + g_rmidi->ops = &pisnd_global_ops;
  402. +
  403. + g_rmidi->private_data = (void *)0;
  404. +
  405. + snd_rawmidi_set_ops(
  406. + g_rmidi,
  407. + SNDRV_RAWMIDI_STREAM_OUTPUT,
  408. + &pisnd_output_ops
  409. + );
  410. +
  411. + snd_rawmidi_set_ops(
  412. + g_rmidi,
  413. + SNDRV_RAWMIDI_STREAM_INPUT,
  414. + &pisnd_input_ops
  415. + );
  416. +
  417. + return 0;
  418. +}
  419. +
  420. +static void pisnd_midi_uninit(void)
  421. +{
  422. +}
  423. +
  424. +static void *g_recvData;
  425. +static pisnd_spi_recv_cb g_recvCallback;
  426. +
  427. +#define FIFO_SIZE 512
  428. +
  429. +static char g_serial_num[11];
  430. +static char g_id[25];
  431. +static char g_version[5];
  432. +
  433. +DEFINE_KFIFO(spi_fifo_in, uint8_t, FIFO_SIZE);
  434. +DEFINE_KFIFO(spi_fifo_out, uint8_t, FIFO_SIZE);
  435. +
  436. +static struct gpio_desc *data_available;
  437. +static struct gpio_desc *spi_reset;
  438. +
  439. +static struct spi_device *pisnd_spi_device;
  440. +
  441. +static struct workqueue_struct *pisnd_workqueue;
  442. +static struct work_struct pisnd_work_process;
  443. +
  444. +static void pisnd_work_handler(struct work_struct *work);
  445. +
  446. +static uint16_t spi_transfer16(uint16_t val);
  447. +
  448. +static int pisnd_init_workqueues(void)
  449. +{
  450. + pisnd_workqueue = create_singlethread_workqueue("pisnd_workqueue");
  451. + INIT_WORK(&pisnd_work_process, pisnd_work_handler);
  452. +
  453. + return 0;
  454. +}
  455. +
  456. +static void pisnd_uninit_workqueues(void)
  457. +{
  458. + flush_workqueue(pisnd_workqueue);
  459. + destroy_workqueue(pisnd_workqueue);
  460. +
  461. + pisnd_workqueue = NULL;
  462. +}
  463. +
  464. +static bool pisnd_spi_has_more(void)
  465. +{
  466. + return gpiod_get_value(data_available);
  467. +}
  468. +
  469. +enum task_e {
  470. + TASK_PROCESS = 0,
  471. +};
  472. +
  473. +static void pisnd_schedule_process(enum task_e task)
  474. +{
  475. + if (pisnd_spi_device != NULL &&
  476. + pisnd_workqueue != NULL &&
  477. + !work_pending(&pisnd_work_process)
  478. + ) {
  479. + printd("schedule: has more = %d\n", pisnd_spi_has_more());
  480. + if (task == TASK_PROCESS)
  481. + queue_work(pisnd_workqueue, &pisnd_work_process);
  482. + }
  483. +}
  484. +
  485. +static irqreturn_t data_available_interrupt_handler(int irq, void *dev_id)
  486. +{
  487. + if (irq == gpiod_to_irq(data_available) && pisnd_spi_has_more()) {
  488. + printd("schedule from irq\n");
  489. + pisnd_schedule_process(TASK_PROCESS);
  490. + }
  491. +
  492. + return IRQ_HANDLED;
  493. +}
  494. +
  495. +static DEFINE_SPINLOCK(spilock);
  496. +static unsigned long spilockflags;
  497. +
  498. +static uint16_t spi_transfer16(uint16_t val)
  499. +{
  500. + int err;
  501. + struct spi_transfer transfer;
  502. + struct spi_message msg;
  503. + uint8_t txbuf[2];
  504. + uint8_t rxbuf[2];
  505. +
  506. + if (!pisnd_spi_device) {
  507. + printe("pisnd_spi_device null, returning\n");
  508. + return 0;
  509. + }
  510. +
  511. + spi_message_init(&msg);
  512. +
  513. + memset(&transfer, 0, sizeof(transfer));
  514. + memset(&rxbuf, 0, sizeof(rxbuf));
  515. +
  516. + txbuf[0] = val >> 8;
  517. + txbuf[1] = val & 0xff;
  518. +
  519. + transfer.tx_buf = &txbuf;
  520. + transfer.rx_buf = &rxbuf;
  521. + transfer.len = sizeof(txbuf);
  522. + transfer.speed_hz = 125000;
  523. + transfer.delay_usecs = 100;
  524. + spi_message_add_tail(&transfer, &msg);
  525. +
  526. + spin_lock_irqsave(&spilock, spilockflags);
  527. + err = spi_sync(pisnd_spi_device, &msg);
  528. + spin_unlock_irqrestore(&spilock, spilockflags);
  529. +
  530. + if (err < 0) {
  531. + printe("spi_sync error %d\n", err);
  532. + return 0;
  533. + }
  534. +
  535. + printd("received: %02x%02x\n", rxbuf[0], rxbuf[1]);
  536. + printd("hasMore %d\n", pisnd_spi_has_more());
  537. +
  538. + return (rxbuf[0] << 8) | rxbuf[1];
  539. +}
  540. +
  541. +static int spi_read_bytes(char *dst, size_t length, uint8_t *bytesRead)
  542. +{
  543. + uint16_t rx;
  544. + uint8_t size;
  545. + uint8_t i;
  546. +
  547. + memset(dst, 0, length);
  548. + *bytesRead = 0;
  549. +
  550. + rx = spi_transfer16(0);
  551. + if (!(rx >> 8))
  552. + return -EINVAL;
  553. +
  554. + size = rx & 0xff;
  555. +
  556. + if (size > length)
  557. + return -EINVAL;
  558. +
  559. + for (i = 0; i < size; ++i) {
  560. + rx = spi_transfer16(0);
  561. + if (!(rx >> 8))
  562. + return -EINVAL;
  563. +
  564. + dst[i] = rx & 0xff;
  565. + }
  566. +
  567. + *bytesRead = i;
  568. +
  569. + return 0;
  570. +}
  571. +
  572. +static int spi_device_match(struct device *dev, void *data)
  573. +{
  574. + struct spi_device *spi = container_of(dev, struct spi_device, dev);
  575. +
  576. + printd(" %s %s %dkHz %d bits mode=0x%02X\n",
  577. + spi->modalias, dev_name(dev), spi->max_speed_hz/1000,
  578. + spi->bits_per_word, spi->mode);
  579. +
  580. + if (strcmp("pisound-spi", spi->modalias) == 0) {
  581. + printi("\tFound!\n");
  582. + return 1;
  583. + }
  584. +
  585. + printe("\tNot found!\n");
  586. + return 0;
  587. +}
  588. +
  589. +static struct spi_device *pisnd_spi_find_device(void)
  590. +{
  591. + struct device *dev;
  592. +
  593. + printi("Searching for spi device...\n");
  594. + dev = bus_find_device(&spi_bus_type, NULL, NULL, spi_device_match);
  595. + if (dev != NULL)
  596. + return container_of(dev, struct spi_device, dev);
  597. + else
  598. + return NULL;
  599. +}
  600. +
  601. +static void pisnd_work_handler(struct work_struct *work)
  602. +{
  603. + uint16_t rx;
  604. + uint16_t tx;
  605. + uint8_t val;
  606. +
  607. + if (work == &pisnd_work_process) {
  608. + if (pisnd_spi_device == NULL)
  609. + return;
  610. +
  611. + do {
  612. + val = 0;
  613. + tx = 0;
  614. +
  615. + if (kfifo_get(&spi_fifo_out, &val))
  616. + tx = 0x0f00 | val;
  617. +
  618. + rx = spi_transfer16(tx);
  619. +
  620. + if (rx & 0xff00) {
  621. + kfifo_put(&spi_fifo_in, rx & 0xff);
  622. + if (kfifo_len(&spi_fifo_in) > 16
  623. + && g_recvCallback)
  624. + g_recvCallback(g_recvData);
  625. + }
  626. + } while (rx != 0
  627. + || !kfifo_is_empty(&spi_fifo_out)
  628. + || pisnd_spi_has_more()
  629. + );
  630. +
  631. + if (!kfifo_is_empty(&spi_fifo_in) && g_recvCallback)
  632. + g_recvCallback(g_recvData);
  633. + }
  634. +}
  635. +
  636. +static int pisnd_spi_gpio_init(struct device *dev)
  637. +{
  638. + spi_reset = gpiod_get_index(dev, "reset", 1, GPIOD_ASIS);
  639. + data_available = gpiod_get_index(dev, "data_available", 0, GPIOD_ASIS);
  640. +
  641. + gpiod_direction_output(spi_reset, 1);
  642. + gpiod_direction_input(data_available);
  643. +
  644. + /* Reset the slave. */
  645. + gpiod_set_value(spi_reset, false);
  646. + mdelay(1);
  647. + gpiod_set_value(spi_reset, true);
  648. +
  649. + /* Give time for spi slave to start. */
  650. + mdelay(64);
  651. +
  652. + return 0;
  653. +}
  654. +
  655. +static void pisnd_spi_gpio_uninit(void)
  656. +{
  657. + gpiod_set_value(spi_reset, false);
  658. + gpiod_put(spi_reset);
  659. + spi_reset = NULL;
  660. +
  661. + gpiod_put(data_available);
  662. + data_available = NULL;
  663. +}
  664. +
  665. +static int pisnd_spi_gpio_irq_init(struct device *dev)
  666. +{
  667. + return request_irq(
  668. + gpiod_to_irq(data_available),
  669. + data_available_interrupt_handler,
  670. + IRQF_TIMER | IRQF_TRIGGER_RISING,
  671. + "data_available_int",
  672. + NULL
  673. + );
  674. +}
  675. +
  676. +static void pisnd_spi_gpio_irq_uninit(void)
  677. +{
  678. + free_irq(gpiod_to_irq(data_available), NULL);
  679. +}
  680. +
  681. +static int spi_read_info(void)
  682. +{
  683. + uint16_t tmp;
  684. + uint8_t count;
  685. + uint8_t n;
  686. + uint8_t i;
  687. + uint8_t j;
  688. + char buffer[257];
  689. + int ret;
  690. + char *p;
  691. +
  692. + memset(g_serial_num, 0, sizeof(g_serial_num));
  693. + memset(g_version, 0, sizeof(g_version));
  694. + memset(g_id, 0, sizeof(g_id));
  695. +
  696. + tmp = spi_transfer16(0);
  697. +
  698. + if (!(tmp >> 8))
  699. + return -EINVAL;
  700. +
  701. + count = tmp & 0xff;
  702. +
  703. + for (i = 0; i < count; ++i) {
  704. + memset(buffer, 0, sizeof(buffer));
  705. + ret = spi_read_bytes(buffer, sizeof(buffer)-1, &n);
  706. +
  707. + if (ret < 0)
  708. + return ret;
  709. +
  710. + switch (i) {
  711. + case 0:
  712. + if (n != 2)
  713. + return -EINVAL;
  714. +
  715. + snprintf(
  716. + g_version,
  717. + sizeof(g_version),
  718. + "%x.%02x",
  719. + buffer[0],
  720. + buffer[1]
  721. + );
  722. + break;
  723. + case 1:
  724. + if (n >= sizeof(g_serial_num))
  725. + return -EINVAL;
  726. +
  727. + memcpy(g_serial_num, buffer, sizeof(g_serial_num));
  728. + break;
  729. + case 2:
  730. + {
  731. + if (n >= sizeof(g_id))
  732. + return -EINVAL;
  733. +
  734. + p = g_id;
  735. + for (j = 0; j < n; ++j)
  736. + p += sprintf(p, "%02x", buffer[j]);
  737. + }
  738. + break;
  739. + default:
  740. + break;
  741. + }
  742. + }
  743. +
  744. + return 0;
  745. +}
  746. +
  747. +static int pisnd_spi_init(struct device *dev)
  748. +{
  749. + int ret;
  750. + struct spi_device *spi;
  751. +
  752. + memset(g_serial_num, 0, sizeof(g_serial_num));
  753. + memset(g_id, 0, sizeof(g_id));
  754. + memset(g_version, 0, sizeof(g_version));
  755. +
  756. + spi = pisnd_spi_find_device();
  757. +
  758. + if (spi != NULL) {
  759. + printd("initializing spi!\n");
  760. + pisnd_spi_device = spi;
  761. + ret = spi_setup(pisnd_spi_device);
  762. + } else {
  763. + printe("SPI device not found, deferring!\n");
  764. + return -EPROBE_DEFER;
  765. + }
  766. +
  767. + ret = pisnd_spi_gpio_init(dev);
  768. +
  769. + if (ret < 0) {
  770. + printe("SPI GPIO init failed: %d\n", ret);
  771. + spi_dev_put(pisnd_spi_device);
  772. + pisnd_spi_device = NULL;
  773. + pisnd_spi_gpio_uninit();
  774. + return ret;
  775. + }
  776. +
  777. + ret = spi_read_info();
  778. +
  779. + if (ret < 0) {
  780. + printe("Reading card info failed: %d\n", ret);
  781. + spi_dev_put(pisnd_spi_device);
  782. + pisnd_spi_device = NULL;
  783. + pisnd_spi_gpio_uninit();
  784. + return ret;
  785. + }
  786. +
  787. + /* Flash the LEDs. */
  788. + spi_transfer16(0xf000);
  789. +
  790. + ret = pisnd_spi_gpio_irq_init(dev);
  791. + if (ret < 0) {
  792. + printe("SPI irq request failed: %d\n", ret);
  793. + spi_dev_put(pisnd_spi_device);
  794. + pisnd_spi_device = NULL;
  795. + pisnd_spi_gpio_irq_uninit();
  796. + pisnd_spi_gpio_uninit();
  797. + }
  798. +
  799. + ret = pisnd_init_workqueues();
  800. + if (ret != 0) {
  801. + printe("Workqueue initialization failed: %d\n", ret);
  802. + spi_dev_put(pisnd_spi_device);
  803. + pisnd_spi_device = NULL;
  804. + pisnd_spi_gpio_irq_uninit();
  805. + pisnd_spi_gpio_uninit();
  806. + pisnd_uninit_workqueues();
  807. + return ret;
  808. + }
  809. +
  810. + if (pisnd_spi_has_more()) {
  811. + printd("data is available, scheduling from init\n");
  812. + pisnd_schedule_process(TASK_PROCESS);
  813. + }
  814. +
  815. + return 0;
  816. +}
  817. +
  818. +static void pisnd_spi_uninit(void)
  819. +{
  820. + pisnd_uninit_workqueues();
  821. +
  822. + spi_dev_put(pisnd_spi_device);
  823. + pisnd_spi_device = NULL;
  824. +
  825. + pisnd_spi_gpio_irq_uninit();
  826. + pisnd_spi_gpio_uninit();
  827. +}
  828. +
  829. +static void pisnd_spi_send(uint8_t val)
  830. +{
  831. + kfifo_put(&spi_fifo_out, val);
  832. + printd("schedule from spi_send\n");
  833. + pisnd_schedule_process(TASK_PROCESS);
  834. +}
  835. +
  836. +static uint8_t pisnd_spi_recv(uint8_t *buffer, uint8_t length)
  837. +{
  838. + return kfifo_out(&spi_fifo_in, buffer, length);
  839. +}
  840. +
  841. +static void pisnd_spi_set_callback(pisnd_spi_recv_cb cb, void *data)
  842. +{
  843. + g_recvData = data;
  844. + g_recvCallback = cb;
  845. +}
  846. +
  847. +static const char *pisnd_spi_get_serial(void)
  848. +{
  849. + if (strlen(g_serial_num))
  850. + return g_serial_num;
  851. +
  852. + return "";
  853. +}
  854. +
  855. +static const char *pisnd_spi_get_id(void)
  856. +{
  857. + if (strlen(g_id))
  858. + return g_id;
  859. +
  860. + return "";
  861. +}
  862. +
  863. +static const char *pisnd_spi_get_version(void)
  864. +{
  865. + if (strlen(g_version))
  866. + return g_version;
  867. +
  868. + return "";
  869. +}
  870. +
  871. +static const struct of_device_id pisound_of_match[] = {
  872. + { .compatible = "blokaslabs,pisound", },
  873. + { .compatible = "blokaslabs,pisound-spi", },
  874. + {},
  875. +};
  876. +
  877. +static struct gpio_desc *osr0, *osr1, *osr2;
  878. +static struct gpio_desc *reset;
  879. +static struct gpio_desc *button;
  880. +
  881. +static int pisnd_hw_params(
  882. + struct snd_pcm_substream *substream,
  883. + struct snd_pcm_hw_params *params
  884. + )
  885. +{
  886. + printd("rate = %d\n", params_rate(params));
  887. + printd("ch = %d\n", params_channels(params));
  888. + printd("bits = %u\n",
  889. + snd_pcm_format_physical_width(params_format(params)));
  890. + printd("format = %d\n", params_format(params));
  891. +
  892. + gpiod_set_value(reset, false);
  893. +
  894. + switch (params_rate(params)) {
  895. + case 48000:
  896. + gpiod_set_value(osr0, true);
  897. + gpiod_set_value(osr1, false);
  898. + gpiod_set_value(osr2, false);
  899. + break;
  900. + case 96000:
  901. + gpiod_set_value(osr0, true);
  902. + gpiod_set_value(osr1, true);
  903. + gpiod_set_value(osr2, false);
  904. + break;
  905. + case 192000:
  906. + gpiod_set_value(osr0, true);
  907. + gpiod_set_value(osr1, true);
  908. + gpiod_set_value(osr2, true);
  909. + break;
  910. + default:
  911. + printe("Unsupported rate %u!\n", params_rate(params));
  912. + return -EINVAL;
  913. + }
  914. +
  915. + gpiod_set_value(reset, true);
  916. +
  917. + return 0;
  918. +}
  919. +
  920. +static unsigned int rates[3] = {
  921. + 48000, 96000, 192000
  922. +};
  923. +
  924. +static struct snd_pcm_hw_constraint_list constraints_rates = {
  925. + .count = ARRAY_SIZE(rates),
  926. + .list = rates,
  927. + .mask = 0,
  928. +};
  929. +
  930. +static unsigned int sample_bits[] = {
  931. + 24, 32
  932. +};
  933. +
  934. +static struct snd_pcm_hw_constraint_list constraints_sample_bits = {
  935. + .count = ARRAY_SIZE(sample_bits),
  936. + .list = sample_bits,
  937. + .mask = 0,
  938. +};
  939. +
  940. +static int pisnd_startup(struct snd_pcm_substream *substream)
  941. +{
  942. + int err = snd_pcm_hw_constraint_list(
  943. + substream->runtime,
  944. + 0,
  945. + SNDRV_PCM_HW_PARAM_RATE,
  946. + &constraints_rates
  947. + );
  948. +
  949. + if (err < 0)
  950. + return err;
  951. +
  952. + err = snd_pcm_hw_constraint_list(
  953. + substream->runtime,
  954. + 0,
  955. + SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
  956. + &constraints_sample_bits
  957. + );
  958. +
  959. + if (err < 0)
  960. + return err;
  961. +
  962. + return 0;
  963. +}
  964. +
  965. +static struct snd_soc_ops pisnd_ops = {
  966. + .startup = pisnd_startup,
  967. + .hw_params = pisnd_hw_params,
  968. +};
  969. +
  970. +static struct snd_soc_dai_link pisnd_dai[] = {
  971. + {
  972. + .name = "pisound",
  973. + .stream_name = "pisound",
  974. + .cpu_dai_name = "bcm2708-i2s.0",
  975. + .codec_dai_name = "snd-soc-dummy-dai",
  976. + .platform_name = "bcm2708-i2s.0",
  977. + .codec_name = "snd-soc-dummy",
  978. + .dai_fmt =
  979. + SND_SOC_DAIFMT_I2S |
  980. + SND_SOC_DAIFMT_NB_NF |
  981. + SND_SOC_DAIFMT_CBM_CFM,
  982. + .ops = &pisnd_ops,
  983. + },
  984. +};
  985. +
  986. +static int pisnd_card_probe(struct snd_soc_card *card)
  987. +{
  988. + int err = pisnd_midi_init(card->snd_card);
  989. +
  990. + if (err < 0)
  991. + printe("pisnd_midi_init failed: %d\n", err);
  992. +
  993. + return err;
  994. +}
  995. +
  996. +static int pisnd_card_remove(struct snd_soc_card *card)
  997. +{
  998. + pisnd_midi_uninit();
  999. + return 0;
  1000. +}
  1001. +
  1002. +static struct snd_soc_card pisnd_card = {
  1003. + .name = "pisound",
  1004. + .owner = THIS_MODULE,
  1005. + .dai_link = pisnd_dai,
  1006. + .num_links = ARRAY_SIZE(pisnd_dai),
  1007. + .probe = pisnd_card_probe,
  1008. + .remove = pisnd_card_remove,
  1009. +};
  1010. +
  1011. +static int pisnd_init_gpio(struct device *dev)
  1012. +{
  1013. + osr0 = gpiod_get_index(dev, "osr", 0, GPIOD_ASIS);
  1014. + osr1 = gpiod_get_index(dev, "osr", 1, GPIOD_ASIS);
  1015. + osr2 = gpiod_get_index(dev, "osr", 2, GPIOD_ASIS);
  1016. +
  1017. + reset = gpiod_get_index(dev, "reset", 0, GPIOD_ASIS);
  1018. +
  1019. + button = gpiod_get_index(dev, "button", 0, GPIOD_ASIS);
  1020. +
  1021. + gpiod_direction_output(osr0, 1);
  1022. + gpiod_direction_output(osr1, 1);
  1023. + gpiod_direction_output(osr2, 1);
  1024. + gpiod_direction_output(reset, 1);
  1025. +
  1026. + gpiod_set_value(reset, false);
  1027. + gpiod_set_value(osr0, true);
  1028. + gpiod_set_value(osr1, false);
  1029. + gpiod_set_value(osr2, false);
  1030. + gpiod_set_value(reset, true);
  1031. +
  1032. + gpiod_export(button, false);
  1033. +
  1034. + return 0;
  1035. +}
  1036. +
  1037. +static int pisnd_uninit_gpio(void)
  1038. +{
  1039. + int i;
  1040. +
  1041. + struct gpio_desc **gpios[] = {
  1042. + &osr0, &osr1, &osr2, &reset, &button,
  1043. + };
  1044. +
  1045. + gpiod_unexport(button);
  1046. +
  1047. + for (i = 0; i < ARRAY_SIZE(gpios); ++i) {
  1048. + if (*gpios[i] == NULL) {
  1049. + printd("weird, GPIO[%d] is NULL already\n", i);
  1050. + continue;
  1051. + }
  1052. +
  1053. + gpiod_put(*gpios[i]);
  1054. + *gpios[i] = NULL;
  1055. + }
  1056. +
  1057. + return 0;
  1058. +}
  1059. +
  1060. +static struct kobject *pisnd_kobj;
  1061. +
  1062. +static ssize_t pisnd_serial_show(
  1063. + struct kobject *kobj,
  1064. + struct kobj_attribute *attr,
  1065. + char *buf
  1066. + )
  1067. +{
  1068. + return sprintf(buf, "%s\n", pisnd_spi_get_serial());
  1069. +}
  1070. +
  1071. +static ssize_t pisnd_id_show(
  1072. + struct kobject *kobj,
  1073. + struct kobj_attribute *attr,
  1074. + char *buf
  1075. + )
  1076. +{
  1077. + return sprintf(buf, "%s\n", pisnd_spi_get_id());
  1078. +}
  1079. +
  1080. +static ssize_t pisnd_version_show(
  1081. + struct kobject *kobj,
  1082. + struct kobj_attribute *attr,
  1083. + char *buf
  1084. + )
  1085. +{
  1086. + return sprintf(buf, "%s\n", pisnd_spi_get_version());
  1087. +}
  1088. +
  1089. +static struct kobj_attribute pisnd_serial_attribute =
  1090. + __ATTR(serial, 0644, pisnd_serial_show, NULL);
  1091. +static struct kobj_attribute pisnd_id_attribute =
  1092. + __ATTR(id, 0644, pisnd_id_show, NULL);
  1093. +static struct kobj_attribute pisnd_version_attribute =
  1094. + __ATTR(version, 0644, pisnd_version_show, NULL);
  1095. +
  1096. +static struct attribute *attrs[] = {
  1097. + &pisnd_serial_attribute.attr,
  1098. + &pisnd_id_attribute.attr,
  1099. + &pisnd_version_attribute.attr,
  1100. + NULL
  1101. +};
  1102. +
  1103. +static struct attribute_group attr_group = { .attrs = attrs };
  1104. +
  1105. +static int pisnd_probe(struct platform_device *pdev)
  1106. +{
  1107. + int ret = 0;
  1108. + int i;
  1109. +
  1110. + ret = pisnd_spi_init(&pdev->dev);
  1111. + if (ret < 0) {
  1112. + printe("pisnd_spi_init failed: %d\n", ret);
  1113. + return ret;
  1114. + }
  1115. +
  1116. + printi("Detected pisound card:\n");
  1117. + printi("\tSerial: %s\n", pisnd_spi_get_serial());
  1118. + printi("\tVersion: %s\n", pisnd_spi_get_version());
  1119. + printi("\tId: %s\n", pisnd_spi_get_id());
  1120. +
  1121. + pisnd_kobj = kobject_create_and_add("pisound", kernel_kobj);
  1122. + if (!pisnd_kobj) {
  1123. + pisnd_spi_uninit();
  1124. + return -ENOMEM;
  1125. + }
  1126. +
  1127. + ret = sysfs_create_group(pisnd_kobj, &attr_group);
  1128. + if (ret < 0) {
  1129. + pisnd_spi_uninit();
  1130. + kobject_put(pisnd_kobj);
  1131. + return -ENOMEM;
  1132. + }
  1133. +
  1134. + pisnd_init_gpio(&pdev->dev);
  1135. + pisnd_card.dev = &pdev->dev;
  1136. +
  1137. + if (pdev->dev.of_node) {
  1138. + struct device_node *i2s_node;
  1139. +
  1140. + i2s_node = of_parse_phandle(
  1141. + pdev->dev.of_node,
  1142. + "i2s-controller",
  1143. + 0
  1144. + );
  1145. +
  1146. + for (i = 0; i < pisnd_card.num_links; ++i) {
  1147. + struct snd_soc_dai_link *dai = &pisnd_dai[i];
  1148. +
  1149. + if (i2s_node) {
  1150. + dai->cpu_dai_name = NULL;
  1151. + dai->cpu_of_node = i2s_node;
  1152. + dai->platform_name = NULL;
  1153. + dai->platform_of_node = i2s_node;
  1154. + dai->stream_name = pisnd_spi_get_serial();
  1155. + }
  1156. + }
  1157. + }
  1158. +
  1159. + ret = snd_soc_register_card(&pisnd_card);
  1160. +
  1161. + if (ret < 0) {
  1162. + printe("snd_soc_register_card() failed: %d\n", ret);
  1163. + pisnd_uninit_gpio();
  1164. + kobject_put(pisnd_kobj);
  1165. + pisnd_spi_uninit();
  1166. + }
  1167. +
  1168. + return ret;
  1169. +}
  1170. +
  1171. +static int pisnd_remove(struct platform_device *pdev)
  1172. +{
  1173. + if (pisnd_kobj) {
  1174. + kobject_put(pisnd_kobj);
  1175. + pisnd_kobj = NULL;
  1176. + }
  1177. +
  1178. + pisnd_spi_uninit();
  1179. +
  1180. + /* Turn off */
  1181. + gpiod_set_value(reset, false);
  1182. + pisnd_uninit_gpio();
  1183. +
  1184. + return snd_soc_unregister_card(&pisnd_card);
  1185. +}
  1186. +
  1187. +MODULE_DEVICE_TABLE(of, pisound_of_match);
  1188. +
  1189. +static struct platform_driver pisnd_driver = {
  1190. + .driver = {
  1191. + .name = "snd-rpi-pisound",
  1192. + .owner = THIS_MODULE,
  1193. + .of_match_table = pisound_of_match,
  1194. + },
  1195. + .probe = pisnd_probe,
  1196. + .remove = pisnd_remove,
  1197. +};
  1198. +
  1199. +module_platform_driver(pisnd_driver);
  1200. +
  1201. +MODULE_AUTHOR("Giedrius Trainavicius <giedrius@blokas.io>");
  1202. +MODULE_DESCRIPTION("ASoC Driver for pisound, http://blokas.io/pisound");
  1203. +MODULE_LICENSE("GPL v2");