mpc8610_hpcd.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /**
  2. * Freescale MPC8610HPCD ALSA SoC Fabric driver
  3. *
  4. * Author: Timur Tabi <timur@freescale.com>
  5. *
  6. * Copyright 2007-2008 Freescale Semiconductor, Inc. This file is licensed
  7. * under the terms of the GNU General Public License version 2. This
  8. * program is licensed "as is" without any warranty of any kind, whether
  9. * express or implied.
  10. */
  11. #include <linux/slab.h>
  12. #include <linux/module.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/of_device.h>
  15. #include <linux/of_platform.h>
  16. #include <sound/soc.h>
  17. #include <asm/immap_86xx.h>
  18. #include "../codecs/cs4270.h"
  19. #include "fsl_dma.h"
  20. #include "fsl_ssi.h"
  21. /**
  22. * mpc8610_hpcd_data: fabric-specific ASoC device data
  23. *
  24. * This structure contains data for a single sound platform device on an
  25. * MPC8610 HPCD. Some of the data is taken from the device tree.
  26. */
  27. struct mpc8610_hpcd_data {
  28. struct snd_soc_device sound_devdata;
  29. struct snd_soc_dai_link dai;
  30. struct snd_soc_card machine;
  31. unsigned int dai_format;
  32. unsigned int codec_clk_direction;
  33. unsigned int cpu_clk_direction;
  34. unsigned int clk_frequency;
  35. struct ccsr_guts __iomem *guts;
  36. struct ccsr_ssi __iomem *ssi;
  37. unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */
  38. unsigned int ssi_irq;
  39. unsigned int dma_id; /* 0 = DMA1, 1 = DMA2, etc */
  40. unsigned int dma_irq[2];
  41. struct ccsr_dma_channel __iomem *dma[2];
  42. unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/
  43. };
  44. /**
  45. * mpc8610_hpcd_machine_probe: initalize the board
  46. *
  47. * This function is called when platform_device_add() is called. It is used
  48. * to initialize the board-specific hardware.
  49. *
  50. * Here we program the DMACR and PMUXCR registers.
  51. */
  52. static int mpc8610_hpcd_machine_probe(struct platform_device *sound_device)
  53. {
  54. struct mpc8610_hpcd_data *machine_data =
  55. sound_device->dev.platform_data;
  56. /* Program the signal routing between the SSI and the DMA */
  57. guts_set_dmacr(machine_data->guts, machine_data->dma_id,
  58. machine_data->dma_channel_id[0], CCSR_GUTS_DMACR_DEV_SSI);
  59. guts_set_dmacr(machine_data->guts, machine_data->dma_id,
  60. machine_data->dma_channel_id[1], CCSR_GUTS_DMACR_DEV_SSI);
  61. guts_set_pmuxcr_dma(machine_data->guts, machine_data->dma_id,
  62. machine_data->dma_channel_id[0], 0);
  63. guts_set_pmuxcr_dma(machine_data->guts, machine_data->dma_id,
  64. machine_data->dma_channel_id[1], 0);
  65. switch (machine_data->ssi_id) {
  66. case 0:
  67. clrsetbits_be32(&machine_data->guts->pmuxcr,
  68. CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_SSI);
  69. break;
  70. case 1:
  71. clrsetbits_be32(&machine_data->guts->pmuxcr,
  72. CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_SSI);
  73. break;
  74. }
  75. return 0;
  76. }
  77. /**
  78. * mpc8610_hpcd_startup: program the board with various hardware parameters
  79. *
  80. * This function takes board-specific information, like clock frequencies
  81. * and serial data formats, and passes that information to the codec and
  82. * transport drivers.
  83. */
  84. static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream)
  85. {
  86. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  87. struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
  88. struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
  89. struct mpc8610_hpcd_data *machine_data =
  90. rtd->socdev->dev->platform_data;
  91. int ret = 0;
  92. /* Tell the CPU driver what the serial protocol is. */
  93. ret = snd_soc_dai_set_fmt(cpu_dai, machine_data->dai_format);
  94. if (ret < 0) {
  95. dev_err(substream->pcm->card->dev,
  96. "could not set CPU driver audio format\n");
  97. return ret;
  98. }
  99. /* Tell the codec driver what the serial protocol is. */
  100. ret = snd_soc_dai_set_fmt(codec_dai, machine_data->dai_format);
  101. if (ret < 0) {
  102. dev_err(substream->pcm->card->dev,
  103. "could not set codec driver audio format\n");
  104. return ret;
  105. }
  106. /*
  107. * Tell the CPU driver what the clock frequency is, and whether it's a
  108. * slave or master.
  109. */
  110. ret = snd_soc_dai_set_sysclk(cpu_dai, 0,
  111. machine_data->clk_frequency,
  112. machine_data->cpu_clk_direction);
  113. if (ret < 0) {
  114. dev_err(substream->pcm->card->dev,
  115. "could not set CPU driver clock parameters\n");
  116. return ret;
  117. }
  118. /*
  119. * Tell the codec driver what the MCLK frequency is, and whether it's
  120. * a slave or master.
  121. */
  122. ret = snd_soc_dai_set_sysclk(codec_dai, 0,
  123. machine_data->clk_frequency,
  124. machine_data->codec_clk_direction);
  125. if (ret < 0) {
  126. dev_err(substream->pcm->card->dev,
  127. "could not set codec driver clock params\n");
  128. return ret;
  129. }
  130. return 0;
  131. }
  132. /**
  133. * mpc8610_hpcd_machine_remove: Remove the sound device
  134. *
  135. * This function is called to remove the sound device for one SSI. We
  136. * de-program the DMACR and PMUXCR register.
  137. */
  138. int mpc8610_hpcd_machine_remove(struct platform_device *sound_device)
  139. {
  140. struct mpc8610_hpcd_data *machine_data =
  141. sound_device->dev.platform_data;
  142. /* Restore the signal routing */
  143. guts_set_dmacr(machine_data->guts, machine_data->dma_id,
  144. machine_data->dma_channel_id[0], 0);
  145. guts_set_dmacr(machine_data->guts, machine_data->dma_id,
  146. machine_data->dma_channel_id[1], 0);
  147. switch (machine_data->ssi_id) {
  148. case 0:
  149. clrsetbits_be32(&machine_data->guts->pmuxcr,
  150. CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_LA);
  151. break;
  152. case 1:
  153. clrsetbits_be32(&machine_data->guts->pmuxcr,
  154. CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_LA);
  155. break;
  156. }
  157. return 0;
  158. }
  159. /**
  160. * mpc8610_hpcd_ops: ASoC fabric driver operations
  161. */
  162. static struct snd_soc_ops mpc8610_hpcd_ops = {
  163. .startup = mpc8610_hpcd_startup,
  164. };
  165. /**
  166. * mpc8610_hpcd_probe: OF probe function for the fabric driver
  167. *
  168. * This function gets called when an SSI node is found in the device tree.
  169. *
  170. * Although this is a fabric driver, the SSI node is the "master" node with
  171. * respect to audio hardware connections. Therefore, we create a new ASoC
  172. * device for each new SSI node that has a codec attached.
  173. *
  174. * FIXME: Currently, we only support one DMA controller, so if there are
  175. * multiple SSI nodes with codecs, only the first will be supported.
  176. *
  177. * FIXME: Even if we did support multiple DMA controllers, we have no
  178. * mechanism for assigning DMA controllers and channels to the individual
  179. * SSI devices. We also probably aren't compatible with the generic Elo DMA
  180. * device driver.
  181. */
  182. static int mpc8610_hpcd_probe(struct of_device *ofdev,
  183. const struct of_device_id *match)
  184. {
  185. struct device_node *np = ofdev->node;
  186. struct device_node *codec_np = NULL;
  187. struct device_node *guts_np = NULL;
  188. struct device_node *dma_np = NULL;
  189. struct device_node *dma_channel_np = NULL;
  190. const phandle *codec_ph;
  191. const char *sprop;
  192. const u32 *iprop;
  193. struct resource res;
  194. struct platform_device *sound_device = NULL;
  195. struct mpc8610_hpcd_data *machine_data;
  196. struct fsl_ssi_info ssi_info;
  197. struct fsl_dma_info dma_info;
  198. int ret = -ENODEV;
  199. unsigned int playback_dma_channel;
  200. unsigned int capture_dma_channel;
  201. machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);
  202. if (!machine_data)
  203. return -ENOMEM;
  204. memset(&ssi_info, 0, sizeof(ssi_info));
  205. memset(&dma_info, 0, sizeof(dma_info));
  206. ssi_info.dev = &ofdev->dev;
  207. /*
  208. * We are only interested in SSIs with a codec phandle in them, so let's
  209. * make sure this SSI has one.
  210. */
  211. codec_ph = of_get_property(np, "codec-handle", NULL);
  212. if (!codec_ph)
  213. goto error;
  214. codec_np = of_find_node_by_phandle(*codec_ph);
  215. if (!codec_np)
  216. goto error;
  217. /* The MPC8610 HPCD only knows about the CS4270 codec, so reject
  218. anything else. */
  219. if (!of_device_is_compatible(codec_np, "cirrus,cs4270"))
  220. goto error;
  221. /* Get the device ID */
  222. iprop = of_get_property(np, "cell-index", NULL);
  223. if (!iprop) {
  224. dev_err(&ofdev->dev, "cell-index property not found\n");
  225. ret = -EINVAL;
  226. goto error;
  227. }
  228. machine_data->ssi_id = *iprop;
  229. ssi_info.id = *iprop;
  230. /* Get the serial format and clock direction. */
  231. sprop = of_get_property(np, "fsl,mode", NULL);
  232. if (!sprop) {
  233. dev_err(&ofdev->dev, "fsl,mode property not found\n");
  234. ret = -EINVAL;
  235. goto error;
  236. }
  237. if (strcasecmp(sprop, "i2s-slave") == 0) {
  238. machine_data->dai_format = SND_SOC_DAIFMT_I2S;
  239. machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
  240. machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
  241. /*
  242. * In i2s-slave mode, the codec has its own clock source, so we
  243. * need to get the frequency from the device tree and pass it to
  244. * the codec driver.
  245. */
  246. iprop = of_get_property(codec_np, "clock-frequency", NULL);
  247. if (!iprop || !*iprop) {
  248. dev_err(&ofdev->dev, "codec bus-frequency property "
  249. "is missing or invalid\n");
  250. ret = -EINVAL;
  251. goto error;
  252. }
  253. machine_data->clk_frequency = *iprop;
  254. } else if (strcasecmp(sprop, "i2s-master") == 0) {
  255. machine_data->dai_format = SND_SOC_DAIFMT_I2S;
  256. machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
  257. machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  258. } else if (strcasecmp(sprop, "lj-slave") == 0) {
  259. machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J;
  260. machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
  261. machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
  262. } else if (strcasecmp(sprop, "lj-master") == 0) {
  263. machine_data->dai_format = SND_SOC_DAIFMT_LEFT_J;
  264. machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
  265. machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  266. } else if (strcasecmp(sprop, "rj-slave") == 0) {
  267. machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J;
  268. machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
  269. machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
  270. } else if (strcasecmp(sprop, "rj-master") == 0) {
  271. machine_data->dai_format = SND_SOC_DAIFMT_RIGHT_J;
  272. machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
  273. machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  274. } else if (strcasecmp(sprop, "ac97-slave") == 0) {
  275. machine_data->dai_format = SND_SOC_DAIFMT_AC97;
  276. machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
  277. machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
  278. } else if (strcasecmp(sprop, "ac97-master") == 0) {
  279. machine_data->dai_format = SND_SOC_DAIFMT_AC97;
  280. machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
  281. machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  282. } else {
  283. dev_err(&ofdev->dev,
  284. "unrecognized fsl,mode property \"%s\"\n", sprop);
  285. ret = -EINVAL;
  286. goto error;
  287. }
  288. if (!machine_data->clk_frequency) {
  289. dev_err(&ofdev->dev, "unknown clock frequency\n");
  290. ret = -EINVAL;
  291. goto error;
  292. }
  293. /* Read the SSI information from the device tree */
  294. ret = of_address_to_resource(np, 0, &res);
  295. if (ret) {
  296. dev_err(&ofdev->dev, "could not obtain SSI address\n");
  297. goto error;
  298. }
  299. if (!res.start) {
  300. dev_err(&ofdev->dev, "invalid SSI address\n");
  301. goto error;
  302. }
  303. ssi_info.ssi_phys = res.start;
  304. machine_data->ssi = ioremap(ssi_info.ssi_phys, sizeof(struct ccsr_ssi));
  305. if (!machine_data->ssi) {
  306. dev_err(&ofdev->dev, "could not map SSI address %x\n",
  307. ssi_info.ssi_phys);
  308. ret = -EINVAL;
  309. goto error;
  310. }
  311. ssi_info.ssi = machine_data->ssi;
  312. /* Get the IRQ of the SSI */
  313. machine_data->ssi_irq = irq_of_parse_and_map(np, 0);
  314. if (!machine_data->ssi_irq) {
  315. dev_err(&ofdev->dev, "could not get SSI IRQ\n");
  316. ret = -EINVAL;
  317. goto error;
  318. }
  319. ssi_info.irq = machine_data->ssi_irq;
  320. /* Do we want to use asynchronous mode? */
  321. ssi_info.asynchronous =
  322. of_find_property(np, "fsl,ssi-asynchronous", NULL) ? 1 : 0;
  323. if (ssi_info.asynchronous)
  324. dev_info(&ofdev->dev, "using asynchronous mode\n");
  325. /* Map the global utilities registers. */
  326. guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
  327. if (!guts_np) {
  328. dev_err(&ofdev->dev, "could not obtain address of GUTS\n");
  329. ret = -EINVAL;
  330. goto error;
  331. }
  332. machine_data->guts = of_iomap(guts_np, 0);
  333. of_node_put(guts_np);
  334. if (!machine_data->guts) {
  335. dev_err(&ofdev->dev, "could not map GUTS\n");
  336. ret = -EINVAL;
  337. goto error;
  338. }
  339. /* Find the DMA channels to use. Both SSIs need to use the same DMA
  340. * controller, so let's use DMA#1.
  341. */
  342. for_each_compatible_node(dma_np, NULL, "fsl,mpc8610-dma") {
  343. iprop = of_get_property(dma_np, "cell-index", NULL);
  344. if (iprop && (*iprop == 0)) {
  345. of_node_put(dma_np);
  346. break;
  347. }
  348. }
  349. if (!dma_np) {
  350. dev_err(&ofdev->dev, "could not find DMA node\n");
  351. ret = -EINVAL;
  352. goto error;
  353. }
  354. machine_data->dma_id = *iprop;
  355. /* SSI1 needs to use DMA Channels 0 and 1, and SSI2 needs to use DMA
  356. * channels 2 and 3. This is just how the MPC8610 is wired
  357. * internally.
  358. */
  359. playback_dma_channel = (machine_data->ssi_id == 0) ? 0 : 2;
  360. capture_dma_channel = (machine_data->ssi_id == 0) ? 1 : 3;
  361. /*
  362. * Find the DMA channels to use.
  363. */
  364. while ((dma_channel_np = of_get_next_child(dma_np, dma_channel_np))) {
  365. iprop = of_get_property(dma_channel_np, "cell-index", NULL);
  366. if (iprop && (*iprop == playback_dma_channel)) {
  367. /* dma_channel[0] and dma_irq[0] are for playback */
  368. dma_info.dma_channel[0] = of_iomap(dma_channel_np, 0);
  369. dma_info.dma_irq[0] =
  370. irq_of_parse_and_map(dma_channel_np, 0);
  371. machine_data->dma_channel_id[0] = *iprop;
  372. continue;
  373. }
  374. if (iprop && (*iprop == capture_dma_channel)) {
  375. /* dma_channel[1] and dma_irq[1] are for capture */
  376. dma_info.dma_channel[1] = of_iomap(dma_channel_np, 0);
  377. dma_info.dma_irq[1] =
  378. irq_of_parse_and_map(dma_channel_np, 0);
  379. machine_data->dma_channel_id[1] = *iprop;
  380. continue;
  381. }
  382. }
  383. if (!dma_info.dma_channel[0] || !dma_info.dma_channel[1] ||
  384. !dma_info.dma_irq[0] || !dma_info.dma_irq[1]) {
  385. dev_err(&ofdev->dev, "could not find DMA channels\n");
  386. ret = -EINVAL;
  387. goto error;
  388. }
  389. dma_info.ssi_stx_phys = ssi_info.ssi_phys +
  390. offsetof(struct ccsr_ssi, stx0);
  391. dma_info.ssi_srx_phys = ssi_info.ssi_phys +
  392. offsetof(struct ccsr_ssi, srx0);
  393. /* We have the DMA information, so tell the DMA driver what it is */
  394. if (!fsl_dma_configure(&dma_info)) {
  395. dev_err(&ofdev->dev, "could not instantiate DMA device\n");
  396. ret = -EBUSY;
  397. goto error;
  398. }
  399. /*
  400. * Initialize our DAI data structure. We should probably get this
  401. * information from the device tree.
  402. */
  403. machine_data->dai.name = "CS4270";
  404. machine_data->dai.stream_name = "CS4270";
  405. machine_data->dai.cpu_dai = fsl_ssi_create_dai(&ssi_info);
  406. machine_data->dai.codec_dai = &cs4270_dai; /* The codec_dai we want */
  407. machine_data->dai.ops = &mpc8610_hpcd_ops;
  408. machine_data->machine.probe = mpc8610_hpcd_machine_probe;
  409. machine_data->machine.remove = mpc8610_hpcd_machine_remove;
  410. machine_data->machine.name = "MPC8610 HPCD";
  411. machine_data->machine.num_links = 1;
  412. machine_data->machine.dai_link = &machine_data->dai;
  413. /* Allocate a new audio platform device structure */
  414. sound_device = platform_device_alloc("soc-audio", -1);
  415. if (!sound_device) {
  416. dev_err(&ofdev->dev, "platform device allocation failed\n");
  417. ret = -ENOMEM;
  418. goto error;
  419. }
  420. machine_data->sound_devdata.card = &machine_data->machine;
  421. machine_data->sound_devdata.codec_dev = &soc_codec_device_cs4270;
  422. machine_data->machine.platform = &fsl_soc_platform;
  423. sound_device->dev.platform_data = machine_data;
  424. /* Set the platform device and ASoC device to point to each other */
  425. platform_set_drvdata(sound_device, &machine_data->sound_devdata);
  426. machine_data->sound_devdata.dev = &sound_device->dev;
  427. /* Tell ASoC to probe us. This will call mpc8610_hpcd_machine.probe(),
  428. if it exists. */
  429. ret = platform_device_add(sound_device);
  430. if (ret) {
  431. dev_err(&ofdev->dev, "platform device add failed\n");
  432. goto error;
  433. }
  434. dev_set_drvdata(&ofdev->dev, sound_device);
  435. return 0;
  436. error:
  437. of_node_put(codec_np);
  438. of_node_put(guts_np);
  439. of_node_put(dma_np);
  440. of_node_put(dma_channel_np);
  441. if (sound_device)
  442. platform_device_unregister(sound_device);
  443. if (machine_data->dai.cpu_dai)
  444. fsl_ssi_destroy_dai(machine_data->dai.cpu_dai);
  445. if (ssi_info.ssi)
  446. iounmap(ssi_info.ssi);
  447. if (ssi_info.irq)
  448. irq_dispose_mapping(ssi_info.irq);
  449. if (dma_info.dma_channel[0])
  450. iounmap(dma_info.dma_channel[0]);
  451. if (dma_info.dma_channel[1])
  452. iounmap(dma_info.dma_channel[1]);
  453. if (dma_info.dma_irq[0])
  454. irq_dispose_mapping(dma_info.dma_irq[0]);
  455. if (dma_info.dma_irq[1])
  456. irq_dispose_mapping(dma_info.dma_irq[1]);
  457. if (machine_data->guts)
  458. iounmap(machine_data->guts);
  459. kfree(machine_data);
  460. return ret;
  461. }
  462. /**
  463. * mpc8610_hpcd_remove: remove the OF device
  464. *
  465. * This function is called when the OF device is removed.
  466. */
  467. static int mpc8610_hpcd_remove(struct of_device *ofdev)
  468. {
  469. struct platform_device *sound_device = dev_get_drvdata(&ofdev->dev);
  470. struct mpc8610_hpcd_data *machine_data =
  471. sound_device->dev.platform_data;
  472. platform_device_unregister(sound_device);
  473. if (machine_data->dai.cpu_dai)
  474. fsl_ssi_destroy_dai(machine_data->dai.cpu_dai);
  475. if (machine_data->ssi)
  476. iounmap(machine_data->ssi);
  477. if (machine_data->dma[0])
  478. iounmap(machine_data->dma[0]);
  479. if (machine_data->dma[1])
  480. iounmap(machine_data->dma[1]);
  481. if (machine_data->dma_irq[0])
  482. irq_dispose_mapping(machine_data->dma_irq[0]);
  483. if (machine_data->dma_irq[1])
  484. irq_dispose_mapping(machine_data->dma_irq[1]);
  485. if (machine_data->guts)
  486. iounmap(machine_data->guts);
  487. kfree(machine_data);
  488. sound_device->dev.platform_data = NULL;
  489. dev_set_drvdata(&ofdev->dev, NULL);
  490. return 0;
  491. }
  492. static struct of_device_id mpc8610_hpcd_match[] = {
  493. {
  494. .compatible = "fsl,mpc8610-ssi",
  495. },
  496. {}
  497. };
  498. MODULE_DEVICE_TABLE(of, mpc8610_hpcd_match);
  499. static struct of_platform_driver mpc8610_hpcd_of_driver = {
  500. .owner = THIS_MODULE,
  501. .name = "mpc8610_hpcd",
  502. .match_table = mpc8610_hpcd_match,
  503. .probe = mpc8610_hpcd_probe,
  504. .remove = mpc8610_hpcd_remove,
  505. };
  506. /**
  507. * mpc8610_hpcd_init: fabric driver initialization.
  508. *
  509. * This function is called when this module is loaded.
  510. */
  511. static int __init mpc8610_hpcd_init(void)
  512. {
  513. int ret;
  514. printk(KERN_INFO "Freescale MPC8610 HPCD ALSA SoC fabric driver\n");
  515. ret = of_register_platform_driver(&mpc8610_hpcd_of_driver);
  516. if (ret)
  517. printk(KERN_ERR
  518. "mpc8610-hpcd: failed to register platform driver\n");
  519. return ret;
  520. }
  521. /**
  522. * mpc8610_hpcd_exit: fabric driver exit
  523. *
  524. * This function is called when this driver is unloaded.
  525. */
  526. static void __exit mpc8610_hpcd_exit(void)
  527. {
  528. of_unregister_platform_driver(&mpc8610_hpcd_of_driver);
  529. }
  530. module_init(mpc8610_hpcd_init);
  531. module_exit(mpc8610_hpcd_exit);
  532. MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
  533. MODULE_DESCRIPTION("Freescale MPC8610 HPCD ALSA SoC fabric driver");
  534. MODULE_LICENSE("GPL");