kirkwood-i2s.c (d8d11ba566761625e2b5ab716dca920725f3dc0b) kirkwood-i2s.c (363589bf110aa0352a203112af16685dd9cb56c1)
1/*
2 * kirkwood-i2s.c
3 *
4 * (c) 2010 Arnaud Patard <apatard@mandriva.com>
5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 85 unchanged lines hidden (view full) ---

94 /* wait for dco locked */
95 do {
96 cpu_relax();
97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS);
98 value &= KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK;
99 } while (value == 0);
100}
101
1/*
2 * kirkwood-i2s.c
3 *
4 * (c) 2010 Arnaud Patard <apatard@mandriva.com>
5 * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the

--- 85 unchanged lines hidden (view full) ---

94 /* wait for dco locked */
95 do {
96 cpu_relax();
97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS);
98 value &= KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK;
99 } while (value == 0);
100}
101
102static void kirkwood_set_rate(struct snd_soc_dai *dai,
103 struct kirkwood_dma_data *priv, unsigned long rate)
104{
105 uint32_t clks_ctrl;
106
107 if (rate == 44100 || rate == 48000 || rate == 96000) {
108 /* use internal dco for supported rates */
109 dev_dbg(dai->dev, "%s: dco set rate = %lu\n",
110 __func__, rate);
111 kirkwood_set_dco(priv->io, rate);
112
113 clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO;
114 } else if (!IS_ERR(priv->extclk)) {
115 /* use optional external clk for other rates */
116 dev_dbg(dai->dev, "%s: extclk set rate = %lu -> %lu\n",
117 __func__, rate, 256 * rate);
118 clk_set_rate(priv->extclk, 256 * rate);
119
120 clks_ctrl = KIRKWOOD_MCLK_SOURCE_EXTCLK;
121 }
122 writel(clks_ctrl, priv->io + KIRKWOOD_CLOCKS_CTRL);
123}
124
102static int kirkwood_i2s_startup(struct snd_pcm_substream *substream,
103 struct snd_soc_dai *dai)
104{
105 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
106
107 snd_soc_dai_set_dma_data(dai, substream, priv);
108 return 0;
109}

--- 8 unchanged lines hidden (view full) ---

118 unsigned long i2s_value;
119
120 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
121 i2s_reg = KIRKWOOD_I2S_PLAYCTL;
122 } else {
123 i2s_reg = KIRKWOOD_I2S_RECCTL;
124 }
125
125static int kirkwood_i2s_startup(struct snd_pcm_substream *substream,
126 struct snd_soc_dai *dai)
127{
128 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
129
130 snd_soc_dai_set_dma_data(dai, substream, priv);
131 return 0;
132}

--- 8 unchanged lines hidden (view full) ---

141 unsigned long i2s_value;
142
143 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
144 i2s_reg = KIRKWOOD_I2S_PLAYCTL;
145 } else {
146 i2s_reg = KIRKWOOD_I2S_RECCTL;
147 }
148
126 /* set dco conf */
127 kirkwood_set_dco(priv->io, params_rate(params));
149 kirkwood_set_rate(dai, priv, params_rate(params));
128
129 i2s_value = readl(priv->io+i2s_reg);
130 i2s_value &= ~KIRKWOOD_I2S_CTL_SIZE_MASK;
131
132 /*
133 * Size settings in play/rec i2s control regs and play/rec control
134 * regs must be the same.
135 */

--- 255 unchanged lines hidden (view full) ---

391
392static struct snd_soc_dai_driver kirkwood_i2s_dai = {
393 .probe = kirkwood_i2s_probe,
394 .remove = kirkwood_i2s_remove,
395 .playback = {
396 .channels_min = 1,
397 .channels_max = 2,
398 .rates = KIRKWOOD_I2S_RATES,
150
151 i2s_value = readl(priv->io+i2s_reg);
152 i2s_value &= ~KIRKWOOD_I2S_CTL_SIZE_MASK;
153
154 /*
155 * Size settings in play/rec i2s control regs and play/rec control
156 * regs must be the same.
157 */

--- 255 unchanged lines hidden (view full) ---

413
414static struct snd_soc_dai_driver kirkwood_i2s_dai = {
415 .probe = kirkwood_i2s_probe,
416 .remove = kirkwood_i2s_remove,
417 .playback = {
418 .channels_min = 1,
419 .channels_max = 2,
420 .rates = KIRKWOOD_I2S_RATES,
399 .formats = KIRKWOOD_I2S_FORMATS,},
421 .formats = KIRKWOOD_I2S_FORMATS,
422 },
400 .capture = {
401 .channels_min = 1,
402 .channels_max = 2,
403 .rates = KIRKWOOD_I2S_RATES,
423 .capture = {
424 .channels_min = 1,
425 .channels_max = 2,
426 .rates = KIRKWOOD_I2S_RATES,
404 .formats = KIRKWOOD_I2S_FORMATS,},
427 .formats = KIRKWOOD_I2S_FORMATS,
428 },
405 .ops = &kirkwood_i2s_dai_ops,
406};
407
429 .ops = &kirkwood_i2s_dai_ops,
430};
431
432static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = {
433 .probe = kirkwood_i2s_probe,
434 .remove = kirkwood_i2s_remove,
435 .playback = {
436 .channels_min = 1,
437 .channels_max = 2,
438 .rates = SNDRV_PCM_RATE_8000_192000 |
439 SNDRV_PCM_RATE_CONTINUOUS |
440 SNDRV_PCM_RATE_KNOT,
441 .formats = KIRKWOOD_I2S_FORMATS,
442 },
443 .capture = {
444 .channels_min = 1,
445 .channels_max = 2,
446 .rates = SNDRV_PCM_RATE_8000_192000 |
447 SNDRV_PCM_RATE_CONTINUOUS |
448 SNDRV_PCM_RATE_KNOT,
449 .formats = KIRKWOOD_I2S_FORMATS,
450 },
451 .ops = &kirkwood_i2s_dai_ops,
452};
453
408static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
409{
454static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
455{
410 struct resource *mem;
411 struct kirkwood_asoc_platform_data *data =
412 pdev->dev.platform_data;
456 struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data;
457 struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai;
413 struct kirkwood_dma_data *priv;
458 struct kirkwood_dma_data *priv;
459 struct resource *mem;
414 int err;
415
416 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
417 if (!priv) {
418 dev_err(&pdev->dev, "allocation failed\n");
419 return -ENOMEM;
420 }
421 dev_set_drvdata(&pdev->dev, priv);

--- 53 unchanged lines hidden (view full) ---

475 if (data->burst == 32) {
476 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_32;
477 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_32;
478 } else {
479 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_128;
480 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
481 }
482
460 int err;
461
462 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
463 if (!priv) {
464 dev_err(&pdev->dev, "allocation failed\n");
465 return -ENOMEM;
466 }
467 dev_set_drvdata(&pdev->dev, priv);

--- 53 unchanged lines hidden (view full) ---

521 if (data->burst == 32) {
522 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_32;
523 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_32;
524 } else {
525 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_128;
526 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
527 }
528
483 err = snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
529 err = snd_soc_register_dai(&pdev->dev, soc_dai);
484 if (!err)
485 return 0;
486 dev_err(&pdev->dev, "snd_soc_register_dai failed\n");
487
530 if (!err)
531 return 0;
532 dev_err(&pdev->dev, "snd_soc_register_dai failed\n");
533
534 if (!IS_ERR(priv->extclk)) {
535 clk_disable_unprepare(priv->extclk);
536 clk_put(priv->extclk);
537 }
488 clk_disable_unprepare(priv->clk);
489
490 return err;
491}
492
493static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
494{
495 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
496
497 snd_soc_unregister_dai(&pdev->dev);
498
538 clk_disable_unprepare(priv->clk);
539
540 return err;
541}
542
543static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
544{
545 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
546
547 snd_soc_unregister_dai(&pdev->dev);
548
549 if (!IS_ERR(priv->extclk)) {
550 clk_disable_unprepare(priv->extclk);
551 clk_put(priv->extclk);
552 }
499 clk_disable_unprepare(priv->clk);
500
501 return 0;
502}
503
504static struct platform_driver kirkwood_i2s_driver = {
505 .probe = kirkwood_i2s_dev_probe,
506 .remove = __devexit_p(kirkwood_i2s_dev_remove),

--- 13 unchanged lines hidden ---
553 clk_disable_unprepare(priv->clk);
554
555 return 0;
556}
557
558static struct platform_driver kirkwood_i2s_driver = {
559 .probe = kirkwood_i2s_dev_probe,
560 .remove = __devexit_p(kirkwood_i2s_dev_remove),

--- 13 unchanged lines hidden ---