diff options
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/sgtl5000.c | 71 | ||||
-rw-r--r-- | sound/soc/codecs/sgtl5000.h | 9 | ||||
-rw-r--r-- | sound/soc/fsl/Kconfig | 5 | ||||
-rw-r--r-- | sound/soc/fsl/Makefile | 3 | ||||
-rw-r--r-- | sound/soc/fsl/fsl_spdif.c | 4 | ||||
-rw-r--r-- | sound/soc/fsl/imx-sgtl5000.c | 47 |
6 files changed, 102 insertions, 37 deletions
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 39810b713d5f..f99dd0673f57 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -35,8 +35,15 @@ #define SGTL5000_DAP_REG_OFFSET 0x0100 #define SGTL5000_MAX_REG_OFFSET 0x013A +/* + * The Manual recommends a VAG ramp delay 200-400 ms. + * For Toradex SoM Apalis TK1 v1.2A the optimal up/down delay is 500 ms. + * For Toradex SoM Apalis iMX6D/Q v1.1B the optimal delay + * is 600 ms for ramp up and 500 ms ramp down. + */ + /* Delay for the VAG ramp up */ -#define SGTL5000_VAG_POWERUP_DELAY 500 /* ms */ +#define SGTL5000_VAG_POWERUP_DELAY 600 /* ms */ /* Delay for the VAG ramp down */ #define SGTL5000_VAG_POWERDOWN_DELAY 500 /* ms */ @@ -106,6 +113,13 @@ enum sgtl5000_micbias_resistor { SGTL5000_MICBIAS_8K = 8, }; +enum { + I2S_LRCLK_STRENGTH_DISABLE, + I2S_LRCLK_STRENGTH_LOW, + I2S_LRCLK_STRENGTH_MEDIUM, + I2S_LRCLK_STRENGTH_HIGH, +}; + enum { HP_POWER_EVENT, DAC_POWER_EVENT, @@ -125,6 +139,7 @@ struct sgtl5000_priv { int revision; u8 micbias_resistor; u8 micbias_voltage; + u8 lrclk_strength; u16 mute_state[LAST_POWER_EVENT + 1]; }; @@ -572,32 +587,42 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = { .put = dac_put_volsw, }, + /* ADC Capture */ SOC_DOUBLE("Capture Volume", SGTL5000_CHIP_ANA_ADC_CTRL, 0, 4, 0xf, 0), SOC_SINGLE_TLV("Capture Attenuate Switch (-6dB)", - SGTL5000_CHIP_ANA_ADC_CTRL, - 8, 1, 0, capture_6db_attenuate), - SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, 1, 1, 0), + SGTL5000_CHIP_ANA_ADC_CTRL, + SGTL5000_ADC_VOL_M6DB, 1, 0, capture_6db_attenuate), + SOC_SINGLE("Capture ZC Switch", SGTL5000_CHIP_ANA_CTRL, + SGTL5000_ADC_ZCD_EN, 1, 0), + SOC_SINGLE("Capture Switch", SGTL5000_CHIP_ANA_CTRL, + SGTL5000_ADC_MUTE_SHIFT, 1, 1), + + /* Headphone */ SOC_DOUBLE_TLV("Headphone Playback Volume", - SGTL5000_CHIP_ANA_HP_CTRL, - 0, 8, - 0x7f, 1, - headphone_volume), + SGTL5000_CHIP_ANA_HP_CTRL, + SGTL5000_HP_VOL_LEFT_SHIFT, + SGTL5000_HP_VOL_RIGHT_SHIFT, + 0x7f, 1, + headphone_volume), SOC_SINGLE("Headphone Playback Switch", SGTL5000_CHIP_ANA_CTRL, - 4, 1, 1), + SGTL5000_HP_MUTE_SHIFT, 1, 1), SOC_SINGLE("Headphone Playback ZC Switch", SGTL5000_CHIP_ANA_CTRL, - 5, 1, 0), + SGTL5000_HP_ZCD_EN, 1, 0), + /* Microphone */ SOC_SINGLE_TLV("Mic Volume", SGTL5000_CHIP_MIC_CTRL, - 0, 3, 0, mic_gain_tlv), + SGTL5000_MIC_GAIN_SHIFT, 3, 0, mic_gain_tlv), + /* Lineout */ SOC_DOUBLE_TLV("Lineout Playback Volume", SGTL5000_CHIP_LINE_OUT_VOL, SGTL5000_LINE_OUT_VOL_LEFT_SHIFT, SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT, 0x1f, 1, lineout_volume), - SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, 8, 1, 1), + SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, + SGTL5000_LINE_MUTE_SHIFT, 1, 1), }; /* mute the codec used by alsa core */ @@ -1277,7 +1302,9 @@ static int sgtl5000_enable_regulators(struct i2c_client *client) static int sgtl5000_probe(struct snd_soc_codec *codec) { int ret; + u16 reg; struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + unsigned int zcd_mask = SGTL5000_HP_ZCD_EN | SGTL5000_ADC_ZCD_EN; /* power up sgtl5000 */ ret = sgtl5000_set_power_regs(codec); @@ -1286,7 +1313,7 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) /* enable small pop, introduce 400ms delay in turning off */ snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, - SGTL5000_SMALL_POP, 1); + SGTL5000_SMALL_POP, SGTL5000_SMALL_POP); /* disable short cut detector */ snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0); @@ -1306,11 +1333,11 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) SGTL5000_DAC_MUTE_RIGHT | SGTL5000_DAC_MUTE_LEFT); - snd_soc_write(codec, SGTL5000_CHIP_PAD_STRENGTH, 0x015f); + reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | 0x5f); + snd_soc_write(codec, SGTL5000_CHIP_PAD_STRENGTH, reg); - snd_soc_write(codec, SGTL5000_CHIP_ANA_CTRL, - SGTL5000_HP_ZCD_EN | - SGTL5000_ADC_ZCD_EN); + snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_CTRL, + zcd_mask, zcd_mask); snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, @@ -1341,6 +1368,9 @@ static struct snd_soc_codec_driver sgtl5000_driver = { .probe = sgtl5000_probe, .remove = sgtl5000_remove, .set_bias_level = sgtl5000_set_bias_level, + .reg_cache_size = SGTL5000_MAX_REG_OFFSET, + .reg_word_size = sizeof(u16), + .reg_cache_step = 2, .suspend_bias_off = true, .component_driver = { .controls = sgtl5000_snd_controls, @@ -1535,6 +1565,13 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, } } + sgtl5000->lrclk_strength = I2S_LRCLK_STRENGTH_LOW; + if (!of_property_read_u32(np, "lrclk-strength", &value)) { + if (value > I2S_LRCLK_STRENGTH_HIGH) + value = I2S_LRCLK_STRENGTH_LOW; + sgtl5000->lrclk_strength = value; + } + /* Ensure sgtl5000 will start with sane register values */ sgtl5000_fill_defaults(client); diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 22f3442af982..75cc78670e04 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -237,6 +237,7 @@ * SGTL5000_CHIP_ANA_CTRL */ #define SGTL5000_LINE_OUT_MUTE 0x0100 +#define SGTL5000_LINE_MUTE_SHIFT 8 #define SGTL5000_HP_SEL_MASK 0x0040 #define SGTL5000_HP_SEL_SHIFT 6 #define SGTL5000_HP_SEL_WIDTH 1 @@ -244,6 +245,7 @@ #define SGTL5000_HP_SEL_LINE_IN 0x1 #define SGTL5000_HP_ZCD_EN 0x0020 #define SGTL5000_HP_MUTE 0x0010 +#define SGTL5000_HP_MUTE_SHIFT 4 #define SGTL5000_ADC_SEL_MASK 0x0004 #define SGTL5000_ADC_SEL_SHIFT 2 #define SGTL5000_ADC_SEL_WIDTH 1 @@ -251,6 +253,7 @@ #define SGTL5000_ADC_SEL_LINE_IN 0x1 #define SGTL5000_ADC_ZCD_EN 0x0002 #define SGTL5000_ADC_MUTE 0x0001 +#define SGTL5000_ADC_MUTE_SHIFT 0 /* * SGTL5000_CHIP_LINREG_CTRL @@ -276,7 +279,7 @@ #define SGTL5000_BIAS_CTRL_MASK 0x000e #define SGTL5000_BIAS_CTRL_SHIFT 1 #define SGTL5000_BIAS_CTRL_WIDTH 3 -#define SGTL5000_SMALL_POP 1 +#define SGTL5000_SMALL_POP 0x0001 /* * SGTL5000_CHIP_MIC_CTRL @@ -338,10 +341,14 @@ #define SGTL5000_ADC_STEREO 0x0040 #define SGTL5000_REFTOP_POWERUP 0x0020 #define SGTL5000_HP_POWERUP 0x0010 +#define SGTL5000_HP_POWERUP_SHIFT 4 #define SGTL5000_DAC_POWERUP 0x0008 +#define SGTL5000_DAC_POWERUP_SHIFT 3 #define SGTL5000_CAPLESS_HP_POWERUP 0x0004 #define SGTL5000_ADC_POWERUP 0x0002 +#define SGTL5000_ADC_POWERUP_SHIFT 1 #define SGTL5000_LINE_OUT_POWERUP 0x0001 +#define SGTL5000_LINE_OUT_POWERUP_SHIFT 0 /* * SGTL5000_CHIP_PLL_CTRL diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 0fcf4065d0e4..4c49e5e42828 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -55,6 +55,7 @@ config SND_SOC_FSL_SSI config SND_SOC_FSL_SPDIF tristate "Sony/Philips Digital Interface (S/PDIF) module support" select REGMAP_MMIO + select SND_SOC_FSL_DMA_WORKAROUND select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && (MXC_TZIC || MXC_AVIC) help @@ -66,6 +67,7 @@ config SND_SOC_FSL_SPDIF config SND_SOC_FSL_ESAI tristate "Enhanced Serial Audio Interface (ESAI) module support" select REGMAP_MMIO + select SND_SOC_FSL_DMA_WORKAROUND select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n help Say Y if you want to add Enhanced Synchronous Audio Interface @@ -99,6 +101,9 @@ config SND_SOC_FSL_DSP This option is only useful for out-of-tree drivers since in-tree drivers select it automatically. +config SND_SOC_FSL_DMA_WORKAROUND + tristate + config SND_SOC_FSL_UTILS tristate diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index 3e41fd9abfbd..ed0fe428464f 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -20,7 +20,7 @@ snd-soc-fsl-sai-objs := fsl_sai.o snd-soc-fsl-ssi-y := fsl_ssi.o snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o snd-soc-fsl-spdif-objs := fsl_spdif.o -snd-soc-fsl-esai-objs := fsl_esai.o fsl_dma_workaround.o +snd-soc-fsl-esai-objs := fsl_esai.o snd-soc-fsl-utils-objs := fsl_utils.o snd-soc-fsl-dma-objs := fsl_dma.o snd-soc-fsl-rpmsg-i2s-objs := fsl_rpmsg_i2s.o @@ -31,6 +31,7 @@ snd-soc-fsl-micfil-objs := fsl_micfil.o obj-$(CONFIG_SND_SOC_FSL_ACM) += snd-soc-fsl-acm.o obj-$(CONFIG_SND_SOC_FSL_AMIX) += snd-soc-fsl-amix.o obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o +obj-$(CONFIG_SND_SOC_FSL_DMA_WORKAROUND) += snd-soc-fsl-dma-workaround.o obj-$(CONFIG_SND_SOC_FSL_DSP) += snd-soc-fsl-dsp.o obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index a7a3639e50b2..5149912ae22f 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -548,10 +548,10 @@ static int fsl_spdif_startup(struct snd_pcm_substream *substream, if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { scr = SCR_TXFIFO_AUTOSYNC | SCR_TXFIFO_CTRL_NORMAL | SCR_TXSEL_NORMAL | SCR_USRC_SEL_CHIP | - SCR_TXFIFO_FSEL_IF8; + SCR_TXFIFO_FSEL_IF8 | SCR_VAL_CLEAR; mask = SCR_TXFIFO_AUTOSYNC_MASK | SCR_TXFIFO_CTRL_MASK | SCR_TXSEL_MASK | SCR_USRC_SEL_MASK | - SCR_TXFIFO_FSEL_MASK; + SCR_TXFIFO_FSEL_MASK | SCR_VAL_MASK; } else { scr = SCR_RXFIFO_FSEL_IF8 | SCR_RXFIFO_AUTOSYNC; mask = SCR_RXFIFO_FSEL_MASK | SCR_RXFIFO_AUTOSYNC_MASK| diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index 3d99a8579c99..ab5c62f2d240 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012, 2014 Freescale Semiconductor, Inc. * Copyright 2012 Linaro Ltd. * * The code contained herein is licensed under the GNU General Public @@ -55,13 +55,9 @@ static const struct snd_soc_dapm_widget imx_sgtl5000_dapm_widgets[] = { SND_SOC_DAPM_SPK("Ext Spk", NULL), }; -static int imx_sgtl5000_probe(struct platform_device *pdev) +static int imx_sgtl5000_audmux_config(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; - struct device_node *ssi_np, *codec_np; - struct platform_device *ssi_pdev; - struct i2c_client *codec_dev; - struct imx_sgtl5000_data *data = NULL; int int_port, ext_port; int ret; @@ -101,21 +97,38 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) return ret; } - ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0); + return 0; +} + +static int imx_sgtl5000_probe(struct platform_device *pdev) +{ + struct device_node *cpu_np, *codec_np; + struct platform_device *cpu_pdev; + struct i2c_client *codec_dev; + struct imx_sgtl5000_data *data = NULL; + int ret; + + cpu_np = of_parse_phandle(pdev->dev.of_node, "cpu-dai", 0); codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); - if (!ssi_np || !codec_np) { + if (!cpu_np || !codec_np) { dev_err(&pdev->dev, "phandle missing or invalid\n"); ret = -EINVAL; goto fail; } - ssi_pdev = of_find_device_by_node(ssi_np); - if (!ssi_pdev) { + if (strstr(cpu_np->name, "ssi")) { + ret = imx_sgtl5000_audmux_config(pdev); + if (ret) + goto fail; + } + + cpu_pdev = of_find_device_by_node(cpu_np); + if (!cpu_pdev) { dev_err(&pdev->dev, "failed to find SSI platform device\n"); ret = -EPROBE_DEFER; goto fail; } - put_device(&ssi_pdev->dev); + put_device(&cpu_pdev->dev); codec_dev = of_find_i2c_device_by_node(codec_np); if (!codec_dev) { dev_err(&pdev->dev, "failed to find codec platform device\n"); @@ -141,8 +154,8 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) data->dai.stream_name = "HiFi"; data->dai.codec_dai_name = "sgtl5000"; data->dai.codec_of_node = codec_np; - data->dai.cpu_of_node = ssi_np; - data->dai.platform_of_node = ssi_np; + data->dai.cpu_of_node = cpu_np; + data->dai.platform_of_node = cpu_np; data->dai.init = &imx_sgtl5000_dai_init; data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM; @@ -169,7 +182,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) goto fail; } - of_node_put(ssi_np); + of_node_put(cpu_np); of_node_put(codec_np); return 0; @@ -177,8 +190,10 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) fail: if (data && !IS_ERR(data->codec_clk)) clk_put(data->codec_clk); - of_node_put(ssi_np); - of_node_put(codec_np); + if (cpu_np) + of_node_put(cpu_np); + if (codec_np) + of_node_put(codec_np); return ret; } |