Commit 2d8432d8 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/max9850', 'asoc/topic/max9860',...

Merge remote-tracking branches 'asoc/topic/max9850', 'asoc/topic/max9860', 'asoc/topic/max9867', 'asoc/topic/max98925' and 'asoc/topic/max98926' into asoc-next
...@@ -641,7 +641,8 @@ config SND_SOC_MAX98504 ...@@ -641,7 +641,8 @@ config SND_SOC_MAX98504
depends on I2C depends on I2C
config SND_SOC_MAX9867 config SND_SOC_MAX9867
tristate tristate "Maxim MAX9867 CODEC"
depends on I2C
config SND_SOC_MAX98925 config SND_SOC_MAX98925
tristate tristate
......
...@@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
u64 lrclk_div; u64 lrclk_div;
u8 sf, da; u8 sf, da;
...@@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
/* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */
sf = (snd_soc_read(codec, MAX9850_CLOCK) >> 2) + 1; sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1;
lrclk_div = (1 << 22); lrclk_div = (1 << 22);
lrclk_div *= params_rate(params); lrclk_div *= params_rate(params);
lrclk_div *= sf; lrclk_div *= sf;
do_div(lrclk_div, max9850->sysclk); do_div(lrclk_div, max9850->sysclk);
snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f);
snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff);
switch (params_width(params)) { switch (params_width(params)) {
case 16: case 16:
...@@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
default: default:
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, MAX9850_DIGITAL_AUDIO, 0x3, da); snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da);
return 0; return 0;
} }
...@@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, ...@@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream,
static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
/* calculate mclk -> iclk divider */ /* calculate mclk -> iclk divider */
if (freq <= 13000000) if (freq <= 13000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x0); snd_soc_component_write(component, MAX9850_CLOCK, 0x0);
else if (freq <= 26000000) else if (freq <= 26000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x4); snd_soc_component_write(component, MAX9850_CLOCK, 0x4);
else if (freq <= 40000000) else if (freq <= 40000000)
snd_soc_write(codec, MAX9850_CLOCK, 0x8); snd_soc_component_write(component, MAX9850_CLOCK, 0x8);
else else
return -EINVAL; return -EINVAL;
...@@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u8 da = 0; u8 da = 0;
/* set master/slave audio interface */ /* set master/slave audio interface */
...@@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) ...@@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
} }
/* set da */ /* set da */
snd_soc_write(codec, MAX9850_DIGITAL_AUDIO, da); snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da);
return 0; return 0;
} }
static int max9850_set_bias_level(struct snd_soc_codec *codec, static int max9850_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, ...@@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
ret = regcache_sync(max9850->regmap); ret = regcache_sync(max9850->regmap);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to sync cache: %d\n", ret); "Failed to sync cache: %d\n", ret);
return ret; return ret;
} }
...@@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = { ...@@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = {
.ops = &max9850_dai_ops, .ops = &max9850_dai_ops,
}; };
static int max9850_probe(struct snd_soc_codec *codec) static int max9850_probe(struct snd_soc_component *component)
{ {
/* enable zero-detect */ /* enable zero-detect */
snd_soc_update_bits(codec, MAX9850_GENERAL_PURPOSE, 1, 1); snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1);
/* enable slew-rate control */ /* enable slew-rate control */
snd_soc_update_bits(codec, MAX9850_VOLUME, 0x40, 0x40); snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40);
/* set slew-rate 125ms */ /* set slew-rate 125ms */
snd_soc_update_bits(codec, MAX9850_CHARGE_PUMP, 0xff, 0xc0); snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { static const struct snd_soc_component_driver soc_component_dev_max9850 = {
.probe = max9850_probe, .probe = max9850_probe,
.set_bias_level = max9850_set_bias_level, .set_bias_level = max9850_set_bias_level,
.suspend_bias_off = true, .controls = max9850_controls,
.num_controls = ARRAY_SIZE(max9850_controls),
.component_driver = { .dapm_widgets = max9850_dapm_widgets,
.controls = max9850_controls, .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets),
.num_controls = ARRAY_SIZE(max9850_controls), .dapm_routes = max9850_dapm_routes,
.dapm_widgets = max9850_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = max9850_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int max9850_i2c_probe(struct i2c_client *i2c, static int max9850_i2c_probe(struct i2c_client *i2c,
...@@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c, ...@@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, max9850); i2c_set_clientdata(i2c, max9850);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_max9850, &max9850_dai, 1); &soc_component_dev_max9850, &max9850_dai, 1);
return ret; return ret;
} }
static int max9850_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id max9850_i2c_id[] = { static const struct i2c_device_id max9850_i2c_id[] = {
{ "max9850", 0 }, { "max9850", 0 },
{ } { }
...@@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = { ...@@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = {
.name = "max9850", .name = "max9850",
}, },
.probe = max9850_i2c_probe, .probe = max9850_i2c_probe,
.remove = max9850_i2c_remove,
.id_table = max9850_i2c_id, .id_table = max9850_i2c_id,
}; };
......
...@@ -261,8 +261,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -261,8 +261,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component);
u8 master; u8 master;
u8 ifc1a = 0; u8 ifc1a = 0;
u8 ifc1b = 0; u8 ifc1b = 0;
...@@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
unsigned long n; unsigned long n;
int ret; int ret;
dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", dev_dbg(component->dev, "hw_params %u Hz, %u channels\n",
params_rate(params), params_rate(params),
params_channels(params)); params_channels(params));
...@@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
break; break;
case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_A:
if (params_width(params) != 16) { if (params_width(params) != 16) {
dev_err(codec->dev, dev_err(component->dev,
"DSP_A works for 16 bits per sample only.\n"); "DSP_A works for 16 bits per sample only.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
break; break;
case SND_SOC_DAIFMT_DSP_B: case SND_SOC_DAIFMT_DSP_B:
if (params_width(params) != 16) { if (params_width(params) != 16) {
dev_err(codec->dev, dev_err(component->dev,
"DSP_B works for 16 bits per sample only.\n"); "DSP_B works for 16 bits per sample only.\n");
return -EINVAL; return -EINVAL;
} }
...@@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "IFC1A %02x\n", ifc1a); dev_dbg(component->dev, "IFC1A %02x\n", ifc1a);
ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a); ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set IFC1A: %d\n", ret); dev_err(component->dev, "Failed to set IFC1A: %d\n", ret);
return ret; return ret;
} }
dev_dbg(codec->dev, "IFC1B %02x\n", ifc1b); dev_dbg(component->dev, "IFC1B %02x\n", ifc1b);
ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b); ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set IFC1B: %d\n", ret); dev_err(component->dev, "Failed to set IFC1B: %d\n", ret);
return ret; return ret;
} }
...@@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
} }
sysclk |= max9860->psclk; sysclk |= max9860->psclk;
dev_dbg(codec->dev, "SYSCLK %02x\n", sysclk); dev_dbg(component->dev, "SYSCLK %02x\n", sysclk);
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_SYSCLK, sysclk); MAX9860_SYSCLK, sysclk);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret); dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret);
return ret; return ret;
} }
dev_dbg(codec->dev, "N %lu\n", n); dev_dbg(component->dev, "N %lu\n", n);
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_AUDIOCLKHIGH, n >> 8); MAX9860_AUDIOCLKHIGH, n >> 8);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set NHI: %d\n", ret); dev_err(component->dev, "Failed to set NHI: %d\n", ret);
return ret; return ret;
} }
ret = regmap_write(max9860->regmap, ret = regmap_write(max9860->regmap,
MAX9860_AUDIOCLKLOW, n & 0xff); MAX9860_AUDIOCLKLOW, n & 0xff);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to set NLO: %d\n", ret); dev_err(component->dev, "Failed to set NLO: %d\n", ret);
return ret; return ret;
} }
if (!master) { if (!master) {
dev_dbg(codec->dev, "Enable PLL\n"); dev_dbg(component->dev, "Enable PLL\n");
ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH, ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH,
MAX9860_PLL, MAX9860_PLL); MAX9860_PLL, MAX9860_PLL);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable PLL: %d\n", ret); dev_err(component->dev, "Failed to enable PLL: %d\n", ret);
return ret; return ret;
} }
} }
...@@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, ...@@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream,
static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBM_CFM: case SND_SOC_DAIFMT_CBM_CFM:
...@@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = { ...@@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int max9860_set_bias_level(struct snd_soc_codec *codec, static int max9860_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct max9860_priv *max9860 = dev_get_drvdata(codec->dev); struct max9860_priv *max9860 = dev_get_drvdata(component->dev);
int ret; int ret;
switch (level) { switch (level) {
...@@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN,
MAX9860_SHDN, MAX9860_SHDN); MAX9860_SHDN, MAX9860_SHDN);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to remove SHDN: %d\n", ret); dev_err(component->dev, "Failed to remove SHDN: %d\n", ret);
return ret; return ret;
} }
break; break;
...@@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN,
MAX9860_SHDN, 0); MAX9860_SHDN, 0);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to request SHDN: %d\n", dev_err(component->dev, "Failed to request SHDN: %d\n",
ret); ret);
return ret; return ret;
} }
...@@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ...@@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static const struct snd_soc_codec_driver max9860_codec_driver = { static const struct snd_soc_component_driver max9860_component_driver = {
.set_bias_level = max9860_set_bias_level, .set_bias_level = max9860_set_bias_level,
.idle_bias_off = true, .controls = max9860_controls,
.num_controls = ARRAY_SIZE(max9860_controls),
.component_driver = { .dapm_widgets = max9860_dapm_widgets,
.controls = max9860_controls, .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets),
.num_controls = ARRAY_SIZE(max9860_controls), .dapm_routes = max9860_dapm_routes,
.dapm_widgets = max9860_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), .use_pmdown_time = 1,
.dapm_routes = max9860_dapm_routes, .endianness = 1,
.num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), .non_legacy_dai_naming = 1,
},
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c, ...@@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c,
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_idle(dev); pm_runtime_idle(dev);
ret = snd_soc_register_codec(dev, &max9860_codec_driver, ret = devm_snd_soc_register_component(dev, &max9860_component_driver,
&max9860_dai, 1); &max9860_dai, 1);
if (ret) { if (ret) {
dev_err(dev, "Failed to register CODEC: %d\n", ret); dev_err(dev, "Failed to register CODEC: %d\n", ret);
...@@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c) ...@@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c)
struct device *dev = &i2c->dev; struct device *dev = &i2c->dev;
struct max9860_priv *max9860 = dev_get_drvdata(dev); struct max9860_priv *max9860 = dev_get_drvdata(dev);
snd_soc_unregister_codec(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
regulator_disable(max9860->dvddio); regulator_disable(max9860->dvddio);
return 0; return 0;
......
...@@ -179,8 +179,8 @@ static inline int get_ni_value(int mclk, int rate) ...@@ -179,8 +179,8 @@ static inline int get_ni_value(int mclk, int rate)
static int max9867_dai_hw_params(struct snd_pcm_substream *substream, static int max9867_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
unsigned int ni_h, ni_l; unsigned int ni_h, ni_l;
int value; int value;
...@@ -227,7 +227,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -227,7 +227,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream,
bclk_value = MAX9867_IFC1B_PCLK_16; bclk_value = MAX9867_IFC1B_PCLK_16;
break; break;
default: default:
dev_err(codec->dev, dev_err(component->dev,
"unsupported sampling rate\n"); "unsupported sampling rate\n");
return -EINVAL; return -EINVAL;
} }
...@@ -239,7 +239,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -239,7 +239,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream,
bclk_value = MAX9867_IFC1B_32BIT; bclk_value = MAX9867_IFC1B_32BIT;
break; break;
default: default:
dev_err(codec->dev, "unsupported sampling rate\n"); dev_err(component->dev, "unsupported sampling rate\n");
return -EINVAL; return -EINVAL;
} }
regmap_update_bits(max9867->regmap, MAX9867_IFC1B, regmap_update_bits(max9867->regmap, MAX9867_IFC1B,
...@@ -251,8 +251,8 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -251,8 +251,8 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream,
static int max9867_prepare(struct snd_pcm_substream *substream, static int max9867_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, regmap_update_bits(max9867->regmap, MAX9867_PWRMAN,
MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK); MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK);
...@@ -261,8 +261,8 @@ static int max9867_prepare(struct snd_pcm_substream *substream, ...@@ -261,8 +261,8 @@ static int max9867_prepare(struct snd_pcm_substream *substream,
static int max9867_mute(struct snd_soc_dai *dai, int mute) static int max9867_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
if (mute) if (mute)
regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL,
...@@ -276,8 +276,8 @@ static int max9867_mute(struct snd_soc_dai *dai, int mute) ...@@ -276,8 +276,8 @@ static int max9867_mute(struct snd_soc_dai *dai, int mute)
static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
int value = 0; int value = 0;
/* Set the prescaler based on the master clock frequency*/ /* Set the prescaler based on the master clock frequency*/
...@@ -291,7 +291,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -291,7 +291,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai,
value |= MAX9867_PSCLK_40_60; value |= MAX9867_PSCLK_40_60;
max9867->pclk = freq/4; max9867->pclk = freq/4;
} else { } else {
pr_err("bad clock frequency %d", freq); dev_err(component->dev,
"Invalid clock frequency %uHz (required 10-60MHz)\n",
freq);
return -EINVAL; return -EINVAL;
} }
value = value << MAX9867_PSCLK_SHIFT; value = value << MAX9867_PSCLK_SHIFT;
...@@ -306,8 +308,8 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, ...@@ -306,8 +308,8 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component);
u8 iface1A = 0, iface1B = 0; u8 iface1A = 0, iface1B = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -323,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, ...@@ -323,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
/* for i2s compatible mode */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
iface1A |= MAX9867_I2S_DLY; case SND_SOC_DAIFMT_I2S:
/* SDOUT goes to hiz state after all data is transferred */ iface1A |= MAX9867_I2S_DLY;
iface1A |= MAX9867_SDOUT_HIZ; break;
case SND_SOC_DAIFMT_DSP_A:
iface1A |= MAX9867_TDM_MODE | MAX9867_SDOUT_HIZ;
break;
default:
return -EINVAL;
}
/* Clock inversion bits, BCI and WCI */ /* Clock inversion bits, BCI and WCI */
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
...@@ -367,19 +375,20 @@ static struct snd_soc_dai_driver max9867_dai[] = { ...@@ -367,19 +375,20 @@ static struct snd_soc_dai_driver max9867_dai[] = {
.name = "max9867-aif1", .name = "max9867-aif1",
.playback = { .playback = {
.stream_name = "HiFi Playback", .stream_name = "HiFi Playback",
.channels_min = 1, .channels_min = 2,
.channels_max = 2, .channels_max = 2,
.rates = MAX9867_RATES, .rates = MAX9867_RATES,
.formats = MAX9867_FORMATS, .formats = MAX9867_FORMATS,
}, },
.capture = { .capture = {
.stream_name = "HiFi Capture", .stream_name = "HiFi Capture",
.channels_min = 1, .channels_min = 2,
.channels_max = 2, .channels_max = 2,
.rates = MAX9867_RATES, .rates = MAX9867_RATES,
.formats = MAX9867_FORMATS, .formats = MAX9867_FORMATS,
}, },
.ops = &max9867_dai_ops, .ops = &max9867_dai_ops,
.symmetric_rates = 1,
} }
}; };
...@@ -404,25 +413,17 @@ static int max9867_resume(struct device *dev) ...@@ -404,25 +413,17 @@ static int max9867_resume(struct device *dev)
} }
#endif #endif
static int max9867_probe(struct snd_soc_codec *codec) static const struct snd_soc_component_driver max9867_component = {
{ .controls = max9867_snd_controls,
struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); .num_controls = ARRAY_SIZE(max9867_snd_controls),
.dapm_routes = max9867_audio_map,
dev_dbg(codec->dev, "max98090_probe\n"); .num_dapm_routes = ARRAY_SIZE(max9867_audio_map),
max9867->codec = codec; .dapm_widgets = max9867_dapm_widgets,
return 0; .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets),
} .idle_bias_on = 1,
.use_pmdown_time = 1,
static const struct snd_soc_codec_driver max9867_codec = { .endianness = 1,
.probe = max9867_probe, .non_legacy_dai_naming = 1,
.component_driver = {
.controls = max9867_snd_controls,
.num_controls = ARRAY_SIZE(max9867_snd_controls),
.dapm_routes = max9867_audio_map,
.num_dapm_routes = ARRAY_SIZE(max9867_audio_map),
.dapm_widgets = max9867_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets),
},
}; };
static bool max9867_volatile_register(struct device *dev, unsigned int reg) static bool max9867_volatile_register(struct device *dev, unsigned int reg)
...@@ -486,8 +487,7 @@ static int max9867_i2c_probe(struct i2c_client *i2c, ...@@ -486,8 +487,7 @@ static int max9867_i2c_probe(struct i2c_client *i2c,
max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap); max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap);
if (IS_ERR(max9867->regmap)) { if (IS_ERR(max9867->regmap)) {
ret = PTR_ERR(max9867->regmap); ret = PTR_ERR(max9867->regmap);
dev_err(&i2c->dev, dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
"Failed to allocate regmap: %d\n", ret);
return ret; return ret;
} }
ret = regmap_read(max9867->regmap, ret = regmap_read(max9867->regmap,
...@@ -497,21 +497,15 @@ static int max9867_i2c_probe(struct i2c_client *i2c, ...@@ -497,21 +497,15 @@ static int max9867_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
dev_info(&i2c->dev, "device revision: %x\n", reg); dev_info(&i2c->dev, "device revision: %x\n", reg);
ret = snd_soc_register_codec(&i2c->dev, &max9867_codec, ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component,
max9867_dai, ARRAY_SIZE(max9867_dai)); max9867_dai, ARRAY_SIZE(max9867_dai));
if (ret < 0) { if (ret < 0) {
dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); dev_err(&i2c->dev, "Failed to register component: %d\n", ret);
return ret; return ret;
} }
return ret; return ret;
} }
static int max9867_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id max9867_i2c_id[] = { static const struct i2c_device_id max9867_i2c_id[] = {
{ "max9867", 0 }, { "max9867", 0 },
{ } { }
...@@ -535,7 +529,6 @@ static struct i2c_driver max9867_i2c_driver = { ...@@ -535,7 +529,6 @@ static struct i2c_driver max9867_i2c_driver = {
.pm = &max9867_pm_ops, .pm = &max9867_pm_ops,
}, },
.probe = max9867_i2c_probe, .probe = max9867_i2c_probe,
.remove = max9867_i2c_remove,
.id_table = max9867_i2c_id, .id_table = max9867_i2c_id,
}; };
......
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
/* codec private data */ /* codec private data */
struct max9867_priv { struct max9867_priv {
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec;
unsigned int sysclk; unsigned int sysclk;
unsigned int pclk; unsigned int pclk;
unsigned int master; unsigned int master;
......
...@@ -99,8 +99,8 @@ static const struct snd_kcontrol_new max98925_dai_sel_mux = ...@@ -99,8 +99,8 @@ static const struct snd_kcontrol_new max98925_dai_sel_mux =
static int max98925_dac_event(struct snd_soc_dapm_widget *w, static int max98925_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event) struct snd_kcontrol *kcontrol, int event)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -256,7 +256,7 @@ static const struct { ...@@ -256,7 +256,7 @@ static const struct {
}, },
}; };
static inline int max98925_rate_value(struct snd_soc_codec *codec, static inline int max98925_rate_value(struct snd_soc_component *component,
int rate, int clock, int *value, int *n, int *m) int rate, int clock, int *value, int *n, int *m)
{ {
int ret = -EINVAL; int ret = -EINVAL;
...@@ -297,11 +297,11 @@ static void max98925_set_sense_data(struct max98925_priv *max98925) ...@@ -297,11 +297,11 @@ static void max98925_set_sense_data(struct max98925_priv *max98925)
static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component);
unsigned int invert = 0; unsigned int invert = 0;
dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
/* set DAI to slave mode */ /* set DAI to slave mode */
...@@ -322,7 +322,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, ...@@ -322,7 +322,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai,
case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBS_CFM:
case SND_SOC_DAIFMT_CBM_CFS: case SND_SOC_DAIFMT_CBM_CFS:
default: default:
dev_err(codec->dev, "DAI clock mode unsupported"); dev_err(component->dev, "DAI clock mode unsupported");
return -EINVAL; return -EINVAL;
} }
...@@ -339,7 +339,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, ...@@ -339,7 +339,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai,
invert = M98925_DAI_BCI_MASK | M98925_DAI_WCI_MASK; invert = M98925_DAI_BCI_MASK | M98925_DAI_WCI_MASK;
break; break;
default: default:
dev_err(codec->dev, "DAI invert mode unsupported"); dev_err(component->dev, "DAI invert mode unsupported");
return -EINVAL; return -EINVAL;
} }
...@@ -352,7 +352,7 @@ static int max98925_set_clock(struct max98925_priv *max98925, ...@@ -352,7 +352,7 @@ static int max98925_set_clock(struct max98925_priv *max98925,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
unsigned int dai_sr = 0, clock, mdll, n, m; unsigned int dai_sr = 0, clock, mdll, n, m;
struct snd_soc_codec *codec = max98925->codec; struct snd_soc_component *component = max98925->component;
int rate = params_rate(params); int rate = params_rate(params);
/* BCLK/LRCLK ratio calculation */ /* BCLK/LRCLK ratio calculation */
int blr_clk_ratio = params_channels(params) * max98925->ch_size; int blr_clk_ratio = params_channels(params) * max98925->ch_size;
...@@ -395,12 +395,12 @@ static int max98925_set_clock(struct max98925_priv *max98925, ...@@ -395,12 +395,12 @@ static int max98925_set_clock(struct max98925_priv *max98925,
mdll = M98925_MDLL_MULT_MCLKx8; mdll = M98925_MDLL_MULT_MCLKx8;
break; break;
default: default:
dev_info(max98925->codec->dev, "unsupported sysclk %d\n", dev_info(max98925->component->dev, "unsupported sysclk %d\n",
max98925->sysclk); max98925->sysclk);
return -EINVAL; return -EINVAL;
} }
if (max98925_rate_value(codec, rate, clock, &dai_sr, &n, &m)) if (max98925_rate_value(component, rate, clock, &dai_sr, &n, &m))
return -EINVAL; return -EINVAL;
/* set DAI_SR to correct LRCLK frequency */ /* set DAI_SR to correct LRCLK frequency */
...@@ -427,8 +427,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -427,8 +427,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component);
switch (params_width(params)) { switch (params_width(params)) {
case 16: case 16:
...@@ -454,7 +454,7 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -454,7 +454,7 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream,
__func__, params_format(params)); __func__, params_format(params));
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "%s: format supported %d", dev_dbg(component->dev, "%s: format supported %d",
__func__, params_format(params)); __func__, params_format(params));
return max98925_set_clock(max98925, params); return max98925_set_clock(max98925, params);
} }
...@@ -462,8 +462,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -462,8 +462,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream,
static int max98925_dai_set_sysclk(struct snd_soc_dai *dai, static int max98925_dai_set_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir) int clk_id, unsigned int freq, int dir)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case 0: case 0:
...@@ -516,11 +516,11 @@ static struct snd_soc_dai_driver max98925_dai[] = { ...@@ -516,11 +516,11 @@ static struct snd_soc_dai_driver max98925_dai[] = {
} }
}; };
static int max98925_probe(struct snd_soc_codec *codec) static int max98925_probe(struct snd_soc_component *component)
{ {
struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component);
max98925->codec = codec; max98925->component = component;
regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00); regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00);
/* It's not the default but we need to set DAI_DLY */ /* It's not the default but we need to set DAI_DLY */
regmap_write(max98925->regmap, regmap_write(max98925->regmap,
...@@ -538,16 +538,18 @@ static int max98925_probe(struct snd_soc_codec *codec) ...@@ -538,16 +538,18 @@ static int max98925_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_max98925 = { static const struct snd_soc_component_driver soc_component_dev_max98925 = {
.probe = max98925_probe, .probe = max98925_probe,
.component_driver = { .controls = max98925_snd_controls,
.controls = max98925_snd_controls, .num_controls = ARRAY_SIZE(max98925_snd_controls),
.num_controls = ARRAY_SIZE(max98925_snd_controls), .dapm_routes = max98925_audio_map,
.dapm_routes = max98925_audio_map, .num_dapm_routes = ARRAY_SIZE(max98925_audio_map),
.num_dapm_routes = ARRAY_SIZE(max98925_audio_map), .dapm_widgets = max98925_dapm_widgets,
.dapm_widgets = max98925_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config max98925_regmap = { static const struct regmap_config max98925_regmap = {
...@@ -612,20 +614,15 @@ static int max98925_i2c_probe(struct i2c_client *i2c, ...@@ -612,20 +614,15 @@ static int max98925_i2c_probe(struct i2c_client *i2c,
dev_info(&i2c->dev, "device version 0x%02X\n", reg); dev_info(&i2c->dev, "device version 0x%02X\n", reg);
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_max98925,
max98925_dai, ARRAY_SIZE(max98925_dai)); max98925_dai, ARRAY_SIZE(max98925_dai));
if (ret < 0) if (ret < 0)
dev_err(&i2c->dev, dev_err(&i2c->dev,
"Failed to register codec: %d\n", ret); "Failed to register component: %d\n", ret);
return ret; return ret;
} }
static int max98925_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id max98925_i2c_id[] = { static const struct i2c_device_id max98925_i2c_id[] = {
{ "max98925", 0 }, { "max98925", 0 },
{ } { }
...@@ -645,7 +642,6 @@ static struct i2c_driver max98925_i2c_driver = { ...@@ -645,7 +642,6 @@ static struct i2c_driver max98925_i2c_driver = {
.pm = NULL, .pm = NULL,
}, },
.probe = max98925_i2c_probe, .probe = max98925_i2c_probe,
.remove = max98925_i2c_remove,
.id_table = max98925_i2c_id, .id_table = max98925_i2c_id,
}; };
......
...@@ -821,7 +821,7 @@ ...@@ -821,7 +821,7 @@
struct max98925_priv { struct max98925_priv {
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct max98925_pdata *pdata; struct max98925_pdata *pdata;
unsigned int sysclk; unsigned int sysclk;
unsigned int v_slot; unsigned int v_slot;
......
...@@ -336,18 +336,18 @@ static void max98926_set_sense_data(struct max98926_priv *max98926) ...@@ -336,18 +336,18 @@ static void max98926_set_sense_data(struct max98926_priv *max98926)
static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component);
unsigned int invert = 0; unsigned int invert = 0;
dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt);
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
case SND_SOC_DAIFMT_CBS_CFS: case SND_SOC_DAIFMT_CBS_CFS:
max98926_set_sense_data(max98926); max98926_set_sense_data(max98926);
break; break;
default: default:
dev_err(codec->dev, "DAI clock mode unsupported\n"); dev_err(component->dev, "DAI clock mode unsupported\n");
return -EINVAL; return -EINVAL;
} }
...@@ -364,7 +364,7 @@ static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, ...@@ -364,7 +364,7 @@ static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai,
invert = MAX98926_DAI_BCI_MASK | MAX98926_DAI_WCI_MASK; invert = MAX98926_DAI_BCI_MASK | MAX98926_DAI_WCI_MASK;
break; break;
default: default:
dev_err(codec->dev, "DAI invert mode unsupported\n"); dev_err(component->dev, "DAI invert mode unsupported\n");
return -EINVAL; return -EINVAL;
} }
...@@ -381,8 +381,8 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -381,8 +381,8 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream,
{ {
int dai_sr = -EINVAL; int dai_sr = -EINVAL;
int rate = params_rate(params), i; int rate = params_rate(params), i;
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component);
int blr_clk_ratio; int blr_clk_ratio;
switch (params_format(params)) { switch (params_format(params)) {
...@@ -408,7 +408,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, ...@@ -408,7 +408,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream,
max98926->ch_size = 32; max98926->ch_size = 32;
break; break;
default: default:
dev_dbg(codec->dev, "format unsupported %d\n", dev_dbg(component->dev, "format unsupported %d\n",
params_format(params)); params_format(params));
return -EINVAL; return -EINVAL;
} }
...@@ -485,27 +485,29 @@ static struct snd_soc_dai_driver max98926_dai[] = { ...@@ -485,27 +485,29 @@ static struct snd_soc_dai_driver max98926_dai[] = {
} }
}; };
static int max98926_probe(struct snd_soc_codec *codec) static int max98926_probe(struct snd_soc_component *component)
{ {
struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component);
max98926->codec = codec; max98926->component = component;
/* Hi-Z all the slots */ /* Hi-Z all the slots */
regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0); regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0);
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_max98926 = { static const struct snd_soc_component_driver soc_component_dev_max98926 = {
.probe = max98926_probe, .probe = max98926_probe,
.component_driver = { .controls = max98926_snd_controls,
.controls = max98926_snd_controls, .num_controls = ARRAY_SIZE(max98926_snd_controls),
.num_controls = ARRAY_SIZE(max98926_snd_controls), .dapm_routes = max98926_audio_map,
.dapm_routes = max98926_audio_map, .num_dapm_routes = ARRAY_SIZE(max98926_audio_map),
.num_dapm_routes = ARRAY_SIZE(max98926_audio_map), .dapm_widgets = max98926_dapm_widgets,
.dapm_widgets = max98926_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets),
.num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets), .idle_bias_on = 1,
}, .use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config max98926_regmap = { static const struct regmap_config max98926_regmap = {
...@@ -563,22 +565,17 @@ static int max98926_i2c_probe(struct i2c_client *i2c, ...@@ -563,22 +565,17 @@ static int max98926_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98926, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_component_dev_max98926,
max98926_dai, ARRAY_SIZE(max98926_dai)); max98926_dai, ARRAY_SIZE(max98926_dai));
if (ret < 0) if (ret < 0)
dev_err(&i2c->dev, dev_err(&i2c->dev,
"Failed to register codec: %d\n", ret); "Failed to register component: %d\n", ret);
dev_info(&i2c->dev, "device version: %x\n", reg); dev_info(&i2c->dev, "device version: %x\n", reg);
err_out: err_out:
return ret; return ret;
} }
static int max98926_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id max98926_i2c_id[] = { static const struct i2c_device_id max98926_i2c_id[] = {
{ "max98926", 0 }, { "max98926", 0 },
{ } { }
...@@ -598,7 +595,6 @@ static struct i2c_driver max98926_i2c_driver = { ...@@ -598,7 +595,6 @@ static struct i2c_driver max98926_i2c_driver = {
.pm = NULL, .pm = NULL,
}, },
.probe = max98926_i2c_probe, .probe = max98926_i2c_probe,
.remove = max98926_i2c_remove,
.id_table = max98926_i2c_id, .id_table = max98926_i2c_id,
}; };
......
...@@ -838,7 +838,7 @@ ...@@ -838,7 +838,7 @@
struct max98926_priv { struct max98926_priv {
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
unsigned int sysclk; unsigned int sysclk;
unsigned int v_slot; unsigned int v_slot;
unsigned int i_slot; unsigned int i_slot;
......
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