Merge remote-tracking branches 'asoc/topic/cs42l56', 'asoc/topic/cs42l73', 'asoc/topic/cs4349' and 'asoc/topic/da732x' into asoc-next

This commit is contained in:
Mark Brown 2015-08-30 15:53:22 +01:00
8 changed files with 563 additions and 151 deletions

View File

@ -0,0 +1,19 @@
CS4349 audio CODEC
Required properties:
- compatible : "cirrus,cs4349"
- reg : the I2C address of the device for I2C
Optional properties:
- reset-gpios : a GPIO spec for the reset pin.
Example:
codec: cs4349@48 {
compatible = "cirrus,cs4349";
reg = <0x48>;
reset-gpios = <&gpio 54 0>;
};

View File

@ -53,6 +53,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_CS4271_I2C if I2C select SND_SOC_CS4271_I2C if I2C
select SND_SOC_CS4271_SPI if SPI_MASTER select SND_SOC_CS4271_SPI if SPI_MASTER
select SND_SOC_CS42XX8_I2C if I2C select SND_SOC_CS42XX8_I2C if I2C
select SND_SOC_CS4349 if I2C
select SND_SOC_CX20442 if TTY select SND_SOC_CX20442 if TTY
select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI select SND_SOC_DA7210 if SND_SOC_I2C_AND_SPI
select SND_SOC_DA7213 if I2C select SND_SOC_DA7213 if I2C
@ -404,6 +405,11 @@ config SND_SOC_CS42XX8_I2C
select SND_SOC_CS42XX8 select SND_SOC_CS42XX8
select REGMAP_I2C select REGMAP_I2C
# Cirrus Logic CS4349 HiFi DAC
config SND_SOC_CS4349
tristate "Cirrus Logic CS4349 CODEC"
depends on I2C
config SND_SOC_CX20442 config SND_SOC_CX20442
tristate tristate
depends on TTY depends on TTY

View File

@ -45,6 +45,7 @@ snd-soc-cs4271-i2c-objs := cs4271-i2c.o
snd-soc-cs4271-spi-objs := cs4271-spi.o snd-soc-cs4271-spi-objs := cs4271-spi.o
snd-soc-cs42xx8-objs := cs42xx8.o snd-soc-cs42xx8-objs := cs42xx8.o
snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o snd-soc-cs42xx8-i2c-objs := cs42xx8-i2c.o
snd-soc-cs4349-objs := cs4349.o
snd-soc-cx20442-objs := cx20442.o snd-soc-cx20442-objs := cx20442.o
snd-soc-da7210-objs := da7210.o snd-soc-da7210-objs := da7210.o
snd-soc-da7213-objs := da7213.o snd-soc-da7213-objs := da7213.o
@ -233,6 +234,7 @@ obj-$(CONFIG_SND_SOC_CS4271_I2C) += snd-soc-cs4271-i2c.o
obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o obj-$(CONFIG_SND_SOC_CS4271_SPI) += snd-soc-cs4271-spi.o
obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o
obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o obj-$(CONFIG_SND_SOC_CS42XX8_I2C) += snd-soc-cs42xx8-i2c.o
obj-$(CONFIG_SND_SOC_CS4349) += snd-soc-cs4349.o
obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o
obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o
obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o obj-$(CONFIG_SND_SOC_DA7213) += snd-soc-da7213.o

View File

@ -115,52 +115,7 @@ static const struct reg_default cs42l56_reg_defaults[] = {
static bool cs42l56_readable_register(struct device *dev, unsigned int reg) static bool cs42l56_readable_register(struct device *dev, unsigned int reg)
{ {
switch (reg) { switch (reg) {
case CS42L56_CHIP_ID_1: case CS42L56_CHIP_ID_1 ... CS42L56_LIM_ATTACK_RATE:
case CS42L56_CHIP_ID_2:
case CS42L56_PWRCTL_1:
case CS42L56_PWRCTL_2:
case CS42L56_CLKCTL_1:
case CS42L56_CLKCTL_2:
case CS42L56_SERIAL_FMT:
case CS42L56_CLASSH_CTL:
case CS42L56_MISC_CTL:
case CS42L56_INT_STATUS:
case CS42L56_PLAYBACK_CTL:
case CS42L56_DSP_MUTE_CTL:
case CS42L56_ADCA_MIX_VOLUME:
case CS42L56_ADCB_MIX_VOLUME:
case CS42L56_PCMA_MIX_VOLUME:
case CS42L56_PCMB_MIX_VOLUME:
case CS42L56_ANAINPUT_ADV_VOLUME:
case CS42L56_DIGINPUT_ADV_VOLUME:
case CS42L56_MASTER_A_VOLUME:
case CS42L56_MASTER_B_VOLUME:
case CS42L56_BEEP_FREQ_ONTIME:
case CS42L56_BEEP_FREQ_OFFTIME:
case CS42L56_BEEP_TONE_CFG:
case CS42L56_TONE_CTL:
case CS42L56_CHAN_MIX_SWAP:
case CS42L56_AIN_REFCFG_ADC_MUX:
case CS42L56_HPF_CTL:
case CS42L56_MISC_ADC_CTL:
case CS42L56_GAIN_BIAS_CTL:
case CS42L56_PGAA_MUX_VOLUME:
case CS42L56_PGAB_MUX_VOLUME:
case CS42L56_ADCA_ATTENUATOR:
case CS42L56_ADCB_ATTENUATOR:
case CS42L56_ALC_EN_ATTACK_RATE:
case CS42L56_ALC_RELEASE_RATE:
case CS42L56_ALC_THRESHOLD:
case CS42L56_NOISE_GATE_CTL:
case CS42L56_ALC_LIM_SFT_ZC:
case CS42L56_AMUTE_HPLO_MUX:
case CS42L56_HPA_VOLUME:
case CS42L56_HPB_VOLUME:
case CS42L56_LOA_VOLUME:
case CS42L56_LOB_VOLUME:
case CS42L56_LIM_THRESHOLD_CTL:
case CS42L56_LIM_CTL_RELEASE_RATE:
case CS42L56_LIM_ATTACK_RATE:
return true; return true;
default: default:
return false; return false;

View File

@ -153,100 +153,8 @@ static bool cs42l73_volatile_register(struct device *dev, unsigned int reg)
static bool cs42l73_readable_register(struct device *dev, unsigned int reg) static bool cs42l73_readable_register(struct device *dev, unsigned int reg)
{ {
switch (reg) { switch (reg) {
case CS42L73_DEVID_AB: case CS42L73_DEVID_AB ... CS42L73_DEVID_E:
case CS42L73_DEVID_CD: case CS42L73_REVID ... CS42L73_IM2:
case CS42L73_DEVID_E:
case CS42L73_REVID:
case CS42L73_PWRCTL1:
case CS42L73_PWRCTL2:
case CS42L73_PWRCTL3:
case CS42L73_CPFCHC:
case CS42L73_OLMBMSDC:
case CS42L73_DMMCC:
case CS42L73_XSPC:
case CS42L73_XSPMMCC:
case CS42L73_ASPC:
case CS42L73_ASPMMCC:
case CS42L73_VSPC:
case CS42L73_VSPMMCC:
case CS42L73_VXSPFS:
case CS42L73_MIOPC:
case CS42L73_ADCIPC:
case CS42L73_MICAPREPGAAVOL:
case CS42L73_MICBPREPGABVOL:
case CS42L73_IPADVOL:
case CS42L73_IPBDVOL:
case CS42L73_PBDC:
case CS42L73_HLADVOL:
case CS42L73_HLBDVOL:
case CS42L73_SPKDVOL:
case CS42L73_ESLDVOL:
case CS42L73_HPAAVOL:
case CS42L73_HPBAVOL:
case CS42L73_LOAAVOL:
case CS42L73_LOBAVOL:
case CS42L73_STRINV:
case CS42L73_XSPINV:
case CS42L73_ASPINV:
case CS42L73_VSPINV:
case CS42L73_LIMARATEHL:
case CS42L73_LIMRRATEHL:
case CS42L73_LMAXHL:
case CS42L73_LIMARATESPK:
case CS42L73_LIMRRATESPK:
case CS42L73_LMAXSPK:
case CS42L73_LIMARATEESL:
case CS42L73_LIMRRATEESL:
case CS42L73_LMAXESL:
case CS42L73_ALCARATE:
case CS42L73_ALCRRATE:
case CS42L73_ALCMINMAX:
case CS42L73_NGCAB:
case CS42L73_ALCNGMC:
case CS42L73_MIXERCTL:
case CS42L73_HLAIPAA:
case CS42L73_HLBIPBA:
case CS42L73_HLAXSPAA:
case CS42L73_HLBXSPBA:
case CS42L73_HLAASPAA:
case CS42L73_HLBASPBA:
case CS42L73_HLAVSPMA:
case CS42L73_HLBVSPMA:
case CS42L73_XSPAIPAA:
case CS42L73_XSPBIPBA:
case CS42L73_XSPAXSPAA:
case CS42L73_XSPBXSPBA:
case CS42L73_XSPAASPAA:
case CS42L73_XSPAASPBA:
case CS42L73_XSPAVSPMA:
case CS42L73_XSPBVSPMA:
case CS42L73_ASPAIPAA:
case CS42L73_ASPBIPBA:
case CS42L73_ASPAXSPAA:
case CS42L73_ASPBXSPBA:
case CS42L73_ASPAASPAA:
case CS42L73_ASPBASPBA:
case CS42L73_ASPAVSPMA:
case CS42L73_ASPBVSPMA:
case CS42L73_VSPAIPAA:
case CS42L73_VSPBIPBA:
case CS42L73_VSPAXSPAA:
case CS42L73_VSPBXSPBA:
case CS42L73_VSPAASPAA:
case CS42L73_VSPBASPBA:
case CS42L73_VSPAVSPMA:
case CS42L73_VSPBVSPMA:
case CS42L73_MMIXCTL:
case CS42L73_SPKMIPMA:
case CS42L73_SPKMXSPA:
case CS42L73_SPKMASPA:
case CS42L73_SPKMVSPMA:
case CS42L73_ESLMIPMA:
case CS42L73_ESLMXSPA:
case CS42L73_ESLMASPA:
case CS42L73_ESLMVSPMA:
case CS42L73_IM1:
case CS42L73_IM2:
return true; return true;
default: default:
return false; return false;
@ -1236,8 +1144,8 @@ static int cs42l73_set_tristate(struct snd_soc_dai *dai, int tristate)
struct snd_soc_codec *codec = dai->codec; struct snd_soc_codec *codec = dai->codec;
int id = dai->id; int id = dai->id;
return snd_soc_update_bits(codec, CS42L73_SPC(id), return snd_soc_update_bits(codec, CS42L73_SPC(id), CS42L73_SP_3ST,
0x7F, tristate << 7); tristate << 7);
} }
static const struct snd_pcm_hw_constraint_list constraints_12_24 = { static const struct snd_pcm_hw_constraint_list constraints_12_24 = {

392
sound/soc/codecs/cs4349.c Normal file
View File

@ -0,0 +1,392 @@
/*
* cs4349.c -- CS4349 ALSA Soc Audio driver
*
* Copyright 2015 Cirrus Logic, Inc.
*
* Authors: Tim Howe <Tim.Howe@cirrus.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/kernel.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/platform_device.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/of_device.h>
#include <linux/regmap.h>
#include <linux/slab.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/initval.h>
#include <sound/tlv.h>
#include "cs4349.h"
static const struct reg_default cs4349_reg_defaults[] = {
{ 2, 0x00 }, /* r02 - Mode Control */
{ 3, 0x09 }, /* r03 - Volume, Mixing and Inversion Control */
{ 4, 0x81 }, /* r04 - Mute Control */
{ 5, 0x00 }, /* r05 - Channel A Volume Control */
{ 6, 0x00 }, /* r06 - Channel B Volume Control */
{ 7, 0xB1 }, /* r07 - Ramp and Filter Control */
{ 8, 0x1C }, /* r08 - Misc. Control */
};
/* Private data for the CS4349 */
struct cs4349_private {
struct regmap *regmap;
struct gpio_desc *reset_gpio;
unsigned int mode;
int rate;
};
static bool cs4349_readable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case CS4349_CHIPID ... CS4349_MISC:
return true;
default:
return false;
}
}
static bool cs4349_writeable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case CS4349_MODE ... CS4349_MISC:
return true;
default:
return false;
}
}
static int cs4349_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int format)
{
struct snd_soc_codec *codec = codec_dai->codec;
struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec);
unsigned int fmt;
fmt = format & SND_SOC_DAIFMT_FORMAT_MASK;
switch (fmt) {
case SND_SOC_DAIFMT_I2S:
case SND_SOC_DAIFMT_LEFT_J:
case SND_SOC_DAIFMT_RIGHT_J:
cs4349->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
break;
default:
return -EINVAL;
}
return 0;
}
static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{
struct snd_soc_codec *codec = dai->codec;
struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec);
int fmt, ret;
cs4349->rate = params_rate(params);
switch (cs4349->mode) {
case SND_SOC_DAIFMT_I2S:
fmt = DIF_I2S;
break;
case SND_SOC_DAIFMT_LEFT_J:
fmt = DIF_LEFT_JST;
break;
case SND_SOC_DAIFMT_RIGHT_J:
switch (params_width(params)) {
case 16:
fmt = DIF_RGHT_JST16;
break;
case 24:
fmt = DIF_RGHT_JST24;
break;
default:
return -EINVAL;
}
break;
default:
return -EINVAL;
}
ret = snd_soc_update_bits(codec, CS4349_MODE, DIF_MASK,
MODE_FORMAT(fmt));
if (ret < 0)
return ret;
return 0;
}
static int cs4349_digital_mute(struct snd_soc_dai *dai, int mute)
{
struct snd_soc_codec *codec = dai->codec;
int reg;
reg = 0;
if (mute)
reg = MUTE_AB_MASK;
return snd_soc_update_bits(codec, CS4349_MUTE, MUTE_AB_MASK, reg);
}
static DECLARE_TLV_DB_SCALE(dig_tlv, -12750, 50, 0);
static const char * const chan_mix_texts[] = {
"Mute", "MuteA", "MuteA SwapB", "MuteA MonoB", "SwapA MuteB",
"BothR", "Swap", "SwapA MonoB", "MuteB", "Normal", "BothL",
"MonoB", "MonoA MuteB", "MonoA", "MonoA SwapB", "Mono",
/*Normal == Channel A = Left, Channel B = Right*/
};
static const char * const fm_texts[] = {
"Auto", "Single", "Double", "Quad",
};
static const char * const deemph_texts[] = {
"None", "44.1k", "48k", "32k",
};
static const char * const softr_zeroc_texts[] = {
"Immediate", "Zero Cross", "Soft Ramp", "SR on ZC",
};
static int deemph_values[] = {
0, 4, 8, 12,
};
static int softr_zeroc_values[] = {
0, 64, 128, 192,
};
static const struct soc_enum chan_mix_enum =
SOC_ENUM_SINGLE(CS4349_VMI, 0,
ARRAY_SIZE(chan_mix_texts),
chan_mix_texts);
static const struct soc_enum fm_mode_enum =
SOC_ENUM_SINGLE(CS4349_MODE, 0,
ARRAY_SIZE(fm_texts),
fm_texts);
static SOC_VALUE_ENUM_SINGLE_DECL(deemph_enum, CS4349_MODE, 0, DEM_MASK,
deemph_texts, deemph_values);
static SOC_VALUE_ENUM_SINGLE_DECL(softr_zeroc_enum, CS4349_RMPFLT, 0,
SR_ZC_MASK, softr_zeroc_texts,
softr_zeroc_values);
static const struct snd_kcontrol_new cs4349_snd_controls[] = {
SOC_DOUBLE_R_TLV("Master Playback Volume",
CS4349_VOLA, CS4349_VOLB, 0, 0xFF, 1, dig_tlv),
SOC_ENUM("Functional Mode", fm_mode_enum),
SOC_ENUM("De-Emphasis Control", deemph_enum),
SOC_ENUM("Soft Ramp Zero Cross Control", softr_zeroc_enum),
SOC_ENUM("Channel Mixer", chan_mix_enum),
SOC_SINGLE("VolA = VolB Switch", CS4349_VMI, 7, 1, 0),
SOC_SINGLE("InvertA Switch", CS4349_VMI, 6, 1, 0),
SOC_SINGLE("InvertB Switch", CS4349_VMI, 5, 1, 0),
SOC_SINGLE("Auto-Mute Switch", CS4349_MUTE, 7, 1, 0),
SOC_SINGLE("MUTEC A = B Switch", CS4349_MUTE, 5, 1, 0),
SOC_SINGLE("Soft Ramp Up Switch", CS4349_RMPFLT, 5, 1, 0),
SOC_SINGLE("Soft Ramp Down Switch", CS4349_RMPFLT, 4, 1, 0),
SOC_SINGLE("Slow Roll Off Filter Switch", CS4349_RMPFLT, 2, 1, 0),
SOC_SINGLE("Freeze Switch", CS4349_MISC, 5, 1, 0),
SOC_SINGLE("Popguard Switch", CS4349_MISC, 4, 1, 0),
};
static const struct snd_soc_dapm_widget cs4349_dapm_widgets[] = {
SND_SOC_DAPM_DAC("HiFi DAC", NULL, SND_SOC_NOPM, 0, 0),
SND_SOC_DAPM_OUTPUT("OutputA"),
SND_SOC_DAPM_OUTPUT("OutputB"),
};
static const struct snd_soc_dapm_route cs4349_routes[] = {
{"DAC Playback", NULL, "OutputA"},
{"DAC Playback", NULL, "OutputB"},
{"OutputA", NULL, "HiFi DAC"},
{"OutputB", NULL, "HiFi DAC"},
};
#define CS4349_PCM_FORMATS (SNDRV_PCM_FMTBIT_S8 | \
SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | \
SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE | \
SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE | \
SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | \
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE | \
SNDRV_PCM_FMTBIT_S32_LE)
#define CS4349_PCM_RATES SNDRV_PCM_RATE_8000_192000
static const struct snd_soc_dai_ops cs4349_dai_ops = {
.hw_params = cs4349_pcm_hw_params,
.set_fmt = cs4349_set_dai_fmt,
.digital_mute = cs4349_digital_mute,
};
static struct snd_soc_dai_driver cs4349_dai = {
.name = "cs4349_hifi",
.playback = {
.stream_name = "DAC Playback",
.channels_min = 1,
.channels_max = 2,
.rates = CS4349_PCM_RATES,
.formats = CS4349_PCM_FORMATS,
},
.ops = &cs4349_dai_ops,
.symmetric_rates = 1,
};
static struct snd_soc_codec_driver soc_codec_dev_cs4349 = {
.controls = cs4349_snd_controls,
.num_controls = ARRAY_SIZE(cs4349_snd_controls),
.dapm_widgets = cs4349_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(cs4349_dapm_widgets),
.dapm_routes = cs4349_routes,
.num_dapm_routes = ARRAY_SIZE(cs4349_routes),
};
static const struct regmap_config cs4349_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = CS4349_MISC,
.reg_defaults = cs4349_reg_defaults,
.num_reg_defaults = ARRAY_SIZE(cs4349_reg_defaults),
.readable_reg = cs4349_readable_register,
.writeable_reg = cs4349_writeable_register,
.cache_type = REGCACHE_RBTREE,
};
static int cs4349_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct cs4349_private *cs4349;
int ret;
cs4349 = devm_kzalloc(&client->dev, sizeof(*cs4349), GFP_KERNEL);
if (!cs4349)
return -ENOMEM;
cs4349->regmap = devm_regmap_init_i2c(client, &cs4349_regmap);
if (IS_ERR(cs4349->regmap)) {
ret = PTR_ERR(cs4349->regmap);
dev_err(&client->dev, "regmap_init() failed: %d\n", ret);
return ret;
}
/* Reset the Device */
cs4349->reset_gpio = devm_gpiod_get_optional(&client->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(cs4349->reset_gpio))
return PTR_ERR(cs4349->reset_gpio);
gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
i2c_set_clientdata(client, cs4349);
return snd_soc_register_codec(&client->dev, &soc_codec_dev_cs4349,
&cs4349_dai, 1);
}
static int cs4349_i2c_remove(struct i2c_client *client)
{
struct cs4349_private *cs4349 = i2c_get_clientdata(client);
snd_soc_unregister_codec(&client->dev);
/* Hold down reset */
gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
return 0;
}
#ifdef CONFIG_PM
static int cs4349_runtime_suspend(struct device *dev)
{
struct cs4349_private *cs4349 = dev_get_drvdata(dev);
int ret;
ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, PWR_DWN);
if (ret < 0)
return ret;
regcache_cache_only(cs4349->regmap, true);
/* Hold down reset */
gpiod_set_value_cansleep(cs4349->reset_gpio, 0);
return 0;
}
static int cs4349_runtime_resume(struct device *dev)
{
struct cs4349_private *cs4349 = dev_get_drvdata(dev);
int ret;
ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 0);
if (ret < 0)
return ret;
gpiod_set_value_cansleep(cs4349->reset_gpio, 1);
regcache_cache_only(cs4349->regmap, false);
regcache_sync(cs4349->regmap);
return 0;
}
#endif
static const struct dev_pm_ops cs4349_runtime_pm = {
SET_RUNTIME_PM_OPS(cs4349_runtime_suspend, cs4349_runtime_resume,
NULL)
};
static const struct of_device_id cs4349_of_match[] = {
{ .compatible = "cirrus,cs4349", },
{},
};
MODULE_DEVICE_TABLE(of, cs4349_of_match);
static const struct i2c_device_id cs4349_i2c_id[] = {
{"cs4349", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, cs4349_i2c_id);
static struct i2c_driver cs4349_i2c_driver = {
.driver = {
.name = "cs4349",
.of_match_table = cs4349_of_match,
},
.id_table = cs4349_i2c_id,
.probe = cs4349_i2c_probe,
.remove = cs4349_i2c_remove,
};
module_i2c_driver(cs4349_i2c_driver);
MODULE_AUTHOR("Tim Howe <tim.howe@cirrus.com>");
MODULE_DESCRIPTION("Cirrus Logic CS4349 ALSA SoC Codec Driver");
MODULE_LICENSE("GPL");

136
sound/soc/codecs/cs4349.h Normal file
View File

@ -0,0 +1,136 @@
/*
* ALSA SoC CS4349 codec driver
*
* Copyright 2015 Cirrus Logic, Inc.
*
* Author: Tim Howe <Tim.Howe@cirrus.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.
*
*/
#ifndef __CS4349_H__
#define __CS4349_H__
/* CS4349 registers addresses */
#define CS4349_CHIPID 0x01 /* Device and Rev ID, Read Only */
#define CS4349_MODE 0x02 /* Mode Control */
#define CS4349_VMI 0x03 /* Volume, Mixing, Inversion Control */
#define CS4349_MUTE 0x04 /* Mute Control */
#define CS4349_VOLA 0x05 /* DAC Channel A Volume Control */
#define CS4349_VOLB 0x06 /* DAC Channel B Volume Control */
#define CS4349_RMPFLT 0x07 /* Ramp and Filter Control */
#define CS4349_MISC 0x08 /* Power Down,Freeze Control,Pop Stop*/
#define CS4349_I2C_INCR 0x80
/* Device and Revision ID */
#define CS4349_REVA 0xF0 /* Rev A */
#define CS4349_REVB 0xF1 /* Rev B */
#define CS4349_REVC2 0xFF /* Rev C2 */
/* PDN_DONE Poll Maximum
* If soft ramp is set it will take much longer to power down
* the system.
*/
#define PDN_POLL_MAX 900
/* Bitfield Definitions */
/* CS4349_MODE */
/* (Digital Interface Format, De-Emphasis Control, Functional Mode */
#define DIF2 (1 << 6)
#define DIF1 (1 << 5)
#define DIF0 (1 << 4)
#define DEM1 (1 << 3)
#define DEM0 (1 << 2)
#define FM1 (1 << 1)
#define DIF_LEFT_JST 0x00
#define DIF_I2S 0x01
#define DIF_RGHT_JST16 0x02
#define DIF_RGHT_JST24 0x03
#define DIF_TDM0 0x04
#define DIF_TDM1 0x05
#define DIF_TDM2 0x06
#define DIF_TDM3 0x07
#define DIF_MASK 0x70
#define MODE_FORMAT(x) (((x)&7)<<4)
#define DEM_MASK 0x0C
#define NO_DEM 0x00
#define DEM_441 0x04
#define DEM_48K 0x08
#define DEM_32K 0x0C
#define FM_AUTO 0x00
#define FM_SNGL 0x01
#define FM_DBL 0x02
#define FM_QUAD 0x03
#define FM_SNGL_MIN 30000
#define FM_SNGL_MAX 54000
#define FM_DBL_MAX 108000
#define FM_QUAD_MAX 216000
#define FM_MASK 0x03
/* CS4349_VMI (VMI = Volume, Mixing and Inversion Controls) */
#define VOLBISA (1 << 7)
#define VOLAISB (1 << 7)
/* INVERT_A only available for Left Jstfd, Right Jstfd16 and Right Jstfd24 */
#define INVERT_A (1 << 6)
/* INVERT_B only available for Left Jstfd, Right Jstfd16 and Right Jstfd24 */
#define INVERT_B (1 << 5)
#define ATAPI3 (1 << 3)
#define ATAPI2 (1 << 2)
#define ATAPI1 (1 << 1)
#define ATAPI0 (1 << 0)
#define MUTEAB 0x00
#define MUTEA_RIGHTB 0x01
#define MUTEA_LEFTB 0x02
#define MUTEA_SUMLRDIV2B 0x03
#define RIGHTA_MUTEB 0x04
#define RIGHTA_RIGHTB 0x05
#define RIGHTA_LEFTB 0x06
#define RIGHTA_SUMLRDIV2B 0x07
#define LEFTA_MUTEB 0x08
#define LEFTA_RIGHTB 0x09 /* Default */
#define LEFTA_LEFTB 0x0A
#define LEFTA_SUMLRDIV2B 0x0B
#define SUMLRDIV2A_MUTEB 0x0C
#define SUMLRDIV2A_RIGHTB 0x0D
#define SUMLRDIV2A_LEFTB 0x0E
#define SUMLRDIV2_AB 0x0F
#define CHMIX_MASK 0x0F
/* CS4349_MUTE */
#define AUTOMUTE (1 << 7)
#define MUTEC_AB (1 << 5)
#define MUTE_A (1 << 4)
#define MUTE_B (1 << 3)
#define MUTE_AB_MASK 0x18
/* CS4349_RMPFLT (Ramp and Filter Control) */
#define SCZ1 (1 << 7)
#define SCZ0 (1 << 6)
#define RMP_UP (1 << 5)
#define RMP_DN (1 << 4)
#define FILT_SEL (1 << 2)
#define IMMDT_CHNG 0x31
#define ZEROCRSS 0x71
#define SOFT_RMP 0xB1
#define SFTRMP_ZEROCRSS 0xF1
#define SR_ZC_MASK 0xC0
/* CS4349_MISC */
#define PWR_DWN (1 << 7)
#define FREEZE (1 << 5)
#define POPG_EN (1 << 4)
#endif /* __CS4349_H__ */

View File

@ -1196,13 +1196,7 @@ static int da732x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id,
#define DA732X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ #define DA732X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
static struct snd_soc_dai_ops da732x_dai1_ops = { static const struct snd_soc_dai_ops da732x_dai_ops = {
.hw_params = da732x_hw_params,
.set_fmt = da732x_set_dai_fmt,
.set_sysclk = da732x_set_dai_sysclk,
};
static struct snd_soc_dai_ops da732x_dai2_ops = {
.hw_params = da732x_hw_params, .hw_params = da732x_hw_params,
.set_fmt = da732x_set_dai_fmt, .set_fmt = da732x_set_dai_fmt,
.set_sysclk = da732x_set_dai_sysclk, .set_sysclk = da732x_set_dai_sysclk,
@ -1227,7 +1221,7 @@ static struct snd_soc_dai_driver da732x_dai[] = {
.rates = DA732X_RATES, .rates = DA732X_RATES,
.formats = DA732X_FORMATS, .formats = DA732X_FORMATS,
}, },
.ops = &da732x_dai1_ops, .ops = &da732x_dai_ops,
}, },
{ {
.name = "DA732X_AIFB", .name = "DA732X_AIFB",
@ -1247,7 +1241,7 @@ static struct snd_soc_dai_driver da732x_dai[] = {
.rates = DA732X_RATES, .rates = DA732X_RATES,
.formats = DA732X_FORMATS, .formats = DA732X_FORMATS,
}, },
.ops = &da732x_dai2_ops, .ops = &da732x_dai_ops,
}, },
}; };