diff options
| author | Frank Mandarino <fmandarino@endrelia.com> | 2006-10-06 12:41:10 -0400 |
|---|---|---|
| committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:00:30 -0500 |
| commit | b41bf38a4323a32ec4890c74818c4a3d2661fe6c (patch) | |
| tree | 5d91b51efd9f16b2fe4ccaf6333ee3d1c755da08 /sound/soc/at91 | |
| parent | 0cbbec0984f10f216ed8332e0d39ac93cbe33a0b (diff) | |
[ALSA] ASoC AT91RM92000 eti_b1 machine support
This patch adds support for the Endrelia ETI_B1 machine using the WM8731
codec and the AT91RM9200 platform.
Signed-off-by: Frank Mandarino <fmandarino@endrelia.com>
Signed-off-by: Liam Girdwood <liam.girdwood@wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/soc/at91')
| -rw-r--r-- | sound/soc/at91/eti_b1_wm8731.c | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/sound/soc/at91/eti_b1_wm8731.c b/sound/soc/at91/eti_b1_wm8731.c new file mode 100644 index 000000000000..d955cacf2d0d --- /dev/null +++ b/sound/soc/at91/eti_b1_wm8731.c | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | /* | ||
| 2 | * eti_b1_wm8731 -- SoC audio for Endrelia ETI_B1. | ||
| 3 | * | ||
| 4 | * Author: Frank Mandarino <fmandarino@endrelia.com> | ||
| 5 | * Endrelia Technologies Inc. | ||
| 6 | * Created: Mar 29, 2006 | ||
| 7 | * | ||
| 8 | * Based on corgi.c by: | ||
| 9 | * | ||
| 10 | * Copyright 2005 Wolfson Microelectronics PLC. | ||
| 11 | * Copyright 2005 Openedhand Ltd. | ||
| 12 | * | ||
| 13 | * Authors: Liam Girdwood <liam.girdwood@wolfsonmicro.com> | ||
| 14 | * Richard Purdie <richard@openedhand.com> | ||
| 15 | * | ||
| 16 | * This program is free software; you can redistribute it and/or modify it | ||
| 17 | * under the terms of the GNU General Public License as published by the | ||
| 18 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 19 | * option) any later version. | ||
| 20 | * | ||
| 21 | * Revision history | ||
| 22 | * 30th Nov 2005 Initial version. | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/module.h> | ||
| 27 | #include <linux/moduleparam.h> | ||
| 28 | #include <linux/version.h> | ||
| 29 | #include <linux/kernel.h> | ||
| 30 | #include <linux/clk.h> | ||
| 31 | #include <linux/timer.h> | ||
| 32 | #include <linux/interrupt.h> | ||
| 33 | #include <linux/platform_device.h> | ||
| 34 | #include <sound/driver.h> | ||
| 35 | #include <sound/core.h> | ||
| 36 | #include <sound/pcm.h> | ||
| 37 | #include <sound/soc.h> | ||
| 38 | #include <sound/soc-dapm.h> | ||
| 39 | |||
| 40 | #include <asm/arch/at91rm9200.h> | ||
| 41 | #include <asm/arch/gpio.h> | ||
| 42 | #include <asm/arch/hardware.h> | ||
| 43 | |||
| 44 | #include "../codecs/wm8731.h" | ||
| 45 | #include "at91rm9200-pcm.h" | ||
| 46 | |||
| 47 | #if 0 | ||
| 48 | #define DBG(x...) printk(KERN_INFO "eti_b1_wm8731:" x) | ||
| 49 | #else | ||
| 50 | #define DBG(x...) | ||
| 51 | #endif | ||
| 52 | |||
| 53 | static struct clk *pck1_clk; | ||
| 54 | static struct clk *pllb_clk; | ||
| 55 | |||
| 56 | static int eti_b1_startup(snd_pcm_substream_t *substream) | ||
| 57 | { | ||
| 58 | /* Start PCK1 clock. */ | ||
| 59 | clk_enable(pck1_clk); | ||
| 60 | DBG("pck1 started\n"); | ||
| 61 | |||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | static void eti_b1_shutdown(snd_pcm_substream_t *substream) | ||
| 66 | { | ||
| 67 | /* Stop PCK1 clock. */ | ||
| 68 | clk_disable(pck1_clk); | ||
| 69 | DBG("pck1 stopped\n"); | ||
| 70 | } | ||
| 71 | |||
| 72 | static struct snd_soc_ops eti_b1_ops = { | ||
| 73 | .startup = eti_b1_startup, | ||
| 74 | .shutdown = eti_b1_shutdown, | ||
| 75 | }; | ||
| 76 | |||
| 77 | |||
| 78 | static const struct snd_soc_dapm_widget eti_b1_dapm_widgets[] = { | ||
| 79 | SND_SOC_DAPM_MIC("Int Mic", NULL), | ||
| 80 | SND_SOC_DAPM_SPK("Ext Spk", NULL), | ||
| 81 | }; | ||
| 82 | |||
| 83 | static const char *intercon[][3] = { | ||
| 84 | |||
| 85 | /* speaker connected to LHPOUT */ | ||
| 86 | {"Ext Spk", NULL, "LHPOUT"}, | ||
| 87 | |||
| 88 | /* mic is connected to Mic Jack, with WM8731 Mic Bias */ | ||
| 89 | {"MICIN", NULL, "Mic Bias"}, | ||
| 90 | {"Mic Bias", NULL, "Int Mic"}, | ||
| 91 | |||
| 92 | /* terminator */ | ||
| 93 | {NULL, NULL, NULL}, | ||
| 94 | }; | ||
| 95 | |||
| 96 | /* | ||
| 97 | * Logic for a wm8731 as connected on a Endrelia ETI-B1 board. | ||
| 98 | */ | ||
| 99 | static int eti_b1_wm8731_init(struct snd_soc_codec *codec) | ||
| 100 | { | ||
| 101 | int i; | ||
| 102 | |||
| 103 | DBG("eti_b1_wm8731_init() called\n"); | ||
| 104 | |||
| 105 | /* Add specific widgets */ | ||
| 106 | for(i = 0; i < ARRAY_SIZE(eti_b1_dapm_widgets); i++) { | ||
| 107 | snd_soc_dapm_new_control(codec, &eti_b1_dapm_widgets[i]); | ||
| 108 | } | ||
| 109 | |||
| 110 | /* Set up specific audio path interconnects */ | ||
| 111 | for(i = 0; intercon[i][0] != NULL; i++) { | ||
| 112 | snd_soc_dapm_connect_input(codec, intercon[i][0], | ||
| 113 | intercon[i][1], intercon[i][2]); | ||
| 114 | } | ||
| 115 | |||
| 116 | /* not connected */ | ||
| 117 | snd_soc_dapm_set_endpoint(codec, "RLINEIN", 0); | ||
| 118 | snd_soc_dapm_set_endpoint(codec, "LLINEIN", 0); | ||
| 119 | |||
| 120 | /* always connected */ | ||
| 121 | snd_soc_dapm_set_endpoint(codec, "Int Mic", 1); | ||
| 122 | snd_soc_dapm_set_endpoint(codec, "Ext Spk", 1); | ||
| 123 | |||
| 124 | snd_soc_dapm_sync_endpoints(codec); | ||
| 125 | |||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | unsigned int eti_b1_config_sysclk(struct snd_soc_pcm_runtime *rtd, | ||
| 130 | struct snd_soc_clock_info *info) | ||
| 131 | { | ||
| 132 | if(info->bclk_master & SND_SOC_DAIFMT_CBS_CFS) { | ||
| 133 | return rtd->codec_dai->config_sysclk(rtd->codec_dai, info, 12000000); | ||
| 134 | } | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 138 | static struct snd_soc_dai_link eti_b1_dai = { | ||
| 139 | .name = "WM8731", | ||
| 140 | .stream_name = "WM8731", | ||
| 141 | .cpu_dai = &at91rm9200_i2s_dai[1], | ||
| 142 | .codec_dai = &wm8731_dai, | ||
| 143 | .init = eti_b1_wm8731_init, | ||
| 144 | .config_sysclk = eti_b1_config_sysclk, | ||
| 145 | }; | ||
| 146 | |||
| 147 | static struct snd_soc_machine snd_soc_machine_eti_b1 = { | ||
| 148 | .name = "ETI_B1", | ||
| 149 | .dai_link = &eti_b1_dai, | ||
| 150 | .num_links = 1, | ||
| 151 | .ops = &eti_b1_ops, | ||
| 152 | }; | ||
| 153 | |||
| 154 | static struct wm8731_setup_data eti_b1_wm8731_setup = { | ||
| 155 | .i2c_address = 0x1a, | ||
| 156 | }; | ||
| 157 | |||
| 158 | static struct snd_soc_device eti_b1_snd_devdata = { | ||
| 159 | .machine = &snd_soc_machine_eti_b1, | ||
| 160 | .platform = &at91rm9200_soc_platform, | ||
| 161 | .codec_dev = &soc_codec_dev_wm8731, | ||
| 162 | .codec_data = &eti_b1_wm8731_setup, | ||
| 163 | }; | ||
| 164 | |||
| 165 | static struct platform_device *eti_b1_snd_device; | ||
| 166 | |||
| 167 | static int __init eti_b1_init(void) | ||
| 168 | { | ||
| 169 | int ret; | ||
| 170 | u32 ssc_pio_lines; | ||
| 171 | |||
| 172 | eti_b1_snd_device = platform_device_alloc("soc-audio", -1); | ||
| 173 | if (!eti_b1_snd_device) | ||
| 174 | return -ENOMEM; | ||
| 175 | |||
| 176 | platform_set_drvdata(eti_b1_snd_device, &eti_b1_snd_devdata); | ||
| 177 | eti_b1_snd_devdata.dev = &eti_b1_snd_device->dev; | ||
| 178 | |||
| 179 | ret = platform_device_add(eti_b1_snd_device); | ||
| 180 | if (ret) { | ||
| 181 | platform_device_put(eti_b1_snd_device); | ||
| 182 | return ret; | ||
| 183 | } | ||
| 184 | |||
| 185 | ssc_pio_lines = AT91_PB6_TF1 | AT91_PB7_TK1 | AT91_PB8_TD1 | ||
| 186 | | AT91_PB9_RD1 /* | AT91_PB10_RK1 | AT91_PB11_RF1 */; | ||
| 187 | |||
| 188 | /* Reset all PIO registers and assign lines to peripheral A */ | ||
| 189 | at91_sys_write(AT91_PIOB + PIO_PDR, ssc_pio_lines); | ||
| 190 | at91_sys_write(AT91_PIOB + PIO_ODR, ssc_pio_lines); | ||
| 191 | at91_sys_write(AT91_PIOB + PIO_IFDR, ssc_pio_lines); | ||
| 192 | at91_sys_write(AT91_PIOB + PIO_CODR, ssc_pio_lines); | ||
| 193 | at91_sys_write(AT91_PIOB + PIO_IDR, ssc_pio_lines); | ||
| 194 | at91_sys_write(AT91_PIOB + PIO_MDDR, ssc_pio_lines); | ||
| 195 | at91_sys_write(AT91_PIOB + PIO_PUDR, ssc_pio_lines); | ||
| 196 | at91_sys_write(AT91_PIOB + PIO_ASR, ssc_pio_lines); | ||
| 197 | at91_sys_write(AT91_PIOB + PIO_OWDR, ssc_pio_lines); | ||
| 198 | |||
| 199 | /* | ||
| 200 | * Set PCK1 parent to PLLB and its rate to 12 Mhz. | ||
| 201 | */ | ||
| 202 | pllb_clk = clk_get(NULL, "pllb"); | ||
| 203 | pck1_clk = clk_get(NULL, "pck1"); | ||
| 204 | |||
| 205 | clk_set_parent(pck1_clk, pllb_clk); | ||
| 206 | clk_set_rate(pck1_clk, 12000000); | ||
| 207 | |||
| 208 | DBG("MCLK rate %luHz\n", clk_get_rate(pck1_clk)); | ||
| 209 | |||
| 210 | /* assign the GPIO pin to PCK1 */ | ||
| 211 | at91_set_B_periph(AT91_PIN_PA24, 0); | ||
| 212 | |||
| 213 | return ret; | ||
| 214 | } | ||
| 215 | |||
| 216 | static void __exit eti_b1_exit(void) | ||
| 217 | { | ||
| 218 | clk_put(pck1_clk); | ||
| 219 | clk_put(pllb_clk); | ||
| 220 | |||
| 221 | platform_device_unregister(eti_b1_snd_device); | ||
| 222 | } | ||
| 223 | |||
| 224 | module_init(eti_b1_init); | ||
| 225 | module_exit(eti_b1_exit); | ||
| 226 | |||
| 227 | /* Module information */ | ||
| 228 | MODULE_AUTHOR("Frank Mandarino <fmandarino@endrelia.com>"); | ||
| 229 | MODULE_DESCRIPTION("ALSA SoC ETI-B1-WM8731"); | ||
| 230 | MODULE_LICENSE("GPL"); | ||
