aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/fsl/mpc5200_psc_i2s.c
diff options
context:
space:
mode:
authorJon Smirl <jonsmirl@gmail.com>2009-05-23 19:13:01 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-05-24 14:31:03 -0400
commitcebe77674cab51a9ff1deaa077ab74aff3996764 (patch)
tree5f64370d795ffc835b39db88dfe67bdcf6de2de0 /sound/soc/fsl/mpc5200_psc_i2s.c
parent89dd08425273773fd33fc85d48d152c5679b2fb4 (diff)
ASoC: Rename the PSC functions to DMA
Rename the functions in the mpc5200 DMA file from i2s based names to dma ones to reflect the file they are in. Signed-off-by: Jon Smirl <jonsmirl@gmail.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/fsl/mpc5200_psc_i2s.c')
-rw-r--r--sound/soc/fsl/mpc5200_psc_i2s.c160
1 files changed, 80 insertions, 80 deletions
diff --git a/sound/soc/fsl/mpc5200_psc_i2s.c b/sound/soc/fsl/mpc5200_psc_i2s.c
index 8974b53eec9f..12a7917b57b0 100644
--- a/sound/soc/fsl/mpc5200_psc_i2s.c
+++ b/sound/soc/fsl/mpc5200_psc_i2s.c
@@ -54,10 +54,10 @@ static int psc_i2s_hw_params(struct snd_pcm_substream *substream,
54 struct snd_soc_dai *dai) 54 struct snd_soc_dai *dai)
55{ 55{
56 struct snd_soc_pcm_runtime *rtd = substream->private_data; 56 struct snd_soc_pcm_runtime *rtd = substream->private_data;
57 struct psc_i2s *psc_i2s = rtd->dai->cpu_dai->private_data; 57 struct psc_dma *psc_dma = rtd->dai->cpu_dai->private_data;
58 u32 mode; 58 u32 mode;
59 59
60 dev_dbg(psc_i2s->dev, "%s(substream=%p) p_size=%i p_bytes=%i" 60 dev_dbg(psc_dma->dev, "%s(substream=%p) p_size=%i p_bytes=%i"
61 " periods=%i buffer_size=%i buffer_bytes=%i\n", 61 " periods=%i buffer_size=%i buffer_bytes=%i\n",
62 __func__, substream, params_period_size(params), 62 __func__, substream, params_period_size(params),
63 params_period_bytes(params), params_periods(params), 63 params_period_bytes(params), params_periods(params),
@@ -77,10 +77,10 @@ static int psc_i2s_hw_params(struct snd_pcm_substream *substream,
77 mode = MPC52xx_PSC_SICR_SIM_CODEC_32; 77 mode = MPC52xx_PSC_SICR_SIM_CODEC_32;
78 break; 78 break;
79 default: 79 default:
80 dev_dbg(psc_i2s->dev, "invalid format\n"); 80 dev_dbg(psc_dma->dev, "invalid format\n");
81 return -EINVAL; 81 return -EINVAL;
82 } 82 }
83 out_be32(&psc_i2s->psc_regs->sicr, psc_i2s->sicr | mode); 83 out_be32(&psc_dma->psc_regs->sicr, psc_dma->sicr | mode);
84 84
85 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 85 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
86 86
@@ -104,8 +104,8 @@ static int psc_i2s_hw_params(struct snd_pcm_substream *substream,
104static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, 104static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
105 int clk_id, unsigned int freq, int dir) 105 int clk_id, unsigned int freq, int dir)
106{ 106{
107 struct psc_i2s *psc_i2s = cpu_dai->private_data; 107 struct psc_dma *psc_dma = cpu_dai->private_data;
108 dev_dbg(psc_i2s->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n", 108 dev_dbg(psc_dma->dev, "psc_i2s_set_sysclk(cpu_dai=%p, dir=%i)\n",
109 cpu_dai, dir); 109 cpu_dai, dir);
110 return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL; 110 return (dir == SND_SOC_CLOCK_IN) ? 0 : -EINVAL;
111} 111}
@@ -123,8 +123,8 @@ static int psc_i2s_set_sysclk(struct snd_soc_dai *cpu_dai,
123 */ 123 */
124static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format) 124static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format)
125{ 125{
126 struct psc_i2s *psc_i2s = cpu_dai->private_data; 126 struct psc_dma *psc_dma = cpu_dai->private_data;
127 dev_dbg(psc_i2s->dev, "psc_i2s_set_fmt(cpu_dai=%p, format=%i)\n", 127 dev_dbg(psc_dma->dev, "psc_i2s_set_fmt(cpu_dai=%p, format=%i)\n",
128 cpu_dai, format); 128 cpu_dai, format);
129 return (format == SND_SOC_DAIFMT_I2S) ? 0 : -EINVAL; 129 return (format == SND_SOC_DAIFMT_I2S) ? 0 : -EINVAL;
130} 130}
@@ -140,11 +140,11 @@ static int psc_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int format)
140 * psc_i2s_dai_template: template CPU Digital Audio Interface 140 * psc_i2s_dai_template: template CPU Digital Audio Interface
141 */ 141 */
142static struct snd_soc_dai_ops psc_i2s_dai_ops = { 142static struct snd_soc_dai_ops psc_i2s_dai_ops = {
143 .startup = psc_i2s_startup, 143 .startup = psc_dma_startup,
144 .hw_params = psc_i2s_hw_params, 144 .hw_params = psc_i2s_hw_params,
145 .hw_free = psc_i2s_hw_free, 145 .hw_free = psc_dma_hw_free,
146 .shutdown = psc_i2s_shutdown, 146 .shutdown = psc_dma_shutdown,
147 .trigger = psc_i2s_trigger, 147 .trigger = psc_dma_trigger,
148 .set_sysclk = psc_i2s_set_sysclk, 148 .set_sysclk = psc_i2s_set_sysclk,
149 .set_fmt = psc_i2s_set_fmt, 149 .set_fmt = psc_i2s_set_fmt,
150}; 150};
@@ -172,24 +172,24 @@ static struct snd_soc_dai psc_i2s_dai_template = {
172static ssize_t psc_i2s_status_show(struct device *dev, 172static ssize_t psc_i2s_status_show(struct device *dev,
173 struct device_attribute *attr, char *buf) 173 struct device_attribute *attr, char *buf)
174{ 174{
175 struct psc_i2s *psc_i2s = dev_get_drvdata(dev); 175 struct psc_dma *psc_dma = dev_get_drvdata(dev);
176 176
177 return sprintf(buf, "status=%.4x sicr=%.8x rfnum=%i rfstat=0x%.4x " 177 return sprintf(buf, "status=%.4x sicr=%.8x rfnum=%i rfstat=0x%.4x "
178 "tfnum=%i tfstat=0x%.4x\n", 178 "tfnum=%i tfstat=0x%.4x\n",
179 in_be16(&psc_i2s->psc_regs->sr_csr.status), 179 in_be16(&psc_dma->psc_regs->sr_csr.status),
180 in_be32(&psc_i2s->psc_regs->sicr), 180 in_be32(&psc_dma->psc_regs->sicr),
181 in_be16(&psc_i2s->fifo_regs->rfnum) & 0x1ff, 181 in_be16(&psc_dma->fifo_regs->rfnum) & 0x1ff,
182 in_be16(&psc_i2s->fifo_regs->rfstat), 182 in_be16(&psc_dma->fifo_regs->rfstat),
183 in_be16(&psc_i2s->fifo_regs->tfnum) & 0x1ff, 183 in_be16(&psc_dma->fifo_regs->tfnum) & 0x1ff,
184 in_be16(&psc_i2s->fifo_regs->tfstat)); 184 in_be16(&psc_dma->fifo_regs->tfstat));
185} 185}
186 186
187static int *psc_i2s_get_stat_attr(struct psc_i2s *psc_i2s, const char *name) 187static int *psc_i2s_get_stat_attr(struct psc_dma *psc_dma, const char *name)
188{ 188{
189 if (strcmp(name, "playback_underrun") == 0) 189 if (strcmp(name, "playback_underrun") == 0)
190 return &psc_i2s->stats.underrun_count; 190 return &psc_dma->stats.underrun_count;
191 if (strcmp(name, "capture_overrun") == 0) 191 if (strcmp(name, "capture_overrun") == 0)
192 return &psc_i2s->stats.overrun_count; 192 return &psc_dma->stats.overrun_count;
193 193
194 return NULL; 194 return NULL;
195} 195}
@@ -197,10 +197,10 @@ static int *psc_i2s_get_stat_attr(struct psc_i2s *psc_i2s, const char *name)
197static ssize_t psc_i2s_stat_show(struct device *dev, 197static ssize_t psc_i2s_stat_show(struct device *dev,
198 struct device_attribute *attr, char *buf) 198 struct device_attribute *attr, char *buf)
199{ 199{
200 struct psc_i2s *psc_i2s = dev_get_drvdata(dev); 200 struct psc_dma *psc_dma = dev_get_drvdata(dev);
201 int *attrib; 201 int *attrib;
202 202
203 attrib = psc_i2s_get_stat_attr(psc_i2s, attr->attr.name); 203 attrib = psc_i2s_get_stat_attr(psc_dma, attr->attr.name);
204 if (!attrib) 204 if (!attrib)
205 return 0; 205 return 0;
206 206
@@ -212,10 +212,10 @@ static ssize_t psc_i2s_stat_store(struct device *dev,
212 const char *buf, 212 const char *buf,
213 size_t count) 213 size_t count)
214{ 214{
215 struct psc_i2s *psc_i2s = dev_get_drvdata(dev); 215 struct psc_dma *psc_dma = dev_get_drvdata(dev);
216 int *attrib; 216 int *attrib;
217 217
218 attrib = psc_i2s_get_stat_attr(psc_i2s, attr->attr.name); 218 attrib = psc_i2s_get_stat_attr(psc_dma, attr->attr.name);
219 if (!attrib) 219 if (!attrib)
220 return 0; 220 return 0;
221 221
@@ -238,7 +238,7 @@ static int __devinit psc_i2s_of_probe(struct of_device *op,
238 const struct of_device_id *match) 238 const struct of_device_id *match)
239{ 239{
240 phys_addr_t fifo; 240 phys_addr_t fifo;
241 struct psc_i2s *psc_i2s; 241 struct psc_dma *psc_dma;
242 struct resource res; 242 struct resource res;
243 int size, psc_id, irq, rc; 243 int size, psc_id, irq, rc;
244 const __be32 *prop; 244 const __be32 *prop;
@@ -265,56 +265,56 @@ static int __devinit psc_i2s_of_probe(struct of_device *op,
265 } 265 }
266 266
267 /* Allocate and initialize the driver private data */ 267 /* Allocate and initialize the driver private data */
268 psc_i2s = kzalloc(sizeof *psc_i2s, GFP_KERNEL); 268 psc_dma = kzalloc(sizeof *psc_dma, GFP_KERNEL);
269 if (!psc_i2s) { 269 if (!psc_dma) {
270 iounmap(regs); 270 iounmap(regs);
271 return -ENOMEM; 271 return -ENOMEM;
272 } 272 }
273 spin_lock_init(&psc_i2s->lock); 273 spin_lock_init(&psc_dma->lock);
274 psc_i2s->irq = irq; 274 psc_dma->irq = irq;
275 psc_i2s->psc_regs = regs; 275 psc_dma->psc_regs = regs;
276 psc_i2s->fifo_regs = regs + sizeof *psc_i2s->psc_regs; 276 psc_dma->fifo_regs = regs + sizeof *psc_dma->psc_regs;
277 psc_i2s->dev = &op->dev; 277 psc_dma->dev = &op->dev;
278 psc_i2s->playback.psc_i2s = psc_i2s; 278 psc_dma->playback.psc_dma = psc_dma;
279 psc_i2s->capture.psc_i2s = psc_i2s; 279 psc_dma->capture.psc_dma = psc_dma;
280 snprintf(psc_i2s->name, sizeof psc_i2s->name, "PSC%u", psc_id+1); 280 snprintf(psc_dma->name, sizeof psc_dma->name, "PSC%u", psc_id+1);
281 281
282 /* Fill out the CPU DAI structure */ 282 /* Fill out the CPU DAI structure */
283 memcpy(&psc_i2s->dai, &psc_i2s_dai_template, sizeof psc_i2s->dai); 283 memcpy(&psc_dma->dai, &psc_i2s_dai_template, sizeof psc_dma->dai);
284 psc_i2s->dai.private_data = psc_i2s; 284 psc_dma->dai.private_data = psc_dma;
285 psc_i2s->dai.name = psc_i2s->name; 285 psc_dma->dai.name = psc_dma->name;
286 psc_i2s->dai.id = psc_id; 286 psc_dma->dai.id = psc_id;
287 287
288 /* Find the address of the fifo data registers and setup the 288 /* Find the address of the fifo data registers and setup the
289 * DMA tasks */ 289 * DMA tasks */
290 fifo = res.start + offsetof(struct mpc52xx_psc, buffer.buffer_32); 290 fifo = res.start + offsetof(struct mpc52xx_psc, buffer.buffer_32);
291 psc_i2s->capture.bcom_task = 291 psc_dma->capture.bcom_task =
292 bcom_psc_gen_bd_rx_init(psc_id, 10, fifo, 512); 292 bcom_psc_gen_bd_rx_init(psc_id, 10, fifo, 512);
293 psc_i2s->playback.bcom_task = 293 psc_dma->playback.bcom_task =
294 bcom_psc_gen_bd_tx_init(psc_id, 10, fifo); 294 bcom_psc_gen_bd_tx_init(psc_id, 10, fifo);
295 if (!psc_i2s->capture.bcom_task || 295 if (!psc_dma->capture.bcom_task ||
296 !psc_i2s->playback.bcom_task) { 296 !psc_dma->playback.bcom_task) {
297 dev_err(&op->dev, "Could not allocate bestcomm tasks\n"); 297 dev_err(&op->dev, "Could not allocate bestcomm tasks\n");
298 iounmap(regs); 298 iounmap(regs);
299 kfree(psc_i2s); 299 kfree(psc_dma);
300 return -ENODEV; 300 return -ENODEV;
301 } 301 }
302 302
303 /* Disable all interrupts and reset the PSC */ 303 /* Disable all interrupts and reset the PSC */
304 out_be16(&psc_i2s->psc_regs->isr_imr.imr, 0); 304 out_be16(&psc_dma->psc_regs->isr_imr.imr, 0);
305 out_8(&psc_i2s->psc_regs->command, 3 << 4); /* reset transmitter */ 305 out_8(&psc_dma->psc_regs->command, 3 << 4); /* reset transmitter */
306 out_8(&psc_i2s->psc_regs->command, 2 << 4); /* reset receiver */ 306 out_8(&psc_dma->psc_regs->command, 2 << 4); /* reset receiver */
307 out_8(&psc_i2s->psc_regs->command, 1 << 4); /* reset mode */ 307 out_8(&psc_dma->psc_regs->command, 1 << 4); /* reset mode */
308 out_8(&psc_i2s->psc_regs->command, 4 << 4); /* reset error */ 308 out_8(&psc_dma->psc_regs->command, 4 << 4); /* reset error */
309 309
310 /* Configure the serial interface mode; defaulting to CODEC8 mode */ 310 /* Configure the serial interface mode; defaulting to CODEC8 mode */
311 psc_i2s->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S | 311 psc_dma->sicr = MPC52xx_PSC_SICR_DTS1 | MPC52xx_PSC_SICR_I2S |
312 MPC52xx_PSC_SICR_CLKPOL; 312 MPC52xx_PSC_SICR_CLKPOL;
313 if (of_get_property(op->node, "fsl,cellslave", NULL)) 313 if (of_get_property(op->node, "fsl,cellslave", NULL))
314 psc_i2s->sicr |= MPC52xx_PSC_SICR_CELLSLAVE | 314 psc_dma->sicr |= MPC52xx_PSC_SICR_CELLSLAVE |
315 MPC52xx_PSC_SICR_GENCLK; 315 MPC52xx_PSC_SICR_GENCLK;
316 out_be32(&psc_i2s->psc_regs->sicr, 316 out_be32(&psc_dma->psc_regs->sicr,
317 psc_i2s->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8); 317 psc_dma->sicr | MPC52xx_PSC_SICR_SIM_CODEC_8);
318 318
319 /* Check for the codec handle. If it is not present then we 319 /* Check for the codec handle. If it is not present then we
320 * are done */ 320 * are done */
@@ -325,54 +325,54 @@ static int __devinit psc_i2s_of_probe(struct of_device *op,
325 * First write: RxRdy (FIFO Alarm) generates rx FIFO irq 325 * First write: RxRdy (FIFO Alarm) generates rx FIFO irq
326 * Second write: register Normal mode for non loopback 326 * Second write: register Normal mode for non loopback
327 */ 327 */
328 out_8(&psc_i2s->psc_regs->mode, 0); 328 out_8(&psc_dma->psc_regs->mode, 0);
329 out_8(&psc_i2s->psc_regs->mode, 0); 329 out_8(&psc_dma->psc_regs->mode, 0);
330 330
331 /* Set the TX and RX fifo alarm thresholds */ 331 /* Set the TX and RX fifo alarm thresholds */
332 out_be16(&psc_i2s->fifo_regs->rfalarm, 0x100); 332 out_be16(&psc_dma->fifo_regs->rfalarm, 0x100);
333 out_8(&psc_i2s->fifo_regs->rfcntl, 0x4); 333 out_8(&psc_dma->fifo_regs->rfcntl, 0x4);
334 out_be16(&psc_i2s->fifo_regs->tfalarm, 0x100); 334 out_be16(&psc_dma->fifo_regs->tfalarm, 0x100);
335 out_8(&psc_i2s->fifo_regs->tfcntl, 0x7); 335 out_8(&psc_dma->fifo_regs->tfcntl, 0x7);
336 336
337 /* Lookup the IRQ numbers */ 337 /* Lookup the IRQ numbers */
338 psc_i2s->playback.irq = 338 psc_dma->playback.irq =
339 bcom_get_task_irq(psc_i2s->playback.bcom_task); 339 bcom_get_task_irq(psc_dma->playback.bcom_task);
340 psc_i2s->capture.irq = 340 psc_dma->capture.irq =
341 bcom_get_task_irq(psc_i2s->capture.bcom_task); 341 bcom_get_task_irq(psc_dma->capture.bcom_task);
342 342
343 /* Save what we've done so it can be found again later */ 343 /* Save what we've done so it can be found again later */
344 dev_set_drvdata(&op->dev, psc_i2s); 344 dev_set_drvdata(&op->dev, psc_dma);
345 345
346 /* Register the SYSFS files */ 346 /* Register the SYSFS files */
347 rc = device_create_file(psc_i2s->dev, &dev_attr_status); 347 rc = device_create_file(psc_dma->dev, &dev_attr_status);
348 rc |= device_create_file(psc_i2s->dev, &dev_attr_capture_overrun); 348 rc |= device_create_file(psc_dma->dev, &dev_attr_capture_overrun);
349 rc |= device_create_file(psc_i2s->dev, &dev_attr_playback_underrun); 349 rc |= device_create_file(psc_dma->dev, &dev_attr_playback_underrun);
350 if (rc) 350 if (rc)
351 dev_info(psc_i2s->dev, "error creating sysfs files\n"); 351 dev_info(psc_dma->dev, "error creating sysfs files\n");
352 352
353 snd_soc_register_platform(&psc_i2s_pcm_soc_platform); 353 snd_soc_register_platform(&psc_dma_pcm_soc_platform);
354 354
355 /* Tell the ASoC OF helpers about it */ 355 /* Tell the ASoC OF helpers about it */
356 of_snd_soc_register_platform(&psc_i2s_pcm_soc_platform, op->node, 356 of_snd_soc_register_platform(&psc_dma_pcm_soc_platform, op->node,
357 &psc_i2s->dai); 357 &psc_dma->dai);
358 358
359 return 0; 359 return 0;
360} 360}
361 361
362static int __devexit psc_i2s_of_remove(struct of_device *op) 362static int __devexit psc_i2s_of_remove(struct of_device *op)
363{ 363{
364 struct psc_i2s *psc_i2s = dev_get_drvdata(&op->dev); 364 struct psc_dma *psc_dma = dev_get_drvdata(&op->dev);
365 365
366 dev_dbg(&op->dev, "psc_i2s_remove()\n"); 366 dev_dbg(&op->dev, "psc_i2s_remove()\n");
367 367
368 snd_soc_unregister_platform(&psc_i2s_pcm_soc_platform); 368 snd_soc_unregister_platform(&psc_dma_pcm_soc_platform);
369 369
370 bcom_gen_bd_rx_release(psc_i2s->capture.bcom_task); 370 bcom_gen_bd_rx_release(psc_dma->capture.bcom_task);
371 bcom_gen_bd_tx_release(psc_i2s->playback.bcom_task); 371 bcom_gen_bd_tx_release(psc_dma->playback.bcom_task);
372 372
373 iounmap(psc_i2s->psc_regs); 373 iounmap(psc_dma->psc_regs);
374 iounmap(psc_i2s->fifo_regs); 374 iounmap(psc_dma->fifo_regs);
375 kfree(psc_i2s); 375 kfree(psc_dma);
376 dev_set_drvdata(&op->dev, NULL); 376 dev_set_drvdata(&op->dev, NULL);
377 377
378 return 0; 378 return 0;