p1022_ds.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /**
  2. * Freescale P1022DS ALSA SoC Machine driver
  3. *
  4. * Author: Timur Tabi <timur@freescale.com>
  5. *
  6. * Copyright 2010 Freescale Semiconductor, Inc.
  7. *
  8. * This file is licensed under the terms of the GNU General Public License
  9. * version 2. This program is licensed "as is" without any warranty of any
  10. * kind, whether express or implied.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/of_device.h>
  15. #include <linux/slab.h>
  16. #include <linux/of_i2c.h>
  17. #include <sound/soc.h>
  18. #include <asm/fsl_guts.h>
  19. #include "fsl_dma.h"
  20. #include "fsl_ssi.h"
  21. /* P1022-specific PMUXCR and DMUXCR bit definitions */
  22. #define CCSR_GUTS_PMUXCR_UART0_I2C1_MASK 0x0001c000
  23. #define CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI 0x00010000
  24. #define CCSR_GUTS_PMUXCR_UART0_I2C1_SSI 0x00018000
  25. #define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK 0x00000c00
  26. #define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI 0x00000000
  27. #define CCSR_GUTS_DMUXCR_PAD 1 /* DMA controller/channel set to pad */
  28. #define CCSR_GUTS_DMUXCR_SSI 2 /* DMA controller/channel set to SSI */
  29. /*
  30. * Set the DMACR register in the GUTS
  31. *
  32. * The DMACR register determines the source of initiated transfers for each
  33. * channel on each DMA controller. Rather than have a bunch of repetitive
  34. * macros for the bit patterns, we just have a function that calculates
  35. * them.
  36. *
  37. * guts: Pointer to GUTS structure
  38. * co: The DMA controller (0 or 1)
  39. * ch: The channel on the DMA controller (0, 1, 2, or 3)
  40. * device: The device to set as the target (CCSR_GUTS_DMUXCR_xxx)
  41. */
  42. static inline void guts_set_dmuxcr(struct ccsr_guts __iomem *guts,
  43. unsigned int co, unsigned int ch, unsigned int device)
  44. {
  45. unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch));
  46. clrsetbits_be32(&guts->dmuxcr, 3 << shift, device << shift);
  47. }
  48. /* There's only one global utilities register */
  49. static phys_addr_t guts_phys;
  50. #define DAI_NAME_SIZE 32
  51. /**
  52. * machine_data: machine-specific ASoC device data
  53. *
  54. * This structure contains data for a single sound platform device on an
  55. * P1022 DS. Some of the data is taken from the device tree.
  56. */
  57. struct machine_data {
  58. struct snd_soc_dai_link dai[2];
  59. struct snd_soc_card card;
  60. unsigned int dai_format;
  61. unsigned int codec_clk_direction;
  62. unsigned int cpu_clk_direction;
  63. unsigned int clk_frequency;
  64. unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */
  65. unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */
  66. unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/
  67. char codec_name[DAI_NAME_SIZE];
  68. char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */
  69. };
  70. /**
  71. * p1022_ds_machine_probe: initialize the board
  72. *
  73. * This function is used to initialize the board-specific hardware.
  74. *
  75. * Here we program the DMACR and PMUXCR registers.
  76. */
  77. static int p1022_ds_machine_probe(struct snd_soc_card *card)
  78. {
  79. struct machine_data *mdata =
  80. container_of(card, struct machine_data, card);
  81. struct ccsr_guts __iomem *guts;
  82. guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
  83. if (!guts) {
  84. dev_err(card->dev, "could not map global utilities\n");
  85. return -ENOMEM;
  86. }
  87. /* Enable SSI Tx signal */
  88. clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK,
  89. CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI);
  90. /* Enable SSI Rx signal */
  91. clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK,
  92. CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI);
  93. /* Enable DMA Channel for SSI */
  94. guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0],
  95. CCSR_GUTS_DMUXCR_SSI);
  96. guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1],
  97. CCSR_GUTS_DMUXCR_SSI);
  98. iounmap(guts);
  99. return 0;
  100. }
  101. /**
  102. * p1022_ds_startup: program the board with various hardware parameters
  103. *
  104. * This function takes board-specific information, like clock frequencies
  105. * and serial data formats, and passes that information to the codec and
  106. * transport drivers.
  107. */
  108. static int p1022_ds_startup(struct snd_pcm_substream *substream)
  109. {
  110. struct snd_soc_pcm_runtime *rtd = substream->private_data;
  111. struct machine_data *mdata =
  112. container_of(rtd->card, struct machine_data, card);
  113. struct device *dev = rtd->card->dev;
  114. int ret = 0;
  115. /* Tell the codec driver what the serial protocol is. */
  116. ret = snd_soc_dai_set_fmt(rtd->codec_dai, mdata->dai_format);
  117. if (ret < 0) {
  118. dev_err(dev, "could not set codec driver audio format\n");
  119. return ret;
  120. }
  121. /*
  122. * Tell the codec driver what the MCLK frequency is, and whether it's
  123. * a slave or master.
  124. */
  125. ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, mdata->clk_frequency,
  126. mdata->codec_clk_direction);
  127. if (ret < 0) {
  128. dev_err(dev, "could not set codec driver clock params\n");
  129. return ret;
  130. }
  131. return 0;
  132. }
  133. /**
  134. * p1022_ds_machine_remove: Remove the sound device
  135. *
  136. * This function is called to remove the sound device for one SSI. We
  137. * de-program the DMACR and PMUXCR register.
  138. */
  139. static int p1022_ds_machine_remove(struct snd_soc_card *card)
  140. {
  141. struct machine_data *mdata =
  142. container_of(card, struct machine_data, card);
  143. struct ccsr_guts __iomem *guts;
  144. guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
  145. if (!guts) {
  146. dev_err(card->dev, "could not map global utilities\n");
  147. return -ENOMEM;
  148. }
  149. /* Restore the signal routing */
  150. clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK);
  151. clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK);
  152. guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], 0);
  153. guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], 0);
  154. iounmap(guts);
  155. return 0;
  156. }
  157. /**
  158. * p1022_ds_ops: ASoC machine driver operations
  159. */
  160. static struct snd_soc_ops p1022_ds_ops = {
  161. .startup = p1022_ds_startup,
  162. };
  163. /**
  164. * get_node_by_phandle_name - get a node by its phandle name
  165. *
  166. * This function takes a node, the name of a property in that node, and a
  167. * compatible string. Assuming the property is a phandle to another node,
  168. * it returns that node, (optionally) if that node is compatible.
  169. *
  170. * If the property is not a phandle, or the node it points to is not compatible
  171. * with the specific string, then NULL is returned.
  172. */
  173. static struct device_node *get_node_by_phandle_name(struct device_node *np,
  174. const char *name, const char *compatible)
  175. {
  176. np = of_parse_phandle(np, name, 0);
  177. if (!np)
  178. return NULL;
  179. if (!of_device_is_compatible(np, compatible)) {
  180. of_node_put(np);
  181. return NULL;
  182. }
  183. return np;
  184. }
  185. /**
  186. * get_parent_cell_index -- return the cell-index of the parent of a node
  187. *
  188. * Return the value of the cell-index property of the parent of the given
  189. * node. This is used for DMA channel nodes that need to know the DMA ID
  190. * of the controller they are on.
  191. */
  192. static int get_parent_cell_index(struct device_node *np)
  193. {
  194. struct device_node *parent = of_get_parent(np);
  195. const u32 *iprop;
  196. int ret = -1;
  197. if (!parent)
  198. return -1;
  199. iprop = of_get_property(parent, "cell-index", NULL);
  200. if (iprop)
  201. ret = be32_to_cpup(iprop);
  202. of_node_put(parent);
  203. return ret;
  204. }
  205. /**
  206. * codec_node_dev_name - determine the dev_name for a codec node
  207. *
  208. * This function determines the dev_name for an I2C node. This is the name
  209. * that would be returned by dev_name() if this device_node were part of a
  210. * 'struct device' It's ugly and hackish, but it works.
  211. *
  212. * The dev_name for such devices include the bus number and I2C address. For
  213. * example, "cs4270-codec.0-004f".
  214. */
  215. static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
  216. {
  217. const u32 *iprop;
  218. int addr;
  219. char temp[DAI_NAME_SIZE];
  220. struct i2c_client *i2c;
  221. of_modalias_node(np, temp, DAI_NAME_SIZE);
  222. iprop = of_get_property(np, "reg", NULL);
  223. if (!iprop)
  224. return -EINVAL;
  225. addr = be32_to_cpup(iprop);
  226. /* We need the adapter number */
  227. i2c = of_find_i2c_device_by_node(np);
  228. if (!i2c)
  229. return -ENODEV;
  230. snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr);
  231. return 0;
  232. }
  233. static int get_dma_channel(struct device_node *ssi_np,
  234. const char *name,
  235. struct snd_soc_dai_link *dai,
  236. unsigned int *dma_channel_id,
  237. unsigned int *dma_id)
  238. {
  239. struct resource res;
  240. struct device_node *dma_channel_np;
  241. const u32 *iprop;
  242. int ret;
  243. dma_channel_np = get_node_by_phandle_name(ssi_np, name,
  244. "fsl,ssi-dma-channel");
  245. if (!dma_channel_np)
  246. return -EINVAL;
  247. /* Determine the dev_name for the device_node. This code mimics the
  248. * behavior of of_device_make_bus_id(). We need this because ASoC uses
  249. * the dev_name() of the device to match the platform (DMA) device with
  250. * the CPU (SSI) device. It's all ugly and hackish, but it works (for
  251. * now).
  252. *
  253. * dai->platform name should already point to an allocated buffer.
  254. */
  255. ret = of_address_to_resource(dma_channel_np, 0, &res);
  256. if (ret) {
  257. of_node_put(dma_channel_np);
  258. return ret;
  259. }
  260. snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",
  261. (unsigned long long) res.start, dma_channel_np->name);
  262. iprop = of_get_property(dma_channel_np, "cell-index", NULL);
  263. if (!iprop) {
  264. of_node_put(dma_channel_np);
  265. return -EINVAL;
  266. }
  267. *dma_channel_id = be32_to_cpup(iprop);
  268. *dma_id = get_parent_cell_index(dma_channel_np);
  269. of_node_put(dma_channel_np);
  270. return 0;
  271. }
  272. /**
  273. * p1022_ds_probe: platform probe function for the machine driver
  274. *
  275. * Although this is a machine driver, the SSI node is the "master" node with
  276. * respect to audio hardware connections. Therefore, we create a new ASoC
  277. * device for each new SSI node that has a codec attached.
  278. */
  279. static int p1022_ds_probe(struct platform_device *pdev)
  280. {
  281. struct device *dev = pdev->dev.parent;
  282. /* ssi_pdev is the platform device for the SSI node that probed us */
  283. struct platform_device *ssi_pdev =
  284. container_of(dev, struct platform_device, dev);
  285. struct device_node *np = ssi_pdev->dev.of_node;
  286. struct device_node *codec_np = NULL;
  287. struct platform_device *sound_device = NULL;
  288. struct machine_data *mdata;
  289. int ret = -ENODEV;
  290. const char *sprop;
  291. const u32 *iprop;
  292. /* Find the codec node for this SSI. */
  293. codec_np = of_parse_phandle(np, "codec-handle", 0);
  294. if (!codec_np) {
  295. dev_err(dev, "could not find codec node\n");
  296. return -EINVAL;
  297. }
  298. mdata = kzalloc(sizeof(struct machine_data), GFP_KERNEL);
  299. if (!mdata) {
  300. ret = -ENOMEM;
  301. goto error_put;
  302. }
  303. mdata->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
  304. mdata->dai[0].ops = &p1022_ds_ops;
  305. /* Determine the codec name, it will be used as the codec DAI name */
  306. ret = codec_node_dev_name(codec_np, mdata->codec_name, DAI_NAME_SIZE);
  307. if (ret) {
  308. dev_err(&pdev->dev, "invalid codec node %s\n",
  309. codec_np->full_name);
  310. ret = -EINVAL;
  311. goto error;
  312. }
  313. mdata->dai[0].codec_name = mdata->codec_name;
  314. /* We register two DAIs per SSI, one for playback and the other for
  315. * capture. We support codecs that have separate DAIs for both playback
  316. * and capture.
  317. */
  318. memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link));
  319. /* The DAI names from the codec (snd_soc_dai_driver.name) */
  320. mdata->dai[0].codec_dai_name = "wm8776-hifi-playback";
  321. mdata->dai[1].codec_dai_name = "wm8776-hifi-capture";
  322. /* Get the device ID */
  323. iprop = of_get_property(np, "cell-index", NULL);
  324. if (!iprop) {
  325. dev_err(&pdev->dev, "cell-index property not found\n");
  326. ret = -EINVAL;
  327. goto error;
  328. }
  329. mdata->ssi_id = be32_to_cpup(iprop);
  330. /* Get the serial format and clock direction. */
  331. sprop = of_get_property(np, "fsl,mode", NULL);
  332. if (!sprop) {
  333. dev_err(&pdev->dev, "fsl,mode property not found\n");
  334. ret = -EINVAL;
  335. goto error;
  336. }
  337. if (strcasecmp(sprop, "i2s-slave") == 0) {
  338. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  339. SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
  340. mdata->codec_clk_direction = SND_SOC_CLOCK_OUT;
  341. mdata->cpu_clk_direction = SND_SOC_CLOCK_IN;
  342. /* In i2s-slave mode, the codec has its own clock source, so we
  343. * need to get the frequency from the device tree and pass it to
  344. * the codec driver.
  345. */
  346. iprop = of_get_property(codec_np, "clock-frequency", NULL);
  347. if (!iprop || !*iprop) {
  348. dev_err(&pdev->dev, "codec bus-frequency "
  349. "property is missing or invalid\n");
  350. ret = -EINVAL;
  351. goto error;
  352. }
  353. mdata->clk_frequency = be32_to_cpup(iprop);
  354. } else if (strcasecmp(sprop, "i2s-master") == 0) {
  355. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  356. SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
  357. mdata->codec_clk_direction = SND_SOC_CLOCK_IN;
  358. mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  359. } else if (strcasecmp(sprop, "lj-slave") == 0) {
  360. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  361. SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM;
  362. mdata->codec_clk_direction = SND_SOC_CLOCK_OUT;
  363. mdata->cpu_clk_direction = SND_SOC_CLOCK_IN;
  364. } else if (strcasecmp(sprop, "lj-master") == 0) {
  365. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  366. SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBS_CFS;
  367. mdata->codec_clk_direction = SND_SOC_CLOCK_IN;
  368. mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  369. } else if (strcasecmp(sprop, "rj-slave") == 0) {
  370. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  371. SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBM_CFM;
  372. mdata->codec_clk_direction = SND_SOC_CLOCK_OUT;
  373. mdata->cpu_clk_direction = SND_SOC_CLOCK_IN;
  374. } else if (strcasecmp(sprop, "rj-master") == 0) {
  375. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  376. SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBS_CFS;
  377. mdata->codec_clk_direction = SND_SOC_CLOCK_IN;
  378. mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  379. } else if (strcasecmp(sprop, "ac97-slave") == 0) {
  380. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  381. SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBM_CFM;
  382. mdata->codec_clk_direction = SND_SOC_CLOCK_OUT;
  383. mdata->cpu_clk_direction = SND_SOC_CLOCK_IN;
  384. } else if (strcasecmp(sprop, "ac97-master") == 0) {
  385. mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
  386. SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBS_CFS;
  387. mdata->codec_clk_direction = SND_SOC_CLOCK_IN;
  388. mdata->cpu_clk_direction = SND_SOC_CLOCK_OUT;
  389. } else {
  390. dev_err(&pdev->dev,
  391. "unrecognized fsl,mode property '%s'\n", sprop);
  392. ret = -EINVAL;
  393. goto error;
  394. }
  395. if (!mdata->clk_frequency) {
  396. dev_err(&pdev->dev, "unknown clock frequency\n");
  397. ret = -EINVAL;
  398. goto error;
  399. }
  400. /* Find the playback DMA channel to use. */
  401. mdata->dai[0].platform_name = mdata->platform_name[0];
  402. ret = get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0],
  403. &mdata->dma_channel_id[0],
  404. &mdata->dma_id[0]);
  405. if (ret) {
  406. dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n");
  407. goto error;
  408. }
  409. /* Find the capture DMA channel to use. */
  410. mdata->dai[1].platform_name = mdata->platform_name[1];
  411. ret = get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1],
  412. &mdata->dma_channel_id[1],
  413. &mdata->dma_id[1]);
  414. if (ret) {
  415. dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n");
  416. goto error;
  417. }
  418. /* Initialize our DAI data structure. */
  419. mdata->dai[0].stream_name = "playback";
  420. mdata->dai[1].stream_name = "capture";
  421. mdata->dai[0].name = mdata->dai[0].stream_name;
  422. mdata->dai[1].name = mdata->dai[1].stream_name;
  423. mdata->card.probe = p1022_ds_machine_probe;
  424. mdata->card.remove = p1022_ds_machine_remove;
  425. mdata->card.name = pdev->name; /* The platform driver name */
  426. mdata->card.num_links = 2;
  427. mdata->card.dai_link = mdata->dai;
  428. /* Allocate a new audio platform device structure */
  429. sound_device = platform_device_alloc("soc-audio", -1);
  430. if (!sound_device) {
  431. dev_err(&pdev->dev, "platform device alloc failed\n");
  432. ret = -ENOMEM;
  433. goto error;
  434. }
  435. /* Associate the card data with the sound device */
  436. platform_set_drvdata(sound_device, &mdata->card);
  437. /* Register with ASoC */
  438. ret = platform_device_add(sound_device);
  439. if (ret) {
  440. dev_err(&pdev->dev, "platform device add failed\n");
  441. goto error;
  442. }
  443. dev_set_drvdata(&pdev->dev, sound_device);
  444. of_node_put(codec_np);
  445. return 0;
  446. error:
  447. if (sound_device)
  448. platform_device_put(sound_device);
  449. kfree(mdata);
  450. error_put:
  451. of_node_put(codec_np);
  452. return ret;
  453. }
  454. /**
  455. * p1022_ds_remove: remove the platform device
  456. *
  457. * This function is called when the platform device is removed.
  458. */
  459. static int __devexit p1022_ds_remove(struct platform_device *pdev)
  460. {
  461. struct platform_device *sound_device = dev_get_drvdata(&pdev->dev);
  462. struct snd_soc_card *card = platform_get_drvdata(sound_device);
  463. struct machine_data *mdata =
  464. container_of(card, struct machine_data, card);
  465. platform_device_unregister(sound_device);
  466. kfree(mdata);
  467. sound_device->dev.platform_data = NULL;
  468. dev_set_drvdata(&pdev->dev, NULL);
  469. return 0;
  470. }
  471. static struct platform_driver p1022_ds_driver = {
  472. .probe = p1022_ds_probe,
  473. .remove = __devexit_p(p1022_ds_remove),
  474. .driver = {
  475. /*
  476. * The name must match 'compatible' property in the device tree,
  477. * in lowercase letters.
  478. */
  479. .name = "snd-soc-p1022ds",
  480. .owner = THIS_MODULE,
  481. },
  482. };
  483. /**
  484. * p1022_ds_init: machine driver initialization.
  485. *
  486. * This function is called when this module is loaded.
  487. */
  488. static int __init p1022_ds_init(void)
  489. {
  490. struct device_node *guts_np;
  491. struct resource res;
  492. /* Get the physical address of the global utilities registers */
  493. guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts");
  494. if (of_address_to_resource(guts_np, 0, &res)) {
  495. pr_err("snd-soc-p1022ds: missing/invalid global utils node\n");
  496. of_node_put(guts_np);
  497. return -EINVAL;
  498. }
  499. guts_phys = res.start;
  500. of_node_put(guts_np);
  501. return platform_driver_register(&p1022_ds_driver);
  502. }
  503. /**
  504. * p1022_ds_exit: machine driver exit
  505. *
  506. * This function is called when this driver is unloaded.
  507. */
  508. static void __exit p1022_ds_exit(void)
  509. {
  510. platform_driver_unregister(&p1022_ds_driver);
  511. }
  512. module_init(p1022_ds_init);
  513. module_exit(p1022_ds_exit);
  514. MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
  515. MODULE_DESCRIPTION("Freescale P1022 DS ALSA SoC machine driver");
  516. MODULE_LICENSE("GPL v2");