ASoC: fsl: rename imx-pcm Kconfig options and filename
[deliverable/linux.git] / sound / soc / fsl / mpc8610_hpcd.c
CommitLineData
17467f23 1/**
f0fba2ad 2 * Freescale MPC8610HPCD ALSA SoC Machine driver
17467f23
TT
3 *
4 * Author: Timur Tabi <timur@freescale.com>
5 *
f0fba2ad
LG
6 * Copyright 2007-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.
17467f23
TT
11 */
12
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/of_device.h>
38fec727 16#include <linux/slab.h>
6132725e 17#include <linux/of_i2c.h>
17467f23 18#include <sound/soc.h>
6e6f6622 19#include <asm/fsl_guts.h>
17467f23 20
17467f23
TT
21#include "fsl_dma.h"
22#include "fsl_ssi.h"
23
f0fba2ad
LG
24/* There's only one global utilities register */
25static phys_addr_t guts_phys;
26
27#define DAI_NAME_SIZE 32
28
17467f23 29/**
f0fba2ad 30 * mpc8610_hpcd_data: machine-specific ASoC device data
17467f23
TT
31 *
32 * This structure contains data for a single sound platform device on an
33 * MPC8610 HPCD. Some of the data is taken from the device tree.
34 */
35struct mpc8610_hpcd_data {
f0fba2ad
LG
36 struct snd_soc_dai_link dai[2];
37 struct snd_soc_card card;
17467f23
TT
38 unsigned int dai_format;
39 unsigned int codec_clk_direction;
40 unsigned int cpu_clk_direction;
41 unsigned int clk_frequency;
f0fba2ad
LG
42 unsigned int ssi_id; /* 0 = SSI1, 1 = SSI2, etc */
43 unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */
17467f23 44 unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/
f0fba2ad
LG
45 char codec_dai_name[DAI_NAME_SIZE];
46 char codec_name[DAI_NAME_SIZE];
47 char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */
17467f23
TT
48};
49
50/**
f0fba2ad 51 * mpc8610_hpcd_machine_probe: initialize the board
17467f23 52 *
f0fba2ad 53 * This function is used to initialize the board-specific hardware.
17467f23
TT
54 *
55 * Here we program the DMACR and PMUXCR registers.
56 */
e7361ec4 57static int mpc8610_hpcd_machine_probe(struct snd_soc_card *card)
17467f23
TT
58{
59 struct mpc8610_hpcd_data *machine_data =
f0fba2ad 60 container_of(card, struct mpc8610_hpcd_data, card);
6e6f6622 61 struct ccsr_guts_86xx __iomem *guts;
17467f23 62
6e6f6622 63 guts = ioremap(guts_phys, sizeof(struct ccsr_guts_86xx));
f0fba2ad
LG
64 if (!guts) {
65 dev_err(card->dev, "could not map global utilities\n");
66 return -ENOMEM;
67 }
17467f23 68
f0fba2ad
LG
69 /* Program the signal routing between the SSI and the DMA */
70 guts_set_dmacr(guts, machine_data->dma_id[0],
71 machine_data->dma_channel_id[0],
72 CCSR_GUTS_DMACR_DEV_SSI);
73 guts_set_dmacr(guts, machine_data->dma_id[1],
74 machine_data->dma_channel_id[1],
75 CCSR_GUTS_DMACR_DEV_SSI);
76
77 guts_set_pmuxcr_dma(guts, machine_data->dma_id[0],
78 machine_data->dma_channel_id[0], 0);
79 guts_set_pmuxcr_dma(guts, machine_data->dma_id[1],
80 machine_data->dma_channel_id[1], 0);
17467f23 81
17467f23
TT
82 switch (machine_data->ssi_id) {
83 case 0:
f0fba2ad 84 clrsetbits_be32(&guts->pmuxcr,
17467f23
TT
85 CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_SSI);
86 break;
87 case 1:
f0fba2ad 88 clrsetbits_be32(&guts->pmuxcr,
17467f23
TT
89 CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_SSI);
90 break;
91 }
92
f0fba2ad
LG
93 iounmap(guts);
94
17467f23
TT
95 return 0;
96}
97
98/**
99 * mpc8610_hpcd_startup: program the board with various hardware parameters
100 *
101 * This function takes board-specific information, like clock frequencies
102 * and serial data formats, and passes that information to the codec and
103 * transport drivers.
104 */
105static int mpc8610_hpcd_startup(struct snd_pcm_substream *substream)
106{
107 struct snd_soc_pcm_runtime *rtd = substream->private_data;
17467f23 108 struct mpc8610_hpcd_data *machine_data =
f0fba2ad
LG
109 container_of(rtd->card, struct mpc8610_hpcd_data, card);
110 struct device *dev = rtd->card->dev;
17467f23
TT
111 int ret = 0;
112
17467f23 113 /* Tell the codec driver what the serial protocol is. */
f0fba2ad 114 ret = snd_soc_dai_set_fmt(rtd->codec_dai, machine_data->dai_format);
64105cfd 115 if (ret < 0) {
f0fba2ad 116 dev_err(dev, "could not set codec driver audio format\n");
64105cfd 117 return ret;
17467f23
TT
118 }
119
120 /*
121 * Tell the codec driver what the MCLK frequency is, and whether it's
122 * a slave or master.
123 */
f0fba2ad
LG
124 ret = snd_soc_dai_set_sysclk(rtd->codec_dai, 0,
125 machine_data->clk_frequency,
126 machine_data->codec_clk_direction);
64105cfd 127 if (ret < 0) {
f0fba2ad 128 dev_err(dev, "could not set codec driver clock params\n");
64105cfd 129 return ret;
17467f23
TT
130 }
131
132 return 0;
133}
134
135/**
136 * mpc8610_hpcd_machine_remove: Remove the sound device
137 *
138 * This function is called to remove the sound device for one SSI. We
139 * de-program the DMACR and PMUXCR register.
140 */
e7361ec4 141static int mpc8610_hpcd_machine_remove(struct snd_soc_card *card)
17467f23
TT
142{
143 struct mpc8610_hpcd_data *machine_data =
f0fba2ad 144 container_of(card, struct mpc8610_hpcd_data, card);
6e6f6622 145 struct ccsr_guts_86xx __iomem *guts;
f0fba2ad 146
6e6f6622 147 guts = ioremap(guts_phys, sizeof(struct ccsr_guts_86xx));
f0fba2ad
LG
148 if (!guts) {
149 dev_err(card->dev, "could not map global utilities\n");
150 return -ENOMEM;
151 }
17467f23
TT
152
153 /* Restore the signal routing */
154
f0fba2ad
LG
155 guts_set_dmacr(guts, machine_data->dma_id[0],
156 machine_data->dma_channel_id[0], 0);
157 guts_set_dmacr(guts, machine_data->dma_id[1],
158 machine_data->dma_channel_id[1], 0);
17467f23
TT
159
160 switch (machine_data->ssi_id) {
161 case 0:
f0fba2ad 162 clrsetbits_be32(&guts->pmuxcr,
17467f23
TT
163 CCSR_GUTS_PMUXCR_SSI1_MASK, CCSR_GUTS_PMUXCR_SSI1_LA);
164 break;
165 case 1:
f0fba2ad 166 clrsetbits_be32(&guts->pmuxcr,
83544994 167 CCSR_GUTS_PMUXCR_SSI2_MASK, CCSR_GUTS_PMUXCR_SSI2_LA);
17467f23
TT
168 break;
169 }
170
f0fba2ad
LG
171 iounmap(guts);
172
17467f23
TT
173 return 0;
174}
175
176/**
f0fba2ad 177 * mpc8610_hpcd_ops: ASoC machine driver operations
17467f23
TT
178 */
179static struct snd_soc_ops mpc8610_hpcd_ops = {
180 .startup = mpc8610_hpcd_startup,
181};
182
17467f23 183/**
f0fba2ad 184 * get_node_by_phandle_name - get a node by its phandle name
17467f23 185 *
f0fba2ad
LG
186 * This function takes a node, the name of a property in that node, and a
187 * compatible string. Assuming the property is a phandle to another node,
188 * it returns that node, (optionally) if that node is compatible.
17467f23 189 *
f0fba2ad
LG
190 * If the property is not a phandle, or the node it points to is not compatible
191 * with the specific string, then NULL is returned.
192 */
193static struct device_node *get_node_by_phandle_name(struct device_node *np,
194 const char *name,
195 const char *compatible)
196{
197 const phandle *ph;
198 int len;
199
200 ph = of_get_property(np, name, &len);
201 if (!ph || (len != sizeof(phandle)))
202 return NULL;
203
204 np = of_find_node_by_phandle(*ph);
205 if (!np)
206 return NULL;
207
208 if (compatible && !of_device_is_compatible(np, compatible)) {
209 of_node_put(np);
210 return NULL;
211 }
212
213 return np;
214}
215
216/**
217 * get_parent_cell_index -- return the cell-index of the parent of a node
17467f23 218 *
f0fba2ad
LG
219 * Return the value of the cell-index property of the parent of the given
220 * node. This is used for DMA channel nodes that need to know the DMA ID
221 * of the controller they are on.
222 */
223static int get_parent_cell_index(struct device_node *np)
224{
225 struct device_node *parent = of_get_parent(np);
226 const u32 *iprop;
227
228 if (!parent)
229 return -1;
230
231 iprop = of_get_property(parent, "cell-index", NULL);
232 of_node_put(parent);
233
234 if (!iprop)
235 return -1;
236
147dfe90 237 return be32_to_cpup(iprop);
f0fba2ad
LG
238}
239
240/**
241 * codec_node_dev_name - determine the dev_name for a codec node
17467f23 242 *
f0fba2ad
LG
243 * This function determines the dev_name for an I2C node. This is the name
244 * that would be returned by dev_name() if this device_node were part of a
245 * 'struct device' It's ugly and hackish, but it works.
246 *
247 * The dev_name for such devices include the bus number and I2C address. For
64902b29 248 * example, "cs4270.0-004f".
17467f23 249 */
f0fba2ad 250static int codec_node_dev_name(struct device_node *np, char *buf, size_t len)
17467f23 251{
17467f23 252 const u32 *iprop;
6132725e 253 int addr;
f0fba2ad 254 char temp[DAI_NAME_SIZE];
6132725e 255 struct i2c_client *i2c;
f0fba2ad
LG
256
257 of_modalias_node(np, temp, DAI_NAME_SIZE);
258
259 iprop = of_get_property(np, "reg", NULL);
260 if (!iprop)
261 return -EINVAL;
262
147dfe90 263 addr = be32_to_cpup(iprop);
f0fba2ad 264
6132725e
TT
265 /* We need the adapter number */
266 i2c = of_find_i2c_device_by_node(np);
267 if (!i2c)
268 return -ENODEV;
f0fba2ad 269
64902b29 270 snprintf(buf, len, "%s.%u-%04x", temp, i2c->adapter->nr, addr);
f0fba2ad
LG
271
272 return 0;
273}
274
275static int get_dma_channel(struct device_node *ssi_np,
fb1a6453 276 const char *name,
f0fba2ad
LG
277 struct snd_soc_dai_link *dai,
278 unsigned int *dma_channel_id,
279 unsigned int *dma_id)
280{
17467f23 281 struct resource res;
f0fba2ad
LG
282 struct device_node *dma_channel_np;
283 const u32 *iprop;
284 int ret;
285
fb1a6453 286 dma_channel_np = get_node_by_phandle_name(ssi_np, name,
f0fba2ad
LG
287 "fsl,ssi-dma-channel");
288 if (!dma_channel_np)
289 return -EINVAL;
290
291 /* Determine the dev_name for the device_node. This code mimics the
292 * behavior of of_device_make_bus_id(). We need this because ASoC uses
293 * the dev_name() of the device to match the platform (DMA) device with
294 * the CPU (SSI) device. It's all ugly and hackish, but it works (for
295 * now).
296 *
297 * dai->platform name should already point to an allocated buffer.
298 */
299 ret = of_address_to_resource(dma_channel_np, 0, &res);
300 if (ret)
301 return ret;
302 snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",
303 (unsigned long long) res.start, dma_channel_np->name);
304
305 iprop = of_get_property(dma_channel_np, "cell-index", NULL);
306 if (!iprop) {
307 of_node_put(dma_channel_np);
308 return -EINVAL;
309 }
310
147dfe90 311 *dma_channel_id = be32_to_cpup(iprop);
f0fba2ad
LG
312 *dma_id = get_parent_cell_index(dma_channel_np);
313 of_node_put(dma_channel_np);
314
315 return 0;
316}
317
318/**
319 * mpc8610_hpcd_probe: platform probe function for the machine driver
320 *
321 * Although this is a machine driver, the SSI node is the "master" node with
322 * respect to audio hardware connections. Therefore, we create a new ASoC
323 * device for each new SSI node that has a codec attached.
324 */
325static int mpc8610_hpcd_probe(struct platform_device *pdev)
326{
327 struct device *dev = pdev->dev.parent;
38fec727
TT
328 /* ssi_pdev is the platform device for the SSI node that probed us */
329 struct platform_device *ssi_pdev =
330 container_of(dev, struct platform_device, dev);
331 struct device_node *np = ssi_pdev->dev.of_node;
f0fba2ad 332 struct device_node *codec_np = NULL;
17467f23
TT
333 struct platform_device *sound_device = NULL;
334 struct mpc8610_hpcd_data *machine_data;
17467f23 335 int ret = -ENODEV;
f0fba2ad
LG
336 const char *sprop;
337 const u32 *iprop;
338
7c59bc55
SG
339 /* Find the codec node for this SSI. */
340 codec_np = of_parse_phandle(np, "codec-handle", 0);
f0fba2ad
LG
341 if (!codec_np) {
342 dev_err(dev, "invalid codec node\n");
343 return -EINVAL;
344 }
17467f23
TT
345
346 machine_data = kzalloc(sizeof(struct mpc8610_hpcd_data), GFP_KERNEL);
c09f5ca7
JL
347 if (!machine_data) {
348 ret = -ENOMEM;
349 goto error_alloc;
350 }
17467f23 351
38fec727 352 machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
f0fba2ad 353 machine_data->dai[0].ops = &mpc8610_hpcd_ops;
17467f23 354
f0fba2ad
LG
355 /* Determine the codec name, it will be used as the codec DAI name */
356 ret = codec_node_dev_name(codec_np, machine_data->codec_name,
357 DAI_NAME_SIZE);
358 if (ret) {
359 dev_err(&pdev->dev, "invalid codec node %s\n",
360 codec_np->full_name);
361 ret = -EINVAL;
17467f23 362 goto error;
f0fba2ad
LG
363 }
364 machine_data->dai[0].codec_name = machine_data->codec_name;
17467f23 365
f0fba2ad
LG
366 /* The DAI name from the codec (snd_soc_dai_driver.name) */
367 machine_data->dai[0].codec_dai_name = "cs4270-hifi";
17467f23 368
f0fba2ad
LG
369 /* We register two DAIs per SSI, one for playback and the other for
370 * capture. Currently, we only support codecs that have one DAI for
371 * both playback and capture.
372 */
373 memcpy(&machine_data->dai[1], &machine_data->dai[0],
374 sizeof(struct snd_soc_dai_link));
17467f23
TT
375
376 /* Get the device ID */
377 iprop = of_get_property(np, "cell-index", NULL);
378 if (!iprop) {
f0fba2ad 379 dev_err(&pdev->dev, "cell-index property not found\n");
17467f23
TT
380 ret = -EINVAL;
381 goto error;
382 }
147dfe90 383 machine_data->ssi_id = be32_to_cpup(iprop);
17467f23
TT
384
385 /* Get the serial format and clock direction. */
386 sprop = of_get_property(np, "fsl,mode", NULL);
387 if (!sprop) {
f0fba2ad 388 dev_err(&pdev->dev, "fsl,mode property not found\n");
17467f23
TT
389 ret = -EINVAL;
390 goto error;
391 }
392
393 if (strcasecmp(sprop, "i2s-slave") == 0) {
380c8830
TT
394 machine_data->dai_format =
395 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
17467f23
TT
396 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
397 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
398
f0fba2ad 399 /* In i2s-slave mode, the codec has its own clock source, so we
17467f23
TT
400 * need to get the frequency from the device tree and pass it to
401 * the codec driver.
402 */
403 iprop = of_get_property(codec_np, "clock-frequency", NULL);
404 if (!iprop || !*iprop) {
f0fba2ad
LG
405 dev_err(&pdev->dev, "codec bus-frequency "
406 "property is missing or invalid\n");
17467f23
TT
407 ret = -EINVAL;
408 goto error;
409 }
147dfe90 410 machine_data->clk_frequency = be32_to_cpup(iprop);
17467f23 411 } else if (strcasecmp(sprop, "i2s-master") == 0) {
380c8830
TT
412 machine_data->dai_format =
413 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS;
17467f23
TT
414 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
415 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
416 } else if (strcasecmp(sprop, "lj-slave") == 0) {
380c8830
TT
417 machine_data->dai_format =
418 SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBM_CFM;
17467f23
TT
419 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
420 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
421 } else if (strcasecmp(sprop, "lj-master") == 0) {
380c8830
TT
422 machine_data->dai_format =
423 SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBS_CFS;
17467f23
TT
424 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
425 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
e5c21571 426 } else if (strcasecmp(sprop, "rj-slave") == 0) {
380c8830
TT
427 machine_data->dai_format =
428 SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBM_CFM;
17467f23
TT
429 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
430 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
431 } else if (strcasecmp(sprop, "rj-master") == 0) {
380c8830
TT
432 machine_data->dai_format =
433 SND_SOC_DAIFMT_RIGHT_J | SND_SOC_DAIFMT_CBS_CFS;
17467f23
TT
434 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
435 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
436 } else if (strcasecmp(sprop, "ac97-slave") == 0) {
380c8830
TT
437 machine_data->dai_format =
438 SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBM_CFM;
17467f23
TT
439 machine_data->codec_clk_direction = SND_SOC_CLOCK_OUT;
440 machine_data->cpu_clk_direction = SND_SOC_CLOCK_IN;
441 } else if (strcasecmp(sprop, "ac97-master") == 0) {
380c8830
TT
442 machine_data->dai_format =
443 SND_SOC_DAIFMT_AC97 | SND_SOC_DAIFMT_CBS_CFS;
17467f23
TT
444 machine_data->codec_clk_direction = SND_SOC_CLOCK_IN;
445 machine_data->cpu_clk_direction = SND_SOC_CLOCK_OUT;
446 } else {
f0fba2ad
LG
447 dev_err(&pdev->dev,
448 "unrecognized fsl,mode property '%s'\n", sprop);
17467f23
TT
449 ret = -EINVAL;
450 goto error;
451 }
452
453 if (!machine_data->clk_frequency) {
f0fba2ad 454 dev_err(&pdev->dev, "unknown clock frequency\n");
17467f23
TT
455 ret = -EINVAL;
456 goto error;
457 }
458
f0fba2ad
LG
459 /* Find the playback DMA channel to use. */
460 machine_data->dai[0].platform_name = machine_data->platform_name[0];
461 ret = get_dma_channel(np, "fsl,playback-dma", &machine_data->dai[0],
462 &machine_data->dma_channel_id[0],
463 &machine_data->dma_id[0]);
17467f23 464 if (ret) {
f0fba2ad 465 dev_err(&pdev->dev, "missing/invalid playback DMA phandle\n");
17467f23
TT
466 goto error;
467 }
468
f0fba2ad
LG
469 /* Find the capture DMA channel to use. */
470 machine_data->dai[1].platform_name = machine_data->platform_name[1];
471 ret = get_dma_channel(np, "fsl,capture-dma", &machine_data->dai[1],
472 &machine_data->dma_channel_id[1],
473 &machine_data->dma_id[1]);
474 if (ret) {
475 dev_err(&pdev->dev, "missing/invalid capture DMA phandle\n");
17467f23
TT
476 goto error;
477 }
478
f0fba2ad
LG
479 /* Initialize our DAI data structure. */
480 machine_data->dai[0].stream_name = "playback";
481 machine_data->dai[1].stream_name = "capture";
482 machine_data->dai[0].name = machine_data->dai[0].stream_name;
483 machine_data->dai[1].name = machine_data->dai[1].stream_name;
17467f23 484
f0fba2ad
LG
485 machine_data->card.probe = mpc8610_hpcd_machine_probe;
486 machine_data->card.remove = mpc8610_hpcd_machine_remove;
487 machine_data->card.name = pdev->name; /* The platform driver name */
488 machine_data->card.num_links = 2;
489 machine_data->card.dai_link = machine_data->dai;
17467f23
TT
490
491 /* Allocate a new audio platform device structure */
492 sound_device = platform_device_alloc("soc-audio", -1);
493 if (!sound_device) {
f0fba2ad 494 dev_err(&pdev->dev, "platform device alloc failed\n");
17467f23
TT
495 ret = -ENOMEM;
496 goto error;
497 }
498
f0fba2ad
LG
499 /* Associate the card data with the sound device */
500 platform_set_drvdata(sound_device, &machine_data->card);
17467f23 501
f0fba2ad 502 /* Register with ASoC */
17467f23 503 ret = platform_device_add(sound_device);
17467f23 504 if (ret) {
f0fba2ad 505 dev_err(&pdev->dev, "platform device add failed\n");
c09f5ca7 506 goto error_sound;
17467f23 507 }
67bd489a 508 dev_set_drvdata(&pdev->dev, sound_device);
17467f23 509
f0fba2ad 510 of_node_put(codec_np);
17467f23
TT
511
512 return 0;
513
c09f5ca7 514error_sound:
d890a1a4 515 platform_device_put(sound_device);
17467f23 516error:
17467f23 517 kfree(machine_data);
c09f5ca7
JL
518error_alloc:
519 of_node_put(codec_np);
17467f23
TT
520 return ret;
521}
522
523/**
f0fba2ad 524 * mpc8610_hpcd_remove: remove the platform device
17467f23 525 *
f0fba2ad 526 * This function is called when the platform device is removed.
17467f23 527 */
f0fba2ad 528static int __devexit mpc8610_hpcd_remove(struct platform_device *pdev)
17467f23 529{
f0fba2ad
LG
530 struct platform_device *sound_device = dev_get_drvdata(&pdev->dev);
531 struct snd_soc_card *card = platform_get_drvdata(sound_device);
17467f23 532 struct mpc8610_hpcd_data *machine_data =
f0fba2ad 533 container_of(card, struct mpc8610_hpcd_data, card);
17467f23
TT
534
535 platform_device_unregister(sound_device);
536
17467f23
TT
537 kfree(machine_data);
538 sound_device->dev.platform_data = NULL;
539
f0fba2ad 540 dev_set_drvdata(&pdev->dev, NULL);
17467f23
TT
541
542 return 0;
543}
544
f0fba2ad
LG
545static struct platform_driver mpc8610_hpcd_driver = {
546 .probe = mpc8610_hpcd_probe,
547 .remove = __devexit_p(mpc8610_hpcd_remove),
4018294b 548 .driver = {
2b81ec69 549 /* The name must match 'compatible' property in the device tree,
f0fba2ad
LG
550 * in lowercase letters.
551 */
552 .name = "snd-soc-mpc8610hpcd",
4018294b 553 .owner = THIS_MODULE,
4018294b 554 },
17467f23
TT
555};
556
557/**
f0fba2ad 558 * mpc8610_hpcd_init: machine driver initialization.
17467f23
TT
559 *
560 * This function is called when this module is loaded.
561 */
562static int __init mpc8610_hpcd_init(void)
563{
f0fba2ad
LG
564 struct device_node *guts_np;
565 struct resource res;
17467f23 566
f0fba2ad 567 pr_info("Freescale MPC8610 HPCD ALSA SoC machine driver\n");
17467f23 568
f0fba2ad
LG
569 /* Get the physical address of the global utilities registers */
570 guts_np = of_find_compatible_node(NULL, NULL, "fsl,mpc8610-guts");
571 if (of_address_to_resource(guts_np, 0, &res)) {
572 pr_err("mpc8610-hpcd: missing/invalid global utilities node\n");
573 return -EINVAL;
574 }
575 guts_phys = res.start;
17467f23 576
f0fba2ad 577 return platform_driver_register(&mpc8610_hpcd_driver);
17467f23
TT
578}
579
580/**
f0fba2ad 581 * mpc8610_hpcd_exit: machine driver exit
17467f23
TT
582 *
583 * This function is called when this driver is unloaded.
584 */
585static void __exit mpc8610_hpcd_exit(void)
586{
f0fba2ad 587 platform_driver_unregister(&mpc8610_hpcd_driver);
17467f23
TT
588}
589
590module_init(mpc8610_hpcd_init);
591module_exit(mpc8610_hpcd_exit);
592
593MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
f0fba2ad
LG
594MODULE_DESCRIPTION("Freescale MPC8610 HPCD ALSA SoC machine driver");
595MODULE_LICENSE("GPL v2");
This page took 0.688342 seconds and 5 git commands to generate.