diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-01-06 12:56:52 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-01-17 06:10:01 -0500 |
commit | 48dbc41988d07c7a9ba83afd31543d8ecb2beecc (patch) | |
tree | 457d418fcebb96b306e5eb3c9a8cc9d9b99ac785 /sound/soc/imx | |
parent | 157a777c8e809bd0c703e3f7617b3539df30feff (diff) |
ASoC: Convert new i.MX SSI driver to use static DAI array
While dynamically allocated DAIs are the way forward the core doesn't
yet support anything except matching with a pointer to the actual DAI
so convert to doing that so that machine drivers don't have to jump
through hoops to register themselves.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Javier Martin <javier.martin@vista-silicon.com>
Diffstat (limited to 'sound/soc/imx')
-rw-r--r-- | sound/soc/imx/imx-ssi.c | 40 | ||||
-rw-r--r-- | sound/soc/imx/imx-ssi.h | 3 |
2 files changed, 21 insertions, 22 deletions
diff --git a/sound/soc/imx/imx-ssi.c b/sound/soc/imx/imx-ssi.c index c57a11f66954..ccb7ec9ce997 100644 --- a/sound/soc/imx/imx-ssi.c +++ b/sound/soc/imx/imx-ssi.c | |||
@@ -60,7 +60,7 @@ | |||
60 | static int imx_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, | 60 | static int imx_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, |
61 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) | 61 | unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) |
62 | { | 62 | { |
63 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 63 | struct imx_ssi *ssi = cpu_dai->private_data; |
64 | u32 sccr; | 64 | u32 sccr; |
65 | 65 | ||
66 | sccr = readl(ssi->base + SSI_STCCR); | 66 | sccr = readl(ssi->base + SSI_STCCR); |
@@ -87,7 +87,7 @@ static int imx_ssi_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, | |||
87 | */ | 87 | */ |
88 | static int imx_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | 88 | static int imx_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) |
89 | { | 89 | { |
90 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 90 | struct imx_ssi *ssi = cpu_dai->private_data; |
91 | u32 strcr = 0, scr; | 91 | u32 strcr = 0, scr; |
92 | 92 | ||
93 | scr = readl(ssi->base + SSI_SCR) & ~(SSI_SCR_SYN | SSI_SCR_NET); | 93 | scr = readl(ssi->base + SSI_SCR) & ~(SSI_SCR_SYN | SSI_SCR_NET); |
@@ -160,7 +160,7 @@ static int imx_ssi_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) | |||
160 | static int imx_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | 160 | static int imx_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, |
161 | int clk_id, unsigned int freq, int dir) | 161 | int clk_id, unsigned int freq, int dir) |
162 | { | 162 | { |
163 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 163 | struct imx_ssi *ssi = cpu_dai->private_data; |
164 | u32 scr; | 164 | u32 scr; |
165 | 165 | ||
166 | scr = readl(ssi->base + SSI_SCR); | 166 | scr = readl(ssi->base + SSI_SCR); |
@@ -188,7 +188,7 @@ static int imx_ssi_set_dai_sysclk(struct snd_soc_dai *cpu_dai, | |||
188 | static int imx_ssi_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, | 188 | static int imx_ssi_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, |
189 | int div_id, int div) | 189 | int div_id, int div) |
190 | { | 190 | { |
191 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 191 | struct imx_ssi *ssi = cpu_dai->private_data; |
192 | u32 stccr, srccr; | 192 | u32 stccr, srccr; |
193 | 193 | ||
194 | stccr = readl(ssi->base + SSI_STCCR); | 194 | stccr = readl(ssi->base + SSI_STCCR); |
@@ -237,7 +237,7 @@ static int imx_ssi_hw_params(struct snd_pcm_substream *substream, | |||
237 | struct snd_pcm_hw_params *params, | 237 | struct snd_pcm_hw_params *params, |
238 | struct snd_soc_dai *cpu_dai) | 238 | struct snd_soc_dai *cpu_dai) |
239 | { | 239 | { |
240 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 240 | struct imx_ssi *ssi = cpu_dai->private_data; |
241 | u32 reg, sccr; | 241 | u32 reg, sccr; |
242 | 242 | ||
243 | /* Tx/Rx config */ | 243 | /* Tx/Rx config */ |
@@ -274,7 +274,7 @@ static int imx_ssi_trigger(struct snd_pcm_substream *substream, int cmd, | |||
274 | { | 274 | { |
275 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 275 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
276 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; | 276 | struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; |
277 | struct imx_ssi *ssi = container_of(cpu_dai, struct imx_ssi, dai); | 277 | struct imx_ssi *ssi = cpu_dai->private_data; |
278 | unsigned int sier_bits, sier; | 278 | unsigned int sier_bits, sier; |
279 | unsigned int scr; | 279 | unsigned int scr; |
280 | 280 | ||
@@ -570,7 +570,7 @@ struct snd_ac97_bus_ops soc_ac97_ops = { | |||
570 | }; | 570 | }; |
571 | EXPORT_SYMBOL_GPL(soc_ac97_ops); | 571 | EXPORT_SYMBOL_GPL(soc_ac97_ops); |
572 | 572 | ||
573 | struct snd_soc_dai *imx_ssi_pcm_dai[2]; | 573 | struct snd_soc_dai imx_ssi_pcm_dai[2]; |
574 | EXPORT_SYMBOL_GPL(imx_ssi_pcm_dai); | 574 | EXPORT_SYMBOL_GPL(imx_ssi_pcm_dai); |
575 | 575 | ||
576 | static int imx_ssi_probe(struct platform_device *pdev) | 576 | static int imx_ssi_probe(struct platform_device *pdev) |
@@ -581,6 +581,10 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
581 | struct snd_soc_platform *platform; | 581 | struct snd_soc_platform *platform; |
582 | int ret = 0; | 582 | int ret = 0; |
583 | unsigned int val; | 583 | unsigned int val; |
584 | struct snd_soc_dai *dai = &imx_ssi_pcm_dai[pdev->id]; | ||
585 | |||
586 | if (dai->id >= ARRAY_SIZE(imx_ssi_pcm_dai)) | ||
587 | return -EINVAL; | ||
584 | 588 | ||
585 | ssi = kzalloc(sizeof(*ssi), GFP_KERNEL); | 589 | ssi = kzalloc(sizeof(*ssi), GFP_KERNEL); |
586 | if (!ssi) | 590 | if (!ssi) |
@@ -592,8 +596,6 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
592 | ssi->flags = pdata->flags; | 596 | ssi->flags = pdata->flags; |
593 | } | 597 | } |
594 | 598 | ||
595 | imx_ssi_pcm_dai[pdev->id] = &ssi->dai; | ||
596 | |||
597 | ssi->irq = platform_get_irq(pdev, 0); | 599 | ssi->irq = platform_get_irq(pdev, 0); |
598 | 600 | ||
599 | ssi->clk = clk_get(&pdev->dev, NULL); | 601 | ssi->clk = clk_get(&pdev->dev, NULL); |
@@ -631,13 +633,9 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
631 | } | 633 | } |
632 | ac97_ssi = ssi; | 634 | ac97_ssi = ssi; |
633 | setup_channel_to_ac97(ssi); | 635 | setup_channel_to_ac97(ssi); |
634 | memcpy(&ssi->dai, &imx_ac97_dai, sizeof(imx_ac97_dai)); | 636 | memcpy(dai, &imx_ac97_dai, sizeof(imx_ac97_dai)); |
635 | } else | 637 | } else |
636 | memcpy(&ssi->dai, &imx_ssi_dai, sizeof(imx_ssi_dai)); | 638 | memcpy(dai, &imx_ssi_dai, sizeof(imx_ssi_dai)); |
637 | |||
638 | ssi->dai.id = pdev->id; | ||
639 | ssi->dai.dev = &pdev->dev; | ||
640 | ssi->dai.name = kasprintf(GFP_KERNEL, "imx-ssi.%d", pdev->id); | ||
641 | 639 | ||
642 | writel(0x0, ssi->base + SSI_SIER); | 640 | writel(0x0, ssi->base + SSI_SIER); |
643 | 641 | ||
@@ -652,9 +650,10 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
652 | if (res) | 650 | if (res) |
653 | ssi->dma_params_rx.dma = res->start; | 651 | ssi->dma_params_rx.dma = res->start; |
654 | 652 | ||
655 | ssi->dai.id = pdev->id; | 653 | dai->id = pdev->id; |
656 | ssi->dai.dev = &pdev->dev; | 654 | dai->dev = &pdev->dev; |
657 | ssi->dai.name = kasprintf(GFP_KERNEL, "imx-ssi.%d", pdev->id); | 655 | dai->name = kasprintf(GFP_KERNEL, "imx-ssi.%d", pdev->id); |
656 | dai->private_data = ssi; | ||
658 | 657 | ||
659 | if ((cpu_is_mx27() || cpu_is_mx21()) && | 658 | if ((cpu_is_mx27() || cpu_is_mx21()) && |
660 | !(ssi->flags & IMX_SSI_USE_AC97)) { | 659 | !(ssi->flags & IMX_SSI_USE_AC97)) { |
@@ -671,7 +670,7 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
671 | SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize); | 670 | SSI_SFCSR_RFWM0(ssi->dma_params_rx.burstsize); |
672 | writel(val, ssi->base + SSI_SFCSR); | 671 | writel(val, ssi->base + SSI_SFCSR); |
673 | 672 | ||
674 | ret = snd_soc_register_dai(&ssi->dai); | 673 | ret = snd_soc_register_dai(dai); |
675 | if (ret) { | 674 | if (ret) { |
676 | dev_err(&pdev->dev, "register DAI failed\n"); | 675 | dev_err(&pdev->dev, "register DAI failed\n"); |
677 | goto failed_register; | 676 | goto failed_register; |
@@ -699,8 +698,9 @@ static int __devexit imx_ssi_remove(struct platform_device *pdev) | |||
699 | { | 698 | { |
700 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 699 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
701 | struct imx_ssi *ssi = platform_get_drvdata(pdev); | 700 | struct imx_ssi *ssi = platform_get_drvdata(pdev); |
701 | struct snd_soc_dai *dai = &imx_ssi_pcm_dai[pdev->id]; | ||
702 | 702 | ||
703 | snd_soc_unregister_dai(&ssi->dai); | 703 | snd_soc_unregister_dai(dai); |
704 | 704 | ||
705 | if (ssi->flags & IMX_SSI_USE_AC97) | 705 | if (ssi->flags & IMX_SSI_USE_AC97) |
706 | ac97_ssi = NULL; | 706 | ac97_ssi = NULL; |
diff --git a/sound/soc/imx/imx-ssi.h b/sound/soc/imx/imx-ssi.h index cb2c81f1a6fc..55f26ebcd8c2 100644 --- a/sound/soc/imx/imx-ssi.h +++ b/sound/soc/imx/imx-ssi.h | |||
@@ -183,7 +183,7 @@ | |||
183 | #define IMX_SSI_RX_DIV_PSR 4 | 183 | #define IMX_SSI_RX_DIV_PSR 4 |
184 | #define IMX_SSI_RX_DIV_PM 5 | 184 | #define IMX_SSI_RX_DIV_PM 5 |
185 | 185 | ||
186 | extern struct snd_soc_dai *imx_ssi_pcm_dai[2]; | 186 | extern struct snd_soc_dai imx_ssi_pcm_dai[2]; |
187 | extern struct snd_soc_platform imx_soc_platform; | 187 | extern struct snd_soc_platform imx_soc_platform; |
188 | 188 | ||
189 | #define DRV_NAME "imx-ssi" | 189 | #define DRV_NAME "imx-ssi" |
@@ -195,7 +195,6 @@ struct imx_pcm_dma_params { | |||
195 | }; | 195 | }; |
196 | 196 | ||
197 | struct imx_ssi { | 197 | struct imx_ssi { |
198 | struct snd_soc_dai dai; | ||
199 | struct platform_device *ac97_dev; | 198 | struct platform_device *ac97_dev; |
200 | 199 | ||
201 | struct snd_soc_device imx_ac97; | 200 | struct snd_soc_device imx_ac97; |