Commit a1c83f69 authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/wm8991', 'asoc/topic/wm8994',...

Merge remote-tracking branches 'asoc/topic/wm8991', 'asoc/topic/wm8994', 'asoc/topic/wm8995', 'asoc/topic/wm8996' and 'asoc/topic/wm9081' into asoc-next
...@@ -39,10 +39,10 @@ ...@@ -39,10 +39,10 @@
#define WM_FW_BLOCK_A 0x08 #define WM_FW_BLOCK_A 0x08
#define WM_FW_BLOCK_C 0x0c #define WM_FW_BLOCK_C 0x0c
static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name,
const struct firmware *fw, bool check) const struct firmware *fw, bool check)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
u64 data64; u64 data64;
u32 data32; u32 data32;
const u8 *data; const u8 *data;
...@@ -55,7 +55,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -55,7 +55,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
return 0; return 0;
if (fw->size < 32) { if (fw->size < 32) {
dev_err(codec->dev, "%s: firmware too short (%zd bytes)\n", dev_err(component->dev, "%s: firmware too short (%zd bytes)\n",
name, fw->size); name, fw->size);
goto err; goto err;
} }
...@@ -63,7 +63,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -63,7 +63,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
if (memcmp(fw->data, "WMFW", 4) != 0) { if (memcmp(fw->data, "WMFW", 4) != 0) {
memcpy(&data32, fw->data, sizeof(data32)); memcpy(&data32, fw->data, sizeof(data32));
data32 = be32_to_cpu(data32); data32 = be32_to_cpu(data32);
dev_err(codec->dev, "%s: firmware has bad file magic %08x\n", dev_err(component->dev, "%s: firmware has bad file magic %08x\n",
name, data32); name, data32);
goto err; goto err;
} }
...@@ -74,35 +74,35 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -74,35 +74,35 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
memcpy(&data32, fw->data + 8, sizeof(data32)); memcpy(&data32, fw->data + 8, sizeof(data32));
data32 = be32_to_cpu(data32); data32 = be32_to_cpu(data32);
if ((data32 >> 24) & 0xff) { if ((data32 >> 24) & 0xff) {
dev_err(codec->dev, "%s: unsupported firmware version %d\n", dev_err(component->dev, "%s: unsupported firmware version %d\n",
name, (data32 >> 24) & 0xff); name, (data32 >> 24) & 0xff);
goto err; goto err;
} }
if ((data32 & 0xffff) != 8958) { if ((data32 & 0xffff) != 8958) {
dev_err(codec->dev, "%s: unsupported target device %d\n", dev_err(component->dev, "%s: unsupported target device %d\n",
name, data32 & 0xffff); name, data32 & 0xffff);
goto err; goto err;
} }
if (((data32 >> 16) & 0xff) != 0xc) { if (((data32 >> 16) & 0xff) != 0xc) {
dev_err(codec->dev, "%s: unsupported target core %d\n", dev_err(component->dev, "%s: unsupported target core %d\n",
name, (data32 >> 16) & 0xff); name, (data32 >> 16) & 0xff);
goto err; goto err;
} }
if (check) { if (check) {
memcpy(&data64, fw->data + 24, sizeof(u64)); memcpy(&data64, fw->data + 24, sizeof(u64));
dev_info(codec->dev, "%s timestamp %llx\n", dev_info(component->dev, "%s timestamp %llx\n",
name, be64_to_cpu(data64)); name, be64_to_cpu(data64));
} else { } else {
snd_soc_write(codec, 0x102, 0x2); snd_soc_component_write(component, 0x102, 0x2);
snd_soc_write(codec, 0x900, 0x2); snd_soc_component_write(component, 0x900, 0x2);
} }
data = fw->data + len; data = fw->data + len;
len = fw->size - len; len = fw->size - len;
while (len) { while (len) {
if (len < 12) { if (len < 12) {
dev_err(codec->dev, "%s short data block of %zd\n", dev_err(component->dev, "%s short data block of %zd\n",
name, len); name, len);
goto err; goto err;
} }
...@@ -110,12 +110,12 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -110,12 +110,12 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
memcpy(&data32, data + 4, sizeof(data32)); memcpy(&data32, data + 4, sizeof(data32));
block_len = be32_to_cpu(data32); block_len = be32_to_cpu(data32);
if (block_len + 8 > len) { if (block_len + 8 > len) {
dev_err(codec->dev, "%zd byte block longer than file\n", dev_err(component->dev, "%zd byte block longer than file\n",
block_len); block_len);
goto err; goto err;
} }
if (block_len == 0) { if (block_len == 0) {
dev_err(codec->dev, "Zero length block\n"); dev_err(component->dev, "Zero length block\n");
goto err; goto err;
} }
...@@ -131,10 +131,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -131,10 +131,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
str = kzalloc(block_len + 1, GFP_KERNEL); str = kzalloc(block_len + 1, GFP_KERNEL);
if (str) { if (str) {
memcpy(str, data + 8, block_len); memcpy(str, data + 8, block_len);
dev_info(codec->dev, "%s: %s\n", name, str); dev_info(component->dev, "%s: %s\n", name, str);
kfree(str); kfree(str);
} else { } else {
dev_err(codec->dev, "Out of memory\n"); dev_err(component->dev, "Out of memory\n");
} }
break; break;
case WM_FW_BLOCK_PM: case WM_FW_BLOCK_PM:
...@@ -144,7 +144,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -144,7 +144,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
case WM_FW_BLOCK_I: case WM_FW_BLOCK_I:
case WM_FW_BLOCK_A: case WM_FW_BLOCK_A:
case WM_FW_BLOCK_C: case WM_FW_BLOCK_C:
dev_dbg(codec->dev, "%s: %zd bytes of %x@%x\n", name, dev_dbg(component->dev, "%s: %zd bytes of %x@%x\n", name,
block_len, (data32 >> 24) & 0xff, block_len, (data32 >> 24) & 0xff,
data32 & 0xffffff); data32 & 0xffffff);
...@@ -160,7 +160,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -160,7 +160,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
break; break;
default: default:
dev_warn(codec->dev, "%s: unknown block type %d\n", dev_warn(component->dev, "%s: unknown block type %d\n",
name, (data32 >> 24) & 0xff); name, (data32 >> 24) & 0xff);
break; break;
} }
...@@ -173,10 +173,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -173,10 +173,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
} }
if (!check) { if (!check) {
dev_dbg(codec->dev, "%s: download done\n", name); dev_dbg(component->dev, "%s: download done\n", name);
wm8994->cur_fw = fw; wm8994->cur_fw = fw;
} else { } else {
dev_info(codec->dev, "%s: got firmware\n", name); dev_info(component->dev, "%s: got firmware\n", name);
} }
goto ok; goto ok;
...@@ -185,28 +185,28 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, ...@@ -185,28 +185,28 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name,
ret = -EINVAL; ret = -EINVAL;
ok: ok:
if (!check) { if (!check) {
snd_soc_write(codec, 0x900, 0x0); snd_soc_component_write(component, 0x900, 0x0);
snd_soc_write(codec, 0x102, 0x0); snd_soc_component_write(component, 0x102, 0x0);
} }
return ret; return ret;
} }
static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) static void wm8958_dsp_start_mbc(struct snd_soc_component *component, int path)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int i; int i;
/* If the DSP is already running then noop */ /* If the DSP is already running then noop */
if (snd_soc_read(codec, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA) if (snd_soc_component_read32(component, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA)
return; return;
/* If we have MBC firmware download it */ /* If we have MBC firmware download it */
if (wm8994->mbc) if (wm8994->mbc)
wm8958_dsp2_fw(codec, "MBC", wm8994->mbc, false); wm8958_dsp2_fw(component, "MBC", wm8994->mbc, false);
snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM,
WM8958_DSP2_ENA, WM8958_DSP2_ENA); WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied MBC settings use them */ /* If we've got user supplied MBC settings use them */
...@@ -215,37 +215,37 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) ...@@ -215,37 +215,37 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
= &control->pdata.mbc_cfgs[wm8994->mbc_cfg]; = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++)
snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1, snd_soc_component_write(component, i + WM8958_MBC_BAND_1_K_1,
cfg->coeff_regs[i]); cfg->coeff_regs[i]);
for (i = 0; i < ARRAY_SIZE(cfg->cutoff_regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->cutoff_regs); i++)
snd_soc_write(codec, snd_soc_component_write(component,
i + WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_1, i + WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_1,
cfg->cutoff_regs[i]); cfg->cutoff_regs[i]);
} }
/* Run the DSP */ /* Run the DSP */
snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL,
WM8958_DSP2_RUNR); WM8958_DSP2_RUNR);
/* And we're off! */ /* And we're off! */
snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG,
WM8958_MBC_ENA | WM8958_MBC_ENA |
WM8958_MBC_SEL_MASK, WM8958_MBC_SEL_MASK,
path << WM8958_MBC_SEL_SHIFT | path << WM8958_MBC_SEL_SHIFT |
WM8958_MBC_ENA); WM8958_MBC_ENA);
} }
static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) static void wm8958_dsp_start_vss(struct snd_soc_component *component, int path)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int i, ena; int i, ena;
if (wm8994->mbc_vss) if (wm8994->mbc_vss)
wm8958_dsp2_fw(codec, "MBC+VSS", wm8994->mbc_vss, false); wm8958_dsp2_fw(component, "MBC+VSS", wm8994->mbc_vss, false);
snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM,
WM8958_DSP2_ENA, WM8958_DSP2_ENA); WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied settings use them */ /* If we've got user supplied settings use them */
...@@ -254,7 +254,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) ...@@ -254,7 +254,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
= &control->pdata.mbc_cfgs[wm8994->mbc_cfg]; = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++)
snd_soc_write(codec, i + 0x2800, snd_soc_component_write(component, i + 0x2800,
cfg->combined_regs[i]); cfg->combined_regs[i]);
} }
...@@ -263,7 +263,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) ...@@ -263,7 +263,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
= &control->pdata.vss_cfgs[wm8994->vss_cfg]; = &control->pdata.vss_cfgs[wm8994->vss_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2600, cfg->regs[i]); snd_soc_component_write(component, i + 0x2600, cfg->regs[i]);
} }
if (control->pdata.num_vss_hpf_cfgs) { if (control->pdata.num_vss_hpf_cfgs) {
...@@ -271,11 +271,11 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) ...@@ -271,11 +271,11 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
= &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg]; = &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2400, cfg->regs[i]); snd_soc_component_write(component, i + 0x2400, cfg->regs[i]);
} }
/* Run the DSP */ /* Run the DSP */
snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL,
WM8958_DSP2_RUNR); WM8958_DSP2_RUNR);
/* Enable the algorithms we've selected */ /* Enable the algorithms we've selected */
...@@ -289,23 +289,23 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) ...@@ -289,23 +289,23 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
if (wm8994->vss_ena[path]) if (wm8994->vss_ena[path])
ena |= 0x1; ena |= 0x1;
snd_soc_write(codec, 0x2201, ena); snd_soc_component_write(component, 0x2201, ena);
/* Switch the DSP into the data path */ /* Switch the DSP into the data path */
snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG,
WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA,
path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA);
} }
static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) static void wm8958_dsp_start_enh_eq(struct snd_soc_component *component, int path)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int i; int i;
wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false); wm8958_dsp2_fw(component, "ENH_EQ", wm8994->enh_eq, false);
snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM,
WM8958_DSP2_ENA, WM8958_DSP2_ENA); WM8958_DSP2_ENA, WM8958_DSP2_ENA);
/* If we've got user supplied settings use them */ /* If we've got user supplied settings use them */
...@@ -314,24 +314,24 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) ...@@ -314,24 +314,24 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path)
= &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg]; = &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg];
for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
snd_soc_write(codec, i + 0x2200, snd_soc_component_write(component, i + 0x2200,
cfg->regs[i]); cfg->regs[i]);
} }
/* Run the DSP */ /* Run the DSP */
snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL,
WM8958_DSP2_RUNR); WM8958_DSP2_RUNR);
/* Switch the DSP into the data path */ /* Switch the DSP into the data path */
snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG,
WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA,
path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA);
} }
static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) static void wm8958_dsp_apply(struct snd_soc_component *component, int path, int start)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int pwr_reg = snd_soc_read(codec, WM8994_POWER_MANAGEMENT_5); int pwr_reg = snd_soc_component_read32(component, WM8994_POWER_MANAGEMENT_5);
int ena, reg, aif; int ena, reg, aif;
switch (path) { switch (path) {
...@@ -359,9 +359,9 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) ...@@ -359,9 +359,9 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start)
if (!pwr_reg) if (!pwr_reg)
ena = 0; ena = 0;
reg = snd_soc_read(codec, WM8958_DSP2_PROGRAM); reg = snd_soc_component_read32(component, WM8958_DSP2_PROGRAM);
dev_dbg(codec->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n", dev_dbg(component->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n",
path, wm8994->dsp_active, start, pwr_reg, reg); path, wm8994->dsp_active, start, pwr_reg, reg);
if (start && ena) { if (start && ena) {
...@@ -370,29 +370,29 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) ...@@ -370,29 +370,29 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start)
return; return;
/* If either AIFnCLK is not yet enabled postpone */ /* If either AIFnCLK is not yet enabled postpone */
if (!(snd_soc_read(codec, WM8994_AIF1_CLOCKING_1) if (!(snd_soc_component_read32(component, WM8994_AIF1_CLOCKING_1)
& WM8994_AIF1CLK_ENA_MASK) && & WM8994_AIF1CLK_ENA_MASK) &&
!(snd_soc_read(codec, WM8994_AIF2_CLOCKING_1) !(snd_soc_component_read32(component, WM8994_AIF2_CLOCKING_1)
& WM8994_AIF2CLK_ENA_MASK)) & WM8994_AIF2CLK_ENA_MASK))
return; return;
/* Switch the clock over to the appropriate AIF */ /* Switch the clock over to the appropriate AIF */
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8958_DSP2CLK_SRC | WM8958_DSP2CLK_ENA, WM8958_DSP2CLK_SRC | WM8958_DSP2CLK_ENA,
aif << WM8958_DSP2CLK_SRC_SHIFT | aif << WM8958_DSP2CLK_SRC_SHIFT |
WM8958_DSP2CLK_ENA); WM8958_DSP2CLK_ENA);
if (wm8994->enh_eq_ena[path]) if (wm8994->enh_eq_ena[path])
wm8958_dsp_start_enh_eq(codec, path); wm8958_dsp_start_enh_eq(component, path);
else if (wm8994->vss_ena[path] || wm8994->hpf1_ena[path] || else if (wm8994->vss_ena[path] || wm8994->hpf1_ena[path] ||
wm8994->hpf2_ena[path]) wm8994->hpf2_ena[path])
wm8958_dsp_start_vss(codec, path); wm8958_dsp_start_vss(component, path);
else if (wm8994->mbc_ena[path]) else if (wm8994->mbc_ena[path])
wm8958_dsp_start_mbc(codec, path); wm8958_dsp_start_mbc(component, path);
wm8994->dsp_active = path; wm8994->dsp_active = path;
dev_dbg(codec->dev, "DSP running in path %d\n", path); dev_dbg(component->dev, "DSP running in path %d\n", path);
} }
if (!start && wm8994->dsp_active == path) { if (!start && wm8994->dsp_active == path) {
...@@ -400,37 +400,37 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) ...@@ -400,37 +400,37 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start)
if (!(reg & WM8958_DSP2_ENA)) if (!(reg & WM8958_DSP2_ENA))
return; return;
snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG,
WM8958_MBC_ENA, 0); WM8958_MBC_ENA, 0);
snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL,
WM8958_DSP2_STOP); WM8958_DSP2_STOP);
snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM,
WM8958_DSP2_ENA, 0); WM8958_DSP2_ENA, 0);
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8958_DSP2CLK_ENA, 0); WM8958_DSP2CLK_ENA, 0);
wm8994->dsp_active = -1; wm8994->dsp_active = -1;
dev_dbg(codec->dev, "DSP stopped\n"); dev_dbg(component->dev, "DSP stopped\n");
} }
} }
int wm8958_aif_ev(struct snd_soc_dapm_widget *w, int wm8958_aif_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int i; int i;
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
wm8958_dsp_apply(codec, i, 1); wm8958_dsp_apply(component, i, 1);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
wm8958_dsp_apply(codec, i, 0); wm8958_dsp_apply(component, i, 0);
break; break;
} }
...@@ -456,14 +456,14 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) ...@@ -456,14 +456,14 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif)
static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.enumerated.item[0]; int value = ucontrol->value.enumerated.item[0];
int reg; int reg;
/* Don't allow on the fly reconfiguration */ /* Don't allow on the fly reconfiguration */
reg = snd_soc_read(codec, WM8994_CLOCKING_1); reg = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (reg < 0 || reg & WM8958_DSP2CLK_ENA) if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY; return -EBUSY;
...@@ -478,8 +478,8 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, ...@@ -478,8 +478,8 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg;
...@@ -500,8 +500,8 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, ...@@ -500,8 +500,8 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int mbc = kcontrol->private_value; int mbc = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc];
...@@ -512,8 +512,8 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, ...@@ -512,8 +512,8 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int mbc = kcontrol->private_value; int mbc = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0])
return 0; return 0;
...@@ -522,7 +522,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, ...@@ -522,7 +522,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
return -EINVAL; return -EINVAL;
if (wm8958_dsp2_busy(wm8994, mbc)) { if (wm8958_dsp2_busy(wm8994, mbc)) {
dev_dbg(codec->dev, "DSP2 active on %d already\n", mbc); dev_dbg(component->dev, "DSP2 active on %d already\n", mbc);
return -EBUSY; return -EBUSY;
} }
...@@ -531,7 +531,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, ...@@ -531,7 +531,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
wm8994->mbc_ena[mbc] = ucontrol->value.integer.value[0]; wm8994->mbc_ena[mbc] = ucontrol->value.integer.value[0];
wm8958_dsp_apply(codec, mbc, wm8994->mbc_ena[mbc]); wm8958_dsp_apply(component, mbc, wm8994->mbc_ena[mbc]);
return 0; return 0;
} }
...@@ -546,14 +546,14 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, ...@@ -546,14 +546,14 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol,
static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.enumerated.item[0]; int value = ucontrol->value.enumerated.item[0];
int reg; int reg;
/* Don't allow on the fly reconfiguration */ /* Don't allow on the fly reconfiguration */
reg = snd_soc_read(codec, WM8994_CLOCKING_1); reg = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (reg < 0 || reg & WM8958_DSP2CLK_ENA) if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY; return -EBUSY;
...@@ -568,8 +568,8 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, ...@@ -568,8 +568,8 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; ucontrol->value.enumerated.item[0] = wm8994->vss_cfg;
...@@ -579,14 +579,14 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, ...@@ -579,14 +579,14 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol,
static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.enumerated.item[0]; int value = ucontrol->value.enumerated.item[0];
int reg; int reg;
/* Don't allow on the fly reconfiguration */ /* Don't allow on the fly reconfiguration */
reg = snd_soc_read(codec, WM8994_CLOCKING_1); reg = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (reg < 0 || reg & WM8958_DSP2CLK_ENA) if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY; return -EBUSY;
...@@ -601,8 +601,8 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, ...@@ -601,8 +601,8 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg;
...@@ -623,8 +623,8 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, ...@@ -623,8 +623,8 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int vss = kcontrol->private_value; int vss = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; ucontrol->value.integer.value[0] = wm8994->vss_ena[vss];
...@@ -635,8 +635,8 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, ...@@ -635,8 +635,8 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int vss = kcontrol->private_value; int vss = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0])
return 0; return 0;
...@@ -648,7 +648,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, ...@@ -648,7 +648,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol,
return -ENODEV; return -ENODEV;
if (wm8958_dsp2_busy(wm8994, vss)) { if (wm8958_dsp2_busy(wm8994, vss)) {
dev_dbg(codec->dev, "DSP2 active on %d already\n", vss); dev_dbg(component->dev, "DSP2 active on %d already\n", vss);
return -EBUSY; return -EBUSY;
} }
...@@ -657,7 +657,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, ...@@ -657,7 +657,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol,
wm8994->vss_ena[vss] = ucontrol->value.integer.value[0]; wm8994->vss_ena[vss] = ucontrol->value.integer.value[0];
wm8958_dsp_apply(codec, vss, wm8994->vss_ena[vss]); wm8958_dsp_apply(component, vss, wm8994->vss_ena[vss]);
return 0; return 0;
} }
...@@ -684,8 +684,8 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol, ...@@ -684,8 +684,8 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int hpf = kcontrol->private_value; int hpf = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (hpf < 3) if (hpf < 3)
ucontrol->value.integer.value[0] = wm8994->hpf1_ena[hpf % 3]; ucontrol->value.integer.value[0] = wm8994->hpf1_ena[hpf % 3];
...@@ -699,8 +699,8 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, ...@@ -699,8 +699,8 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int hpf = kcontrol->private_value; int hpf = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (hpf < 3) { if (hpf < 3) {
if (wm8994->hpf1_ena[hpf % 3] == if (wm8994->hpf1_ena[hpf % 3] ==
...@@ -719,7 +719,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, ...@@ -719,7 +719,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
return -ENODEV; return -ENODEV;
if (wm8958_dsp2_busy(wm8994, hpf % 3)) { if (wm8958_dsp2_busy(wm8994, hpf % 3)) {
dev_dbg(codec->dev, "DSP2 active on %d already\n", hpf); dev_dbg(component->dev, "DSP2 active on %d already\n", hpf);
return -EBUSY; return -EBUSY;
} }
...@@ -731,7 +731,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, ...@@ -731,7 +731,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
else else
wm8994->hpf2_ena[hpf % 3] = ucontrol->value.integer.value[0]; wm8994->hpf2_ena[hpf % 3] = ucontrol->value.integer.value[0];
wm8958_dsp_apply(codec, hpf % 3, ucontrol->value.integer.value[0]); wm8958_dsp_apply(component, hpf % 3, ucontrol->value.integer.value[0]);
return 0; return 0;
} }
...@@ -746,14 +746,14 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, ...@@ -746,14 +746,14 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol,
static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int value = ucontrol->value.enumerated.item[0]; int value = ucontrol->value.enumerated.item[0];
int reg; int reg;
/* Don't allow on the fly reconfiguration */ /* Don't allow on the fly reconfiguration */
reg = snd_soc_read(codec, WM8994_CLOCKING_1); reg = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (reg < 0 || reg & WM8958_DSP2CLK_ENA) if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
return -EBUSY; return -EBUSY;
...@@ -768,8 +768,8 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, ...@@ -768,8 +768,8 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg;
...@@ -790,8 +790,8 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol, ...@@ -790,8 +790,8 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int eq = kcontrol->private_value; int eq = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq];
...@@ -802,8 +802,8 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, ...@@ -802,8 +802,8 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
int eq = kcontrol->private_value; int eq = kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0])
return 0; return 0;
...@@ -815,7 +815,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, ...@@ -815,7 +815,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol,
return -ENODEV; return -ENODEV;
if (wm8958_dsp2_busy(wm8994, eq)) { if (wm8958_dsp2_busy(wm8994, eq)) {
dev_dbg(codec->dev, "DSP2 active on %d already\n", eq); dev_dbg(component->dev, "DSP2 active on %d already\n", eq);
return -EBUSY; return -EBUSY;
} }
...@@ -825,7 +825,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, ...@@ -825,7 +825,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol,
wm8994->enh_eq_ena[eq] = ucontrol->value.integer.value[0]; wm8994->enh_eq_ena[eq] = ucontrol->value.integer.value[0];
wm8958_dsp_apply(codec, eq, ucontrol->value.integer.value[0]); wm8958_dsp_apply(component, eq, ucontrol->value.integer.value[0]);
return 0; return 0;
} }
...@@ -863,10 +863,10 @@ WM8958_ENH_EQ_SWITCH("AIF2DAC Enhanced EQ Switch", 2), ...@@ -863,10 +863,10 @@ WM8958_ENH_EQ_SWITCH("AIF2DAC Enhanced EQ Switch", 2),
static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context) static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context)
{ {
struct snd_soc_codec *codec = context; struct snd_soc_component *component = context;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (fw && (wm8958_dsp2_fw(codec, "ENH_EQ", fw, true) == 0)) { if (fw && (wm8958_dsp2_fw(component, "ENH_EQ", fw, true) == 0)) {
mutex_lock(&wm8994->fw_lock); mutex_lock(&wm8994->fw_lock);
wm8994->enh_eq = fw; wm8994->enh_eq = fw;
mutex_unlock(&wm8994->fw_lock); mutex_unlock(&wm8994->fw_lock);
...@@ -875,10 +875,10 @@ static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context) ...@@ -875,10 +875,10 @@ static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context)
static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context) static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
{ {
struct snd_soc_codec *codec = context; struct snd_soc_component *component = context;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (fw && (wm8958_dsp2_fw(codec, "MBC+VSS", fw, true) == 0)) { if (fw && (wm8958_dsp2_fw(component, "MBC+VSS", fw, true) == 0)) {
mutex_lock(&wm8994->fw_lock); mutex_lock(&wm8994->fw_lock);
wm8994->mbc_vss = fw; wm8994->mbc_vss = fw;
mutex_unlock(&wm8994->fw_lock); mutex_unlock(&wm8994->fw_lock);
...@@ -887,43 +887,43 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context) ...@@ -887,43 +887,43 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
static void wm8958_mbc_loaded(const struct firmware *fw, void *context) static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
{ {
struct snd_soc_codec *codec = context; struct snd_soc_component *component = context;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) { if (fw && (wm8958_dsp2_fw(component, "MBC", fw, true) == 0)) {
mutex_lock(&wm8994->fw_lock); mutex_lock(&wm8994->fw_lock);
wm8994->mbc = fw; wm8994->mbc = fw;
mutex_unlock(&wm8994->fw_lock); mutex_unlock(&wm8994->fw_lock);
} }
} }
void wm8958_dsp2_init(struct snd_soc_codec *codec) void wm8958_dsp2_init(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int ret, i; int ret, i;
wm8994->dsp_active = -1; wm8994->dsp_active = -1;
snd_soc_add_codec_controls(codec, wm8958_mbc_snd_controls, snd_soc_add_component_controls(component, wm8958_mbc_snd_controls,
ARRAY_SIZE(wm8958_mbc_snd_controls)); ARRAY_SIZE(wm8958_mbc_snd_controls));
snd_soc_add_codec_controls(codec, wm8958_vss_snd_controls, snd_soc_add_component_controls(component, wm8958_vss_snd_controls,
ARRAY_SIZE(wm8958_vss_snd_controls)); ARRAY_SIZE(wm8958_vss_snd_controls));
snd_soc_add_codec_controls(codec, wm8958_enh_eq_snd_controls, snd_soc_add_component_controls(component, wm8958_enh_eq_snd_controls,
ARRAY_SIZE(wm8958_enh_eq_snd_controls)); ARRAY_SIZE(wm8958_enh_eq_snd_controls));
/* We don't *require* firmware and don't want to delay boot */ /* We don't *require* firmware and don't want to delay boot */
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_mbc.wfw", codec->dev, GFP_KERNEL, "wm8958_mbc.wfw", component->dev, GFP_KERNEL,
codec, wm8958_mbc_loaded); component, wm8958_mbc_loaded);
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL, "wm8958_mbc_vss.wfw", component->dev, GFP_KERNEL,
codec, wm8958_mbc_vss_loaded); component, wm8958_mbc_vss_loaded);
request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
"wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL, "wm8958_enh_eq.wfw", component->dev, GFP_KERNEL,
codec, wm8958_enh_eq_loaded); component, wm8958_enh_eq_loaded);
if (pdata->num_mbc_cfgs) { if (pdata->num_mbc_cfgs) {
struct snd_kcontrol_new control[] = { struct snd_kcontrol_new control[] = {
...@@ -943,10 +943,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) ...@@ -943,10 +943,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
wm8994->mbc_enum.items = pdata->num_mbc_cfgs; wm8994->mbc_enum.items = pdata->num_mbc_cfgs;
wm8994->mbc_enum.texts = wm8994->mbc_texts; wm8994->mbc_enum.texts = wm8994->mbc_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, ret = snd_soc_add_component_controls(wm8994->hubs.component,
control, 1); control, 1);
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add MBC mode controls: %d\n", ret); "Failed to add MBC mode controls: %d\n", ret);
} }
...@@ -968,10 +968,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) ...@@ -968,10 +968,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
wm8994->vss_enum.items = pdata->num_vss_cfgs; wm8994->vss_enum.items = pdata->num_vss_cfgs;
wm8994->vss_enum.texts = wm8994->vss_texts; wm8994->vss_enum.texts = wm8994->vss_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, ret = snd_soc_add_component_controls(wm8994->hubs.component,
control, 1); control, 1);
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add VSS mode controls: %d\n", ret); "Failed to add VSS mode controls: %d\n", ret);
} }
...@@ -994,10 +994,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) ...@@ -994,10 +994,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
wm8994->vss_hpf_enum.items = pdata->num_vss_hpf_cfgs; wm8994->vss_hpf_enum.items = pdata->num_vss_hpf_cfgs;
wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts; wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, ret = snd_soc_add_component_controls(wm8994->hubs.component,
control, 1); control, 1);
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add VSS HPFmode controls: %d\n", "Failed to add VSS HPFmode controls: %d\n",
ret); ret);
} }
...@@ -1021,10 +1021,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) ...@@ -1021,10 +1021,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
wm8994->enh_eq_enum.items = pdata->num_enh_eq_cfgs; wm8994->enh_eq_enum.items = pdata->num_enh_eq_cfgs;
wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts; wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, ret = snd_soc_add_component_controls(wm8994->hubs.component,
control, 1); control, 1);
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add enhanced EQ controls: %d\n", "Failed to add enhanced EQ controls: %d\n",
ret); ret);
} }
......
...@@ -133,7 +133,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv, ...@@ -133,7 +133,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv,
static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
int reg = kcontrol->private_value & 0xff; int reg = kcontrol->private_value & 0xff;
int ret; int ret;
u16 val; u16 val;
...@@ -143,8 +143,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, ...@@ -143,8 +143,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol,
return ret; return ret;
/* now hit the volume update bits (always bit 8) */ /* now hit the volume update bits (always bit 8) */
val = snd_soc_read(codec, reg); val = snd_soc_component_read32(component, reg);
return snd_soc_write(codec, reg, val | 0x0100); return snd_soc_component_write(component, reg, val | 0x0100);
} }
static const char *wm8991_digital_sidetone[] = static const char *wm8991_digital_sidetone[] =
...@@ -361,14 +361,14 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = { ...@@ -361,14 +361,14 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = {
static int outmixer_event(struct snd_soc_dapm_widget *w, static int outmixer_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
u32 reg_shift = kcontrol->private_value & 0xfff; u32 reg_shift = kcontrol->private_value & 0xfff;
int ret = 0; int ret = 0;
u16 reg; u16 reg;
switch (reg_shift) { switch (reg_shift) {
case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8):
reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1); reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER1);
if (reg & WM8991_LDLO) { if (reg & WM8991_LDLO) {
printk(KERN_WARNING printk(KERN_WARNING
"Cannot set as Output Mixer 1 LDLO Set\n"); "Cannot set as Output Mixer 1 LDLO Set\n");
...@@ -377,7 +377,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, ...@@ -377,7 +377,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
break; break;
case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8):
reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2); reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER2);
if (reg & WM8991_RDRO) { if (reg & WM8991_RDRO) {
printk(KERN_WARNING printk(KERN_WARNING
"Cannot set as Output Mixer 2 RDRO Set\n"); "Cannot set as Output Mixer 2 RDRO Set\n");
...@@ -386,7 +386,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, ...@@ -386,7 +386,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
break; break;
case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8):
reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER);
if (reg & WM8991_LDSPK) { if (reg & WM8991_LDSPK) {
printk(KERN_WARNING printk(KERN_WARNING
"Cannot set as Speaker Mixer LDSPK Set\n"); "Cannot set as Speaker Mixer LDSPK Set\n");
...@@ -395,7 +395,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, ...@@ -395,7 +395,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w,
break; break;
case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8):
reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER);
if (reg & WM8991_RDSPK) { if (reg & WM8991_RDSPK) {
printk(KERN_WARNING printk(KERN_WARNING
"Cannot set as Speaker Mixer RDSPK Set\n"); "Cannot set as Speaker Mixer RDSPK Set\n");
...@@ -927,31 +927,31 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, ...@@ -927,31 +927,31 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai,
int pll_id, int src, unsigned int freq_in, unsigned int freq_out) int pll_id, int src, unsigned int freq_in, unsigned int freq_out)
{ {
u16 reg; u16 reg;
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
struct _pll_div pll_div; struct _pll_div pll_div;
if (freq_in && freq_out) { if (freq_in && freq_out) {
pll_factors(&pll_div, freq_out * 4, freq_in); pll_factors(&pll_div, freq_out * 4, freq_in);
/* Turn on PLL */ /* Turn on PLL */
reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2);
reg |= WM8991_PLL_ENA; reg |= WM8991_PLL_ENA;
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg);
/* sysclk comes from PLL */ /* sysclk comes from PLL */
reg = snd_soc_read(codec, WM8991_CLOCKING_2); reg = snd_soc_component_read32(component, WM8991_CLOCKING_2);
snd_soc_write(codec, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC); snd_soc_component_write(component, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC);
/* set up N , fractional mode and pre-divisor if necessary */ /* set up N , fractional mode and pre-divisor if necessary */
snd_soc_write(codec, WM8991_PLL1, pll_div.n | WM8991_SDM | snd_soc_component_write(component, WM8991_PLL1, pll_div.n | WM8991_SDM |
(pll_div.div2 ? WM8991_PRESCALE : 0)); (pll_div.div2 ? WM8991_PRESCALE : 0));
snd_soc_write(codec, WM8991_PLL2, (u8)(pll_div.k>>8)); snd_soc_component_write(component, WM8991_PLL2, (u8)(pll_div.k>>8));
snd_soc_write(codec, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); snd_soc_component_write(component, WM8991_PLL3, (u8)(pll_div.k & 0xFF));
} else { } else {
/* Turn on PLL */ /* Turn on PLL */
reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2);
reg &= ~WM8991_PLL_ENA; reg &= ~WM8991_PLL_ENA;
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg);
} }
return 0; return 0;
} }
...@@ -962,11 +962,11 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, ...@@ -962,11 +962,11 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai,
static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8991_set_dai_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;
u16 audio1, audio3; u16 audio1, audio3;
audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1);
audio3 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_3); audio3 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_3);
/* set master/slave audio interface */ /* set master/slave audio interface */
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -1007,37 +1007,37 @@ static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, ...@@ -1007,37 +1007,37 @@ static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1);
snd_soc_write(codec, WM8991_AUDIO_INTERFACE_3, audio3); snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_3, audio3);
return 0; return 0;
} }
static int wm8991_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8991_set_dai_clkdiv(struct snd_soc_dai *codec_dai,
int div_id, int div) int div_id, int div)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
u16 reg; u16 reg;
switch (div_id) { switch (div_id) {
case WM8991_MCLK_DIV: case WM8991_MCLK_DIV:
reg = snd_soc_read(codec, WM8991_CLOCKING_2) & reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) &
~WM8991_MCLK_DIV_MASK; ~WM8991_MCLK_DIV_MASK;
snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div);
break; break;
case WM8991_DACCLK_DIV: case WM8991_DACCLK_DIV:
reg = snd_soc_read(codec, WM8991_CLOCKING_2) & reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) &
~WM8991_DAC_CLKDIV_MASK; ~WM8991_DAC_CLKDIV_MASK;
snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div);
break; break;
case WM8991_ADCCLK_DIV: case WM8991_ADCCLK_DIV:
reg = snd_soc_read(codec, WM8991_CLOCKING_2) & reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) &
~WM8991_ADC_CLKDIV_MASK; ~WM8991_ADC_CLKDIV_MASK;
snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div);
break; break;
case WM8991_BCLK_DIV: case WM8991_BCLK_DIV:
reg = snd_soc_read(codec, WM8991_CLOCKING_1) & reg = snd_soc_component_read32(component, WM8991_CLOCKING_1) &
~WM8991_BCLK_DIV_MASK; ~WM8991_BCLK_DIV_MASK;
snd_soc_write(codec, WM8991_CLOCKING_1, reg | div); snd_soc_component_write(component, WM8991_CLOCKING_1, reg | div);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -1053,8 +1053,8 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, ...@@ -1053,8 +1053,8 @@ static int wm8991_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;
u16 audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); u16 audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1);
audio1 &= ~WM8991_AIF_WL_MASK; audio1 &= ~WM8991_AIF_WL_MASK;
/* bit size */ /* bit size */
...@@ -1072,27 +1072,27 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, ...@@ -1072,27 +1072,27 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream,
break; break;
} }
snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1);
return 0; return 0;
} }
static int wm8991_mute(struct snd_soc_dai *dai, int mute) static int wm8991_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
u16 val; u16 val;
val = snd_soc_read(codec, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; val = snd_soc_component_read32(component, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE;
if (mute) if (mute)
snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE);
else else
snd_soc_write(codec, WM8991_DAC_CTRL, val); snd_soc_component_write(component, WM8991_DAC_CTRL, val);
return 0; return 0;
} }
static int wm8991_set_bias_level(struct snd_soc_codec *codec, static int wm8991_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8991_priv *wm8991 = snd_soc_codec_get_drvdata(codec); struct wm8991_priv *wm8991 = snd_soc_component_get_drvdata(component);
u16 val; u16 val;
switch (level) { switch (level) {
...@@ -1101,22 +1101,22 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, ...@@ -1101,22 +1101,22 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* VMID=2*50k */ /* VMID=2*50k */
val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) &
~WM8991_VMID_MODE_MASK; ~WM8991_VMID_MODE_MASK;
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x2); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x2);
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) {
regcache_sync(wm8991->regmap); regcache_sync(wm8991->regmap);
/* Enable all output discharge bits */ /* Enable all output discharge bits */
snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE |
WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_RLINE | WM8991_DIS_OUT3 |
WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_OUT4 | WM8991_DIS_LOUT |
WM8991_DIS_ROUT); WM8991_DIS_ROUT);
/* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST |
WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFDCOPEN | WM8991_POBCTRL |
WM8991_VMIDTOG); WM8991_VMIDTOG);
...@@ -1124,78 +1124,78 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, ...@@ -1124,78 +1124,78 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec,
msleep(300); msleep(300);
/* Disable VMIDTOG */ /* Disable VMIDTOG */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST |
WM8991_BUFDCOPEN | WM8991_POBCTRL); WM8991_BUFDCOPEN | WM8991_POBCTRL);
/* disable all output discharge bits */ /* disable all output discharge bits */
snd_soc_write(codec, WM8991_ANTIPOP1, 0); snd_soc_component_write(component, WM8991_ANTIPOP1, 0);
/* Enable outputs */ /* Enable outputs */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1b00); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1b00);
msleep(50); msleep(50);
/* Enable VMID at 2x50k */ /* Enable VMID at 2x50k */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f02); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f02);
msleep(100); msleep(100);
/* Enable VREF */ /* Enable VREF */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03);
msleep(600); msleep(600);
/* Enable BUFIOEN */ /* Enable BUFIOEN */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST |
WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFDCOPEN | WM8991_POBCTRL |
WM8991_BUFIOEN); WM8991_BUFIOEN);
/* Disable outputs */ /* Disable outputs */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x3); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x3);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ /* disable POBCTRL, SOFT_ST and BUFDCOPEN */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_BUFIOEN); snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_BUFIOEN);
} }
/* VMID=2*250k */ /* VMID=2*250k */
val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) &
~WM8991_VMID_MODE_MASK; ~WM8991_VMID_MODE_MASK;
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x4); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x4);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* Enable POBCTRL and SOFT_ST */ /* Enable POBCTRL and SOFT_ST */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST |
WM8991_POBCTRL | WM8991_BUFIOEN); WM8991_POBCTRL | WM8991_BUFIOEN);
/* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */
snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST |
WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFDCOPEN | WM8991_POBCTRL |
WM8991_BUFIOEN); WM8991_BUFIOEN);
/* mute DAC */ /* mute DAC */
val = snd_soc_read(codec, WM8991_DAC_CTRL); val = snd_soc_component_read32(component, WM8991_DAC_CTRL);
snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE);
/* Enable any disabled outputs */ /* Enable any disabled outputs */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03);
/* Disable VMID */ /* Disable VMID */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f01); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f01);
msleep(300); msleep(300);
/* Enable all output discharge bits */ /* Enable all output discharge bits */
snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE |
WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_RLINE | WM8991_DIS_OUT3 |
WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_OUT4 | WM8991_DIS_LOUT |
WM8991_DIS_ROUT); WM8991_DIS_ROUT);
/* Disable VREF */ /* Disable VREF */
snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x0); snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x0);
/* disable POBCTRL, SOFT_ST and BUFDCOPEN */ /* disable POBCTRL, SOFT_ST and BUFDCOPEN */
snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); snd_soc_component_write(component, WM8991_ANTIPOP2, 0x0);
regcache_mark_dirty(wm8991->regmap); regcache_mark_dirty(wm8991->regmap);
break; break;
} }
...@@ -1242,18 +1242,19 @@ static struct snd_soc_dai_driver wm8991_dai = { ...@@ -1242,18 +1242,19 @@ static struct snd_soc_dai_driver wm8991_dai = {
.ops = &wm8991_ops .ops = &wm8991_ops
}; };
static const struct snd_soc_codec_driver soc_codec_dev_wm8991 = { static const struct snd_soc_component_driver soc_component_dev_wm8991 = {
.set_bias_level = wm8991_set_bias_level, .set_bias_level = wm8991_set_bias_level,
.suspend_bias_off = true, .controls = wm8991_snd_controls,
.num_controls = ARRAY_SIZE(wm8991_snd_controls),
.component_driver = { .dapm_widgets = wm8991_dapm_widgets,
.controls = wm8991_snd_controls, .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets),
.num_controls = ARRAY_SIZE(wm8991_snd_controls), .dapm_routes = wm8991_dapm_routes,
.dapm_widgets = wm8991_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes),
.num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), .suspend_bias_off = 1,
.dapm_routes = wm8991_dapm_routes, .idle_bias_on = 1,
.num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static const struct regmap_config wm8991_regmap = { static const struct regmap_config wm8991_regmap = {
...@@ -1319,19 +1320,12 @@ static int wm8991_i2c_probe(struct i2c_client *i2c, ...@@ -1319,19 +1320,12 @@ static int wm8991_i2c_probe(struct i2c_client *i2c,
regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME,
0x50 | (1<<8)); 0x50 | (1<<8));
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8991, &wm8991_dai, 1); &soc_component_dev_wm8991, &wm8991_dai, 1);
return ret; return ret;
} }
static int wm8991_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8991_i2c_id[] = { static const struct i2c_device_id wm8991_i2c_id[] = {
{ "wm8991", 0 }, { "wm8991", 0 },
{ } { }
...@@ -1343,7 +1337,6 @@ static struct i2c_driver wm8991_i2c_driver = { ...@@ -1343,7 +1337,6 @@ static struct i2c_driver wm8991_i2c_driver = {
.name = "wm8991", .name = "wm8991",
}, },
.probe = wm8991_i2c_probe, .probe = wm8991_i2c_probe,
.remove = wm8991_i2c_remove,
.id_table = wm8991_i2c_id, .id_table = wm8991_i2c_id,
}; };
......
...@@ -466,11 +466,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, ...@@ -466,11 +466,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
return 0; return 0;
} }
static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
struct i2c_client *i2c = to_i2c_client(codec->dev); struct i2c_client *i2c = to_i2c_client(component->dev);
u16 reg1, reg4, reg5; u16 reg1, reg4, reg5;
struct _fll_div fll_div; struct _fll_div fll_div;
unsigned int timeout; unsigned int timeout;
...@@ -482,13 +482,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -482,13 +482,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
/* Disable the FLL */ /* Disable the FLL */
if (Fout == 0) { if (Fout == 0) {
dev_dbg(codec->dev, "FLL disabled\n"); dev_dbg(component->dev, "FLL disabled\n");
wm8993->fll_fref = 0; wm8993->fll_fref = 0;
wm8993->fll_fout = 0; wm8993->fll_fout = 0;
reg1 = snd_soc_read(codec, WM8993_FLL_CONTROL_1); reg1 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_1);
reg1 &= ~WM8993_FLL_ENA; reg1 &= ~WM8993_FLL_ENA;
snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1);
return 0; return 0;
} }
...@@ -497,7 +497,7 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -497,7 +497,7 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
if (ret != 0) if (ret != 0)
return ret; return ret;
reg5 = snd_soc_read(codec, WM8993_FLL_CONTROL_5); reg5 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_5);
reg5 &= ~WM8993_FLL_CLK_SRC_MASK; reg5 &= ~WM8993_FLL_CLK_SRC_MASK;
switch (fll_id) { switch (fll_id) {
...@@ -513,36 +513,36 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -513,36 +513,36 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
break; break;
default: default:
dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); dev_err(component->dev, "Unknown FLL ID %d\n", fll_id);
return -EINVAL; return -EINVAL;
} }
/* Any FLL configuration change requires that the FLL be /* Any FLL configuration change requires that the FLL be
* disabled first. */ * disabled first. */
reg1 = snd_soc_read(codec, WM8993_FLL_CONTROL_1); reg1 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_1);
reg1 &= ~WM8993_FLL_ENA; reg1 &= ~WM8993_FLL_ENA;
snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1);
/* Apply the configuration */ /* Apply the configuration */
if (fll_div.k) if (fll_div.k)
reg1 |= WM8993_FLL_FRAC_MASK; reg1 |= WM8993_FLL_FRAC_MASK;
else else
reg1 &= ~WM8993_FLL_FRAC_MASK; reg1 &= ~WM8993_FLL_FRAC_MASK;
snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1);
snd_soc_write(codec, WM8993_FLL_CONTROL_2, snd_soc_component_write(component, WM8993_FLL_CONTROL_2,
(fll_div.fll_outdiv << WM8993_FLL_OUTDIV_SHIFT) | (fll_div.fll_outdiv << WM8993_FLL_OUTDIV_SHIFT) |
(fll_div.fll_fratio << WM8993_FLL_FRATIO_SHIFT)); (fll_div.fll_fratio << WM8993_FLL_FRATIO_SHIFT));
snd_soc_write(codec, WM8993_FLL_CONTROL_3, fll_div.k); snd_soc_component_write(component, WM8993_FLL_CONTROL_3, fll_div.k);
reg4 = snd_soc_read(codec, WM8993_FLL_CONTROL_4); reg4 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_4);
reg4 &= ~WM8993_FLL_N_MASK; reg4 &= ~WM8993_FLL_N_MASK;
reg4 |= fll_div.n << WM8993_FLL_N_SHIFT; reg4 |= fll_div.n << WM8993_FLL_N_SHIFT;
snd_soc_write(codec, WM8993_FLL_CONTROL_4, reg4); snd_soc_component_write(component, WM8993_FLL_CONTROL_4, reg4);
reg5 &= ~WM8993_FLL_CLK_REF_DIV_MASK; reg5 &= ~WM8993_FLL_CLK_REF_DIV_MASK;
reg5 |= fll_div.fll_clk_ref_div << WM8993_FLL_CLK_REF_DIV_SHIFT; reg5 |= fll_div.fll_clk_ref_div << WM8993_FLL_CLK_REF_DIV_SHIFT;
snd_soc_write(codec, WM8993_FLL_CONTROL_5, reg5); snd_soc_component_write(component, WM8993_FLL_CONTROL_5, reg5);
/* If we've got an interrupt wired up make sure we get it */ /* If we've got an interrupt wired up make sure we get it */
if (i2c->irq) if (i2c->irq)
...@@ -555,13 +555,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -555,13 +555,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
try_wait_for_completion(&wm8993->fll_lock); try_wait_for_completion(&wm8993->fll_lock);
/* Enable the FLL */ /* Enable the FLL */
snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA); snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA);
timeout = wait_for_completion_timeout(&wm8993->fll_lock, timeout); timeout = wait_for_completion_timeout(&wm8993->fll_lock, timeout);
if (i2c->irq && !timeout) if (i2c->irq && !timeout)
dev_warn(codec->dev, "Timed out waiting for FLL\n"); dev_warn(component->dev, "Timed out waiting for FLL\n");
dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout);
wm8993->fll_fref = Fref; wm8993->fll_fref = Fref;
wm8993->fll_fout = Fout; wm8993->fll_fout = Fout;
...@@ -573,20 +573,20 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -573,20 +573,20 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
static int wm8993_set_fll(struct snd_soc_dai *dai, int fll_id, int source, static int wm8993_set_fll(struct snd_soc_dai *dai, int fll_id, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
return _wm8993_set_fll(dai->codec, fll_id, source, Fref, Fout); return _wm8993_set_fll(dai->component, fll_id, source, Fref, Fout);
} }
static int configure_clock(struct snd_soc_codec *codec) static int configure_clock(struct snd_soc_component *component)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
unsigned int reg; unsigned int reg;
/* This should be done on init() for bypass paths */ /* This should be done on init() for bypass paths */
switch (wm8993->sysclk_source) { switch (wm8993->sysclk_source) {
case WM8993_SYSCLK_MCLK: case WM8993_SYSCLK_MCLK:
dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8993->mclk_rate); dev_dbg(component->dev, "Using %dHz MCLK\n", wm8993->mclk_rate);
reg = snd_soc_read(codec, WM8993_CLOCKING_2); reg = snd_soc_component_read32(component, WM8993_CLOCKING_2);
reg &= ~(WM8993_MCLK_DIV | WM8993_SYSCLK_SRC); reg &= ~(WM8993_MCLK_DIV | WM8993_SYSCLK_SRC);
if (wm8993->mclk_rate > 13500000) { if (wm8993->mclk_rate > 13500000) {
reg |= WM8993_MCLK_DIV; reg |= WM8993_MCLK_DIV;
...@@ -595,14 +595,14 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -595,14 +595,14 @@ static int configure_clock(struct snd_soc_codec *codec)
reg &= ~WM8993_MCLK_DIV; reg &= ~WM8993_MCLK_DIV;
wm8993->sysclk_rate = wm8993->mclk_rate; wm8993->sysclk_rate = wm8993->mclk_rate;
} }
snd_soc_write(codec, WM8993_CLOCKING_2, reg); snd_soc_component_write(component, WM8993_CLOCKING_2, reg);
break; break;
case WM8993_SYSCLK_FLL: case WM8993_SYSCLK_FLL:
dev_dbg(codec->dev, "Using %dHz FLL clock\n", dev_dbg(component->dev, "Using %dHz FLL clock\n",
wm8993->fll_fout); wm8993->fll_fout);
reg = snd_soc_read(codec, WM8993_CLOCKING_2); reg = snd_soc_component_read32(component, WM8993_CLOCKING_2);
reg |= WM8993_SYSCLK_SRC; reg |= WM8993_SYSCLK_SRC;
if (wm8993->fll_fout > 13500000) { if (wm8993->fll_fout > 13500000) {
reg |= WM8993_MCLK_DIV; reg |= WM8993_MCLK_DIV;
...@@ -611,15 +611,15 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -611,15 +611,15 @@ static int configure_clock(struct snd_soc_codec *codec)
reg &= ~WM8993_MCLK_DIV; reg &= ~WM8993_MCLK_DIV;
wm8993->sysclk_rate = wm8993->fll_fout; wm8993->sysclk_rate = wm8993->fll_fout;
} }
snd_soc_write(codec, WM8993_CLOCKING_2, reg); snd_soc_component_write(component, WM8993_CLOCKING_2, reg);
break; break;
default: default:
dev_err(codec->dev, "System clock not configured\n"); dev_err(component->dev, "System clock not configured\n");
return -EINVAL; return -EINVAL;
} }
dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8993->sysclk_rate); dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8993->sysclk_rate);
return 0; return 0;
} }
...@@ -809,11 +809,11 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), ...@@ -809,11 +809,11 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv),
static int clk_sys_event(struct snd_soc_dapm_widget *w, static int clk_sys_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
return configure_clock(codec); return configure_clock(component);
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
break; break;
...@@ -972,26 +972,26 @@ static const struct snd_soc_dapm_route routes[] = { ...@@ -972,26 +972,26 @@ static const struct snd_soc_dapm_route routes[] = {
{ "Right Headphone Mux", "DAC", "DACR" }, { "Right Headphone Mux", "DAC", "DACR" },
}; };
static int wm8993_set_bias_level(struct snd_soc_codec *codec, static int wm8993_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
int ret; int ret;
wm_hubs_set_bias_level(codec, level); wm_hubs_set_bias_level(component, level);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* VMID=2*40k */ /* VMID=2*40k */
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_VMID_SEL_MASK, 0x2); WM8993_VMID_SEL_MASK, 0x2);
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_2, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_2,
WM8993_TSHUT_ENA, WM8993_TSHUT_ENA); WM8993_TSHUT_ENA, WM8993_TSHUT_ENA);
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 = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies),
wm8993->supplies); wm8993->supplies);
if (ret != 0) if (ret != 0)
...@@ -1000,10 +1000,10 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, ...@@ -1000,10 +1000,10 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,
regcache_cache_only(wm8993->regmap, false); regcache_cache_only(wm8993->regmap, false);
regcache_sync(wm8993->regmap); regcache_sync(wm8993->regmap);
wm_hubs_vmid_ena(codec); wm_hubs_vmid_ena(component);
/* Bring up VMID with fast soft start */ /* Bring up VMID with fast soft start */
snd_soc_update_bits(codec, WM8993_ANTIPOP2, snd_soc_component_update_bits(component, WM8993_ANTIPOP2,
WM8993_STARTUP_BIAS_ENA | WM8993_STARTUP_BIAS_ENA |
WM8993_VMID_BUF_ENA | WM8993_VMID_BUF_ENA |
WM8993_VMID_RAMP_MASK | WM8993_VMID_RAMP_MASK |
...@@ -1017,40 +1017,40 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, ...@@ -1017,40 +1017,40 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,
* need the VMID buffer */ * need the VMID buffer */
if (!wm8993->pdata.lineout1_diff || if (!wm8993->pdata.lineout1_diff ||
!wm8993->pdata.lineout2_diff) !wm8993->pdata.lineout2_diff)
snd_soc_update_bits(codec, WM8993_ANTIPOP1, snd_soc_component_update_bits(component, WM8993_ANTIPOP1,
WM8993_LINEOUT_VMID_BUF_ENA, WM8993_LINEOUT_VMID_BUF_ENA,
WM8993_LINEOUT_VMID_BUF_ENA); WM8993_LINEOUT_VMID_BUF_ENA);
/* VMID=2*40k */ /* VMID=2*40k */
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_VMID_SEL_MASK | WM8993_VMID_SEL_MASK |
WM8993_BIAS_ENA, WM8993_BIAS_ENA,
WM8993_BIAS_ENA | 0x2); WM8993_BIAS_ENA | 0x2);
msleep(32); msleep(32);
/* Switch to normal bias */ /* Switch to normal bias */
snd_soc_update_bits(codec, WM8993_ANTIPOP2, snd_soc_component_update_bits(component, WM8993_ANTIPOP2,
WM8993_BIAS_SRC | WM8993_BIAS_SRC |
WM8993_STARTUP_BIAS_ENA, 0); WM8993_STARTUP_BIAS_ENA, 0);
} }
/* VMID=2*240k */ /* VMID=2*240k */
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_VMID_SEL_MASK, 0x4); WM8993_VMID_SEL_MASK, 0x4);
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_2, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_2,
WM8993_TSHUT_ENA, 0); WM8993_TSHUT_ENA, 0);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, WM8993_ANTIPOP1, snd_soc_component_update_bits(component, WM8993_ANTIPOP1,
WM8993_LINEOUT_VMID_BUF_ENA, 0); WM8993_LINEOUT_VMID_BUF_ENA, 0);
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_VMID_SEL_MASK | WM8993_BIAS_ENA, WM8993_VMID_SEL_MASK | WM8993_BIAS_ENA,
0); 0);
snd_soc_update_bits(codec, WM8993_ANTIPOP2, snd_soc_component_update_bits(component, WM8993_ANTIPOP2,
WM8993_STARTUP_BIAS_ENA | WM8993_STARTUP_BIAS_ENA |
WM8993_VMID_BUF_ENA | WM8993_VMID_BUF_ENA |
WM8993_VMID_RAMP_MASK | WM8993_VMID_RAMP_MASK |
...@@ -1070,8 +1070,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, ...@@ -1070,8 +1070,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec,
static int wm8993_set_sysclk(struct snd_soc_dai *codec_dai, static int wm8993_set_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 wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case WM8993_SYSCLK_MCLK: case WM8993_SYSCLK_MCLK:
...@@ -1091,10 +1091,10 @@ static int wm8993_set_sysclk(struct snd_soc_dai *codec_dai, ...@@ -1091,10 +1091,10 @@ static int wm8993_set_sysclk(struct snd_soc_dai *codec_dai,
static int wm8993_set_dai_fmt(struct snd_soc_dai *dai, static int wm8993_set_dai_fmt(struct snd_soc_dai *dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
unsigned int aif1 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_1); unsigned int aif1 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_1);
unsigned int aif4 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_4); unsigned int aif4 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_4);
aif1 &= ~(WM8993_BCLK_DIR | WM8993_AIF_BCLK_INV | aif1 &= ~(WM8993_BCLK_DIR | WM8993_AIF_BCLK_INV |
WM8993_AIF_LRCLK_INV | WM8993_AIF_FMT_MASK); WM8993_AIF_LRCLK_INV | WM8993_AIF_FMT_MASK);
...@@ -1178,8 +1178,8 @@ static int wm8993_set_dai_fmt(struct snd_soc_dai *dai, ...@@ -1178,8 +1178,8 @@ static int wm8993_set_dai_fmt(struct snd_soc_dai *dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM8993_AUDIO_INTERFACE_1, aif1); snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_1, aif1);
snd_soc_write(codec, WM8993_AUDIO_INTERFACE_4, aif4); snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_4, aif4);
return 0; return 0;
} }
...@@ -1188,28 +1188,28 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1188,28 +1188,28 @@ static int wm8993_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 wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
int ret, i, best, best_val, cur_val; int ret, i, best, best_val, cur_val;
unsigned int clocking1, clocking3, aif1, aif4; unsigned int clocking1, clocking3, aif1, aif4;
clocking1 = snd_soc_read(codec, WM8993_CLOCKING_1); clocking1 = snd_soc_component_read32(component, WM8993_CLOCKING_1);
clocking1 &= ~WM8993_BCLK_DIV_MASK; clocking1 &= ~WM8993_BCLK_DIV_MASK;
clocking3 = snd_soc_read(codec, WM8993_CLOCKING_3); clocking3 = snd_soc_component_read32(component, WM8993_CLOCKING_3);
clocking3 &= ~(WM8993_CLK_SYS_RATE_MASK | WM8993_SAMPLE_RATE_MASK); clocking3 &= ~(WM8993_CLK_SYS_RATE_MASK | WM8993_SAMPLE_RATE_MASK);
aif1 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_1); aif1 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_1);
aif1 &= ~WM8993_AIF_WL_MASK; aif1 &= ~WM8993_AIF_WL_MASK;
aif4 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_4); aif4 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_4);
aif4 &= ~WM8993_LRCLK_RATE_MASK; aif4 &= ~WM8993_LRCLK_RATE_MASK;
/* What BCLK do we need? */ /* What BCLK do we need? */
wm8993->fs = params_rate(params); wm8993->fs = params_rate(params);
wm8993->bclk = 2 * wm8993->fs; wm8993->bclk = 2 * wm8993->fs;
if (wm8993->tdm_slots) { if (wm8993->tdm_slots) {
dev_dbg(codec->dev, "Configuring for %d %d bit TDM slots\n", dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n",
wm8993->tdm_slots, wm8993->tdm_width); wm8993->tdm_slots, wm8993->tdm_width);
wm8993->bclk *= wm8993->tdm_width * wm8993->tdm_slots; wm8993->bclk *= wm8993->tdm_width * wm8993->tdm_slots;
} else { } else {
...@@ -1234,9 +1234,9 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1234,9 +1234,9 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
} }
} }
dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm8993->bclk); dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8993->bclk);
ret = configure_clock(codec); ret = configure_clock(component);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -1252,7 +1252,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1252,7 +1252,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
best_val = cur_val; best_val = cur_val;
} }
} }
dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n",
clk_sys_rates[best].ratio); clk_sys_rates[best].ratio);
clocking3 |= (clk_sys_rates[best].clk_sys_rate clocking3 |= (clk_sys_rates[best].clk_sys_rate
<< WM8993_CLK_SYS_RATE_SHIFT); << WM8993_CLK_SYS_RATE_SHIFT);
...@@ -1268,7 +1268,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1268,7 +1268,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
best_val = cur_val; best_val = cur_val;
} }
} }
dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n",
sample_rates[best].rate); sample_rates[best].rate);
clocking3 |= (sample_rates[best].sample_rate clocking3 |= (sample_rates[best].sample_rate
<< WM8993_SAMPLE_RATE_SHIFT); << WM8993_SAMPLE_RATE_SHIFT);
...@@ -1287,22 +1287,22 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1287,22 +1287,22 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
} }
} }
wm8993->bclk = (wm8993->sysclk_rate * 10) / bclk_divs[best].div; wm8993->bclk = (wm8993->sysclk_rate * 10) / bclk_divs[best].div;
dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n",
bclk_divs[best].div, wm8993->bclk); bclk_divs[best].div, wm8993->bclk);
clocking1 |= bclk_divs[best].bclk_div << WM8993_BCLK_DIV_SHIFT; clocking1 |= bclk_divs[best].bclk_div << WM8993_BCLK_DIV_SHIFT;
/* LRCLK is a simple fraction of BCLK */ /* LRCLK is a simple fraction of BCLK */
dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm8993->bclk / wm8993->fs); dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8993->bclk / wm8993->fs);
aif4 |= wm8993->bclk / wm8993->fs; aif4 |= wm8993->bclk / wm8993->fs;
snd_soc_write(codec, WM8993_CLOCKING_1, clocking1); snd_soc_component_write(component, WM8993_CLOCKING_1, clocking1);
snd_soc_write(codec, WM8993_CLOCKING_3, clocking3); snd_soc_component_write(component, WM8993_CLOCKING_3, clocking3);
snd_soc_write(codec, WM8993_AUDIO_INTERFACE_1, aif1); snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_1, aif1);
snd_soc_write(codec, WM8993_AUDIO_INTERFACE_4, aif4); snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_4, aif4);
/* ReTune Mobile? */ /* ReTune Mobile? */
if (wm8993->pdata.num_retune_configs) { if (wm8993->pdata.num_retune_configs) {
u16 eq1 = snd_soc_read(codec, WM8993_EQ1); u16 eq1 = snd_soc_component_read32(component, WM8993_EQ1);
struct wm8993_retune_mobile_setting *s; struct wm8993_retune_mobile_setting *s;
best = 0; best = 0;
...@@ -1318,16 +1318,16 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1318,16 +1318,16 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
} }
s = &wm8993->pdata.retune_configs[best]; s = &wm8993->pdata.retune_configs[best];
dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", dev_dbg(component->dev, "ReTune Mobile %s tuned for %dHz\n",
s->name, s->rate); s->name, s->rate);
/* Disable EQ while we reconfigure */ /* Disable EQ while we reconfigure */
snd_soc_update_bits(codec, WM8993_EQ1, WM8993_EQ_ENA, 0); snd_soc_component_update_bits(component, WM8993_EQ1, WM8993_EQ_ENA, 0);
for (i = 1; i < ARRAY_SIZE(s->config); i++) for (i = 1; i < ARRAY_SIZE(s->config); i++)
snd_soc_write(codec, WM8993_EQ1 + i, s->config[i]); snd_soc_component_write(component, WM8993_EQ1 + i, s->config[i]);
snd_soc_update_bits(codec, WM8993_EQ1, WM8993_EQ_ENA, eq1); snd_soc_component_update_bits(component, WM8993_EQ1, WM8993_EQ_ENA, eq1);
} }
return 0; return 0;
...@@ -1335,17 +1335,17 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, ...@@ -1335,17 +1335,17 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream,
static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute) static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
unsigned int reg; unsigned int reg;
reg = snd_soc_read(codec, WM8993_DAC_CTRL); reg = snd_soc_component_read32(component, WM8993_DAC_CTRL);
if (mute) if (mute)
reg |= WM8993_DAC_MUTE; reg |= WM8993_DAC_MUTE;
else else
reg &= ~WM8993_DAC_MUTE; reg &= ~WM8993_DAC_MUTE;
snd_soc_write(codec, WM8993_DAC_CTRL, reg); snd_soc_component_write(component, WM8993_DAC_CTRL, reg);
return 0; return 0;
} }
...@@ -1353,8 +1353,8 @@ static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute) ...@@ -1353,8 +1353,8 @@ static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute)
static int wm8993_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int wm8993_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int slot_width) unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
int aif1 = 0; int aif1 = 0;
int aif2 = 0; int aif2 = 0;
...@@ -1396,9 +1396,9 @@ static int wm8993_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, ...@@ -1396,9 +1396,9 @@ static int wm8993_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
wm8993->tdm_width = slot_width; wm8993->tdm_width = slot_width;
wm8993->tdm_slots = slots / 2; wm8993->tdm_slots = slots / 2;
snd_soc_update_bits(codec, WM8993_AUDIO_INTERFACE_1, snd_soc_component_update_bits(component, WM8993_AUDIO_INTERFACE_1,
WM8993_AIFADC_TDM | WM8993_AIFADC_TDM_CHAN, aif1); WM8993_AIFADC_TDM | WM8993_AIFADC_TDM_CHAN, aif1);
snd_soc_update_bits(codec, WM8993_AUDIO_INTERFACE_2, snd_soc_component_update_bits(component, WM8993_AUDIO_INTERFACE_2,
WM8993_AIFDAC_TDM | WM8993_AIFDAC_TDM_CHAN, aif2); WM8993_AIFDAC_TDM | WM8993_AIFDAC_TDM_CHAN, aif2);
return 0; return 0;
...@@ -1481,10 +1481,10 @@ static struct snd_soc_dai_driver wm8993_dai = { ...@@ -1481,10 +1481,10 @@ static struct snd_soc_dai_driver wm8993_dai = {
.symmetric_rates = 1, .symmetric_rates = 1,
}; };
static int wm8993_probe(struct snd_soc_codec *codec) static int wm8993_probe(struct snd_soc_component *component)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
wm8993->hubs_data.hp_startup_mode = 1; wm8993->hubs_data.hp_startup_mode = 1;
wm8993->hubs_data.dcs_codes_l = -2; wm8993->hubs_data.dcs_codes_l = -2;
...@@ -1492,20 +1492,20 @@ static int wm8993_probe(struct snd_soc_codec *codec) ...@@ -1492,20 +1492,20 @@ static int wm8993_probe(struct snd_soc_codec *codec)
wm8993->hubs_data.series_startup = 1; wm8993->hubs_data.series_startup = 1;
/* Latch volume update bits and default ZC on */ /* Latch volume update bits and default ZC on */
snd_soc_update_bits(codec, WM8993_RIGHT_DAC_DIGITAL_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_DAC_DIGITAL_VOLUME,
WM8993_DAC_VU, WM8993_DAC_VU); WM8993_DAC_VU, WM8993_DAC_VU);
snd_soc_update_bits(codec, WM8993_RIGHT_ADC_DIGITAL_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_ADC_DIGITAL_VOLUME,
WM8993_ADC_VU, WM8993_ADC_VU); WM8993_ADC_VU, WM8993_ADC_VU);
/* Manualy manage the HPOUT sequencing for independent stereo /* Manualy manage the HPOUT sequencing for independent stereo
* control. */ * control. */
snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0,
WM8993_HPOUT1_AUTO_PU, 0); WM8993_HPOUT1_AUTO_PU, 0);
/* Use automatic clock configuration */ /* Use automatic clock configuration */
snd_soc_update_bits(codec, WM8993_CLOCKING_4, WM8993_SR_MODE, 0); snd_soc_component_update_bits(component, WM8993_CLOCKING_4, WM8993_SR_MODE, 0);
wm_hubs_handle_analogue_pdata(codec, wm8993->pdata.lineout1_diff, wm_hubs_handle_analogue_pdata(component, wm8993->pdata.lineout1_diff,
wm8993->pdata.lineout2_diff, wm8993->pdata.lineout2_diff,
wm8993->pdata.lineout1fb, wm8993->pdata.lineout1fb,
wm8993->pdata.lineout2fb, wm8993->pdata.lineout2fb,
...@@ -1516,22 +1516,22 @@ static int wm8993_probe(struct snd_soc_codec *codec) ...@@ -1516,22 +1516,22 @@ static int wm8993_probe(struct snd_soc_codec *codec)
wm8993->pdata.micbias1_lvl, wm8993->pdata.micbias1_lvl,
wm8993->pdata.micbias2_lvl); wm8993->pdata.micbias2_lvl);
snd_soc_add_codec_controls(codec, wm8993_snd_controls, snd_soc_add_component_controls(component, wm8993_snd_controls,
ARRAY_SIZE(wm8993_snd_controls)); ARRAY_SIZE(wm8993_snd_controls));
if (wm8993->pdata.num_retune_configs != 0) { if (wm8993->pdata.num_retune_configs != 0) {
dev_dbg(codec->dev, "Using ReTune Mobile\n"); dev_dbg(component->dev, "Using ReTune Mobile\n");
} else { } else {
dev_dbg(codec->dev, "No ReTune Mobile, using normal EQ\n"); dev_dbg(component->dev, "No ReTune Mobile, using normal EQ\n");
snd_soc_add_codec_controls(codec, wm8993_eq_controls, snd_soc_add_component_controls(component, wm8993_eq_controls,
ARRAY_SIZE(wm8993_eq_controls)); ARRAY_SIZE(wm8993_eq_controls));
} }
snd_soc_dapm_new_controls(dapm, wm8993_dapm_widgets, snd_soc_dapm_new_controls(dapm, wm8993_dapm_widgets,
ARRAY_SIZE(wm8993_dapm_widgets)); ARRAY_SIZE(wm8993_dapm_widgets));
wm_hubs_add_analogue_controls(codec); wm_hubs_add_analogue_controls(component);
snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes)); snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes));
wm_hubs_add_analogue_routes(codec, wm8993->pdata.lineout1_diff, wm_hubs_add_analogue_routes(component, wm8993->pdata.lineout1_diff,
wm8993->pdata.lineout2_diff); wm8993->pdata.lineout2_diff);
/* If the line outputs are differential then we aren't presenting /* If the line outputs are differential then we aren't presenting
...@@ -1545,34 +1545,34 @@ static int wm8993_probe(struct snd_soc_codec *codec) ...@@ -1545,34 +1545,34 @@ static int wm8993_probe(struct snd_soc_codec *codec)
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int wm8993_suspend(struct snd_soc_codec *codec) static int wm8993_suspend(struct snd_soc_component *component)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
int fll_fout = wm8993->fll_fout; int fll_fout = wm8993->fll_fout;
int fll_fref = wm8993->fll_fref; int fll_fref = wm8993->fll_fref;
int ret; int ret;
/* Stop the FLL in an orderly fashion */ /* Stop the FLL in an orderly fashion */
ret = _wm8993_set_fll(codec, 0, 0, 0, 0); ret = _wm8993_set_fll(component, 0, 0, 0, 0);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, "Failed to stop FLL\n"); dev_err(component->dev, "Failed to stop FLL\n");
return ret; return ret;
} }
wm8993->fll_fout = fll_fout; wm8993->fll_fout = fll_fout;
wm8993->fll_fref = fll_fref; wm8993->fll_fref = fll_fref;
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
return 0; return 0;
} }
static int wm8993_resume(struct snd_soc_codec *codec) static int wm8993_resume(struct snd_soc_component *component)
{ {
struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component);
int ret; int ret;
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY);
/* Restart the FLL? */ /* Restart the FLL? */
if (wm8993->fll_fout) { if (wm8993->fll_fout) {
...@@ -1582,10 +1582,10 @@ static int wm8993_resume(struct snd_soc_codec *codec) ...@@ -1582,10 +1582,10 @@ static int wm8993_resume(struct snd_soc_codec *codec)
wm8993->fll_fref = 0; wm8993->fll_fref = 0;
wm8993->fll_fout = 0; wm8993->fll_fout = 0;
ret = _wm8993_set_fll(codec, 0, wm8993->fll_src, ret = _wm8993_set_fll(component, 0, wm8993->fll_src,
fll_fref, fll_fout); fll_fref, fll_fout);
if (ret != 0) if (ret != 0)
dev_err(codec->dev, "Failed to restart FLL\n"); dev_err(component->dev, "Failed to restart FLL\n");
} }
return 0; return 0;
...@@ -1615,11 +1615,15 @@ static const struct regmap_config wm8993_regmap = { ...@@ -1615,11 +1615,15 @@ static const struct regmap_config wm8993_regmap = {
.num_reg_defaults = ARRAY_SIZE(wm8993_reg_defaults), .num_reg_defaults = ARRAY_SIZE(wm8993_reg_defaults),
}; };
static const struct snd_soc_codec_driver soc_codec_dev_wm8993 = { static const struct snd_soc_component_driver soc_component_dev_wm8993 = {
.probe = wm8993_probe, .probe = wm8993_probe,
.suspend = wm8993_suspend, .suspend = wm8993_suspend,
.resume = wm8993_resume, .resume = wm8993_resume,
.set_bias_level = wm8993_set_bias_level, .set_bias_level = wm8993_set_bias_level,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm8993_i2c_probe(struct i2c_client *i2c, static int wm8993_i2c_probe(struct i2c_client *i2c,
...@@ -1705,8 +1709,8 @@ static int wm8993_i2c_probe(struct i2c_client *i2c, ...@@ -1705,8 +1709,8 @@ static int wm8993_i2c_probe(struct i2c_client *i2c,
regcache_cache_only(wm8993->regmap, true); regcache_cache_only(wm8993->regmap, true);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8993, &wm8993_dai, 1); &soc_component_dev_wm8993, &wm8993_dai, 1);
if (ret != 0) { if (ret != 0) {
dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
goto err_irq; goto err_irq;
...@@ -1726,7 +1730,6 @@ static int wm8993_i2c_remove(struct i2c_client *i2c) ...@@ -1726,7 +1730,6 @@ static int wm8993_i2c_remove(struct i2c_client *i2c)
{ {
struct wm8993_priv *wm8993 = i2c_get_clientdata(i2c); struct wm8993_priv *wm8993 = i2c_get_clientdata(i2c);
snd_soc_unregister_codec(&i2c->dev);
if (i2c->irq) if (i2c->irq)
free_irq(i2c->irq, wm8993); free_irq(i2c->irq, wm8993);
regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies);
......
...@@ -106,9 +106,9 @@ static const struct wm8958_micd_rate jackdet_rates[] = { ...@@ -106,9 +106,9 @@ static const struct wm8958_micd_rate jackdet_rates[] = {
{ 44100 * 256, false, 7, 8 }, { 44100 * 256, false, 7, 8 },
}; };
static void wm8958_micd_set_rate(struct snd_soc_codec *codec) static void wm8958_micd_set_rate(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int best, i, sysclk, val; int best, i, sysclk, val;
bool idle; bool idle;
...@@ -117,7 +117,7 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec) ...@@ -117,7 +117,7 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec)
idle = !wm8994->jack_mic; idle = !wm8994->jack_mic;
sysclk = snd_soc_read(codec, WM8994_CLOCKING_1); sysclk = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (sysclk & WM8994_SYSCLK_SRC) if (sysclk & WM8994_SYSCLK_SRC)
sysclk = wm8994->aifclk[1]; sysclk = wm8994->aifclk[1];
else else
...@@ -148,18 +148,18 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec) ...@@ -148,18 +148,18 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec)
val = rates[best].start << WM8958_MICD_BIAS_STARTTIME_SHIFT val = rates[best].start << WM8958_MICD_BIAS_STARTTIME_SHIFT
| rates[best].rate << WM8958_MICD_RATE_SHIFT; | rates[best].rate << WM8958_MICD_RATE_SHIFT;
dev_dbg(codec->dev, "MICD rate %d,%d for %dHz %s\n", dev_dbg(component->dev, "MICD rate %d,%d for %dHz %s\n",
rates[best].start, rates[best].rate, sysclk, rates[best].start, rates[best].rate, sysclk,
idle ? "idle" : "active"); idle ? "idle" : "active");
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
WM8958_MICD_BIAS_STARTTIME_MASK | WM8958_MICD_BIAS_STARTTIME_MASK |
WM8958_MICD_RATE_MASK, val); WM8958_MICD_RATE_MASK, val);
} }
static int configure_aif_clock(struct snd_soc_codec *codec, int aif) static int configure_aif_clock(struct snd_soc_component *component, int aif)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int rate; int rate;
int reg1 = 0; int reg1 = 0;
int offset; int offset;
...@@ -197,28 +197,28 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif) ...@@ -197,28 +197,28 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif)
rate /= 2; rate /= 2;
reg1 |= WM8994_AIF1CLK_DIV; reg1 |= WM8994_AIF1CLK_DIV;
dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n", dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n",
aif + 1, rate); aif + 1, rate);
} }
wm8994->aifclk[aif] = rate; wm8994->aifclk[aif] = rate;
snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1 + offset, snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1 + offset,
WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV, WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV,
reg1); reg1);
return 0; return 0;
} }
static int configure_clock(struct snd_soc_codec *codec) static int configure_clock(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int change, new; int change, new;
/* Bring up the AIF clocks first */ /* Bring up the AIF clocks first */
configure_aif_clock(codec, 0); configure_aif_clock(component, 0);
configure_aif_clock(codec, 1); configure_aif_clock(component, 1);
/* Then switch CLK_SYS over to the higher of them; a change /* Then switch CLK_SYS over to the higher of them; a change
* can only happen as a result of a clocking change which can * can only happen as a result of a clocking change which can
...@@ -228,7 +228,7 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -228,7 +228,7 @@ static int configure_clock(struct snd_soc_codec *codec)
/* If they're equal it doesn't matter which is used */ /* If they're equal it doesn't matter which is used */
if (wm8994->aifclk[0] == wm8994->aifclk[1]) { if (wm8994->aifclk[0] == wm8994->aifclk[1]) {
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
return 0; return 0;
} }
...@@ -237,12 +237,12 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -237,12 +237,12 @@ static int configure_clock(struct snd_soc_codec *codec)
else else
new = 0; new = 0;
change = snd_soc_update_bits(codec, WM8994_CLOCKING_1, change = snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8994_SYSCLK_SRC, new); WM8994_SYSCLK_SRC, new);
if (change) if (change)
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
return 0; return 0;
} }
...@@ -250,8 +250,8 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -250,8 +250,8 @@ static int configure_clock(struct snd_soc_codec *codec)
static int check_clk_sys(struct snd_soc_dapm_widget *source, static int check_clk_sys(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
int reg = snd_soc_read(codec, WM8994_CLOCKING_1); int reg = snd_soc_component_read32(component, WM8994_CLOCKING_1);
const char *clk; const char *clk;
/* Check what we're currently using for CLK_SYS */ /* Check what we're currently using for CLK_SYS */
...@@ -300,7 +300,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, ...@@ -300,7 +300,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
{ {
struct soc_mixer_control *mc = struct soc_mixer_control *mc =
(struct soc_mixer_control *)kcontrol->private_value; (struct soc_mixer_control *)kcontrol->private_value;
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
int mask, ret; int mask, ret;
/* Can't enable both ADC and DAC paths simultaneously */ /* Can't enable both ADC and DAC paths simultaneously */
...@@ -310,7 +310,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, ...@@ -310,7 +310,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
else else
mask = WM8994_AIF1DAC1_DRC_ENA_MASK; mask = WM8994_AIF1DAC1_DRC_ENA_MASK;
ret = snd_soc_read(codec, mc->reg); ret = snd_soc_component_read32(component, mc->reg);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (ret & mask) if (ret & mask)
...@@ -319,9 +319,9 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, ...@@ -319,9 +319,9 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
return snd_soc_put_volsw(kcontrol, ucontrol); return snd_soc_put_volsw(kcontrol, ucontrol);
} }
static void wm8994_set_drc(struct snd_soc_codec *codec, int drc) static void wm8994_set_drc(struct snd_soc_component *component, int drc)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int base = wm8994_drc_base[drc]; int base = wm8994_drc_base[drc];
...@@ -329,15 +329,15 @@ static void wm8994_set_drc(struct snd_soc_codec *codec, int drc) ...@@ -329,15 +329,15 @@ static void wm8994_set_drc(struct snd_soc_codec *codec, int drc)
int save, i; int save, i;
/* Save any enables; the configuration should clear them. */ /* Save any enables; the configuration should clear them. */
save = snd_soc_read(codec, base); save = snd_soc_component_read32(component, base);
save &= WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA | save &= WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA |
WM8994_AIF1ADC1R_DRC_ENA; WM8994_AIF1ADC1R_DRC_ENA;
for (i = 0; i < WM8994_DRC_REGS; i++) for (i = 0; i < WM8994_DRC_REGS; i++)
snd_soc_update_bits(codec, base + i, 0xffff, snd_soc_component_update_bits(component, base + i, 0xffff,
pdata->drc_cfgs[cfg].regs[i]); pdata->drc_cfgs[cfg].regs[i]);
snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_DRC_ENA | snd_soc_component_update_bits(component, base, WM8994_AIF1DAC1_DRC_ENA |
WM8994_AIF1ADC1L_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA |
WM8994_AIF1ADC1R_DRC_ENA, save); WM8994_AIF1ADC1R_DRC_ENA, save);
} }
...@@ -357,8 +357,8 @@ static int wm8994_get_drc(const char *name) ...@@ -357,8 +357,8 @@ static int wm8994_get_drc(const char *name)
static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int drc = wm8994_get_drc(kcontrol->id.name); int drc = wm8994_get_drc(kcontrol->id.name);
...@@ -372,7 +372,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, ...@@ -372,7 +372,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
wm8994->drc_cfg[drc] = value; wm8994->drc_cfg[drc] = value;
wm8994_set_drc(codec, drc); wm8994_set_drc(component, drc);
return 0; return 0;
} }
...@@ -380,8 +380,8 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, ...@@ -380,8 +380,8 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int drc = wm8994_get_drc(kcontrol->id.name); int drc = wm8994_get_drc(kcontrol->id.name);
if (drc < 0) if (drc < 0)
...@@ -391,9 +391,9 @@ static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, ...@@ -391,9 +391,9 @@ static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
return 0; return 0;
} }
static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) static void wm8994_set_retune_mobile(struct snd_soc_component *component, int block)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int base = wm8994_retune_mobile_base[block]; int base = wm8994_retune_mobile_base[block];
...@@ -430,7 +430,7 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -430,7 +430,7 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block)
} }
} }
dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n",
block, block,
pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].name,
pdata->retune_mobile_cfgs[best].rate, pdata->retune_mobile_cfgs[best].rate,
...@@ -439,14 +439,14 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -439,14 +439,14 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block)
/* The EQ will be disabled while reconfiguring it, remember the /* The EQ will be disabled while reconfiguring it, remember the
* current configuration. * current configuration.
*/ */
save = snd_soc_read(codec, base); save = snd_soc_component_read32(component, base);
save &= WM8994_AIF1DAC1_EQ_ENA; save &= WM8994_AIF1DAC1_EQ_ENA;
for (i = 0; i < WM8994_EQ_REGS; i++) for (i = 0; i < WM8994_EQ_REGS; i++)
snd_soc_update_bits(codec, base + i, 0xffff, snd_soc_component_update_bits(component, base + i, 0xffff,
pdata->retune_mobile_cfgs[best].regs[i]); pdata->retune_mobile_cfgs[best].regs[i]);
snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_EQ_ENA, save); snd_soc_component_update_bits(component, base, WM8994_AIF1DAC1_EQ_ENA, save);
} }
/* Icky as hell but saves code duplication */ /* Icky as hell but saves code duplication */
...@@ -464,8 +464,8 @@ static int wm8994_get_retune_mobile_block(const char *name) ...@@ -464,8 +464,8 @@ static int wm8994_get_retune_mobile_block(const char *name)
static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int block = wm8994_get_retune_mobile_block(kcontrol->id.name); int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
...@@ -479,7 +479,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, ...@@ -479,7 +479,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
wm8994->retune_mobile_cfg[block] = value; wm8994->retune_mobile_cfg[block] = value;
wm8994_set_retune_mobile(codec, block); wm8994_set_retune_mobile(component, block);
return 0; return 0;
} }
...@@ -487,8 +487,8 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, ...@@ -487,8 +487,8 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int block = wm8994_get_retune_mobile_block(kcontrol->id.name); int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
if (block < 0) if (block < 0)
...@@ -740,9 +740,9 @@ SOC_SINGLE_TLV("MIXINL IN1RP Boost Volume", WM8994_INPUT_MIXER_1, 8, 1, 0, ...@@ -740,9 +740,9 @@ SOC_SINGLE_TLV("MIXINL IN1RP Boost Volume", WM8994_INPUT_MIXER_1, 8, 1, 0,
}; };
/* We run all mode setting through a function to enforce audio mode */ /* We run all mode setting through a function to enforce audio mode */
static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) static void wm1811_jackdet_set_mode(struct snd_soc_component *component, u16 mode)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (!wm8994->jackdet || !wm8994->micdet[0].jack) if (!wm8994->jackdet || !wm8994->micdet[0].jack)
return; return;
...@@ -759,37 +759,37 @@ static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) ...@@ -759,37 +759,37 @@ static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode)
if (mode != WM1811_JACKDET_MODE_NONE) if (mode != WM1811_JACKDET_MODE_NONE)
mode = WM1811_JACKDET_MODE_AUDIO; mode = WM1811_JACKDET_MODE_AUDIO;
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM1811_JACKDET_MODE_MASK, mode); WM1811_JACKDET_MODE_MASK, mode);
} }
static void active_reference(struct snd_soc_codec *codec) static void active_reference(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
wm8994->active_refcount++; wm8994->active_refcount++;
dev_dbg(codec->dev, "Active refcount incremented, now %d\n", dev_dbg(component->dev, "Active refcount incremented, now %d\n",
wm8994->active_refcount); wm8994->active_refcount);
/* If we're using jack detection go into audio mode */ /* If we're using jack detection go into audio mode */
wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_AUDIO); wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_AUDIO);
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
} }
static void active_dereference(struct snd_soc_codec *codec) static void active_dereference(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
u16 mode; u16 mode;
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
wm8994->active_refcount--; wm8994->active_refcount--;
dev_dbg(codec->dev, "Active refcount decremented, now %d\n", dev_dbg(component->dev, "Active refcount decremented, now %d\n",
wm8994->active_refcount); wm8994->active_refcount);
if (wm8994->active_refcount == 0) { if (wm8994->active_refcount == 0) {
...@@ -799,7 +799,7 @@ static void active_dereference(struct snd_soc_codec *codec) ...@@ -799,7 +799,7 @@ static void active_dereference(struct snd_soc_codec *codec)
else else
mode = WM1811_JACKDET_MODE_JACK; mode = WM1811_JACKDET_MODE_JACK;
wm1811_jackdet_set_mode(codec, mode); wm1811_jackdet_set_mode(component, mode);
} }
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
...@@ -808,12 +808,12 @@ static void active_dereference(struct snd_soc_codec *codec) ...@@ -808,12 +808,12 @@ static void active_dereference(struct snd_soc_codec *codec)
static int clk_sys_event(struct snd_soc_dapm_widget *w, static int clk_sys_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
return configure_clock(codec); return configure_clock(component);
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
/* /*
...@@ -832,30 +832,30 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w, ...@@ -832,30 +832,30 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w,
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
configure_clock(codec); configure_clock(component);
break; break;
} }
return 0; return 0;
} }
static void vmid_reference(struct snd_soc_codec *codec) static void vmid_reference(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
wm8994->vmid_refcount++; wm8994->vmid_refcount++;
dev_dbg(codec->dev, "Referencing VMID, refcount is now %d\n", dev_dbg(component->dev, "Referencing VMID, refcount is now %d\n",
wm8994->vmid_refcount); wm8994->vmid_refcount);
if (wm8994->vmid_refcount == 1) { if (wm8994->vmid_refcount == 1) {
snd_soc_update_bits(codec, WM8994_ANTIPOP_1, snd_soc_component_update_bits(component, WM8994_ANTIPOP_1,
WM8994_LINEOUT1_DISCH | WM8994_LINEOUT1_DISCH |
WM8994_LINEOUT2_DISCH, 0); WM8994_LINEOUT2_DISCH, 0);
wm_hubs_vmid_ena(codec); wm_hubs_vmid_ena(component);
switch (wm8994->vmid_mode) { switch (wm8994->vmid_mode) {
default: default:
...@@ -863,7 +863,7 @@ static void vmid_reference(struct snd_soc_codec *codec) ...@@ -863,7 +863,7 @@ static void vmid_reference(struct snd_soc_codec *codec)
/* fall through */ /* fall through */
case WM8994_VMID_NORMAL: case WM8994_VMID_NORMAL:
/* Startup bias, VMID ramp & buffer */ /* Startup bias, VMID ramp & buffer */
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_BIAS_SRC | WM8994_BIAS_SRC |
WM8994_VMID_DISCH | WM8994_VMID_DISCH |
WM8994_STARTUP_BIAS_ENA | WM8994_STARTUP_BIAS_ENA |
...@@ -875,14 +875,14 @@ static void vmid_reference(struct snd_soc_codec *codec) ...@@ -875,14 +875,14 @@ static void vmid_reference(struct snd_soc_codec *codec)
(0x2 << WM8994_VMID_RAMP_SHIFT)); (0x2 << WM8994_VMID_RAMP_SHIFT));
/* Main bias enable, VMID=2x40k */ /* Main bias enable, VMID=2x40k */
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1,
WM8994_BIAS_ENA | WM8994_BIAS_ENA |
WM8994_VMID_SEL_MASK, WM8994_VMID_SEL_MASK,
WM8994_BIAS_ENA | 0x2); WM8994_BIAS_ENA | 0x2);
msleep(300); msleep(300);
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_VMID_RAMP_MASK | WM8994_VMID_RAMP_MASK |
WM8994_BIAS_SRC, WM8994_BIAS_SRC,
0); 0);
...@@ -890,7 +890,7 @@ static void vmid_reference(struct snd_soc_codec *codec) ...@@ -890,7 +890,7 @@ static void vmid_reference(struct snd_soc_codec *codec)
case WM8994_VMID_FORCE: case WM8994_VMID_FORCE:
/* Startup bias, slow VMID ramp & buffer */ /* Startup bias, slow VMID ramp & buffer */
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_BIAS_SRC | WM8994_BIAS_SRC |
WM8994_VMID_DISCH | WM8994_VMID_DISCH |
WM8994_STARTUP_BIAS_ENA | WM8994_STARTUP_BIAS_ENA |
...@@ -902,14 +902,14 @@ static void vmid_reference(struct snd_soc_codec *codec) ...@@ -902,14 +902,14 @@ static void vmid_reference(struct snd_soc_codec *codec)
(0x2 << WM8994_VMID_RAMP_SHIFT)); (0x2 << WM8994_VMID_RAMP_SHIFT));
/* Main bias enable, VMID=2x40k */ /* Main bias enable, VMID=2x40k */
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1,
WM8994_BIAS_ENA | WM8994_BIAS_ENA |
WM8994_VMID_SEL_MASK, WM8994_VMID_SEL_MASK,
WM8994_BIAS_ENA | 0x2); WM8994_BIAS_ENA | 0x2);
msleep(400); msleep(400);
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_VMID_RAMP_MASK | WM8994_VMID_RAMP_MASK |
WM8994_BIAS_SRC, WM8994_BIAS_SRC,
0); 0);
...@@ -918,120 +918,120 @@ static void vmid_reference(struct snd_soc_codec *codec) ...@@ -918,120 +918,120 @@ static void vmid_reference(struct snd_soc_codec *codec)
} }
} }
static void vmid_dereference(struct snd_soc_codec *codec) static void vmid_dereference(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
wm8994->vmid_refcount--; wm8994->vmid_refcount--;
dev_dbg(codec->dev, "Dereferencing VMID, refcount is now %d\n", dev_dbg(component->dev, "Dereferencing VMID, refcount is now %d\n",
wm8994->vmid_refcount); wm8994->vmid_refcount);
if (wm8994->vmid_refcount == 0) { if (wm8994->vmid_refcount == 0) {
if (wm8994->hubs.lineout1_se) if (wm8994->hubs.lineout1_se)
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3,
WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1N_ENA |
WM8994_LINEOUT1P_ENA, WM8994_LINEOUT1P_ENA,
WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1N_ENA |
WM8994_LINEOUT1P_ENA); WM8994_LINEOUT1P_ENA);
if (wm8994->hubs.lineout2_se) if (wm8994->hubs.lineout2_se)
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3,
WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2N_ENA |
WM8994_LINEOUT2P_ENA, WM8994_LINEOUT2P_ENA,
WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2N_ENA |
WM8994_LINEOUT2P_ENA); WM8994_LINEOUT2P_ENA);
/* Start discharging VMID */ /* Start discharging VMID */
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_BIAS_SRC | WM8994_BIAS_SRC |
WM8994_VMID_DISCH, WM8994_VMID_DISCH,
WM8994_BIAS_SRC | WM8994_BIAS_SRC |
WM8994_VMID_DISCH); WM8994_VMID_DISCH);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1,
WM8994_VMID_SEL_MASK, 0); WM8994_VMID_SEL_MASK, 0);
msleep(400); msleep(400);
/* Active discharge */ /* Active discharge */
snd_soc_update_bits(codec, WM8994_ANTIPOP_1, snd_soc_component_update_bits(component, WM8994_ANTIPOP_1,
WM8994_LINEOUT1_DISCH | WM8994_LINEOUT1_DISCH |
WM8994_LINEOUT2_DISCH, WM8994_LINEOUT2_DISCH,
WM8994_LINEOUT1_DISCH | WM8994_LINEOUT1_DISCH |
WM8994_LINEOUT2_DISCH); WM8994_LINEOUT2_DISCH);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3,
WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1N_ENA |
WM8994_LINEOUT1P_ENA | WM8994_LINEOUT1P_ENA |
WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2N_ENA |
WM8994_LINEOUT2P_ENA, 0); WM8994_LINEOUT2P_ENA, 0);
/* Switch off startup biases */ /* Switch off startup biases */
snd_soc_update_bits(codec, WM8994_ANTIPOP_2, snd_soc_component_update_bits(component, WM8994_ANTIPOP_2,
WM8994_BIAS_SRC | WM8994_BIAS_SRC |
WM8994_STARTUP_BIAS_ENA | WM8994_STARTUP_BIAS_ENA |
WM8994_VMID_BUF_ENA | WM8994_VMID_BUF_ENA |
WM8994_VMID_RAMP_MASK, 0); WM8994_VMID_RAMP_MASK, 0);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1,
WM8994_VMID_SEL_MASK, 0); WM8994_VMID_SEL_MASK, 0);
} }
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
} }
static int vmid_event(struct snd_soc_dapm_widget *w, static int vmid_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
vmid_reference(codec); vmid_reference(component);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
vmid_dereference(codec); vmid_dereference(component);
break; break;
} }
return 0; return 0;
} }
static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec) static bool wm8994_check_class_w_digital(struct snd_soc_component *component)
{ {
int source = 0; /* GCC flow analysis can't track enable */ int source = 0; /* GCC flow analysis can't track enable */
int reg, reg_r; int reg, reg_r;
/* We also need the same AIF source for L/R and only one path */ /* We also need the same AIF source for L/R and only one path */
reg = snd_soc_read(codec, WM8994_DAC1_LEFT_MIXER_ROUTING); reg = snd_soc_component_read32(component, WM8994_DAC1_LEFT_MIXER_ROUTING);
switch (reg) { switch (reg) {
case WM8994_AIF2DACL_TO_DAC1L: case WM8994_AIF2DACL_TO_DAC1L:
dev_vdbg(codec->dev, "Class W source AIF2DAC\n"); dev_vdbg(component->dev, "Class W source AIF2DAC\n");
source = 2 << WM8994_CP_DYN_SRC_SEL_SHIFT; source = 2 << WM8994_CP_DYN_SRC_SEL_SHIFT;
break; break;
case WM8994_AIF1DAC2L_TO_DAC1L: case WM8994_AIF1DAC2L_TO_DAC1L:
dev_vdbg(codec->dev, "Class W source AIF1DAC2\n"); dev_vdbg(component->dev, "Class W source AIF1DAC2\n");
source = 1 << WM8994_CP_DYN_SRC_SEL_SHIFT; source = 1 << WM8994_CP_DYN_SRC_SEL_SHIFT;
break; break;
case WM8994_AIF1DAC1L_TO_DAC1L: case WM8994_AIF1DAC1L_TO_DAC1L:
dev_vdbg(codec->dev, "Class W source AIF1DAC1\n"); dev_vdbg(component->dev, "Class W source AIF1DAC1\n");
source = 0 << WM8994_CP_DYN_SRC_SEL_SHIFT; source = 0 << WM8994_CP_DYN_SRC_SEL_SHIFT;
break; break;
default: default:
dev_vdbg(codec->dev, "DAC mixer setting: %x\n", reg); dev_vdbg(component->dev, "DAC mixer setting: %x\n", reg);
return false; return false;
} }
reg_r = snd_soc_read(codec, WM8994_DAC1_RIGHT_MIXER_ROUTING); reg_r = snd_soc_component_read32(component, WM8994_DAC1_RIGHT_MIXER_ROUTING);
if (reg_r != reg) { if (reg_r != reg) {
dev_vdbg(codec->dev, "Left and right DAC mixers different\n"); dev_vdbg(component->dev, "Left and right DAC mixers different\n");
return false; return false;
} }
/* Set the source up */ /* Set the source up */
snd_soc_update_bits(codec, WM8994_CLASS_W_1, snd_soc_component_update_bits(component, WM8994_CLASS_W_1,
WM8994_CP_DYN_SRC_SEL_MASK, source); WM8994_CP_DYN_SRC_SEL_MASK, source);
return true; return true;
...@@ -1040,8 +1040,8 @@ static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec) ...@@ -1040,8 +1040,8 @@ static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec)
static int aif1clk_ev(struct snd_soc_dapm_widget *w, static int aif1clk_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
int i; int i;
...@@ -1064,7 +1064,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1064,7 +1064,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
if (wm8994->channels[0] <= 2) if (wm8994->channels[0] <= 2)
mask &= ~(WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA); mask &= ~(WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA);
val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1); val = snd_soc_component_read32(component, WM8994_AIF1_CONTROL_1);
if ((val & WM8994_AIF1ADCL_SRC) && if ((val & WM8994_AIF1ADCL_SRC) &&
(val & WM8994_AIF1ADCR_SRC)) (val & WM8994_AIF1ADCR_SRC))
adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA; adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA;
...@@ -1075,7 +1075,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1075,7 +1075,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA | adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA |
WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA; WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA;
val = snd_soc_read(codec, WM8994_AIF1_CONTROL_2); val = snd_soc_component_read32(component, WM8994_AIF1_CONTROL_2);
if ((val & WM8994_AIF1DACL_SRC) && if ((val & WM8994_AIF1DACL_SRC) &&
(val & WM8994_AIF1DACR_SRC)) (val & WM8994_AIF1DACR_SRC))
dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA; dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA;
...@@ -1086,21 +1086,21 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1086,21 +1086,21 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA | dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA |
WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA; WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA;
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4,
mask, adc); mask, adc);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
mask, dac); mask, dac);
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8994_AIF1DSPCLK_ENA | WM8994_AIF1DSPCLK_ENA |
WM8994_SYSDSPCLK_ENA, WM8994_SYSDSPCLK_ENA,
WM8994_AIF1DSPCLK_ENA | WM8994_AIF1DSPCLK_ENA |
WM8994_SYSDSPCLK_ENA); WM8994_SYSDSPCLK_ENA);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, mask, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, mask,
WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC1R_ENA |
WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC1L_ENA |
WM8994_AIF1ADC2R_ENA | WM8994_AIF1ADC2R_ENA |
WM8994_AIF1ADC2L_ENA); WM8994_AIF1ADC2L_ENA);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, mask, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, mask,
WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC1R_ENA |
WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1L_ENA |
WM8994_AIF1DAC2R_ENA | WM8994_AIF1DAC2R_ENA |
...@@ -1109,24 +1109,24 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1109,24 +1109,24 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
snd_soc_write(codec, wm8994_vu_bits[i].reg, snd_soc_component_write(component, wm8994_vu_bits[i].reg,
snd_soc_read(codec, snd_soc_component_read32(component,
wm8994_vu_bits[i].reg)); wm8994_vu_bits[i].reg));
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
mask, 0); mask, 0);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4,
mask, 0); mask, 0);
val = snd_soc_read(codec, WM8994_CLOCKING_1); val = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (val & WM8994_AIF2DSPCLK_ENA) if (val & WM8994_AIF2DSPCLK_ENA)
val = WM8994_SYSDSPCLK_ENA; val = WM8994_SYSDSPCLK_ENA;
else else
val = 0; val = 0;
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8994_SYSDSPCLK_ENA | WM8994_SYSDSPCLK_ENA |
WM8994_AIF1DSPCLK_ENA, val); WM8994_AIF1DSPCLK_ENA, val);
break; break;
...@@ -1138,7 +1138,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1138,7 +1138,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
static int aif2clk_ev(struct snd_soc_dapm_widget *w, static int aif2clk_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int i; int i;
int dac; int dac;
int adc; int adc;
...@@ -1146,7 +1146,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1146,7 +1146,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
val = snd_soc_read(codec, WM8994_AIF2_CONTROL_1); val = snd_soc_component_read32(component, WM8994_AIF2_CONTROL_1);
if ((val & WM8994_AIF2ADCL_SRC) && if ((val & WM8994_AIF2ADCL_SRC) &&
(val & WM8994_AIF2ADCR_SRC)) (val & WM8994_AIF2ADCR_SRC))
adc = WM8994_AIF2ADCR_ENA; adc = WM8994_AIF2ADCR_ENA;
...@@ -1157,7 +1157,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1157,7 +1157,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
adc = WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA; adc = WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA;
val = snd_soc_read(codec, WM8994_AIF2_CONTROL_2); val = snd_soc_component_read32(component, WM8994_AIF2_CONTROL_2);
if ((val & WM8994_AIF2DACL_SRC) && if ((val & WM8994_AIF2DACL_SRC) &&
(val & WM8994_AIF2DACR_SRC)) (val & WM8994_AIF2DACR_SRC))
dac = WM8994_AIF2DACR_ENA; dac = WM8994_AIF2DACR_ENA;
...@@ -1167,23 +1167,23 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1167,23 +1167,23 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
else else
dac = WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA; dac = WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA;
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4,
WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCL_ENA |
WM8994_AIF2ADCR_ENA, adc); WM8994_AIF2ADCR_ENA, adc);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
WM8994_AIF2DACL_ENA | WM8994_AIF2DACL_ENA |
WM8994_AIF2DACR_ENA, dac); WM8994_AIF2DACR_ENA, dac);
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8994_AIF2DSPCLK_ENA | WM8994_AIF2DSPCLK_ENA |
WM8994_SYSDSPCLK_ENA, WM8994_SYSDSPCLK_ENA,
WM8994_AIF2DSPCLK_ENA | WM8994_AIF2DSPCLK_ENA |
WM8994_SYSDSPCLK_ENA); WM8994_SYSDSPCLK_ENA);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4,
WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCL_ENA |
WM8994_AIF2ADCR_ENA, WM8994_AIF2ADCR_ENA,
WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCL_ENA |
WM8994_AIF2ADCR_ENA); WM8994_AIF2ADCR_ENA);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
WM8994_AIF2DACL_ENA | WM8994_AIF2DACL_ENA |
WM8994_AIF2DACR_ENA, WM8994_AIF2DACR_ENA,
WM8994_AIF2DACL_ENA | WM8994_AIF2DACL_ENA |
...@@ -1192,26 +1192,26 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1192,26 +1192,26 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
snd_soc_write(codec, wm8994_vu_bits[i].reg, snd_soc_component_write(component, wm8994_vu_bits[i].reg,
snd_soc_read(codec, snd_soc_component_read32(component,
wm8994_vu_bits[i].reg)); wm8994_vu_bits[i].reg));
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
WM8994_AIF2DACL_ENA | WM8994_AIF2DACL_ENA |
WM8994_AIF2DACR_ENA, 0); WM8994_AIF2DACR_ENA, 0);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4,
WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCL_ENA |
WM8994_AIF2ADCR_ENA, 0); WM8994_AIF2ADCR_ENA, 0);
val = snd_soc_read(codec, WM8994_CLOCKING_1); val = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (val & WM8994_AIF1DSPCLK_ENA) if (val & WM8994_AIF1DSPCLK_ENA)
val = WM8994_SYSDSPCLK_ENA; val = WM8994_SYSDSPCLK_ENA;
else else
val = 0; val = 0;
snd_soc_update_bits(codec, WM8994_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_CLOCKING_1,
WM8994_SYSDSPCLK_ENA | WM8994_SYSDSPCLK_ENA |
WM8994_AIF2DSPCLK_ENA, val); WM8994_AIF2DSPCLK_ENA, val);
break; break;
...@@ -1223,8 +1223,8 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, ...@@ -1223,8 +1223,8 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w,
static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, static int aif1clk_late_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -1241,8 +1241,8 @@ static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, ...@@ -1241,8 +1241,8 @@ static int aif1clk_late_ev(struct snd_soc_dapm_widget *w,
static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, static int aif2clk_late_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -1259,14 +1259,14 @@ static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, ...@@ -1259,14 +1259,14 @@ static int aif2clk_late_ev(struct snd_soc_dapm_widget *w,
static int late_enable_ev(struct snd_soc_dapm_widget *w, static int late_enable_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
if (wm8994->aif1clk_enable) { if (wm8994->aif1clk_enable) {
aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU);
snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1,
WM8994_AIF1CLK_ENA_MASK, WM8994_AIF1CLK_ENA_MASK,
WM8994_AIF1CLK_ENA); WM8994_AIF1CLK_ENA);
aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU);
...@@ -1274,7 +1274,7 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w, ...@@ -1274,7 +1274,7 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w,
} }
if (wm8994->aif2clk_enable) { if (wm8994->aif2clk_enable) {
aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU);
snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_AIF2_CLOCKING_1,
WM8994_AIF2CLK_ENA_MASK, WM8994_AIF2CLK_ENA_MASK,
WM8994_AIF2CLK_ENA); WM8994_AIF2CLK_ENA);
aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU);
...@@ -1292,21 +1292,21 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w, ...@@ -1292,21 +1292,21 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w,
static int late_disable_ev(struct snd_soc_dapm_widget *w, static int late_disable_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
if (wm8994->aif1clk_disable) { if (wm8994->aif1clk_disable) {
aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD);
snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1,
WM8994_AIF1CLK_ENA_MASK, 0); WM8994_AIF1CLK_ENA_MASK, 0);
aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD);
wm8994->aif1clk_disable = 0; wm8994->aif1clk_disable = 0;
} }
if (wm8994->aif2clk_disable) { if (wm8994->aif2clk_disable) {
aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD);
snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1, snd_soc_component_update_bits(component, WM8994_AIF2_CLOCKING_1,
WM8994_AIF2CLK_ENA_MASK, 0); WM8994_AIF2CLK_ENA_MASK, 0);
aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD);
wm8994->aif2clk_disable = 0; wm8994->aif2clk_disable = 0;
...@@ -1334,10 +1334,10 @@ static int micbias_ev(struct snd_soc_dapm_widget *w, ...@@ -1334,10 +1334,10 @@ static int micbias_ev(struct snd_soc_dapm_widget *w,
static int dac_ev(struct snd_soc_dapm_widget *w, static int dac_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
unsigned int mask = 1 << w->shift; unsigned int mask = 1 << w->shift;
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5,
mask, mask); mask, mask);
return 0; return 0;
} }
...@@ -1375,9 +1375,9 @@ SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0), ...@@ -1375,9 +1375,9 @@ SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0),
static int post_ev(struct snd_soc_dapm_widget *w, static int post_ev(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
dev_dbg(codec->dev, "SRC status: %x\n", dev_dbg(component->dev, "SRC status: %x\n",
snd_soc_read(codec, snd_soc_component_read32(component,
WM8994_RATE_STATUS)); WM8994_RATE_STATUS));
return 0; return 0;
} }
...@@ -1443,12 +1443,12 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING, ...@@ -1443,12 +1443,12 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
static int wm8994_put_class_w(struct snd_kcontrol *kcontrol, static int wm8994_put_class_w(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
int ret; int ret;
ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
wm_hubs_update_class_w(codec); wm_hubs_update_class_w(component);
return ret; return ret;
} }
...@@ -2130,10 +2130,10 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll, ...@@ -2130,10 +2130,10 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll,
return 0; return 0;
} }
static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int reg_offset, ret; int reg_offset, ret;
struct fll_div fll; struct fll_div fll;
...@@ -2156,7 +2156,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2156,7 +2156,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
return -EINVAL; return -EINVAL;
} }
reg = snd_soc_read(codec, WM8994_FLL1_CONTROL_1 + reg_offset); reg = snd_soc_component_read32(component, WM8994_FLL1_CONTROL_1 + reg_offset);
was_enabled = reg & WM8994_FLL1_ENA; was_enabled = reg & WM8994_FLL1_ENA;
switch (src) { switch (src) {
...@@ -2197,57 +2197,57 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2197,57 +2197,57 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
return ret; return ret;
/* Make sure that we're not providing SYSCLK right now */ /* Make sure that we're not providing SYSCLK right now */
clk1 = snd_soc_read(codec, WM8994_CLOCKING_1); clk1 = snd_soc_component_read32(component, WM8994_CLOCKING_1);
if (clk1 & WM8994_SYSCLK_SRC) if (clk1 & WM8994_SYSCLK_SRC)
aif_reg = WM8994_AIF2_CLOCKING_1; aif_reg = WM8994_AIF2_CLOCKING_1;
else else
aif_reg = WM8994_AIF1_CLOCKING_1; aif_reg = WM8994_AIF1_CLOCKING_1;
reg = snd_soc_read(codec, aif_reg); reg = snd_soc_component_read32(component, aif_reg);
if ((reg & WM8994_AIF1CLK_ENA) && if ((reg & WM8994_AIF1CLK_ENA) &&
(reg & WM8994_AIF1CLK_SRC_MASK) == aif_src) { (reg & WM8994_AIF1CLK_SRC_MASK) == aif_src) {
dev_err(codec->dev, "FLL%d is currently providing SYSCLK\n", dev_err(component->dev, "FLL%d is currently providing SYSCLK\n",
id + 1); id + 1);
return -EBUSY; return -EBUSY;
} }
/* We always need to disable the FLL while reconfiguring */ /* We always need to disable the FLL while reconfiguring */
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_1 + reg_offset,
WM8994_FLL1_ENA, 0); WM8994_FLL1_ENA, 0);
if (wm8994->fll_byp && src == WM8994_FLL_SRC_BCLK && if (wm8994->fll_byp && src == WM8994_FLL_SRC_BCLK &&
freq_in == freq_out && freq_out) { freq_in == freq_out && freq_out) {
dev_dbg(codec->dev, "Bypassing FLL%d\n", id + 1); dev_dbg(component->dev, "Bypassing FLL%d\n", id + 1);
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_5 + reg_offset,
WM8958_FLL1_BYP, WM8958_FLL1_BYP); WM8958_FLL1_BYP, WM8958_FLL1_BYP);
goto out; goto out;
} }
reg = (fll.outdiv << WM8994_FLL1_OUTDIV_SHIFT) | reg = (fll.outdiv << WM8994_FLL1_OUTDIV_SHIFT) |
(fll.fll_fratio << WM8994_FLL1_FRATIO_SHIFT); (fll.fll_fratio << WM8994_FLL1_FRATIO_SHIFT);
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_2 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_2 + reg_offset,
WM8994_FLL1_OUTDIV_MASK | WM8994_FLL1_OUTDIV_MASK |
WM8994_FLL1_FRATIO_MASK, reg); WM8994_FLL1_FRATIO_MASK, reg);
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_3 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_3 + reg_offset,
WM8994_FLL1_K_MASK, fll.k); WM8994_FLL1_K_MASK, fll.k);
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_4 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_4 + reg_offset,
WM8994_FLL1_N_MASK, WM8994_FLL1_N_MASK,
fll.n << WM8994_FLL1_N_SHIFT); fll.n << WM8994_FLL1_N_SHIFT);
if (fll.lambda) { if (fll.lambda) {
snd_soc_update_bits(codec, WM8958_FLL1_EFS_1 + reg_offset, snd_soc_component_update_bits(component, WM8958_FLL1_EFS_1 + reg_offset,
WM8958_FLL1_LAMBDA_MASK, WM8958_FLL1_LAMBDA_MASK,
fll.lambda); fll.lambda);
snd_soc_update_bits(codec, WM8958_FLL1_EFS_2 + reg_offset, snd_soc_component_update_bits(component, WM8958_FLL1_EFS_2 + reg_offset,
WM8958_FLL1_EFS_ENA, WM8958_FLL1_EFS_ENA); WM8958_FLL1_EFS_ENA, WM8958_FLL1_EFS_ENA);
} else { } else {
snd_soc_update_bits(codec, WM8958_FLL1_EFS_2 + reg_offset, snd_soc_component_update_bits(component, WM8958_FLL1_EFS_2 + reg_offset,
WM8958_FLL1_EFS_ENA, 0); WM8958_FLL1_EFS_ENA, 0);
} }
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_5 + reg_offset,
WM8994_FLL1_FRC_NCO | WM8958_FLL1_BYP | WM8994_FLL1_FRC_NCO | WM8958_FLL1_BYP |
WM8994_FLL1_REFCLK_DIV_MASK | WM8994_FLL1_REFCLK_DIV_MASK |
WM8994_FLL1_REFCLK_SRC_MASK, WM8994_FLL1_REFCLK_SRC_MASK,
...@@ -2263,15 +2263,15 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2263,15 +2263,15 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
if (freq_out) { if (freq_out) {
/* Enable VMID if we need it */ /* Enable VMID if we need it */
if (!was_enabled) { if (!was_enabled) {
active_reference(codec); active_reference(component);
switch (control->type) { switch (control->type) {
case WM8994: case WM8994:
vmid_reference(codec); vmid_reference(component);
break; break;
case WM8958: case WM8958:
if (control->revision < 1) if (control->revision < 1)
vmid_reference(codec); vmid_reference(component);
break; break;
default: default:
break; break;
...@@ -2285,7 +2285,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2285,7 +2285,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
if (src == WM8994_FLL_SRC_INTERNAL) if (src == WM8994_FLL_SRC_INTERNAL)
reg |= WM8994_FLL1_OSC_ENA; reg |= WM8994_FLL1_OSC_ENA;
snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_1 + reg_offset,
WM8994_FLL1_ENA | WM8994_FLL1_OSC_ENA | WM8994_FLL1_ENA | WM8994_FLL1_OSC_ENA |
WM8994_FLL1_FRAC, reg); WM8994_FLL1_FRAC, reg);
...@@ -2293,7 +2293,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2293,7 +2293,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
timeout = wait_for_completion_timeout(&wm8994->fll_locked[id], timeout = wait_for_completion_timeout(&wm8994->fll_locked[id],
msecs_to_jiffies(10)); msecs_to_jiffies(10));
if (timeout == 0) if (timeout == 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Timed out waiting for FLL lock\n"); "Timed out waiting for FLL lock\n");
} else { } else {
msleep(5); msleep(5);
...@@ -2302,17 +2302,17 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2302,17 +2302,17 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
if (was_enabled) { if (was_enabled) {
switch (control->type) { switch (control->type) {
case WM8994: case WM8994:
vmid_dereference(codec); vmid_dereference(component);
break; break;
case WM8958: case WM8958:
if (control->revision < 1) if (control->revision < 1)
vmid_dereference(codec); vmid_dereference(component);
break; break;
default: default:
break; break;
} }
active_dereference(codec); active_dereference(component);
} }
} }
...@@ -2321,29 +2321,29 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, ...@@ -2321,29 +2321,29 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src,
wm8994->fll[id].out = freq_out; wm8994->fll[id].out = freq_out;
wm8994->fll[id].src = src; wm8994->fll[id].src = src;
configure_clock(codec); configure_clock(component);
/* /*
* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers
* for detection. * for detection.
*/ */
if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
dev_dbg(codec->dev, "Configuring AIFs for 128fs\n"); dev_dbg(component->dev, "Configuring AIFs for 128fs\n");
wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE) wm8994->aifdiv[0] = snd_soc_component_read32(component, WM8994_AIF1_RATE)
& WM8994_AIF1CLK_RATE_MASK; & WM8994_AIF1CLK_RATE_MASK;
wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE) wm8994->aifdiv[1] = snd_soc_component_read32(component, WM8994_AIF2_RATE)
& WM8994_AIF1CLK_RATE_MASK; & WM8994_AIF1CLK_RATE_MASK;
snd_soc_update_bits(codec, WM8994_AIF1_RATE, snd_soc_component_update_bits(component, WM8994_AIF1_RATE,
WM8994_AIF1CLK_RATE_MASK, 0x1); WM8994_AIF1CLK_RATE_MASK, 0x1);
snd_soc_update_bits(codec, WM8994_AIF2_RATE, snd_soc_component_update_bits(component, WM8994_AIF2_RATE,
WM8994_AIF2CLK_RATE_MASK, 0x1); WM8994_AIF2CLK_RATE_MASK, 0x1);
} else if (wm8994->aifdiv[0]) { } else if (wm8994->aifdiv[0]) {
snd_soc_update_bits(codec, WM8994_AIF1_RATE, snd_soc_component_update_bits(component, WM8994_AIF1_RATE,
WM8994_AIF1CLK_RATE_MASK, WM8994_AIF1CLK_RATE_MASK,
wm8994->aifdiv[0]); wm8994->aifdiv[0]);
snd_soc_update_bits(codec, WM8994_AIF2_RATE, snd_soc_component_update_bits(component, WM8994_AIF2_RATE,
WM8994_AIF2CLK_RATE_MASK, WM8994_AIF2CLK_RATE_MASK,
wm8994->aifdiv[1]); wm8994->aifdiv[1]);
...@@ -2368,14 +2368,14 @@ static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 }; ...@@ -2368,14 +2368,14 @@ static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 };
static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src, static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src,
unsigned int freq_in, unsigned int freq_out) unsigned int freq_in, unsigned int freq_out)
{ {
return _wm8994_set_fll(dai->codec, id, src, freq_in, freq_out); return _wm8994_set_fll(dai->component, id, src, freq_in, freq_out);
} }
static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, static int wm8994_set_dai_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 wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int i; int i;
switch (dai->id) { switch (dai->id) {
...@@ -2424,12 +2424,12 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -2424,12 +2424,12 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
break; break;
if (i == ARRAY_SIZE(opclk_divs)) if (i == ARRAY_SIZE(opclk_divs))
return -EINVAL; return -EINVAL;
snd_soc_update_bits(codec, WM8994_CLOCKING_2, snd_soc_component_update_bits(component, WM8994_CLOCKING_2,
WM8994_OPCLK_DIV_MASK, i); WM8994_OPCLK_DIV_MASK, i);
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_2,
WM8994_OPCLK_ENA, WM8994_OPCLK_ENA); WM8994_OPCLK_ENA, WM8994_OPCLK_ENA);
} else { } else {
snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2, snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_2,
WM8994_OPCLK_ENA, 0); WM8994_OPCLK_ENA, 0);
} }
...@@ -2437,29 +2437,29 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -2437,29 +2437,29 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
return -EINVAL; return -EINVAL;
} }
configure_clock(codec); configure_clock(component);
/* /*
* If SYSCLK will be less than 50kHz adjust AIFnCLK dividers * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers
* for detection. * for detection.
*/ */
if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
dev_dbg(codec->dev, "Configuring AIFs for 128fs\n"); dev_dbg(component->dev, "Configuring AIFs for 128fs\n");
wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE) wm8994->aifdiv[0] = snd_soc_component_read32(component, WM8994_AIF1_RATE)
& WM8994_AIF1CLK_RATE_MASK; & WM8994_AIF1CLK_RATE_MASK;
wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE) wm8994->aifdiv[1] = snd_soc_component_read32(component, WM8994_AIF2_RATE)
& WM8994_AIF1CLK_RATE_MASK; & WM8994_AIF1CLK_RATE_MASK;
snd_soc_update_bits(codec, WM8994_AIF1_RATE, snd_soc_component_update_bits(component, WM8994_AIF1_RATE,
WM8994_AIF1CLK_RATE_MASK, 0x1); WM8994_AIF1CLK_RATE_MASK, 0x1);
snd_soc_update_bits(codec, WM8994_AIF2_RATE, snd_soc_component_update_bits(component, WM8994_AIF2_RATE,
WM8994_AIF2CLK_RATE_MASK, 0x1); WM8994_AIF2CLK_RATE_MASK, 0x1);
} else if (wm8994->aifdiv[0]) { } else if (wm8994->aifdiv[0]) {
snd_soc_update_bits(codec, WM8994_AIF1_RATE, snd_soc_component_update_bits(component, WM8994_AIF1_RATE,
WM8994_AIF1CLK_RATE_MASK, WM8994_AIF1CLK_RATE_MASK,
wm8994->aifdiv[0]); wm8994->aifdiv[0]);
snd_soc_update_bits(codec, WM8994_AIF2_RATE, snd_soc_component_update_bits(component, WM8994_AIF2_RATE,
WM8994_AIF2CLK_RATE_MASK, WM8994_AIF2CLK_RATE_MASK,
wm8994->aifdiv[1]); wm8994->aifdiv[1]);
...@@ -2470,13 +2470,13 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -2470,13 +2470,13 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
return 0; return 0;
} }
static int wm8994_set_bias_level(struct snd_soc_codec *codec, static int wm8994_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
wm_hubs_set_bias_level(codec, level); wm_hubs_set_bias_level(component, level);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -2487,26 +2487,26 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -2487,26 +2487,26 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
switch (control->type) { switch (control->type) {
case WM8958: case WM8958:
case WM1811: case WM1811:
snd_soc_update_bits(codec, WM8958_MICBIAS1, snd_soc_component_update_bits(component, WM8958_MICBIAS1,
WM8958_MICB1_MODE, 0); WM8958_MICB1_MODE, 0);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_MODE, 0); WM8958_MICB2_MODE, 0);
break; break;
default: default:
break; break;
} }
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY)
active_reference(codec); active_reference(component);
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) {
switch (control->type) { switch (control->type) {
case WM8958: case WM8958:
if (control->revision == 0) { if (control->revision == 0) {
/* Optimise performance for rev A */ /* Optimise performance for rev A */
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
WM8958_CHARGE_PUMP_2, WM8958_CHARGE_PUMP_2,
WM8958_CP_DISCH, WM8958_CP_DISCH,
WM8958_CP_DISCH); WM8958_CP_DISCH);
...@@ -2518,24 +2518,24 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -2518,24 +2518,24 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
} }
/* Discharge LINEOUT1 & 2 */ /* Discharge LINEOUT1 & 2 */
snd_soc_update_bits(codec, WM8994_ANTIPOP_1, snd_soc_component_update_bits(component, WM8994_ANTIPOP_1,
WM8994_LINEOUT1_DISCH | WM8994_LINEOUT1_DISCH |
WM8994_LINEOUT2_DISCH, WM8994_LINEOUT2_DISCH,
WM8994_LINEOUT1_DISCH | WM8994_LINEOUT1_DISCH |
WM8994_LINEOUT2_DISCH); WM8994_LINEOUT2_DISCH);
} }
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE)
active_dereference(codec); active_dereference(component);
/* MICBIAS into bypass mode on newer devices */ /* MICBIAS into bypass mode on newer devices */
switch (control->type) { switch (control->type) {
case WM8958: case WM8958:
case WM1811: case WM1811:
snd_soc_update_bits(codec, WM8958_MICBIAS1, snd_soc_component_update_bits(component, WM8958_MICBIAS1,
WM8958_MICB1_MODE, WM8958_MICB1_MODE,
WM8958_MICB1_MODE); WM8958_MICB1_MODE);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_MODE, WM8958_MICB2_MODE,
WM8958_MICB2_MODE); WM8958_MICB2_MODE);
break; break;
...@@ -2545,7 +2545,7 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -2545,7 +2545,7 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY)
wm8994->cur_fw = NULL; wm8994->cur_fw = NULL;
break; break;
} }
...@@ -2553,10 +2553,10 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, ...@@ -2553,10 +2553,10 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
switch (mode) { switch (mode) {
case WM8994_VMID_NORMAL: case WM8994_VMID_NORMAL:
...@@ -2613,8 +2613,8 @@ int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) ...@@ -2613,8 +2613,8 @@ int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode)
static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int ms_reg; int ms_reg;
int aif1_reg; int aif1_reg;
...@@ -2717,7 +2717,7 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2717,7 +2717,7 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
case WM1811: case WM1811:
case WM8958: case WM8958:
if (dai->id == 2) if (dai->id == 2)
snd_soc_update_bits(codec, WM8958_AIF3_CONTROL_1, snd_soc_component_update_bits(component, WM8958_AIF3_CONTROL_1,
WM8994_AIF1_LRCLK_INV | WM8994_AIF1_LRCLK_INV |
WM8958_AIF3_FMT_MASK, aif1); WM8958_AIF3_FMT_MASK, aif1);
break; break;
...@@ -2726,15 +2726,15 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -2726,15 +2726,15 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
break; break;
} }
snd_soc_update_bits(codec, aif1_reg, snd_soc_component_update_bits(component, aif1_reg,
WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV | WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV |
WM8994_AIF1_FMT_MASK, WM8994_AIF1_FMT_MASK,
aif1); aif1);
snd_soc_update_bits(codec, ms_reg, WM8994_AIF1_MSTR, snd_soc_component_update_bits(component, ms_reg, WM8994_AIF1_MSTR,
ms); ms);
snd_soc_update_bits(codec, dac_reg, snd_soc_component_update_bits(component, dac_reg,
WM8958_AIF1_LRCLK_INV, lrclk); WM8958_AIF1_LRCLK_INV, lrclk);
snd_soc_update_bits(codec, adc_reg, snd_soc_component_update_bits(component, adc_reg,
WM8958_AIF1_LRCLK_INV, lrclk); WM8958_AIF1_LRCLK_INV, lrclk);
return 0; return 0;
...@@ -2769,8 +2769,8 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2769,8 +2769,8 @@ static int wm8994_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 wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int aif1_reg; int aif1_reg;
...@@ -2798,7 +2798,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2798,7 +2798,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
lrclk_reg = WM8994_AIF1DAC_LRCLK; lrclk_reg = WM8994_AIF1DAC_LRCLK;
} else { } else {
lrclk_reg = WM8994_AIF1ADC_LRCLK; lrclk_reg = WM8994_AIF1ADC_LRCLK;
dev_dbg(codec->dev, "AIF1 using split LRCLK\n"); dev_dbg(component->dev, "AIF1 using split LRCLK\n");
} }
break; break;
case 2: case 2:
...@@ -2811,7 +2811,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2811,7 +2811,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
lrclk_reg = WM8994_AIF2DAC_LRCLK; lrclk_reg = WM8994_AIF2DAC_LRCLK;
} else { } else {
lrclk_reg = WM8994_AIF2ADC_LRCLK; lrclk_reg = WM8994_AIF2ADC_LRCLK;
dev_dbg(codec->dev, "AIF2 using split LRCLK\n"); dev_dbg(component->dev, "AIF2 using split LRCLK\n");
} }
break; break;
default: default:
...@@ -2870,7 +2870,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2870,7 +2870,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
dai->id, wm8994->aifclk[id], bclk_rate); dai->id, wm8994->aifclk[id], bclk_rate);
if (wm8994->channels[id] == 1 && if (wm8994->channels[id] == 1 &&
(snd_soc_read(codec, aif1_reg) & 0x18) == 0x18) (snd_soc_component_read32(component, aif1_reg) & 0x18) == 0x18)
aif2 |= WM8994_AIF1_MONO; aif2 |= WM8994_AIF1_MONO;
if (wm8994->aifclk[id] == 0) { if (wm8994->aifclk[id] == 0) {
...@@ -2920,24 +2920,24 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, ...@@ -2920,24 +2920,24 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
lrclk, bclk_rate / lrclk); lrclk, bclk_rate / lrclk);
snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1); snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
snd_soc_update_bits(codec, aif2_reg, WM8994_AIF1_MONO, aif2); snd_soc_component_update_bits(component, aif2_reg, WM8994_AIF1_MONO, aif2);
snd_soc_update_bits(codec, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk); snd_soc_component_update_bits(component, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk);
snd_soc_update_bits(codec, lrclk_reg, WM8994_AIF1DAC_RATE_MASK, snd_soc_component_update_bits(component, lrclk_reg, WM8994_AIF1DAC_RATE_MASK,
lrclk); lrclk);
snd_soc_update_bits(codec, rate_reg, WM8994_AIF1_SR_MASK | snd_soc_component_update_bits(component, rate_reg, WM8994_AIF1_SR_MASK |
WM8994_AIF1CLK_RATE_MASK, rate_val); WM8994_AIF1CLK_RATE_MASK, rate_val);
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
switch (dai->id) { switch (dai->id) {
case 1: case 1:
wm8994->dac_rates[0] = params_rate(params); wm8994->dac_rates[0] = params_rate(params);
wm8994_set_retune_mobile(codec, 0); wm8994_set_retune_mobile(component, 0);
wm8994_set_retune_mobile(codec, 1); wm8994_set_retune_mobile(component, 1);
break; break;
case 2: case 2:
wm8994->dac_rates[1] = params_rate(params); wm8994->dac_rates[1] = params_rate(params);
wm8994_set_retune_mobile(codec, 2); wm8994_set_retune_mobile(component, 2);
break; break;
} }
} }
...@@ -2949,8 +2949,8 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream, ...@@ -2949,8 +2949,8 @@ static int wm8994_aif3_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 wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int aif1_reg; int aif1_reg;
int aif1 = 0; int aif1 = 0;
...@@ -2986,12 +2986,12 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream, ...@@ -2986,12 +2986,12 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream,
return -EINVAL; return -EINVAL;
} }
return snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1); return snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1);
} }
static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute) static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int mute_reg; int mute_reg;
int reg; int reg;
...@@ -3011,14 +3011,14 @@ static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute) ...@@ -3011,14 +3011,14 @@ static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute)
else else
reg = 0; reg = 0;
snd_soc_update_bits(codec, mute_reg, WM8994_AIF1DAC1_MUTE, reg); snd_soc_component_update_bits(component, mute_reg, WM8994_AIF1DAC1_MUTE, reg);
return 0; return 0;
} }
static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate) static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int reg, val, mask; int reg, val, mask;
switch (codec_dai->id) { switch (codec_dai->id) {
...@@ -3039,19 +3039,19 @@ static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate) ...@@ -3039,19 +3039,19 @@ static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
else else
val = 0; val = 0;
return snd_soc_update_bits(codec, reg, mask, val); return snd_soc_component_update_bits(component, reg, mask, val);
} }
static int wm8994_aif2_probe(struct snd_soc_dai *dai) static int wm8994_aif2_probe(struct snd_soc_dai *dai)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
/* Disable the pulls on the AIF if we're using it to save power. */ /* Disable the pulls on the AIF if we're using it to save power. */
snd_soc_update_bits(codec, WM8994_GPIO_3, snd_soc_component_update_bits(component, WM8994_GPIO_3,
WM8994_GPN_PU | WM8994_GPN_PD, 0); WM8994_GPN_PU | WM8994_GPN_PD, 0);
snd_soc_update_bits(codec, WM8994_GPIO_4, snd_soc_component_update_bits(component, WM8994_GPIO_4,
WM8994_GPN_PU | WM8994_GPN_PD, 0); WM8994_GPN_PU | WM8994_GPN_PD, 0);
snd_soc_update_bits(codec, WM8994_GPIO_5, snd_soc_component_update_bits(component, WM8994_GPIO_5,
WM8994_GPN_PU | WM8994_GPN_PD, 0); WM8994_GPN_PU | WM8994_GPN_PD, 0);
return 0; return 0;
...@@ -3152,53 +3152,53 @@ static struct snd_soc_dai_driver wm8994_dai[] = { ...@@ -3152,53 +3152,53 @@ static struct snd_soc_dai_driver wm8994_dai[] = {
}; };
#ifdef CONFIG_PM #ifdef CONFIG_PM
static int wm8994_codec_suspend(struct snd_soc_codec *codec) static int wm8994_component_suspend(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int i, ret; int i, ret;
for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) {
memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i], memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i],
sizeof(struct wm8994_fll_config)); sizeof(struct wm8994_fll_config));
ret = _wm8994_set_fll(codec, i + 1, 0, 0, 0); ret = _wm8994_set_fll(component, i + 1, 0, 0, 0);
if (ret < 0) if (ret < 0)
dev_warn(codec->dev, "Failed to stop FLL%d: %d\n", dev_warn(component->dev, "Failed to stop FLL%d: %d\n",
i + 1, ret); i + 1, ret);
} }
snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
return 0; return 0;
} }
static int wm8994_codec_resume(struct snd_soc_codec *codec) static int wm8994_component_resume(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int i, ret; int i, ret;
for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) {
if (!wm8994->fll_suspend[i].out) if (!wm8994->fll_suspend[i].out)
continue; continue;
ret = _wm8994_set_fll(codec, i + 1, ret = _wm8994_set_fll(component, i + 1,
wm8994->fll_suspend[i].src, wm8994->fll_suspend[i].src,
wm8994->fll_suspend[i].in, wm8994->fll_suspend[i].in,
wm8994->fll_suspend[i].out); wm8994->fll_suspend[i].out);
if (ret < 0) if (ret < 0)
dev_warn(codec->dev, "Failed to restore FLL%d: %d\n", dev_warn(component->dev, "Failed to restore FLL%d: %d\n",
i + 1, ret); i + 1, ret);
} }
return 0; return 0;
} }
#else #else
#define wm8994_codec_suspend NULL #define wm8994_component_suspend NULL
#define wm8994_codec_resume NULL #define wm8994_component_resume NULL
#endif #endif
static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
{ {
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
struct snd_kcontrol_new controls[] = { struct snd_kcontrol_new controls[] = {
...@@ -3251,22 +3251,22 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) ...@@ -3251,22 +3251,22 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
wm8994->retune_mobile_texts = t; wm8994->retune_mobile_texts = t;
} }
dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n",
wm8994->num_retune_mobile_texts); wm8994->num_retune_mobile_texts);
wm8994->retune_mobile_enum.items = wm8994->num_retune_mobile_texts; wm8994->retune_mobile_enum.items = wm8994->num_retune_mobile_texts;
wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts; wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, ret = snd_soc_add_component_controls(wm8994->hubs.component, controls,
ARRAY_SIZE(controls)); ARRAY_SIZE(controls));
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add ReTune Mobile controls: %d\n", ret); "Failed to add ReTune Mobile controls: %d\n", ret);
} }
static void wm8994_handle_pdata(struct wm8994_priv *wm8994) static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
{ {
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct wm8994_pdata *pdata = &control->pdata; struct wm8994_pdata *pdata = &control->pdata;
int ret, i; int ret, i;
...@@ -3274,7 +3274,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3274,7 +3274,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
if (!pdata) if (!pdata)
return; return;
wm_hubs_handle_analogue_pdata(codec, pdata->lineout1_diff, wm_hubs_handle_analogue_pdata(component, pdata->lineout1_diff,
pdata->lineout2_diff, pdata->lineout2_diff,
pdata->lineout1fb, pdata->lineout1fb,
pdata->lineout2fb, pdata->lineout2fb,
...@@ -3285,7 +3285,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3285,7 +3285,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
pdata->micbias1_lvl, pdata->micbias1_lvl,
pdata->micbias2_lvl); pdata->micbias2_lvl);
dev_dbg(codec->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs);
if (pdata->num_drc_cfgs) { if (pdata->num_drc_cfgs) {
struct snd_kcontrol_new controls[] = { struct snd_kcontrol_new controls[] = {
...@@ -3298,7 +3298,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3298,7 +3298,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
}; };
/* We need an array of texts for the enum API */ /* We need an array of texts for the enum API */
wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev, wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev,
sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL);
if (!wm8994->drc_texts) if (!wm8994->drc_texts)
return; return;
...@@ -3309,33 +3309,33 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3309,33 +3309,33 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
wm8994->drc_enum.items = pdata->num_drc_cfgs; wm8994->drc_enum.items = pdata->num_drc_cfgs;
wm8994->drc_enum.texts = wm8994->drc_texts; wm8994->drc_enum.texts = wm8994->drc_texts;
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, ret = snd_soc_add_component_controls(wm8994->hubs.component, controls,
ARRAY_SIZE(controls)); ARRAY_SIZE(controls));
for (i = 0; i < WM8994_NUM_DRC; i++) for (i = 0; i < WM8994_NUM_DRC; i++)
wm8994_set_drc(codec, i); wm8994_set_drc(component, i);
} else { } else {
ret = snd_soc_add_codec_controls(wm8994->hubs.codec, ret = snd_soc_add_component_controls(wm8994->hubs.component,
wm8994_drc_controls, wm8994_drc_controls,
ARRAY_SIZE(wm8994_drc_controls)); ARRAY_SIZE(wm8994_drc_controls));
} }
if (ret != 0) if (ret != 0)
dev_err(wm8994->hubs.codec->dev, dev_err(wm8994->hubs.component->dev,
"Failed to add DRC mode controls: %d\n", ret); "Failed to add DRC mode controls: %d\n", ret);
dev_dbg(codec->dev, "%d ReTune Mobile configurations\n", dev_dbg(component->dev, "%d ReTune Mobile configurations\n",
pdata->num_retune_mobile_cfgs); pdata->num_retune_mobile_cfgs);
if (pdata->num_retune_mobile_cfgs) if (pdata->num_retune_mobile_cfgs)
wm8994_handle_retune_mobile_pdata(wm8994); wm8994_handle_retune_mobile_pdata(wm8994);
else else
snd_soc_add_codec_controls(wm8994->hubs.codec, wm8994_eq_controls, snd_soc_add_component_controls(wm8994->hubs.component, wm8994_eq_controls,
ARRAY_SIZE(wm8994_eq_controls)); ARRAY_SIZE(wm8994_eq_controls));
for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) { for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) {
if (pdata->micbias[i]) { if (pdata->micbias[i]) {
snd_soc_write(codec, WM8958_MICBIAS1 + i, snd_soc_component_write(component, WM8958_MICBIAS1 + i,
pdata->micbias[i] & 0xffff); pdata->micbias[i] & 0xffff);
} }
} }
...@@ -3344,7 +3344,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3344,7 +3344,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
/** /**
* wm8994_mic_detect - Enable microphone detection via the WM8994 IRQ * wm8994_mic_detect - Enable microphone detection via the WM8994 IRQ
* *
* @codec: WM8994 codec * @component: WM8994 component
* @jack: jack to report detection events on * @jack: jack to report detection events on
* @micbias: microphone bias to detect on * @micbias: microphone bias to detect on
* *
...@@ -3356,17 +3356,17 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) ...@@ -3356,17 +3356,17 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
* Configuration of detection levels is available via the micbias1_lvl * Configuration of detection levels is available via the micbias1_lvl
* and micbias2_lvl platform data members. * and micbias2_lvl platform data members.
*/ */
int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
int micbias) int micbias)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994_micdet *micdet; struct wm8994_micdet *micdet;
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int reg, ret; int reg, ret;
if (control->type != WM8994) { if (control->type != WM8994) {
dev_warn(codec->dev, "Not a WM8994\n"); dev_warn(component->dev, "Not a WM8994\n");
return -EINVAL; return -EINVAL;
} }
...@@ -3386,15 +3386,15 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -3386,15 +3386,15 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
ret = snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); ret = snd_soc_dapm_disable_pin(dapm, "MICBIAS1");
break; break;
default: default:
dev_warn(codec->dev, "Invalid MICBIAS %d\n", micbias); dev_warn(component->dev, "Invalid MICBIAS %d\n", micbias);
return -EINVAL; return -EINVAL;
} }
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, "Failed to configure MICBIAS%d: %d\n", dev_warn(component->dev, "Failed to configure MICBIAS%d: %d\n",
micbias, ret); micbias, ret);
dev_dbg(codec->dev, "Configuring microphone detection on %d %p\n", dev_dbg(component->dev, "Configuring microphone detection on %d %p\n",
micbias, jack); micbias, jack);
/* Store the configuration */ /* Store the configuration */
...@@ -3407,10 +3407,10 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -3407,10 +3407,10 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
else else
reg = 0; reg = 0;
snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, reg); snd_soc_component_update_bits(component, WM8994_MICBIAS, WM8994_MICD_ENA, reg);
/* enable MICDET and MICSHRT deboune */ /* enable MICDET and MICSHRT deboune */
snd_soc_update_bits(codec, WM8994_IRQ_DEBOUNCE, snd_soc_component_update_bits(component, WM8994_IRQ_DEBOUNCE,
WM8994_MIC1_DET_DB_MASK | WM8994_MIC1_SHRT_DB_MASK | WM8994_MIC1_DET_DB_MASK | WM8994_MIC1_SHRT_DB_MASK |
WM8994_MIC2_DET_DB_MASK | WM8994_MIC2_SHRT_DB_MASK, WM8994_MIC2_DET_DB_MASK | WM8994_MIC2_SHRT_DB_MASK,
WM8994_MIC1_DET_DB | WM8994_MIC1_SHRT_DB); WM8994_MIC1_DET_DB | WM8994_MIC1_SHRT_DB);
...@@ -3488,13 +3488,13 @@ static void wm8994_mic_work(struct work_struct *work) ...@@ -3488,13 +3488,13 @@ static void wm8994_mic_work(struct work_struct *work)
static irqreturn_t wm8994_mic_irq(int irq, void *data) static irqreturn_t wm8994_mic_irq(int irq, void *data)
{ {
struct wm8994_priv *priv = data; struct wm8994_priv *priv = data;
struct snd_soc_codec *codec = priv->hubs.codec; struct snd_soc_component *component = priv->hubs.component;
#ifndef CONFIG_SND_SOC_WM8994_MODULE #ifndef CONFIG_SND_SOC_WM8994_MODULE
trace_snd_soc_jack_irq(dev_name(codec->dev)); trace_snd_soc_jack_irq(dev_name(component->dev));
#endif #endif
pm_wakeup_event(codec->dev, 300); pm_wakeup_event(component->dev, 300);
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&priv->mic_work, msecs_to_jiffies(250)); &priv->mic_work, msecs_to_jiffies(250));
...@@ -3503,25 +3503,25 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data) ...@@ -3503,25 +3503,25 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data)
} }
/* Should be called with accdet_lock held */ /* Should be called with accdet_lock held */
static void wm1811_micd_stop(struct snd_soc_codec *codec) static void wm1811_micd_stop(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
if (!wm8994->jackdet) if (!wm8994->jackdet)
return; return;
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0);
wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_JACK);
if (wm8994->wm8994->pdata.jd_ext_cap) if (wm8994->wm8994->pdata.jd_ext_cap)
snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); snd_soc_dapm_disable_pin(dapm, "MICBIAS2");
} }
static void wm8958_button_det(struct snd_soc_codec *codec, u16 status) static void wm8958_button_det(struct snd_soc_component *component, u16 status)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
int report; int report;
report = 0; report = 0;
...@@ -3556,14 +3556,14 @@ static void wm8958_open_circuit_work(struct work_struct *work) ...@@ -3556,14 +3556,14 @@ static void wm8958_open_circuit_work(struct work_struct *work)
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
wm1811_micd_stop(wm8994->hubs.codec); wm1811_micd_stop(wm8994->hubs.component);
dev_dbg(dev, "Reporting open circuit\n"); dev_dbg(dev, "Reporting open circuit\n");
wm8994->jack_mic = false; wm8994->jack_mic = false;
wm8994->mic_detecting = true; wm8994->mic_detecting = true;
wm8958_micd_set_rate(wm8994->hubs.codec); wm8958_micd_set_rate(wm8994->hubs.component);
snd_soc_jack_report(wm8994->micdet[0].jack, 0, snd_soc_jack_report(wm8994->micdet[0].jack, 0,
wm8994->btn_mask | wm8994->btn_mask |
...@@ -3574,13 +3574,13 @@ static void wm8958_open_circuit_work(struct work_struct *work) ...@@ -3574,13 +3574,13 @@ static void wm8958_open_circuit_work(struct work_struct *work)
static void wm8958_mic_id(void *data, u16 status) static void wm8958_mic_id(void *data, u16 status)
{ {
struct snd_soc_codec *codec = data; struct snd_soc_component *component = data;
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
/* Either nothing present or just starting detection */ /* Either nothing present or just starting detection */
if (!(status & WM8958_MICD_STS)) { if (!(status & WM8958_MICD_STS)) {
/* If nothing present then clear our statuses */ /* If nothing present then clear our statuses */
dev_dbg(codec->dev, "Detected open circuit\n"); dev_dbg(component->dev, "Detected open circuit\n");
queue_delayed_work(system_power_efficient_wq, queue_delayed_work(system_power_efficient_wq,
&wm8994->open_circuit_work, &wm8994->open_circuit_work,
...@@ -3592,12 +3592,12 @@ static void wm8958_mic_id(void *data, u16 status) ...@@ -3592,12 +3592,12 @@ static void wm8958_mic_id(void *data, u16 status)
* microphone. * microphone.
*/ */
if (status & 0x600) { if (status & 0x600) {
dev_dbg(codec->dev, "Detected microphone\n"); dev_dbg(component->dev, "Detected microphone\n");
wm8994->mic_detecting = false; wm8994->mic_detecting = false;
wm8994->jack_mic = true; wm8994->jack_mic = true;
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADSET, snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADSET,
SND_JACK_HEADSET); SND_JACK_HEADSET);
...@@ -3605,13 +3605,13 @@ static void wm8958_mic_id(void *data, u16 status) ...@@ -3605,13 +3605,13 @@ static void wm8958_mic_id(void *data, u16 status)
if (status & 0xfc) { if (status & 0xfc) {
dev_dbg(codec->dev, "Detected headphone\n"); dev_dbg(component->dev, "Detected headphone\n");
wm8994->mic_detecting = false; wm8994->mic_detecting = false;
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
/* If we have jackdet that will detect removal */ /* If we have jackdet that will detect removal */
wm1811_micd_stop(codec); wm1811_micd_stop(component);
snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE, snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE,
SND_JACK_HEADSET); SND_JACK_HEADSET);
...@@ -3624,10 +3624,10 @@ static void wm1811_mic_work(struct work_struct *work) ...@@ -3624,10 +3624,10 @@ static void wm1811_mic_work(struct work_struct *work)
struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv, struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv,
mic_work.work); mic_work.work);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
/* If required for an external cap force MICBIAS on */ /* If required for an external cap force MICBIAS on */
if (control->pdata.jd_ext_cap) { if (control->pdata.jd_ext_cap) {
...@@ -3637,7 +3637,7 @@ static void wm1811_mic_work(struct work_struct *work) ...@@ -3637,7 +3637,7 @@ static void wm1811_mic_work(struct work_struct *work)
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
dev_dbg(codec->dev, "Starting mic detection\n"); dev_dbg(component->dev, "Starting mic detection\n");
/* Use a user-supplied callback if we have one */ /* Use a user-supplied callback if we have one */
if (wm8994->micd_cb) { if (wm8994->micd_cb) {
...@@ -3648,54 +3648,54 @@ static void wm1811_mic_work(struct work_struct *work) ...@@ -3648,54 +3648,54 @@ static void wm1811_mic_work(struct work_struct *work)
* what's actually there. * what's actually there.
*/ */
wm8994->mic_detecting = true; wm8994->mic_detecting = true;
wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC); wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_MIC);
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, WM8958_MICD_ENA); WM8958_MICD_ENA, WM8958_MICD_ENA);
} }
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
} }
static irqreturn_t wm1811_jackdet_irq(int irq, void *data) static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
{ {
struct wm8994_priv *wm8994 = data; struct wm8994_priv *wm8994 = data;
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
int reg, delay; int reg, delay;
bool present; bool present;
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
cancel_delayed_work_sync(&wm8994->mic_complete_work); cancel_delayed_work_sync(&wm8994->mic_complete_work);
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
reg = snd_soc_read(codec, WM1811_JACKDET_CTRL); reg = snd_soc_component_read32(component, WM1811_JACKDET_CTRL);
if (reg < 0) { if (reg < 0) {
dev_err(codec->dev, "Failed to read jack status: %d\n", reg); dev_err(component->dev, "Failed to read jack status: %d\n", reg);
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return IRQ_NONE; return IRQ_NONE;
} }
dev_dbg(codec->dev, "JACKDET %x\n", reg); dev_dbg(component->dev, "JACKDET %x\n", reg);
present = reg & WM1811_JACKDET_LVL; present = reg & WM1811_JACKDET_LVL;
if (present) { if (present) {
dev_dbg(codec->dev, "Jack detected\n"); dev_dbg(component->dev, "Jack detected\n");
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_DISCH, 0); WM8958_MICB2_DISCH, 0);
/* Disable debounce while inserted */ /* Disable debounce while inserted */
snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL,
WM1811_JACKDET_DB, 0); WM1811_JACKDET_DB, 0);
delay = control->pdata.micdet_delay; delay = control->pdata.micdet_delay;
...@@ -3703,22 +3703,22 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) ...@@ -3703,22 +3703,22 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
&wm8994->mic_work, &wm8994->mic_work,
msecs_to_jiffies(delay)); msecs_to_jiffies(delay));
} else { } else {
dev_dbg(codec->dev, "Jack not detected\n"); dev_dbg(component->dev, "Jack not detected\n");
cancel_delayed_work_sync(&wm8994->mic_work); cancel_delayed_work_sync(&wm8994->mic_work);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_DISCH, WM8958_MICB2_DISCH); WM8958_MICB2_DISCH, WM8958_MICB2_DISCH);
/* Enable debounce while removed */ /* Enable debounce while removed */
snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL,
WM1811_JACKDET_DB, WM1811_JACKDET_DB); WM1811_JACKDET_DB, WM1811_JACKDET_DB);
wm8994->mic_detecting = false; wm8994->mic_detecting = false;
wm8994->jack_mic = false; wm8994->jack_mic = false;
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, 0); WM8958_MICD_ENA, 0);
wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_JACK);
} }
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
...@@ -3739,7 +3739,7 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) ...@@ -3739,7 +3739,7 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
* avoid bootstrapping issues with the core. */ * avoid bootstrapping issues with the core. */
snd_soc_jack_report(wm8994->micdet[0].jack, 0, 0); snd_soc_jack_report(wm8994->micdet[0].jack, 0, 0);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -3754,7 +3754,7 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work) ...@@ -3754,7 +3754,7 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work)
/** /**
* wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ * wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ
* *
* @codec: WM8958 codec * @component: WM8958 component
* @jack: jack to report detection events on * @jack: jack to report detection events on
* *
* Enable microphone detection functionality for the WM8958. By * Enable microphone detection functionality for the WM8958. By
...@@ -3767,12 +3767,12 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work) ...@@ -3767,12 +3767,12 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work)
* flexiblity a callback is provided which allows a completely custom * flexiblity a callback is provided which allows a completely custom
* detection algorithm. * detection algorithm.
*/ */
int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
wm1811_micdet_cb det_cb, void *det_cb_data, wm1811_micdet_cb det_cb, void *det_cb_data,
wm1811_mic_id_cb id_cb, void *id_cb_data) wm1811_mic_id_cb id_cb, void *id_cb_data)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
u16 micd_lvl_sel; u16 micd_lvl_sel;
...@@ -3803,10 +3803,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -3803,10 +3803,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
wm8994->mic_id_cb_data = id_cb_data; wm8994->mic_id_cb_data = id_cb_data;
} else { } else {
wm8994->mic_id_cb = wm8958_mic_id; wm8994->mic_id_cb = wm8958_mic_id;
wm8994->mic_id_cb_data = codec; wm8994->mic_id_cb_data = component;
} }
wm8958_micd_set_rate(codec); wm8958_micd_set_rate(component);
/* Detect microphones and short circuits by default */ /* Detect microphones and short circuits by default */
if (control->pdata.micd_lvl_sel) if (control->pdata.micd_lvl_sel)
...@@ -3818,10 +3818,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -3818,10 +3818,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_BTN_2 | SND_JACK_BTN_3 |
SND_JACK_BTN_4 | SND_JACK_BTN_5; SND_JACK_BTN_4 | SND_JACK_BTN_5;
snd_soc_update_bits(codec, WM8958_MIC_DETECT_2, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_2,
WM8958_MICD_LVL_SEL_MASK, micd_lvl_sel); WM8958_MICD_LVL_SEL_MASK, micd_lvl_sel);
WARN_ON(snd_soc_codec_get_bias_level(codec) > SND_SOC_BIAS_STANDBY); WARN_ON(snd_soc_component_get_bias_level(component) > SND_SOC_BIAS_STANDBY);
/* /*
* If we can use jack detection start off with that, * If we can use jack detection start off with that,
...@@ -3829,25 +3829,25 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -3829,25 +3829,25 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
*/ */
if (wm8994->jackdet) { if (wm8994->jackdet) {
/* Disable debounce for the initial detect */ /* Disable debounce for the initial detect */
snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL,
WM1811_JACKDET_DB, 0); WM1811_JACKDET_DB, 0);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_DISCH, WM8958_MICB2_DISCH,
WM8958_MICB2_DISCH); WM8958_MICB2_DISCH);
snd_soc_update_bits(codec, WM8994_LDO_1, snd_soc_component_update_bits(component, WM8994_LDO_1,
WM8994_LDO1_DISCH, 0); WM8994_LDO1_DISCH, 0);
wm1811_jackdet_set_mode(codec, wm1811_jackdet_set_mode(component,
WM1811_JACKDET_MODE_JACK); WM1811_JACKDET_MODE_JACK);
} else { } else {
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, WM8958_MICD_ENA); WM8958_MICD_ENA, WM8958_MICD_ENA);
} }
} else { } else {
snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
WM8958_MICD_ENA, 0); WM8958_MICD_ENA, 0);
wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_NONE); wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_NONE);
snd_soc_dapm_disable_pin(dapm, "CLK_SYS"); snd_soc_dapm_disable_pin(dapm, "CLK_SYS");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
} }
...@@ -3861,9 +3861,9 @@ static void wm8958_mic_work(struct work_struct *work) ...@@ -3861,9 +3861,9 @@ static void wm8958_mic_work(struct work_struct *work)
struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv *wm8994 = container_of(work,
struct wm8994_priv, struct wm8994_priv,
mic_complete_work.work); mic_complete_work.work);
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
mutex_lock(&wm8994->accdet_lock); mutex_lock(&wm8994->accdet_lock);
...@@ -3871,13 +3871,13 @@ static void wm8958_mic_work(struct work_struct *work) ...@@ -3871,13 +3871,13 @@ static void wm8958_mic_work(struct work_struct *work)
mutex_unlock(&wm8994->accdet_lock); mutex_unlock(&wm8994->accdet_lock);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
} }
static irqreturn_t wm8958_mic_irq(int irq, void *data) static irqreturn_t wm8958_mic_irq(int irq, void *data)
{ {
struct wm8994_priv *wm8994 = data; struct wm8994_priv *wm8994 = data;
struct snd_soc_codec *codec = wm8994->hubs.codec; struct snd_soc_component *component = wm8994->hubs.component;
int reg, count, ret, id_delay; int reg, count, ret, id_delay;
/* /*
...@@ -3885,30 +3885,30 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) ...@@ -3885,30 +3885,30 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
* with an update of the MICDET status; if so it will have * with an update of the MICDET status; if so it will have
* stopped detection and we can ignore this interrupt. * stopped detection and we can ignore this interrupt.
*/ */
if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) if (!(snd_soc_component_read32(component, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA))
return IRQ_HANDLED; return IRQ_HANDLED;
cancel_delayed_work_sync(&wm8994->mic_complete_work); cancel_delayed_work_sync(&wm8994->mic_complete_work);
cancel_delayed_work_sync(&wm8994->open_circuit_work); cancel_delayed_work_sync(&wm8994->open_circuit_work);
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
/* We may occasionally read a detection without an impedence /* We may occasionally read a detection without an impedence
* range being provided - if that happens loop again. * range being provided - if that happens loop again.
*/ */
count = 10; count = 10;
do { do {
reg = snd_soc_read(codec, WM8958_MIC_DETECT_3); reg = snd_soc_component_read32(component, WM8958_MIC_DETECT_3);
if (reg < 0) { if (reg < 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to read mic detect status: %d\n", "Failed to read mic detect status: %d\n",
reg); reg);
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return IRQ_NONE; return IRQ_NONE;
} }
if (!(reg & WM8958_MICD_VALID)) { if (!(reg & WM8958_MICD_VALID)) {
dev_dbg(codec->dev, "Mic detect data not valid\n"); dev_dbg(component->dev, "Mic detect data not valid\n");
goto out; goto out;
} }
...@@ -3919,20 +3919,20 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) ...@@ -3919,20 +3919,20 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
} while (count--); } while (count--);
if (count == 0) if (count == 0)
dev_warn(codec->dev, "No impedance range reported for jack\n"); dev_warn(component->dev, "No impedance range reported for jack\n");
#ifndef CONFIG_SND_SOC_WM8994_MODULE #ifndef CONFIG_SND_SOC_WM8994_MODULE
trace_snd_soc_jack_irq(dev_name(codec->dev)); trace_snd_soc_jack_irq(dev_name(component->dev));
#endif #endif
/* Avoid a transient report when the accessory is being removed */ /* Avoid a transient report when the accessory is being removed */
if (wm8994->jackdet) { if (wm8994->jackdet) {
ret = snd_soc_read(codec, WM1811_JACKDET_CTRL); ret = snd_soc_component_read32(component, WM1811_JACKDET_CTRL);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read jack status: %d\n", dev_err(component->dev, "Failed to read jack status: %d\n",
ret); ret);
} else if (!(ret & WM1811_JACKDET_LVL)) { } else if (!(ret & WM1811_JACKDET_LVL)) {
dev_dbg(codec->dev, "Ignoring removed jack\n"); dev_dbg(component->dev, "Ignoring removed jack\n");
goto out; goto out;
} }
} else if (!(reg & WM8958_MICD_STS)) { } else if (!(reg & WM8958_MICD_STS)) {
...@@ -3951,51 +3951,51 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) ...@@ -3951,51 +3951,51 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
&wm8994->mic_complete_work, &wm8994->mic_complete_work,
msecs_to_jiffies(id_delay)); msecs_to_jiffies(id_delay));
else else
wm8958_button_det(codec, reg); wm8958_button_det(component, reg);
out: out:
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t wm8994_fifo_error(int irq, void *data) static irqreturn_t wm8994_fifo_error(int irq, void *data)
{ {
struct snd_soc_codec *codec = data; struct snd_soc_component *component = data;
dev_err(codec->dev, "FIFO error\n"); dev_err(component->dev, "FIFO error\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t wm8994_temp_warn(int irq, void *data) static irqreturn_t wm8994_temp_warn(int irq, void *data)
{ {
struct snd_soc_codec *codec = data; struct snd_soc_component *component = data;
dev_err(codec->dev, "Thermal warning\n"); dev_err(component->dev, "Thermal warning\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static irqreturn_t wm8994_temp_shut(int irq, void *data) static irqreturn_t wm8994_temp_shut(int irq, void *data)
{ {
struct snd_soc_codec *codec = data; struct snd_soc_component *component = data;
dev_crit(codec->dev, "Thermal shutdown\n"); dev_crit(component->dev, "Thermal shutdown\n");
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int wm8994_codec_probe(struct snd_soc_codec *codec) static int wm8994_component_probe(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8994 *control = dev_get_drvdata(codec->dev->parent); struct wm8994 *control = dev_get_drvdata(component->dev->parent);
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
unsigned int reg; unsigned int reg;
int ret, i; int ret, i;
snd_soc_codec_init_regmap(codec, control->regmap); snd_soc_component_init_regmap(component, control->regmap);
wm8994->hubs.codec = codec; wm8994->hubs.component = component;
mutex_init(&wm8994->accdet_lock); mutex_init(&wm8994->accdet_lock);
INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
...@@ -4070,7 +4070,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4070,7 +4070,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994->hubs.dcs_codes_l = -9; wm8994->hubs.dcs_codes_l = -9;
wm8994->hubs.dcs_codes_r = -7; wm8994->hubs.dcs_codes_r = -7;
snd_soc_update_bits(codec, WM8994_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8994_ANALOGUE_HP_1,
WM1811_HPOUT1_ATTN, WM1811_HPOUT1_ATTN); WM1811_HPOUT1_ATTN, WM1811_HPOUT1_ATTN);
break; break;
...@@ -4079,11 +4079,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4079,11 +4079,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
} }
wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR,
wm8994_fifo_error, "FIFO error", codec); wm8994_fifo_error, "FIFO error", component);
wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN,
wm8994_temp_warn, "Thermal warning", codec); wm8994_temp_warn, "Thermal warning", component);
wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT,
wm8994_temp_shut, "Thermal shutdown", codec); wm8994_temp_shut, "Thermal shutdown", component);
switch (control->type) { switch (control->type) {
case WM8994: case WM8994:
...@@ -4101,7 +4101,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4101,7 +4101,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994); wm8994);
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to request Mic1 detect IRQ: %d\n", "Failed to request Mic1 detect IRQ: %d\n",
ret); ret);
...@@ -4111,7 +4111,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4111,7 +4111,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994_mic_irq, "Mic 1 short", wm8994_mic_irq, "Mic 1 short",
wm8994); wm8994);
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to request Mic1 short IRQ: %d\n", "Failed to request Mic1 short IRQ: %d\n",
ret); ret);
...@@ -4120,7 +4120,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4120,7 +4120,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994_mic_irq, "Mic 2 detect", wm8994_mic_irq, "Mic 2 detect",
wm8994); wm8994);
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to request Mic2 detect IRQ: %d\n", "Failed to request Mic2 detect IRQ: %d\n",
ret); ret);
...@@ -4129,7 +4129,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4129,7 +4129,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994_mic_irq, "Mic 2 short", wm8994_mic_irq, "Mic 2 short",
wm8994); wm8994);
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to request Mic2 short IRQ: %d\n", "Failed to request Mic2 short IRQ: %d\n",
ret); ret);
break; break;
...@@ -4144,7 +4144,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4144,7 +4144,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
"Mic detect", "Mic detect",
wm8994); wm8994);
if (ret != 0) if (ret != 0)
dev_warn(codec->dev, dev_warn(component->dev,
"Failed to request Mic detect IRQ: %d\n", "Failed to request Mic detect IRQ: %d\n",
ret); ret);
} else { } else {
...@@ -4180,7 +4180,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4180,7 +4180,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
} }
/* Make sure we can read from the GPIOs if they're inputs */ /* Make sure we can read from the GPIOs if they're inputs */
pm_runtime_get_sync(codec->dev); pm_runtime_get_sync(component->dev);
/* Remember if AIFnLRCLK is configured as a GPIO. This should be /* Remember if AIFnLRCLK is configured as a GPIO. This should be
* configured on init - if a system wants to do this dynamically * configured on init - if a system wants to do this dynamically
...@@ -4188,7 +4188,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4188,7 +4188,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
*/ */
ret = regmap_read(control->regmap, WM8994_GPIO_1, &reg); ret = regmap_read(control->regmap, WM8994_GPIO_1, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret); dev_err(component->dev, "Failed to read GPIO1 state: %d\n", ret);
goto err_irq; goto err_irq;
} }
if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
...@@ -4200,7 +4200,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4200,7 +4200,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
ret = regmap_read(control->regmap, WM8994_GPIO_6, &reg); ret = regmap_read(control->regmap, WM8994_GPIO_6, &reg);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret); dev_err(component->dev, "Failed to read GPIO6 state: %d\n", ret);
goto err_irq; goto err_irq;
} }
if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) {
...@@ -4210,22 +4210,22 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4210,22 +4210,22 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
wm8994->lrclk_shared[1] = 0; wm8994->lrclk_shared[1] = 0;
} }
pm_runtime_put(codec->dev); pm_runtime_put(component->dev);
/* Latch volume update bits */ /* Latch volume update bits */
for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++)
snd_soc_update_bits(codec, wm8994_vu_bits[i].reg, snd_soc_component_update_bits(component, wm8994_vu_bits[i].reg,
wm8994_vu_bits[i].mask, wm8994_vu_bits[i].mask,
wm8994_vu_bits[i].mask); wm8994_vu_bits[i].mask);
/* Set the low bit of the 3D stereo depth so TLV matches */ /* Set the low bit of the 3D stereo depth so TLV matches */
snd_soc_update_bits(codec, WM8994_AIF1_DAC1_FILTERS_2, snd_soc_component_update_bits(component, WM8994_AIF1_DAC1_FILTERS_2,
1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT, 1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT,
1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT); 1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT);
snd_soc_update_bits(codec, WM8994_AIF1_DAC2_FILTERS_2, snd_soc_component_update_bits(component, WM8994_AIF1_DAC2_FILTERS_2,
1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT, 1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT,
1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT); 1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT);
snd_soc_update_bits(codec, WM8994_AIF2_DAC_FILTERS_2, snd_soc_component_update_bits(component, WM8994_AIF2_DAC_FILTERS_2,
1 << WM8994_AIF2DAC_3D_GAIN_SHIFT, 1 << WM8994_AIF2DAC_3D_GAIN_SHIFT,
1 << WM8994_AIF2DAC_3D_GAIN_SHIFT); 1 << WM8994_AIF2DAC_3D_GAIN_SHIFT);
...@@ -4235,7 +4235,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4235,7 +4235,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
switch (control->type) { switch (control->type) {
case WM8994: case WM8994:
case WM8958: case WM8958:
snd_soc_update_bits(codec, WM8994_AIF1_CONTROL_1, snd_soc_component_update_bits(component, WM8994_AIF1_CONTROL_1,
WM8994_AIF1ADC_TDM, WM8994_AIF1ADC_TDM); WM8994_AIF1ADC_TDM, WM8994_AIF1ADC_TDM);
break; break;
default: default:
...@@ -4246,9 +4246,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4246,9 +4246,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
switch (control->type) { switch (control->type) {
case WM8958: case WM8958:
case WM1811: case WM1811:
snd_soc_update_bits(codec, WM8958_MICBIAS1, snd_soc_component_update_bits(component, WM8958_MICBIAS1,
WM8958_MICB1_MODE, WM8958_MICB1_MODE); WM8958_MICB1_MODE, WM8958_MICB1_MODE);
snd_soc_update_bits(codec, WM8958_MICBIAS2, snd_soc_component_update_bits(component, WM8958_MICBIAS2,
WM8958_MICB2_MODE, WM8958_MICB2_MODE); WM8958_MICB2_MODE, WM8958_MICB2_MODE);
break; break;
default: default:
...@@ -4256,12 +4256,12 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4256,12 +4256,12 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
} }
wm8994->hubs.check_class_w_digital = wm8994_check_class_w_digital; wm8994->hubs.check_class_w_digital = wm8994_check_class_w_digital;
wm_hubs_update_class_w(codec); wm_hubs_update_class_w(component);
wm8994_handle_pdata(wm8994); wm8994_handle_pdata(wm8994);
wm_hubs_add_analogue_controls(codec); wm_hubs_add_analogue_controls(component);
snd_soc_add_codec_controls(codec, wm8994_snd_controls, snd_soc_add_component_controls(component, wm8994_snd_controls,
ARRAY_SIZE(wm8994_snd_controls)); ARRAY_SIZE(wm8994_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8994_dapm_widgets, snd_soc_dapm_new_controls(dapm, wm8994_dapm_widgets,
ARRAY_SIZE(wm8994_dapm_widgets)); ARRAY_SIZE(wm8994_dapm_widgets));
...@@ -4287,7 +4287,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4287,7 +4287,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
} }
break; break;
case WM8958: case WM8958:
snd_soc_add_codec_controls(codec, wm8958_snd_controls, snd_soc_add_component_controls(component, wm8958_snd_controls,
ARRAY_SIZE(wm8958_snd_controls)); ARRAY_SIZE(wm8958_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets, snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets,
ARRAY_SIZE(wm8958_dapm_widgets)); ARRAY_SIZE(wm8958_dapm_widgets));
...@@ -4309,7 +4309,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4309,7 +4309,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
break; break;
case WM1811: case WM1811:
snd_soc_add_codec_controls(codec, wm8958_snd_controls, snd_soc_add_component_controls(component, wm8958_snd_controls,
ARRAY_SIZE(wm8958_snd_controls)); ARRAY_SIZE(wm8958_snd_controls));
snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets, snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets,
ARRAY_SIZE(wm8958_dapm_widgets)); ARRAY_SIZE(wm8958_dapm_widgets));
...@@ -4322,7 +4322,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4322,7 +4322,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
break; break;
} }
wm_hubs_add_analogue_routes(codec, 0, 0); wm_hubs_add_analogue_routes(component, 0, 0);
ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE,
wm_hubs_dcs_done, "DC servo done", wm_hubs_dcs_done, "DC servo done",
&wm8994->hubs); &wm8994->hubs);
...@@ -4360,7 +4360,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4360,7 +4360,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
ARRAY_SIZE(wm8958_intercon)); ARRAY_SIZE(wm8958_intercon));
} }
wm8958_dsp2_init(codec); wm8958_dsp2_init(component);
break; break;
case WM1811: case WM1811:
snd_soc_dapm_add_routes(dapm, wm8994_lateclk_intercon, snd_soc_dapm_add_routes(dapm, wm8994_lateclk_intercon,
...@@ -4385,16 +4385,16 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ...@@ -4385,16 +4385,16 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
&wm8994->fll_locked[i]); &wm8994->fll_locked[i]);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE,
&wm8994->hubs); &wm8994->hubs);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component);
return ret; return ret;
} }
static int wm8994_codec_remove(struct snd_soc_codec *codec) static void wm8994_component_remove(struct snd_soc_component *component)
{ {
struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
struct wm8994 *control = wm8994->wm8994; struct wm8994 *control = wm8994->wm8994;
int i; int i;
...@@ -4404,9 +4404,9 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) ...@@ -4404,9 +4404,9 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE,
&wm8994->hubs); &wm8994->hubs);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component);
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, codec); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component);
if (wm8994->jackdet) if (wm8994->jackdet)
wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_GPIO(6), wm8994); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_GPIO(6), wm8994);
...@@ -4433,15 +4433,18 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) ...@@ -4433,15 +4433,18 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
release_firmware(wm8994->mbc_vss); release_firmware(wm8994->mbc_vss);
release_firmware(wm8994->enh_eq); release_firmware(wm8994->enh_eq);
kfree(wm8994->retune_mobile_texts); kfree(wm8994->retune_mobile_texts);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8994 = { static const struct snd_soc_component_driver soc_component_dev_wm8994 = {
.probe = wm8994_codec_probe, .probe = wm8994_component_probe,
.remove = wm8994_codec_remove, .remove = wm8994_component_remove,
.suspend = wm8994_codec_suspend, .suspend = wm8994_component_suspend,
.resume = wm8994_codec_resume, .resume = wm8994_component_resume,
.set_bias_level = wm8994_set_bias_level, .set_bias_level = wm8994_set_bias_level,
.idle_bias_on = 1,
.use_pmdown_time = 1,
.endianness = 1,
.non_legacy_dai_naming = 1,
}; };
static int wm8994_probe(struct platform_device *pdev) static int wm8994_probe(struct platform_device *pdev)
...@@ -4461,13 +4464,12 @@ static int wm8994_probe(struct platform_device *pdev) ...@@ -4461,13 +4464,12 @@ static int wm8994_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
pm_runtime_idle(&pdev->dev); pm_runtime_idle(&pdev->dev);
return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994, return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8994,
wm8994_dai, ARRAY_SIZE(wm8994_dai)); wm8994_dai, ARRAY_SIZE(wm8994_dai));
} }
static int wm8994_remove(struct platform_device *pdev) static int wm8994_remove(struct platform_device *pdev)
{ {
snd_soc_unregister_codec(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0; return 0;
......
...@@ -43,18 +43,18 @@ enum wm8994_vmid_mode { ...@@ -43,18 +43,18 @@ enum wm8994_vmid_mode {
typedef void (*wm1811_micdet_cb)(void *data); typedef void (*wm1811_micdet_cb)(void *data);
typedef void (*wm1811_mic_id_cb)(void *data, u16 status); typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
int micbias); int micbias);
int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
wm1811_micdet_cb cb, void *det_cb_data, wm1811_micdet_cb cb, void *det_cb_data,
wm1811_mic_id_cb id_cb, void *id_cb_data); wm1811_mic_id_cb id_cb, void *id_cb_data);
int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode); int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode);
int wm8958_aif_ev(struct snd_soc_dapm_widget *w, int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event); struct snd_kcontrol *kcontrol, int event);
void wm8958_dsp2_init(struct snd_soc_codec *codec); void wm8958_dsp2_init(struct snd_soc_component *component);
struct wm8994_micdet { struct wm8994_micdet {
struct snd_soc_jack *jack; struct snd_soc_jack *jack;
......
...@@ -385,7 +385,7 @@ struct wm8995_priv { ...@@ -385,7 +385,7 @@ struct wm8995_priv {
struct fll_config fll[2], fll_suspend[2]; struct fll_config fll[2], fll_suspend[2];
struct regulator_bulk_data supplies[WM8995_NUM_SUPPLIES]; struct regulator_bulk_data supplies[WM8995_NUM_SUPPLIES];
struct notifier_block disable_nb[WM8995_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8995_NUM_SUPPLIES];
struct snd_soc_codec *codec; struct snd_soc_component *component;
}; };
/* /*
...@@ -485,48 +485,48 @@ static const struct snd_kcontrol_new wm8995_snd_controls[] = { ...@@ -485,48 +485,48 @@ static const struct snd_kcontrol_new wm8995_snd_controls[] = {
WM8995_AIF2_ADC_RIGHT_VOLUME, 0, 96, 0, digital_tlv) WM8995_AIF2_ADC_RIGHT_VOLUME, 0, 96, 0, digital_tlv)
}; };
static void wm8995_update_class_w(struct snd_soc_codec *codec) static void wm8995_update_class_w(struct snd_soc_component *component)
{ {
int enable = 1; int enable = 1;
int source = 0; /* GCC flow analysis can't track enable */ int source = 0; /* GCC flow analysis can't track enable */
int reg, reg_r; int reg, reg_r;
/* We also need the same setting for L/R and only one path */ /* We also need the same setting for L/R and only one path */
reg = snd_soc_read(codec, WM8995_DAC1_LEFT_MIXER_ROUTING); reg = snd_soc_component_read32(component, WM8995_DAC1_LEFT_MIXER_ROUTING);
switch (reg) { switch (reg) {
case WM8995_AIF2DACL_TO_DAC1L: case WM8995_AIF2DACL_TO_DAC1L:
dev_dbg(codec->dev, "Class W source AIF2DAC\n"); dev_dbg(component->dev, "Class W source AIF2DAC\n");
source = 2 << WM8995_CP_DYN_SRC_SEL_SHIFT; source = 2 << WM8995_CP_DYN_SRC_SEL_SHIFT;
break; break;
case WM8995_AIF1DAC2L_TO_DAC1L: case WM8995_AIF1DAC2L_TO_DAC1L:
dev_dbg(codec->dev, "Class W source AIF1DAC2\n"); dev_dbg(component->dev, "Class W source AIF1DAC2\n");
source = 1 << WM8995_CP_DYN_SRC_SEL_SHIFT; source = 1 << WM8995_CP_DYN_SRC_SEL_SHIFT;
break; break;
case WM8995_AIF1DAC1L_TO_DAC1L: case WM8995_AIF1DAC1L_TO_DAC1L:
dev_dbg(codec->dev, "Class W source AIF1DAC1\n"); dev_dbg(component->dev, "Class W source AIF1DAC1\n");
source = 0 << WM8995_CP_DYN_SRC_SEL_SHIFT; source = 0 << WM8995_CP_DYN_SRC_SEL_SHIFT;
break; break;
default: default:
dev_dbg(codec->dev, "DAC mixer setting: %x\n", reg); dev_dbg(component->dev, "DAC mixer setting: %x\n", reg);
enable = 0; enable = 0;
break; break;
} }
reg_r = snd_soc_read(codec, WM8995_DAC1_RIGHT_MIXER_ROUTING); reg_r = snd_soc_component_read32(component, WM8995_DAC1_RIGHT_MIXER_ROUTING);
if (reg_r != reg) { if (reg_r != reg) {
dev_dbg(codec->dev, "Left and right DAC mixers different\n"); dev_dbg(component->dev, "Left and right DAC mixers different\n");
enable = 0; enable = 0;
} }
if (enable) { if (enable) {
dev_dbg(codec->dev, "Class W enabled\n"); dev_dbg(component->dev, "Class W enabled\n");
snd_soc_update_bits(codec, WM8995_CLASS_W_1, snd_soc_component_update_bits(component, WM8995_CLASS_W_1,
WM8995_CP_DYN_PWR_MASK | WM8995_CP_DYN_PWR_MASK |
WM8995_CP_DYN_SRC_SEL_MASK, WM8995_CP_DYN_SRC_SEL_MASK,
source | WM8995_CP_DYN_PWR); source | WM8995_CP_DYN_PWR);
} else { } else {
dev_dbg(codec->dev, "Class W disabled\n"); dev_dbg(component->dev, "Class W disabled\n");
snd_soc_update_bits(codec, WM8995_CLASS_W_1, snd_soc_component_update_bits(component, WM8995_CLASS_W_1,
WM8995_CP_DYN_PWR_MASK, 0); WM8995_CP_DYN_PWR_MASK, 0);
} }
} }
...@@ -534,11 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec) ...@@ -534,11 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec)
static int check_clk_sys(struct snd_soc_dapm_widget *source, static int check_clk_sys(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink) struct snd_soc_dapm_widget *sink)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm);
unsigned int reg; unsigned int reg;
const char *clk; const char *clk;
reg = snd_soc_read(codec, WM8995_CLOCKING_1); reg = snd_soc_component_read32(component, WM8995_CLOCKING_1);
/* Check what we're currently using for CLK_SYS */ /* Check what we're currently using for CLK_SYS */
if (reg & WM8995_SYSCLK_SRC) if (reg & WM8995_SYSCLK_SRC)
clk = "AIF2CLK"; clk = "AIF2CLK";
...@@ -550,37 +550,37 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source, ...@@ -550,37 +550,37 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source,
static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, static int wm8995_put_class_w(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
int ret; int ret;
ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
wm8995_update_class_w(codec); wm8995_update_class_w(component);
return ret; return ret;
} }
static int hp_supply_event(struct snd_soc_dapm_widget *w, static int hp_supply_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
/* Enable the headphone amp */ /* Enable the headphone amp */
snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1,
WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1L_ENA_MASK |
WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1R_ENA_MASK,
WM8995_HPOUT1L_ENA | WM8995_HPOUT1L_ENA |
WM8995_HPOUT1R_ENA); WM8995_HPOUT1R_ENA);
/* Enable the second stage */ /* Enable the second stage */
snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1,
WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1L_DLY_MASK |
WM8995_HPOUT1R_DLY_MASK, WM8995_HPOUT1R_DLY_MASK,
WM8995_HPOUT1L_DLY | WM8995_HPOUT1L_DLY |
WM8995_HPOUT1R_DLY); WM8995_HPOUT1R_DLY);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1,
WM8995_CP_ENA_MASK, 0); WM8995_CP_ENA_MASK, 0);
break; break;
} }
...@@ -588,41 +588,41 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, ...@@ -588,41 +588,41 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
static void dc_servo_cmd(struct snd_soc_codec *codec, static void dc_servo_cmd(struct snd_soc_component *component,
unsigned int reg, unsigned int val, unsigned int mask) unsigned int reg, unsigned int val, unsigned int mask)
{ {
int timeout = 10; int timeout = 10;
dev_dbg(codec->dev, "%s: reg = %#x, val = %#x, mask = %#x\n", dev_dbg(component->dev, "%s: reg = %#x, val = %#x, mask = %#x\n",
__func__, reg, val, mask); __func__, reg, val, mask);
snd_soc_write(codec, reg, val); snd_soc_component_write(component, reg, val);
while (timeout--) { while (timeout--) {
msleep(10); msleep(10);
val = snd_soc_read(codec, WM8995_DC_SERVO_READBACK_0); val = snd_soc_component_read32(component, WM8995_DC_SERVO_READBACK_0);
if ((val & mask) == mask) if ((val & mask) == mask)
return; return;
} }
dev_err(codec->dev, "Timed out waiting for DC Servo\n"); dev_err(component->dev, "Timed out waiting for DC Servo\n");
} }
static int hp_event(struct snd_soc_dapm_widget *w, static int hp_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
unsigned int reg; unsigned int reg;
reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1); reg = snd_soc_component_read32(component, WM8995_ANALOGUE_HP_1);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1,
WM8995_CP_ENA_MASK, WM8995_CP_ENA); WM8995_CP_ENA_MASK, WM8995_CP_ENA);
msleep(5); msleep(5);
snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1,
WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1L_ENA_MASK |
WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1R_ENA_MASK,
WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA); WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA);
...@@ -630,12 +630,12 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -630,12 +630,12 @@ static int hp_event(struct snd_soc_dapm_widget *w,
udelay(20); udelay(20);
reg |= WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY; reg |= WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY;
snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg);
snd_soc_write(codec, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 | snd_soc_component_write(component, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 |
WM8995_DCS_ENA_CHAN_1); WM8995_DCS_ENA_CHAN_1);
dc_servo_cmd(codec, WM8995_DC_SERVO_2, dc_servo_cmd(component, WM8995_DC_SERVO_2,
WM8995_DCS_TRIG_STARTUP_0 | WM8995_DCS_TRIG_STARTUP_0 |
WM8995_DCS_TRIG_STARTUP_1, WM8995_DCS_TRIG_STARTUP_1,
WM8995_DCS_TRIG_DAC_WR_0 | WM8995_DCS_TRIG_DAC_WR_0 |
...@@ -643,23 +643,23 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -643,23 +643,23 @@ static int hp_event(struct snd_soc_dapm_widget *w,
reg |= WM8995_HPOUT1R_OUTP | WM8995_HPOUT1R_RMV_SHORT | reg |= WM8995_HPOUT1R_OUTP | WM8995_HPOUT1R_RMV_SHORT |
WM8995_HPOUT1L_OUTP | WM8995_HPOUT1L_RMV_SHORT; WM8995_HPOUT1L_OUTP | WM8995_HPOUT1L_RMV_SHORT;
snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1,
WM8995_HPOUT1L_OUTP_MASK | WM8995_HPOUT1L_OUTP_MASK |
WM8995_HPOUT1R_OUTP_MASK | WM8995_HPOUT1R_OUTP_MASK |
WM8995_HPOUT1L_RMV_SHORT_MASK | WM8995_HPOUT1L_RMV_SHORT_MASK |
WM8995_HPOUT1R_RMV_SHORT_MASK, 0); WM8995_HPOUT1R_RMV_SHORT_MASK, 0);
snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1,
WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1L_DLY_MASK |
WM8995_HPOUT1R_DLY_MASK, 0); WM8995_HPOUT1R_DLY_MASK, 0);
snd_soc_write(codec, WM8995_DC_SERVO_1, 0); snd_soc_component_write(component, WM8995_DC_SERVO_1, 0);
snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1,
WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1L_ENA_MASK |
WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1R_ENA_MASK,
0); 0);
...@@ -669,14 +669,14 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -669,14 +669,14 @@ static int hp_event(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
static int configure_aif_clock(struct snd_soc_codec *codec, int aif) static int configure_aif_clock(struct snd_soc_component *component, int aif)
{ {
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int rate; int rate;
int reg1 = 0; int reg1 = 0;
int offset; int offset;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
if (aif) if (aif)
offset = 4; offset = 4;
...@@ -707,29 +707,29 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif) ...@@ -707,29 +707,29 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif)
rate /= 2; rate /= 2;
reg1 |= WM8995_AIF1CLK_DIV; reg1 |= WM8995_AIF1CLK_DIV;
dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n", dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n",
aif + 1, rate); aif + 1, rate);
} }
wm8995->aifclk[aif] = rate; wm8995->aifclk[aif] = rate;
snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1 + offset, snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1 + offset,
WM8995_AIF1CLK_SRC_MASK | WM8995_AIF1CLK_DIV_MASK, WM8995_AIF1CLK_SRC_MASK | WM8995_AIF1CLK_DIV_MASK,
reg1); reg1);
return 0; return 0;
} }
static int configure_clock(struct snd_soc_codec *codec) static int configure_clock(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int change, new; int change, new;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
/* Bring up the AIF clocks first */ /* Bring up the AIF clocks first */
configure_aif_clock(codec, 0); configure_aif_clock(component, 0);
configure_aif_clock(codec, 1); configure_aif_clock(component, 1);
/* /*
* Then switch CLK_SYS over to the higher of them; a change * Then switch CLK_SYS over to the higher of them; a change
...@@ -747,7 +747,7 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -747,7 +747,7 @@ static int configure_clock(struct snd_soc_codec *codec)
else else
new = 0; new = 0;
change = snd_soc_update_bits(codec, WM8995_CLOCKING_1, change = snd_soc_component_update_bits(component, WM8995_CLOCKING_1,
WM8995_SYSCLK_SRC_MASK, new); WM8995_SYSCLK_SRC_MASK, new);
if (!change) if (!change)
return 0; return 0;
...@@ -760,14 +760,14 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -760,14 +760,14 @@ static int configure_clock(struct snd_soc_codec *codec)
static int clk_sys_event(struct snd_soc_dapm_widget *w, static int clk_sys_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
return configure_clock(codec); return configure_clock(component);
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
configure_clock(codec); configure_clock(component);
break; break;
} }
...@@ -1422,7 +1422,7 @@ static bool wm8995_volatile(struct device *dev, unsigned int reg) ...@@ -1422,7 +1422,7 @@ static bool wm8995_volatile(struct device *dev, unsigned int reg)
static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int mute_reg; int mute_reg;
switch (dai->id) { switch (dai->id) {
...@@ -1436,18 +1436,18 @@ static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) ...@@ -1436,18 +1436,18 @@ static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, mute_reg, WM8995_AIF1DAC1_MUTE_MASK, snd_soc_component_update_bits(component, mute_reg, WM8995_AIF1DAC1_MUTE_MASK,
!!mute << WM8995_AIF1DAC1_MUTE_SHIFT); !!mute << WM8995_AIF1DAC1_MUTE_SHIFT);
return 0; return 0;
} }
static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
int master; int master;
int aif; int aif;
codec = dai->codec; component = dai->component;
master = 0; master = 0;
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
...@@ -1519,11 +1519,11 @@ static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -1519,11 +1519,11 @@ static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, WM8995_AIF1_CONTROL_1, snd_soc_component_update_bits(component, WM8995_AIF1_CONTROL_1,
WM8995_AIF1_BCLK_INV_MASK | WM8995_AIF1_BCLK_INV_MASK |
WM8995_AIF1_LRCLK_INV_MASK | WM8995_AIF1_LRCLK_INV_MASK |
WM8995_AIF1_FMT_MASK, aif); WM8995_AIF1_FMT_MASK, aif);
snd_soc_update_bits(codec, WM8995_AIF1_MASTER_SLAVE, snd_soc_component_update_bits(component, WM8995_AIF1_MASTER_SLAVE,
WM8995_AIF1_MSTR_MASK, master); WM8995_AIF1_MSTR_MASK, master);
return 0; return 0;
} }
...@@ -1546,7 +1546,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1546,7 +1546,7 @@ static int wm8995_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; struct snd_soc_component *component;
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int aif1_reg; int aif1_reg;
int bclk_reg; int bclk_reg;
...@@ -1557,8 +1557,8 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1557,8 +1557,8 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
int lrclk, bclk; int lrclk, bclk;
int i, rate_val, best, best_val, cur_val; int i, rate_val, best, best_val, cur_val;
codec = dai->codec; component = dai->component;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
switch (dai->id) { switch (dai->id) {
case 0: case 0:
...@@ -1570,7 +1570,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1570,7 +1570,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
lrclk_reg = WM8995_AIF1DAC_LRCLK; lrclk_reg = WM8995_AIF1DAC_LRCLK;
} else { } else {
lrclk_reg = WM8995_AIF1ADC_LRCLK; lrclk_reg = WM8995_AIF1ADC_LRCLK;
dev_dbg(codec->dev, "AIF1 using split LRCLK\n"); dev_dbg(component->dev, "AIF1 using split LRCLK\n");
} }
break; break;
case 1: case 1:
...@@ -1582,7 +1582,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1582,7 +1582,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
lrclk_reg = WM8995_AIF2DAC_LRCLK; lrclk_reg = WM8995_AIF2DAC_LRCLK;
} else { } else {
lrclk_reg = WM8995_AIF2ADC_LRCLK; lrclk_reg = WM8995_AIF2ADC_LRCLK;
dev_dbg(codec->dev, "AIF2 using split LRCLK\n"); dev_dbg(component->dev, "AIF2 using split LRCLK\n");
} }
break; break;
default: default:
...@@ -1668,13 +1668,13 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1668,13 +1668,13 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
lrclk, bclk_rate / lrclk); lrclk, bclk_rate / lrclk);
snd_soc_update_bits(codec, aif1_reg, snd_soc_component_update_bits(component, aif1_reg,
WM8995_AIF1_WL_MASK, aif1); WM8995_AIF1_WL_MASK, aif1);
snd_soc_update_bits(codec, bclk_reg, snd_soc_component_update_bits(component, bclk_reg,
WM8995_AIF1_BCLK_DIV_MASK, bclk); WM8995_AIF1_BCLK_DIV_MASK, bclk);
snd_soc_update_bits(codec, lrclk_reg, snd_soc_component_update_bits(component, lrclk_reg,
WM8995_AIF1DAC_RATE_MASK, lrclk); WM8995_AIF1DAC_RATE_MASK, lrclk);
snd_soc_update_bits(codec, rate_reg, snd_soc_component_update_bits(component, rate_reg,
WM8995_AIF1_SR_MASK | WM8995_AIF1_SR_MASK |
WM8995_AIF1CLK_RATE_MASK, rate_val); WM8995_AIF1CLK_RATE_MASK, rate_val);
return 0; return 0;
...@@ -1682,7 +1682,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, ...@@ -1682,7 +1682,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream,
static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
int reg, val, mask; int reg, val, mask;
switch (codec_dai->id) { switch (codec_dai->id) {
...@@ -1707,7 +1707,7 @@ static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) ...@@ -1707,7 +1707,7 @@ static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate)
else else
val = 0; val = 0;
return snd_soc_update_bits(codec, reg, mask, val); return snd_soc_component_update_bits(component, reg, mask, val);
} }
/* The size in bits of the FLL divide multiplied by 10 /* The size in bits of the FLL divide multiplied by 10
...@@ -1797,19 +1797,19 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, ...@@ -1797,19 +1797,19 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id,
int src, unsigned int freq_in, int src, unsigned int freq_in,
unsigned int freq_out) unsigned int freq_out)
{ {
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int reg_offset, ret; int reg_offset, ret;
struct fll_div fll; struct fll_div fll;
u16 reg, aif1, aif2; u16 reg, aif1, aif2;
codec = dai->codec; component = dai->component;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
aif1 = snd_soc_read(codec, WM8995_AIF1_CLOCKING_1) aif1 = snd_soc_component_read32(component, WM8995_AIF1_CLOCKING_1)
& WM8995_AIF1CLK_ENA; & WM8995_AIF1CLK_ENA;
aif2 = snd_soc_read(codec, WM8995_AIF2_CLOCKING_1) aif2 = snd_soc_component_read32(component, WM8995_AIF2_CLOCKING_1)
& WM8995_AIF2CLK_ENA; & WM8995_AIF2CLK_ENA;
switch (id) { switch (id) {
...@@ -1858,35 +1858,35 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, ...@@ -1858,35 +1858,35 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id,
return ret; return ret;
/* Gate the AIF clocks while we reclock */ /* Gate the AIF clocks while we reclock */
snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1,
WM8995_AIF1CLK_ENA_MASK, 0); WM8995_AIF1CLK_ENA_MASK, 0);
snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1,
WM8995_AIF2CLK_ENA_MASK, 0); WM8995_AIF2CLK_ENA_MASK, 0);
/* We always need to disable the FLL while reconfiguring */ /* We always need to disable the FLL while reconfiguring */
snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset,
WM8995_FLL1_ENA_MASK, 0); WM8995_FLL1_ENA_MASK, 0);
reg = (fll.outdiv << WM8995_FLL1_OUTDIV_SHIFT) | reg = (fll.outdiv << WM8995_FLL1_OUTDIV_SHIFT) |
(fll.fll_fratio << WM8995_FLL1_FRATIO_SHIFT); (fll.fll_fratio << WM8995_FLL1_FRATIO_SHIFT);
snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_2 + reg_offset, snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_2 + reg_offset,
WM8995_FLL1_OUTDIV_MASK | WM8995_FLL1_OUTDIV_MASK |
WM8995_FLL1_FRATIO_MASK, reg); WM8995_FLL1_FRATIO_MASK, reg);
snd_soc_write(codec, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k); snd_soc_component_write(component, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k);
snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_4 + reg_offset, snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_4 + reg_offset,
WM8995_FLL1_N_MASK, WM8995_FLL1_N_MASK,
fll.n << WM8995_FLL1_N_SHIFT); fll.n << WM8995_FLL1_N_SHIFT);
snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_5 + reg_offset, snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_5 + reg_offset,
WM8995_FLL1_REFCLK_DIV_MASK | WM8995_FLL1_REFCLK_DIV_MASK |
WM8995_FLL1_REFCLK_SRC_MASK, WM8995_FLL1_REFCLK_SRC_MASK,
(fll.clk_ref_div << WM8995_FLL1_REFCLK_DIV_SHIFT) | (fll.clk_ref_div << WM8995_FLL1_REFCLK_DIV_SHIFT) |
(src - 1)); (src - 1));
if (freq_out) if (freq_out)
snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset,
WM8995_FLL1_ENA_MASK, WM8995_FLL1_ENA); WM8995_FLL1_ENA_MASK, WM8995_FLL1_ENA);
wm8995->fll[id].in = freq_in; wm8995->fll[id].in = freq_in;
...@@ -1894,12 +1894,12 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, ...@@ -1894,12 +1894,12 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id,
wm8995->fll[id].src = src; wm8995->fll[id].src = src;
/* Enable any gated AIF clocks */ /* Enable any gated AIF clocks */
snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1,
WM8995_AIF1CLK_ENA_MASK, aif1); WM8995_AIF1CLK_ENA_MASK, aif1);
snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1,
WM8995_AIF2CLK_ENA_MASK, aif2); WM8995_AIF2CLK_ENA_MASK, aif2);
configure_clock(codec); configure_clock(component);
return 0; return 0;
} }
...@@ -1907,11 +1907,11 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, ...@@ -1907,11 +1907,11 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id,
static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, static int wm8995_set_dai_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; struct snd_soc_component *component;
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
codec = dai->codec; component = dai->component;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
switch (dai->id) { switch (dai->id) {
case 0: case 0:
...@@ -1949,24 +1949,24 @@ static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, ...@@ -1949,24 +1949,24 @@ static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai,
return -EINVAL; return -EINVAL;
} }
configure_clock(codec); configure_clock(component);
return 0; return 0;
} }
static int wm8995_set_bias_level(struct snd_soc_codec *codec, static int wm8995_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int ret; int ret;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
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 = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies),
wm8995->supplies); wm8995->supplies);
if (ret) if (ret)
...@@ -1974,17 +1974,17 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, ...@@ -1974,17 +1974,17 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec,
ret = regcache_sync(wm8995->regmap); ret = regcache_sync(wm8995->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;
} }
snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1,
WM8995_BG_ENA_MASK, WM8995_BG_ENA); WM8995_BG_ENA_MASK, WM8995_BG_ENA);
} }
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1,
WM8995_BG_ENA_MASK, 0); WM8995_BG_ENA_MASK, 0);
regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies),
wm8995->supplies); wm8995->supplies);
...@@ -1994,37 +1994,36 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, ...@@ -1994,37 +1994,36 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec,
return 0; return 0;
} }
static int wm8995_remove(struct snd_soc_codec *codec) static void wm8995_remove(struct snd_soc_component *component)
{ {
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int i; int i;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i) for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i)
regulator_unregister_notifier(wm8995->supplies[i].consumer, regulator_unregister_notifier(wm8995->supplies[i].consumer,
&wm8995->disable_nb[i]); &wm8995->disable_nb[i]);
regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies);
return 0;
} }
static int wm8995_probe(struct snd_soc_codec *codec) static int wm8995_probe(struct snd_soc_component *component)
{ {
struct wm8995_priv *wm8995; struct wm8995_priv *wm8995;
int i; int i;
int ret; int ret;
wm8995 = snd_soc_codec_get_drvdata(codec); wm8995 = snd_soc_component_get_drvdata(component);
wm8995->codec = codec; wm8995->component = component;
for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++)
wm8995->supplies[i].supply = wm8995_supply_names[i]; wm8995->supplies[i].supply = wm8995_supply_names[i];
ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8995->supplies), ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies),
wm8995->supplies); wm8995->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to request supplies: %d\n", ret); dev_err(component->dev, "Failed to request supplies: %d\n", ret);
return ret; return ret;
} }
...@@ -2042,7 +2041,7 @@ static int wm8995_probe(struct snd_soc_codec *codec) ...@@ -2042,7 +2041,7 @@ static int wm8995_probe(struct snd_soc_codec *codec)
ret = regulator_register_notifier(wm8995->supplies[i].consumer, ret = regulator_register_notifier(wm8995->supplies[i].consumer,
&wm8995->disable_nb[i]); &wm8995->disable_nb[i]);
if (ret) { if (ret) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to register regulator notifier: %d\n", "Failed to register regulator notifier: %d\n",
ret); ret);
} }
...@@ -2051,49 +2050,49 @@ static int wm8995_probe(struct snd_soc_codec *codec) ...@@ -2051,49 +2050,49 @@ static int wm8995_probe(struct snd_soc_codec *codec)
ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies),
wm8995->supplies); wm8995->supplies);
if (ret) { if (ret) {
dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); dev_err(component->dev, "Failed to enable supplies: %d\n", ret);
goto err_reg_get; goto err_reg_get;
} }
ret = snd_soc_read(codec, WM8995_SOFTWARE_RESET); ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to read device ID: %d\n", ret); dev_err(component->dev, "Failed to read device ID: %d\n", ret);
goto err_reg_enable; goto err_reg_enable;
} }
if (ret != 0x8995) { if (ret != 0x8995) {
dev_err(codec->dev, "Invalid device ID: %#x\n", ret); dev_err(component->dev, "Invalid device ID: %#x\n", ret);
ret = -EINVAL; ret = -EINVAL;
goto err_reg_enable; goto err_reg_enable;
} }
ret = snd_soc_write(codec, WM8995_SOFTWARE_RESET, 0); ret = snd_soc_component_write(component, WM8995_SOFTWARE_RESET, 0);
if (ret < 0) { if (ret < 0) {
dev_err(codec->dev, "Failed to issue reset: %d\n", ret); dev_err(component->dev, "Failed to issue reset: %d\n", ret);
goto err_reg_enable; goto err_reg_enable;
} }
/* Latch volume updates (right only; we always do left then right). */ /* Latch volume updates (right only; we always do left then right). */
snd_soc_update_bits(codec, WM8995_AIF1_DAC1_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF1_DAC1_RIGHT_VOLUME,
WM8995_AIF1DAC1_VU_MASK, WM8995_AIF1DAC1_VU); WM8995_AIF1DAC1_VU_MASK, WM8995_AIF1DAC1_VU);
snd_soc_update_bits(codec, WM8995_AIF1_DAC2_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF1_DAC2_RIGHT_VOLUME,
WM8995_AIF1DAC2_VU_MASK, WM8995_AIF1DAC2_VU); WM8995_AIF1DAC2_VU_MASK, WM8995_AIF1DAC2_VU);
snd_soc_update_bits(codec, WM8995_AIF2_DAC_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF2_DAC_RIGHT_VOLUME,
WM8995_AIF2DAC_VU_MASK, WM8995_AIF2DAC_VU); WM8995_AIF2DAC_VU_MASK, WM8995_AIF2DAC_VU);
snd_soc_update_bits(codec, WM8995_AIF1_ADC1_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF1_ADC1_RIGHT_VOLUME,
WM8995_AIF1ADC1_VU_MASK, WM8995_AIF1ADC1_VU); WM8995_AIF1ADC1_VU_MASK, WM8995_AIF1ADC1_VU);
snd_soc_update_bits(codec, WM8995_AIF1_ADC2_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF1_ADC2_RIGHT_VOLUME,
WM8995_AIF1ADC2_VU_MASK, WM8995_AIF1ADC2_VU); WM8995_AIF1ADC2_VU_MASK, WM8995_AIF1ADC2_VU);
snd_soc_update_bits(codec, WM8995_AIF2_ADC_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_AIF2_ADC_RIGHT_VOLUME,
WM8995_AIF2ADC_VU_MASK, WM8995_AIF1ADC2_VU); WM8995_AIF2ADC_VU_MASK, WM8995_AIF1ADC2_VU);
snd_soc_update_bits(codec, WM8995_DAC1_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_DAC1_RIGHT_VOLUME,
WM8995_DAC1_VU_MASK, WM8995_DAC1_VU); WM8995_DAC1_VU_MASK, WM8995_DAC1_VU);
snd_soc_update_bits(codec, WM8995_DAC2_RIGHT_VOLUME, snd_soc_component_update_bits(component, WM8995_DAC2_RIGHT_VOLUME,
WM8995_DAC2_VU_MASK, WM8995_DAC2_VU); WM8995_DAC2_VU_MASK, WM8995_DAC2_VU);
snd_soc_update_bits(codec, WM8995_RIGHT_LINE_INPUT_1_VOLUME, snd_soc_component_update_bits(component, WM8995_RIGHT_LINE_INPUT_1_VOLUME,
WM8995_IN1_VU_MASK, WM8995_IN1_VU); WM8995_IN1_VU_MASK, WM8995_IN1_VU);
wm8995_update_class_w(codec); wm8995_update_class_w(component);
return 0; return 0;
...@@ -2186,20 +2185,19 @@ static struct snd_soc_dai_driver wm8995_dai[] = { ...@@ -2186,20 +2185,19 @@ static struct snd_soc_dai_driver wm8995_dai[] = {
} }
}; };
static const struct snd_soc_codec_driver soc_codec_dev_wm8995 = { static const struct snd_soc_component_driver soc_component_dev_wm8995 = {
.probe = wm8995_probe, .probe = wm8995_probe,
.remove = wm8995_remove, .remove = wm8995_remove,
.set_bias_level = wm8995_set_bias_level, .set_bias_level = wm8995_set_bias_level,
.idle_bias_off = true, .controls = wm8995_snd_controls,
.num_controls = ARRAY_SIZE(wm8995_snd_controls),
.component_driver = { .dapm_widgets = wm8995_dapm_widgets,
.controls = wm8995_snd_controls, .num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets),
.num_controls = ARRAY_SIZE(wm8995_snd_controls), .dapm_routes = wm8995_intercon,
.dapm_widgets = wm8995_dapm_widgets, .num_dapm_routes = ARRAY_SIZE(wm8995_intercon),
.num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets), .use_pmdown_time = 1,
.dapm_routes = wm8995_intercon, .endianness = 1,
.num_dapm_routes = ARRAY_SIZE(wm8995_intercon), .non_legacy_dai_naming = 1,
},
}; };
static const struct regmap_config wm8995_regmap = { static const struct regmap_config wm8995_regmap = {
...@@ -2233,24 +2231,17 @@ static int wm8995_spi_probe(struct spi_device *spi) ...@@ -2233,24 +2231,17 @@ static int wm8995_spi_probe(struct spi_device *spi)
return ret; return ret;
} }
ret = snd_soc_register_codec(&spi->dev, ret = devm_snd_soc_register_component(&spi->dev,
&soc_codec_dev_wm8995, wm8995_dai, &soc_component_dev_wm8995, wm8995_dai,
ARRAY_SIZE(wm8995_dai)); ARRAY_SIZE(wm8995_dai));
return ret; return ret;
} }
static int wm8995_spi_remove(struct spi_device *spi)
{
snd_soc_unregister_codec(&spi->dev);
return 0;
}
static struct spi_driver wm8995_spi_driver = { static struct spi_driver wm8995_spi_driver = {
.driver = { .driver = {
.name = "wm8995", .name = "wm8995",
}, },
.probe = wm8995_spi_probe, .probe = wm8995_spi_probe,
.remove = wm8995_spi_remove
}; };
#endif #endif
...@@ -2274,8 +2265,8 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, ...@@ -2274,8 +2265,8 @@ static int wm8995_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8995, wm8995_dai, &soc_component_dev_wm8995, wm8995_dai,
ARRAY_SIZE(wm8995_dai)); ARRAY_SIZE(wm8995_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 CODEC: %d\n", ret);
...@@ -2283,12 +2274,6 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, ...@@ -2283,12 +2274,6 @@ static int wm8995_i2c_probe(struct i2c_client *i2c,
return ret; return ret;
} }
static int wm8995_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
}
static const struct i2c_device_id wm8995_i2c_id[] = { static const struct i2c_device_id wm8995_i2c_id[] = {
{"wm8995", 0}, {"wm8995", 0},
{} {}
...@@ -2301,7 +2286,6 @@ static struct i2c_driver wm8995_i2c_driver = { ...@@ -2301,7 +2286,6 @@ static struct i2c_driver wm8995_i2c_driver = {
.name = "wm8995", .name = "wm8995",
}, },
.probe = wm8995_i2c_probe, .probe = wm8995_i2c_probe,
.remove = wm8995_i2c_remove,
.id_table = wm8995_i2c_id .id_table = wm8995_i2c_id
}; };
#endif #endif
......
...@@ -53,7 +53,7 @@ static const char *wm8996_supply_names[WM8996_NUM_SUPPLIES] = { ...@@ -53,7 +53,7 @@ static const char *wm8996_supply_names[WM8996_NUM_SUPPLIES] = {
struct wm8996_priv { struct wm8996_priv {
struct device *dev; struct device *dev;
struct regmap *regmap; struct regmap *regmap;
struct snd_soc_codec *codec; struct snd_soc_component *component;
int ldo1ena; int ldo1ena;
...@@ -335,9 +335,9 @@ static SOC_ENUM_SINGLE_DECL(dsp1tx_hpf_cutoff, ...@@ -335,9 +335,9 @@ static SOC_ENUM_SINGLE_DECL(dsp1tx_hpf_cutoff,
static SOC_ENUM_SINGLE_DECL(dsp2tx_hpf_cutoff, static SOC_ENUM_SINGLE_DECL(dsp2tx_hpf_cutoff,
WM8996_DSP2_TX_FILTERS, 0, hpf_cutoff_text); WM8996_DSP2_TX_FILTERS, 0, hpf_cutoff_text);
static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) static void wm8996_set_retune_mobile(struct snd_soc_component *component, int block)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct wm8996_pdata *pdata = &wm8996->pdata; struct wm8996_pdata *pdata = &wm8996->pdata;
int base, best, best_val, save, i, cfg, iface; int base, best, best_val, save, i, cfg, iface;
...@@ -347,7 +347,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -347,7 +347,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block)
switch (block) { switch (block) {
case 0: case 0:
base = WM8996_DSP1_RX_EQ_GAINS_1; base = WM8996_DSP1_RX_EQ_GAINS_1;
if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) &
WM8996_DSP1RX_SRC) WM8996_DSP1RX_SRC)
iface = 1; iface = 1;
else else
...@@ -355,7 +355,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -355,7 +355,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block)
break; break;
case 1: case 1:
base = WM8996_DSP1_RX_EQ_GAINS_2; base = WM8996_DSP1_RX_EQ_GAINS_2;
if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) &
WM8996_DSP2RX_SRC) WM8996_DSP2RX_SRC)
iface = 1; iface = 1;
else else
...@@ -381,7 +381,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -381,7 +381,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block)
} }
} }
dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n",
block, block,
pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].name,
pdata->retune_mobile_cfgs[best].rate, pdata->retune_mobile_cfgs[best].rate,
...@@ -390,14 +390,14 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) ...@@ -390,14 +390,14 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block)
/* The EQ will be disabled while reconfiguring it, remember the /* The EQ will be disabled while reconfiguring it, remember the
* current configuration. * current configuration.
*/ */
save = snd_soc_read(codec, base); save = snd_soc_component_read32(component, base);
save &= WM8996_DSP1RX_EQ_ENA; save &= WM8996_DSP1RX_EQ_ENA;
for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++) for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++)
snd_soc_update_bits(codec, base + i, 0xffff, snd_soc_component_update_bits(component, base + i, 0xffff,
pdata->retune_mobile_cfgs[best].regs[i]); pdata->retune_mobile_cfgs[best].regs[i]);
snd_soc_update_bits(codec, base, WM8996_DSP1RX_EQ_ENA, save); snd_soc_component_update_bits(component, base, WM8996_DSP1RX_EQ_ENA, save);
} }
/* Icky as hell but saves code duplication */ /* Icky as hell but saves code duplication */
...@@ -413,8 +413,8 @@ static int wm8996_get_retune_mobile_block(const char *name) ...@@ -413,8 +413,8 @@ static int wm8996_get_retune_mobile_block(const char *name)
static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct wm8996_pdata *pdata = &wm8996->pdata; struct wm8996_pdata *pdata = &wm8996->pdata;
int block = wm8996_get_retune_mobile_block(kcontrol->id.name); int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
int value = ucontrol->value.enumerated.item[0]; int value = ucontrol->value.enumerated.item[0];
...@@ -427,7 +427,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, ...@@ -427,7 +427,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
wm8996->retune_mobile_cfg[block] = value; wm8996->retune_mobile_cfg[block] = value;
wm8996_set_retune_mobile(codec, block); wm8996_set_retune_mobile(component, block);
return 0; return 0;
} }
...@@ -435,8 +435,8 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, ...@@ -435,8 +435,8 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int block = wm8996_get_retune_mobile_block(kcontrol->id.name); int block = wm8996_get_retune_mobile_block(kcontrol->id.name);
if (block < 0) if (block < 0)
...@@ -575,40 +575,40 @@ SOC_SINGLE_TLV("DSP2 EQ B5 Volume", WM8996_DSP2_RX_EQ_GAINS_2, 6, 31, 0, ...@@ -575,40 +575,40 @@ SOC_SINGLE_TLV("DSP2 EQ B5 Volume", WM8996_DSP2_RX_EQ_GAINS_2, 6, 31, 0,
eq_tlv), eq_tlv),
}; };
static void wm8996_bg_enable(struct snd_soc_codec *codec) static void wm8996_bg_enable(struct snd_soc_component *component)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
wm8996->bg_ena++; wm8996->bg_ena++;
if (wm8996->bg_ena == 1) { if (wm8996->bg_ena == 1) {
snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1,
WM8996_BG_ENA, WM8996_BG_ENA); WM8996_BG_ENA, WM8996_BG_ENA);
msleep(2); msleep(2);
} }
} }
static void wm8996_bg_disable(struct snd_soc_codec *codec) static void wm8996_bg_disable(struct snd_soc_component *component)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
wm8996->bg_ena--; wm8996->bg_ena--;
if (!wm8996->bg_ena) if (!wm8996->bg_ena)
snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1,
WM8996_BG_ENA, 0); WM8996_BG_ENA, 0);
} }
static int bg_event(struct snd_soc_dapm_widget *w, static int bg_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int ret = 0; int ret = 0;
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
wm8996_bg_enable(codec); wm8996_bg_enable(component);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
wm8996_bg_disable(codec); wm8996_bg_disable(component);
break; break;
default: default:
WARN(1, "Invalid event %d\n", event); WARN(1, "Invalid event %d\n", event);
...@@ -635,8 +635,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, ...@@ -635,8 +635,8 @@ static int cp_event(struct snd_soc_dapm_widget *w,
static int rmv_short_event(struct snd_soc_dapm_widget *w, static int rmv_short_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
/* Record which outputs we enabled */ /* Record which outputs we enabled */
switch (event) { switch (event) {
...@@ -654,14 +654,14 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w, ...@@ -654,14 +654,14 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) static void wait_for_dc_servo(struct snd_soc_component *component, u16 mask)
{ {
struct i2c_client *i2c = to_i2c_client(codec->dev); struct i2c_client *i2c = to_i2c_client(component->dev);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int ret; int ret;
unsigned long timeout = 200; unsigned long timeout = 200;
snd_soc_write(codec, WM8996_DC_SERVO_2, mask); snd_soc_component_write(component, WM8996_DC_SERVO_2, mask);
/* Use the interrupt if possible */ /* Use the interrupt if possible */
do { do {
...@@ -669,44 +669,43 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) ...@@ -669,44 +669,43 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask)
timeout = wait_for_completion_timeout(&wm8996->dcs_done, timeout = wait_for_completion_timeout(&wm8996->dcs_done,
msecs_to_jiffies(200)); msecs_to_jiffies(200));
if (timeout == 0) if (timeout == 0)
dev_err(codec->dev, "DC servo timed out\n"); dev_err(component->dev, "DC servo timed out\n");
} else { } else {
msleep(1); msleep(1);
timeout--; timeout--;
} }
ret = snd_soc_read(codec, WM8996_DC_SERVO_2); ret = snd_soc_component_read32(component, WM8996_DC_SERVO_2);
dev_dbg(codec->dev, "DC servo state: %x\n", ret); dev_dbg(component->dev, "DC servo state: %x\n", ret);
} while (timeout && ret & mask); } while (timeout && ret & mask);
if (timeout == 0) if (timeout == 0)
dev_err(codec->dev, "DC servo timed out for %x\n", mask); dev_err(component->dev, "DC servo timed out for %x\n", mask);
else else
dev_dbg(codec->dev, "DC servo complete for %x\n", mask); dev_dbg(component->dev, "DC servo complete for %x\n", mask);
} }
static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, static void wm8996_seq_notifier(struct snd_soc_component *component,
enum snd_soc_dapm_type event, int subseq) enum snd_soc_dapm_type event, int subseq)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec);
u16 val, mask; u16 val, mask;
/* Complete any pending DC servo starts */ /* Complete any pending DC servo starts */
if (wm8996->dcs_pending) { if (wm8996->dcs_pending) {
dev_dbg(codec->dev, "Starting DC servo for %x\n", dev_dbg(component->dev, "Starting DC servo for %x\n",
wm8996->dcs_pending); wm8996->dcs_pending);
/* Trigger a startup sequence */ /* Trigger a startup sequence */
wait_for_dc_servo(codec, wm8996->dcs_pending wait_for_dc_servo(component, wm8996->dcs_pending
<< WM8996_DCS_TRIG_STARTUP_0_SHIFT); << WM8996_DCS_TRIG_STARTUP_0_SHIFT);
wm8996->dcs_pending = 0; wm8996->dcs_pending = 0;
} }
if (wm8996->hpout_pending != wm8996->hpout_ena) { if (wm8996->hpout_pending != wm8996->hpout_ena) {
dev_dbg(codec->dev, "Applying RMV_SHORTs %x->%x\n", dev_dbg(component->dev, "Applying RMV_SHORTs %x->%x\n",
wm8996->hpout_ena, wm8996->hpout_pending); wm8996->hpout_ena, wm8996->hpout_pending);
val = 0; val = 0;
...@@ -729,7 +728,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, ...@@ -729,7 +728,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm,
WM8996_HPOUT1R_DLY; WM8996_HPOUT1R_DLY;
} }
snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, mask, val); snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, mask, val);
val = 0; val = 0;
mask = 0; mask = 0;
...@@ -751,7 +750,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, ...@@ -751,7 +750,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm,
WM8996_HPOUT2R_DLY; WM8996_HPOUT2R_DLY;
} }
snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_2, mask, val); snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_2, mask, val);
wm8996->hpout_ena = wm8996->hpout_pending; wm8996->hpout_ena = wm8996->hpout_pending;
} }
...@@ -760,8 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, ...@@ -760,8 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm,
static int dcs_start(struct snd_soc_dapm_widget *w, static int dcs_start(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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
...@@ -1533,9 +1532,9 @@ static const int bclk_divs[] = { ...@@ -1533,9 +1532,9 @@ static const int bclk_divs[] = {
1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96
}; };
static void wm8996_update_bclk(struct snd_soc_codec *codec) static void wm8996_update_bclk(struct snd_soc_component *component)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int aif, best, cur_val, bclk_rate, bclk_reg, i; int aif, best, cur_val, bclk_rate, bclk_reg, i;
/* Don't bother if we're in a low frequency idle mode that /* Don't bother if we're in a low frequency idle mode that
...@@ -1565,18 +1564,18 @@ static void wm8996_update_bclk(struct snd_soc_codec *codec) ...@@ -1565,18 +1564,18 @@ static void wm8996_update_bclk(struct snd_soc_codec *codec)
best = i; best = i;
} }
bclk_rate = wm8996->sysclk / bclk_divs[best]; bclk_rate = wm8996->sysclk / bclk_divs[best];
dev_dbg(codec->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", dev_dbg(component->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n",
bclk_divs[best], bclk_rate); bclk_divs[best], bclk_rate);
snd_soc_update_bits(codec, bclk_reg, snd_soc_component_update_bits(component, bclk_reg,
WM8996_AIF1_BCLK_DIV_MASK, best); WM8996_AIF1_BCLK_DIV_MASK, best);
} }
} }
static int wm8996_set_bias_level(struct snd_soc_codec *codec, static int wm8996_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int ret; int ret;
switch (level) { switch (level) {
...@@ -1584,18 +1583,18 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, ...@@ -1584,18 +1583,18 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec,
break; break;
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* Put the MICBIASes into regulating mode */ /* Put the MICBIASes into regulating mode */
snd_soc_update_bits(codec, WM8996_MICBIAS_1, snd_soc_component_update_bits(component, WM8996_MICBIAS_1,
WM8996_MICB1_MODE, 0); WM8996_MICB1_MODE, 0);
snd_soc_update_bits(codec, WM8996_MICBIAS_2, snd_soc_component_update_bits(component, WM8996_MICBIAS_2,
WM8996_MICB2_MODE, 0); WM8996_MICB2_MODE, 0);
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 = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies),
wm8996->supplies); wm8996->supplies);
if (ret != 0) { if (ret != 0) {
dev_err(codec->dev, dev_err(component->dev,
"Failed to enable supplies: %d\n", "Failed to enable supplies: %d\n",
ret); ret);
return ret; return ret;
...@@ -1612,9 +1611,9 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, ...@@ -1612,9 +1611,9 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec,
} }
/* Bypass the MICBIASes for lowest power */ /* Bypass the MICBIASes for lowest power */
snd_soc_update_bits(codec, WM8996_MICBIAS_1, snd_soc_component_update_bits(component, WM8996_MICBIAS_1,
WM8996_MICB1_MODE, WM8996_MICB1_MODE); WM8996_MICB1_MODE, WM8996_MICB1_MODE);
snd_soc_update_bits(codec, WM8996_MICBIAS_2, snd_soc_component_update_bits(component, WM8996_MICBIAS_2,
WM8996_MICB2_MODE, WM8996_MICB2_MODE); WM8996_MICB2_MODE, WM8996_MICB2_MODE);
break; break;
...@@ -1634,7 +1633,7 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, ...@@ -1634,7 +1633,7 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec,
static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
int aifctrl = 0; int aifctrl = 0;
int bclk = 0; int bclk = 0;
int lrclk_tx = 0; int lrclk_tx = 0;
...@@ -1711,15 +1710,15 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) ...@@ -1711,15 +1710,15 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
return -EINVAL; return -EINVAL;
} }
snd_soc_update_bits(codec, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); snd_soc_component_update_bits(component, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl);
snd_soc_update_bits(codec, bclk_reg, snd_soc_component_update_bits(component, bclk_reg,
WM8996_AIF1_BCLK_INV | WM8996_AIF1_BCLK_MSTR, WM8996_AIF1_BCLK_INV | WM8996_AIF1_BCLK_MSTR,
bclk); bclk);
snd_soc_update_bits(codec, lrclk_tx_reg, snd_soc_component_update_bits(component, lrclk_tx_reg,
WM8996_AIF1TX_LRCLK_INV | WM8996_AIF1TX_LRCLK_INV |
WM8996_AIF1TX_LRCLK_MSTR, WM8996_AIF1TX_LRCLK_MSTR,
lrclk_tx); lrclk_tx);
snd_soc_update_bits(codec, lrclk_rx_reg, snd_soc_component_update_bits(component, lrclk_rx_reg,
WM8996_AIF1RX_LRCLK_INV | WM8996_AIF1RX_LRCLK_INV |
WM8996_AIF1RX_LRCLK_MSTR, WM8996_AIF1RX_LRCLK_MSTR,
lrclk_rx); lrclk_rx);
...@@ -1735,8 +1734,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1735,8 +1734,8 @@ static int wm8996_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 wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int bits, i, bclk_rate, best; int bits, i, bclk_rate, best;
int aifdata = 0; int aifdata = 0;
int lrclk = 0; int lrclk = 0;
...@@ -1746,7 +1745,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1746,7 +1745,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
switch (dai->id) { switch (dai->id) {
case 0: case 0:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
(snd_soc_read(codec, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { (snd_soc_component_read32(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) {
aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION; aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION;
lrclk_reg = WM8996_AIF1_RX_LRCLK_1; lrclk_reg = WM8996_AIF1_RX_LRCLK_1;
} else { } else {
...@@ -1757,7 +1756,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1757,7 +1756,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
break; break;
case 1: case 1:
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
(snd_soc_read(codec, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { (snd_soc_component_read32(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) {
aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION; aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION;
lrclk_reg = WM8996_AIF2_RX_LRCLK_1; lrclk_reg = WM8996_AIF2_RX_LRCLK_1;
} else { } else {
...@@ -1773,7 +1772,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1773,7 +1772,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
bclk_rate = snd_soc_params_to_bclk(params); bclk_rate = snd_soc_params_to_bclk(params);
if (bclk_rate < 0) { if (bclk_rate < 0) {
dev_err(codec->dev, "Unsupported BCLK rate: %d\n", bclk_rate); dev_err(component->dev, "Unsupported BCLK rate: %d\n", bclk_rate);
return bclk_rate; return bclk_rate;
} }
...@@ -1794,19 +1793,19 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1794,19 +1793,19 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
} }
dsp |= i << dsp_shift; dsp |= i << dsp_shift;
wm8996_update_bclk(codec); wm8996_update_bclk(component);
lrclk = bclk_rate / params_rate(params); lrclk = bclk_rate / params_rate(params);
dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n",
lrclk, bclk_rate / lrclk); lrclk, bclk_rate / lrclk);
snd_soc_update_bits(codec, aifdata_reg, snd_soc_component_update_bits(component, aifdata_reg,
WM8996_AIF1TX_WL_MASK | WM8996_AIF1TX_WL_MASK |
WM8996_AIF1TX_SLOT_LEN_MASK, WM8996_AIF1TX_SLOT_LEN_MASK,
aifdata); aifdata);
snd_soc_update_bits(codec, lrclk_reg, WM8996_AIF1RX_RATE_MASK, snd_soc_component_update_bits(component, lrclk_reg, WM8996_AIF1RX_RATE_MASK,
lrclk); lrclk);
snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_2, snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_2,
WM8996_DSP1_DIV_MASK << dsp_shift, dsp); WM8996_DSP1_DIV_MASK << dsp_shift, dsp);
return 0; return 0;
...@@ -1815,8 +1814,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, ...@@ -1815,8 +1814,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream,
static int wm8996_set_sysclk(struct snd_soc_dai *dai, static int wm8996_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 wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int lfclk = 0; int lfclk = 0;
int ratediv = 0; int ratediv = 0;
int sync = WM8996_REG_SYNC; int sync = WM8996_REG_SYNC;
...@@ -1827,8 +1826,8 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, ...@@ -1827,8 +1826,8 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai,
return 0; return 0;
/* Disable SYSCLK while we reconfigure */ /* Disable SYSCLK while we reconfigure */
old = snd_soc_read(codec, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; old = snd_soc_component_read32(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA;
snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1,
WM8996_SYSCLK_ENA, 0); WM8996_SYSCLK_ENA, 0);
switch (clk_id) { switch (clk_id) {
...@@ -1845,14 +1844,14 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, ...@@ -1845,14 +1844,14 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai,
src = 2; src = 2;
break; break;
default: default:
dev_err(codec->dev, "Unsupported clock source %d\n", clk_id); dev_err(component->dev, "Unsupported clock source %d\n", clk_id);
return -EINVAL; return -EINVAL;
} }
switch (wm8996->sysclk) { switch (wm8996->sysclk) {
case 5644800: case 5644800:
case 6144000: case 6144000:
snd_soc_update_bits(codec, WM8996_AIF_RATE, snd_soc_component_update_bits(component, WM8996_AIF_RATE,
WM8996_SYSCLK_RATE, 0); WM8996_SYSCLK_RATE, 0);
break; break;
case 22579200: case 22579200:
...@@ -1861,7 +1860,7 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, ...@@ -1861,7 +1860,7 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai,
wm8996->sysclk /= 2; wm8996->sysclk /= 2;
case 11289600: case 11289600:
case 12288000: case 12288000:
snd_soc_update_bits(codec, WM8996_AIF_RATE, snd_soc_component_update_bits(component, WM8996_AIF_RATE,
WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE); WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE);
break; break;
case 32000: case 32000:
...@@ -1870,20 +1869,20 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, ...@@ -1870,20 +1869,20 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai,
sync = 0; sync = 0;
break; break;
default: default:
dev_warn(codec->dev, "Unsupported clock rate %dHz\n", dev_warn(component->dev, "Unsupported clock rate %dHz\n",
wm8996->sysclk); wm8996->sysclk);
return -EINVAL; return -EINVAL;
} }
wm8996_update_bclk(codec); wm8996_update_bclk(component);
snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1,
WM8996_SYSCLK_SRC_MASK | WM8996_SYSCLK_DIV_MASK, WM8996_SYSCLK_SRC_MASK | WM8996_SYSCLK_DIV_MASK,
src << WM8996_SYSCLK_SRC_SHIFT | ratediv); src << WM8996_SYSCLK_SRC_SHIFT | ratediv);
snd_soc_update_bits(codec, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); snd_soc_component_update_bits(component, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk);
snd_soc_update_bits(codec, WM8996_CONTROL_INTERFACE_1, snd_soc_component_update_bits(component, WM8996_CONTROL_INTERFACE_1,
WM8996_REG_SYNC, sync); WM8996_REG_SYNC, sync);
snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1,
WM8996_SYSCLK_ENA, old); WM8996_SYSCLK_ENA, old);
wm8996->sysclk_src = clk_id; wm8996->sysclk_src = clk_id;
...@@ -2002,11 +2001,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, ...@@ -2002,11 +2001,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
return 0; return 0;
} }
static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, static int wm8996_set_fll(struct snd_soc_component *component, int fll_id, int source,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct i2c_client *i2c = to_i2c_client(codec->dev); struct i2c_client *i2c = to_i2c_client(component->dev);
struct _fll_div fll_div; struct _fll_div fll_div;
unsigned long timeout, time_left; unsigned long timeout, time_left;
int ret, reg, retry; int ret, reg, retry;
...@@ -2017,15 +2016,15 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2017,15 +2016,15 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
return 0; return 0;
if (Fout == 0) { if (Fout == 0) {
dev_dbg(codec->dev, "FLL disabled\n"); dev_dbg(component->dev, "FLL disabled\n");
wm8996->fll_fref = 0; wm8996->fll_fref = 0;
wm8996->fll_fout = 0; wm8996->fll_fout = 0;
snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1,
WM8996_FLL_ENA, 0); WM8996_FLL_ENA, 0);
wm8996_bg_disable(codec); wm8996_bg_disable(component);
return 0; return 0;
} }
...@@ -2048,14 +2047,14 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2048,14 +2047,14 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
reg = 3; reg = 3;
break; break;
default: default:
dev_err(codec->dev, "Unknown FLL source %d\n", ret); dev_err(component->dev, "Unknown FLL source %d\n", ret);
return -EINVAL; return -EINVAL;
} }
reg |= fll_div.fll_refclk_div << WM8996_FLL_REFCLK_DIV_SHIFT; reg |= fll_div.fll_refclk_div << WM8996_FLL_REFCLK_DIV_SHIFT;
reg |= fll_div.fll_ref_freq << WM8996_FLL_REF_FREQ_SHIFT; reg |= fll_div.fll_ref_freq << WM8996_FLL_REF_FREQ_SHIFT;
snd_soc_update_bits(codec, WM8996_FLL_CONTROL_5, snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_5,
WM8996_FLL_REFCLK_DIV_MASK | WM8996_FLL_REF_FREQ | WM8996_FLL_REFCLK_DIV_MASK | WM8996_FLL_REF_FREQ |
WM8996_FLL_REFCLK_SRC_MASK, reg); WM8996_FLL_REFCLK_SRC_MASK, reg);
...@@ -2064,38 +2063,38 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2064,38 +2063,38 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
reg |= WM8996_FLL_EFS_ENA | (3 << WM8996_FLL_LFSR_SEL_SHIFT); reg |= WM8996_FLL_EFS_ENA | (3 << WM8996_FLL_LFSR_SEL_SHIFT);
else else
reg |= 1 << WM8996_FLL_LFSR_SEL_SHIFT; reg |= 1 << WM8996_FLL_LFSR_SEL_SHIFT;
snd_soc_write(codec, WM8996_FLL_EFS_2, reg); snd_soc_component_write(component, WM8996_FLL_EFS_2, reg);
snd_soc_update_bits(codec, WM8996_FLL_CONTROL_2, snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_2,
WM8996_FLL_OUTDIV_MASK | WM8996_FLL_OUTDIV_MASK |
WM8996_FLL_FRATIO_MASK, WM8996_FLL_FRATIO_MASK,
(fll_div.fll_outdiv << WM8996_FLL_OUTDIV_SHIFT) | (fll_div.fll_outdiv << WM8996_FLL_OUTDIV_SHIFT) |
(fll_div.fll_fratio)); (fll_div.fll_fratio));
snd_soc_write(codec, WM8996_FLL_CONTROL_3, fll_div.theta); snd_soc_component_write(component, WM8996_FLL_CONTROL_3, fll_div.theta);
snd_soc_update_bits(codec, WM8996_FLL_CONTROL_4, snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_4,
WM8996_FLL_N_MASK | WM8996_FLL_LOOP_GAIN_MASK, WM8996_FLL_N_MASK | WM8996_FLL_LOOP_GAIN_MASK,
(fll_div.n << WM8996_FLL_N_SHIFT) | (fll_div.n << WM8996_FLL_N_SHIFT) |
fll_div.fll_loop_gain); fll_div.fll_loop_gain);
snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda); snd_soc_component_write(component, WM8996_FLL_EFS_1, fll_div.lambda);
/* Enable the bandgap if it's not already enabled */ /* Enable the bandgap if it's not already enabled */
ret = snd_soc_read(codec, WM8996_FLL_CONTROL_1); ret = snd_soc_component_read32(component, WM8996_FLL_CONTROL_1);
if (!(ret & WM8996_FLL_ENA)) if (!(ret & WM8996_FLL_ENA))
wm8996_bg_enable(codec); wm8996_bg_enable(component);
/* Clear any pending completions (eg, from failed startups) */ /* Clear any pending completions (eg, from failed startups) */
try_wait_for_completion(&wm8996->fll_lock); try_wait_for_completion(&wm8996->fll_lock);
snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1,
WM8996_FLL_ENA, WM8996_FLL_ENA); WM8996_FLL_ENA, WM8996_FLL_ENA);
/* The FLL supports live reconfiguration - kick that in case we were /* The FLL supports live reconfiguration - kick that in case we were
* already enabled. * already enabled.
*/ */
snd_soc_write(codec, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK); snd_soc_component_write(component, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK);
/* Wait for the FLL to lock, using the interrupt if possible */ /* Wait for the FLL to lock, using the interrupt if possible */
if (Fref > 1000000) if (Fref > 1000000)
...@@ -2121,16 +2120,16 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, ...@@ -2121,16 +2120,16 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
break; break;
} }
ret = snd_soc_read(codec, WM8996_INTERRUPT_RAW_STATUS_2); ret = snd_soc_component_read32(component, WM8996_INTERRUPT_RAW_STATUS_2);
if (ret & WM8996_FLL_LOCK_STS) if (ret & WM8996_FLL_LOCK_STS)
break; break;
} }
if (retry == 10) { if (retry == 10) {
dev_err(codec->dev, "Timed out waiting for FLL\n"); dev_err(component->dev, "Timed out waiting for FLL\n");
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
} }
dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout);
wm8996->fll_fref = Fref; wm8996->fll_fref = Fref;
wm8996->fll_fout = Fout; wm8996->fll_fout = Fout;
...@@ -2237,11 +2236,11 @@ static void wm8996_free_gpio(struct wm8996_priv *wm8996) ...@@ -2237,11 +2236,11 @@ static void wm8996_free_gpio(struct wm8996_priv *wm8996)
* will also detect inverted microphone ground connections and update * will also detect inverted microphone ground connections and update
* the polarity of the connections. * the polarity of the connections.
*/ */
int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
wm8996_polarity_fn polarity_cb) wm8996_polarity_fn polarity_cb)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
wm8996->jack = jack; wm8996->jack = jack;
wm8996->detecting = true; wm8996->detecting = true;
...@@ -2249,12 +2248,12 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -2249,12 +2248,12 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
wm8996->jack_flips = 0; wm8996->jack_flips = 0;
if (wm8996->polarity_cb) if (wm8996->polarity_cb)
wm8996->polarity_cb(codec, 0); wm8996->polarity_cb(component, 0);
/* Clear discarge to avoid noise during detection */ /* Clear discarge to avoid noise during detection */
snd_soc_update_bits(codec, WM8996_MICBIAS_1, snd_soc_component_update_bits(component, WM8996_MICBIAS_1,
WM8996_MICB1_DISCH, 0); WM8996_MICB1_DISCH, 0);
snd_soc_update_bits(codec, WM8996_MICBIAS_2, snd_soc_component_update_bits(component, WM8996_MICBIAS_2,
WM8996_MICB2_DISCH, 0); WM8996_MICB2_DISCH, 0);
/* LDO2 powers the microphones, SYSCLK clocks detection */ /* LDO2 powers the microphones, SYSCLK clocks detection */
...@@ -2268,26 +2267,26 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ...@@ -2268,26 +2267,26 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
/* We start off just enabling microphone detection - even a /* We start off just enabling microphone detection - even a
* plain headphone will trigger detection. * plain headphone will trigger detection.
*/ */
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1,
WM8996_MICD_ENA, WM8996_MICD_ENA); WM8996_MICD_ENA, WM8996_MICD_ENA);
/* Slowest detection rate, gives debounce for initial detection */ /* Slowest detection rate, gives debounce for initial detection */
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1,
WM8996_MICD_RATE_MASK, WM8996_MICD_RATE_MASK,
WM8996_MICD_RATE_MASK); WM8996_MICD_RATE_MASK);
/* Enable interrupts and we're off */ /* Enable interrupts and we're off */
snd_soc_update_bits(codec, WM8996_INTERRUPT_STATUS_2_MASK, snd_soc_component_update_bits(component, WM8996_INTERRUPT_STATUS_2_MASK,
WM8996_IM_MICD_EINT | WM8996_HP_DONE_EINT, 0); WM8996_IM_MICD_EINT | WM8996_HP_DONE_EINT, 0);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(wm8996_detect); EXPORT_SYMBOL_GPL(wm8996_detect);
static void wm8996_hpdet_irq(struct snd_soc_codec *codec) static void wm8996_hpdet_irq(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int val, reg, report; int val, reg, report;
/* Assume headphone in error conditions; we need to report /* Assume headphone in error conditions; we need to report
...@@ -2295,20 +2294,20 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec) ...@@ -2295,20 +2294,20 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec)
*/ */
report = SND_JACK_HEADPHONE; report = SND_JACK_HEADPHONE;
reg = snd_soc_read(codec, WM8996_HEADPHONE_DETECT_2); reg = snd_soc_component_read32(component, WM8996_HEADPHONE_DETECT_2);
if (reg < 0) { if (reg < 0) {
dev_err(codec->dev, "Failed to read HPDET status\n"); dev_err(component->dev, "Failed to read HPDET status\n");
goto out; goto out;
} }
if (!(reg & WM8996_HP_DONE)) { if (!(reg & WM8996_HP_DONE)) {
dev_err(codec->dev, "Got HPDET IRQ but HPDET is busy\n"); dev_err(component->dev, "Got HPDET IRQ but HPDET is busy\n");
goto out; goto out;
} }
val = reg & WM8996_HP_LVL_MASK; val = reg & WM8996_HP_LVL_MASK;
dev_dbg(codec->dev, "HPDET measured %d ohms\n", val); dev_dbg(component->dev, "HPDET measured %d ohms\n", val);
/* If we've got high enough impedence then report as line, /* If we've got high enough impedence then report as line,
* otherwise assume headphone. * otherwise assume headphone.
...@@ -2328,28 +2327,28 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec) ...@@ -2328,28 +2327,28 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec)
wm8996->detecting = false; wm8996->detecting = false;
/* If the output isn't running re-clamp it */ /* If the output isn't running re-clamp it */
if (!(snd_soc_read(codec, WM8996_POWER_MANAGEMENT_1) & if (!(snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_1) &
(WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT))) (WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT)))
snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1,
WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1L_RMV_SHORT |
WM8996_HPOUT1R_RMV_SHORT, 0); WM8996_HPOUT1R_RMV_SHORT, 0);
/* Go back to looking at the microphone */ /* Go back to looking at the microphone */
snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1,
WM8996_JD_MODE_MASK, 0); WM8996_JD_MODE_MASK, 0);
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA,
WM8996_MICD_ENA); WM8996_MICD_ENA);
snd_soc_dapm_disable_pin(dapm, "Bandgap"); snd_soc_dapm_disable_pin(dapm, "Bandgap");
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
} }
static void wm8996_hpdet_start(struct snd_soc_codec *codec) static void wm8996_hpdet_start(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
/* Unclamp the output, we can't measure while we're shorting it */ /* Unclamp the output, we can't measure while we're shorting it */
snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1,
WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1L_RMV_SHORT |
WM8996_HPOUT1R_RMV_SHORT, WM8996_HPOUT1R_RMV_SHORT,
WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1L_RMV_SHORT |
...@@ -2360,45 +2359,45 @@ static void wm8996_hpdet_start(struct snd_soc_codec *codec) ...@@ -2360,45 +2359,45 @@ static void wm8996_hpdet_start(struct snd_soc_codec *codec)
snd_soc_dapm_sync(dapm); snd_soc_dapm_sync(dapm);
/* Go into headphone detect left mode */ /* Go into headphone detect left mode */
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0);
snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1,
WM8996_JD_MODE_MASK, 1); WM8996_JD_MODE_MASK, 1);
/* Trigger a measurement */ /* Trigger a measurement */
snd_soc_update_bits(codec, WM8996_HEADPHONE_DETECT_1, snd_soc_component_update_bits(component, WM8996_HEADPHONE_DETECT_1,
WM8996_HP_POLL, WM8996_HP_POLL); WM8996_HP_POLL, WM8996_HP_POLL);
} }
static void wm8996_report_headphone(struct snd_soc_codec *codec) static void wm8996_report_headphone(struct snd_soc_component *component)
{ {
dev_dbg(codec->dev, "Headphone detected\n"); dev_dbg(component->dev, "Headphone detected\n");
wm8996_hpdet_start(codec); wm8996_hpdet_start(component);
/* Increase the detection rate a bit for responsiveness. */ /* Increase the detection rate a bit for responsiveness. */
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1,
WM8996_MICD_RATE_MASK | WM8996_MICD_RATE_MASK |
WM8996_MICD_BIAS_STARTTIME_MASK, WM8996_MICD_BIAS_STARTTIME_MASK,
7 << WM8996_MICD_RATE_SHIFT | 7 << WM8996_MICD_RATE_SHIFT |
7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT);
} }
static void wm8996_micd(struct snd_soc_codec *codec) static void wm8996_micd(struct snd_soc_component *component)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int val, reg; int val, reg;
val = snd_soc_read(codec, WM8996_MIC_DETECT_3); val = snd_soc_component_read32(component, WM8996_MIC_DETECT_3);
dev_dbg(codec->dev, "Microphone event: %x\n", val); dev_dbg(component->dev, "Microphone event: %x\n", val);
if (!(val & WM8996_MICD_VALID)) { if (!(val & WM8996_MICD_VALID)) {
dev_warn(codec->dev, "Microphone detection state invalid\n"); dev_warn(component->dev, "Microphone detection state invalid\n");
return; return;
} }
/* No accessory, reset everything and report removal */ /* No accessory, reset everything and report removal */
if (!(val & WM8996_MICD_STS)) { if (!(val & WM8996_MICD_STS)) {
dev_dbg(codec->dev, "Jack removal detected\n"); dev_dbg(component->dev, "Jack removal detected\n");
wm8996->jack_mic = false; wm8996->jack_mic = false;
wm8996->detecting = true; wm8996->detecting = true;
wm8996->jack_flips = 0; wm8996->jack_flips = 0;
...@@ -2406,7 +2405,7 @@ static void wm8996_micd(struct snd_soc_codec *codec) ...@@ -2406,7 +2405,7 @@ static void wm8996_micd(struct snd_soc_codec *codec)
SND_JACK_LINEOUT | SND_JACK_HEADSET | SND_JACK_LINEOUT | SND_JACK_HEADSET |
SND_JACK_BTN_0); SND_JACK_BTN_0);
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1,
WM8996_MICD_RATE_MASK | WM8996_MICD_RATE_MASK |
WM8996_MICD_BIAS_STARTTIME_MASK, WM8996_MICD_BIAS_STARTTIME_MASK,
WM8996_MICD_RATE_MASK | WM8996_MICD_RATE_MASK |
...@@ -2420,19 +2419,19 @@ static void wm8996_micd(struct snd_soc_codec *codec) ...@@ -2420,19 +2419,19 @@ static void wm8996_micd(struct snd_soc_codec *codec)
*/ */
if (val & 0x400) { if (val & 0x400) {
if (wm8996->detecting) { if (wm8996->detecting) {
dev_dbg(codec->dev, "Microphone detected\n"); dev_dbg(component->dev, "Microphone detected\n");
wm8996->jack_mic = true; wm8996->jack_mic = true;
wm8996_hpdet_start(codec); wm8996_hpdet_start(component);
/* Increase poll rate to give better responsiveness /* Increase poll rate to give better responsiveness
* for buttons */ * for buttons */
snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1,
WM8996_MICD_RATE_MASK | WM8996_MICD_RATE_MASK |
WM8996_MICD_BIAS_STARTTIME_MASK, WM8996_MICD_BIAS_STARTTIME_MASK,
5 << WM8996_MICD_RATE_SHIFT | 5 << WM8996_MICD_RATE_SHIFT |
7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT);
} else { } else {
dev_dbg(codec->dev, "Mic button up\n"); dev_dbg(component->dev, "Mic button up\n");
snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0); snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0);
} }
...@@ -2449,22 +2448,22 @@ static void wm8996_micd(struct snd_soc_codec *codec) ...@@ -2449,22 +2448,22 @@ static void wm8996_micd(struct snd_soc_codec *codec)
wm8996->jack_flips++; wm8996->jack_flips++;
if (wm8996->jack_flips > 1) { if (wm8996->jack_flips > 1) {
wm8996_report_headphone(codec); wm8996_report_headphone(component);
return; return;
} }
reg = snd_soc_read(codec, WM8996_ACCESSORY_DETECT_MODE_2); reg = snd_soc_component_read32(component, WM8996_ACCESSORY_DETECT_MODE_2);
reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC |
WM8996_MICD_BIAS_SRC; WM8996_MICD_BIAS_SRC;
snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_2, snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_2,
WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC |
WM8996_MICD_BIAS_SRC, reg); WM8996_MICD_BIAS_SRC, reg);
if (wm8996->polarity_cb) if (wm8996->polarity_cb)
wm8996->polarity_cb(codec, wm8996->polarity_cb(component,
(reg & WM8996_MICD_SRC) != 0); (reg & WM8996_MICD_SRC) != 0);
dev_dbg(codec->dev, "Set microphone polarity to %d\n", dev_dbg(component->dev, "Set microphone polarity to %d\n",
(reg & WM8996_MICD_SRC) != 0); (reg & WM8996_MICD_SRC) != 0);
return; return;
...@@ -2475,52 +2474,52 @@ static void wm8996_micd(struct snd_soc_codec *codec) ...@@ -2475,52 +2474,52 @@ static void wm8996_micd(struct snd_soc_codec *codec)
*/ */
if (val & 0x3fc) { if (val & 0x3fc) {
if (wm8996->jack_mic) { if (wm8996->jack_mic) {
dev_dbg(codec->dev, "Mic button detected\n"); dev_dbg(component->dev, "Mic button detected\n");
snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0, snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0,
SND_JACK_BTN_0); SND_JACK_BTN_0);
} else if (wm8996->detecting) { } else if (wm8996->detecting) {
wm8996_report_headphone(codec); wm8996_report_headphone(component);
} }
} }
} }
static irqreturn_t wm8996_irq(int irq, void *data) static irqreturn_t wm8996_irq(int irq, void *data)
{ {
struct snd_soc_codec *codec = data; struct snd_soc_component *component = data;
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
int irq_val; int irq_val;
irq_val = snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2); irq_val = snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2);
if (irq_val < 0) { if (irq_val < 0) {
dev_err(codec->dev, "Failed to read IRQ status: %d\n", dev_err(component->dev, "Failed to read IRQ status: %d\n",
irq_val); irq_val);
return IRQ_NONE; return IRQ_NONE;
} }
irq_val &= ~snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2_MASK); irq_val &= ~snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2_MASK);
if (!irq_val) if (!irq_val)
return IRQ_NONE; return IRQ_NONE;
snd_soc_write(codec, WM8996_INTERRUPT_STATUS_2, irq_val); snd_soc_component_write(component, WM8996_INTERRUPT_STATUS_2, irq_val);
if (irq_val & (WM8996_DCS_DONE_01_EINT | WM8996_DCS_DONE_23_EINT)) { if (irq_val & (WM8996_DCS_DONE_01_EINT | WM8996_DCS_DONE_23_EINT)) {
dev_dbg(codec->dev, "DC servo IRQ\n"); dev_dbg(component->dev, "DC servo IRQ\n");
complete(&wm8996->dcs_done); complete(&wm8996->dcs_done);
} }
if (irq_val & WM8996_FIFOS_ERR_EINT) if (irq_val & WM8996_FIFOS_ERR_EINT)
dev_err(codec->dev, "Digital core FIFO error\n"); dev_err(component->dev, "Digital core FIFO error\n");
if (irq_val & WM8996_FLL_LOCK_EINT) { if (irq_val & WM8996_FLL_LOCK_EINT) {
dev_dbg(codec->dev, "FLL locked\n"); dev_dbg(component->dev, "FLL locked\n");
complete(&wm8996->fll_lock); complete(&wm8996->fll_lock);
} }
if (irq_val & WM8996_MICD_EINT) if (irq_val & WM8996_MICD_EINT)
wm8996_micd(codec); wm8996_micd(component);
if (irq_val & WM8996_HP_DONE_EINT) if (irq_val & WM8996_HP_DONE_EINT)
wm8996_hpdet_irq(codec); wm8996_hpdet_irq(component);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -2539,9 +2538,9 @@ static irqreturn_t wm8996_edge_irq(int irq, void *data) ...@@ -2539,9 +2538,9 @@ static irqreturn_t wm8996_edge_irq(int irq, void *data)
return ret; return ret;
} }
static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) static void wm8996_retune_mobile_pdata(struct snd_soc_component *component)
{ {
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct wm8996_pdata *pdata = &wm8996->pdata; struct wm8996_pdata *pdata = &wm8996->pdata;
struct snd_kcontrol_new controls[] = { struct snd_kcontrol_new controls[] = {
...@@ -2590,15 +2589,15 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) ...@@ -2590,15 +2589,15 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec)
wm8996->retune_mobile_texts = t; wm8996->retune_mobile_texts = t;
} }
dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n",
wm8996->num_retune_mobile_texts); wm8996->num_retune_mobile_texts);
wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts; wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts;
wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts; wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts;
ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls));
if (ret != 0) if (ret != 0)
dev_err(codec->dev, dev_err(component->dev,
"Failed to add ReTune Mobile controls: %d\n", ret); "Failed to add ReTune Mobile controls: %d\n", ret);
} }
...@@ -2614,22 +2613,22 @@ static const struct regmap_config wm8996_regmap = { ...@@ -2614,22 +2613,22 @@ static const struct regmap_config wm8996_regmap = {
.cache_type = REGCACHE_RBTREE, .cache_type = REGCACHE_RBTREE,
}; };
static int wm8996_probe(struct snd_soc_codec *codec) static int wm8996_probe(struct snd_soc_component *component)
{ {
int ret; int ret;
struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
struct i2c_client *i2c = to_i2c_client(codec->dev); struct i2c_client *i2c = to_i2c_client(component->dev);
int irq_flags; int irq_flags;
wm8996->codec = codec; wm8996->component = component;
init_completion(&wm8996->dcs_done); init_completion(&wm8996->dcs_done);
init_completion(&wm8996->fll_lock); init_completion(&wm8996->fll_lock);
if (wm8996->pdata.num_retune_mobile_cfgs) if (wm8996->pdata.num_retune_mobile_cfgs)
wm8996_retune_mobile_pdata(codec); wm8996_retune_mobile_pdata(component);
else else
snd_soc_add_codec_controls(codec, wm8996_eq_controls, snd_soc_add_component_controls(component, wm8996_eq_controls,
ARRAY_SIZE(wm8996_eq_controls)); ARRAY_SIZE(wm8996_eq_controls));
if (i2c->irq) { if (i2c->irq) {
...@@ -2643,18 +2642,18 @@ static int wm8996_probe(struct snd_soc_codec *codec) ...@@ -2643,18 +2642,18 @@ static int wm8996_probe(struct snd_soc_codec *codec)
if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))
ret = request_threaded_irq(i2c->irq, NULL, ret = request_threaded_irq(i2c->irq, NULL,
wm8996_edge_irq, wm8996_edge_irq,
irq_flags, "wm8996", codec); irq_flags, "wm8996", component);
else else
ret = request_threaded_irq(i2c->irq, NULL, wm8996_irq, ret = request_threaded_irq(i2c->irq, NULL, wm8996_irq,
irq_flags, "wm8996", codec); irq_flags, "wm8996", component);
if (ret == 0) { if (ret == 0) {
/* Unmask the interrupt */ /* Unmask the interrupt */
snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL,
WM8996_IM_IRQ, 0); WM8996_IM_IRQ, 0);
/* Enable error reporting and DC servo status */ /* Enable error reporting and DC servo status */
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
WM8996_INTERRUPT_STATUS_2_MASK, WM8996_INTERRUPT_STATUS_2_MASK,
WM8996_IM_DCS_DONE_23_EINT | WM8996_IM_DCS_DONE_23_EINT |
WM8996_IM_DCS_DONE_01_EINT | WM8996_IM_DCS_DONE_01_EINT |
...@@ -2662,7 +2661,7 @@ static int wm8996_probe(struct snd_soc_codec *codec) ...@@ -2662,7 +2661,7 @@ static int wm8996_probe(struct snd_soc_codec *codec)
WM8996_IM_FIFOS_ERR_EINT, WM8996_IM_FIFOS_ERR_EINT,
0); 0);
} else { } else {
dev_err(codec->dev, "Failed to request IRQ: %d\n", dev_err(component->dev, "Failed to request IRQ: %d\n",
ret); ret);
return ret; return ret;
} }
...@@ -2671,34 +2670,33 @@ static int wm8996_probe(struct snd_soc_codec *codec) ...@@ -2671,34 +2670,33 @@ static int wm8996_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static int wm8996_remove(struct snd_soc_codec *codec) static void wm8996_remove(struct snd_soc_component *component)
{ {
struct i2c_client *i2c = to_i2c_client(codec->dev); struct i2c_client *i2c = to_i2c_client(component->dev);
snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL,
WM8996_IM_IRQ, WM8996_IM_IRQ); WM8996_IM_IRQ, WM8996_IM_IRQ);
if (i2c->irq) if (i2c->irq)
free_irq(i2c->irq, codec); free_irq(i2c->irq, component);
return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm8996 = { static const struct snd_soc_component_driver soc_component_dev_wm8996 = {
.probe = wm8996_probe, .probe = wm8996_probe,
.remove = wm8996_remove, .remove = wm8996_remove,
.set_bias_level = wm8996_set_bias_level, .set_bias_level = wm8996_set_bias_level,
.idle_bias_off = true, .seq_notifier = wm8996_seq_notifier,
.seq_notifier = wm8996_seq_notifier, .controls = wm8996_snd_controls,
.component_driver = { .num_controls = ARRAY_SIZE(wm8996_snd_controls),
.controls = wm8996_snd_controls, .dapm_widgets = wm8996_dapm_widgets,
.num_controls = ARRAY_SIZE(wm8996_snd_controls), .num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets),
.dapm_widgets = wm8996_dapm_widgets, .dapm_routes = wm8996_dapm_routes,
.num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets), .num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes),
.dapm_routes = wm8996_dapm_routes, .set_pll = wm8996_set_fll,
.num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes), .use_pmdown_time = 1,
}, .endianness = 1,
.set_pll = wm8996_set_fll, .non_legacy_dai_naming = 1,
}; };
#define WM8996_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ #define WM8996_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
...@@ -3046,8 +3044,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c, ...@@ -3046,8 +3044,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c,
wm8996_init_gpio(wm8996); wm8996_init_gpio(wm8996);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm8996, wm8996_dai, &soc_component_dev_wm8996, wm8996_dai,
ARRAY_SIZE(wm8996_dai)); ARRAY_SIZE(wm8996_dai));
if (ret < 0) if (ret < 0)
goto err_gpiolib; goto err_gpiolib;
...@@ -3074,7 +3072,6 @@ static int wm8996_i2c_remove(struct i2c_client *client) ...@@ -3074,7 +3072,6 @@ static int wm8996_i2c_remove(struct i2c_client *client)
struct wm8996_priv *wm8996 = i2c_get_clientdata(client); struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
int i; int i;
snd_soc_unregister_codec(&client->dev);
wm8996_free_gpio(wm8996); wm8996_free_gpio(wm8996);
if (wm8996->pdata.ldo_ena > 0) { if (wm8996->pdata.ldo_ena > 0) {
gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#define WM8996_FLL_DACLRCLK1 3 #define WM8996_FLL_DACLRCLK1 3
#define WM8996_FLL_BCLK1 4 #define WM8996_FLL_BCLK1 4
typedef void (*wm8996_polarity_fn)(struct snd_soc_codec *codec, int polarity); typedef void (*wm8996_polarity_fn)(struct snd_soc_component *component, int polarity);
int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
wm8996_polarity_fn polarity_cb); wm8996_polarity_fn polarity_cb);
/* /*
......
...@@ -339,10 +339,10 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, ...@@ -339,10 +339,10 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6,
static int speaker_mode_get(struct snd_kcontrol *kcontrol, static int speaker_mode_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg; unsigned int reg;
reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); reg = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2);
if (reg & WM9081_SPK_MODE) if (reg & WM9081_SPK_MODE)
ucontrol->value.enumerated.item[0] = 1; ucontrol->value.enumerated.item[0] = 1;
else else
...@@ -360,9 +360,9 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, ...@@ -360,9 +360,9 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol,
static int speaker_mode_put(struct snd_kcontrol *kcontrol, static int speaker_mode_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); unsigned int reg_pwr = snd_soc_component_read32(component, WM9081_POWER_MANAGEMENT);
unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); unsigned int reg2 = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2);
/* Are we changing anything? */ /* Are we changing anything? */
if (ucontrol->value.enumerated.item[0] == if (ucontrol->value.enumerated.item[0] ==
...@@ -383,7 +383,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol, ...@@ -383,7 +383,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol,
reg2 &= ~WM9081_SPK_MODE; reg2 &= ~WM9081_SPK_MODE;
} }
snd_soc_write(codec, WM9081_ANALOGUE_SPEAKER_2, reg2); snd_soc_component_write(component, WM9081_ANALOGUE_SPEAKER_2, reg2);
return 0; return 0;
} }
...@@ -546,10 +546,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, ...@@ -546,10 +546,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
return 0; return 0;
} }
static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, static int wm9081_set_fll(struct snd_soc_component *component, int fll_id,
unsigned int Fref, unsigned int Fout) unsigned int Fref, unsigned int Fout)
{ {
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
u16 reg1, reg4, reg5; u16 reg1, reg4, reg5;
struct _fll_div fll_div; struct _fll_div fll_div;
int ret; int ret;
...@@ -561,7 +561,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, ...@@ -561,7 +561,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
/* Disable the FLL */ /* Disable the FLL */
if (Fout == 0) { if (Fout == 0) {
dev_dbg(codec->dev, "FLL disabled\n"); dev_dbg(component->dev, "FLL disabled\n");
wm9081->fll_fref = 0; wm9081->fll_fref = 0;
wm9081->fll_fout = 0; wm9081->fll_fout = 0;
...@@ -572,7 +572,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, ...@@ -572,7 +572,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
if (ret != 0) if (ret != 0)
return ret; return ret;
reg5 = snd_soc_read(codec, WM9081_FLL_CONTROL_5); reg5 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_5);
reg5 &= ~WM9081_FLL_CLK_SRC_MASK; reg5 &= ~WM9081_FLL_CLK_SRC_MASK;
switch (fll_id) { switch (fll_id) {
...@@ -581,55 +581,55 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, ...@@ -581,55 +581,55 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
break; break;
default: default:
dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); dev_err(component->dev, "Unknown FLL ID %d\n", fll_id);
return -EINVAL; return -EINVAL;
} }
/* Disable CLK_SYS while we reconfigure */ /* Disable CLK_SYS while we reconfigure */
clk_sys_reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); clk_sys_reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3);
if (clk_sys_reg & WM9081_CLK_SYS_ENA) if (clk_sys_reg & WM9081_CLK_SYS_ENA)
snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3,
clk_sys_reg & ~WM9081_CLK_SYS_ENA); clk_sys_reg & ~WM9081_CLK_SYS_ENA);
/* Any FLL configuration change requires that the FLL be /* Any FLL configuration change requires that the FLL be
* disabled first. */ * disabled first. */
reg1 = snd_soc_read(codec, WM9081_FLL_CONTROL_1); reg1 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_1);
reg1 &= ~WM9081_FLL_ENA; reg1 &= ~WM9081_FLL_ENA;
snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1);
/* Apply the configuration */ /* Apply the configuration */
if (fll_div.k) if (fll_div.k)
reg1 |= WM9081_FLL_FRAC_MASK; reg1 |= WM9081_FLL_FRAC_MASK;
else else
reg1 &= ~WM9081_FLL_FRAC_MASK; reg1 &= ~WM9081_FLL_FRAC_MASK;
snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1);
snd_soc_write(codec, WM9081_FLL_CONTROL_2, snd_soc_component_write(component, WM9081_FLL_CONTROL_2,
(fll_div.fll_outdiv << WM9081_FLL_OUTDIV_SHIFT) | (fll_div.fll_outdiv << WM9081_FLL_OUTDIV_SHIFT) |
(fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT)); (fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT));
snd_soc_write(codec, WM9081_FLL_CONTROL_3, fll_div.k); snd_soc_component_write(component, WM9081_FLL_CONTROL_3, fll_div.k);
reg4 = snd_soc_read(codec, WM9081_FLL_CONTROL_4); reg4 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_4);
reg4 &= ~WM9081_FLL_N_MASK; reg4 &= ~WM9081_FLL_N_MASK;
reg4 |= fll_div.n << WM9081_FLL_N_SHIFT; reg4 |= fll_div.n << WM9081_FLL_N_SHIFT;
snd_soc_write(codec, WM9081_FLL_CONTROL_4, reg4); snd_soc_component_write(component, WM9081_FLL_CONTROL_4, reg4);
reg5 &= ~WM9081_FLL_CLK_REF_DIV_MASK; reg5 &= ~WM9081_FLL_CLK_REF_DIV_MASK;
reg5 |= fll_div.fll_clk_ref_div << WM9081_FLL_CLK_REF_DIV_SHIFT; reg5 |= fll_div.fll_clk_ref_div << WM9081_FLL_CLK_REF_DIV_SHIFT;
snd_soc_write(codec, WM9081_FLL_CONTROL_5, reg5); snd_soc_component_write(component, WM9081_FLL_CONTROL_5, reg5);
/* Set gain to the recommended value */ /* Set gain to the recommended value */
snd_soc_update_bits(codec, WM9081_FLL_CONTROL_4, snd_soc_component_update_bits(component, WM9081_FLL_CONTROL_4,
WM9081_FLL_GAIN_MASK, 0); WM9081_FLL_GAIN_MASK, 0);
/* Enable the FLL */ /* Enable the FLL */
snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA); snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA);
/* Then bring CLK_SYS up again if it was disabled */ /* Then bring CLK_SYS up again if it was disabled */
if (clk_sys_reg & WM9081_CLK_SYS_ENA) if (clk_sys_reg & WM9081_CLK_SYS_ENA)
snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, clk_sys_reg); snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, clk_sys_reg);
dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout);
wm9081->fll_fref = Fref; wm9081->fll_fref = Fref;
wm9081->fll_fout = Fout; wm9081->fll_fout = Fout;
...@@ -637,9 +637,9 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, ...@@ -637,9 +637,9 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
return 0; return 0;
} }
static int configure_clock(struct snd_soc_codec *codec) static int configure_clock(struct snd_soc_component *component)
{ {
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
int new_sysclk, i, target; int new_sysclk, i, target;
unsigned int reg; unsigned int reg;
int ret = 0; int ret = 0;
...@@ -654,7 +654,7 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -654,7 +654,7 @@ static int configure_clock(struct snd_soc_codec *codec)
} else { } else {
wm9081->sysclk_rate = wm9081->mclk_rate; wm9081->sysclk_rate = wm9081->mclk_rate;
} }
wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, 0, 0); wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK, 0, 0);
break; break;
case WM9081_SYSCLK_FLL_MCLK: case WM9081_SYSCLK_FLL_MCLK:
...@@ -695,7 +695,7 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -695,7 +695,7 @@ static int configure_clock(struct snd_soc_codec *codec)
new_sysclk = 12288000; new_sysclk = 12288000;
} }
ret = wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, ret = wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK,
wm9081->mclk_rate, new_sysclk); wm9081->mclk_rate, new_sysclk);
if (ret == 0) { if (ret == 0) {
wm9081->sysclk_rate = new_sysclk; wm9081->sysclk_rate = new_sysclk;
...@@ -711,21 +711,21 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -711,21 +711,21 @@ static int configure_clock(struct snd_soc_codec *codec)
return -EINVAL; return -EINVAL;
} }
reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_1); reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_1);
if (mclkdiv) if (mclkdiv)
reg |= WM9081_MCLKDIV2; reg |= WM9081_MCLKDIV2;
else else
reg &= ~WM9081_MCLKDIV2; reg &= ~WM9081_MCLKDIV2;
snd_soc_write(codec, WM9081_CLOCK_CONTROL_1, reg); snd_soc_component_write(component, WM9081_CLOCK_CONTROL_1, reg);
reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3);
if (fll) if (fll)
reg |= WM9081_CLK_SRC_SEL; reg |= WM9081_CLK_SRC_SEL;
else else
reg &= ~WM9081_CLK_SRC_SEL; reg &= ~WM9081_CLK_SRC_SEL;
snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, reg); snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, reg);
dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate); dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate);
return ret; return ret;
} }
...@@ -733,31 +733,31 @@ static int configure_clock(struct snd_soc_codec *codec) ...@@ -733,31 +733,31 @@ static int configure_clock(struct snd_soc_codec *codec)
static int clk_sys_event(struct snd_soc_dapm_widget *w, static int clk_sys_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
/* This should be done on init() for bypass paths */ /* This should be done on init() for bypass paths */
switch (wm9081->sysclk_source) { switch (wm9081->sysclk_source) {
case WM9081_SYSCLK_MCLK: case WM9081_SYSCLK_MCLK:
dev_dbg(codec->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); dev_dbg(component->dev, "Using %dHz MCLK\n", wm9081->mclk_rate);
break; break;
case WM9081_SYSCLK_FLL_MCLK: case WM9081_SYSCLK_FLL_MCLK:
dev_dbg(codec->dev, "Using %dHz MCLK with FLL\n", dev_dbg(component->dev, "Using %dHz MCLK with FLL\n",
wm9081->mclk_rate); wm9081->mclk_rate);
break; break;
default: default:
dev_err(codec->dev, "System clock not configured\n"); dev_err(component->dev, "System clock not configured\n");
return -EINVAL; return -EINVAL;
} }
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
configure_clock(codec); configure_clock(component);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
/* Disable the FLL if it's running */ /* Disable the FLL if it's running */
wm9081_set_fll(codec, 0, 0, 0); wm9081_set_fll(component, 0, 0, 0);
break; break;
} }
...@@ -816,10 +816,10 @@ static const struct snd_soc_dapm_route wm9081_audio_paths[] = { ...@@ -816,10 +816,10 @@ static const struct snd_soc_dapm_route wm9081_audio_paths[] = {
{ "SPKP", NULL, "Speaker" }, { "SPKP", NULL, "Speaker" },
}; };
static int wm9081_set_bias_level(struct snd_soc_codec *codec, static int wm9081_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
switch (level) { switch (level) {
case SND_SOC_BIAS_ON: case SND_SOC_BIAS_ON:
...@@ -827,31 +827,31 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, ...@@ -827,31 +827,31 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_PREPARE:
/* VMID=2*40k */ /* VMID=2*40k */
snd_soc_update_bits(codec, WM9081_VMID_CONTROL, snd_soc_component_update_bits(component, WM9081_VMID_CONTROL,
WM9081_VMID_SEL_MASK, 0x2); WM9081_VMID_SEL_MASK, 0x2);
/* Normal bias current */ /* Normal bias current */
snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1,
WM9081_STBY_BIAS_ENA, 0); WM9081_STBY_BIAS_ENA, 0);
break; break;
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* Initial cold start */ /* Initial cold start */
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
regcache_cache_only(wm9081->regmap, false); regcache_cache_only(wm9081->regmap, false);
regcache_sync(wm9081->regmap); regcache_sync(wm9081->regmap);
/* Disable LINEOUT discharge */ /* Disable LINEOUT discharge */
snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL,
WM9081_LINEOUT_DISCH, 0); WM9081_LINEOUT_DISCH, 0);
/* Select startup bias source */ /* Select startup bias source */
snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1,
WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC | WM9081_BIAS_ENA,
WM9081_BIAS_SRC | WM9081_BIAS_ENA); WM9081_BIAS_SRC | WM9081_BIAS_ENA);
/* VMID 2*4k; Soft VMID ramp enable */ /* VMID 2*4k; Soft VMID ramp enable */
snd_soc_update_bits(codec, WM9081_VMID_CONTROL, snd_soc_component_update_bits(component, WM9081_VMID_CONTROL,
WM9081_VMID_RAMP | WM9081_VMID_RAMP |
WM9081_VMID_SEL_MASK, WM9081_VMID_SEL_MASK,
WM9081_VMID_RAMP | 0x6); WM9081_VMID_RAMP | 0x6);
...@@ -859,37 +859,37 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, ...@@ -859,37 +859,37 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
mdelay(100); mdelay(100);
/* Normal bias enable & soft start off */ /* Normal bias enable & soft start off */
snd_soc_update_bits(codec, WM9081_VMID_CONTROL, snd_soc_component_update_bits(component, WM9081_VMID_CONTROL,
WM9081_VMID_RAMP, 0); WM9081_VMID_RAMP, 0);
/* Standard bias source */ /* Standard bias source */
snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1,
WM9081_BIAS_SRC, 0); WM9081_BIAS_SRC, 0);
} }
/* VMID 2*240k */ /* VMID 2*240k */
snd_soc_update_bits(codec, WM9081_VMID_CONTROL, snd_soc_component_update_bits(component, WM9081_VMID_CONTROL,
WM9081_VMID_SEL_MASK, 0x04); WM9081_VMID_SEL_MASK, 0x04);
/* Standby bias current on */ /* Standby bias current on */
snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1,
WM9081_STBY_BIAS_ENA, WM9081_STBY_BIAS_ENA,
WM9081_STBY_BIAS_ENA); WM9081_STBY_BIAS_ENA);
break; break;
case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_OFF:
/* Startup bias source and disable bias */ /* Startup bias source and disable bias */
snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1,
WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC | WM9081_BIAS_ENA,
WM9081_BIAS_SRC); WM9081_BIAS_SRC);
/* Disable VMID with soft ramping */ /* Disable VMID with soft ramping */
snd_soc_update_bits(codec, WM9081_VMID_CONTROL, snd_soc_component_update_bits(component, WM9081_VMID_CONTROL,
WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK, WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK,
WM9081_VMID_RAMP); WM9081_VMID_RAMP);
/* Actively discharge LINEOUT */ /* Actively discharge LINEOUT */
snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL,
WM9081_LINEOUT_DISCH, WM9081_LINEOUT_DISCH,
WM9081_LINEOUT_DISCH); WM9081_LINEOUT_DISCH);
...@@ -903,9 +903,9 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, ...@@ -903,9 +903,9 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec,
static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, static int wm9081_set_dai_fmt(struct snd_soc_dai *dai,
unsigned int fmt) unsigned int fmt)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
unsigned int aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); unsigned int aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2);
aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV | aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV |
WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK); WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK);
...@@ -986,7 +986,7 @@ static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, ...@@ -986,7 +986,7 @@ static int wm9081_set_dai_fmt(struct snd_soc_dai *dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2);
return 0; return 0;
} }
...@@ -995,23 +995,23 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -995,23 +995,23 @@ static int wm9081_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 wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
int ret, i, best, best_val, cur_val; int ret, i, best, best_val, cur_val;
unsigned int clk_ctrl2, aif1, aif2, aif3, aif4; unsigned int clk_ctrl2, aif1, aif2, aif3, aif4;
clk_ctrl2 = snd_soc_read(codec, WM9081_CLOCK_CONTROL_2); clk_ctrl2 = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_2);
clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK); clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK);
aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2);
aif2 &= ~WM9081_AIF_WL_MASK; aif2 &= ~WM9081_AIF_WL_MASK;
aif3 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_3); aif3 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_3);
aif3 &= ~WM9081_BCLK_DIV_MASK; aif3 &= ~WM9081_BCLK_DIV_MASK;
aif4 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_4); aif4 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_4);
aif4 &= ~WM9081_LRCLK_RATE_MASK; aif4 &= ~WM9081_LRCLK_RATE_MASK;
wm9081->fs = params_rate(params); wm9081->fs = params_rate(params);
...@@ -1047,9 +1047,9 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -1047,9 +1047,9 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
} }
} }
dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm9081->bclk); dev_dbg(component->dev, "Target BCLK is %dHz\n", wm9081->bclk);
ret = configure_clock(codec); ret = configure_clock(component);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -1065,7 +1065,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -1065,7 +1065,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
best_val = cur_val; best_val = cur_val;
} }
} }
dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n",
clk_sys_rates[best].ratio); clk_sys_rates[best].ratio);
clk_ctrl2 |= (clk_sys_rates[best].clk_sys_rate clk_ctrl2 |= (clk_sys_rates[best].clk_sys_rate
<< WM9081_CLK_SYS_RATE_SHIFT); << WM9081_CLK_SYS_RATE_SHIFT);
...@@ -1081,7 +1081,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -1081,7 +1081,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
best_val = cur_val; best_val = cur_val;
} }
} }
dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n",
sample_rates[best].rate); sample_rates[best].rate);
clk_ctrl2 |= (sample_rates[best].sample_rate clk_ctrl2 |= (sample_rates[best].sample_rate
<< WM9081_SAMPLE_RATE_SHIFT); << WM9081_SAMPLE_RATE_SHIFT);
...@@ -1100,12 +1100,12 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -1100,12 +1100,12 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
} }
} }
wm9081->bclk = (wm9081->sysclk_rate * 10) / bclk_divs[best].div; wm9081->bclk = (wm9081->sysclk_rate * 10) / bclk_divs[best].div;
dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n",
bclk_divs[best].div, wm9081->bclk); bclk_divs[best].div, wm9081->bclk);
aif3 |= bclk_divs[best].bclk_div; aif3 |= bclk_divs[best].bclk_div;
/* LRCLK is a simple fraction of BCLK */ /* LRCLK is a simple fraction of BCLK */
dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs);
aif4 |= wm9081->bclk / wm9081->fs; aif4 |= wm9081->bclk / wm9081->fs;
/* Apply a ReTune Mobile configuration if it's in use */ /* Apply a ReTune Mobile configuration if it's in use */
...@@ -1126,51 +1126,51 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, ...@@ -1126,51 +1126,51 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
} }
s = &pdata->retune_configs[best]; s = &pdata->retune_configs[best];
dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", dev_dbg(component->dev, "ReTune Mobile %s tuned for %dHz\n",
s->name, s->rate); s->name, s->rate);
/* If the EQ is enabled then disable it while we write out */ /* If the EQ is enabled then disable it while we write out */
eq1 = snd_soc_read(codec, WM9081_EQ_1) & WM9081_EQ_ENA; eq1 = snd_soc_component_read32(component, WM9081_EQ_1) & WM9081_EQ_ENA;
if (eq1 & WM9081_EQ_ENA) if (eq1 & WM9081_EQ_ENA)
snd_soc_write(codec, WM9081_EQ_1, 0); snd_soc_component_write(component, WM9081_EQ_1, 0);
/* Write out the other values */ /* Write out the other values */
for (i = 1; i < ARRAY_SIZE(s->config); i++) for (i = 1; i < ARRAY_SIZE(s->config); i++)
snd_soc_write(codec, WM9081_EQ_1 + i, s->config[i]); snd_soc_component_write(component, WM9081_EQ_1 + i, s->config[i]);
eq1 |= (s->config[0] & ~WM9081_EQ_ENA); eq1 |= (s->config[0] & ~WM9081_EQ_ENA);
snd_soc_write(codec, WM9081_EQ_1, eq1); snd_soc_component_write(component, WM9081_EQ_1, eq1);
} }
snd_soc_write(codec, WM9081_CLOCK_CONTROL_2, clk_ctrl2); snd_soc_component_write(component, WM9081_CLOCK_CONTROL_2, clk_ctrl2);
snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2);
snd_soc_write(codec, WM9081_AUDIO_INTERFACE_3, aif3); snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_3, aif3);
snd_soc_write(codec, WM9081_AUDIO_INTERFACE_4, aif4); snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_4, aif4);
return 0; return 0;
} }
static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute) static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{ {
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_component *component = codec_dai->component;
unsigned int reg; unsigned int reg;
reg = snd_soc_read(codec, WM9081_DAC_DIGITAL_2); reg = snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2);
if (mute) if (mute)
reg |= WM9081_DAC_MUTE; reg |= WM9081_DAC_MUTE;
else else
reg &= ~WM9081_DAC_MUTE; reg &= ~WM9081_DAC_MUTE;
snd_soc_write(codec, WM9081_DAC_DIGITAL_2, reg); snd_soc_component_write(component, WM9081_DAC_DIGITAL_2, reg);
return 0; return 0;
} }
static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int wm9081_set_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir) int source, unsigned int freq, int dir)
{ {
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
switch (clk_id) { switch (clk_id) {
case WM9081_SYSCLK_MCLK: case WM9081_SYSCLK_MCLK:
...@@ -1189,9 +1189,9 @@ static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, ...@@ -1189,9 +1189,9 @@ static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id,
static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, static int wm9081_set_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
{ {
struct snd_soc_codec *codec = dai->codec; struct snd_soc_component *component = dai->component;
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
unsigned int aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); unsigned int aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1);
aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK); aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK);
...@@ -1221,7 +1221,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, ...@@ -1221,7 +1221,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai,
return -EINVAL; return -EINVAL;
} }
snd_soc_write(codec, WM9081_AUDIO_INTERFACE_1, aif1); snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_1, aif1);
return 0; return 0;
} }
...@@ -1254,42 +1254,39 @@ static struct snd_soc_dai_driver wm9081_dai = { ...@@ -1254,42 +1254,39 @@ static struct snd_soc_dai_driver wm9081_dai = {
.ops = &wm9081_dai_ops, .ops = &wm9081_dai_ops,
}; };
static int wm9081_probe(struct snd_soc_codec *codec) static int wm9081_probe(struct snd_soc_component *component)
{ {
struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component);
/* Enable zero cross by default */ /* Enable zero cross by default */
snd_soc_update_bits(codec, WM9081_ANALOGUE_LINEOUT, snd_soc_component_update_bits(component, WM9081_ANALOGUE_LINEOUT,
WM9081_LINEOUTZC, WM9081_LINEOUTZC); WM9081_LINEOUTZC, WM9081_LINEOUTZC);
snd_soc_update_bits(codec, WM9081_ANALOGUE_SPEAKER_PGA, snd_soc_component_update_bits(component, WM9081_ANALOGUE_SPEAKER_PGA,
WM9081_SPKPGAZC, WM9081_SPKPGAZC); WM9081_SPKPGAZC, WM9081_SPKPGAZC);
if (!wm9081->pdata.num_retune_configs) { if (!wm9081->pdata.num_retune_configs) {
dev_dbg(codec->dev, dev_dbg(component->dev,
"No ReTune Mobile data, using normal EQ\n"); "No ReTune Mobile data, using normal EQ\n");
snd_soc_add_codec_controls(codec, wm9081_eq_controls, snd_soc_add_component_controls(component, wm9081_eq_controls,
ARRAY_SIZE(wm9081_eq_controls)); ARRAY_SIZE(wm9081_eq_controls));
} }
return 0; return 0;
} }
static const struct snd_soc_codec_driver soc_codec_dev_wm9081 = { static const struct snd_soc_component_driver soc_component_dev_wm9081 = {
.probe = wm9081_probe, .probe = wm9081_probe,
.set_sysclk = wm9081_set_sysclk,
.set_sysclk = wm9081_set_sysclk, .set_bias_level = wm9081_set_bias_level,
.set_bias_level = wm9081_set_bias_level, .controls = wm9081_snd_controls,
.num_controls = ARRAY_SIZE(wm9081_snd_controls),
.idle_bias_off = true, .dapm_widgets = wm9081_dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets),
.component_driver = { .dapm_routes = wm9081_audio_paths,
.controls = wm9081_snd_controls, .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths),
.num_controls = ARRAY_SIZE(wm9081_snd_controls), .use_pmdown_time = 1,
.dapm_widgets = wm9081_dapm_widgets, .endianness = 1,
.num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), .non_legacy_dai_naming = 1,
.dapm_routes = wm9081_audio_paths,
.num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths),
},
}; };
static const struct regmap_config wm9081_regmap = { static const struct regmap_config wm9081_regmap = {
...@@ -1355,8 +1352,8 @@ static int wm9081_i2c_probe(struct i2c_client *i2c, ...@@ -1355,8 +1352,8 @@ static int wm9081_i2c_probe(struct i2c_client *i2c,
regcache_cache_only(wm9081->regmap, true); regcache_cache_only(wm9081->regmap, true);
ret = snd_soc_register_codec(&i2c->dev, ret = devm_snd_soc_register_component(&i2c->dev,
&soc_codec_dev_wm9081, &wm9081_dai, 1); &soc_component_dev_wm9081, &wm9081_dai, 1);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1365,7 +1362,6 @@ static int wm9081_i2c_probe(struct i2c_client *i2c, ...@@ -1365,7 +1362,6 @@ static int wm9081_i2c_probe(struct i2c_client *i2c,
static int wm9081_i2c_remove(struct i2c_client *client) static int wm9081_i2c_remove(struct i2c_client *client)
{ {
snd_soc_unregister_codec(&client->dev);
return 0; return 0;
} }
......
...@@ -60,9 +60,9 @@ static const char *speaker_mode_text[] = { ...@@ -60,9 +60,9 @@ static const char *speaker_mode_text[] = {
static SOC_ENUM_SINGLE_DECL(speaker_mode, static SOC_ENUM_SINGLE_DECL(speaker_mode,
WM8993_SPKMIXR_ATTENUATION, 8, speaker_mode_text); WM8993_SPKMIXR_ATTENUATION, 8, speaker_mode_text);
static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) static void wait_for_dc_servo(struct snd_soc_component *component, unsigned int op)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
unsigned int reg; unsigned int reg;
int count = 0; int count = 0;
int timeout; int timeout;
...@@ -71,9 +71,9 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) ...@@ -71,9 +71,9 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1; val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1;
/* Trigger the command */ /* Trigger the command */
snd_soc_write(codec, WM8993_DC_SERVO_0, val); snd_soc_component_write(component, WM8993_DC_SERVO_0, val);
dev_dbg(codec->dev, "Waiting for DC servo...\n"); dev_dbg(component->dev, "Waiting for DC servo...\n");
if (hubs->dcs_done_irq) if (hubs->dcs_done_irq)
timeout = 4; timeout = 4;
...@@ -89,12 +89,12 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) ...@@ -89,12 +89,12 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op)
else else
msleep(1); msleep(1);
reg = snd_soc_read(codec, WM8993_DC_SERVO_0); reg = snd_soc_component_read32(component, WM8993_DC_SERVO_0);
dev_dbg(codec->dev, "DC servo: %x\n", reg); dev_dbg(component->dev, "DC servo: %x\n", reg);
} while (reg & op && count < timeout); } while (reg & op && count < timeout);
if (reg & op) if (reg & op)
dev_err(codec->dev, "Timed out waiting for DC Servo %x\n", dev_err(component->dev, "Timed out waiting for DC Servo %x\n",
op); op);
} }
...@@ -108,35 +108,35 @@ irqreturn_t wm_hubs_dcs_done(int irq, void *data) ...@@ -108,35 +108,35 @@ irqreturn_t wm_hubs_dcs_done(int irq, void *data)
} }
EXPORT_SYMBOL_GPL(wm_hubs_dcs_done); EXPORT_SYMBOL_GPL(wm_hubs_dcs_done);
static bool wm_hubs_dac_hp_direct(struct snd_soc_codec *codec) static bool wm_hubs_dac_hp_direct(struct snd_soc_component *component)
{ {
int reg; int reg;
/* If we're going via the mixer we'll need to do additional checks */ /* If we're going via the mixer we'll need to do additional checks */
reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER1); reg = snd_soc_component_read32(component, WM8993_OUTPUT_MIXER1);
if (!(reg & WM8993_DACL_TO_HPOUT1L)) { if (!(reg & WM8993_DACL_TO_HPOUT1L)) {
if (reg & ~WM8993_DACL_TO_MIXOUTL) { if (reg & ~WM8993_DACL_TO_MIXOUTL) {
dev_vdbg(codec->dev, "Analogue paths connected: %x\n", dev_vdbg(component->dev, "Analogue paths connected: %x\n",
reg & ~WM8993_DACL_TO_HPOUT1L); reg & ~WM8993_DACL_TO_HPOUT1L);
return false; return false;
} else { } else {
dev_vdbg(codec->dev, "HPL connected to mixer\n"); dev_vdbg(component->dev, "HPL connected to mixer\n");
} }
} else { } else {
dev_vdbg(codec->dev, "HPL connected to DAC\n"); dev_vdbg(component->dev, "HPL connected to DAC\n");
} }
reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER2); reg = snd_soc_component_read32(component, WM8993_OUTPUT_MIXER2);
if (!(reg & WM8993_DACR_TO_HPOUT1R)) { if (!(reg & WM8993_DACR_TO_HPOUT1R)) {
if (reg & ~WM8993_DACR_TO_MIXOUTR) { if (reg & ~WM8993_DACR_TO_MIXOUTR) {
dev_vdbg(codec->dev, "Analogue paths connected: %x\n", dev_vdbg(component->dev, "Analogue paths connected: %x\n",
reg & ~WM8993_DACR_TO_HPOUT1R); reg & ~WM8993_DACR_TO_HPOUT1R);
return false; return false;
} else { } else {
dev_vdbg(codec->dev, "HPR connected to mixer\n"); dev_vdbg(component->dev, "HPR connected to mixer\n");
} }
} else { } else {
dev_vdbg(codec->dev, "HPR connected to DAC\n"); dev_vdbg(component->dev, "HPR connected to DAC\n");
} }
return true; return true;
...@@ -149,17 +149,17 @@ struct wm_hubs_dcs_cache { ...@@ -149,17 +149,17 @@ struct wm_hubs_dcs_cache {
u16 dcs_cfg; u16 dcs_cfg;
}; };
static bool wm_hubs_dcs_cache_get(struct snd_soc_codec *codec, static bool wm_hubs_dcs_cache_get(struct snd_soc_component *component,
struct wm_hubs_dcs_cache **entry) struct wm_hubs_dcs_cache **entry)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
struct wm_hubs_dcs_cache *cache; struct wm_hubs_dcs_cache *cache;
unsigned int left, right; unsigned int left, right;
left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); left = snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME);
left &= WM8993_HPOUT1L_VOL_MASK; left &= WM8993_HPOUT1L_VOL_MASK;
right = snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME); right = snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME);
right &= WM8993_HPOUT1R_VOL_MASK; right &= WM8993_HPOUT1R_VOL_MASK;
list_for_each_entry(cache, &hubs->dcs_cache, list) { list_for_each_entry(cache, &hubs->dcs_cache, list) {
...@@ -173,22 +173,22 @@ static bool wm_hubs_dcs_cache_get(struct snd_soc_codec *codec, ...@@ -173,22 +173,22 @@ static bool wm_hubs_dcs_cache_get(struct snd_soc_codec *codec,
return false; return false;
} }
static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg) static void wm_hubs_dcs_cache_set(struct snd_soc_component *component, u16 dcs_cfg)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
struct wm_hubs_dcs_cache *cache; struct wm_hubs_dcs_cache *cache;
if (hubs->no_cache_dac_hp_direct) if (hubs->no_cache_dac_hp_direct)
return; return;
cache = devm_kzalloc(codec->dev, sizeof(*cache), GFP_KERNEL); cache = devm_kzalloc(component->dev, sizeof(*cache), GFP_KERNEL);
if (!cache) if (!cache)
return; return;
cache->left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); cache->left = snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME);
cache->left &= WM8993_HPOUT1L_VOL_MASK; cache->left &= WM8993_HPOUT1L_VOL_MASK;
cache->right = snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME); cache->right = snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME);
cache->right &= WM8993_HPOUT1R_VOL_MASK; cache->right &= WM8993_HPOUT1R_VOL_MASK;
cache->dcs_cfg = dcs_cfg; cache->dcs_cfg = dcs_cfg;
...@@ -196,10 +196,10 @@ static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg) ...@@ -196,10 +196,10 @@ static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg)
list_add_tail(&cache->list, &hubs->dcs_cache); list_add_tail(&cache->list, &hubs->dcs_cache);
} }
static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, static int wm_hubs_read_dc_servo(struct snd_soc_component *component,
u16 *reg_l, u16 *reg_r) u16 *reg_l, u16 *reg_r)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
u16 dcs_reg, reg; u16 dcs_reg, reg;
int ret = 0; int ret = 0;
...@@ -220,14 +220,14 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, ...@@ -220,14 +220,14 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec,
*/ */
switch (hubs->dcs_readback_mode) { switch (hubs->dcs_readback_mode) {
case 0: case 0:
*reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) *reg_l = snd_soc_component_read32(component, WM8993_DC_SERVO_READBACK_1)
& WM8993_DCS_INTEG_CHAN_0_MASK; & WM8993_DCS_INTEG_CHAN_0_MASK;
*reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) *reg_r = snd_soc_component_read32(component, WM8993_DC_SERVO_READBACK_2)
& WM8993_DCS_INTEG_CHAN_1_MASK; & WM8993_DCS_INTEG_CHAN_1_MASK;
break; break;
case 2: case 2:
case 1: case 1:
reg = snd_soc_read(codec, dcs_reg); reg = snd_soc_component_read32(component, dcs_reg);
*reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK) *reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK)
>> WM8993_DCS_DAC_WR_VAL_1_SHIFT; >> WM8993_DCS_DAC_WR_VAL_1_SHIFT;
*reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK; *reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK;
...@@ -242,9 +242,9 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, ...@@ -242,9 +242,9 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec,
/* /*
* Startup calibration of the DC servo * Startup calibration of the DC servo
*/ */
static void enable_dc_servo(struct snd_soc_codec *codec) static void enable_dc_servo(struct snd_soc_component *component)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
struct wm_hubs_dcs_cache *cache; struct wm_hubs_dcs_cache *cache;
s8 offset; s8 offset;
u16 reg_l, reg_r, dcs_cfg, dcs_reg; u16 reg_l, reg_r, dcs_cfg, dcs_reg;
...@@ -260,12 +260,12 @@ static void enable_dc_servo(struct snd_soc_codec *codec) ...@@ -260,12 +260,12 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
/* If we're using a digital only path and have a previously /* If we're using a digital only path and have a previously
* callibrated DC servo offset stored then use that. */ * callibrated DC servo offset stored then use that. */
if (wm_hubs_dac_hp_direct(codec) && if (wm_hubs_dac_hp_direct(component) &&
wm_hubs_dcs_cache_get(codec, &cache)) { wm_hubs_dcs_cache_get(component, &cache)) {
dev_dbg(codec->dev, "Using cached DCS offset %x for %d,%d\n", dev_dbg(component->dev, "Using cached DCS offset %x for %d,%d\n",
cache->dcs_cfg, cache->left, cache->right); cache->dcs_cfg, cache->left, cache->right);
snd_soc_write(codec, dcs_reg, cache->dcs_cfg); snd_soc_component_write(component, dcs_reg, cache->dcs_cfg);
wait_for_dc_servo(codec, wait_for_dc_servo(component,
WM8993_DCS_TRIG_DAC_WR_0 | WM8993_DCS_TRIG_DAC_WR_0 |
WM8993_DCS_TRIG_DAC_WR_1); WM8993_DCS_TRIG_DAC_WR_1);
return; return;
...@@ -273,48 +273,48 @@ static void enable_dc_servo(struct snd_soc_codec *codec) ...@@ -273,48 +273,48 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
if (hubs->series_startup) { if (hubs->series_startup) {
/* Set for 32 series updates */ /* Set for 32 series updates */
snd_soc_update_bits(codec, WM8993_DC_SERVO_1, snd_soc_component_update_bits(component, WM8993_DC_SERVO_1,
WM8993_DCS_SERIES_NO_01_MASK, WM8993_DCS_SERIES_NO_01_MASK,
32 << WM8993_DCS_SERIES_NO_01_SHIFT); 32 << WM8993_DCS_SERIES_NO_01_SHIFT);
wait_for_dc_servo(codec, wait_for_dc_servo(component,
WM8993_DCS_TRIG_SERIES_0 | WM8993_DCS_TRIG_SERIES_0 |
WM8993_DCS_TRIG_SERIES_1); WM8993_DCS_TRIG_SERIES_1);
} else { } else {
wait_for_dc_servo(codec, wait_for_dc_servo(component,
WM8993_DCS_TRIG_STARTUP_0 | WM8993_DCS_TRIG_STARTUP_0 |
WM8993_DCS_TRIG_STARTUP_1); WM8993_DCS_TRIG_STARTUP_1);
} }
if (wm_hubs_read_dc_servo(codec, &reg_l, &reg_r) < 0) if (wm_hubs_read_dc_servo(component, &reg_l, &reg_r) < 0)
return; return;
dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r); dev_dbg(component->dev, "DCS input: %x %x\n", reg_l, reg_r);
/* Apply correction to DC servo result */ /* Apply correction to DC servo result */
if (hubs->dcs_codes_l || hubs->dcs_codes_r) { if (hubs->dcs_codes_l || hubs->dcs_codes_r) {
dev_dbg(codec->dev, dev_dbg(component->dev,
"Applying %d/%d code DC servo correction\n", "Applying %d/%d code DC servo correction\n",
hubs->dcs_codes_l, hubs->dcs_codes_r); hubs->dcs_codes_l, hubs->dcs_codes_r);
/* HPOUT1R */ /* HPOUT1R */
offset = (s8)reg_r; offset = (s8)reg_r;
dev_dbg(codec->dev, "DCS right %d->%d\n", offset, dev_dbg(component->dev, "DCS right %d->%d\n", offset,
offset + hubs->dcs_codes_r); offset + hubs->dcs_codes_r);
offset += hubs->dcs_codes_r; offset += hubs->dcs_codes_r;
dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT; dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT;
/* HPOUT1L */ /* HPOUT1L */
offset = (s8)reg_l; offset = (s8)reg_l;
dev_dbg(codec->dev, "DCS left %d->%d\n", offset, dev_dbg(component->dev, "DCS left %d->%d\n", offset,
offset + hubs->dcs_codes_l); offset + hubs->dcs_codes_l);
offset += hubs->dcs_codes_l; offset += hubs->dcs_codes_l;
dcs_cfg |= (u8)offset; dcs_cfg |= (u8)offset;
dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg); dev_dbg(component->dev, "DCS result: %x\n", dcs_cfg);
/* Do it */ /* Do it */
snd_soc_write(codec, dcs_reg, dcs_cfg); snd_soc_component_write(component, dcs_reg, dcs_cfg);
wait_for_dc_servo(codec, wait_for_dc_servo(component,
WM8993_DCS_TRIG_DAC_WR_0 | WM8993_DCS_TRIG_DAC_WR_0 |
WM8993_DCS_TRIG_DAC_WR_1); WM8993_DCS_TRIG_DAC_WR_1);
} else { } else {
...@@ -324,8 +324,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec) ...@@ -324,8 +324,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
/* Save the callibrated offset if we're in class W mode and /* Save the callibrated offset if we're in class W mode and
* therefore don't have any analogue signal mixed in. */ * therefore don't have any analogue signal mixed in. */
if (wm_hubs_dac_hp_direct(codec)) if (wm_hubs_dac_hp_direct(component))
wm_hubs_dcs_cache_set(codec, dcs_cfg); wm_hubs_dcs_cache_set(component, dcs_cfg);
} }
/* /*
...@@ -334,8 +334,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec) ...@@ -334,8 +334,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec)
static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
int ret; int ret;
ret = snd_soc_put_volsw(kcontrol, ucontrol); ret = snd_soc_put_volsw(kcontrol, ucontrol);
...@@ -346,9 +346,9 @@ static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, ...@@ -346,9 +346,9 @@ static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol,
return ret; return ret;
/* Only need to do this if the outputs are active */ /* Only need to do this if the outputs are active */
if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) if (snd_soc_component_read32(component, WM8993_POWER_MANAGEMENT_1)
& (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA))
snd_soc_update_bits(codec, snd_soc_component_update_bits(component,
WM8993_DC_SERVO_0, WM8993_DC_SERVO_0,
WM8993_DCS_TRIG_SINGLE_0 | WM8993_DCS_TRIG_SINGLE_0 |
WM8993_DCS_TRIG_SINGLE_1, WM8993_DCS_TRIG_SINGLE_1,
...@@ -499,8 +499,8 @@ SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, ...@@ -499,8 +499,8 @@ SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1,
static int hp_supply_event(struct snd_soc_dapm_widget *w, static int hp_supply_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -509,28 +509,28 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, ...@@ -509,28 +509,28 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
break; break;
case 1: case 1:
/* Enable the headphone amp */ /* Enable the headphone amp */
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_HPOUT1L_ENA | WM8993_HPOUT1L_ENA |
WM8993_HPOUT1R_ENA, WM8993_HPOUT1R_ENA,
WM8993_HPOUT1L_ENA | WM8993_HPOUT1L_ENA |
WM8993_HPOUT1R_ENA); WM8993_HPOUT1R_ENA);
/* Enable the second stage */ /* Enable the second stage */
snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0,
WM8993_HPOUT1L_DLY | WM8993_HPOUT1L_DLY |
WM8993_HPOUT1R_DLY, WM8993_HPOUT1R_DLY,
WM8993_HPOUT1L_DLY | WM8993_HPOUT1L_DLY |
WM8993_HPOUT1R_DLY); WM8993_HPOUT1R_DLY);
break; break;
default: default:
dev_err(codec->dev, "Unknown HP startup mode %d\n", dev_err(component->dev, "Unknown HP startup mode %d\n",
hubs->hp_startup_mode); hubs->hp_startup_mode);
break; break;
} }
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, snd_soc_component_update_bits(component, WM8993_CHARGE_PUMP_1,
WM8993_CP_ENA, 0); WM8993_CP_ENA, 0);
break; break;
} }
...@@ -541,47 +541,47 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, ...@@ -541,47 +541,47 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w,
static int hp_event(struct snd_soc_dapm_widget *w, static int hp_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); unsigned int reg = snd_soc_component_read32(component, WM8993_ANALOGUE_HP_0);
switch (event) { switch (event) {
case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMU:
snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, snd_soc_component_update_bits(component, WM8993_CHARGE_PUMP_1,
WM8993_CP_ENA, WM8993_CP_ENA); WM8993_CP_ENA, WM8993_CP_ENA);
msleep(5); msleep(5);
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA,
WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA);
reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY;
snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); snd_soc_component_write(component, WM8993_ANALOGUE_HP_0, reg);
snd_soc_update_bits(codec, WM8993_DC_SERVO_1, snd_soc_component_update_bits(component, WM8993_DC_SERVO_1,
WM8993_DCS_TIMER_PERIOD_01_MASK, 0); WM8993_DCS_TIMER_PERIOD_01_MASK, 0);
enable_dc_servo(codec); enable_dc_servo(component);
reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT |
WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT;
snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); snd_soc_component_write(component, WM8993_ANALOGUE_HP_0, reg);
break; break;
case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMD:
snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0,
WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_OUTP |
WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_OUTP |
WM8993_HPOUT1L_RMV_SHORT | WM8993_HPOUT1L_RMV_SHORT |
WM8993_HPOUT1R_RMV_SHORT, 0); WM8993_HPOUT1R_RMV_SHORT, 0);
snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0,
WM8993_HPOUT1L_DLY | WM8993_HPOUT1L_DLY |
WM8993_HPOUT1R_DLY, 0); WM8993_HPOUT1R_DLY, 0);
snd_soc_write(codec, WM8993_DC_SERVO_0, 0); snd_soc_component_write(component, WM8993_DC_SERVO_0, 0);
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1,
WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA,
0); 0);
break; break;
...@@ -593,18 +593,18 @@ static int hp_event(struct snd_soc_dapm_widget *w, ...@@ -593,18 +593,18 @@ static int hp_event(struct snd_soc_dapm_widget *w,
static int earpiece_event(struct snd_soc_dapm_widget *w, static int earpiece_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *control, int event) struct snd_kcontrol *control, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; u16 reg = snd_soc_component_read32(component, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA;
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
reg |= WM8993_HPOUT2_IN_ENA; reg |= WM8993_HPOUT2_IN_ENA;
snd_soc_write(codec, WM8993_ANTIPOP1, reg); snd_soc_component_write(component, WM8993_ANTIPOP1, reg);
udelay(50); udelay(50);
break; break;
case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_POST_PMD:
snd_soc_write(codec, WM8993_ANTIPOP1, reg); snd_soc_component_write(component, WM8993_ANTIPOP1, reg);
break; break;
default: default:
...@@ -618,8 +618,8 @@ static int earpiece_event(struct snd_soc_dapm_widget *w, ...@@ -618,8 +618,8 @@ static int earpiece_event(struct snd_soc_dapm_widget *w,
static int lineout_event(struct snd_soc_dapm_widget *w, static int lineout_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *control, int event) struct snd_kcontrol *control, int event)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
bool *flag; bool *flag;
switch (w->shift) { switch (w->shift) {
...@@ -648,8 +648,8 @@ static int lineout_event(struct snd_soc_dapm_widget *w, ...@@ -648,8 +648,8 @@ static int lineout_event(struct snd_soc_dapm_widget *w,
static int micbias_event(struct snd_soc_dapm_widget *w, static int micbias_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_dapm_to_codec(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
switch (w->shift) { switch (w->shift) {
case WM8993_MICB1_ENA_SHIFT: case WM8993_MICB1_ENA_SHIFT:
...@@ -667,26 +667,26 @@ static int micbias_event(struct snd_soc_dapm_widget *w, ...@@ -667,26 +667,26 @@ static int micbias_event(struct snd_soc_dapm_widget *w,
return 0; return 0;
} }
void wm_hubs_update_class_w(struct snd_soc_codec *codec) void wm_hubs_update_class_w(struct snd_soc_component *component)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
int enable = WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ; int enable = WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ;
if (!wm_hubs_dac_hp_direct(codec)) if (!wm_hubs_dac_hp_direct(component))
enable = false; enable = false;
if (hubs->check_class_w_digital && !hubs->check_class_w_digital(codec)) if (hubs->check_class_w_digital && !hubs->check_class_w_digital(component))
enable = false; enable = false;
dev_vdbg(codec->dev, "Class W %s\n", enable ? "enabled" : "disabled"); dev_vdbg(component->dev, "Class W %s\n", enable ? "enabled" : "disabled");
snd_soc_update_bits(codec, WM8993_CLASS_W_0, snd_soc_component_update_bits(component, WM8993_CLASS_W_0,
WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ, enable); WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ, enable);
snd_soc_write(codec, WM8993_LEFT_OUTPUT_VOLUME, snd_soc_component_write(component, WM8993_LEFT_OUTPUT_VOLUME,
snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME)); snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME));
snd_soc_write(codec, WM8993_RIGHT_OUTPUT_VOLUME, snd_soc_component_write(component, WM8993_RIGHT_OUTPUT_VOLUME,
snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME)); snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME));
} }
EXPORT_SYMBOL_GPL(wm_hubs_update_class_w); EXPORT_SYMBOL_GPL(wm_hubs_update_class_w);
...@@ -697,12 +697,12 @@ EXPORT_SYMBOL_GPL(wm_hubs_update_class_w); ...@@ -697,12 +697,12 @@ EXPORT_SYMBOL_GPL(wm_hubs_update_class_w);
static int class_w_put_volsw(struct snd_kcontrol *kcontrol, static int class_w_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
int ret; int ret;
ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
wm_hubs_update_class_w(codec); wm_hubs_update_class_w(component);
return ret; return ret;
} }
...@@ -717,12 +717,12 @@ static int class_w_put_volsw(struct snd_kcontrol *kcontrol, ...@@ -717,12 +717,12 @@ static int class_w_put_volsw(struct snd_kcontrol *kcontrol,
static int class_w_put_double(struct snd_kcontrol *kcontrol, static int class_w_put_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
int ret; int ret;
ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol);
wm_hubs_update_class_w(codec); wm_hubs_update_class_w(component);
return ret; return ret;
} }
...@@ -1113,40 +1113,40 @@ static const struct snd_soc_dapm_route lineout2_se_routes[] = { ...@@ -1113,40 +1113,40 @@ static const struct snd_soc_dapm_route lineout2_se_routes[] = {
{ "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" },
}; };
int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) int wm_hubs_add_analogue_controls(struct snd_soc_component *component)
{ {
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
/* Latch volume update bits & default ZC on */ /* Latch volume update bits & default ZC on */
snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, snd_soc_component_update_bits(component, WM8993_LEFT_LINE_INPUT_1_2_VOLUME,
WM8993_IN1_VU, WM8993_IN1_VU); WM8993_IN1_VU, WM8993_IN1_VU);
snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME,
WM8993_IN1_VU, WM8993_IN1_VU); WM8993_IN1_VU, WM8993_IN1_VU);
snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, snd_soc_component_update_bits(component, WM8993_LEFT_LINE_INPUT_3_4_VOLUME,
WM8993_IN2_VU, WM8993_IN2_VU); WM8993_IN2_VU, WM8993_IN2_VU);
snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME,
WM8993_IN2_VU, WM8993_IN2_VU); WM8993_IN2_VU, WM8993_IN2_VU);
snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_LEFT, snd_soc_component_update_bits(component, WM8993_SPEAKER_VOLUME_LEFT,
WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); WM8993_SPKOUT_VU, WM8993_SPKOUT_VU);
snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, snd_soc_component_update_bits(component, WM8993_SPEAKER_VOLUME_RIGHT,
WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); WM8993_SPKOUT_VU, WM8993_SPKOUT_VU);
snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, snd_soc_component_update_bits(component, WM8993_LEFT_OUTPUT_VOLUME,
WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC, WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC,
WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC); WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC);
snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_OUTPUT_VOLUME,
WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC,
WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC);
snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, snd_soc_component_update_bits(component, WM8993_LEFT_OPGA_VOLUME,
WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU, WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU,
WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU); WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU);
snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, snd_soc_component_update_bits(component, WM8993_RIGHT_OPGA_VOLUME,
WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU,
WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU);
snd_soc_add_codec_controls(codec, analogue_snd_controls, snd_soc_add_component_controls(component, analogue_snd_controls,
ARRAY_SIZE(analogue_snd_controls)); ARRAY_SIZE(analogue_snd_controls));
snd_soc_dapm_new_controls(dapm, analogue_dapm_widgets, snd_soc_dapm_new_controls(dapm, analogue_dapm_widgets,
...@@ -1155,13 +1155,13 @@ int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) ...@@ -1155,13 +1155,13 @@ int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec)
} }
EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls);
int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, int wm_hubs_add_analogue_routes(struct snd_soc_component *component,
int lineout1_diff, int lineout2_diff) int lineout1_diff, int lineout2_diff)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
hubs->codec = codec; hubs->component = component;
INIT_LIST_HEAD(&hubs->dcs_cache); INIT_LIST_HEAD(&hubs->dcs_cache);
init_completion(&hubs->dcs_done); init_completion(&hubs->dcs_done);
...@@ -1191,14 +1191,14 @@ int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, ...@@ -1191,14 +1191,14 @@ int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec,
} }
EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes); EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes);
int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, int wm_hubs_handle_analogue_pdata(struct snd_soc_component *component,
int lineout1_diff, int lineout2_diff, int lineout1_diff, int lineout2_diff,
int lineout1fb, int lineout2fb, int lineout1fb, int lineout2fb,
int jd_scthr, int jd_thr, int jd_scthr, int jd_thr,
int micbias1_delay, int micbias2_delay, int micbias1_delay, int micbias2_delay,
int micbias1_lvl, int micbias2_lvl) int micbias1_lvl, int micbias2_lvl)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
hubs->lineout1_se = !lineout1_diff; hubs->lineout1_se = !lineout1_diff;
hubs->lineout2_se = !lineout2_diff; hubs->lineout2_se = !lineout2_diff;
...@@ -1206,28 +1206,28 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, ...@@ -1206,28 +1206,28 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
hubs->micb2_delay = micbias2_delay; hubs->micb2_delay = micbias2_delay;
if (!lineout1_diff) if (!lineout1_diff)
snd_soc_update_bits(codec, WM8993_LINE_MIXER1, snd_soc_component_update_bits(component, WM8993_LINE_MIXER1,
WM8993_LINEOUT1_MODE, WM8993_LINEOUT1_MODE,
WM8993_LINEOUT1_MODE); WM8993_LINEOUT1_MODE);
if (!lineout2_diff) if (!lineout2_diff)
snd_soc_update_bits(codec, WM8993_LINE_MIXER2, snd_soc_component_update_bits(component, WM8993_LINE_MIXER2,
WM8993_LINEOUT2_MODE, WM8993_LINEOUT2_MODE,
WM8993_LINEOUT2_MODE); WM8993_LINEOUT2_MODE);
if (!lineout1_diff && !lineout2_diff) if (!lineout1_diff && !lineout2_diff)
snd_soc_update_bits(codec, WM8993_ANTIPOP1, snd_soc_component_update_bits(component, WM8993_ANTIPOP1,
WM8993_LINEOUT_VMID_BUF_ENA, WM8993_LINEOUT_VMID_BUF_ENA,
WM8993_LINEOUT_VMID_BUF_ENA); WM8993_LINEOUT_VMID_BUF_ENA);
if (lineout1fb) if (lineout1fb)
snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, snd_soc_component_update_bits(component, WM8993_ADDITIONAL_CONTROL,
WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB); WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB);
if (lineout2fb) if (lineout2fb)
snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, snd_soc_component_update_bits(component, WM8993_ADDITIONAL_CONTROL,
WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB); WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB);
snd_soc_update_bits(codec, WM8993_MICBIAS, snd_soc_component_update_bits(component, WM8993_MICBIAS,
WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK | WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK |
WM8993_MICB1_LVL | WM8993_MICB2_LVL, WM8993_MICB1_LVL | WM8993_MICB2_LVL,
jd_scthr << WM8993_JD_SCTHR_SHIFT | jd_scthr << WM8993_JD_SCTHR_SHIFT |
...@@ -1239,9 +1239,9 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, ...@@ -1239,9 +1239,9 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec,
} }
EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata); EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata);
void wm_hubs_vmid_ena(struct snd_soc_codec *codec) void wm_hubs_vmid_ena(struct snd_soc_component *component)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
int val = 0; int val = 0;
if (hubs->lineout1_se) if (hubs->lineout1_se)
...@@ -1251,20 +1251,20 @@ void wm_hubs_vmid_ena(struct snd_soc_codec *codec) ...@@ -1251,20 +1251,20 @@ void wm_hubs_vmid_ena(struct snd_soc_codec *codec)
val |= WM8993_LINEOUT2N_ENA | WM8993_LINEOUT2P_ENA; val |= WM8993_LINEOUT2N_ENA | WM8993_LINEOUT2P_ENA;
/* Enable the line outputs while we power up */ /* Enable the line outputs while we power up */
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, val, val); snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_3, val, val);
} }
EXPORT_SYMBOL_GPL(wm_hubs_vmid_ena); EXPORT_SYMBOL_GPL(wm_hubs_vmid_ena);
void wm_hubs_set_bias_level(struct snd_soc_codec *codec, void wm_hubs_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level) enum snd_soc_bias_level level)
{ {
struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component);
int mask, val; int mask, val;
switch (level) { switch (level) {
case SND_SOC_BIAS_STANDBY: case SND_SOC_BIAS_STANDBY:
/* Clamp the inputs to VMID while we ramp to charge caps */ /* Clamp the inputs to VMID while we ramp to charge caps */
snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, snd_soc_component_update_bits(component, WM8993_INPUTS_CLAMP_REG,
WM8993_INPUTS_CLAMP, WM8993_INPUTS_CLAMP); WM8993_INPUTS_CLAMP, WM8993_INPUTS_CLAMP);
break; break;
...@@ -1291,11 +1291,11 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec, ...@@ -1291,11 +1291,11 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec,
if (hubs->lineout2_se && hubs->lineout2p_ena) if (hubs->lineout2_se && hubs->lineout2p_ena)
val |= WM8993_LINEOUT2P_ENA; val |= WM8993_LINEOUT2P_ENA;
snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_3,
mask, val); mask, val);
/* Remove the input clamps */ /* Remove the input clamps */
snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, snd_soc_component_update_bits(component, WM8993_INPUTS_CLAMP_REG,
WM8993_INPUTS_CLAMP, 0); WM8993_INPUTS_CLAMP, 0);
break; break;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <sound/control.h> #include <sound/control.h>
struct snd_soc_codec; struct snd_soc_component;
extern const unsigned int wm_hubs_spkmix_tlv[]; extern const unsigned int wm_hubs_spkmix_tlv[];
...@@ -34,7 +34,7 @@ struct wm_hubs_data { ...@@ -34,7 +34,7 @@ struct wm_hubs_data {
bool no_cache_dac_hp_direct; bool no_cache_dac_hp_direct;
struct list_head dcs_cache; struct list_head dcs_cache;
bool (*check_class_w_digital)(struct snd_soc_codec *); bool (*check_class_w_digital)(struct snd_soc_component *);
int micb1_delay; int micb1_delay;
int micb2_delay; int micb2_delay;
...@@ -50,12 +50,12 @@ struct wm_hubs_data { ...@@ -50,12 +50,12 @@ struct wm_hubs_data {
bool dcs_done_irq; bool dcs_done_irq;
struct completion dcs_done; struct completion dcs_done;
struct snd_soc_codec *codec; struct snd_soc_component *component;
}; };
extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *); extern int wm_hubs_add_analogue_controls(struct snd_soc_component *);
extern int wm_hubs_add_analogue_routes(struct snd_soc_codec *, int, int); extern int wm_hubs_add_analogue_routes(struct snd_soc_component *, int, int);
extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *, extern int wm_hubs_handle_analogue_pdata(struct snd_soc_component *,
int lineout1_diff, int lineout2_diff, int lineout1_diff, int lineout2_diff,
int lineout1fb, int lineout2fb, int lineout1fb, int lineout2fb,
int jd_scthr, int jd_thr, int jd_scthr, int jd_thr,
...@@ -63,10 +63,10 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *, ...@@ -63,10 +63,10 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *,
int micbias1_lvl, int micbias2_lvl); int micbias1_lvl, int micbias2_lvl);
extern irqreturn_t wm_hubs_dcs_done(int irq, void *data); extern irqreturn_t wm_hubs_dcs_done(int irq, void *data);
extern void wm_hubs_vmid_ena(struct snd_soc_codec *codec); extern void wm_hubs_vmid_ena(struct snd_soc_component *component);
extern void wm_hubs_set_bias_level(struct snd_soc_codec *codec, extern void wm_hubs_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level); enum snd_soc_bias_level level);
extern void wm_hubs_update_class_w(struct snd_soc_codec *codec); extern void wm_hubs_update_class_w(struct snd_soc_component *component);
extern const struct snd_kcontrol_new wm_hubs_hpl_mux; extern const struct snd_kcontrol_new wm_hubs_hpl_mux;
extern const struct snd_kcontrol_new wm_hubs_hpr_mux; extern const struct snd_kcontrol_new wm_hubs_hpr_mux;
......
...@@ -258,13 +258,13 @@ static struct snd_soc_jack littlemill_headset; ...@@ -258,13 +258,13 @@ static struct snd_soc_jack littlemill_headset;
static int littlemill_late_probe(struct snd_soc_card *card) static int littlemill_late_probe(struct snd_soc_card *card)
{ {
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_codec *codec; struct snd_soc_component *component;
struct snd_soc_dai *aif1_dai; struct snd_soc_dai *aif1_dai;
struct snd_soc_dai *aif2_dai; struct snd_soc_dai *aif2_dai;
int ret; int ret;
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
codec = rtd->codec; component = rtd->codec_dai->component;
aif1_dai = rtd->codec_dai; aif1_dai = rtd->codec_dai;
rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name);
...@@ -290,10 +290,10 @@ static int littlemill_late_probe(struct snd_soc_card *card) ...@@ -290,10 +290,10 @@ static int littlemill_late_probe(struct snd_soc_card *card)
return ret; return ret;
/* This will check device compatibility itself */ /* This will check device compatibility itself */
wm8958_mic_detect(codec, &littlemill_headset, NULL, NULL, NULL, NULL); wm8958_mic_detect(component, &littlemill_headset, NULL, NULL, NULL, NULL);
/* As will this */ /* As will this */
wm8994_mic_detect(codec, &littlemill_headset, 1); wm8994_mic_detect(component, &littlemill_headset, 1);
return 0; return 0;
} }
......
...@@ -124,14 +124,14 @@ static int speyside_get_micbias(struct snd_soc_dapm_widget *source, ...@@ -124,14 +124,14 @@ static int speyside_get_micbias(struct snd_soc_dapm_widget *source,
return 0; return 0;
} }
static void speyside_set_polarity(struct snd_soc_codec *codec, static void speyside_set_polarity(struct snd_soc_component *component,
int polarity) int polarity)
{ {
speyside_jack_polarity = !polarity; speyside_jack_polarity = !polarity;
gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
/* Re-run DAPM to make sure we're using the correct mic bias */ /* Re-run DAPM to make sure we're using the correct mic bias */
snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); snd_soc_dapm_sync(snd_soc_component_get_dapm(component));
} }
static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd)
...@@ -149,7 +149,7 @@ static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) ...@@ -149,7 +149,7 @@ static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd)
static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_dai *dai = rtd->codec_dai; struct snd_soc_dai *dai = rtd->codec_dai;
struct snd_soc_codec *codec = rtd->codec; struct snd_soc_component *component = dai->component;
int ret; int ret;
ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0); ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0);
...@@ -168,7 +168,7 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) ...@@ -168,7 +168,7 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
if (ret) if (ret)
return ret; return ret;
wm8996_detect(codec, &speyside_headset, speyside_set_polarity); wm8996_detect(component, &speyside_headset, speyside_set_polarity);
return 0; return 0;
} }
...@@ -232,10 +232,8 @@ static struct snd_soc_dai_link speyside_dai[] = { ...@@ -232,10 +232,8 @@ static struct snd_soc_dai_link speyside_dai[] = {
static int speyside_wm9081_init(struct snd_soc_component *component) static int speyside_wm9081_init(struct snd_soc_component *component)
{ {
struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
/* At any time the WM9081 is active it will have this clock */ /* At any time the WM9081 is active it will have this clock */
return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0, return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0,
MCLK_AUDIO_RATE, 0); MCLK_AUDIO_RATE, 0);
} }
......
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