Commit fbd60ce7 authored by Mark Brown's avatar Mark Brown

Merge remote branch 'broonie-asoc/for-2.6.37' into for-2.6.37

parents 9745e824 014a2755
...@@ -789,13 +789,14 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = { ...@@ -789,13 +789,14 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = {
static __devinit int asoc_ssc_probe(struct platform_device *pdev) static __devinit int asoc_ssc_probe(struct platform_device *pdev)
{ {
return snd_soc_register_dais(&pdev->dev, atmel_ssc_dai, BUG_ON(pdev->id < 0);
ARRAY_SIZE(atmel_ssc_dai)); BUG_ON(pdev->id >= ARRAY_SIZE(atmel_ssc_dai));
return snd_soc_register_dai(&pdev->dev, &atmel_ssc_dai[pdev->id]);
} }
static int __devexit asoc_ssc_remove(struct platform_device *pdev) static int __devexit asoc_ssc_remove(struct platform_device *pdev)
{ {
snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(atmel_ssc_dai)); snd_soc_unregister_dai(&pdev->dev);
return 0; return 0;
} }
...@@ -809,6 +810,56 @@ static struct platform_driver asoc_ssc_driver = { ...@@ -809,6 +810,56 @@ static struct platform_driver asoc_ssc_driver = {
.remove = __devexit_p(asoc_ssc_remove), .remove = __devexit_p(asoc_ssc_remove),
}; };
/**
* atmel_ssc_set_audio - Allocate the specified SSC for audio use.
*/
int atmel_ssc_set_audio(int ssc_id)
{
struct ssc_device *ssc;
static struct platform_device *dma_pdev;
struct platform_device *ssc_pdev;
int ret;
if (ssc_id < 0 || ssc_id >= ARRAY_SIZE(atmel_ssc_dai))
return -EINVAL;
/* Allocate a dummy device for DMA if we don't have one already */
if (!dma_pdev) {
dma_pdev = platform_device_alloc("atmel-pcm-audio", -1);
if (!dma_pdev)
return -ENOMEM;
ret = platform_device_add(dma_pdev);
if (ret < 0) {
platform_device_put(dma_pdev);
dma_pdev = NULL;
return ret;
}
}
ssc_pdev = platform_device_alloc("atmel-ssc-dai", ssc_id);
if (!ssc_pdev) {
ssc_free(ssc);
return -ENOMEM;
}
/* If we can grab the SSC briefly to parent the DAI device off it */
ssc = ssc_request(ssc_id);
if (IS_ERR(ssc))
pr_warn("Unable to parent ASoC SSC DAI on SSC: %ld\n",
PTR_ERR(ssc));
else
ssc_pdev->dev.parent = &(ssc->pdev->dev);
ssc_free(ssc);
ret = platform_device_add(ssc_pdev);
if (ret < 0)
platform_device_put(ssc_pdev);
return ret;
}
EXPORT_SYMBOL_GPL(atmel_ssc_set_audio);
static int __init snd_atmel_ssc_init(void) static int __init snd_atmel_ssc_init(void)
{ {
return platform_driver_register(&asoc_ssc_driver); return platform_driver_register(&asoc_ssc_driver);
......
...@@ -117,4 +117,6 @@ struct atmel_ssc_info { ...@@ -117,4 +117,6 @@ struct atmel_ssc_info {
struct atmel_ssc_state ssc_state; struct atmel_ssc_state ssc_state;
}; };
int atmel_ssc_set_audio(int ssc);
#endif /* _AT91_SSC_DAI_H */ #endif /* _AT91_SSC_DAI_H */
...@@ -183,8 +183,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = { ...@@ -183,8 +183,8 @@ static struct snd_soc_dai_link at91sam9g20ek_dai = {
.cpu_dai_name = "atmel-ssc-dai.0", .cpu_dai_name = "atmel-ssc-dai.0",
.codec_dai_name = "wm8731-hifi", .codec_dai_name = "wm8731-hifi",
.init = at91sam9g20ek_wm8731_init, .init = at91sam9g20ek_wm8731_init,
.platform_name = "atmel_pcm-audio", .platform_name = "atmel-pcm-audio",
.codec_name = "wm8731-codec.0-001a", .codec_name = "wm8731-codec.0-001b",
.ops = &at91sam9g20ek_ops, .ops = &at91sam9g20ek_ops,
}; };
...@@ -205,6 +205,12 @@ static int __init at91sam9g20ek_init(void) ...@@ -205,6 +205,12 @@ static int __init at91sam9g20ek_init(void)
if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc()))
return -ENODEV; return -ENODEV;
ret = atmel_ssc_set_audio(0);
if (ret != 0) {
pr_err("Failed to set SSC 0 for audio: %d\n", ret);
return ret;
}
/* /*
* Codec MCLK is supplied by PCK0 - set it up. * Codec MCLK is supplied by PCK0 - set it up.
*/ */
......
This diff is collapsed.
/*
* 88pm860x-codec.h -- 88PM860x ALSA SoC Audio Driver
*
* Copyright 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __88PM860X_H
#define __88PM860X_H
/* The offset of these registers are 0xb0 */
#define PM860X_PCM_IFACE_1 0x00
#define PM860X_PCM_IFACE_2 0x01
#define PM860X_PCM_IFACE_3 0x02
#define PM860X_PCM_RATE 0x03
#define PM860X_EC_PATH 0x04
#define PM860X_SIDETONE_L_GAIN 0x05
#define PM860X_SIDETONE_R_GAIN 0x06
#define PM860X_SIDETONE_SHIFT 0x07
#define PM860X_ADC_OFFSET_1 0x08
#define PM860X_ADC_OFFSET_2 0x09
#define PM860X_DMIC_DELAY 0x0a
#define PM860X_I2S_IFACE_1 0x0b
#define PM860X_I2S_IFACE_2 0x0c
#define PM860X_I2S_IFACE_3 0x0d
#define PM860X_I2S_IFACE_4 0x0e
#define PM860X_EQUALIZER_N0_1 0x0f
#define PM860X_EQUALIZER_N0_2 0x10
#define PM860X_EQUALIZER_N1_1 0x11
#define PM860X_EQUALIZER_N1_2 0x12
#define PM860X_EQUALIZER_D1_1 0x13
#define PM860X_EQUALIZER_D1_2 0x14
#define PM860X_LOFI_GAIN_LEFT 0x15
#define PM860X_LOFI_GAIN_RIGHT 0x16
#define PM860X_HIFIL_GAIN_LEFT 0x17
#define PM860X_HIFIL_GAIN_RIGHT 0x18
#define PM860X_HIFIR_GAIN_LEFT 0x19
#define PM860X_HIFIR_GAIN_RIGHT 0x1a
#define PM860X_DAC_OFFSET 0x1b
#define PM860X_OFFSET_LEFT_1 0x1c
#define PM860X_OFFSET_LEFT_2 0x1d
#define PM860X_OFFSET_RIGHT_1 0x1e
#define PM860X_OFFSET_RIGHT_2 0x1f
#define PM860X_ADC_ANA_1 0x20
#define PM860X_ADC_ANA_2 0x21
#define PM860X_ADC_ANA_3 0x22
#define PM860X_ADC_ANA_4 0x23
#define PM860X_ANA_TO_ANA 0x24
#define PM860X_HS1_CTRL 0x25
#define PM860X_HS2_CTRL 0x26
#define PM860X_LO1_CTRL 0x27
#define PM860X_LO2_CTRL 0x28
#define PM860X_EAR_CTRL_1 0x29
#define PM860X_EAR_CTRL_2 0x2a
#define PM860X_AUDIO_SUPPLIES_1 0x2b
#define PM860X_AUDIO_SUPPLIES_2 0x2c
#define PM860X_ADC_EN_1 0x2d
#define PM860X_ADC_EN_2 0x2e
#define PM860X_DAC_EN_1 0x2f
#define PM860X_DAC_EN_2 0x31
#define PM860X_AUDIO_CAL_1 0x32
#define PM860X_AUDIO_CAL_2 0x33
#define PM860X_AUDIO_CAL_3 0x34
#define PM860X_AUDIO_CAL_4 0x35
#define PM860X_AUDIO_CAL_5 0x36
#define PM860X_ANA_INPUT_SEL_1 0x37
#define PM860X_ANA_INPUT_SEL_2 0x38
#define PM860X_PCM_IFACE_4 0x39
#define PM860X_I2S_IFACE_5 0x3a
#define PM860X_SHORTS 0x3b
#define PM860X_PLL_ADJ_1 0x3c
#define PM860X_PLL_ADJ_2 0x3d
/* bits definition */
#define PM860X_CLK_DIR_IN 0
#define PM860X_CLK_DIR_OUT 1
#define PM860X_DET_HEADSET (1 << 0)
#define PM860X_DET_MIC (1 << 1)
#define PM860X_DET_HOOK (1 << 2)
#define PM860X_SHORT_HEADSET (1 << 3)
#define PM860X_SHORT_LINEOUT (1 << 4)
#define PM860X_DET_MASK 0x1F
extern int pm860x_hs_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *,
int, int, int, int);
extern int pm860x_mic_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *,
int);
#endif /* __88PM860X_H */
...@@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI ...@@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI
config SND_SOC_ALL_CODECS config SND_SOC_ALL_CODECS
tristate "Build all ASoC CODEC drivers" tristate "Build all ASoC CODEC drivers"
select SND_SOC_88PM860X if MFD_88PM860X
select SND_SOC_L3 select SND_SOC_L3
select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS select SND_SOC_AC97_CODEC if SND_SOC_AC97_BUS
select SND_SOC_AD1836 if SPI_MASTER select SND_SOC_AD1836 if SPI_MASTER
...@@ -40,6 +41,7 @@ config SND_SOC_ALL_CODECS ...@@ -40,6 +41,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_TWL6040 if TWL4030_CORE select SND_SOC_TWL6040 if TWL4030_CORE
select SND_SOC_UDA134X select SND_SOC_UDA134X
select SND_SOC_UDA1380 if I2C select SND_SOC_UDA1380 if I2C
select SND_SOC_WL1273 if WL1273_CORE
select SND_SOC_WM2000 if I2C select SND_SOC_WM2000 if I2C
select SND_SOC_WM8350 if MFD_WM8350 select SND_SOC_WM8350 if MFD_WM8350
select SND_SOC_WM8400 if MFD_WM8400 select SND_SOC_WM8400 if MFD_WM8400
...@@ -85,6 +87,9 @@ config SND_SOC_ALL_CODECS ...@@ -85,6 +87,9 @@ config SND_SOC_ALL_CODECS
If unsure select "N". If unsure select "N".
config SND_SOC_88PM860X
tristate
config SND_SOC_WM_HUBS config SND_SOC_WM_HUBS
tristate tristate
default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
...@@ -189,6 +194,9 @@ config SND_SOC_UDA134X ...@@ -189,6 +194,9 @@ config SND_SOC_UDA134X
config SND_SOC_UDA1380 config SND_SOC_UDA1380
tristate tristate
config SND_SOC_WL1273
tristate
config SND_SOC_WM8350 config SND_SOC_WM8350
tristate tristate
......
snd-soc-88pm860x-objs := 88pm860x-codec.o
snd-soc-ac97-objs := ac97.o snd-soc-ac97-objs := ac97.o
snd-soc-ad1836-objs := ad1836.o snd-soc-ad1836-objs := ad1836.o
snd-soc-ad193x-objs := ad193x.o snd-soc-ad193x-objs := ad193x.o
...@@ -26,6 +27,7 @@ snd-soc-twl4030-objs := twl4030.o ...@@ -26,6 +27,7 @@ snd-soc-twl4030-objs := twl4030.o
snd-soc-twl6040-objs := twl6040.o snd-soc-twl6040-objs := twl6040.o
snd-soc-uda134x-objs := uda134x.o snd-soc-uda134x-objs := uda134x.o
snd-soc-uda1380-objs := uda1380.o snd-soc-uda1380-objs := uda1380.o
snd-soc-wl1273-objs := wl1273.o
snd-soc-wm8350-objs := wm8350.o snd-soc-wm8350-objs := wm8350.o
snd-soc-wm8400-objs := wm8400.o snd-soc-wm8400-objs := wm8400.o
snd-soc-wm8510-objs := wm8510.o snd-soc-wm8510-objs := wm8510.o
...@@ -67,6 +69,7 @@ snd-soc-tpa6130a2-objs := tpa6130a2.o ...@@ -67,6 +69,7 @@ snd-soc-tpa6130a2-objs := tpa6130a2.o
snd-soc-wm2000-objs := wm2000.o snd-soc-wm2000-objs := wm2000.o
snd-soc-wm9090-objs := wm9090.o snd-soc-wm9090-objs := wm9090.o
obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o
obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o obj-$(CONFIG_SND_SOC_AC97_CODEC) += snd-soc-ac97.o
obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o obj-$(CONFIG_SND_SOC_AD1836) += snd-soc-ad1836.o
obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o obj-$(CONFIG_SND_SOC_AD193X) += snd-soc-ad193x.o
...@@ -96,6 +99,7 @@ obj-$(CONFIG_SND_SOC_TWL4030) += snd-soc-twl4030.o ...@@ -96,6 +99,7 @@ obj-$(CONFIG_SND_SOC_TWL4030) += snd-soc-twl4030.o
obj-$(CONFIG_SND_SOC_TWL6040) += snd-soc-twl6040.o obj-$(CONFIG_SND_SOC_TWL6040) += snd-soc-twl6040.o
obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o obj-$(CONFIG_SND_SOC_UDA134X) += snd-soc-uda134x.o
obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o obj-$(CONFIG_SND_SOC_UDA1380) += snd-soc-uda1380.o
obj-$(CONFIG_SND_SOC_WL1273) += snd-soc-wl1273.o
obj-$(CONFIG_SND_SOC_WM8350) += snd-soc-wm8350.o obj-$(CONFIG_SND_SOC_WM8350) += snd-soc-wm8350.o
obj-$(CONFIG_SND_SOC_WM8400) += snd-soc-wm8400.o obj-$(CONFIG_SND_SOC_WM8400) += snd-soc-wm8400.o
obj-$(CONFIG_SND_SOC_WM8510) += snd-soc-wm8510.o obj-$(CONFIG_SND_SOC_WM8510) += snd-soc-wm8510.o
......
...@@ -318,7 +318,7 @@ EXPORT_SYMBOL_GPL(v253_ops); ...@@ -318,7 +318,7 @@ EXPORT_SYMBOL_GPL(v253_ops);
*/ */
static struct snd_soc_dai_driver cx20442_dai = { static struct snd_soc_dai_driver cx20442_dai = {
.name = "cx20442-hifi", .name = "cx20442-voice",
.playback = { .playback = {
.stream_name = "Playback", .stream_name = "Playback",
.channels_min = 1, .channels_min = 1,
......
...@@ -12,11 +12,11 @@ ...@@ -12,11 +12,11 @@
* *
* Notes: * Notes:
* The AIC3X is a driver for a low power stereo audio * The AIC3X is a driver for a low power stereo audio
* codecs aic31, aic32, aic33. * codecs aic31, aic32, aic33, aic3007.
* *
* It supports full aic33 codec functionality. * It supports full aic33 codec functionality.
* The compatibility with aic32, aic31 is as follows: * The compatibility with aic32, aic31 and aic3007 is as follows:
* aic32 | aic31 * aic32/aic3007 | aic31
* --------------------------------------- * ---------------------------------------
* MONO_LOUT -> N/A | MONO_LOUT -> N/A * MONO_LOUT -> N/A | MONO_LOUT -> N/A
* | IN1L -> LINE1L * | IN1L -> LINE1L
...@@ -70,6 +70,10 @@ struct aic3x_priv { ...@@ -70,6 +70,10 @@ struct aic3x_priv {
unsigned int sysclk; unsigned int sysclk;
int master; int master;
int gpio_reset; int gpio_reset;
#define AIC3X_MODEL_3X 0
#define AIC3X_MODEL_33 1
#define AIC3X_MODEL_3007 2
u16 model;
}; };
/* /*
...@@ -361,6 +365,14 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = { ...@@ -361,6 +365,14 @@ static const struct snd_kcontrol_new aic3x_snd_controls[] = {
SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]), SOC_ENUM("ADC HPF Cut-off", aic3x_enum[ADC_HPF_ENUM]),
}; };
/*
* Class-D amplifier gain. From 0 to 18 dB in 6 dB steps
*/
static DECLARE_TLV_DB_SCALE(classd_amp_tlv, 0, 600, 0);
static const struct snd_kcontrol_new aic3x_classd_amp_gain_ctrl =
SOC_DOUBLE_TLV("Class-D Amplifier Gain", CLASSD_CTRL, 6, 4, 3, 0, classd_amp_tlv);
/* Left DAC Mux */ /* Left DAC Mux */
static const struct snd_kcontrol_new aic3x_left_dac_mux_controls = static const struct snd_kcontrol_new aic3x_left_dac_mux_controls =
SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]); SOC_DAPM_ENUM("Route", aic3x_enum[LDAC_ENUM]);
...@@ -589,6 +601,15 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = { ...@@ -589,6 +601,15 @@ static const struct snd_soc_dapm_widget aic3x_dapm_widgets[] = {
SND_SOC_DAPM_INPUT("LINE2R"), SND_SOC_DAPM_INPUT("LINE2R"),
}; };
static const struct snd_soc_dapm_widget aic3007_dapm_widgets[] = {
/* Class-D outputs */
SND_SOC_DAPM_PGA("Left Class-D Out", CLASSD_CTRL, 3, 0, NULL, 0),
SND_SOC_DAPM_PGA("Right Class-D Out", CLASSD_CTRL, 2, 0, NULL, 0),
SND_SOC_DAPM_OUTPUT("SPOP"),
SND_SOC_DAPM_OUTPUT("SPOM"),
};
static const struct snd_soc_dapm_route intercon[] = { static const struct snd_soc_dapm_route intercon[] = {
/* Left Output */ /* Left Output */
{"Left DAC Mux", "DAC_L1", "Left DAC"}, {"Left DAC Mux", "DAC_L1", "Left DAC"},
...@@ -759,14 +780,30 @@ static const struct snd_soc_dapm_route intercon[] = { ...@@ -759,14 +780,30 @@ static const struct snd_soc_dapm_route intercon[] = {
{"GPIO1 dmic modclk", NULL, "DMic Rate 32"}, {"GPIO1 dmic modclk", NULL, "DMic Rate 32"},
}; };
static const struct snd_soc_dapm_route intercon_3007[] = {
/* Class-D outputs */
{"Left Class-D Out", NULL, "Left Line Out"},
{"Right Class-D Out", NULL, "Left Line Out"},
{"SPOP", NULL, "Left Class-D Out"},
{"SPOM", NULL, "Right Class-D Out"},
};
static int aic3x_add_widgets(struct snd_soc_codec *codec) static int aic3x_add_widgets(struct snd_soc_codec *codec)
{ {
struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets, snd_soc_dapm_new_controls(codec, aic3x_dapm_widgets,
ARRAY_SIZE(aic3x_dapm_widgets)); ARRAY_SIZE(aic3x_dapm_widgets));
/* set up audio path interconnects */ /* set up audio path interconnects */
snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon)); snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
if (aic3x->model == AIC3X_MODEL_3007) {
snd_soc_dapm_new_controls(codec, aic3007_dapm_widgets,
ARRAY_SIZE(aic3007_dapm_widgets));
snd_soc_dapm_add_routes(codec, intercon_3007, ARRAY_SIZE(intercon_3007));
}
return 0; return 0;
} }
...@@ -1117,6 +1154,7 @@ static struct snd_soc_dai_driver aic3x_dai = { ...@@ -1117,6 +1154,7 @@ static struct snd_soc_dai_driver aic3x_dai = {
.rates = AIC3X_RATES, .rates = AIC3X_RATES,
.formats = AIC3X_FORMATS,}, .formats = AIC3X_FORMATS,},
.ops = &aic3x_dai_ops, .ops = &aic3x_dai_ops,
.symmetric_rates = 1,
}; };
static int aic3x_suspend(struct snd_soc_codec *codec, pm_message_t state) static int aic3x_suspend(struct snd_soc_codec *codec, pm_message_t state)
...@@ -1150,6 +1188,7 @@ static int aic3x_resume(struct snd_soc_codec *codec) ...@@ -1150,6 +1188,7 @@ static int aic3x_resume(struct snd_soc_codec *codec)
*/ */
static int aic3x_init(struct snd_soc_codec *codec) static int aic3x_init(struct snd_soc_codec *codec)
{ {
struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
int reg; int reg;
aic3x_write(codec, AIC3X_PAGE_SELECT, PAGE0_SELECT); aic3x_write(codec, AIC3X_PAGE_SELECT, PAGE0_SELECT);
...@@ -1218,6 +1257,17 @@ static int aic3x_init(struct snd_soc_codec *codec) ...@@ -1218,6 +1257,17 @@ static int aic3x_init(struct snd_soc_codec *codec)
aic3x_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); aic3x_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL);
aic3x_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); aic3x_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL);
if (aic3x->model == AIC3X_MODEL_3007) {
/* Class-D speaker driver init; datasheet p. 46 */
aic3x_write(codec, AIC3X_PAGE_SELECT, 0x0D);
aic3x_write(codec, 0xD, 0x0D);
aic3x_write(codec, 0x8, 0x5C);
aic3x_write(codec, 0x8, 0x5D);
aic3x_write(codec, 0x8, 0x5C);
aic3x_write(codec, AIC3X_PAGE_SELECT, 0x00);
aic3x_write(codec, CLASSD_CTRL, 0);
}
/* off, with power on */ /* off, with power on */
aic3x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); aic3x_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
...@@ -1243,6 +1293,8 @@ static int aic3x_probe(struct snd_soc_codec *codec) ...@@ -1243,6 +1293,8 @@ static int aic3x_probe(struct snd_soc_codec *codec)
snd_soc_add_controls(codec, aic3x_snd_controls, snd_soc_add_controls(codec, aic3x_snd_controls,
ARRAY_SIZE(aic3x_snd_controls)); ARRAY_SIZE(aic3x_snd_controls));
if (aic3x->model == AIC3X_MODEL_3007)
snd_soc_add_controls(codec, &aic3x_classd_amp_gain_ctrl, 1);
aic3x_add_widgets(codec); aic3x_add_widgets(codec);
...@@ -1274,6 +1326,14 @@ static struct snd_soc_codec_driver soc_codec_dev_aic3x = { ...@@ -1274,6 +1326,14 @@ static struct snd_soc_codec_driver soc_codec_dev_aic3x = {
* 0x18, 0x19, 0x1A, 0x1B * 0x18, 0x19, 0x1A, 0x1B
*/ */
static const struct i2c_device_id aic3x_i2c_id[] = {
[AIC3X_MODEL_3X] = { "tlv320aic3x", 0 },
[AIC3X_MODEL_33] = { "tlv320aic33", 0 },
[AIC3X_MODEL_3007] = { "tlv320aic3007", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
/* /*
* If the i2c layer weren't so broken, we could pass this kind of data * If the i2c layer weren't so broken, we could pass this kind of data
* around * around
...@@ -1285,6 +1345,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, ...@@ -1285,6 +1345,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
struct aic3x_setup_data *setup = pdata->setup; struct aic3x_setup_data *setup = pdata->setup;
struct aic3x_priv *aic3x; struct aic3x_priv *aic3x;
int ret, i; int ret, i;
const struct i2c_device_id *tbl;
aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL);
if (aic3x == NULL) { if (aic3x == NULL) {
...@@ -1305,6 +1366,12 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, ...@@ -1305,6 +1366,12 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
gpio_direction_output(aic3x->gpio_reset, 0); gpio_direction_output(aic3x->gpio_reset, 0);
} }
for (tbl = aic3x_i2c_id; tbl->name[0]; tbl++) {
if (!strcmp(tbl->name, id->name))
break;
}
aic3x->model = tbl - aic3x_i2c_id;
for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++)
aic3x->supplies[i].supply = aic3x_supply_names[i]; aic3x->supplies[i].supply = aic3x_supply_names[i];
...@@ -1359,13 +1426,6 @@ static int aic3x_i2c_remove(struct i2c_client *client) ...@@ -1359,13 +1426,6 @@ static int aic3x_i2c_remove(struct i2c_client *client)
return 0; return 0;
} }
static const struct i2c_device_id aic3x_i2c_id[] = {
{ "tlv320aic3x", 0 },
{ "tlv320aic33", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id);
/* machine i2c codec control layer */ /* machine i2c codec control layer */
static struct i2c_driver aic3x_i2c_driver = { static struct i2c_driver aic3x_i2c_driver = {
.driver = { .driver = {
......
...@@ -111,6 +111,8 @@ ...@@ -111,6 +111,8 @@
#define DACL1_2_MONOLOPM_VOL 75 #define DACL1_2_MONOLOPM_VOL 75
#define DACR1_2_MONOLOPM_VOL 78 #define DACR1_2_MONOLOPM_VOL 78
#define MONOLOPM_CTRL 79 #define MONOLOPM_CTRL 79
/* Class-D speaker driver on tlv320aic3007 */
#define CLASSD_CTRL 73
/* Line Output Plus/Minus control registers */ /* Line Output Plus/Minus control registers */
#define LINE2L_2_LLOPM_VOL 80 #define LINE2L_2_LLOPM_VOL 80
#define LINE2L_2_RLOPM_VOL 87 #define LINE2L_2_RLOPM_VOL 87
......
This diff is collapsed.
/*
* sound/soc/codec/wl1273.h
*
* ALSA SoC WL1273 codec driver
*
* Copyright (C) Nokia Corporation
* Author: Matti Aaltonen <matti.j.aaltonen@nokia.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef __WL1273_CODEC_H__
#define __WL1273_CODEC_H__
/* I2S protocol, left channel first, data width 16 bits */
#define WL1273_PCM_DEF_MODE 0x00
/* Rx */
#define WL1273_AUDIO_ENABLE_I2S (1 << 0)
#define WL1273_AUDIO_ENABLE_ANALOG (1 << 1)
/* Tx */
#define WL1273_AUDIO_IO_SET_ANALOG 0
#define WL1273_AUDIO_IO_SET_I2S 1
#define WL1273_POWER_SET_OFF 0
#define WL1273_POWER_SET_FM (1 << 0)
#define WL1273_POWER_SET_RDS (1 << 1)
#define WL1273_POWER_SET_RETENTION (1 << 4)
#define WL1273_PUPD_SET_OFF 0x00
#define WL1273_PUPD_SET_ON 0x01
#define WL1273_PUPD_SET_RETENTION 0x10
/* I2S mode */
#define WL1273_IS2_WIDTH_32 0x0
#define WL1273_IS2_WIDTH_40 0x1
#define WL1273_IS2_WIDTH_22_23 0x2
#define WL1273_IS2_WIDTH_23_22 0x3
#define WL1273_IS2_WIDTH_48 0x4
#define WL1273_IS2_WIDTH_50 0x5
#define WL1273_IS2_WIDTH_60 0x6
#define WL1273_IS2_WIDTH_64 0x7
#define WL1273_IS2_WIDTH_80 0x8
#define WL1273_IS2_WIDTH_96 0x9
#define WL1273_IS2_WIDTH_128 0xa
#define WL1273_IS2_WIDTH 0xf
#define WL1273_IS2_FORMAT_STD (0x0 << 4)
#define WL1273_IS2_FORMAT_LEFT (0x1 << 4)
#define WL1273_IS2_FORMAT_RIGHT (0x2 << 4)
#define WL1273_IS2_FORMAT_USER (0x3 << 4)
#define WL1273_IS2_MASTER (0x0 << 6)
#define WL1273_IS2_SLAVEW (0x1 << 6)
#define WL1273_IS2_TRI_AFTER_SENDING (0x0 << 7)
#define WL1273_IS2_TRI_ALWAYS_ACTIVE (0x1 << 7)
#define WL1273_IS2_SDOWS_RR (0x0 << 8)
#define WL1273_IS2_SDOWS_RF (0x1 << 8)
#define WL1273_IS2_SDOWS_FR (0x2 << 8)
#define WL1273_IS2_SDOWS_FF (0x3 << 8)
#define WL1273_IS2_TRI_OPT (0x0 << 10)
#define WL1273_IS2_TRI_ALWAYS (0x1 << 10)
#define WL1273_IS2_RATE_48K (0x0 << 12)
#define WL1273_IS2_RATE_44_1K (0x1 << 12)
#define WL1273_IS2_RATE_32K (0x2 << 12)
#define WL1273_IS2_RATE_22_05K (0x4 << 12)
#define WL1273_IS2_RATE_16K (0x5 << 12)
#define WL1273_IS2_RATE_12K (0x8 << 12)
#define WL1273_IS2_RATE_11_025 (0x9 << 12)
#define WL1273_IS2_RATE_8K (0xa << 12)
#define WL1273_IS2_RATE (0xf << 12)
#define WL1273_I2S_DEF_MODE (WL1273_IS2_WIDTH_32 | \
WL1273_IS2_FORMAT_STD | \
WL1273_IS2_MASTER | \
WL1273_IS2_TRI_AFTER_SENDING | \
WL1273_IS2_SDOWS_RR | \
WL1273_IS2_TRI_OPT | \
WL1273_IS2_RATE_48K)
int wl1273_get_format(struct snd_soc_codec *codec, unsigned int *fmt);
#endif /* End of __WL1273_CODEC_H__ */
...@@ -311,7 +311,7 @@ static struct snd_soc_dai_ops wm8741_dai_ops = { ...@@ -311,7 +311,7 @@ static struct snd_soc_dai_ops wm8741_dai_ops = {
}; };
static struct snd_soc_dai_driver wm8741_dai = { static struct snd_soc_dai_driver wm8741_dai = {
.name = "WM8741", .name = "wm8741",
.playback = { .playback = {
.stream_name = "Playback", .stream_name = "Playback",
.channels_min = 2, /* Mono modes not yet supported */ .channels_min = 2, /* Mono modes not yet supported */
......
...@@ -3316,20 +3316,24 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -3316,20 +3316,24 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
bclk_reg = WM8994_AIF1_BCLK; bclk_reg = WM8994_AIF1_BCLK;
rate_reg = WM8994_AIF1_RATE; rate_reg = WM8994_AIF1_RATE;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
wm8994->lrclk_shared[0]) wm8994->lrclk_shared[0]) {
lrclk_reg = WM8994_AIF1DAC_LRCLK; lrclk_reg = WM8994_AIF1DAC_LRCLK;
else } else {
lrclk_reg = WM8994_AIF1ADC_LRCLK; lrclk_reg = WM8994_AIF1ADC_LRCLK;
dev_dbg(codec->dev, "AIF1 using split LRCLK\n");
}
break; break;
case 2: case 2:
aif1_reg = WM8994_AIF2_CONTROL_1; aif1_reg = WM8994_AIF2_CONTROL_1;
bclk_reg = WM8994_AIF2_BCLK; bclk_reg = WM8994_AIF2_BCLK;
rate_reg = WM8994_AIF2_RATE; rate_reg = WM8994_AIF2_RATE;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
wm8994->lrclk_shared[1]) wm8994->lrclk_shared[1]) {
lrclk_reg = WM8994_AIF2DAC_LRCLK; lrclk_reg = WM8994_AIF2DAC_LRCLK;
else } else {
lrclk_reg = WM8994_AIF2ADC_LRCLK; lrclk_reg = WM8994_AIF2ADC_LRCLK;
dev_dbg(codec->dev, "AIF2 using split LRCLK\n");
}
break; break;
default: default:
return -EINVAL; return -EINVAL;
......
config SND_MPC52xx_DMA config SND_MPC52xx_DMA
tristate tristate
# ASoC platform support for the Freescale MPC8610 SOC. This compiles drivers # ASoC platform support for the Freescale PowerPC SOCs that have an SSI and
# for the SSI and the Elo DMA controller. You will still need to select # an Elo DMA controller, such as the MPC8610 and P1022. You will still need to
# a platform driver and a codec driver. # select a platform driver and a codec driver.
config SND_SOC_MPC8610 config SND_SOC_POWERPC_SSI
tristate tristate
depends on MPC8610 depends on FSL_SOC
config SND_SOC_MPC8610_HPCD config SND_SOC_MPC8610_HPCD
tristate "ALSA SoC support for the Freescale MPC8610 HPCD board" tristate "ALSA SoC support for the Freescale MPC8610 HPCD board"
# I2C is necessary for the CS4270 driver # I2C is necessary for the CS4270 driver
depends on MPC8610_HPCD && I2C depends on MPC8610_HPCD && I2C
select SND_SOC_MPC8610 select SND_SOC_POWERPC_SSI
select SND_SOC_CS4270 select SND_SOC_CS4270
select SND_SOC_CS4270_VD33_ERRATA select SND_SOC_CS4270_VD33_ERRATA
default y if MPC8610_HPCD default y if MPC8610_HPCD
help help
Say Y if you want to enable audio on the Freescale MPC8610 HPCD. Say Y if you want to enable audio on the Freescale MPC8610 HPCD.
config SND_SOC_P1022_DS
tristate "ALSA SoC support for the Freescale P1022 DS board"
# I2C is necessary for the WM8776 driver
depends on P1022_DS && I2C
select SND_SOC_POWERPC_SSI
select SND_SOC_WM8776
default y if P1022_DS
help
Say Y if you want to enable audio on the Freescale P1022 DS board.
This will also include the Wolfson Microelectronics WM8776 codec
driver.
config SND_SOC_MPC5200_I2S config SND_SOC_MPC5200_I2S
tristate "Freescale MPC5200 PSC in I2S mode driver" tristate "Freescale MPC5200 PSC in I2S mode driver"
depends on PPC_MPC52xx && PPC_BESTCOMM depends on PPC_MPC52xx && PPC_BESTCOMM
......
...@@ -2,10 +2,14 @@ ...@@ -2,10 +2,14 @@
snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o snd-soc-mpc8610-hpcd-objs := mpc8610_hpcd.o
obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o
# MPC8610 Platform Support # P1022 DS Machine Support
snd-soc-p1022-ds-objs := p1022_ds.o
obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o
# Freescale PowerPC SSI/DMA Platform Support
snd-soc-fsl-ssi-objs := fsl_ssi.o snd-soc-fsl-ssi-objs := fsl_ssi.o
snd-soc-fsl-dma-objs := fsl_dma.o snd-soc-fsl-dma-objs := fsl_dma.o
obj-$(CONFIG_SND_SOC_MPC8610) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o obj-$(CONFIG_SND_SOC_POWERPC_SSI) += snd-soc-fsl-ssi.o snd-soc-fsl-dma.o
# MPC5200 Platform Support # MPC5200 Platform Support
obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o obj-$(CONFIG_SND_MPC52xx_DMA) += mpc5200_dma.o
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/gfp.h> #include <linux/gfp.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -60,6 +61,7 @@ struct dma_object { ...@@ -60,6 +61,7 @@ struct dma_object {
struct snd_soc_platform_driver dai; struct snd_soc_platform_driver dai;
dma_addr_t ssi_stx_phys; dma_addr_t ssi_stx_phys;
dma_addr_t ssi_srx_phys; dma_addr_t ssi_srx_phys;
unsigned int ssi_fifo_depth;
struct ccsr_dma_channel __iomem *channel; struct ccsr_dma_channel __iomem *channel;
unsigned int irq; unsigned int irq;
bool assigned; bool assigned;
...@@ -99,6 +101,7 @@ struct fsl_dma_private { ...@@ -99,6 +101,7 @@ struct fsl_dma_private {
unsigned int irq; unsigned int irq;
struct snd_pcm_substream *substream; struct snd_pcm_substream *substream;
dma_addr_t ssi_sxx_phys; dma_addr_t ssi_sxx_phys;
unsigned int ssi_fifo_depth;
dma_addr_t ld_buf_phys; dma_addr_t ld_buf_phys;
unsigned int current_link; unsigned int current_link;
dma_addr_t dma_buf_phys; dma_addr_t dma_buf_phys;
...@@ -303,22 +306,30 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai, ...@@ -303,22 +306,30 @@ static int fsl_dma_new(struct snd_card *card, struct snd_soc_dai *dai,
if (!card->dev->coherent_dma_mask) if (!card->dev->coherent_dma_mask)
card->dev->coherent_dma_mask = fsl_dma_dmamask; card->dev->coherent_dma_mask = fsl_dma_dmamask;
/* Some codecs have separate DAIs for playback and capture, so we
* should allocate a DMA buffer only for the streams that are valid.
*/
if (dai->driver->playback.channels_min) {
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
fsl_dma_hardware.buffer_bytes_max, fsl_dma_hardware.buffer_bytes_max,
&pcm->streams[0].substream->dma_buffer); &pcm->streams[0].substream->dma_buffer);
if (ret) { if (ret) {
dev_err(card->dev, "can't allocate playback dma buffer\n"); dev_err(card->dev, "can't alloc playback dma buffer\n");
return ret; return ret;
} }
}
if (dai->driver->capture.channels_min) {
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev, ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, card->dev,
fsl_dma_hardware.buffer_bytes_max, fsl_dma_hardware.buffer_bytes_max,
&pcm->streams[1].substream->dma_buffer); &pcm->streams[1].substream->dma_buffer);
if (ret) { if (ret) {
snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer); snd_dma_free_pages(&pcm->streams[0].substream->dma_buffer);
dev_err(card->dev, "can't allocate capture dma buffer\n"); dev_err(card->dev, "can't alloc capture dma buffer\n");
return ret; return ret;
} }
}
return 0; return 0;
} }
...@@ -431,6 +442,7 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) ...@@ -431,6 +442,7 @@ static int fsl_dma_open(struct snd_pcm_substream *substream)
else else
dma_private->ssi_sxx_phys = dma->ssi_srx_phys; dma_private->ssi_sxx_phys = dma->ssi_srx_phys;
dma_private->ssi_fifo_depth = dma->ssi_fifo_depth;
dma_private->dma_channel = dma->channel; dma_private->dma_channel = dma->channel;
dma_private->irq = dma->irq; dma_private->irq = dma->irq;
dma_private->substream = substream; dma_private->substream = substream;
...@@ -544,11 +556,11 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -544,11 +556,11 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream,
struct device *dev = rtd->platform->dev; struct device *dev = rtd->platform->dev;
/* Number of bits per sample */ /* Number of bits per sample */
unsigned int sample_size = unsigned int sample_bits =
snd_pcm_format_physical_width(params_format(hw_params)); snd_pcm_format_physical_width(params_format(hw_params));
/* Number of bytes per frame */ /* Number of bytes per frame */
unsigned int frame_size = 2 * (sample_size / 8); unsigned int sample_bytes = sample_bits / 8;
/* Bus address of SSI STX register */ /* Bus address of SSI STX register */
dma_addr_t ssi_sxx_phys = dma_private->ssi_sxx_phys; dma_addr_t ssi_sxx_phys = dma_private->ssi_sxx_phys;
...@@ -588,7 +600,7 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -588,7 +600,7 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream,
* that offset here. While we're at it, also tell the DMA controller * that offset here. While we're at it, also tell the DMA controller
* how much data to transfer per sample. * how much data to transfer per sample.
*/ */
switch (sample_size) { switch (sample_bits) {
case 8: case 8:
mr |= CCSR_DMA_MR_DAHTS_1 | CCSR_DMA_MR_SAHTS_1; mr |= CCSR_DMA_MR_DAHTS_1 | CCSR_DMA_MR_SAHTS_1;
ssi_sxx_phys += 3; ssi_sxx_phys += 3;
...@@ -602,22 +614,42 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, ...@@ -602,22 +614,42 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream,
break; break;
default: default:
/* We should never get here */ /* We should never get here */
dev_err(dev, "unsupported sample size %u\n", sample_size); dev_err(dev, "unsupported sample size %u\n", sample_bits);
return -EINVAL; return -EINVAL;
} }
/* /*
* BWC should always be a multiple of the frame size. BWC determines * BWC determines how many bytes are sent/received before the DMA
* how many bytes are sent/received before the DMA controller checks the * controller checks the SSI to see if it needs to stop. BWC should
* SSI to see if it needs to stop. For playback, the transmit FIFO can * always be a multiple of the frame size, so that we always transmit
* hold three frames, so we want to send two frames at a time. For * whole frames. Each frame occupies two slots in the FIFO. The
* capture, the receive FIFO is triggered when it contains one frame, so * parameter for CCSR_DMA_MR_BWC() is rounded down the next power of two
* we want to receive one frame at a time. * (MR[BWC] can only represent even powers of two).
*
* To simplify the process, we set BWC to the largest value that is
* less than or equal to the FIFO watermark. For playback, this ensures
* that we transfer the maximum amount without overrunning the FIFO.
* For capture, this ensures that we transfer the maximum amount without
* underrunning the FIFO.
*
* f = SSI FIFO depth
* w = SSI watermark value (which equals f - 2)
* b = DMA bandwidth count (in bytes)
* s = sample size (in bytes, which equals frame_size * 2)
*
* For playback, we never transmit more than the transmit FIFO
* watermark, otherwise we might write more data than the FIFO can hold.
* The watermark is equal to the FIFO depth minus two.
*
* For capture, two equations must hold:
* w > f - (b / s)
* w >= b / s
*
* So, b > 2 * s, but b must also be <= s * w. To simplify, we set
* b = s * w, which is equal to
* (dma_private->ssi_fifo_depth - 2) * sample_bytes.
*/ */
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) mr |= CCSR_DMA_MR_BWC((dma_private->ssi_fifo_depth - 2) * sample_bytes);
mr |= CCSR_DMA_MR_BWC(2 * frame_size);
else
mr |= CCSR_DMA_MR_BWC(frame_size);
out_be32(&dma_channel->mr, mr); out_be32(&dma_channel->mr, mr);
...@@ -864,32 +896,35 @@ static struct snd_pcm_ops fsl_dma_ops = { ...@@ -864,32 +896,35 @@ static struct snd_pcm_ops fsl_dma_ops = {
.pointer = fsl_dma_pointer, .pointer = fsl_dma_pointer,
}; };
static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, static int __devinit fsl_soc_dma_probe(struct platform_device *pdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct dma_object *dma; struct dma_object *dma;
struct device_node *np = of_dev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct device_node *ssi_np; struct device_node *ssi_np;
struct resource res; struct resource res;
const uint32_t *iprop;
int ret; int ret;
/* Find the SSI node that points to us. */ /* Find the SSI node that points to us. */
ssi_np = find_ssi_node(np); ssi_np = find_ssi_node(np);
if (!ssi_np) { if (!ssi_np) {
dev_err(&of_dev->dev, "cannot find parent SSI node\n"); dev_err(&pdev->dev, "cannot find parent SSI node\n");
return -ENODEV; return -ENODEV;
} }
ret = of_address_to_resource(ssi_np, 0, &res); ret = of_address_to_resource(ssi_np, 0, &res);
of_node_put(ssi_np);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not determine device resources\n"); dev_err(&pdev->dev, "could not determine resources for %s\n",
ssi_np->full_name);
of_node_put(ssi_np);
return ret; return ret;
} }
dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL); dma = kzalloc(sizeof(*dma) + strlen(np->full_name), GFP_KERNEL);
if (!dma) { if (!dma) {
dev_err(&of_dev->dev, "could not allocate dma object\n"); dev_err(&pdev->dev, "could not allocate dma object\n");
of_node_put(ssi_np);
return -ENOMEM; return -ENOMEM;
} }
...@@ -902,9 +937,18 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -902,9 +937,18 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->ssi_stx_phys = res.start + offsetof(struct ccsr_ssi, stx0); dma->ssi_stx_phys = res.start + offsetof(struct ccsr_ssi, stx0);
dma->ssi_srx_phys = res.start + offsetof(struct ccsr_ssi, srx0); dma->ssi_srx_phys = res.start + offsetof(struct ccsr_ssi, srx0);
ret = snd_soc_register_platform(&of_dev->dev, &dma->dai); iprop = of_get_property(ssi_np, "fsl,fifo-depth", NULL);
if (iprop)
dma->ssi_fifo_depth = *iprop;
else
/* Older 8610 DTs didn't have the fifo-depth property */
dma->ssi_fifo_depth = 8;
of_node_put(ssi_np);
ret = snd_soc_register_platform(&pdev->dev, &dma->dai);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not register platform\n"); dev_err(&pdev->dev, "could not register platform\n");
kfree(dma); kfree(dma);
return ret; return ret;
} }
...@@ -912,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev, ...@@ -912,16 +956,16 @@ static int __devinit fsl_soc_dma_probe(struct of_device *of_dev,
dma->channel = of_iomap(np, 0); dma->channel = of_iomap(np, 0);
dma->irq = irq_of_parse_and_map(np, 0); dma->irq = irq_of_parse_and_map(np, 0);
dev_set_drvdata(&of_dev->dev, dma); dev_set_drvdata(&pdev->dev, dma);
return 0; return 0;
} }
static int __devexit fsl_soc_dma_remove(struct of_device *of_dev) static int __devexit fsl_soc_dma_remove(struct platform_device *pdev)
{ {
struct dma_object *dma = dev_get_drvdata(&of_dev->dev); struct dma_object *dma = dev_get_drvdata(&pdev->dev);
snd_soc_unregister_platform(&of_dev->dev); snd_soc_unregister_platform(&pdev->dev);
iounmap(dma->channel); iounmap(dma->channel);
irq_dispose_mapping(dma->irq); irq_dispose_mapping(dma->irq);
kfree(dma); kfree(dma);
......
...@@ -93,6 +93,7 @@ struct fsl_ssi_private { ...@@ -93,6 +93,7 @@ struct fsl_ssi_private {
unsigned int playback; unsigned int playback;
unsigned int capture; unsigned int capture;
int asynchronous; int asynchronous;
unsigned int fifo_depth;
struct snd_soc_dai_driver cpu_dai_drv; struct snd_soc_dai_driver cpu_dai_drv;
struct device_attribute dev_attr; struct device_attribute dev_attr;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -337,11 +338,20 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, ...@@ -337,11 +338,20 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
/* /*
* Set the watermark for transmit FIFI 0 and receive FIFO 0. We * Set the watermark for transmit FIFI 0 and receive FIFO 0. We
* don't use FIFO 1. Since the SSI only supports stereo, the * don't use FIFO 1. We program the transmit water to signal a
* watermark should never be an odd number. * DMA transfer if there are only two (or fewer) elements left
* in the FIFO. Two elements equals one frame (left channel,
* right channel). This value, however, depends on the depth of
* the transmit buffer.
*
* We program the receive FIFO to notify us if at least two
* elements (one frame) have been written to the FIFO. We could
* make this value larger (and maybe we should), but this way
* data will be written to memory as soon as it's available.
*/ */
out_be32(&ssi->sfcsr, out_be32(&ssi->sfcsr,
CCSR_SSI_SFCSR_TFWM0(6) | CCSR_SSI_SFCSR_RFWM0(2)); CCSR_SSI_SFCSR_TFWM0(ssi_private->fifo_depth - 2) |
CCSR_SSI_SFCSR_RFWM0(ssi_private->fifo_depth - 2));
/* /*
* We keep the SSI disabled because if we enable it, then the * We keep the SSI disabled because if we enable it, then the
...@@ -614,14 +624,15 @@ static void make_lowercase(char *s) ...@@ -614,14 +624,15 @@ static void make_lowercase(char *s)
} }
} }
static int __devinit fsl_ssi_probe(struct of_device *of_dev, static int __devinit fsl_ssi_probe(struct platform_device *pdev,
const struct of_device_id *match) const struct of_device_id *match)
{ {
struct fsl_ssi_private *ssi_private; struct fsl_ssi_private *ssi_private;
int ret = 0; int ret = 0;
struct device_attribute *dev_attr = NULL; struct device_attribute *dev_attr = NULL;
struct device_node *np = of_dev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const char *p, *sprop; const char *p, *sprop;
const uint32_t *iprop;
struct resource res; struct resource res;
char name[64]; char name[64];
...@@ -634,14 +645,14 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -634,14 +645,14 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Check for a codec-handle property. */ /* Check for a codec-handle property. */
if (!of_get_property(np, "codec-handle", NULL)) { if (!of_get_property(np, "codec-handle", NULL)) {
dev_err(&of_dev->dev, "missing codec-handle property\n"); dev_err(&pdev->dev, "missing codec-handle property\n");
return -ENODEV; return -ENODEV;
} }
/* We only support the SSI in "I2S Slave" mode */ /* We only support the SSI in "I2S Slave" mode */
sprop = of_get_property(np, "fsl,mode", NULL); sprop = of_get_property(np, "fsl,mode", NULL);
if (!sprop || strcmp(sprop, "i2s-slave")) { if (!sprop || strcmp(sprop, "i2s-slave")) {
dev_notice(&of_dev->dev, "mode %s is unsupported\n", sprop); dev_notice(&pdev->dev, "mode %s is unsupported\n", sprop);
return -ENODEV; return -ENODEV;
} }
...@@ -650,7 +661,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -650,7 +661,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p), ssi_private = kzalloc(sizeof(struct fsl_ssi_private) + strlen(p),
GFP_KERNEL); GFP_KERNEL);
if (!ssi_private) { if (!ssi_private) {
dev_err(&of_dev->dev, "could not allocate DAI object\n"); dev_err(&pdev->dev, "could not allocate DAI object\n");
return -ENOMEM; return -ENOMEM;
} }
...@@ -664,7 +675,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -664,7 +675,7 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
/* Get the addresses and IRQ */ /* Get the addresses and IRQ */
ret = of_address_to_resource(np, 0, &res); ret = of_address_to_resource(np, 0, &res);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not determine device resources\n"); dev_err(&pdev->dev, "could not determine device resources\n");
kfree(ssi_private); kfree(ssi_private);
return ret; return ret;
} }
...@@ -678,25 +689,33 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -678,25 +689,33 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
else else
ssi_private->cpu_dai_drv.symmetric_rates = 1; ssi_private->cpu_dai_drv.symmetric_rates = 1;
/* Determine the FIFO depth. */
iprop = of_get_property(np, "fsl,fifo-depth", NULL);
if (iprop)
ssi_private->fifo_depth = *iprop;
else
/* Older 8610 DTs didn't have the fifo-depth property */
ssi_private->fifo_depth = 8;
/* Initialize the the device_attribute structure */ /* Initialize the the device_attribute structure */
dev_attr = &ssi_private->dev_attr; dev_attr = &ssi_private->dev_attr;
dev_attr->attr.name = "statistics"; dev_attr->attr.name = "statistics";
dev_attr->attr.mode = S_IRUGO; dev_attr->attr.mode = S_IRUGO;
dev_attr->show = fsl_sysfs_ssi_show; dev_attr->show = fsl_sysfs_ssi_show;
ret = device_create_file(&of_dev->dev, dev_attr); ret = device_create_file(&pdev->dev, dev_attr);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "could not create sysfs %s file\n", dev_err(&pdev->dev, "could not create sysfs %s file\n",
ssi_private->dev_attr.attr.name); ssi_private->dev_attr.attr.name);
goto error; goto error;
} }
/* Register with ASoC */ /* Register with ASoC */
dev_set_drvdata(&of_dev->dev, ssi_private); dev_set_drvdata(&pdev->dev, ssi_private);
ret = snd_soc_register_dai(&of_dev->dev, &ssi_private->cpu_dai_drv); ret = snd_soc_register_dai(&pdev->dev, &ssi_private->cpu_dai_drv);
if (ret) { if (ret) {
dev_err(&of_dev->dev, "failed to register DAI: %d\n", ret); dev_err(&pdev->dev, "failed to register DAI: %d\n", ret);
goto error; goto error;
} }
...@@ -714,20 +733,20 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -714,20 +733,20 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
make_lowercase(name); make_lowercase(name);
ssi_private->pdev = ssi_private->pdev =
platform_device_register_data(&of_dev->dev, name, 0, NULL, 0); platform_device_register_data(&pdev->dev, name, 0, NULL, 0);
if (IS_ERR(ssi_private->pdev)) { if (IS_ERR(ssi_private->pdev)) {
ret = PTR_ERR(ssi_private->pdev); ret = PTR_ERR(ssi_private->pdev);
dev_err(&of_dev->dev, "failed to register platform: %d\n", ret); dev_err(&pdev->dev, "failed to register platform: %d\n", ret);
goto error; goto error;
} }
return 0; return 0;
error: error:
snd_soc_unregister_dai(&of_dev->dev); snd_soc_unregister_dai(&pdev->dev);
dev_set_drvdata(&of_dev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
if (dev_attr) if (dev_attr)
device_remove_file(&of_dev->dev, dev_attr); device_remove_file(&pdev->dev, dev_attr);
irq_dispose_mapping(ssi_private->irq); irq_dispose_mapping(ssi_private->irq);
iounmap(ssi_private->ssi); iounmap(ssi_private->ssi);
kfree(ssi_private); kfree(ssi_private);
...@@ -735,16 +754,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev, ...@@ -735,16 +754,16 @@ static int __devinit fsl_ssi_probe(struct of_device *of_dev,
return ret; return ret;
} }
static int fsl_ssi_remove(struct of_device *of_dev) static int fsl_ssi_remove(struct platform_device *pdev)
{ {
struct fsl_ssi_private *ssi_private = dev_get_drvdata(&of_dev->dev); struct fsl_ssi_private *ssi_private = dev_get_drvdata(&pdev->dev);
platform_device_unregister(ssi_private->pdev); platform_device_unregister(ssi_private->pdev);
snd_soc_unregister_dai(&of_dev->dev); snd_soc_unregister_dai(&pdev->dev);
device_remove_file(&of_dev->dev, &ssi_private->dev_attr); device_remove_file(&pdev->dev, &ssi_private->dev_attr);
kfree(ssi_private); kfree(ssi_private);
dev_set_drvdata(&of_dev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
return 0; return 0;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/slab.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <asm/fsl_guts.h> #include <asm/fsl_guts.h>
...@@ -323,9 +324,10 @@ static int get_dma_channel(struct device_node *ssi_np, ...@@ -323,9 +324,10 @@ static int get_dma_channel(struct device_node *ssi_np,
static int mpc8610_hpcd_probe(struct platform_device *pdev) static int mpc8610_hpcd_probe(struct platform_device *pdev)
{ {
struct device *dev = pdev->dev.parent; struct device *dev = pdev->dev.parent;
/* of_dev is the OF device for the SSI node that probed us */ /* ssi_pdev is the platform device for the SSI node that probed us */
struct of_device *of_dev = container_of(dev, struct of_device, dev); struct platform_device *ssi_pdev =
struct device_node *np = of_dev->dev.of_node; container_of(dev, struct platform_device, dev);
struct device_node *np = ssi_pdev->dev.of_node;
struct device_node *codec_np = NULL; struct device_node *codec_np = NULL;
struct platform_device *sound_device = NULL; struct platform_device *sound_device = NULL;
struct mpc8610_hpcd_data *machine_data; struct mpc8610_hpcd_data *machine_data;
...@@ -348,7 +350,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev) ...@@ -348,7 +350,7 @@ static int mpc8610_hpcd_probe(struct platform_device *pdev)
if (!machine_data) if (!machine_data)
return -ENOMEM; return -ENOMEM;
machine_data->dai[0].cpu_dai_name = dev_name(&of_dev->dev); machine_data->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
machine_data->dai[0].ops = &mpc8610_hpcd_ops; machine_data->dai[0].ops = &mpc8610_hpcd_ops;
/* Determine the codec name, it will be used as the codec DAI name */ /* Determine the codec name, it will be used as the codec DAI name */
......
This diff is collapsed.
...@@ -254,6 +254,9 @@ static int imx_ssi_hw_params(struct snd_pcm_substream *substream, ...@@ -254,6 +254,9 @@ static int imx_ssi_hw_params(struct snd_pcm_substream *substream,
dma_data = &ssi->dma_params_rx; dma_data = &ssi->dma_params_rx;
} }
if (ssi->flags & IMX_SSI_SYN)
reg = SSI_STCCR;
snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data);
sccr = readl(ssi->base + reg) & ~SSI_STCCR_WL_MASK; sccr = readl(ssi->base + reg) & ~SSI_STCCR_WL_MASK;
......
...@@ -584,7 +584,7 @@ static struct snd_soc_dai_link ams_delta_dai_link = { ...@@ -584,7 +584,7 @@ static struct snd_soc_dai_link ams_delta_dai_link = {
.name = "CX20442", .name = "CX20442",
.stream_name = "CX20442", .stream_name = "CX20442",
.cpu_dai_name ="omap-mcbsp-dai.0", .cpu_dai_name ="omap-mcbsp-dai.0",
.codec_dai_name = "cx20442-hifi", .codec_dai_name = "cx20442-voice",
.init = ams_delta_cx20442_init, .init = ams_delta_cx20442_init,
.platform_name = "omap-pcm-audio", .platform_name = "omap-pcm-audio",
.codec_name = "cx20442-codec", .codec_name = "cx20442-codec",
......
...@@ -117,6 +117,24 @@ config SND_PXA2XX_SOC_PALM27X ...@@ -117,6 +117,24 @@ config SND_PXA2XX_SOC_PALM27X
Say Y if you want to add support for SoC audio on Say Y if you want to add support for SoC audio on
Palm T|X, T5, E2 or LifeDrive handheld computer. Palm T|X, T5, E2 or LifeDrive handheld computer.
config SND_SOC_SAARB
tristate "SoC Audio support for Marvell Saarb"
depends on SND_PXA2XX_SOC && MACH_SAARB
select SND_PXA_SOC_SSP
select SND_SOC_88PM860X
help
Say Y if you want to add support for SoC audio on the
Marvell Saarb reference platform.
config SND_SOC_TAVOREVB3
tristate "SoC Audio support for Marvell Tavor EVB3"
depends on SND_PXA2XX_SOC && MACH_TAVOREVB3
select SND_PXA_SOC_SSP
select SND_SOC_88PM860X
help
Say Y if you want to add support for SoC audio on the
Marvell Saarb reference platform.
config SND_SOC_ZYLONITE config SND_SOC_ZYLONITE
tristate "SoC Audio support for Marvell Zylonite" tristate "SoC Audio support for Marvell Zylonite"
depends on SND_PXA2XX_SOC && MACH_ZYLONITE depends on SND_PXA2XX_SOC && MACH_ZYLONITE
......
...@@ -19,6 +19,8 @@ snd-soc-e800-objs := e800_wm9712.o ...@@ -19,6 +19,8 @@ snd-soc-e800-objs := e800_wm9712.o
snd-soc-spitz-objs := spitz.o snd-soc-spitz-objs := spitz.o
snd-soc-em-x270-objs := em-x270.o snd-soc-em-x270-objs := em-x270.o
snd-soc-palm27x-objs := palm27x.o snd-soc-palm27x-objs := palm27x.o
snd-soc-saarb-objs := saarb.o
snd-soc-tavorevb3-objs := tavorevb3.o
snd-soc-zylonite-objs := zylonite.o snd-soc-zylonite-objs := zylonite.o
snd-soc-magician-objs := magician.o snd-soc-magician-objs := magician.o
snd-soc-mioa701-objs := mioa701_wm9713.o snd-soc-mioa701-objs := mioa701_wm9713.o
...@@ -38,6 +40,8 @@ obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o ...@@ -38,6 +40,8 @@ obj-$(CONFIG_SND_PXA2XX_SOC_PALM27X) += snd-soc-palm27x.o
obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o obj-$(CONFIG_SND_PXA2XX_SOC_MAGICIAN) += snd-soc-magician.o
obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o obj-$(CONFIG_SND_PXA2XX_SOC_MIOA701) += snd-soc-mioa701.o
obj-$(CONFIG_SND_PXA2XX_SOC_Z2) += snd-soc-z2.o obj-$(CONFIG_SND_PXA2XX_SOC_Z2) += snd-soc-z2.o
obj-$(CONFIG_SND_SOC_SAARB) += snd-soc-saarb.o
obj-$(CONFIG_SND_SOC_TAVOREVB3) += snd-soc-tavorevb3.o
obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o
obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o
obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o
...@@ -198,6 +198,9 @@ static int __init e740_init(void) ...@@ -198,6 +198,9 @@ static int __init e740_init(void)
static void __exit e740_exit(void) static void __exit e740_exit(void)
{ {
platform_device_unregister(e740_snd_device); platform_device_unregister(e740_snd_device);
gpio_free(GPIO_E740_WM9705_nAVDD2);
gpio_free(GPIO_E740_AMP_ON);
gpio_free(GPIO_E740_MIC_ON);
} }
module_init(e740_init); module_init(e740_init);
......
...@@ -63,7 +63,7 @@ static struct snd_soc_ops imote2_asoc_ops = { ...@@ -63,7 +63,7 @@ static struct snd_soc_ops imote2_asoc_ops = {
static struct snd_soc_dai_link imote2_dai = { static struct snd_soc_dai_link imote2_dai = {
.name = "WM8940", .name = "WM8940",
.stream_name = "WM8940", .stream_name = "WM8940",
.cpu_dai_name = "pxa-i2s", .cpu_dai_name = "pxa2xx-i2s",
.codec_dai_name = "wm8940-hifi", .codec_dai_name = "wm8940-hifi",
.platform_name = "pxa-pcm-audio", .platform_name = "pxa-pcm-audio",
.codec_name = "wm8940-codec.0-0034", .codec_name = "wm8940-codec.0-0034",
......
...@@ -437,7 +437,7 @@ static struct snd_soc_dai_link magician_dai[] = { ...@@ -437,7 +437,7 @@ static struct snd_soc_dai_link magician_dai[] = {
{ {
.name = "uda1380", .name = "uda1380",
.stream_name = "UDA1380 Capture", .stream_name = "UDA1380 Capture",
.cpu_dai_name = "pxa-i2s", .cpu_dai_name = "pxa2xx-i2s",
.codec_dai_name = "uda1380-hifi-capture", .codec_dai_name = "uda1380-hifi-capture",
.platform_name = "pxa-pcm-audio", .platform_name = "pxa-pcm-audio",
.codec_name = "uda1380-codec.0-0018", .codec_name = "uda1380-codec.0-0018",
......
...@@ -266,7 +266,7 @@ static int poodle_wm8731_init(struct snd_soc_pcm_runtime *rtd) ...@@ -266,7 +266,7 @@ static int poodle_wm8731_init(struct snd_soc_pcm_runtime *rtd)
static struct snd_soc_dai_link poodle_dai = { static struct snd_soc_dai_link poodle_dai = {
.name = "WM8731", .name = "WM8731",
.stream_name = "WM8731", .stream_name = "WM8731",
.cpu_dai_name = "pxa-i2s", .cpu_dai_name = "pxa2xx-i2s",
.codec_dai_name = "wm8731-hifi", .codec_dai_name = "wm8731-hifi",
.platform_name = "pxa-pcm-audio", .platform_name = "pxa-pcm-audio",
.codec_name = "wm8731-codec.0-001a", .codec_name = "wm8731-codec.0-001a",
......
...@@ -758,6 +758,7 @@ static int pxa_ssp_remove(struct snd_soc_dai *dai) ...@@ -758,6 +758,7 @@ static int pxa_ssp_remove(struct snd_soc_dai *dai)
struct ssp_priv *priv = snd_soc_dai_get_drvdata(dai); struct ssp_priv *priv = snd_soc_dai_get_drvdata(dai);
pxa_ssp_free(priv->ssp); pxa_ssp_free(priv->ssp);
kfree(priv);
return 0; return 0;
} }
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <mach/dma.h> #include <mach/dma.h>
#include <mach/audio.h> #include <mach/audio.h>
#include "pxa2xx-pcm.h"
#include "pxa2xx-ac97.h" #include "pxa2xx-ac97.h"
static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97) static void pxa2xx_ac97_warm_reset(struct snd_ac97 *ac97)
......
...@@ -398,3 +398,4 @@ module_exit(pxa2xx_i2s_exit); ...@@ -398,3 +398,4 @@ module_exit(pxa2xx_i2s_exit);
MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk"); MODULE_AUTHOR("Liam Girdwood, lrg@slimlogic.co.uk");
MODULE_DESCRIPTION("pxa2xx I2S SoC Interface"); MODULE_DESCRIPTION("pxa2xx I2S SoC Interface");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:pxa2xx-i2s");
/*
* saarb.c -- SoC audio for saarb
*
* Copyright (C) 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <asm/mach-types.h>
#include "../codecs/88pm860x-codec.h"
#include "pxa-ssp.h"
static int saarb_pm860x_init(struct snd_soc_pcm_runtime *rtd);
static struct platform_device *saarb_snd_device;
static struct snd_soc_jack hs_jack, mic_jack;
static struct snd_soc_jack_pin hs_jack_pins[] = {
{ .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
};
static struct snd_soc_jack_pin mic_jack_pins[] = {
{ .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
};
/* saarb machine dapm widgets */
static const struct snd_soc_dapm_widget saarb_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headphone Stereophone", NULL),
SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
SND_SOC_DAPM_SPK("Ext Speaker", NULL),
SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
SND_SOC_DAPM_MIC("Headset Mic", NULL),
SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
};
/* saarb machine audio map */
static const struct snd_soc_dapm_route audio_map[] = {
{"Headset Stereophone", NULL, "HS1"},
{"Headset Stereophone", NULL, "HS2"},
{"Ext Speaker", NULL, "LSP"},
{"Ext Speaker", NULL, "LSN"},
{"Lineout Out 1", NULL, "LINEOUT1"},
{"Lineout Out 2", NULL, "LINEOUT2"},
{"MIC1P", NULL, "Mic1 Bias"},
{"MIC1N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Ext Mic 1"},
{"MIC2P", NULL, "Mic1 Bias"},
{"MIC2N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Headset Mic 2"},
{"MIC3P", NULL, "Mic3 Bias"},
{"MIC3N", NULL, "Mic3 Bias"},
{"Mic3 Bias", NULL, "Ext Mic 3"},
};
static int saarb_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int width = snd_pcm_format_physical_width(params_format(params));
int ret;
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_NET_PLL, 0,
PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 3, 3, 2, width);
return ret;
}
static struct snd_soc_ops saarb_i2s_ops = {
.hw_params = saarb_i2s_hw_params,
};
static struct snd_soc_dai_link saarb_dai[] = {
{
.name = "88PM860x I2S",
.stream_name = "I2S Audio",
.cpu_dai_name = "pxa-ssp-dai.1",
.codec_dai_name = "88pm860x-i2s",
.platform_name = "pxa-pcm-audio",
.codec_name = "88pm860x-codec",
.init = saarb_pm860x_init,
.ops = &saarb_i2s_ops,
},
};
static struct snd_soc_card snd_soc_card_saarb = {
.name = "Saarb",
.dai_link = saarb_dai,
.num_links = ARRAY_SIZE(saarb_dai),
};
static int saarb_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
int ret;
snd_soc_dapm_new_controls(codec, saarb_dapm_widgets,
ARRAY_SIZE(saarb_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
/* connected pins */
snd_soc_dapm_enable_pin(codec, "Ext Speaker");
snd_soc_dapm_enable_pin(codec, "Ext Mic 1");
snd_soc_dapm_enable_pin(codec, "Ext Mic 3");
snd_soc_dapm_disable_pin(codec, "Headset Mic 2");
snd_soc_dapm_disable_pin(codec, "Headset Stereophone");
ret = snd_soc_dapm_sync(codec);
if (ret)
return ret;
/* Headset jack detection */
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE
| SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
&hs_jack);
snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
hs_jack_pins);
snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE,
&mic_jack);
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
mic_jack_pins);
/* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE);
return 0;
}
static int __init saarb_init(void)
{
int ret;
if (!machine_is_saarb())
return -ENODEV;
saarb_snd_device = platform_device_alloc("soc-audio", -1);
if (!saarb_snd_device)
return -ENOMEM;
platform_set_drvdata(saarb_snd_device, &snd_soc_card_saarb);
ret = platform_device_add(saarb_snd_device);
if (ret)
platform_device_put(saarb_snd_device);
return ret;
}
static void __exit saarb_exit(void)
{
platform_device_unregister(saarb_snd_device);
}
module_init(saarb_init);
module_exit(saarb_exit);
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_DESCRIPTION("ALSA SoC 88PM860x Saarb");
MODULE_LICENSE("GPL");
/*
* tavorevb3.c -- SoC audio for Tavor EVB3
*
* Copyright (C) 2010 Marvell International Ltd.
* Haojian Zhuang <haojian.zhuang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include <linux/clk.h>
#include <linux/i2c.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/jack.h>
#include <asm/mach-types.h>
#include "../codecs/88pm860x-codec.h"
#include "pxa-ssp.h"
static int evb3_pm860x_init(struct snd_soc_pcm_runtime *rtd);
static struct platform_device *evb3_snd_device;
static struct snd_soc_jack hs_jack, mic_jack;
static struct snd_soc_jack_pin hs_jack_pins[] = {
{ .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE, },
};
static struct snd_soc_jack_pin mic_jack_pins[] = {
{ .pin = "Headset Mic 2", .mask = SND_JACK_MICROPHONE, },
};
/* tavorevb3 machine dapm widgets */
static const struct snd_soc_dapm_widget evb3_dapm_widgets[] = {
SND_SOC_DAPM_HP("Headset Stereophone", NULL),
SND_SOC_DAPM_LINE("Lineout Out 1", NULL),
SND_SOC_DAPM_LINE("Lineout Out 2", NULL),
SND_SOC_DAPM_SPK("Ext Speaker", NULL),
SND_SOC_DAPM_MIC("Ext Mic 1", NULL),
SND_SOC_DAPM_MIC("Headset Mic 2", NULL),
SND_SOC_DAPM_MIC("Ext Mic 3", NULL),
};
/* tavorevb3 machine audio map */
static const struct snd_soc_dapm_route audio_map[] = {
{"Headset Stereophone", NULL, "HS1"},
{"Headset Stereophone", NULL, "HS2"},
{"Ext Speaker", NULL, "LSP"},
{"Ext Speaker", NULL, "LSN"},
{"Lineout Out 1", NULL, "LINEOUT1"},
{"Lineout Out 2", NULL, "LINEOUT2"},
{"MIC1P", NULL, "Mic1 Bias"},
{"MIC1N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Ext Mic 1"},
{"MIC2P", NULL, "Mic1 Bias"},
{"MIC2N", NULL, "Mic1 Bias"},
{"Mic1 Bias", NULL, "Headset Mic 2"},
{"MIC3P", NULL, "Mic3 Bias"},
{"MIC3N", NULL, "Mic3 Bias"},
{"Mic3 Bias", NULL, "Ext Mic 3"},
};
static int evb3_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int width = snd_pcm_format_physical_width(params_format(params));
int ret;
ret = snd_soc_dai_set_sysclk(cpu_dai, PXA_SSP_CLK_NET_PLL, 0,
PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, PM860X_CLK_DIR_OUT);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
if (ret < 0)
return ret;
ret = snd_soc_dai_set_tdm_slot(cpu_dai, 3, 3, 2, width);
return ret;
}
static struct snd_soc_ops evb3_i2s_ops = {
.hw_params = evb3_i2s_hw_params,
};
static struct snd_soc_dai_link evb3_dai[] = {
{
.name = "88PM860x I2S",
.stream_name = "I2S Audio",
.cpu_dai_name = "pxa-ssp-dai.1",
.codec_dai_name = "88pm860x-i2s",
.platform_name = "pxa-pcm-audio",
.codec_name = "88pm860x-codec",
.init = evb3_pm860x_init,
.ops = &evb3_i2s_ops,
},
};
static struct snd_soc_card snd_soc_card_evb3 = {
.name = "Tavor EVB3",
.dai_link = evb3_dai,
.num_links = ARRAY_SIZE(evb3_dai),
};
static int evb3_pm860x_init(struct snd_soc_pcm_runtime *rtd)
{
struct snd_soc_codec *codec = rtd->codec;
int ret;
snd_soc_dapm_new_controls(codec, evb3_dapm_widgets,
ARRAY_SIZE(evb3_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
/* connected pins */
snd_soc_dapm_enable_pin(codec, "Ext Speaker");
snd_soc_dapm_enable_pin(codec, "Ext Mic 1");
snd_soc_dapm_enable_pin(codec, "Ext Mic 3");
snd_soc_dapm_disable_pin(codec, "Headset Mic 2");
snd_soc_dapm_disable_pin(codec, "Headset Stereophone");
ret = snd_soc_dapm_sync(codec);
if (ret)
return ret;
/* Headset jack detection */
snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE
| SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
&hs_jack);
snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
hs_jack_pins);
snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE,
&mic_jack);
snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
mic_jack_pins);
/* headphone, microphone detection & headset short detection */
pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2);
pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE);
return 0;
}
static int __init tavorevb3_init(void)
{
int ret;
if (!machine_is_tavorevb3())
return -ENODEV;
evb3_snd_device = platform_device_alloc("soc-audio", -1);
if (!evb3_snd_device)
return -ENOMEM;
platform_set_drvdata(evb3_snd_device, &snd_soc_card_evb3);
ret = platform_device_add(evb3_snd_device);
if (ret)
platform_device_put(evb3_snd_device);
return ret;
}
static void __exit tavorevb3_exit(void)
{
platform_device_unregister(evb3_snd_device);
}
module_init(tavorevb3_init);
module_exit(tavorevb3_exit);
MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
MODULE_DESCRIPTION("ALSA SoC 88PM860x Tavor EVB3");
MODULE_LICENSE("GPL");
...@@ -189,7 +189,7 @@ static struct snd_soc_ops z2_ops = { ...@@ -189,7 +189,7 @@ static struct snd_soc_ops z2_ops = {
static struct snd_soc_dai_link z2_dai = { static struct snd_soc_dai_link z2_dai = {
.name = "wm8750", .name = "wm8750",
.stream_name = "WM8750", .stream_name = "WM8750",
.cpu_dai_name = "pxa-i2s", .cpu_dai_name = "pxa2xx-i2s",
.codec_dai_name = "wm8750-hifi", .codec_dai_name = "wm8750-hifi",
.platform_name = "pxa-pcm-audio", .platform_name = "pxa-pcm-audio",
.codec_name = "wm8750-codec.0-001a", .codec_name = "wm8750-codec.0-001a",
......
...@@ -2916,7 +2916,7 @@ int snd_soc_register_dais(struct device *dev, ...@@ -2916,7 +2916,7 @@ int snd_soc_register_dais(struct device *dev,
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
int i, ret = 0; int i, ret = 0;
dev_dbg(dev, "dai register %s #%d\n", dev_name(dev), count); dev_dbg(dev, "dai register %s #%Zu\n", dev_name(dev), count);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
...@@ -3122,10 +3122,12 @@ int snd_soc_register_codec(struct device *dev, ...@@ -3122,10 +3122,12 @@ int snd_soc_register_codec(struct device *dev,
fixup_codec_formats(&dai_drv[i].capture); fixup_codec_formats(&dai_drv[i].capture);
} }
/* register DAIs */ /* register any DAIs */
if (num_dai) {
ret = snd_soc_register_dais(dev, dai_drv, num_dai); ret = snd_soc_register_dais(dev, dai_drv, num_dai);
if (ret < 0) if (ret < 0)
goto error; goto error;
}
mutex_lock(&client_mutex); mutex_lock(&client_mutex);
list_add(&codec->list, &codec_list); list_add(&codec->list, &codec_list);
...@@ -3164,6 +3166,7 @@ void snd_soc_unregister_codec(struct device *dev) ...@@ -3164,6 +3166,7 @@ void snd_soc_unregister_codec(struct device *dev)
return; return;
found: found:
if (codec->num_dai)
for (i = 0; i < codec->num_dai; i++) for (i = 0; i < codec->num_dai; i++)
snd_soc_unregister_dai(dev); snd_soc_unregister_dai(dev);
......
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