[alsa-devel] [PATCH 1/2] ASoC: Add CS4271 codec support
From: Alexander Sverdlin subaparts@yandex.ru
Added support for Cirrus CS4271 codec to ALSA SoC subsystem.
Applies on: 2.6.36-rc6
Signed-off-by: Alexander Sverdlin subaparts@yandex.ru
---
sound/soc/codecs/Kconfig | 3 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cs4271.c | 840 +++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cs4271.h | 27 ++ 4 files changed, 872 insertions(+), 0 deletions(-)
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 83f5c67..608cf88 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -138,6 +138,9 @@ config SND_SOC_CS4270_VD33_ERRATA bool depends on SND_SOC_CS4270
+config SND_SOC_CS4271 + tristate + config SND_SOC_CX20442 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 5352409..d7dd676 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -11,6 +11,7 @@ snd-soc-ak4671-objs := ak4671.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs42l51-objs := cs42l51.o snd-soc-cs4270-objs := cs4270.o +snd-soc-cs4271-objs := cs4271.o snd-soc-cx20442-objs := cx20442.o snd-soc-da7210-objs := da7210.o snd-soc-l3-objs := l3.o @@ -79,6 +80,7 @@ obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CS42L51) += snd-soc-cs42l51.o obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o +obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c new file mode 100644 index 0000000..305281a --- /dev/null +++ b/sound/soc/codecs/cs4271.c @@ -0,0 +1,840 @@ +/* + * CS4271 ALSA SoC (ASoC) codec driver + * + * Copyright (c) 2010 Alexander Sverdlin subaparts@yandex.ru + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + * + * This is an ASoC device driver for the Cirrus Logic CS4271 codec. + * + * Current features/limitations: + * + * - I2C and SPI are supported + * - Software mode is supported. Stand-alone mode is not supported + * - Support for master and slave mode + * - The machine driver's 'startup' function must call + * cs4271_set_dai_sysclk() with the value of MCLK + * - Only I2S and left-justified modes are supported + */ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/slab.h> +#include <sound/core.h> +#include <sound/soc.h> +#include <sound/initval.h> +#include <linux/i2c.h> +#include <linux/spi/spi.h> + +#include "cs4271.h" + +#define CS4271_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ + SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S32_LE) + +/* + * CS4271 registers addresses + * High byte represents SPI address (0x10) + write command (0) + */ +#define CS4271_MODE1 0x2001 /* Mode Control 1 */ +#define CS4271_DACCTL 0x2002 /* DAC Control */ +#define CS4271_DACVOL 0x2003 /* DAC Volume & Mixing Control */ +#define CS4271_VOLA 0x2004 /* DAC Channel A Volume Control */ +#define CS4271_VOLB 0x2005 /* DAC Channel B Volume Control */ +#define CS4271_ADCCTL 0x2006 /* ADC Control */ +#define CS4271_MODE2 0x2007 /* Mode Control 2 */ +#define CS4271_CHIPID 0x2008 /* Chip ID */ + +#define CS4271_FIRSTREG CS4271_MODE1 +#define CS4271_LASTREG CS4271_MODE2 +#define CS4271_NR_REGS ((CS4271_LASTREG & 0xFF) + 1) + +/* Bit masks for the CS4271 registers */ +#define CS4271_MODE1_FUNCMODE_MASK 0xC0 +#define CS4271_MODE1_FUNCMODE_1X 0x00 +#define CS4271_MODE1_FUNCMODE_2X 0x80 +#define CS4271_MODE1_FUNCMODE_4X 0xC0 + +#define CS4271_MODE1_DIV_MASK 0x30 +#define CS4271_MODE1_DIV_1 0x00 +#define CS4271_MODE1_DIV_15 0x10 +#define CS4271_MODE1_DIV_2 0x20 +#define CS4271_MODE1_DIV_3 0x30 + +#define CS4271_MODE1_MASTER 0x08 + +#define CS4271_MODE1_DAC_DIF_MASK 0x07 +#define CS4271_MODE1_DAC_DIF_LJ 0x00 +#define CS4271_MODE1_DAC_DIF_I2S 0x01 +#define CS4271_MODE1_DAC_DIF_RJ16 0x02 +#define CS4271_MODE1_DAC_DIF_RJ24 0x03 +#define CS4271_MODE1_DAC_DIF_RJ20 0x04 +#define CS4271_MODE1_DAC_DIF_RJ18 0x05 + +#define CS4271_DACCTL_AMUTE 0x80 +#define CS4271_DACCTL_IF_SLOW 0x40 + +#define CS4271_DACCTL_DEM_MASK 0x30 +#define CS4271_DACCTL_DEM_DIS 0x00 +#define CS4271_DACCTL_DEM_441 0x10 +#define CS4271_DACCTL_DEM_48 0x20 +#define CS4271_DACCTL_DEM_32 0x30 + +#define CS4271_DACCTL_SVRU 0x08 +#define CS4271_DACCTL_SRD 0x04 +#define CS4271_DACCTL_INVA 0x02 +#define CS4271_DACCTL_INVB 0x01 + +#define CS4271_DACVOL_BEQUA 0x40 +#define CS4271_DACVOL_SOFT 0x20 +#define CS4271_DACVOL_ZEROC 0x10 + +#define CS4271_DACVOL_ATAPI_MASK 0x0F +#define CS4271_DACVOL_ATAPI_M_M 0x00 +#define CS4271_DACVOL_ATAPI_M_BR 0x01 +#define CS4271_DACVOL_ATAPI_M_BL 0x02 +#define CS4271_DACVOL_ATAPI_M_BLR2 0x03 +#define CS4271_DACVOL_ATAPI_AR_M 0x04 +#define CS4271_DACVOL_ATAPI_AR_BR 0x05 +#define CS4271_DACVOL_ATAPI_AR_BL 0x06 +#define CS4271_DACVOL_ATAPI_AR_BLR2 0x07 +#define CS4271_DACVOL_ATAPI_AL_M 0x08 +#define CS4271_DACVOL_ATAPI_AL_BR 0x09 +#define CS4271_DACVOL_ATAPI_AL_BL 0x0A +#define CS4271_DACVOL_ATAPI_AL_BLR2 0x0B +#define CS4271_DACVOL_ATAPI_ALR2_M 0x0C +#define CS4271_DACVOL_ATAPI_ALR2_BR 0x0D +#define CS4271_DACVOL_ATAPI_ALR2_BL 0x0E +#define CS4271_DACVOL_ATAPI_ALR2_BLR2 0x0F + +#define CS4271_VOLA_MUTE 0x80 +#define CS4271_VOLA_VOL_MASK 0x7F +#define CS4271_VOLB_MUTE 0x80 +#define CS4271_VOLB_VOL_MASK 0x7F + +#define CS4271_ADCCTL_DITHER16 0x20 + +#define CS4271_ADCCTL_ADC_DIF_MASK 0x10 +#define CS4271_ADCCTL_ADC_DIF_LJ 0x00 +#define CS4271_ADCCTL_ADC_DIF_I2S 0x10 + +#define CS4271_ADCCTL_MUTEA 0x08 +#define CS4271_ADCCTL_MUTEB 0x04 +#define CS4271_ADCCTL_HPFDA 0x02 +#define CS4271_ADCCTL_HPFDB 0x01 + +#define CS4271_MODE2_LOOP 0x10 +#define CS4271_MODE2_MUTECAEQUB 0x08 +#define CS4271_MODE2_FREEZE 0x04 +#define CS4271_MODE2_CPEN 0x02 +#define CS4271_MODE2_PDN 0x01 + +#define CS4271_CHIPID_PART_MASK 0xF0 +#define CS4271_CHIPID_REV_MASK 0x0F + +/* Private data for the CS4271 */ +struct cs4271_private { + struct snd_soc_codec codec; + u8 reg_cache[CS4271_NR_REGS]; + unsigned int mclk; /* Input frequency of the MCLK pin */ + unsigned int mode; /* The mode (I2S or left-justified) */ + unsigned int slave_mode; +}; + +/* + * struct cs4271_mode_ratios - clock ratio tables + * @ratio: the ratio of MCLK to the sample rate + * @speed_mode: the Speed Mode bits to set in the Mode Control register for + * this ratio + * @mclk_master: the Ratio Select bits to set in the Mode Control register + * for this ratio while in Master mode + * @mclk_slave: the Ratio Select bits to set in the Mode Control register + * for this ratio while in Slave mode + * + * This table is used to determine how to program the Mode Control register + * It is also used by cs4271_set_dai_sysclk() to tell ALSA which sampling + * rates the CS4271 currently supports. + */ +struct cs4271_mode_ratios { + unsigned int ratio; + u8 speed_mode; + u8 mclk_master; + u8 mclk_slave; +}; + +static struct cs4271_mode_ratios cs4271_mode_ratios[] = { + {64, CS4271_MODE1_FUNCMODE_4X, CS4271_MODE1_DIV_1, CS4271_MODE1_DIV_1}, + {96, CS4271_MODE1_FUNCMODE_4X, CS4271_MODE1_DIV_15, CS4271_MODE1_DIV_1}, + {128, CS4271_MODE1_FUNCMODE_2X, CS4271_MODE1_DIV_1, CS4271_MODE1_DIV_1}, + {192, CS4271_MODE1_FUNCMODE_2X, CS4271_MODE1_DIV_15, CS4271_MODE1_DIV_1}, + {256, CS4271_MODE1_FUNCMODE_1X, CS4271_MODE1_DIV_1, CS4271_MODE1_DIV_1}, + {384, CS4271_MODE1_FUNCMODE_1X, CS4271_MODE1_DIV_15, CS4271_MODE1_DIV_1}, + {512, CS4271_MODE1_FUNCMODE_1X, CS4271_MODE1_DIV_2, CS4271_MODE1_DIV_1}, + {768, CS4271_MODE1_FUNCMODE_1X, CS4271_MODE1_DIV_3, CS4271_MODE1_DIV_3}, + {1024, CS4271_MODE1_FUNCMODE_1X, CS4271_MODE1_DIV_3, CS4271_MODE1_DIV_3} +}; + +/* The number of MCLK/LRCK ratios supported by the CS4271 */ +#define NUM_MCLK_RATIOS ARRAY_SIZE(cs4271_mode_ratios) + +/* + * cs4271_set_dai_sysclk - determine the CS4271 MCLK rate. + * @codec_dai: the codec DAI + * @clk_id: the clock ID (ignored) + * @freq: the MCLK input frequency + * @dir: the clock direction (ignored) + * + * This function is used to tell the codec driver what the input MCLK + * frequency is. + * + * The value of MCLK is used to determine which sample rates are supported + * by the CS4271. The ratio of MCLK / Fs must be equal to one of + * supported values - 64, 96, 128, 192, 256, 384, 512, 768 and + * for Slave mode 1024. 256 is the best value and widely recommended. + * + * This function must be called by the machine driver's 'startup' function, + * otherwise the list of supported sample rates will not be available in + * time for ALSA. + * + * For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause + * theoretically possible sample rates to be enabled. Call it again with a + * proper value set one the external clock is set (most probably you would do + * that from a machine's driver 'hw_param' hook. + */ +static int cs4271_set_dai_sysclk(struct snd_soc_dai *codec_dai, + int clk_id, unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + unsigned int rates = 0; + unsigned int rate_min = -1; + unsigned int rate_max = 0; + unsigned int i; + + cs4271->mclk = freq; + + if (cs4271->mclk) { + for (i = 0; i < NUM_MCLK_RATIOS; i++) { + unsigned int rate = freq / cs4271_mode_ratios[i].ratio; + rates |= snd_pcm_rate_to_rate_bit(rate); + if (rate < rate_min) + rate_min = rate; + if (rate > rate_max) + rate_max = rate; + } + + rates &= ~SNDRV_PCM_RATE_KNOT; + + if (!rates) { + dev_err(codec->dev, "could not find a valid sample rate\n"); + return -EINVAL; + } + } else { + /* enable all possible rates */ + rates = SNDRV_PCM_RATE_8000_96000; + rate_min = 8000; + rate_max = 96000; + } + + codec_dai->playback.rates = rates; + codec_dai->playback.rate_min = rate_min; + codec_dai->playback.rate_max = rate_max; + + codec_dai->capture.rates = rates; + codec_dai->capture.rate_min = rate_min; + codec_dai->capture.rate_max = rate_max; + + return 0; +} + +/* + * cs4271_set_dai_fmt - configure the codec for the selected audio format + * @codec_dai: the codec DAI + * @format: a SND_SOC_DAIFMT_x value indicating the data format + * + * Currently, this function only supports SND_SOC_DAIFMT_I2S and + * SND_SOC_DAIFMT_LEFT_J. + */ +static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int format) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + int ret = 0; + + /* set DAI format */ + switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_LEFT_J: + cs4271->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; + break; + default: + dev_err(codec->dev, "invalid dai format\n"); + ret = -EINVAL; + } + + /* set master/slave audio interface */ + switch (format & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + cs4271->slave_mode = 1; + break; + case SND_SOC_DAIFMT_CBM_CFM: + cs4271->slave_mode = 0; + break; + default: + /* all other modes are unsupported by the hardware */ + ret = -EINVAL; + } + + return ret; +} + +/* + * cs4271_hw_params - program the CS4271 with the given hardware parameters. + * @substream: the audio stream + * @params: the hardware parameters to set + * @dai: the SOC DAI (ignored) + */ +static int cs4271_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_device *socdev = rtd->socdev; + struct snd_soc_codec *codec = socdev->card->codec; + struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + int ret; + unsigned int i, ratio; + + /* Figure out which MCLK/LRCK ratio to use */ + ratio = cs4271->mclk / params_rate(params); + + for (i = 0; i < NUM_MCLK_RATIOS; i++) + if (cs4271_mode_ratios[i].ratio == ratio) + break; + + if ((i == NUM_MCLK_RATIOS) || ((ratio == 1024) && (!cs4271->slave_mode))) { + dev_err(codec->dev, "could not find matching ratio\n"); + return -EINVAL; + } + + /* Set the sample rate */ + ret = snd_soc_read(codec, CS4271_MODE1); + ret &= ~(CS4271_MODE1_FUNCMODE_MASK | CS4271_MODE1_DIV_MASK | CS4271_MODE1_DAC_DIF_MASK); + ret |= cs4271_mode_ratios[i].speed_mode; + + if (cs4271->slave_mode) { + ret &= ~CS4271_MODE1_MASTER; + ret |= cs4271_mode_ratios[i].mclk_slave; + } + else { + ret |= CS4271_MODE1_MASTER; + ret |= cs4271_mode_ratios[i].mclk_master; + } + + switch (cs4271->mode) { + case SND_SOC_DAIFMT_I2S: + ret |= CS4271_MODE1_DAC_DIF_I2S; + break; + case SND_SOC_DAIFMT_LEFT_J: + ret |= CS4271_MODE1_DAC_DIF_LJ; + break; + default: + dev_err(codec->dev, "unknown dai format\n"); + return -EINVAL; + } + + ret = snd_soc_write(codec, CS4271_MODE1, ret); + if (ret < 0) { + dev_err(codec->dev, "Codec write failed\n"); + return ret; + } + + /* Set the DAI format */ + ret = snd_soc_read(codec, CS4271_ADCCTL); + ret &= ~CS4271_ADCCTL_ADC_DIF_MASK; + ret |= (cs4271->mode == SND_SOC_DAIFMT_I2S) ? CS4271_ADCCTL_ADC_DIF_I2S : CS4271_ADCCTL_ADC_DIF_LJ; + ret = snd_soc_write(codec, CS4271_ADCCTL, ret); + if (ret < 0) + dev_err(codec->dev, "Codec write failed\n"); + + return ret; +} + +/* + * cs4271_dai_mute - enable/disable the CS4271 external mute + * @dai: the SOC DAI + * @mute: 0 = disable mute, 1 = enable mute + */ +static int cs4271_dai_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + int ret1, ret2; + + ret1 = snd_soc_read(codec, CS4271_VOLA); + ret2 = snd_soc_read(codec, CS4271_VOLB); + + if (mute) { + ret1 |= CS4271_VOLA_MUTE; + ret2 |= CS4271_VOLB_MUTE; + } + else { + ret1 &= ~(CS4271_VOLA_MUTE); + ret2 &= ~(CS4271_VOLB_MUTE); + } + + ret1 = snd_soc_write(codec, CS4271_VOLA, ret1); + if (ret1) + return ret1; + return snd_soc_write(codec, CS4271_VOLB, ret2); +} + +/* + * A list of non-DAPM controls that the CS4271 supports + */ +static const char *cs4271_de_texts[] = {"None", "44.1KHz", "48KHz", "32KHz"}; +static const struct soc_enum cs4271_de_enum = + SOC_ENUM_SINGLE(CS4271_DACCTL, 4, 4, cs4271_de_texts); + +static const struct snd_kcontrol_new cs4271_snd_controls[] = { + SOC_DOUBLE_R("Master Playback Volume", CS4271_VOLA, CS4271_VOLB, 0, 0x7F, 1), + SOC_SINGLE("Digital Loopback Switch", CS4271_MODE2, 4, 1, 0), + SOC_SINGLE("Soft Ramp Switch", CS4271_DACVOL, 5, 1, 0), + SOC_SINGLE("Zero Cross Switch", CS4271_DACVOL, 4, 1, 0), + SOC_ENUM("De-emphasis filter", cs4271_de_enum), + SOC_SINGLE("Auto-Mute Switch", CS4271_DACCTL, 7, 1, 0), + SOC_SINGLE("Slow Roll Off Filter Switch", CS4271_DACCTL, 6, 1, 0), + SOC_SINGLE("Soft Volume Ramp-Up Switch", CS4271_DACCTL, 3, 1, 0), + SOC_SINGLE("Soft Ramp-Down Switch", CS4271_DACCTL, 2, 1, 0), + SOC_SINGLE("Left Channel Inversion Switch", CS4271_DACCTL, 1, 1, 0), + SOC_SINGLE("Right Channel Inversion Switch", CS4271_DACCTL, 0, 1, 0), + SOC_DOUBLE("Master Capture Switch", CS4271_ADCCTL, 3, 2, 1, 1), + SOC_SINGLE("Dither 16-Bit Data Switch", CS4271_ADCCTL, 5, 1, 0), + SOC_DOUBLE("High Pass Filter Switch", CS4271_ADCCTL, 1, 0, 1, 1), + SOC_DOUBLE_R("Master Playback Switch", CS4271_VOLA, CS4271_VOLB, 7, 1, 1), +}; + +/* + * cs4271_codec - global variable to store codec for the ASoC probe function + * + * For now, we also only allow cs4271_i2c_probe() to be run once. That means + * that we do not support more than one cs4271 device in the system, at least + * for now. + */ +static struct snd_soc_codec *cs4271_codec; + +static struct snd_soc_dai_ops cs4271_dai_ops = { + .hw_params = cs4271_hw_params, + .set_sysclk = cs4271_set_dai_sysclk, + .set_fmt = cs4271_set_dai_fmt, + .digital_mute = cs4271_dai_mute, +}; + +struct snd_soc_dai cs4271_dai = { + .name = "cs4271", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = 0, + .formats = CS4271_FORMATS, + }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 2, + .rates = 0, + .formats = CS4271_FORMATS, + }, + .ops = &cs4271_dai_ops, +}; +EXPORT_SYMBOL_GPL(cs4271_dai); + +/* + * This function writes all writeble registers from cache to codec. + * It's used te setup initial config and restore after suspend. + */ +static int cs4271_write_cache(struct snd_soc_codec *codec) +{ + int i, ret; + + for (i = CS4271_FIRSTREG; i <= CS4271_LASTREG; i++) { + ret = snd_soc_write(codec, i, snd_soc_read(codec, i)); + if (ret) + return ret; + } + + return 0; +} + +/* + * cs4271_probe - ASoC probe function + * @pdev: platform device + * + * This function is called when ASoC has all the pieces it needs to + * instantiate a sound driver. + * This function actually configure the codec, so MCLK must be enabled + * already and reset must be inactive. This is probably done by + * machine drivers. + */ +static int cs4271_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec = cs4271_codec; + int ret; + u8 *cache; + + /* Turn control port on and set power down mode for a while */ + ret = snd_soc_write(codec, CS4271_MODE2, CS4271_MODE2_CPEN | CS4271_MODE2_PDN); + if (ret < 0) { + dev_err(codec->dev, "Codec write failed\n"); + return ret; + } + + cache = codec->reg_cache; + /* + * Almost default power up configuration of codec, except auto + * mute feature which is turned off. + * We need to mask register address, because it contains + * SPI address also. + */ + cache[CS4271_MODE1 & 0xFF] = 0x00; + cache[CS4271_DACCTL & 0xFF] = 0x00; + cache[CS4271_DACVOL & 0xFF] = CS4271_DACVOL_ATAPI_AL_BR; + cache[CS4271_VOLA & 0xFF] = 0x00; + cache[CS4271_VOLB & 0xFF] = 0x00; + cache[CS4271_ADCCTL & 0xFF] = 0x00; + cache[CS4271_MODE2 & 0xFF] = CS4271_MODE2_CPEN; + + ret = cs4271_write_cache(codec); + if (ret < 0) { + dev_err(codec->dev, "Cache write failed\n"); + return ret; + } + + /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ + socdev->card->codec = codec; + + /* Register PCMs */ + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + dev_err(codec->dev, "failed to create pcms\n"); + return ret; + } + + /* Add the non-DAPM controls */ + ret = snd_soc_add_controls(codec, cs4271_snd_controls, + ARRAY_SIZE(cs4271_snd_controls)); + if (ret < 0) { + dev_err(codec->dev, "failed to add controls\n"); + goto error_free_pcms; + } + + return 0; + +error_free_pcms: + snd_soc_free_pcms(socdev); + + return ret; +} + +/* + * cs4271_remove - ASoC remove function + * @pdev: platform device + * + * This function is the counterpart to cs4271_probe(). + */ +static int cs4271_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + + snd_soc_free_pcms(socdev); + + return 0; +}; + +#ifdef CONFIG_PM + +/* + * The codec's own power saving features are enabled in the suspend callback, + * and all registers are written back to the hardware when resuming. + */ +static int cs4271_soc_suspend(struct platform_device *pdev, pm_message_t mesg) +{ + struct snd_soc_codec *codec = cs4271_codec; + struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = snd_soc_read(codec, CS4271_MODE2); + ret |= CS4271_MODE2_PDN; + + return snd_soc_write(codec, CS4271_MODE2, ret); +} + +static int cs4271_soc_resume(struct platform_device *pdev) +{ + struct snd_soc_codec *codec = cs4271_codec; + struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + int ret; + + ret = cs4271_write_cache(codec); + if (ret < 0) { + dev_err(pdev, "Cache write failed\n"); + return ret; + } + + /* ... then disable the power-down bits */ + ret = snd_soc_read(codec, CS4271_MODE2); + ret &= ~CS4271_MODE2_PDN; + + return snd_soc_write(codec, CS4271_MODE2, ret); +} +#else +#define cs4271_soc_suspend NULL +#define cs4271_soc_resume NULL +#endif /* CONFIG_PM */ + +/* + * ASoC codec device structure + * + * Assign this variable to the codec_dev field of the machine driver's + * snd_soc_device structure. + */ +struct snd_soc_codec_device soc_codec_device_cs4271 = { + .probe = cs4271_probe, + .remove = cs4271_remove, + .suspend = cs4271_soc_suspend, + .resume = cs4271_soc_resume, +}; +EXPORT_SYMBOL_GPL(soc_codec_device_cs4271); + +/* + * Serial bus independent probe function. It's called both for + * I2C and SPI -connected codecs. + */ +static int cs4271_bus_probe(struct device *dev, void *ctrl_data, int bus_type) +{ + struct cs4271_private *cs4271; + struct snd_soc_codec *codec; + int ret; + + /* + * For now, we only support one cs4271 device in the system. See the + * comment for cs4271_codec. + */ + if (cs4271_codec) { + dev_err(dev, "Only one CS4271 per board allowed\n"); + return -ENODEV; + } + + /* + * Allocate enough space for the snd_soc_codec structure + * and our private data together. + */ + cs4271 = kzalloc(sizeof(struct cs4271_private), GFP_KERNEL); + if (!cs4271) { + dev_err(dev, "Could not allocate codec\n"); + return -ENOMEM; + } + + dev_set_drvdata(dev, cs4271); + + codec = &cs4271->codec; + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->dev = dev; + codec->name = "CS4271"; + codec->owner = THIS_MODULE; + codec->dai = &cs4271_dai; + codec->num_dai = 1; + snd_soc_codec_set_drvdata(codec, cs4271); + codec->control_data = ctrl_data; + codec->reg_cache = cs4271->reg_cache; + codec->reg_cache_size = ARRAY_SIZE(cs4271->reg_cache); + + /* + * In case of I2C, chip address specified in board data. + * So cache IO operations use 8 bit codec register address. + * In case of SPI, chip address and register address + * passed together as 16 bit value. + * Anyway, register address is masked with 0xFF inside + * soc_cache code. + */ + ret = snd_soc_codec_set_cache_io(codec, + (bus_type == SND_SOC_SPI) ? 16 : 8, 8, bus_type); + if (ret) { + dev_err(dev, "Failed to set cache I/O: %d\n", ret); + goto error_free_codec; + } + + /* + * Initialize the DAI. Normally, we'd prefer to have a kmalloc'd DAI + * structure for each CS4271 device, but the machine driver needs to + * have a pointer to the DAI structure, so for now it must be a global + * variable. + */ + cs4271_dai.dev = dev; + + /* + * Register the DAI. If all the other ASoC driver have already + * registered, then this will call our probe function, so + * cs4271_codec needs to be ready. + */ + cs4271_codec = codec; + + ret = snd_soc_register_codec(codec); + if (ret) { + dev_err(dev, "Failed to register codec: %d\n", ret); + goto error_free_codec; + } + + ret = snd_soc_register_dai(&cs4271_dai); + if (ret) { + dev_err(dev, "failed to register DAI\n"); + goto error_reg; + } + + return 0; + +error_reg: + snd_soc_unregister_codec(codec); +error_free_codec: + kfree(cs4271); + cs4271_codec = NULL; + cs4271_dai.dev = NULL; + + return ret; +} + +static int cs4271_bus_remove(struct device *dev) +{ + struct cs4271_private *cs4271 = dev_get_drvdata(dev); + + snd_soc_unregister_dai(&cs4271_dai); + kfree(cs4271); + cs4271_codec = NULL; + cs4271_dai.dev = NULL; + + return 0; +} + + +#if defined(CONFIG_SPI_MASTER) + +static struct spi_device_id cs4271_spi_id[] = { + {"cs4271", 0}, + {} +}; +MODULE_DEVICE_TABLE(spi, cs4271_spi_id); + +static int __devinit cs4271_spi_probe(struct spi_device *spi) +{ + return cs4271_bus_probe(&spi->dev, spi, SND_SOC_SPI); +} + +static int __devexit cs4271_spi_remove(struct spi_device *spi) +{ + return cs4271_bus_remove(&spi->dev); +} + +static struct spi_driver cs4271_spi_driver = { + .driver = { + .name = "cs4271", + .owner = THIS_MODULE, + }, + .id_table = cs4271_spi_id, + .probe = cs4271_spi_probe, + .remove = __devexit_p(cs4271_spi_remove), +}; + +#endif + +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) +/* + * cs4271_id - I2C device IDs supported by this driver + */ +static struct i2c_device_id cs4271_i2c_id[] = { + {"cs4271", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, cs4271_i2c_id); + +static int __devinit cs4271_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + return cs4271_bus_probe(&client->dev, client, SND_SOC_I2C); +} + +static int __devexit cs4271_i2c_remove(struct i2c_client *client) +{ + return cs4271_bus_remove(&client->dev); +} + +/* + * cs4271_i2c_driver - I2C device identification + * + * This structure tells the I2C subsystem how to identify and support a + * given I2C device type. + */ +static struct i2c_driver cs4271_i2c_driver = { + .driver = { + .name = "cs4271", + .owner = THIS_MODULE, + }, + .id_table = cs4271_i2c_id, + .probe = cs4271_i2c_probe, + .remove = __devexit_p(cs4271_i2c_remove), +}; + +#endif + +/* + * We only register our serial bus driver here without + * assignment to particular chip. So if any of the below + * fails, there is some problem with I2C or SPI subsystem. + * In most cases this module will be compiled with support + * of only one serial bus. + */ +static int __init cs4271_modinit(void) +{ + int ret; + +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + ret = i2c_add_driver(&cs4271_i2c_driver); + if (ret) { + pr_err("Failed to register CS4271 I2C driver: %d\n", ret); + return ret; + } +#endif + +#if defined(CONFIG_SPI_MASTER) + ret = spi_register_driver(&cs4271_spi_driver); + if (ret) { + pr_err("Failed to register CS4271 SPI driver: %d\n", ret); + return ret; + } +#endif + + return 0; +} +module_init(cs4271_modinit); + +static void __exit cs4271_modexit(void) +{ +#if defined(CONFIG_SPI_MASTER) + spi_unregister_driver(&cs4271_spi_driver); +#endif + +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&cs4271_i2c_driver); +#endif +} +module_exit(cs4271_modexit); + +MODULE_AUTHOR("Alexander Sverdlin subaparts@yandex.ru"); +MODULE_DESCRIPTION("Cirrus Logic CS4271 ALSA SoC Codec Driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/cs4271.h b/sound/soc/codecs/cs4271.h new file mode 100644 index 0000000..7cf6af2 --- /dev/null +++ b/sound/soc/codecs/cs4271.h @@ -0,0 +1,27 @@ +/* + * Cirrus Logic CS4271 ALSA SoC Codec Driver + * + * Copyright (c) 2010 Alexander Sverdlin subaparts@yandex.ru + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +#ifndef _CS4271_H +#define _CS4271_H + +/* + * The ASoC codec DAI structure for the CS4271. Assign this structure to + * the .codec_dai field of your machine driver's snd_soc_dai_link structure. + */ +extern struct snd_soc_dai cs4271_dai; + +/* + * The ASoC codec device structure for the CS4271. Assign this structure + * to the .codec_dev field of your machine driver's snd_soc_device + * structure. + */ +extern struct snd_soc_codec_device soc_codec_device_cs4271; + +#endif
On Thu, Oct 07, 2010 at 01:39:01PM +1300, Ryan Mallon wrote:
From: Alexander Sverdlin subaparts@yandex.ru
Added support for Cirrus CS4271 codec to ALSA SoC subsystem.
Applies on: 2.6.36-rc6
Unfortunately there have been major changes in the ASoC APIs in -next for Liam's multi-component work so you'll need to update this before it can be applied. You should always submit code against -next (except for bug fixes to be sent to Linus).
See
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git
for current code.
I gave the driver a quick review and it looks really good - it just needs to be updated for current APIs.
+static const struct snd_kcontrol_new cs4271_snd_controls[] = {
- SOC_DOUBLE_R("Master Playback Volume", CS4271_VOLA, CS4271_VOLB, 0, 0x7F, 1),
TLV information would be nice but isn't essential.
- SOC_SINGLE("Digital Loopback Switch", CS4271_MODE2, 4, 1, 0),
This should probably be done as part of DAPM. Again probably not essential.
On 10/07/2010 01:49 PM, Mark Brown wrote:
On Thu, Oct 07, 2010 at 01:39:01PM +1300, Ryan Mallon wrote:
From: Alexander Sverdlin subaparts@yandex.ru
Added support for Cirrus CS4271 codec to ALSA SoC subsystem.
Applies on: 2.6.36-rc6
Ugh, I managed to miss Alexander from the CC list :-/. Alexander, can you please update the patch as detailed below.
~Ryan
Unfortunately there have been major changes in the ASoC APIs in -next for Liam's multi-component work so you'll need to update this before it can be applied. You should always submit code against -next (except for bug fixes to be sent to Linus).
See
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound-2.6.git
for current code.
I gave the driver a quick review and it looks really good - it just needs to be updated for current APIs.
+static const struct snd_kcontrol_new cs4271_snd_controls[] = {
- SOC_DOUBLE_R("Master Playback Volume", CS4271_VOLA, CS4271_VOLB, 0, 0x7F, 1),
TLV information would be nice but isn't essential.
- SOC_SINGLE("Digital Loopback Switch", CS4271_MODE2, 4, 1, 0),
This should probably be done as part of DAPM. Again probably not essential.
On Thu, Oct 07, 2010 at 01:39:01PM +1300, Ryan Mallon wrote:
--- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -138,6 +138,9 @@ config SND_SOC_CS4270_VD33_ERRATA bool depends on SND_SOC_CS4270
+config SND_SOC_CS4271
- tristate
config SND_SOC_CX20442 tristate
Oh, one actual problem: you should add the driver to SND_SOC_ALL_CODECS too so we get build coverage for testing.
From: Alexander Sverdlin subaparts@yandex.ru
Added support for EDB93xx sound with CS4271 codec. Features: Playback, Capture Sample rates from 8kHz to 96kHz tested Limitations: Depends on ALSA auto sample format conversion No DAPM support
Applies on: 2.6.36-rc6
Signed-off-by: Alexander Sverdlin subaparts@yandex.ru
---
arch/arm/mach-ep93xx/edb93xx.c | 46 +++++++++ sound/soc/ep93xx/Kconfig | 9 ++ sound/soc/ep93xx/Makefile | 5 + sound/soc/ep93xx/edb93xx.c | 205 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 265 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c index c2ce903..1b24203 100644 --- a/arch/arm/mach-ep93xx/edb93xx.c +++ b/arch/arm/mach-ep93xx/edb93xx.c @@ -30,12 +30,19 @@ #include <linux/gpio.h> #include <linux/i2c.h> #include <linux/i2c-gpio.h> +#include <linux/spi/spi.h> +#include <mach/ep93xx_spi.h>
#include <mach/hardware.h>
#include <asm/mach-types.h> #include <asm/mach/arch.h>
+#define edb93xx_has_audio() (machine_is_edb9301() || \ + machine_is_edb9302() || \ + machine_is_edb9302a() || \ + machine_is_edb9307a() || \ + machine_is_edb9315a())
static void __init edb93xx_register_flash(void) { @@ -93,6 +100,43 @@ static void __init edb93xx_register_i2c(void)
/************************************************************************* + * EDB93xx SPI peripheral handling + *************************************************************************/ +static struct spi_board_info edb93xx_spi_board_info[] = { + { + .modalias = "cs4271", + .max_speed_hz = 6000000, + .bus_num = 0, + .chip_select = 0, + .mode = SPI_MODE_3, + }, +}; + +static struct ep93xx_spi_info edb93xx_spi_info = { + .num_chipselect = ARRAY_SIZE(edb93xx_spi_board_info), +}; + +static void __init edb93xx_register_spi(void) +{ + if (edb93xx_has_audio()) { + ep93xx_register_spi(&edb93xx_spi_info, + edb93xx_spi_board_info, + ARRAY_SIZE(edb93xx_spi_board_info)); + } +} + +/************************************************************************* + * EDB93xx I2S + *************************************************************************/ +static void __init edb93xx_register_i2s(void) +{ + if (edb93xx_has_audio()) { + ep93xx_register_i2s(); + } +} + + +/************************************************************************* * EDB93xx pwm *************************************************************************/ static void __init edb93xx_register_pwm(void) @@ -117,6 +161,8 @@ static void __init edb93xx_init_machine(void) edb93xx_register_flash(); ep93xx_register_eth(&edb93xx_eth_data, 1); edb93xx_register_i2c(); + edb93xx_register_spi(); + edb93xx_register_i2s(); edb93xx_register_pwm(); }
diff --git a/sound/soc/ep93xx/Kconfig b/sound/soc/ep93xx/Kconfig index f617f56..22cb673 100644 --- a/sound/soc/ep93xx/Kconfig +++ b/sound/soc/ep93xx/Kconfig @@ -16,3 +16,12 @@ config SND_EP93XX_SOC_SNAPPERCL15 help Say Y or M here if you want to add support for I2S audio on the Bluewater Systems Snapper CL15 module. + +config SND_EP93XX_SOC_EDB93XX + tristate "SoC Audio support for Cirrus Logic EDB93xx boards" + depends on SND_EP93XX_SOC && (MACH_EDB9301 || MACH_EDB9302 || MACH_EDB9302A || MACH_EDB9307A || MACH_EDB9315A) + select SND_EP93XX_SOC_I2S + select SND_SOC_CS4271 + help + Say Y or M here if you want to add support for I2S audio on the + Cirrus Logic EDB93xx boards. diff --git a/sound/soc/ep93xx/Makefile b/sound/soc/ep93xx/Makefile index 272e60f..4f62ad8 100644 --- a/sound/soc/ep93xx/Makefile +++ b/sound/soc/ep93xx/Makefile @@ -9,3 +9,8 @@ obj-$(CONFIG_SND_EP93XX_SOC_I2S) += snd-soc-ep93xx-i2s.o snd-soc-snappercl15-objs := snappercl15.o
obj-$(CONFIG_SND_EP93XX_SOC_SNAPPERCL15) += snd-soc-snappercl15.o + +# EDB93XX Machine Support +snd-soc-edb93xx-objs := edb93xx.o + +obj-$(CONFIG_SND_EP93XX_SOC_EDB93XX) += snd-soc-edb93xx.o diff --git a/sound/soc/ep93xx/edb93xx.c b/sound/soc/ep93xx/edb93xx.c new file mode 100644 index 0000000..dfb78d2 --- /dev/null +++ b/sound/soc/ep93xx/edb93xx.c @@ -0,0 +1,205 @@ +/* + * edb93xx.c -- SoC audio for EDB93xx + * + * Copyright (c) 2010 Alexander Sverdlin subaparts@yandex.ru + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + */ + +#include <linux/platform_device.h> +#include <linux/delay.h> +#include <linux/gpio.h> +#include <sound/core.h> +#include <sound/pcm.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> + +#include <asm/mach-types.h> +#include <mach/hardware.h> + +#include "../codecs/cs4271.h" +#include "ep93xx-pcm.h" +#include "ep93xx-i2s.h" + +#define edb93xx_has_audio() (machine_is_edb9301() || \ + machine_is_edb9302() || \ + machine_is_edb9302a() || \ + machine_is_edb9307a() || \ + machine_is_edb9315a()) + +static int edb93xx_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->dai->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; + int err; + unsigned int rate = params_rate(params); + /* + * We set LRCLK equal to `rate' and SCLK = LRCLK * 64, + * because our sample size is 32 bit * 2 channels. + * I2S standard permits us to transmit more bits than + * the codec uses. + * MCLK = SCLK * 4 is the best recommended value, + * but we have to fall back to ratio 2 for higher + * sample rates. + */ + unsigned int mclk_rate = rate * 64 * ((rate <= 48000) ? 4 : 2); + + err = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_IF | + SND_SOC_DAIFMT_CBS_CFS); + if (err) + return err; + + err = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_IF | + SND_SOC_DAIFMT_CBS_CFS); + if (err) + return err; + + err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk_rate, + SND_SOC_CLOCK_IN); + if (err) + return err; + + return snd_soc_dai_set_sysclk(cpu_dai, 0, mclk_rate, + SND_SOC_CLOCK_OUT); +} + +/* + * This function enables all possible sample rates before and + * after actual playback, cause we use variable MCLK. + */ +static int edb93xx_startup_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; + + return snd_soc_dai_set_sysclk(codec_dai, 0, 0, SND_SOC_CLOCK_IN); +} + +void edb93xx_shutdown(struct snd_pcm_substream *substream) +{ + edb93xx_startup_shutdown(substream); +} + +static struct snd_soc_ops edb93xx_ops = { + .hw_params = edb93xx_hw_params, + .startup = edb93xx_startup_shutdown, + .shutdown = edb93xx_shutdown, +}; + +static struct snd_soc_dai_link edb93xx_dai = { + .name = "CS4271", + .stream_name = "CS4271", + .cpu_dai = &ep93xx_i2s_dai, + .codec_dai = &cs4271_dai, + .ops = &edb93xx_ops, +}; + +static struct snd_soc_card snd_soc_edb93xx = { + .name = "EDB93XX", + .platform = &ep93xx_soc_platform, + .dai_link = &edb93xx_dai, + .num_links = 1, +}; + +static struct snd_soc_device edb93xx_snd_devdata = { + .card = &snd_soc_edb93xx, + .codec_dev = &soc_codec_device_cs4271, +}; + +static struct platform_device *edb93xx_snd_device; + +static int __init edb93xx_enable_cs4271(void) +{ + int ret; + if (!edb93xx_has_audio()) + return -ENODEV; + + ret = gpio_request(EP93XX_GPIO_LINE_EGPIO6, "CS4271 SFRM1 Disable"); + if (ret) + return ret; + ret = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO6, 0); + if (ret) + goto free_EGPIO6; + + ret = gpio_request(EP93XX_GPIO_LINE_EGPIO1, "CS4271 Reset"); + if (ret) + goto free_EGPIO6; + ret = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO1, 1); + if (ret) + goto free_EGPIO1; + + /* Give the codec time to wake up */ + udelay(1); + return 0; + +free_EGPIO1: + gpio_free(EP93XX_GPIO_LINE_EGPIO1); +free_EGPIO6: + gpio_free(EP93XX_GPIO_LINE_EGPIO6); + return ret; +} + +static void __exit edb93xx_disable_cs4271(void) +{ + /* Set codec to the reset state */ + gpio_set_value(EP93XX_GPIO_LINE_EGPIO1, 0); + gpio_free(EP93XX_GPIO_LINE_EGPIO1); + gpio_free(EP93XX_GPIO_LINE_EGPIO6); +} + +static int __init edb93xx_init(void) +{ + int ret; + + ret = ep93xx_i2s_acquire(EP93XX_SYSCON_DEVCFG_I2SONAC97, + EP93XX_SYSCON_I2SCLKDIV_ORIDE | + EP93XX_SYSCON_I2SCLKDIV_SPOL); + if (ret) + return ret; + + ret = edb93xx_enable_cs4271(); + if (ret) + goto free_i2s; + + ret = -ENOMEM; + edb93xx_snd_device = platform_device_alloc("soc-audio", -1); + if (!edb93xx_snd_device) + goto free_i2s; + + platform_set_drvdata(edb93xx_snd_device, &edb93xx_snd_devdata); + edb93xx_snd_devdata.dev = &edb93xx_snd_device->dev; + ret = platform_device_add(edb93xx_snd_device); + if (ret) + goto device_put; + + pr_info("EDB93xx Machine ALSA Driver\n"); + return 0; + +device_put: + platform_device_put(edb93xx_snd_device); +free_i2s: + ep93xx_i2s_release(); + return ret; +} + +static void __exit edb93xx_exit(void) +{ + platform_device_unregister(edb93xx_snd_device); + edb93xx_disable_cs4271(); + ep93xx_i2s_release(); +} + +module_init(edb93xx_init); +module_exit(edb93xx_exit); + +MODULE_AUTHOR("Alexander Sverdlin subaparts@yandex.ru"); +MODULE_DESCRIPTION("ALSA SoC EDB93xx"); +MODULE_LICENSE("GPL");
On Thu, Oct 07, 2010 at 01:50:26PM +1300, Ryan Mallon wrote:
- ret = gpio_request(EP93XX_GPIO_LINE_EGPIO6, "CS4271 SFRM1 Disable");
- if (ret)
return ret;
- ret = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO6, 0);
- if (ret)
goto free_EGPIO6;
- ret = gpio_request(EP93XX_GPIO_LINE_EGPIO1, "CS4271 Reset");
- if (ret)
goto free_EGPIO6;
- ret = gpio_direction_output(EP93XX_GPIO_LINE_EGPIO1, 1);
- if (ret)
goto free_EGPIO1;
It'd seem to make sense for these to be handled by the CODEC driver, using platform data to supply the GPIOs so that their management can be integrated with the CODEC flow?
Otherwise this looks good.
Ryan Mallon wrote:
- For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause
- theoretically possible sample rates to be enabled. Call it again with a
- proper value set one the external clock is set (most probably you would do
- that from a machine's driver 'hw_param' hook.
If you're going to copy/paste parts of my driver verbatim into yours, you should put something like this in the comments:
Based on the CS4270 driver by Timur Tabi timur@freescale.com
On 10/08/2010 10:46 AM, Timur Tabi wrote:
Ryan Mallon wrote:
- For setups with variable MCLKs, pass 0 as 'freq' argument. This will cause
- theoretically possible sample rates to be enabled. Call it again with a
- proper value set one the external clock is set (most probably you would do
- that from a machine's driver 'hw_param' hook.
If you're going to copy/paste parts of my driver verbatim into yours, you should put something like this in the comments:
Based on the CS4270 driver by Timur Tabi timur@freescale.com
Thanks. CC'ed Alexander, the driver author, who I stupidly left of the reply list.
~Ryan
participants (3)
-
Mark Brown
-
Ryan Mallon
-
Timur Tabi