aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2009-11-02 15:21:44 -0500
committerRalf Baechle <ralf@linux-mips.org>2010-02-27 06:53:01 -0500
commit05ae3231801df8fdb4e1c0aa4aa6b8d7278eddde (patch)
tree365411decb44bf15dcae5da42434c71cecc9acff
parent63323ec54a7e922a232c82070727e44eb1a5b43c (diff)
MIPS/SOUND: Alchemy: DB1200 AC97+I2S audio support.
Machine driver for DB1200 AC97 and I2S audio systems, intended as a proper reference asoc machine for Alchemy-based systems. AC97/I2S can be selected at boot time by setting switch S6.7. Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com> Cc: Linux-MIPS <linux-mips@linux-mips.org> Cc: alsa-devel@alsa-project.org Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/alchemy/devboards/db1200/platform.c51
-rw-r--r--sound/soc/au1x/Kconfig10
-rw-r--r--sound/soc/au1x/Makefile4
-rw-r--r--sound/soc/au1x/db1200.c141
-rw-r--r--sound/soc/au1x/sample-ac97.c144
5 files changed, 200 insertions, 150 deletions
diff --git a/arch/mips/alchemy/devboards/db1200/platform.c b/arch/mips/alchemy/devboards/db1200/platform.c
index 5a6ef8deda10..d6b3e64376c0 100644
--- a/arch/mips/alchemy/devboards/db1200/platform.c
+++ b/arch/mips/alchemy/devboards/db1200/platform.c
@@ -399,12 +399,43 @@ static struct platform_device db1200_spi_dev = {
399 .resource = au1200_psc0_res, 399 .resource = au1200_psc0_res,
400}; 400};
401 401
402static struct resource au1200_psc1_res[] = {
403 [0] = {
404 .start = PSC1_PHYS_ADDR,
405 .end = PSC1_PHYS_ADDR + 0x000fffff,
406 .flags = IORESOURCE_MEM,
407 },
408 [1] = {
409 .start = AU1200_PSC1_INT,
410 .end = AU1200_PSC1_INT,
411 .flags = IORESOURCE_IRQ,
412 },
413 [2] = {
414 .start = DSCR_CMD0_PSC1_TX,
415 .end = DSCR_CMD0_PSC1_TX,
416 .flags = IORESOURCE_DMA,
417 },
418 [3] = {
419 .start = DSCR_CMD0_PSC1_RX,
420 .end = DSCR_CMD0_PSC1_RX,
421 .flags = IORESOURCE_DMA,
422 },
423};
424
425static struct platform_device db1200_audio_dev = {
426 /* name assigned later based on switch setting */
427 .id = 1, /* PSC ID */
428 .num_resources = ARRAY_SIZE(au1200_psc1_res),
429 .resource = au1200_psc1_res,
430};
431
402static struct platform_device *db1200_devs[] __initdata = { 432static struct platform_device *db1200_devs[] __initdata = {
403 NULL, /* PSC0, selected by S6.8 */ 433 NULL, /* PSC0, selected by S6.8 */
404 &db1200_ide_dev, 434 &db1200_ide_dev,
405 &db1200_eth_dev, 435 &db1200_eth_dev,
406 &db1200_rtc_dev, 436 &db1200_rtc_dev,
407 &db1200_nand_dev, 437 &db1200_nand_dev,
438 &db1200_audio_dev,
408}; 439};
409 440
410static int __init db1200_dev_init(void) 441static int __init db1200_dev_init(void)
@@ -419,6 +450,7 @@ static int __init db1200_dev_init(void)
419 ARRAY_SIZE(db1200_i2c_devs)); 450 ARRAY_SIZE(db1200_i2c_devs));
420 451
421 /* SWITCHES: S6.8 I2C/SPI selector (OFF=I2C ON=SPI) 452 /* SWITCHES: S6.8 I2C/SPI selector (OFF=I2C ON=SPI)
453 * S6.7 AC97/I2S selector (OFF=AC97 ON=I2S)
422 */ 454 */
423 455
424 /* NOTE: GPIO215 controls OTG VBUS supply. In SPI mode however 456 /* NOTE: GPIO215 controls OTG VBUS supply. In SPI mode however
@@ -456,6 +488,25 @@ static int __init db1200_dev_init(void)
456 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC); 488 __raw_writel(pfc, (void __iomem *)SYS_PINFUNC);
457 wmb(); 489 wmb();
458 490
491 /* Audio: DIP7 selects I2S(0)/AC97(1), but need I2C for I2S!
492 * so: DIP7=1 || DIP8=0 => AC97, DIP7=0 && DIP8=1 => I2S
493 */
494 sw &= BCSR_SWITCHES_DIP_8 | BCSR_SWITCHES_DIP_7;
495 if (sw == BCSR_SWITCHES_DIP_8) {
496 bcsr_mod(BCSR_RESETS, 0, BCSR_RESETS_PSC1MUX);
497 db1200_audio_dev.name = "au1xpsc_i2s";
498 printk(KERN_INFO " S6.7 ON : PSC1 mode I2S\n");
499 } else {
500 bcsr_mod(BCSR_RESETS, BCSR_RESETS_PSC1MUX, 0);
501 db1200_audio_dev.name = "au1xpsc_ac97";
502 printk(KERN_INFO " S6.7 OFF: PSC1 mode AC97\n");
503 }
504
505 /* Audio PSC clock is supplied externally. (FIXME: platdata!!) */
506 __raw_writel(PSC_SEL_CLK_SERCLK,
507 (void __iomem *)KSEG1ADDR(PSC1_PHYS_ADDR) + PSC_SEL_OFFSET);
508 wmb();
509
459 db1x_register_pcmcia_socket(PCMCIA_ATTR_PSEUDO_PHYS, 510 db1x_register_pcmcia_socket(PCMCIA_ATTR_PSEUDO_PHYS,
460 PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1, 511 PCMCIA_ATTR_PSEUDO_PHYS + 0x00040000 - 1,
461 PCMCIA_MEM_PSEUDO_PHYS, 512 PCMCIA_MEM_PSEUDO_PHYS,
diff --git a/sound/soc/au1x/Kconfig b/sound/soc/au1x/Kconfig
index 410a893aa66b..4b67140fdec3 100644
--- a/sound/soc/au1x/Kconfig
+++ b/sound/soc/au1x/Kconfig
@@ -22,11 +22,13 @@ config SND_SOC_AU1XPSC_AC97
22## 22##
23## Boards 23## Boards
24## 24##
25config SND_SOC_SAMPLE_PSC_AC97 25config SND_SOC_DB1200
26 tristate "Sample Au12x0/Au1550 PSC AC97 sound machine" 26 tristate "DB1200 AC97+I2S audio support"
27 depends on SND_SOC_AU1XPSC 27 depends on SND_SOC_AU1XPSC
28 select SND_SOC_AU1XPSC_AC97 28 select SND_SOC_AU1XPSC_AC97
29 select SND_SOC_AC97_CODEC 29 select SND_SOC_AC97_CODEC
30 select SND_SOC_AU1XPSC_I2S
31 select SND_SOC_WM8731
30 help 32 help
31 This is a sample AC97 sound machine for use in Au12x0/Au1550 33 Select this option to enable audio (AC97 or I2S) on the
32 based systems which have audio on PSC1 (e.g. Db1200 demoboard). 34 Alchemy/AMD/RMI DB1200 demoboard.
diff --git a/sound/soc/au1x/Makefile b/sound/soc/au1x/Makefile
index 6c6950b8003a..16873076e8c4 100644
--- a/sound/soc/au1x/Makefile
+++ b/sound/soc/au1x/Makefile
@@ -8,6 +8,6 @@ obj-$(CONFIG_SND_SOC_AU1XPSC_I2S) += snd-soc-au1xpsc-i2s.o
8obj-$(CONFIG_SND_SOC_AU1XPSC_AC97) += snd-soc-au1xpsc-ac97.o 8obj-$(CONFIG_SND_SOC_AU1XPSC_AC97) += snd-soc-au1xpsc-ac97.o
9 9
10# Boards 10# Boards
11snd-soc-sample-ac97-objs := sample-ac97.o 11snd-soc-db1200-objs := db1200.o
12 12
13obj-$(CONFIG_SND_SOC_SAMPLE_PSC_AC97) += snd-soc-sample-ac97.o 13obj-$(CONFIG_SND_SOC_DB1200) += snd-soc-db1200.o
diff --git a/sound/soc/au1x/db1200.c b/sound/soc/au1x/db1200.c
new file mode 100644
index 000000000000..cdf7be1b9b91
--- /dev/null
+++ b/sound/soc/au1x/db1200.c
@@ -0,0 +1,141 @@
1/*
2 * DB1200 ASoC audio fabric support code.
3 *
4 * (c) 2008-9 Manuel Lauss <manuel.lauss@gmail.com>
5 *
6 */
7
8#include <linux/module.h>
9#include <linux/moduleparam.h>
10#include <linux/timer.h>
11#include <linux/interrupt.h>
12#include <linux/platform_device.h>
13#include <sound/core.h>
14#include <sound/pcm.h>
15#include <sound/soc.h>
16#include <sound/soc-dapm.h>
17#include <asm/mach-au1x00/au1000.h>
18#include <asm/mach-au1x00/au1xxx_psc.h>
19#include <asm/mach-au1x00/au1xxx_dbdma.h>
20#include <asm/mach-db1x00/bcsr.h>
21
22#include "../codecs/ac97.h"
23#include "../codecs/wm8731.h"
24#include "psc.h"
25
26/*------------------------- AC97 PART ---------------------------*/
27
28static struct snd_soc_dai_link db1200_ac97_dai = {
29 .name = "AC97",
30 .stream_name = "AC97 HiFi",
31 .cpu_dai = &au1xpsc_ac97_dai,
32 .codec_dai = &ac97_dai,
33};
34
35static struct snd_soc_card db1200_ac97_machine = {
36 .name = "DB1200_AC97",
37 .dai_link = &db1200_ac97_dai,
38 .num_links = 1,
39 .platform = &au1xpsc_soc_platform,
40};
41
42static struct snd_soc_device db1200_ac97_devdata = {
43 .card = &db1200_ac97_machine,
44 .codec_dev = &soc_codec_dev_ac97,
45};
46
47/*------------------------- I2S PART ---------------------------*/
48
49static int db1200_i2s_startup(struct snd_pcm_substream *substream)
50{
51 struct snd_soc_pcm_runtime *rtd = substream->private_data;
52 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
53 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
54 int ret;
55
56 /* WM8731 has its own 12MHz crystal */
57 snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
58 12000000, SND_SOC_CLOCK_IN);
59
60 /* codec is bitclock and lrclk master */
61 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_LEFT_J |
62 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
63 if (ret < 0)
64 goto out;
65
66 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_LEFT_J |
67 SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
68 if (ret < 0)
69 goto out;
70
71 ret = 0;
72out:
73 return ret;
74}
75
76static struct snd_soc_ops db1200_i2s_wm8731_ops = {
77 .startup = db1200_i2s_startup,
78};
79
80static struct snd_soc_dai_link db1200_i2s_dai = {
81 .name = "WM8731",
82 .stream_name = "WM8731 PCM",
83 .cpu_dai = &au1xpsc_i2s_dai,
84 .codec_dai = &wm8731_dai,
85 .ops = &db1200_i2s_wm8731_ops,
86};
87
88static struct snd_soc_card db1200_i2s_machine = {
89 .name = "DB1200_I2S",
90 .dai_link = &db1200_i2s_dai,
91 .num_links = 1,
92 .platform = &au1xpsc_soc_platform,
93};
94
95static struct snd_soc_device db1200_i2s_devdata = {
96 .card = &db1200_i2s_machine,
97 .codec_dev = &soc_codec_dev_wm8731,
98};
99
100/*------------------------- COMMON PART ---------------------------*/
101
102static struct platform_device *db1200_asoc_dev;
103
104static int __init db1200_audio_load(void)
105{
106 int ret;
107
108 ret = -ENOMEM;
109 db1200_asoc_dev = platform_device_alloc("soc-audio", -1);
110 if (!db1200_asoc_dev)
111 goto out;
112
113 /* DB1200 board setup set PSC1MUX to preferred audio device */
114 if (bcsr_read(BCSR_RESETS) & BCSR_RESETS_PSC1MUX)
115 platform_set_drvdata(db1200_asoc_dev, &db1200_i2s_devdata);
116 else
117 platform_set_drvdata(db1200_asoc_dev, &db1200_ac97_devdata);
118
119 db1200_ac97_devdata.dev = &db1200_asoc_dev->dev;
120 db1200_i2s_devdata.dev = &db1200_asoc_dev->dev;
121 ret = platform_device_add(db1200_asoc_dev);
122
123 if (ret) {
124 platform_device_put(db1200_asoc_dev);
125 db1200_asoc_dev = NULL;
126 }
127out:
128 return ret;
129}
130
131static void __exit db1200_audio_unload(void)
132{
133 platform_device_unregister(db1200_asoc_dev);
134}
135
136module_init(db1200_audio_load);
137module_exit(db1200_audio_unload);
138
139MODULE_LICENSE("GPL");
140MODULE_DESCRIPTION("DB1200 ASoC audio support");
141MODULE_AUTHOR("Manuel Lauss");
diff --git a/sound/soc/au1x/sample-ac97.c b/sound/soc/au1x/sample-ac97.c
deleted file mode 100644
index 27683eb7905e..000000000000
--- a/sound/soc/au1x/sample-ac97.c
+++ /dev/null
@@ -1,144 +0,0 @@
1/*
2 * Sample Au12x0/Au1550 PSC AC97 sound machine.
3 *
4 * Copyright (c) 2007-2008 Manuel Lauss <mano@roarinelk.homelinux.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms outlined in the file COPYING at the root of this
8 * source archive.
9 *
10 * This is a very generic AC97 sound machine driver for boards which
11 * have (AC97) audio at PSC1 (e.g. DB1200 demoboards).
12 */
13
14#include <linux/module.h>
15#include <linux/moduleparam.h>
16#include <linux/timer.h>
17#include <linux/interrupt.h>
18#include <linux/platform_device.h>
19#include <sound/core.h>
20#include <sound/pcm.h>
21#include <sound/soc.h>
22#include <sound/soc-dapm.h>
23#include <asm/mach-au1x00/au1000.h>
24#include <asm/mach-au1x00/au1xxx_psc.h>
25#include <asm/mach-au1x00/au1xxx_dbdma.h>
26
27#include "../codecs/ac97.h"
28#include "psc.h"
29
30static int au1xpsc_sample_ac97_init(struct snd_soc_codec *codec)
31{
32 snd_soc_dapm_sync(codec);
33 return 0;
34}
35
36static struct snd_soc_dai_link au1xpsc_sample_ac97_dai = {
37 .name = "AC97",
38 .stream_name = "AC97 HiFi",
39 .cpu_dai = &au1xpsc_ac97_dai, /* see psc-ac97.c */
40 .codec_dai = &ac97_dai, /* see codecs/ac97.c */
41 .init = au1xpsc_sample_ac97_init,
42 .ops = NULL,
43};
44
45static struct snd_soc_card au1xpsc_sample_ac97_machine = {
46 .name = "Au1xxx PSC AC97 Audio",
47 .dai_link = &au1xpsc_sample_ac97_dai,
48 .num_links = 1,
49};
50
51static struct snd_soc_device au1xpsc_sample_ac97_devdata = {
52 .card = &au1xpsc_sample_ac97_machine,
53 .platform = &au1xpsc_soc_platform, /* see dbdma2.c */
54 .codec_dev = &soc_codec_dev_ac97,
55};
56
57static struct resource au1xpsc_psc1_res[] = {
58 [0] = {
59 .start = CPHYSADDR(PSC1_BASE_ADDR),
60 .end = CPHYSADDR(PSC1_BASE_ADDR) + 0x000fffff,
61 .flags = IORESOURCE_MEM,
62 },
63 [1] = {
64#ifdef CONFIG_SOC_AU1200
65 .start = AU1200_PSC1_INT,
66 .end = AU1200_PSC1_INT,
67#elif defined(CONFIG_SOC_AU1550)
68 .start = AU1550_PSC1_INT,
69 .end = AU1550_PSC1_INT,
70#endif
71 .flags = IORESOURCE_IRQ,
72 },
73 [2] = {
74 .start = DSCR_CMD0_PSC1_TX,
75 .end = DSCR_CMD0_PSC1_TX,
76 .flags = IORESOURCE_DMA,
77 },
78 [3] = {
79 .start = DSCR_CMD0_PSC1_RX,
80 .end = DSCR_CMD0_PSC1_RX,
81 .flags = IORESOURCE_DMA,
82 },
83};
84
85static struct platform_device *au1xpsc_sample_ac97_dev;
86
87static int __init au1xpsc_sample_ac97_load(void)
88{
89 int ret;
90
91#ifdef CONFIG_SOC_AU1200
92 unsigned long io;
93
94 /* modify sys_pinfunc for AC97 on PSC1 */
95 io = au_readl(SYS_PINFUNC);
96 io |= SYS_PINFUNC_P1C;
97 io &= ~(SYS_PINFUNC_P1A | SYS_PINFUNC_P1B);
98 au_writel(io, SYS_PINFUNC);
99 au_sync();
100#endif
101
102 ret = -ENOMEM;
103
104 /* setup PSC clock source for AC97 part: external clock provided
105 * by codec. The psc-ac97.c driver depends on this setting!
106 */
107 au_writel(PSC_SEL_CLK_SERCLK, PSC1_BASE_ADDR + PSC_SEL_OFFSET);
108 au_sync();
109
110 au1xpsc_sample_ac97_dev = platform_device_alloc("soc-audio", -1);
111 if (!au1xpsc_sample_ac97_dev)
112 goto out;
113
114 au1xpsc_sample_ac97_dev->resource =
115 kmemdup(au1xpsc_psc1_res, sizeof(struct resource) *
116 ARRAY_SIZE(au1xpsc_psc1_res), GFP_KERNEL);
117 au1xpsc_sample_ac97_dev->num_resources = ARRAY_SIZE(au1xpsc_psc1_res);
118 au1xpsc_sample_ac97_dev->id = 1;
119
120 platform_set_drvdata(au1xpsc_sample_ac97_dev,
121 &au1xpsc_sample_ac97_devdata);
122 au1xpsc_sample_ac97_devdata.dev = &au1xpsc_sample_ac97_dev->dev;
123 ret = platform_device_add(au1xpsc_sample_ac97_dev);
124
125 if (ret) {
126 platform_device_put(au1xpsc_sample_ac97_dev);
127 au1xpsc_sample_ac97_dev = NULL;
128 }
129
130out:
131 return ret;
132}
133
134static void __exit au1xpsc_sample_ac97_exit(void)
135{
136 platform_device_unregister(au1xpsc_sample_ac97_dev);
137}
138
139module_init(au1xpsc_sample_ac97_load);
140module_exit(au1xpsc_sample_ac97_exit);
141
142MODULE_LICENSE("GPL");
143MODULE_DESCRIPTION("Au1xxx PSC sample AC97 machine");
144MODULE_AUTHOR("Manuel Lauss <mano@roarinelk.homelinux.net>");