Commit 54c1e27d authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branch 'asoc/topic/kirkwood' into asoc-next

parents e6ddd861 e4065f3f
...@@ -108,8 +108,8 @@ static void __init dove_clk_init(void) ...@@ -108,8 +108,8 @@ static void __init dove_clk_init(void)
orion_clkdev_add(NULL, "sdhci-dove.1", sdio1); orion_clkdev_add(NULL, "sdhci-dove.1", sdio1);
orion_clkdev_add(NULL, "orion_nand", nand); orion_clkdev_add(NULL, "orion_nand", nand);
orion_clkdev_add(NULL, "cafe1000-ccic.0", camera); orion_clkdev_add(NULL, "cafe1000-ccic.0", camera);
orion_clkdev_add(NULL, "kirkwood-i2s.0", i2s0); orion_clkdev_add(NULL, "mvebu-audio.0", i2s0);
orion_clkdev_add(NULL, "kirkwood-i2s.1", i2s1); orion_clkdev_add(NULL, "mvebu-audio.1", i2s1);
orion_clkdev_add(NULL, "mv_crypto", crypto); orion_clkdev_add(NULL, "mv_crypto", crypto);
orion_clkdev_add(NULL, "dove-ac97", ac97); orion_clkdev_add(NULL, "dove-ac97", ac97);
orion_clkdev_add(NULL, "dove-pdma", pdma); orion_clkdev_add(NULL, "dove-pdma", pdma);
......
...@@ -264,7 +264,7 @@ void __init kirkwood_clk_init(void) ...@@ -264,7 +264,7 @@ void __init kirkwood_clk_init(void)
orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1); orion_clkdev_add(NULL, MV_XOR_NAME ".1", xor1);
orion_clkdev_add("0", "pcie", pex0); orion_clkdev_add("0", "pcie", pex0);
orion_clkdev_add("1", "pcie", pex1); orion_clkdev_add("1", "pcie", pex1);
orion_clkdev_add(NULL, "kirkwood-i2s", audio); orion_clkdev_add(NULL, "mvebu-audio", audio);
orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", runit); orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".0", runit);
orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".1", runit); orion_clkdev_add(NULL, MV64XXX_I2C_CTLR_NAME ".1", runit);
...@@ -560,7 +560,7 @@ void __init kirkwood_timer_init(void) ...@@ -560,7 +560,7 @@ void __init kirkwood_timer_init(void)
/***************************************************************************** /*****************************************************************************
* Audio * Audio
****************************************************************************/ ****************************************************************************/
static struct resource kirkwood_i2s_resources[] = { static struct resource kirkwood_audio_resources[] = {
[0] = { [0] = {
.start = AUDIO_PHYS_BASE, .start = AUDIO_PHYS_BASE,
.end = AUDIO_PHYS_BASE + SZ_16K - 1, .end = AUDIO_PHYS_BASE + SZ_16K - 1,
...@@ -573,29 +573,23 @@ static struct resource kirkwood_i2s_resources[] = { ...@@ -573,29 +573,23 @@ static struct resource kirkwood_i2s_resources[] = {
}, },
}; };
static struct kirkwood_asoc_platform_data kirkwood_i2s_data = { static struct kirkwood_asoc_platform_data kirkwood_audio_data = {
.burst = 128, .burst = 128,
}; };
static struct platform_device kirkwood_i2s_device = { static struct platform_device kirkwood_audio_device = {
.name = "kirkwood-i2s", .name = "mvebu-audio",
.id = -1, .id = -1,
.num_resources = ARRAY_SIZE(kirkwood_i2s_resources), .num_resources = ARRAY_SIZE(kirkwood_audio_resources),
.resource = kirkwood_i2s_resources, .resource = kirkwood_audio_resources,
.dev = { .dev = {
.platform_data = &kirkwood_i2s_data, .platform_data = &kirkwood_audio_data,
}, },
}; };
static struct platform_device kirkwood_pcm_device = {
.name = "kirkwood-pcm-audio",
.id = -1,
};
void __init kirkwood_audio_init(void) void __init kirkwood_audio_init(void)
{ {
platform_device_register(&kirkwood_i2s_device); platform_device_register(&kirkwood_audio_device);
platform_device_register(&kirkwood_pcm_device);
} }
/***************************************************************************** /*****************************************************************************
......
config SND_KIRKWOOD_SOC config SND_KIRKWOOD_SOC
tristate "SoC Audio for the Marvell Kirkwood chip" tristate "SoC Audio for the Marvell Kirkwood chip"
depends on ARCH_KIRKWOOD depends on ARCH_KIRKWOOD || COMPILE_TEST
help help
Say Y or M if you want to add support for codecs attached to Say Y or M if you want to add support for codecs attached to
the Kirkwood I2S interface. You will also need to select the the Kirkwood I2S interface. You will also need to select the
audio interfaces to support below. audio interfaces to support below.
config SND_KIRKWOOD_SOC_I2S
tristate
config SND_KIRKWOOD_SOC_OPENRD config SND_KIRKWOOD_SOC_OPENRD
tristate "SoC Audio support for Kirkwood Openrd Client" tristate "SoC Audio support for Kirkwood Openrd Client"
depends on SND_KIRKWOOD_SOC && (MACH_OPENRD_CLIENT || MACH_OPENRD_ULTIMATE) depends on SND_KIRKWOOD_SOC && (MACH_OPENRD_CLIENT || MACH_OPENRD_ULTIMATE || COMPILE_TEST)
depends on I2C depends on I2C
select SND_KIRKWOOD_SOC_I2S
select SND_SOC_CS42L51 select SND_SOC_CS42L51
help help
Say Y if you want to add support for SoC audio on Say Y if you want to add support for SoC audio on
...@@ -21,8 +17,7 @@ config SND_KIRKWOOD_SOC_OPENRD ...@@ -21,8 +17,7 @@ config SND_KIRKWOOD_SOC_OPENRD
config SND_KIRKWOOD_SOC_T5325 config SND_KIRKWOOD_SOC_T5325
tristate "SoC Audio support for HP t5325" tristate "SoC Audio support for HP t5325"
depends on SND_KIRKWOOD_SOC && MACH_T5325 && I2C depends on SND_KIRKWOOD_SOC && (MACH_T5325 || COMPILE_TEST) && I2C
select SND_KIRKWOOD_SOC_I2S
select SND_SOC_ALC5623 select SND_SOC_ALC5623
help help
Say Y if you want to add support for SoC audio on Say Y if you want to add support for SoC audio on
......
snd-soc-kirkwood-objs := kirkwood-dma.o snd-soc-kirkwood-objs := kirkwood-dma.o kirkwood-i2s.o
snd-soc-kirkwood-i2s-objs := kirkwood-i2s.o
obj-$(CONFIG_SND_KIRKWOOD_SOC) += snd-soc-kirkwood.o obj-$(CONFIG_SND_KIRKWOOD_SOC) += snd-soc-kirkwood.o
obj-$(CONFIG_SND_KIRKWOOD_SOC_I2S) += snd-soc-kirkwood-i2s.o
snd-soc-openrd-objs := kirkwood-openrd.o snd-soc-openrd-objs := kirkwood-openrd.o
snd-soc-t5325-objs := kirkwood-t5325.o snd-soc-t5325-objs := kirkwood-t5325.o
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \
SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE) SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE)
struct kirkwood_dma_priv { static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs)
struct snd_pcm_substream *play_stream; {
struct snd_pcm_substream *rec_stream; struct snd_soc_pcm_runtime *soc_runtime = subs->private_data;
struct kirkwood_dma_data *data; return snd_soc_dai_get_drvdata(soc_runtime->cpu_dai);
}; }
static struct snd_pcm_hardware kirkwood_dma_snd_hw = { static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
.info = (SNDRV_PCM_INFO_INTERLEAVED | .info = (SNDRV_PCM_INFO_INTERLEAVED |
...@@ -51,7 +51,7 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = { ...@@ -51,7 +51,7 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
.rate_max = 384000, .rate_max = 384000,
.channels_min = 1, .channels_min = 1,
.channels_max = 8, .channels_max = 8,
.buffer_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES * KIRKWOOD_SND_MAX_PERIODS, .buffer_bytes_max = KIRKWOOD_SND_MAX_BUFFER_BYTES,
.period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES, .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES,
.period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES, .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES,
.periods_min = KIRKWOOD_SND_MIN_PERIODS, .periods_min = KIRKWOOD_SND_MIN_PERIODS,
...@@ -63,8 +63,7 @@ static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32); ...@@ -63,8 +63,7 @@ static u64 kirkwood_dma_dmamask = DMA_BIT_MASK(32);
static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id) static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
{ {
struct kirkwood_dma_priv *prdata = dev_id; struct kirkwood_dma_data *priv = dev_id;
struct kirkwood_dma_data *priv = prdata->data;
unsigned long mask, status, cause; unsigned long mask, status, cause;
mask = readl(priv->io + KIRKWOOD_INT_MASK); mask = readl(priv->io + KIRKWOOD_INT_MASK);
...@@ -89,10 +88,10 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id) ...@@ -89,10 +88,10 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
writel(status, priv->io + KIRKWOOD_INT_CAUSE); writel(status, priv->io + KIRKWOOD_INT_CAUSE);
if (status & KIRKWOOD_INT_CAUSE_PLAY_BYTES) if (status & KIRKWOOD_INT_CAUSE_PLAY_BYTES)
snd_pcm_period_elapsed(prdata->play_stream); snd_pcm_period_elapsed(priv->substream_play);
if (status & KIRKWOOD_INT_CAUSE_REC_BYTES) if (status & KIRKWOOD_INT_CAUSE_REC_BYTES)
snd_pcm_period_elapsed(prdata->rec_stream); snd_pcm_period_elapsed(priv->substream_rec);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -126,15 +125,10 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) ...@@ -126,15 +125,10 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
{ {
int err; int err;
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct kirkwood_dma_data *priv = kirkwood_priv(substream);
struct snd_soc_platform *platform = soc_runtime->platform;
struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
struct kirkwood_dma_data *priv;
struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
const struct mbus_dram_target_info *dram; const struct mbus_dram_target_info *dram;
unsigned long addr; unsigned long addr;
priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
snd_soc_set_runtime_hwparams(substream, &kirkwood_dma_snd_hw); snd_soc_set_runtime_hwparams(substream, &kirkwood_dma_snd_hw);
/* Ensure that all constraints linked to dma burst are fulfilled */ /* Ensure that all constraints linked to dma burst are fulfilled */
...@@ -157,21 +151,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) ...@@ -157,21 +151,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
if (err < 0) if (err < 0)
return err; return err;
if (prdata == NULL) { if (!priv->substream_play && !priv->substream_rec) {
prdata = kzalloc(sizeof(struct kirkwood_dma_priv), GFP_KERNEL);
if (prdata == NULL)
return -ENOMEM;
prdata->data = priv;
err = request_irq(priv->irq, kirkwood_dma_irq, IRQF_SHARED, err = request_irq(priv->irq, kirkwood_dma_irq, IRQF_SHARED,
"kirkwood-i2s", prdata); "kirkwood-i2s", priv);
if (err) { if (err)
kfree(prdata);
return -EBUSY; return -EBUSY;
}
snd_soc_platform_set_drvdata(platform, prdata);
/* /*
* Enable Error interrupts. We're only ack'ing them but * Enable Error interrupts. We're only ack'ing them but
...@@ -183,11 +167,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) ...@@ -183,11 +167,11 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
dram = mv_mbus_dram_info(); dram = mv_mbus_dram_info();
addr = substream->dma_buffer.addr; addr = substream->dma_buffer.addr;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
prdata->play_stream = substream; priv->substream_play = substream;
kirkwood_dma_conf_mbus_windows(priv->io, kirkwood_dma_conf_mbus_windows(priv->io,
KIRKWOOD_PLAYBACK_WIN, addr, dram); KIRKWOOD_PLAYBACK_WIN, addr, dram);
} else { } else {
prdata->rec_stream = substream; priv->substream_rec = substream;
kirkwood_dma_conf_mbus_windows(priv->io, kirkwood_dma_conf_mbus_windows(priv->io,
KIRKWOOD_RECORD_WIN, addr, dram); KIRKWOOD_RECORD_WIN, addr, dram);
} }
...@@ -197,27 +181,19 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) ...@@ -197,27 +181,19 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
static int kirkwood_dma_close(struct snd_pcm_substream *substream) static int kirkwood_dma_close(struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct kirkwood_dma_data *priv = kirkwood_priv(substream);
struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
struct snd_soc_platform *platform = soc_runtime->platform;
struct kirkwood_dma_priv *prdata = snd_soc_platform_get_drvdata(platform);
struct kirkwood_dma_data *priv;
priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
if (!prdata || !priv) if (!priv)
return 0; return 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
prdata->play_stream = NULL; priv->substream_play = NULL;
else else
prdata->rec_stream = NULL; priv->substream_rec = NULL;
if (!prdata->play_stream && !prdata->rec_stream) { if (!priv->substream_play && !priv->substream_rec) {
writel(0, priv->io + KIRKWOOD_ERR_MASK); writel(0, priv->io + KIRKWOOD_ERR_MASK);
free_irq(priv->irq, prdata); free_irq(priv->irq, priv);
kfree(prdata);
snd_soc_platform_set_drvdata(platform, NULL);
} }
return 0; return 0;
...@@ -243,13 +219,9 @@ static int kirkwood_dma_hw_free(struct snd_pcm_substream *substream) ...@@ -243,13 +219,9 @@ static int kirkwood_dma_hw_free(struct snd_pcm_substream *substream)
static int kirkwood_dma_prepare(struct snd_pcm_substream *substream) static int kirkwood_dma_prepare(struct snd_pcm_substream *substream)
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct kirkwood_dma_data *priv = kirkwood_priv(substream);
struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
struct kirkwood_dma_data *priv;
unsigned long size, count; unsigned long size, count;
priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
/* compute buffer size in term of "words" as requested in specs */ /* compute buffer size in term of "words" as requested in specs */
size = frames_to_bytes(runtime, runtime->buffer_size); size = frames_to_bytes(runtime, runtime->buffer_size);
size = (size>>2)-1; size = (size>>2)-1;
...@@ -272,13 +244,9 @@ static int kirkwood_dma_prepare(struct snd_pcm_substream *substream) ...@@ -272,13 +244,9 @@ static int kirkwood_dma_prepare(struct snd_pcm_substream *substream)
static snd_pcm_uframes_t kirkwood_dma_pointer(struct snd_pcm_substream static snd_pcm_uframes_t kirkwood_dma_pointer(struct snd_pcm_substream
*substream) *substream)
{ {
struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct kirkwood_dma_data *priv = kirkwood_priv(substream);
struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
struct kirkwood_dma_data *priv;
snd_pcm_uframes_t count; snd_pcm_uframes_t count;
priv = snd_soc_dai_get_dma_data(cpu_dai, substream);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
count = bytes_to_frames(substream->runtime, count = bytes_to_frames(substream->runtime,
readl(priv->io + KIRKWOOD_PLAY_BYTE_COUNT)); readl(priv->io + KIRKWOOD_PLAY_BYTE_COUNT));
...@@ -366,36 +334,8 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm) ...@@ -366,36 +334,8 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm)
} }
} }
static struct snd_soc_platform_driver kirkwood_soc_platform = { struct snd_soc_platform_driver kirkwood_soc_platform = {
.ops = &kirkwood_dma_ops, .ops = &kirkwood_dma_ops,
.pcm_new = kirkwood_dma_new, .pcm_new = kirkwood_dma_new,
.pcm_free = kirkwood_dma_free_dma_buffers, .pcm_free = kirkwood_dma_free_dma_buffers,
}; };
static int kirkwood_soc_platform_probe(struct platform_device *pdev)
{
return snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform);
}
static int kirkwood_soc_platform_remove(struct platform_device *pdev)
{
snd_soc_unregister_platform(&pdev->dev);
return 0;
}
static struct platform_driver kirkwood_pcm_driver = {
.driver = {
.name = "kirkwood-pcm-audio",
.owner = THIS_MODULE,
},
.probe = kirkwood_soc_platform_probe,
.remove = kirkwood_soc_platform_remove,
};
module_platform_driver(kirkwood_pcm_driver);
MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>");
MODULE_DESCRIPTION("Marvell Kirkwood Audio DMA module");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:kirkwood-pcm-audio");
...@@ -24,11 +24,8 @@ ...@@ -24,11 +24,8 @@
#include <linux/platform_data/asoc-kirkwood.h> #include <linux/platform_data/asoc-kirkwood.h>
#include "kirkwood.h" #include "kirkwood.h"
#define DRV_NAME "kirkwood-i2s" #define DRV_NAME "mvebu-audio"
#define KIRKWOOD_I2S_RATES \
(SNDRV_PCM_RATE_44100 | \
SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000)
#define KIRKWOOD_I2S_FORMATS \ #define KIRKWOOD_I2S_FORMATS \
(SNDRV_PCM_FMTBIT_S16_LE | \ (SNDRV_PCM_FMTBIT_S16_LE | \
SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \
...@@ -105,14 +102,16 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai, ...@@ -105,14 +102,16 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai,
uint32_t clks_ctrl; uint32_t clks_ctrl;
if (rate == 44100 || rate == 48000 || rate == 96000) { if (rate == 44100 || rate == 48000 || rate == 96000) {
/* use internal dco for supported rates */ /* use internal dco for the supported rates
* defined in kirkwood_i2s_dai */
dev_dbg(dai->dev, "%s: dco set rate = %lu\n", dev_dbg(dai->dev, "%s: dco set rate = %lu\n",
__func__, rate); __func__, rate);
kirkwood_set_dco(priv->io, rate); kirkwood_set_dco(priv->io, rate);
clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO; clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO;
} else if (!IS_ERR(priv->extclk)) { } else {
/* use optional external clk for other rates */ /* use the external clock for the other rates
* defined in kirkwood_i2s_dai_extclk */
dev_dbg(dai->dev, "%s: extclk set rate = %lu -> %lu\n", dev_dbg(dai->dev, "%s: extclk set rate = %lu -> %lu\n",
__func__, rate, 256 * rate); __func__, rate, 256 * rate);
clk_set_rate(priv->extclk, 256 * rate); clk_set_rate(priv->extclk, 256 * rate);
...@@ -199,8 +198,7 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -199,8 +198,7 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
ctl_play |= KIRKWOOD_PLAYCTL_MONO_OFF; ctl_play |= KIRKWOOD_PLAYCTL_MONO_OFF;
priv->ctl_play &= ~(KIRKWOOD_PLAYCTL_MONO_MASK | priv->ctl_play &= ~(KIRKWOOD_PLAYCTL_MONO_MASK |
KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_ENABLE_MASK |
KIRKWOOD_PLAYCTL_SPDIF_EN |
KIRKWOOD_PLAYCTL_SIZE_MASK); KIRKWOOD_PLAYCTL_SIZE_MASK);
priv->ctl_play |= ctl_play; priv->ctl_play |= ctl_play;
} else { } else {
...@@ -244,8 +242,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, ...@@ -244,8 +242,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
/* configure */ /* configure */
ctl = priv->ctl_play; ctl = priv->ctl_play;
value = ctl & ~(KIRKWOOD_PLAYCTL_I2S_EN | value = ctl & ~KIRKWOOD_PLAYCTL_ENABLE_MASK;
KIRKWOOD_PLAYCTL_SPDIF_EN);
writel(value, priv->io + KIRKWOOD_PLAYCTL); writel(value, priv->io + KIRKWOOD_PLAYCTL);
/* enable interrupts */ /* enable interrupts */
...@@ -267,7 +264,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, ...@@ -267,7 +264,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
writel(value, priv->io + KIRKWOOD_INT_MASK); writel(value, priv->io + KIRKWOOD_INT_MASK);
/* disable all playbacks */ /* disable all playbacks */
ctl &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN); ctl &= ~KIRKWOOD_PLAYCTL_ENABLE_MASK;
writel(ctl, priv->io + KIRKWOOD_PLAYCTL); writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
break; break;
...@@ -387,7 +384,7 @@ static int kirkwood_i2s_probe(struct snd_soc_dai *dai) ...@@ -387,7 +384,7 @@ static int kirkwood_i2s_probe(struct snd_soc_dai *dai)
/* disable playback/record */ /* disable playback/record */
value = readl(priv->io + KIRKWOOD_PLAYCTL); value = readl(priv->io + KIRKWOOD_PLAYCTL);
value &= ~(KIRKWOOD_PLAYCTL_I2S_EN|KIRKWOOD_PLAYCTL_SPDIF_EN); value &= ~KIRKWOOD_PLAYCTL_ENABLE_MASK;
writel(value, priv->io + KIRKWOOD_PLAYCTL); writel(value, priv->io + KIRKWOOD_PLAYCTL);
value = readl(priv->io + KIRKWOOD_RECCTL); value = readl(priv->io + KIRKWOOD_RECCTL);
...@@ -398,11 +395,6 @@ static int kirkwood_i2s_probe(struct snd_soc_dai *dai) ...@@ -398,11 +395,6 @@ static int kirkwood_i2s_probe(struct snd_soc_dai *dai)
} }
static int kirkwood_i2s_remove(struct snd_soc_dai *dai)
{
return 0;
}
static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = {
.startup = kirkwood_i2s_startup, .startup = kirkwood_i2s_startup,
.trigger = kirkwood_i2s_trigger, .trigger = kirkwood_i2s_trigger,
...@@ -413,17 +405,18 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { ...@@ -413,17 +405,18 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = {
static struct snd_soc_dai_driver kirkwood_i2s_dai = { static struct snd_soc_dai_driver kirkwood_i2s_dai = {
.probe = kirkwood_i2s_probe, .probe = kirkwood_i2s_probe,
.remove = kirkwood_i2s_remove,
.playback = { .playback = {
.channels_min = 1, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = KIRKWOOD_I2S_RATES, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
SNDRV_PCM_RATE_96000,
.formats = KIRKWOOD_I2S_FORMATS, .formats = KIRKWOOD_I2S_FORMATS,
}, },
.capture = { .capture = {
.channels_min = 1, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
.rates = KIRKWOOD_I2S_RATES, .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
SNDRV_PCM_RATE_96000,
.formats = KIRKWOOD_I2S_FORMATS, .formats = KIRKWOOD_I2S_FORMATS,
}, },
.ops = &kirkwood_i2s_dai_ops, .ops = &kirkwood_i2s_dai_ops,
...@@ -431,7 +424,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai = { ...@@ -431,7 +424,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai = {
static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = { static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = {
.probe = kirkwood_i2s_probe, .probe = kirkwood_i2s_probe,
.remove = kirkwood_i2s_remove,
.playback = { .playback = {
.channels_min = 1, .channels_min = 1,
.channels_max = 2, .channels_max = 2,
...@@ -498,10 +490,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) ...@@ -498,10 +490,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
if (err < 0) if (err < 0)
return err; return err;
priv->extclk = clk_get(&pdev->dev, "extclk"); priv->extclk = devm_clk_get(&pdev->dev, "extclk");
if (!IS_ERR(priv->extclk)) { if (!IS_ERR(priv->extclk)) {
if (priv->extclk == priv->clk) { if (priv->extclk == priv->clk) {
clk_put(priv->extclk); devm_clk_put(&pdev->dev, priv->extclk);
priv->extclk = ERR_PTR(-EINVAL); priv->extclk = ERR_PTR(-EINVAL);
} else { } else {
dev_info(&pdev->dev, "found external clock\n"); dev_info(&pdev->dev, "found external clock\n");
...@@ -525,14 +517,22 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) ...@@ -525,14 +517,22 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev)
err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component,
soc_dai, 1); soc_dai, 1);
if (!err) if (err) {
return 0; dev_err(&pdev->dev, "snd_soc_register_component failed\n");
dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component;
}
if (!IS_ERR(priv->extclk)) { err = snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform);
clk_disable_unprepare(priv->extclk); if (err) {
clk_put(priv->extclk); dev_err(&pdev->dev, "snd_soc_register_platform failed\n");
goto err_platform;
} }
return 0;
err_platform:
snd_soc_unregister_component(&pdev->dev);
err_component:
if (!IS_ERR(priv->extclk))
clk_disable_unprepare(priv->extclk);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
return err; return err;
...@@ -542,12 +542,11 @@ static int kirkwood_i2s_dev_remove(struct platform_device *pdev) ...@@ -542,12 +542,11 @@ static int kirkwood_i2s_dev_remove(struct platform_device *pdev)
{ {
struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_platform(&pdev->dev);
snd_soc_unregister_component(&pdev->dev); snd_soc_unregister_component(&pdev->dev);
if (!IS_ERR(priv->extclk)) { if (!IS_ERR(priv->extclk))
clk_disable_unprepare(priv->extclk); clk_disable_unprepare(priv->extclk);
clk_put(priv->extclk);
}
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
return 0; return 0;
...@@ -568,4 +567,4 @@ module_platform_driver(kirkwood_i2s_driver); ...@@ -568,4 +567,4 @@ module_platform_driver(kirkwood_i2s_driver);
MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>"); MODULE_AUTHOR("Arnaud Patard, <arnaud.patard@rtp-net.org>");
MODULE_DESCRIPTION("Kirkwood I2S SoC Interface"); MODULE_DESCRIPTION("Kirkwood I2S SoC Interface");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:kirkwood-i2s"); MODULE_ALIAS("platform:mvebu-audio");
...@@ -16,9 +16,7 @@ ...@@ -16,9 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <mach/kirkwood.h>
#include <linux/platform_data/asoc-kirkwood.h> #include <linux/platform_data/asoc-kirkwood.h>
#include <asm/mach-types.h>
#include "../codecs/cs42l51.h" #include "../codecs/cs42l51.h"
static int openrd_client_hw_params(struct snd_pcm_substream *substream, static int openrd_client_hw_params(struct snd_pcm_substream *substream,
...@@ -54,8 +52,8 @@ static struct snd_soc_dai_link openrd_client_dai[] = { ...@@ -54,8 +52,8 @@ static struct snd_soc_dai_link openrd_client_dai[] = {
{ {
.name = "CS42L51", .name = "CS42L51",
.stream_name = "CS42L51 HiFi", .stream_name = "CS42L51 HiFi",
.cpu_dai_name = "kirkwood-i2s", .cpu_dai_name = "mvebu-audio",
.platform_name = "kirkwood-pcm-audio", .platform_name = "mvebu-audio",
.codec_dai_name = "cs42l51-hifi", .codec_dai_name = "cs42l51-hifi",
.codec_name = "cs42l51-codec.0-004a", .codec_name = "cs42l51-codec.0-004a",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <mach/kirkwood.h>
#include <linux/platform_data/asoc-kirkwood.h> #include <linux/platform_data/asoc-kirkwood.h>
#include <asm/mach-types.h>
#include "../codecs/alc5623.h" #include "../codecs/alc5623.h"
static int t5325_hw_params(struct snd_pcm_substream *substream, static int t5325_hw_params(struct snd_pcm_substream *substream,
...@@ -70,8 +68,8 @@ static struct snd_soc_dai_link t5325_dai[] = { ...@@ -70,8 +68,8 @@ static struct snd_soc_dai_link t5325_dai[] = {
{ {
.name = "ALC5621", .name = "ALC5621",
.stream_name = "ALC5621 HiFi", .stream_name = "ALC5621 HiFi",
.cpu_dai_name = "kirkwood-i2s", .cpu_dai_name = "mvebu-audio",
.platform_name = "kirkwood-pcm-audio", .platform_name = "mvebu-audio",
.codec_dai_name = "alc5621-hifi", .codec_dai_name = "alc5621-hifi",
.codec_name = "alc562x-codec.0-001a", .codec_name = "alc562x-codec.0-001a",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS,
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#define KIRKWOOD_PLAYCTL_MONO_OFF (0<<5) #define KIRKWOOD_PLAYCTL_MONO_OFF (0<<5)
#define KIRKWOOD_PLAYCTL_I2S_MUTE (1<<7) #define KIRKWOOD_PLAYCTL_I2S_MUTE (1<<7)
#define KIRKWOOD_PLAYCTL_SPDIF_EN (1<<4) #define KIRKWOOD_PLAYCTL_SPDIF_EN (1<<4)
#define KIRKWOOD_PLAYCTL_I2S_EN (1<<3) #define KIRKWOOD_PLAYCTL_I2S_EN (1<<3)
#define KIRKWOOD_PLAYCTL_SIZE_MASK (7<<0) #define KIRKWOOD_PLAYCTL_SIZE_MASK (7<<0)
#define KIRKWOOD_PLAYCTL_SIZE_16 (7<<0) #define KIRKWOOD_PLAYCTL_SIZE_16 (7<<0)
#define KIRKWOOD_PLAYCTL_SIZE_16_C (3<<0) #define KIRKWOOD_PLAYCTL_SIZE_16_C (3<<0)
...@@ -62,6 +62,9 @@ ...@@ -62,6 +62,9 @@
#define KIRKWOOD_PLAYCTL_SIZE_24 (1<<0) #define KIRKWOOD_PLAYCTL_SIZE_24 (1<<0)
#define KIRKWOOD_PLAYCTL_SIZE_32 (0<<0) #define KIRKWOOD_PLAYCTL_SIZE_32 (0<<0)
#define KIRKWOOD_PLAYCTL_ENABLE_MASK (KIRKWOOD_PLAYCTL_SPDIF_EN | \
KIRKWOOD_PLAYCTL_I2S_EN)
#define KIRKWOOD_PLAY_BUF_ADDR 0x1104 #define KIRKWOOD_PLAY_BUF_ADDR 0x1104
#define KIRKWOOD_PLAY_BUF_SIZE 0x1108 #define KIRKWOOD_PLAY_BUF_SIZE 0x1108
#define KIRKWOOD_PLAY_BYTE_COUNT 0x110C #define KIRKWOOD_PLAY_BYTE_COUNT 0x110C
...@@ -122,6 +125,8 @@ ...@@ -122,6 +125,8 @@
#define KIRKWOOD_SND_MAX_PERIODS 16 #define KIRKWOOD_SND_MAX_PERIODS 16
#define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x4000 #define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x4000
#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000 #define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000
#define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \
* KIRKWOOD_SND_MAX_PERIODS)
struct kirkwood_dma_data { struct kirkwood_dma_data {
void __iomem *io; void __iomem *io;
...@@ -129,8 +134,12 @@ struct kirkwood_dma_data { ...@@ -129,8 +134,12 @@ struct kirkwood_dma_data {
struct clk *extclk; struct clk *extclk;
uint32_t ctl_play; uint32_t ctl_play;
uint32_t ctl_rec; uint32_t ctl_rec;
struct snd_pcm_substream *substream_play;
struct snd_pcm_substream *substream_rec;
int irq; int irq;
int burst; int burst;
}; };
extern struct snd_soc_platform_driver kirkwood_soc_platform;
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment