mpc8610_hpcd.c 18 KB

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