diff options
-rw-r--r-- | sound/soc/bcm/cygnus-ssp.c | 2 | ||||
-rw-r--r-- | sound/soc/codecs/cx20442.c | 89 | ||||
-rw-r--r-- | sound/soc/codecs/da7210.c | 181 | ||||
-rw-r--r-- | sound/soc/codecs/da7213.c | 328 | ||||
-rw-r--r-- | sound/soc/codecs/da7218.c | 498 | ||||
-rw-r--r-- | sound/soc/codecs/da7218.h | 2 | ||||
-rw-r--r-- | sound/soc/omap/ams-delta.c | 20 |
7 files changed, 543 insertions, 577 deletions
diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index abafadc0b534..b733f1446353 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c | |||
@@ -1281,7 +1281,7 @@ static int cygnus_ssp_probe(struct platform_device *pdev) | |||
1281 | { | 1281 | { |
1282 | struct device *dev = &pdev->dev; | 1282 | struct device *dev = &pdev->dev; |
1283 | struct device_node *child_node; | 1283 | struct device_node *child_node; |
1284 | struct resource *res = pdev->resource; | 1284 | struct resource *res; |
1285 | struct cygnus_audio *cygaud; | 1285 | struct cygnus_audio *cygaud; |
1286 | int err = -EINVAL; | 1286 | int err = -EINVAL; |
1287 | int node_count; | 1287 | int node_count; |
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index 95bb10ba80dc..07dd33b09596 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c | |||
@@ -89,10 +89,10 @@ static const struct snd_soc_dapm_route cx20442_audio_map[] = { | |||
89 | {"ADC", NULL, "Input Mixer"}, | 89 | {"ADC", NULL, "Input Mixer"}, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec, | 92 | static unsigned int cx20442_read_reg_cache(struct snd_soc_component *component, |
93 | unsigned int reg) | 93 | unsigned int reg) |
94 | { | 94 | { |
95 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); | 95 | struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); |
96 | 96 | ||
97 | if (reg >= 1) | 97 | if (reg >= 1) |
98 | return -EINVAL; | 98 | return -EINVAL; |
@@ -153,10 +153,10 @@ static int cx20442_pm_to_v253_vsp(u8 value) | |||
153 | return (value & (1 << CX20442_AGC)) ? -EINVAL : 0; | 153 | return (value & (1 << CX20442_AGC)) ? -EINVAL : 0; |
154 | } | 154 | } |
155 | 155 | ||
156 | static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, | 156 | static int cx20442_write(struct snd_soc_component *component, unsigned int reg, |
157 | unsigned int value) | 157 | unsigned int value) |
158 | { | 158 | { |
159 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); | 159 | struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); |
160 | int vls, vsp, old, len; | 160 | int vls, vsp, old, len; |
161 | char buf[18]; | 161 | char buf[18]; |
162 | 162 | ||
@@ -193,7 +193,7 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, | |||
193 | if (unlikely(len > (ARRAY_SIZE(buf) - 1))) | 193 | if (unlikely(len > (ARRAY_SIZE(buf) - 1))) |
194 | return -ENOMEM; | 194 | return -ENOMEM; |
195 | 195 | ||
196 | dev_dbg(codec->dev, "%s: %s\n", __func__, buf); | 196 | dev_dbg(component->dev, "%s: %s\n", __func__, buf); |
197 | if (cx20442->tty->ops->write(cx20442->tty, buf, len) != len) | 197 | if (cx20442->tty->ops->write(cx20442->tty, buf, len) != len) |
198 | return -EIO; | 198 | return -EIO; |
199 | 199 | ||
@@ -240,19 +240,19 @@ err: | |||
240 | /* Line discipline .close() */ | 240 | /* Line discipline .close() */ |
241 | static void v253_close(struct tty_struct *tty) | 241 | static void v253_close(struct tty_struct *tty) |
242 | { | 242 | { |
243 | struct snd_soc_codec *codec = tty->disc_data; | 243 | struct snd_soc_component *component = tty->disc_data; |
244 | struct cx20442_priv *cx20442; | 244 | struct cx20442_priv *cx20442; |
245 | 245 | ||
246 | tty->disc_data = NULL; | 246 | tty->disc_data = NULL; |
247 | 247 | ||
248 | if (!codec) | 248 | if (!component) |
249 | return; | 249 | return; |
250 | 250 | ||
251 | cx20442 = snd_soc_codec_get_drvdata(codec); | 251 | cx20442 = snd_soc_component_get_drvdata(component); |
252 | 252 | ||
253 | /* Prevent the codec driver from further accessing the modem */ | 253 | /* Prevent the codec driver from further accessing the modem */ |
254 | cx20442->tty = NULL; | 254 | cx20442->tty = NULL; |
255 | codec->component.card->pop_time = 0; | 255 | component->card->pop_time = 0; |
256 | } | 256 | } |
257 | 257 | ||
258 | /* Line discipline .hangup() */ | 258 | /* Line discipline .hangup() */ |
@@ -266,20 +266,20 @@ static int v253_hangup(struct tty_struct *tty) | |||
266 | static void v253_receive(struct tty_struct *tty, | 266 | static void v253_receive(struct tty_struct *tty, |
267 | const unsigned char *cp, char *fp, int count) | 267 | const unsigned char *cp, char *fp, int count) |
268 | { | 268 | { |
269 | struct snd_soc_codec *codec = tty->disc_data; | 269 | struct snd_soc_component *component = tty->disc_data; |
270 | struct cx20442_priv *cx20442; | 270 | struct cx20442_priv *cx20442; |
271 | 271 | ||
272 | if (!codec) | 272 | if (!component) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | cx20442 = snd_soc_codec_get_drvdata(codec); | 275 | cx20442 = snd_soc_component_get_drvdata(component); |
276 | 276 | ||
277 | if (!cx20442->tty) { | 277 | if (!cx20442->tty) { |
278 | /* First modem response, complete setup procedure */ | 278 | /* First modem response, complete setup procedure */ |
279 | 279 | ||
280 | /* Set up codec driver access to modem controls */ | 280 | /* Set up codec driver access to modem controls */ |
281 | cx20442->tty = tty; | 281 | cx20442->tty = tty; |
282 | codec->component.card->pop_time = 1; | 282 | component->card->pop_time = 1; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
@@ -323,15 +323,15 @@ static struct snd_soc_dai_driver cx20442_dai = { | |||
323 | }, | 323 | }, |
324 | }; | 324 | }; |
325 | 325 | ||
326 | static int cx20442_set_bias_level(struct snd_soc_codec *codec, | 326 | static int cx20442_set_bias_level(struct snd_soc_component *component, |
327 | enum snd_soc_bias_level level) | 327 | enum snd_soc_bias_level level) |
328 | { | 328 | { |
329 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); | 329 | struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); |
330 | int err = 0; | 330 | int err = 0; |
331 | 331 | ||
332 | switch (level) { | 332 | switch (level) { |
333 | case SND_SOC_BIAS_PREPARE: | 333 | case SND_SOC_BIAS_PREPARE: |
334 | if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_STANDBY) | 334 | if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_STANDBY) |
335 | break; | 335 | break; |
336 | if (IS_ERR(cx20442->por)) | 336 | if (IS_ERR(cx20442->por)) |
337 | err = PTR_ERR(cx20442->por); | 337 | err = PTR_ERR(cx20442->por); |
@@ -339,7 +339,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, | |||
339 | err = regulator_enable(cx20442->por); | 339 | err = regulator_enable(cx20442->por); |
340 | break; | 340 | break; |
341 | case SND_SOC_BIAS_STANDBY: | 341 | case SND_SOC_BIAS_STANDBY: |
342 | if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_PREPARE) | 342 | if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_PREPARE) |
343 | break; | 343 | break; |
344 | if (IS_ERR(cx20442->por)) | 344 | if (IS_ERR(cx20442->por)) |
345 | err = PTR_ERR(cx20442->por); | 345 | err = PTR_ERR(cx20442->por); |
@@ -353,7 +353,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, | |||
353 | return err; | 353 | return err; |
354 | } | 354 | } |
355 | 355 | ||
356 | static int cx20442_codec_probe(struct snd_soc_codec *codec) | 356 | static int cx20442_component_probe(struct snd_soc_component *component) |
357 | { | 357 | { |
358 | struct cx20442_priv *cx20442; | 358 | struct cx20442_priv *cx20442; |
359 | 359 | ||
@@ -361,21 +361,21 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec) | |||
361 | if (cx20442 == NULL) | 361 | if (cx20442 == NULL) |
362 | return -ENOMEM; | 362 | return -ENOMEM; |
363 | 363 | ||
364 | cx20442->por = regulator_get(codec->dev, "POR"); | 364 | cx20442->por = regulator_get(component->dev, "POR"); |
365 | if (IS_ERR(cx20442->por)) | 365 | if (IS_ERR(cx20442->por)) |
366 | dev_warn(codec->dev, "failed to get the regulator"); | 366 | dev_warn(component->dev, "failed to get the regulator"); |
367 | cx20442->tty = NULL; | 367 | cx20442->tty = NULL; |
368 | 368 | ||
369 | snd_soc_codec_set_drvdata(codec, cx20442); | 369 | snd_soc_component_set_drvdata(component, cx20442); |
370 | codec->component.card->pop_time = 0; | 370 | component->card->pop_time = 0; |
371 | 371 | ||
372 | return 0; | 372 | return 0; |
373 | } | 373 | } |
374 | 374 | ||
375 | /* power down chip */ | 375 | /* power down chip */ |
376 | static int cx20442_codec_remove(struct snd_soc_codec *codec) | 376 | static void cx20442_component_remove(struct snd_soc_component *component) |
377 | { | 377 | { |
378 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); | 378 | struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); |
379 | 379 | ||
380 | if (cx20442->tty) { | 380 | if (cx20442->tty) { |
381 | struct tty_struct *tty = cx20442->tty; | 381 | struct tty_struct *tty = cx20442->tty; |
@@ -387,36 +387,30 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec) | |||
387 | regulator_put(cx20442->por); | 387 | regulator_put(cx20442->por); |
388 | } | 388 | } |
389 | 389 | ||
390 | snd_soc_codec_set_drvdata(codec, NULL); | 390 | snd_soc_component_set_drvdata(component, NULL); |
391 | kfree(cx20442); | 391 | kfree(cx20442); |
392 | return 0; | ||
393 | } | 392 | } |
394 | 393 | ||
395 | static const struct snd_soc_codec_driver cx20442_codec_dev = { | 394 | static const struct snd_soc_component_driver cx20442_component_dev = { |
396 | .probe = cx20442_codec_probe, | 395 | .probe = cx20442_component_probe, |
397 | .remove = cx20442_codec_remove, | 396 | .remove = cx20442_component_remove, |
398 | .set_bias_level = cx20442_set_bias_level, | 397 | .set_bias_level = cx20442_set_bias_level, |
399 | .read = cx20442_read_reg_cache, | 398 | .read = cx20442_read_reg_cache, |
400 | .write = cx20442_write, | 399 | .write = cx20442_write, |
401 | 400 | .dapm_widgets = cx20442_dapm_widgets, | |
402 | .component_driver = { | 401 | .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), |
403 | .dapm_widgets = cx20442_dapm_widgets, | 402 | .dapm_routes = cx20442_audio_map, |
404 | .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), | 403 | .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), |
405 | .dapm_routes = cx20442_audio_map, | 404 | .idle_bias_on = 1, |
406 | .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), | 405 | .use_pmdown_time = 1, |
407 | }, | 406 | .endianness = 1, |
407 | .non_legacy_dai_naming = 1, | ||
408 | }; | 408 | }; |
409 | 409 | ||
410 | static int cx20442_platform_probe(struct platform_device *pdev) | 410 | static int cx20442_platform_probe(struct platform_device *pdev) |
411 | { | 411 | { |
412 | return snd_soc_register_codec(&pdev->dev, | 412 | return devm_snd_soc_register_component(&pdev->dev, |
413 | &cx20442_codec_dev, &cx20442_dai, 1); | 413 | &cx20442_component_dev, &cx20442_dai, 1); |
414 | } | ||
415 | |||
416 | static int cx20442_platform_remove(struct platform_device *pdev) | ||
417 | { | ||
418 | snd_soc_unregister_codec(&pdev->dev); | ||
419 | return 0; | ||
420 | } | 414 | } |
421 | 415 | ||
422 | static struct platform_driver cx20442_platform_driver = { | 416 | static struct platform_driver cx20442_platform_driver = { |
@@ -424,7 +418,6 @@ static struct platform_driver cx20442_platform_driver = { | |||
424 | .name = "cx20442-codec", | 418 | .name = "cx20442-codec", |
425 | }, | 419 | }, |
426 | .probe = cx20442_platform_probe, | 420 | .probe = cx20442_platform_probe, |
427 | .remove = cx20442_platform_remove, | ||
428 | }; | 421 | }; |
429 | 422 | ||
430 | module_platform_driver(cx20442_platform_driver); | 423 | module_platform_driver(cx20442_platform_driver); |
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 1af443ccbc51..a664111b7184 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c | |||
@@ -331,12 +331,12 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, | |||
331 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | 331 | static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, |
332 | struct snd_ctl_elem_value *ucontrol) | 332 | struct snd_ctl_elem_value *ucontrol) |
333 | { | 333 | { |
334 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 334 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
335 | 335 | ||
336 | if (ucontrol->value.integer.value[0]) { | 336 | if (ucontrol->value.integer.value[0]) { |
337 | /* Check if noise suppression is enabled */ | 337 | /* Check if noise suppression is enabled */ |
338 | if (snd_soc_read(codec, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { | 338 | if (snd_soc_component_read32(component, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { |
339 | dev_dbg(codec->dev, | 339 | dev_dbg(component->dev, |
340 | "Disable noise suppression to enable ALC\n"); | 340 | "Disable noise suppression to enable ALC\n"); |
341 | return -EINVAL; | 341 | return -EINVAL; |
342 | } | 342 | } |
@@ -354,32 +354,32 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, | |||
354 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, | 354 | static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, |
355 | struct snd_ctl_elem_value *ucontrol) | 355 | struct snd_ctl_elem_value *ucontrol) |
356 | { | 356 | { |
357 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 357 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
358 | u8 val; | 358 | u8 val; |
359 | 359 | ||
360 | if (ucontrol->value.integer.value[0]) { | 360 | if (ucontrol->value.integer.value[0]) { |
361 | /* Check if ALC is enabled */ | 361 | /* Check if ALC is enabled */ |
362 | if (snd_soc_read(codec, DA7210_ADC) & DA7210_ADC_ALC_EN) | 362 | if (snd_soc_component_read32(component, DA7210_ADC) & DA7210_ADC_ALC_EN) |
363 | goto err; | 363 | goto err; |
364 | 364 | ||
365 | /* Check ZC for HP and AUX1 PGA */ | 365 | /* Check ZC for HP and AUX1 PGA */ |
366 | if ((snd_soc_read(codec, DA7210_ZERO_CROSS) & | 366 | if ((snd_soc_component_read32(component, DA7210_ZERO_CROSS) & |
367 | (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | | 367 | (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | |
368 | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | | 368 | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | |
369 | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) | 369 | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) |
370 | goto err; | 370 | goto err; |
371 | 371 | ||
372 | /* Check INPGA_L_VOL and INPGA_R_VOL */ | 372 | /* Check INPGA_L_VOL and INPGA_R_VOL */ |
373 | val = snd_soc_read(codec, DA7210_IN_GAIN); | 373 | val = snd_soc_component_read32(component, DA7210_IN_GAIN); |
374 | if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || | 374 | if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || |
375 | (((val & DA7210_INPGA_R_VOL) >> 4) < | 375 | (((val & DA7210_INPGA_R_VOL) >> 4) < |
376 | DA7210_INPGA_MIN_VOL_NS)) | 376 | DA7210_INPGA_MIN_VOL_NS)) |
377 | goto err; | 377 | goto err; |
378 | 378 | ||
379 | /* Check AUX1_L_VOL and AUX1_R_VOL */ | 379 | /* Check AUX1_L_VOL and AUX1_R_VOL */ |
380 | if (((snd_soc_read(codec, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < | 380 | if (((snd_soc_component_read32(component, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < |
381 | DA7210_AUX1_MIN_VOL_NS) || | 381 | DA7210_AUX1_MIN_VOL_NS) || |
382 | ((snd_soc_read(codec, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < | 382 | ((snd_soc_component_read32(component, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < |
383 | DA7210_AUX1_MIN_VOL_NS)) | 383 | DA7210_AUX1_MIN_VOL_NS)) |
384 | goto err; | 384 | goto err; |
385 | } | 385 | } |
@@ -760,19 +760,19 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
760 | struct snd_pcm_hw_params *params, | 760 | struct snd_pcm_hw_params *params, |
761 | struct snd_soc_dai *dai) | 761 | struct snd_soc_dai *dai) |
762 | { | 762 | { |
763 | struct snd_soc_codec *codec = dai->codec; | 763 | struct snd_soc_component *component = dai->component; |
764 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 764 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
765 | u32 dai_cfg1; | 765 | u32 dai_cfg1; |
766 | u32 fs, sysclk; | 766 | u32 fs, sysclk; |
767 | 767 | ||
768 | /* set DAI source to Left and Right ADC */ | 768 | /* set DAI source to Left and Right ADC */ |
769 | snd_soc_write(codec, DA7210_DAI_SRC_SEL, | 769 | snd_soc_component_write(component, DA7210_DAI_SRC_SEL, |
770 | DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); | 770 | DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); |
771 | 771 | ||
772 | /* Enable DAI */ | 772 | /* Enable DAI */ |
773 | snd_soc_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); | 773 | snd_soc_component_write(component, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); |
774 | 774 | ||
775 | dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1); | 775 | dai_cfg1 = 0xFC & snd_soc_component_read32(component, DA7210_DAI_CFG1); |
776 | 776 | ||
777 | switch (params_width(params)) { | 777 | switch (params_width(params)) { |
778 | case 16: | 778 | case 16: |
@@ -791,7 +791,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
791 | return -EINVAL; | 791 | return -EINVAL; |
792 | } | 792 | } |
793 | 793 | ||
794 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); | 794 | snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); |
795 | 795 | ||
796 | switch (params_rate(params)) { | 796 | switch (params_rate(params)) { |
797 | case 8000: | 797 | case 8000: |
@@ -839,17 +839,17 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
839 | } | 839 | } |
840 | 840 | ||
841 | /* Disable active mode */ | 841 | /* Disable active mode */ |
842 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); | 842 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); |
843 | 843 | ||
844 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); | 844 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_FS_MASK, fs); |
845 | 845 | ||
846 | if (da7210->mclk_rate && (da7210->mclk_rate != sysclk)) { | 846 | if (da7210->mclk_rate && (da7210->mclk_rate != sysclk)) { |
847 | /* PLL mode, disable PLL bypass */ | 847 | /* PLL mode, disable PLL bypass */ |
848 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); | 848 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); |
849 | 849 | ||
850 | if (!da7210->master) { | 850 | if (!da7210->master) { |
851 | /* PLL slave mode, also enable SRM */ | 851 | /* PLL slave mode, also enable SRM */ |
852 | snd_soc_update_bits(codec, DA7210_PLL, | 852 | snd_soc_component_update_bits(component, DA7210_PLL, |
853 | (DA7210_MCLK_SRM_EN | | 853 | (DA7210_MCLK_SRM_EN | |
854 | DA7210_MCLK_DET_EN), | 854 | DA7210_MCLK_DET_EN), |
855 | (DA7210_MCLK_SRM_EN | | 855 | (DA7210_MCLK_SRM_EN | |
@@ -857,13 +857,13 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
857 | } | 857 | } |
858 | } else { | 858 | } else { |
859 | /* PLL bypass mode, enable PLL bypass and Auto Detection */ | 859 | /* PLL bypass mode, enable PLL bypass and Auto Detection */ |
860 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_MCLK_DET_EN, | 860 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_MCLK_DET_EN, |
861 | DA7210_MCLK_DET_EN); | 861 | DA7210_MCLK_DET_EN); |
862 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, | 862 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, |
863 | DA7210_PLL_BYP); | 863 | DA7210_PLL_BYP); |
864 | } | 864 | } |
865 | /* Enable active mode */ | 865 | /* Enable active mode */ |
866 | snd_soc_update_bits(codec, DA7210_STARTUP1, | 866 | snd_soc_component_update_bits(component, DA7210_STARTUP1, |
867 | DA7210_SC_MST_EN, DA7210_SC_MST_EN); | 867 | DA7210_SC_MST_EN, DA7210_SC_MST_EN); |
868 | 868 | ||
869 | return 0; | 869 | return 0; |
@@ -874,16 +874,16 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, | |||
874 | */ | 874 | */ |
875 | static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) | 875 | static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) |
876 | { | 876 | { |
877 | struct snd_soc_codec *codec = codec_dai->codec; | 877 | struct snd_soc_component *component = codec_dai->component; |
878 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 878 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
879 | u32 dai_cfg1; | 879 | u32 dai_cfg1; |
880 | u32 dai_cfg3; | 880 | u32 dai_cfg3; |
881 | 881 | ||
882 | dai_cfg1 = 0x7f & snd_soc_read(codec, DA7210_DAI_CFG1); | 882 | dai_cfg1 = 0x7f & snd_soc_component_read32(component, DA7210_DAI_CFG1); |
883 | dai_cfg3 = 0xfc & snd_soc_read(codec, DA7210_DAI_CFG3); | 883 | dai_cfg3 = 0xfc & snd_soc_component_read32(component, DA7210_DAI_CFG3); |
884 | 884 | ||
885 | if ((snd_soc_read(codec, DA7210_PLL) & DA7210_PLL_EN) && | 885 | if ((snd_soc_component_read32(component, DA7210_PLL) & DA7210_PLL_EN) && |
886 | (!(snd_soc_read(codec, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) | 886 | (!(snd_soc_component_read32(component, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) |
887 | return -EINVAL; | 887 | return -EINVAL; |
888 | 888 | ||
889 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 889 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -923,21 +923,21 @@ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) | |||
923 | */ | 923 | */ |
924 | dai_cfg1 |= DA7210_DAI_FLEN_64BIT; | 924 | dai_cfg1 |= DA7210_DAI_FLEN_64BIT; |
925 | 925 | ||
926 | snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); | 926 | snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); |
927 | snd_soc_write(codec, DA7210_DAI_CFG3, dai_cfg3); | 927 | snd_soc_component_write(component, DA7210_DAI_CFG3, dai_cfg3); |
928 | 928 | ||
929 | return 0; | 929 | return 0; |
930 | } | 930 | } |
931 | 931 | ||
932 | static int da7210_mute(struct snd_soc_dai *dai, int mute) | 932 | static int da7210_mute(struct snd_soc_dai *dai, int mute) |
933 | { | 933 | { |
934 | struct snd_soc_codec *codec = dai->codec; | 934 | struct snd_soc_component *component = dai->component; |
935 | u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB; | 935 | u8 mute_reg = snd_soc_component_read32(component, DA7210_DAC_HPF) & 0xFB; |
936 | 936 | ||
937 | if (mute) | 937 | if (mute) |
938 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4); | 938 | snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg | 0x4); |
939 | else | 939 | else |
940 | snd_soc_write(codec, DA7210_DAC_HPF, mute_reg); | 940 | snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg); |
941 | return 0; | 941 | return 0; |
942 | } | 942 | } |
943 | 943 | ||
@@ -947,8 +947,8 @@ static int da7210_mute(struct snd_soc_dai *dai, int mute) | |||
947 | static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 947 | static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
948 | int clk_id, unsigned int freq, int dir) | 948 | int clk_id, unsigned int freq, int dir) |
949 | { | 949 | { |
950 | struct snd_soc_codec *codec = codec_dai->codec; | 950 | struct snd_soc_component *component = codec_dai->component; |
951 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 951 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
952 | 952 | ||
953 | switch (clk_id) { | 953 | switch (clk_id) { |
954 | case DA7210_CLKSRC_MCLK: | 954 | case DA7210_CLKSRC_MCLK: |
@@ -988,8 +988,8 @@ static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
988 | static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | 988 | static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, |
989 | int source, unsigned int fref, unsigned int fout) | 989 | int source, unsigned int fref, unsigned int fout) |
990 | { | 990 | { |
991 | struct snd_soc_codec *codec = codec_dai->codec; | 991 | struct snd_soc_component *component = codec_dai->component; |
992 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 992 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
993 | 993 | ||
994 | u8 pll_div1, pll_div2, pll_div3, cnt; | 994 | u8 pll_div1, pll_div2, pll_div3, cnt; |
995 | 995 | ||
@@ -1014,18 +1014,18 @@ static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1014 | goto err; | 1014 | goto err; |
1015 | 1015 | ||
1016 | /* Disable active mode */ | 1016 | /* Disable active mode */ |
1017 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); | 1017 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); |
1018 | /* Write PLL dividers */ | 1018 | /* Write PLL dividers */ |
1019 | snd_soc_write(codec, DA7210_PLL_DIV1, pll_div1); | 1019 | snd_soc_component_write(component, DA7210_PLL_DIV1, pll_div1); |
1020 | snd_soc_write(codec, DA7210_PLL_DIV2, pll_div2); | 1020 | snd_soc_component_write(component, DA7210_PLL_DIV2, pll_div2); |
1021 | snd_soc_update_bits(codec, DA7210_PLL_DIV3, | 1021 | snd_soc_component_update_bits(component, DA7210_PLL_DIV3, |
1022 | DA7210_PLL_DIV_L_MASK, pll_div3); | 1022 | DA7210_PLL_DIV_L_MASK, pll_div3); |
1023 | 1023 | ||
1024 | /* Enable PLL */ | 1024 | /* Enable PLL */ |
1025 | snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); | 1025 | snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); |
1026 | 1026 | ||
1027 | /* Enable active mode */ | 1027 | /* Enable active mode */ |
1028 | snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, | 1028 | snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, |
1029 | DA7210_SC_MST_EN); | 1029 | DA7210_SC_MST_EN); |
1030 | return 0; | 1030 | return 0; |
1031 | err: | 1031 | err: |
@@ -1064,53 +1064,53 @@ static struct snd_soc_dai_driver da7210_dai = { | |||
1064 | .symmetric_rates = 1, | 1064 | .symmetric_rates = 1, |
1065 | }; | 1065 | }; |
1066 | 1066 | ||
1067 | static int da7210_probe(struct snd_soc_codec *codec) | 1067 | static int da7210_probe(struct snd_soc_component *component) |
1068 | { | 1068 | { |
1069 | struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); | 1069 | struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); |
1070 | 1070 | ||
1071 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); | 1071 | dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
1072 | 1072 | ||
1073 | da7210->mclk_rate = 0; /* This will be set from set_sysclk() */ | 1073 | da7210->mclk_rate = 0; /* This will be set from set_sysclk() */ |
1074 | da7210->master = 0; /* This will be set from set_fmt() */ | 1074 | da7210->master = 0; /* This will be set from set_fmt() */ |
1075 | 1075 | ||
1076 | /* Enable internal regulator & bias current */ | 1076 | /* Enable internal regulator & bias current */ |
1077 | snd_soc_write(codec, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); | 1077 | snd_soc_component_write(component, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); |
1078 | 1078 | ||
1079 | /* | 1079 | /* |
1080 | * ADC settings | 1080 | * ADC settings |
1081 | */ | 1081 | */ |
1082 | 1082 | ||
1083 | /* Enable Left & Right MIC PGA and Mic Bias */ | 1083 | /* Enable Left & Right MIC PGA and Mic Bias */ |
1084 | snd_soc_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); | 1084 | snd_soc_component_write(component, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); |
1085 | snd_soc_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN); | 1085 | snd_soc_component_write(component, DA7210_MIC_R, DA7210_MIC_R_EN); |
1086 | 1086 | ||
1087 | /* Enable Left and Right input PGA */ | 1087 | /* Enable Left and Right input PGA */ |
1088 | snd_soc_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN); | 1088 | snd_soc_component_write(component, DA7210_INMIX_L, DA7210_IN_L_EN); |
1089 | snd_soc_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN); | 1089 | snd_soc_component_write(component, DA7210_INMIX_R, DA7210_IN_R_EN); |
1090 | 1090 | ||
1091 | /* Enable Left and Right ADC */ | 1091 | /* Enable Left and Right ADC */ |
1092 | snd_soc_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); | 1092 | snd_soc_component_write(component, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); |
1093 | 1093 | ||
1094 | /* | 1094 | /* |
1095 | * DAC settings | 1095 | * DAC settings |
1096 | */ | 1096 | */ |
1097 | 1097 | ||
1098 | /* Enable Left and Right DAC */ | 1098 | /* Enable Left and Right DAC */ |
1099 | snd_soc_write(codec, DA7210_DAC_SEL, | 1099 | snd_soc_component_write(component, DA7210_DAC_SEL, |
1100 | DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | | 1100 | DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | |
1101 | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); | 1101 | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); |
1102 | 1102 | ||
1103 | /* Enable Left and Right out PGA */ | 1103 | /* Enable Left and Right out PGA */ |
1104 | snd_soc_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN); | 1104 | snd_soc_component_write(component, DA7210_OUTMIX_L, DA7210_OUT_L_EN); |
1105 | snd_soc_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN); | 1105 | snd_soc_component_write(component, DA7210_OUTMIX_R, DA7210_OUT_R_EN); |
1106 | 1106 | ||
1107 | /* Enable Left and Right HeadPhone PGA */ | 1107 | /* Enable Left and Right HeadPhone PGA */ |
1108 | snd_soc_write(codec, DA7210_HP_CFG, | 1108 | snd_soc_component_write(component, DA7210_HP_CFG, |
1109 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | | 1109 | DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | |
1110 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); | 1110 | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); |
1111 | 1111 | ||
1112 | /* Enable ramp mode for DAC gain update */ | 1112 | /* Enable ramp mode for DAC gain update */ |
1113 | snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN); | 1113 | snd_soc_component_write(component, DA7210_SOFTMUTE, DA7210_RAMP_EN); |
1114 | 1114 | ||
1115 | /* | 1115 | /* |
1116 | * For DA7210 codec, there are two ways to enable/disable analog IOs | 1116 | * For DA7210 codec, there are two ways to enable/disable analog IOs |
@@ -1138,43 +1138,44 @@ static int da7210_probe(struct snd_soc_codec *codec) | |||
1138 | */ | 1138 | */ |
1139 | 1139 | ||
1140 | /* Enable Line out amplifiers */ | 1140 | /* Enable Line out amplifiers */ |
1141 | snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN); | 1141 | snd_soc_component_write(component, DA7210_OUT1_L, DA7210_OUT1_L_EN); |
1142 | snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN); | 1142 | snd_soc_component_write(component, DA7210_OUT1_R, DA7210_OUT1_R_EN); |
1143 | snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN | | 1143 | snd_soc_component_write(component, DA7210_OUT2, DA7210_OUT2_EN | |
1144 | DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); | 1144 | DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); |
1145 | 1145 | ||
1146 | /* Enable Aux1 */ | 1146 | /* Enable Aux1 */ |
1147 | snd_soc_write(codec, DA7210_AUX1_L, DA7210_AUX1_L_EN); | 1147 | snd_soc_component_write(component, DA7210_AUX1_L, DA7210_AUX1_L_EN); |
1148 | snd_soc_write(codec, DA7210_AUX1_R, DA7210_AUX1_R_EN); | 1148 | snd_soc_component_write(component, DA7210_AUX1_R, DA7210_AUX1_R_EN); |
1149 | /* Enable Aux2 */ | 1149 | /* Enable Aux2 */ |
1150 | snd_soc_write(codec, DA7210_AUX2, DA7210_AUX2_EN); | 1150 | snd_soc_component_write(component, DA7210_AUX2, DA7210_AUX2_EN); |
1151 | 1151 | ||
1152 | /* Set PLL Master clock range 10-20 MHz, enable PLL bypass */ | 1152 | /* Set PLL Master clock range 10-20 MHz, enable PLL bypass */ |
1153 | snd_soc_write(codec, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | | 1153 | snd_soc_component_write(component, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | |
1154 | DA7210_PLL_BYP); | 1154 | DA7210_PLL_BYP); |
1155 | 1155 | ||
1156 | /* Diable PLL and bypass it */ | 1156 | /* Diable PLL and bypass it */ |
1157 | snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); | 1157 | snd_soc_component_write(component, DA7210_PLL, DA7210_PLL_FS_48000); |
1158 | 1158 | ||
1159 | /* Activate all enabled subsystem */ | 1159 | /* Activate all enabled subsystem */ |
1160 | snd_soc_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN); | 1160 | snd_soc_component_write(component, DA7210_STARTUP1, DA7210_SC_MST_EN); |
1161 | 1161 | ||
1162 | dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); | 1162 | dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); |
1163 | 1163 | ||
1164 | return 0; | 1164 | return 0; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | static const struct snd_soc_codec_driver soc_codec_dev_da7210 = { | 1167 | static const struct snd_soc_component_driver soc_component_dev_da7210 = { |
1168 | .probe = da7210_probe, | 1168 | .probe = da7210_probe, |
1169 | 1169 | .controls = da7210_snd_controls, | |
1170 | .component_driver = { | 1170 | .num_controls = ARRAY_SIZE(da7210_snd_controls), |
1171 | .controls = da7210_snd_controls, | 1171 | .dapm_widgets = da7210_dapm_widgets, |
1172 | .num_controls = ARRAY_SIZE(da7210_snd_controls), | 1172 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), |
1173 | .dapm_widgets = da7210_dapm_widgets, | 1173 | .dapm_routes = da7210_audio_map, |
1174 | .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), | 1174 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), |
1175 | .dapm_routes = da7210_audio_map, | 1175 | .idle_bias_on = 1, |
1176 | .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), | 1176 | .use_pmdown_time = 1, |
1177 | }, | 1177 | .endianness = 1, |
1178 | .non_legacy_dai_naming = 1, | ||
1178 | }; | 1179 | }; |
1179 | 1180 | ||
1180 | #if IS_ENABLED(CONFIG_I2C) | 1181 | #if IS_ENABLED(CONFIG_I2C) |
@@ -1232,20 +1233,14 @@ static int da7210_i2c_probe(struct i2c_client *i2c, | |||
1232 | if (ret != 0) | 1233 | if (ret != 0) |
1233 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); | 1234 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); |
1234 | 1235 | ||
1235 | ret = snd_soc_register_codec(&i2c->dev, | 1236 | ret = devm_snd_soc_register_component(&i2c->dev, |
1236 | &soc_codec_dev_da7210, &da7210_dai, 1); | 1237 | &soc_component_dev_da7210, &da7210_dai, 1); |
1237 | if (ret < 0) | 1238 | if (ret < 0) |
1238 | dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); | 1239 | dev_err(&i2c->dev, "Failed to register component: %d\n", ret); |
1239 | 1240 | ||
1240 | return ret; | 1241 | return ret; |
1241 | } | 1242 | } |
1242 | 1243 | ||
1243 | static int da7210_i2c_remove(struct i2c_client *client) | ||
1244 | { | ||
1245 | snd_soc_unregister_codec(&client->dev); | ||
1246 | return 0; | ||
1247 | } | ||
1248 | |||
1249 | static const struct i2c_device_id da7210_i2c_id[] = { | 1244 | static const struct i2c_device_id da7210_i2c_id[] = { |
1250 | { "da7210", 0 }, | 1245 | { "da7210", 0 }, |
1251 | { } | 1246 | { } |
@@ -1258,7 +1253,6 @@ static struct i2c_driver da7210_i2c_driver = { | |||
1258 | .name = "da7210", | 1253 | .name = "da7210", |
1259 | }, | 1254 | }, |
1260 | .probe = da7210_i2c_probe, | 1255 | .probe = da7210_i2c_probe, |
1261 | .remove = da7210_i2c_remove, | ||
1262 | .id_table = da7210_i2c_id, | 1256 | .id_table = da7210_i2c_id, |
1263 | }; | 1257 | }; |
1264 | #endif | 1258 | #endif |
@@ -1325,24 +1319,17 @@ static int da7210_spi_probe(struct spi_device *spi) | |||
1325 | if (ret != 0) | 1319 | if (ret != 0) |
1326 | dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); | 1320 | dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); |
1327 | 1321 | ||
1328 | ret = snd_soc_register_codec(&spi->dev, | 1322 | ret = devm_snd_soc_register_component(&spi->dev, |
1329 | &soc_codec_dev_da7210, &da7210_dai, 1); | 1323 | &soc_component_dev_da7210, &da7210_dai, 1); |
1330 | 1324 | ||
1331 | return ret; | 1325 | return ret; |
1332 | } | 1326 | } |
1333 | 1327 | ||
1334 | static int da7210_spi_remove(struct spi_device *spi) | ||
1335 | { | ||
1336 | snd_soc_unregister_codec(&spi->dev); | ||
1337 | return 0; | ||
1338 | } | ||
1339 | |||
1340 | static struct spi_driver da7210_spi_driver = { | 1328 | static struct spi_driver da7210_spi_driver = { |
1341 | .driver = { | 1329 | .driver = { |
1342 | .name = "da7210", | 1330 | .name = "da7210", |
1343 | }, | 1331 | }, |
1344 | .probe = da7210_spi_probe, | 1332 | .probe = da7210_spi_probe, |
1345 | .remove = da7210_spi_remove | ||
1346 | }; | 1333 | }; |
1347 | #endif | 1334 | #endif |
1348 | 1335 | ||
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index b2b4e90fc02a..54cb5f24969f 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c | |||
@@ -194,7 +194,7 @@ static SOC_ENUM_SINGLE_DECL(da7213_alc_integ_release_rate, | |||
194 | * Control Functions | 194 | * Control Functions |
195 | */ | 195 | */ |
196 | 196 | ||
197 | static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) | 197 | static int da7213_get_alc_data(struct snd_soc_component *component, u8 reg_val) |
198 | { | 198 | { |
199 | int mid_data, top_data; | 199 | int mid_data, top_data; |
200 | int sum = 0; | 200 | int sum = 0; |
@@ -203,17 +203,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) | |||
203 | for (iteration = 0; iteration < DA7213_ALC_AVG_ITERATIONS; | 203 | for (iteration = 0; iteration < DA7213_ALC_AVG_ITERATIONS; |
204 | iteration++) { | 204 | iteration++) { |
205 | /* Select the left or right channel and capture data */ | 205 | /* Select the left or right channel and capture data */ |
206 | snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val); | 206 | snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val); |
207 | 207 | ||
208 | /* Select middle 8 bits for read back from data register */ | 208 | /* Select middle 8 bits for read back from data register */ |
209 | snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, | 209 | snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, |
210 | reg_val | DA7213_ALC_DATA_MIDDLE); | 210 | reg_val | DA7213_ALC_DATA_MIDDLE); |
211 | mid_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); | 211 | mid_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA); |
212 | 212 | ||
213 | /* Select top 8 bits for read back from data register */ | 213 | /* Select top 8 bits for read back from data register */ |
214 | snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, | 214 | snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, |
215 | reg_val | DA7213_ALC_DATA_TOP); | 215 | reg_val | DA7213_ALC_DATA_TOP); |
216 | top_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); | 216 | top_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA); |
217 | 217 | ||
218 | sum += ((mid_data << 8) | (top_data << 16)); | 218 | sum += ((mid_data << 8) | (top_data << 16)); |
219 | } | 219 | } |
@@ -221,17 +221,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) | |||
221 | return sum / DA7213_ALC_AVG_ITERATIONS; | 221 | return sum / DA7213_ALC_AVG_ITERATIONS; |
222 | } | 222 | } |
223 | 223 | ||
224 | static void da7213_alc_calib_man(struct snd_soc_codec *codec) | 224 | static void da7213_alc_calib_man(struct snd_soc_component *component) |
225 | { | 225 | { |
226 | u8 reg_val; | 226 | u8 reg_val; |
227 | int avg_left_data, avg_right_data, offset_l, offset_r; | 227 | int avg_left_data, avg_right_data, offset_l, offset_r; |
228 | 228 | ||
229 | /* Calculate average for Left and Right data */ | 229 | /* Calculate average for Left and Right data */ |
230 | /* Left Data */ | 230 | /* Left Data */ |
231 | avg_left_data = da7213_get_alc_data(codec, | 231 | avg_left_data = da7213_get_alc_data(component, |
232 | DA7213_ALC_CIC_OP_CHANNEL_LEFT); | 232 | DA7213_ALC_CIC_OP_CHANNEL_LEFT); |
233 | /* Right Data */ | 233 | /* Right Data */ |
234 | avg_right_data = da7213_get_alc_data(codec, | 234 | avg_right_data = da7213_get_alc_data(component, |
235 | DA7213_ALC_CIC_OP_CHANNEL_RIGHT); | 235 | DA7213_ALC_CIC_OP_CHANNEL_RIGHT); |
236 | 236 | ||
237 | /* Calculate DC offset */ | 237 | /* Calculate DC offset */ |
@@ -239,122 +239,122 @@ static void da7213_alc_calib_man(struct snd_soc_codec *codec) | |||
239 | offset_r = -avg_right_data; | 239 | offset_r = -avg_right_data; |
240 | 240 | ||
241 | reg_val = (offset_l & DA7213_ALC_OFFSET_15_8) >> 8; | 241 | reg_val = (offset_l & DA7213_ALC_OFFSET_15_8) >> 8; |
242 | snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_L, reg_val); | 242 | snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_L, reg_val); |
243 | reg_val = (offset_l & DA7213_ALC_OFFSET_19_16) >> 16; | 243 | reg_val = (offset_l & DA7213_ALC_OFFSET_19_16) >> 16; |
244 | snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_L, reg_val); | 244 | snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_L, reg_val); |
245 | 245 | ||
246 | reg_val = (offset_r & DA7213_ALC_OFFSET_15_8) >> 8; | 246 | reg_val = (offset_r & DA7213_ALC_OFFSET_15_8) >> 8; |
247 | snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_R, reg_val); | 247 | snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_R, reg_val); |
248 | reg_val = (offset_r & DA7213_ALC_OFFSET_19_16) >> 16; | 248 | reg_val = (offset_r & DA7213_ALC_OFFSET_19_16) >> 16; |
249 | snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_R, reg_val); | 249 | snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_R, reg_val); |
250 | 250 | ||
251 | /* Enable analog/digital gain mode & offset cancellation */ | 251 | /* Enable analog/digital gain mode & offset cancellation */ |
252 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, | 252 | snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, |
253 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, | 253 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, |
254 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); | 254 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); |
255 | } | 255 | } |
256 | 256 | ||
257 | static void da7213_alc_calib_auto(struct snd_soc_codec *codec) | 257 | static void da7213_alc_calib_auto(struct snd_soc_component *component) |
258 | { | 258 | { |
259 | u8 alc_ctrl1; | 259 | u8 alc_ctrl1; |
260 | 260 | ||
261 | /* Begin auto calibration and wait for completion */ | 261 | /* Begin auto calibration and wait for completion */ |
262 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN, | 262 | snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN, |
263 | DA7213_ALC_AUTO_CALIB_EN); | 263 | DA7213_ALC_AUTO_CALIB_EN); |
264 | do { | 264 | do { |
265 | alc_ctrl1 = snd_soc_read(codec, DA7213_ALC_CTRL1); | 265 | alc_ctrl1 = snd_soc_component_read32(component, DA7213_ALC_CTRL1); |
266 | } while (alc_ctrl1 & DA7213_ALC_AUTO_CALIB_EN); | 266 | } while (alc_ctrl1 & DA7213_ALC_AUTO_CALIB_EN); |
267 | 267 | ||
268 | /* If auto calibration fails, fall back to digital gain only mode */ | 268 | /* If auto calibration fails, fall back to digital gain only mode */ |
269 | if (alc_ctrl1 & DA7213_ALC_CALIB_OVERFLOW) { | 269 | if (alc_ctrl1 & DA7213_ALC_CALIB_OVERFLOW) { |
270 | dev_warn(codec->dev, | 270 | dev_warn(component->dev, |
271 | "ALC auto calibration failed with overflow\n"); | 271 | "ALC auto calibration failed with overflow\n"); |
272 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, | 272 | snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, |
273 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, | 273 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, |
274 | 0); | 274 | 0); |
275 | } else { | 275 | } else { |
276 | /* Enable analog/digital gain mode & offset cancellation */ | 276 | /* Enable analog/digital gain mode & offset cancellation */ |
277 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, | 277 | snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, |
278 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, | 278 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, |
279 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); | 279 | DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); |
280 | } | 280 | } |
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | static void da7213_alc_calib(struct snd_soc_codec *codec) | 284 | static void da7213_alc_calib(struct snd_soc_component *component) |
285 | { | 285 | { |
286 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 286 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
287 | u8 adc_l_ctrl, adc_r_ctrl; | 287 | u8 adc_l_ctrl, adc_r_ctrl; |
288 | u8 mixin_l_sel, mixin_r_sel; | 288 | u8 mixin_l_sel, mixin_r_sel; |
289 | u8 mic_1_ctrl, mic_2_ctrl; | 289 | u8 mic_1_ctrl, mic_2_ctrl; |
290 | 290 | ||
291 | /* Save current values from ADC control registers */ | 291 | /* Save current values from ADC control registers */ |
292 | adc_l_ctrl = snd_soc_read(codec, DA7213_ADC_L_CTRL); | 292 | adc_l_ctrl = snd_soc_component_read32(component, DA7213_ADC_L_CTRL); |
293 | adc_r_ctrl = snd_soc_read(codec, DA7213_ADC_R_CTRL); | 293 | adc_r_ctrl = snd_soc_component_read32(component, DA7213_ADC_R_CTRL); |
294 | 294 | ||
295 | /* Save current values from MIXIN_L/R_SELECT registers */ | 295 | /* Save current values from MIXIN_L/R_SELECT registers */ |
296 | mixin_l_sel = snd_soc_read(codec, DA7213_MIXIN_L_SELECT); | 296 | mixin_l_sel = snd_soc_component_read32(component, DA7213_MIXIN_L_SELECT); |
297 | mixin_r_sel = snd_soc_read(codec, DA7213_MIXIN_R_SELECT); | 297 | mixin_r_sel = snd_soc_component_read32(component, DA7213_MIXIN_R_SELECT); |
298 | 298 | ||
299 | /* Save current values from MIC control registers */ | 299 | /* Save current values from MIC control registers */ |
300 | mic_1_ctrl = snd_soc_read(codec, DA7213_MIC_1_CTRL); | 300 | mic_1_ctrl = snd_soc_component_read32(component, DA7213_MIC_1_CTRL); |
301 | mic_2_ctrl = snd_soc_read(codec, DA7213_MIC_2_CTRL); | 301 | mic_2_ctrl = snd_soc_component_read32(component, DA7213_MIC_2_CTRL); |
302 | 302 | ||
303 | /* Enable ADC Left and Right */ | 303 | /* Enable ADC Left and Right */ |
304 | snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, DA7213_ADC_EN, | 304 | snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL, DA7213_ADC_EN, |
305 | DA7213_ADC_EN); | 305 | DA7213_ADC_EN); |
306 | snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, DA7213_ADC_EN, | 306 | snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL, DA7213_ADC_EN, |
307 | DA7213_ADC_EN); | 307 | DA7213_ADC_EN); |
308 | 308 | ||
309 | /* Enable MIC paths */ | 309 | /* Enable MIC paths */ |
310 | snd_soc_update_bits(codec, DA7213_MIXIN_L_SELECT, | 310 | snd_soc_component_update_bits(component, DA7213_MIXIN_L_SELECT, |
311 | DA7213_MIXIN_L_MIX_SELECT_MIC_1 | | 311 | DA7213_MIXIN_L_MIX_SELECT_MIC_1 | |
312 | DA7213_MIXIN_L_MIX_SELECT_MIC_2, | 312 | DA7213_MIXIN_L_MIX_SELECT_MIC_2, |
313 | DA7213_MIXIN_L_MIX_SELECT_MIC_1 | | 313 | DA7213_MIXIN_L_MIX_SELECT_MIC_1 | |
314 | DA7213_MIXIN_L_MIX_SELECT_MIC_2); | 314 | DA7213_MIXIN_L_MIX_SELECT_MIC_2); |
315 | snd_soc_update_bits(codec, DA7213_MIXIN_R_SELECT, | 315 | snd_soc_component_update_bits(component, DA7213_MIXIN_R_SELECT, |
316 | DA7213_MIXIN_R_MIX_SELECT_MIC_2 | | 316 | DA7213_MIXIN_R_MIX_SELECT_MIC_2 | |
317 | DA7213_MIXIN_R_MIX_SELECT_MIC_1, | 317 | DA7213_MIXIN_R_MIX_SELECT_MIC_1, |
318 | DA7213_MIXIN_R_MIX_SELECT_MIC_2 | | 318 | DA7213_MIXIN_R_MIX_SELECT_MIC_2 | |
319 | DA7213_MIXIN_R_MIX_SELECT_MIC_1); | 319 | DA7213_MIXIN_R_MIX_SELECT_MIC_1); |
320 | 320 | ||
321 | /* Mute MIC PGAs */ | 321 | /* Mute MIC PGAs */ |
322 | snd_soc_update_bits(codec, DA7213_MIC_1_CTRL, DA7213_MUTE_EN, | 322 | snd_soc_component_update_bits(component, DA7213_MIC_1_CTRL, DA7213_MUTE_EN, |
323 | DA7213_MUTE_EN); | 323 | DA7213_MUTE_EN); |
324 | snd_soc_update_bits(codec, DA7213_MIC_2_CTRL, DA7213_MUTE_EN, | 324 | snd_soc_component_update_bits(component, DA7213_MIC_2_CTRL, DA7213_MUTE_EN, |
325 | DA7213_MUTE_EN); | 325 | DA7213_MUTE_EN); |
326 | 326 | ||
327 | /* Perform calibration */ | 327 | /* Perform calibration */ |
328 | if (da7213->alc_calib_auto) | 328 | if (da7213->alc_calib_auto) |
329 | da7213_alc_calib_auto(codec); | 329 | da7213_alc_calib_auto(component); |
330 | else | 330 | else |
331 | da7213_alc_calib_man(codec); | 331 | da7213_alc_calib_man(component); |
332 | 332 | ||
333 | /* Restore MIXIN_L/R_SELECT registers to their original states */ | 333 | /* Restore MIXIN_L/R_SELECT registers to their original states */ |
334 | snd_soc_write(codec, DA7213_MIXIN_L_SELECT, mixin_l_sel); | 334 | snd_soc_component_write(component, DA7213_MIXIN_L_SELECT, mixin_l_sel); |
335 | snd_soc_write(codec, DA7213_MIXIN_R_SELECT, mixin_r_sel); | 335 | snd_soc_component_write(component, DA7213_MIXIN_R_SELECT, mixin_r_sel); |
336 | 336 | ||
337 | /* Restore ADC control registers to their original states */ | 337 | /* Restore ADC control registers to their original states */ |
338 | snd_soc_write(codec, DA7213_ADC_L_CTRL, adc_l_ctrl); | 338 | snd_soc_component_write(component, DA7213_ADC_L_CTRL, adc_l_ctrl); |
339 | snd_soc_write(codec, DA7213_ADC_R_CTRL, adc_r_ctrl); | 339 | snd_soc_component_write(component, DA7213_ADC_R_CTRL, adc_r_ctrl); |
340 | 340 | ||
341 | /* Restore original values of MIC control registers */ | 341 | /* Restore original values of MIC control registers */ |
342 | snd_soc_write(codec, DA7213_MIC_1_CTRL, mic_1_ctrl); | 342 | snd_soc_component_write(component, DA7213_MIC_1_CTRL, mic_1_ctrl); |
343 | snd_soc_write(codec, DA7213_MIC_2_CTRL, mic_2_ctrl); | 343 | snd_soc_component_write(component, DA7213_MIC_2_CTRL, mic_2_ctrl); |
344 | } | 344 | } |
345 | 345 | ||
346 | static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, | 346 | static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, |
347 | struct snd_ctl_elem_value *ucontrol) | 347 | struct snd_ctl_elem_value *ucontrol) |
348 | { | 348 | { |
349 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 349 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
350 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 350 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
351 | int ret; | 351 | int ret; |
352 | 352 | ||
353 | ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); | 353 | ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); |
354 | 354 | ||
355 | /* If ALC in operation, make sure calibrated offsets are updated */ | 355 | /* If ALC in operation, make sure calibrated offsets are updated */ |
356 | if ((!ret) && (da7213->alc_en)) | 356 | if ((!ret) && (da7213->alc_en)) |
357 | da7213_alc_calib(codec); | 357 | da7213_alc_calib(component); |
358 | 358 | ||
359 | return ret; | 359 | return ret; |
360 | } | 360 | } |
@@ -362,14 +362,14 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, | |||
362 | static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, | 362 | static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, |
363 | struct snd_ctl_elem_value *ucontrol) | 363 | struct snd_ctl_elem_value *ucontrol) |
364 | { | 364 | { |
365 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 365 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
366 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 366 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
367 | 367 | ||
368 | /* Force ALC offset calibration if enabling ALC */ | 368 | /* Force ALC offset calibration if enabling ALC */ |
369 | if (ucontrol->value.integer.value[0] || | 369 | if (ucontrol->value.integer.value[0] || |
370 | ucontrol->value.integer.value[1]) { | 370 | ucontrol->value.integer.value[1]) { |
371 | if (!da7213->alc_en) { | 371 | if (!da7213->alc_en) { |
372 | da7213_alc_calib(codec); | 372 | da7213_alc_calib(component); |
373 | da7213->alc_en = true; | 373 | da7213->alc_en = true; |
374 | } | 374 | } |
375 | } else { | 375 | } else { |
@@ -735,8 +735,8 @@ static const struct snd_kcontrol_new da7213_dapm_mixoutr_controls[] = { | |||
735 | static int da7213_dai_event(struct snd_soc_dapm_widget *w, | 735 | static int da7213_dai_event(struct snd_soc_dapm_widget *w, |
736 | struct snd_kcontrol *kcontrol, int event) | 736 | struct snd_kcontrol *kcontrol, int event) |
737 | { | 737 | { |
738 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 738 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
739 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 739 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
740 | u8 pll_ctrl, pll_status; | 740 | u8 pll_ctrl, pll_status; |
741 | int i = 0; | 741 | int i = 0; |
742 | bool srm_lock = false; | 742 | bool srm_lock = false; |
@@ -745,29 +745,29 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, | |||
745 | case SND_SOC_DAPM_PRE_PMU: | 745 | case SND_SOC_DAPM_PRE_PMU: |
746 | /* Enable DAI clks for master mode */ | 746 | /* Enable DAI clks for master mode */ |
747 | if (da7213->master) | 747 | if (da7213->master) |
748 | snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, | 748 | snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE, |
749 | DA7213_DAI_CLK_EN_MASK, | 749 | DA7213_DAI_CLK_EN_MASK, |
750 | DA7213_DAI_CLK_EN_MASK); | 750 | DA7213_DAI_CLK_EN_MASK); |
751 | 751 | ||
752 | /* PC synchronised to DAI */ | 752 | /* PC synchronised to DAI */ |
753 | snd_soc_update_bits(codec, DA7213_PC_COUNT, | 753 | snd_soc_component_update_bits(component, DA7213_PC_COUNT, |
754 | DA7213_PC_FREERUN_MASK, 0); | 754 | DA7213_PC_FREERUN_MASK, 0); |
755 | 755 | ||
756 | /* If SRM not enabled then nothing more to do */ | 756 | /* If SRM not enabled then nothing more to do */ |
757 | pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); | 757 | pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL); |
758 | if (!(pll_ctrl & DA7213_PLL_SRM_EN)) | 758 | if (!(pll_ctrl & DA7213_PLL_SRM_EN)) |
759 | return 0; | 759 | return 0; |
760 | 760 | ||
761 | /* Assist 32KHz mode PLL lock */ | 761 | /* Assist 32KHz mode PLL lock */ |
762 | if (pll_ctrl & DA7213_PLL_32K_MODE) { | 762 | if (pll_ctrl & DA7213_PLL_32K_MODE) { |
763 | snd_soc_write(codec, 0xF0, 0x8B); | 763 | snd_soc_component_write(component, 0xF0, 0x8B); |
764 | snd_soc_write(codec, 0xF2, 0x03); | 764 | snd_soc_component_write(component, 0xF2, 0x03); |
765 | snd_soc_write(codec, 0xF0, 0x00); | 765 | snd_soc_component_write(component, 0xF0, 0x00); |
766 | } | 766 | } |
767 | 767 | ||
768 | /* Check SRM has locked */ | 768 | /* Check SRM has locked */ |
769 | do { | 769 | do { |
770 | pll_status = snd_soc_read(codec, DA7213_PLL_STATUS); | 770 | pll_status = snd_soc_component_read32(component, DA7213_PLL_STATUS); |
771 | if (pll_status & DA7219_PLL_SRM_LOCK) { | 771 | if (pll_status & DA7219_PLL_SRM_LOCK) { |
772 | srm_lock = true; | 772 | srm_lock = true; |
773 | } else { | 773 | } else { |
@@ -777,26 +777,26 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, | |||
777 | } while ((i < DA7213_SRM_CHECK_RETRIES) && (!srm_lock)); | 777 | } while ((i < DA7213_SRM_CHECK_RETRIES) && (!srm_lock)); |
778 | 778 | ||
779 | if (!srm_lock) | 779 | if (!srm_lock) |
780 | dev_warn(codec->dev, "SRM failed to lock\n"); | 780 | dev_warn(component->dev, "SRM failed to lock\n"); |
781 | 781 | ||
782 | return 0; | 782 | return 0; |
783 | case SND_SOC_DAPM_POST_PMD: | 783 | case SND_SOC_DAPM_POST_PMD: |
784 | /* Revert 32KHz PLL lock udpates if applied previously */ | 784 | /* Revert 32KHz PLL lock udpates if applied previously */ |
785 | pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); | 785 | pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL); |
786 | if (pll_ctrl & DA7213_PLL_32K_MODE) { | 786 | if (pll_ctrl & DA7213_PLL_32K_MODE) { |
787 | snd_soc_write(codec, 0xF0, 0x8B); | 787 | snd_soc_component_write(component, 0xF0, 0x8B); |
788 | snd_soc_write(codec, 0xF2, 0x01); | 788 | snd_soc_component_write(component, 0xF2, 0x01); |
789 | snd_soc_write(codec, 0xF0, 0x00); | 789 | snd_soc_component_write(component, 0xF0, 0x00); |
790 | } | 790 | } |
791 | 791 | ||
792 | /* PC free-running */ | 792 | /* PC free-running */ |
793 | snd_soc_update_bits(codec, DA7213_PC_COUNT, | 793 | snd_soc_component_update_bits(component, DA7213_PC_COUNT, |
794 | DA7213_PC_FREERUN_MASK, | 794 | DA7213_PC_FREERUN_MASK, |
795 | DA7213_PC_FREERUN_MASK); | 795 | DA7213_PC_FREERUN_MASK); |
796 | 796 | ||
797 | /* Disable DAI clks if in master mode */ | 797 | /* Disable DAI clks if in master mode */ |
798 | if (da7213->master) | 798 | if (da7213->master) |
799 | snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, | 799 | snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE, |
800 | DA7213_DAI_CLK_EN_MASK, 0); | 800 | DA7213_DAI_CLK_EN_MASK, 0); |
801 | return 0; | 801 | return 0; |
802 | default: | 802 | default: |
@@ -1150,7 +1150,7 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, | |||
1150 | struct snd_pcm_hw_params *params, | 1150 | struct snd_pcm_hw_params *params, |
1151 | struct snd_soc_dai *dai) | 1151 | struct snd_soc_dai *dai) |
1152 | { | 1152 | { |
1153 | struct snd_soc_codec *codec = dai->codec; | 1153 | struct snd_soc_component *component = dai->component; |
1154 | u8 dai_ctrl = 0; | 1154 | u8 dai_ctrl = 0; |
1155 | u8 fs; | 1155 | u8 fs; |
1156 | 1156 | ||
@@ -1208,17 +1208,17 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, | |||
1208 | return -EINVAL; | 1208 | return -EINVAL; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, | 1211 | snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, |
1212 | dai_ctrl); | 1212 | dai_ctrl); |
1213 | snd_soc_write(codec, DA7213_SR, fs); | 1213 | snd_soc_component_write(component, DA7213_SR, fs); |
1214 | 1214 | ||
1215 | return 0; | 1215 | return 0; |
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 1218 | static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
1219 | { | 1219 | { |
1220 | struct snd_soc_codec *codec = codec_dai->codec; | 1220 | struct snd_soc_component *component = codec_dai->component; |
1221 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1221 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
1222 | u8 dai_clk_mode = 0, dai_ctrl = 0; | 1222 | u8 dai_clk_mode = 0, dai_ctrl = 0; |
1223 | u8 dai_offset = 0; | 1223 | u8 dai_offset = 0; |
1224 | 1224 | ||
@@ -1305,27 +1305,27 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
1305 | /* By default only 64 BCLK per WCLK is supported */ | 1305 | /* By default only 64 BCLK per WCLK is supported */ |
1306 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; | 1306 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; |
1307 | 1307 | ||
1308 | snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); | 1308 | snd_soc_component_write(component, DA7213_DAI_CLK_MODE, dai_clk_mode); |
1309 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, | 1309 | snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, |
1310 | dai_ctrl); | 1310 | dai_ctrl); |
1311 | snd_soc_write(codec, DA7213_DAI_OFFSET, dai_offset); | 1311 | snd_soc_component_write(component, DA7213_DAI_OFFSET, dai_offset); |
1312 | 1312 | ||
1313 | return 0; | 1313 | return 0; |
1314 | } | 1314 | } |
1315 | 1315 | ||
1316 | static int da7213_mute(struct snd_soc_dai *dai, int mute) | 1316 | static int da7213_mute(struct snd_soc_dai *dai, int mute) |
1317 | { | 1317 | { |
1318 | struct snd_soc_codec *codec = dai->codec; | 1318 | struct snd_soc_component *component = dai->component; |
1319 | 1319 | ||
1320 | if (mute) { | 1320 | if (mute) { |
1321 | snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, | 1321 | snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, |
1322 | DA7213_MUTE_EN, DA7213_MUTE_EN); | 1322 | DA7213_MUTE_EN, DA7213_MUTE_EN); |
1323 | snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, | 1323 | snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, |
1324 | DA7213_MUTE_EN, DA7213_MUTE_EN); | 1324 | DA7213_MUTE_EN, DA7213_MUTE_EN); |
1325 | } else { | 1325 | } else { |
1326 | snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, | 1326 | snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, |
1327 | DA7213_MUTE_EN, 0); | 1327 | DA7213_MUTE_EN, 0); |
1328 | snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, | 1328 | snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, |
1329 | DA7213_MUTE_EN, 0); | 1329 | DA7213_MUTE_EN, 0); |
1330 | } | 1330 | } |
1331 | 1331 | ||
@@ -1338,8 +1338,8 @@ static int da7213_mute(struct snd_soc_dai *dai, int mute) | |||
1338 | static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 1338 | static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
1339 | int clk_id, unsigned int freq, int dir) | 1339 | int clk_id, unsigned int freq, int dir) |
1340 | { | 1340 | { |
1341 | struct snd_soc_codec *codec = codec_dai->codec; | 1341 | struct snd_soc_component *component = codec_dai->component; |
1342 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1342 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
1343 | int ret = 0; | 1343 | int ret = 0; |
1344 | 1344 | ||
1345 | if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) | 1345 | if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) |
@@ -1353,11 +1353,11 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1353 | 1353 | ||
1354 | switch (clk_id) { | 1354 | switch (clk_id) { |
1355 | case DA7213_CLKSRC_MCLK: | 1355 | case DA7213_CLKSRC_MCLK: |
1356 | snd_soc_update_bits(codec, DA7213_PLL_CTRL, | 1356 | snd_soc_component_update_bits(component, DA7213_PLL_CTRL, |
1357 | DA7213_PLL_MCLK_SQR_EN, 0); | 1357 | DA7213_PLL_MCLK_SQR_EN, 0); |
1358 | break; | 1358 | break; |
1359 | case DA7213_CLKSRC_MCLK_SQR: | 1359 | case DA7213_CLKSRC_MCLK_SQR: |
1360 | snd_soc_update_bits(codec, DA7213_PLL_CTRL, | 1360 | snd_soc_component_update_bits(component, DA7213_PLL_CTRL, |
1361 | DA7213_PLL_MCLK_SQR_EN, | 1361 | DA7213_PLL_MCLK_SQR_EN, |
1362 | DA7213_PLL_MCLK_SQR_EN); | 1362 | DA7213_PLL_MCLK_SQR_EN); |
1363 | break; | 1363 | break; |
@@ -1387,8 +1387,8 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1387 | static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | 1387 | static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, |
1388 | int source, unsigned int fref, unsigned int fout) | 1388 | int source, unsigned int fref, unsigned int fout) |
1389 | { | 1389 | { |
1390 | struct snd_soc_codec *codec = codec_dai->codec; | 1390 | struct snd_soc_component *component = codec_dai->component; |
1391 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1391 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
1392 | 1392 | ||
1393 | u8 pll_ctrl, indiv_bits, indiv; | 1393 | u8 pll_ctrl, indiv_bits, indiv; |
1394 | u8 pll_frac_top, pll_frac_bot, pll_integer; | 1394 | u8 pll_frac_top, pll_frac_bot, pll_integer; |
@@ -1398,7 +1398,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1398 | /* Workout input divider based on MCLK rate */ | 1398 | /* Workout input divider based on MCLK rate */ |
1399 | if (da7213->mclk_rate == 32768) { | 1399 | if (da7213->mclk_rate == 32768) { |
1400 | if (!da7213->master) { | 1400 | if (!da7213->master) { |
1401 | dev_err(codec->dev, | 1401 | dev_err(component->dev, |
1402 | "32KHz only valid if codec is clock master\n"); | 1402 | "32KHz only valid if codec is clock master\n"); |
1403 | return -EINVAL; | 1403 | return -EINVAL; |
1404 | } | 1404 | } |
@@ -1411,7 +1411,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1411 | 1411 | ||
1412 | } else { | 1412 | } else { |
1413 | if (da7213->mclk_rate < 5000000) { | 1413 | if (da7213->mclk_rate < 5000000) { |
1414 | dev_err(codec->dev, | 1414 | dev_err(component->dev, |
1415 | "PLL input clock %d below valid range\n", | 1415 | "PLL input clock %d below valid range\n", |
1416 | da7213->mclk_rate); | 1416 | da7213->mclk_rate); |
1417 | return -EINVAL; | 1417 | return -EINVAL; |
@@ -1428,7 +1428,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1428 | indiv_bits = DA7213_PLL_INDIV_36_TO_54_MHZ; | 1428 | indiv_bits = DA7213_PLL_INDIV_36_TO_54_MHZ; |
1429 | indiv = DA7213_PLL_INDIV_36_TO_54_MHZ_VAL; | 1429 | indiv = DA7213_PLL_INDIV_36_TO_54_MHZ_VAL; |
1430 | } else { | 1430 | } else { |
1431 | dev_err(codec->dev, | 1431 | dev_err(component->dev, |
1432 | "PLL input clock %d above valid range\n", | 1432 | "PLL input clock %d above valid range\n", |
1433 | da7213->mclk_rate); | 1433 | da7213->mclk_rate); |
1434 | return -EINVAL; | 1434 | return -EINVAL; |
@@ -1441,7 +1441,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1441 | /* Configure PLL */ | 1441 | /* Configure PLL */ |
1442 | switch (source) { | 1442 | switch (source) { |
1443 | case DA7213_SYSCLK_MCLK: | 1443 | case DA7213_SYSCLK_MCLK: |
1444 | snd_soc_update_bits(codec, DA7213_PLL_CTRL, | 1444 | snd_soc_component_update_bits(component, DA7213_PLL_CTRL, |
1445 | DA7213_PLL_INDIV_MASK | | 1445 | DA7213_PLL_INDIV_MASK | |
1446 | DA7213_PLL_MODE_MASK, pll_ctrl); | 1446 | DA7213_PLL_MODE_MASK, pll_ctrl); |
1447 | return 0; | 1447 | return 0; |
@@ -1453,7 +1453,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1453 | break; | 1453 | break; |
1454 | case DA7213_SYSCLK_PLL_32KHZ: | 1454 | case DA7213_SYSCLK_PLL_32KHZ: |
1455 | if (da7213->mclk_rate != 32768) { | 1455 | if (da7213->mclk_rate != 32768) { |
1456 | dev_err(codec->dev, | 1456 | dev_err(component->dev, |
1457 | "32KHz mode only valid with 32KHz MCLK\n"); | 1457 | "32KHz mode only valid with 32KHz MCLK\n"); |
1458 | return -EINVAL; | 1458 | return -EINVAL; |
1459 | } | 1459 | } |
@@ -1462,7 +1462,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1462 | fout = DA7213_PLL_FREQ_OUT_94310400; | 1462 | fout = DA7213_PLL_FREQ_OUT_94310400; |
1463 | break; | 1463 | break; |
1464 | default: | 1464 | default: |
1465 | dev_err(codec->dev, "Invalid PLL config\n"); | 1465 | dev_err(component->dev, "Invalid PLL config\n"); |
1466 | return -EINVAL; | 1466 | return -EINVAL; |
1467 | } | 1467 | } |
1468 | 1468 | ||
@@ -1474,22 +1474,22 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1474 | pll_frac_bot = (frac_div) & DA7213_BYTE_MASK; | 1474 | pll_frac_bot = (frac_div) & DA7213_BYTE_MASK; |
1475 | 1475 | ||
1476 | /* Write PLL dividers */ | 1476 | /* Write PLL dividers */ |
1477 | snd_soc_write(codec, DA7213_PLL_FRAC_TOP, pll_frac_top); | 1477 | snd_soc_component_write(component, DA7213_PLL_FRAC_TOP, pll_frac_top); |
1478 | snd_soc_write(codec, DA7213_PLL_FRAC_BOT, pll_frac_bot); | 1478 | snd_soc_component_write(component, DA7213_PLL_FRAC_BOT, pll_frac_bot); |
1479 | snd_soc_write(codec, DA7213_PLL_INTEGER, pll_integer); | 1479 | snd_soc_component_write(component, DA7213_PLL_INTEGER, pll_integer); |
1480 | 1480 | ||
1481 | /* Enable PLL */ | 1481 | /* Enable PLL */ |
1482 | pll_ctrl |= DA7213_PLL_EN; | 1482 | pll_ctrl |= DA7213_PLL_EN; |
1483 | snd_soc_update_bits(codec, DA7213_PLL_CTRL, | 1483 | snd_soc_component_update_bits(component, DA7213_PLL_CTRL, |
1484 | DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK, | 1484 | DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK, |
1485 | pll_ctrl); | 1485 | pll_ctrl); |
1486 | 1486 | ||
1487 | /* Assist 32KHz mode PLL lock */ | 1487 | /* Assist 32KHz mode PLL lock */ |
1488 | if (source == DA7213_SYSCLK_PLL_32KHZ) { | 1488 | if (source == DA7213_SYSCLK_PLL_32KHZ) { |
1489 | snd_soc_write(codec, 0xF0, 0x8B); | 1489 | snd_soc_component_write(component, 0xF0, 0x8B); |
1490 | snd_soc_write(codec, 0xF1, 0x03); | 1490 | snd_soc_component_write(component, 0xF1, 0x03); |
1491 | snd_soc_write(codec, 0xF1, 0x01); | 1491 | snd_soc_component_write(component, 0xF1, 0x01); |
1492 | snd_soc_write(codec, 0xF0, 0x00); | 1492 | snd_soc_component_write(component, 0xF0, 0x00); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | return 0; | 1495 | return 0; |
@@ -1526,10 +1526,10 @@ static struct snd_soc_dai_driver da7213_dai = { | |||
1526 | .symmetric_rates = 1, | 1526 | .symmetric_rates = 1, |
1527 | }; | 1527 | }; |
1528 | 1528 | ||
1529 | static int da7213_set_bias_level(struct snd_soc_codec *codec, | 1529 | static int da7213_set_bias_level(struct snd_soc_component *component, |
1530 | enum snd_soc_bias_level level) | 1530 | enum snd_soc_bias_level level) |
1531 | { | 1531 | { |
1532 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1532 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
1533 | int ret; | 1533 | int ret; |
1534 | 1534 | ||
1535 | switch (level) { | 1535 | switch (level) { |
@@ -1537,11 +1537,11 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, | |||
1537 | break; | 1537 | break; |
1538 | case SND_SOC_BIAS_PREPARE: | 1538 | case SND_SOC_BIAS_PREPARE: |
1539 | /* Enable MCLK for transition to ON state */ | 1539 | /* Enable MCLK for transition to ON state */ |
1540 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { | 1540 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { |
1541 | if (da7213->mclk) { | 1541 | if (da7213->mclk) { |
1542 | ret = clk_prepare_enable(da7213->mclk); | 1542 | ret = clk_prepare_enable(da7213->mclk); |
1543 | if (ret) { | 1543 | if (ret) { |
1544 | dev_err(codec->dev, | 1544 | dev_err(component->dev, |
1545 | "Failed to enable mclk\n"); | 1545 | "Failed to enable mclk\n"); |
1546 | return ret; | 1546 | return ret; |
1547 | } | 1547 | } |
@@ -1549,9 +1549,9 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, | |||
1549 | } | 1549 | } |
1550 | break; | 1550 | break; |
1551 | case SND_SOC_BIAS_STANDBY: | 1551 | case SND_SOC_BIAS_STANDBY: |
1552 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 1552 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
1553 | /* Enable VMID reference & master bias */ | 1553 | /* Enable VMID reference & master bias */ |
1554 | snd_soc_update_bits(codec, DA7213_REFERENCES, | 1554 | snd_soc_component_update_bits(component, DA7213_REFERENCES, |
1555 | DA7213_VMID_EN | DA7213_BIAS_EN, | 1555 | DA7213_VMID_EN | DA7213_BIAS_EN, |
1556 | DA7213_VMID_EN | DA7213_BIAS_EN); | 1556 | DA7213_VMID_EN | DA7213_BIAS_EN); |
1557 | } else { | 1557 | } else { |
@@ -1562,7 +1562,7 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, | |||
1562 | break; | 1562 | break; |
1563 | case SND_SOC_BIAS_OFF: | 1563 | case SND_SOC_BIAS_OFF: |
1564 | /* Disable VMID reference & master bias */ | 1564 | /* Disable VMID reference & master bias */ |
1565 | snd_soc_update_bits(codec, DA7213_REFERENCES, | 1565 | snd_soc_component_update_bits(component, DA7213_REFERENCES, |
1566 | DA7213_VMID_EN | DA7213_BIAS_EN, 0); | 1566 | DA7213_VMID_EN | DA7213_BIAS_EN, 0); |
1567 | break; | 1567 | break; |
1568 | } | 1568 | } |
@@ -1588,7 +1588,7 @@ MODULE_DEVICE_TABLE(acpi, da7213_acpi_match); | |||
1588 | #endif | 1588 | #endif |
1589 | 1589 | ||
1590 | static enum da7213_micbias_voltage | 1590 | static enum da7213_micbias_voltage |
1591 | da7213_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) | 1591 | da7213_of_micbias_lvl(struct snd_soc_component *component, u32 val) |
1592 | { | 1592 | { |
1593 | switch (val) { | 1593 | switch (val) { |
1594 | case 1600: | 1594 | case 1600: |
@@ -1600,39 +1600,39 @@ static enum da7213_micbias_voltage | |||
1600 | case 3000: | 1600 | case 3000: |
1601 | return DA7213_MICBIAS_3_0V; | 1601 | return DA7213_MICBIAS_3_0V; |
1602 | default: | 1602 | default: |
1603 | dev_warn(codec->dev, "Invalid micbias level\n"); | 1603 | dev_warn(component->dev, "Invalid micbias level\n"); |
1604 | return DA7213_MICBIAS_2_2V; | 1604 | return DA7213_MICBIAS_2_2V; |
1605 | } | 1605 | } |
1606 | } | 1606 | } |
1607 | 1607 | ||
1608 | static enum da7213_dmic_data_sel | 1608 | static enum da7213_dmic_data_sel |
1609 | da7213_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) | 1609 | da7213_of_dmic_data_sel(struct snd_soc_component *component, const char *str) |
1610 | { | 1610 | { |
1611 | if (!strcmp(str, "lrise_rfall")) { | 1611 | if (!strcmp(str, "lrise_rfall")) { |
1612 | return DA7213_DMIC_DATA_LRISE_RFALL; | 1612 | return DA7213_DMIC_DATA_LRISE_RFALL; |
1613 | } else if (!strcmp(str, "lfall_rrise")) { | 1613 | } else if (!strcmp(str, "lfall_rrise")) { |
1614 | return DA7213_DMIC_DATA_LFALL_RRISE; | 1614 | return DA7213_DMIC_DATA_LFALL_RRISE; |
1615 | } else { | 1615 | } else { |
1616 | dev_warn(codec->dev, "Invalid DMIC data select type\n"); | 1616 | dev_warn(component->dev, "Invalid DMIC data select type\n"); |
1617 | return DA7213_DMIC_DATA_LRISE_RFALL; | 1617 | return DA7213_DMIC_DATA_LRISE_RFALL; |
1618 | } | 1618 | } |
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | static enum da7213_dmic_samplephase | 1621 | static enum da7213_dmic_samplephase |
1622 | da7213_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) | 1622 | da7213_of_dmic_samplephase(struct snd_soc_component *component, const char *str) |
1623 | { | 1623 | { |
1624 | if (!strcmp(str, "on_clkedge")) { | 1624 | if (!strcmp(str, "on_clkedge")) { |
1625 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; | 1625 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; |
1626 | } else if (!strcmp(str, "between_clkedge")) { | 1626 | } else if (!strcmp(str, "between_clkedge")) { |
1627 | return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE; | 1627 | return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE; |
1628 | } else { | 1628 | } else { |
1629 | dev_warn(codec->dev, "Invalid DMIC sample phase\n"); | 1629 | dev_warn(component->dev, "Invalid DMIC sample phase\n"); |
1630 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; | 1630 | return DA7213_DMIC_SAMPLE_ON_CLKEDGE; |
1631 | } | 1631 | } |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | static enum da7213_dmic_clk_rate | 1634 | static enum da7213_dmic_clk_rate |
1635 | da7213_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) | 1635 | da7213_of_dmic_clkrate(struct snd_soc_component *component, u32 val) |
1636 | { | 1636 | { |
1637 | switch (val) { | 1637 | switch (val) { |
1638 | case 1500000: | 1638 | case 1500000: |
@@ -1640,46 +1640,46 @@ static enum da7213_dmic_clk_rate | |||
1640 | case 3000000: | 1640 | case 3000000: |
1641 | return DA7213_DMIC_CLK_3_0MHZ; | 1641 | return DA7213_DMIC_CLK_3_0MHZ; |
1642 | default: | 1642 | default: |
1643 | dev_warn(codec->dev, "Invalid DMIC clock rate\n"); | 1643 | dev_warn(component->dev, "Invalid DMIC clock rate\n"); |
1644 | return DA7213_DMIC_CLK_1_5MHZ; | 1644 | return DA7213_DMIC_CLK_1_5MHZ; |
1645 | } | 1645 | } |
1646 | } | 1646 | } |
1647 | 1647 | ||
1648 | static struct da7213_platform_data | 1648 | static struct da7213_platform_data |
1649 | *da7213_fw_to_pdata(struct snd_soc_codec *codec) | 1649 | *da7213_fw_to_pdata(struct snd_soc_component *component) |
1650 | { | 1650 | { |
1651 | struct device *dev = codec->dev; | 1651 | struct device *dev = component->dev; |
1652 | struct da7213_platform_data *pdata; | 1652 | struct da7213_platform_data *pdata; |
1653 | const char *fw_str; | 1653 | const char *fw_str; |
1654 | u32 fw_val32; | 1654 | u32 fw_val32; |
1655 | 1655 | ||
1656 | pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); | 1656 | pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); |
1657 | if (!pdata) | 1657 | if (!pdata) |
1658 | return NULL; | 1658 | return NULL; |
1659 | 1659 | ||
1660 | if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) | 1660 | if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) |
1661 | pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, fw_val32); | 1661 | pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); |
1662 | else | 1662 | else |
1663 | pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; | 1663 | pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; |
1664 | 1664 | ||
1665 | if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) | 1665 | if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) |
1666 | pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, fw_val32); | 1666 | pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); |
1667 | else | 1667 | else |
1668 | pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; | 1668 | pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; |
1669 | 1669 | ||
1670 | if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) | 1670 | if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) |
1671 | pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, fw_str); | 1671 | pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); |
1672 | else | 1672 | else |
1673 | pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; | 1673 | pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; |
1674 | 1674 | ||
1675 | if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) | 1675 | if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) |
1676 | pdata->dmic_samplephase = | 1676 | pdata->dmic_samplephase = |
1677 | da7213_of_dmic_samplephase(codec, fw_str); | 1677 | da7213_of_dmic_samplephase(component, fw_str); |
1678 | else | 1678 | else |
1679 | pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; | 1679 | pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; |
1680 | 1680 | ||
1681 | if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) | 1681 | if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) |
1682 | pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, fw_val32); | 1682 | pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); |
1683 | else | 1683 | else |
1684 | pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; | 1684 | pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; |
1685 | 1685 | ||
@@ -1687,41 +1687,41 @@ static struct da7213_platform_data | |||
1687 | } | 1687 | } |
1688 | 1688 | ||
1689 | 1689 | ||
1690 | static int da7213_probe(struct snd_soc_codec *codec) | 1690 | static int da7213_probe(struct snd_soc_component *component) |
1691 | { | 1691 | { |
1692 | struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); | 1692 | struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); |
1693 | 1693 | ||
1694 | /* Default to using ALC auto offset calibration mode. */ | 1694 | /* Default to using ALC auto offset calibration mode. */ |
1695 | snd_soc_update_bits(codec, DA7213_ALC_CTRL1, | 1695 | snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, |
1696 | DA7213_ALC_CALIB_MODE_MAN, 0); | 1696 | DA7213_ALC_CALIB_MODE_MAN, 0); |
1697 | da7213->alc_calib_auto = true; | 1697 | da7213->alc_calib_auto = true; |
1698 | 1698 | ||
1699 | /* Default PC counter to free-running */ | 1699 | /* Default PC counter to free-running */ |
1700 | snd_soc_update_bits(codec, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, | 1700 | snd_soc_component_update_bits(component, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, |
1701 | DA7213_PC_FREERUN_MASK); | 1701 | DA7213_PC_FREERUN_MASK); |
1702 | 1702 | ||
1703 | /* Enable all Gain Ramps */ | 1703 | /* Enable all Gain Ramps */ |
1704 | snd_soc_update_bits(codec, DA7213_AUX_L_CTRL, | 1704 | snd_soc_component_update_bits(component, DA7213_AUX_L_CTRL, |
1705 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1705 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1706 | snd_soc_update_bits(codec, DA7213_AUX_R_CTRL, | 1706 | snd_soc_component_update_bits(component, DA7213_AUX_R_CTRL, |
1707 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1707 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1708 | snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, | 1708 | snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL, |
1709 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1709 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1710 | snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, | 1710 | snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL, |
1711 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1711 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1712 | snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, | 1712 | snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL, |
1713 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1713 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1714 | snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, | 1714 | snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL, |
1715 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1715 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1716 | snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, | 1716 | snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, |
1717 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1717 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1718 | snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, | 1718 | snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, |
1719 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1719 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1720 | snd_soc_update_bits(codec, DA7213_HP_L_CTRL, | 1720 | snd_soc_component_update_bits(component, DA7213_HP_L_CTRL, |
1721 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1721 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1722 | snd_soc_update_bits(codec, DA7213_HP_R_CTRL, | 1722 | snd_soc_component_update_bits(component, DA7213_HP_R_CTRL, |
1723 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1723 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1724 | snd_soc_update_bits(codec, DA7213_LINE_CTRL, | 1724 | snd_soc_component_update_bits(component, DA7213_LINE_CTRL, |
1725 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); | 1725 | DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); |
1726 | 1726 | ||
1727 | /* | 1727 | /* |
@@ -1732,28 +1732,28 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1732 | * being managed by DAPM while other (non power related) bits are | 1732 | * being managed by DAPM while other (non power related) bits are |
1733 | * enabled here | 1733 | * enabled here |
1734 | */ | 1734 | */ |
1735 | snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, | 1735 | snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL, |
1736 | DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); | 1736 | DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); |
1737 | snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, | 1737 | snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL, |
1738 | DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); | 1738 | DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); |
1739 | 1739 | ||
1740 | snd_soc_update_bits(codec, DA7213_MIXOUT_L_CTRL, | 1740 | snd_soc_component_update_bits(component, DA7213_MIXOUT_L_CTRL, |
1741 | DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); | 1741 | DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); |
1742 | snd_soc_update_bits(codec, DA7213_MIXOUT_R_CTRL, | 1742 | snd_soc_component_update_bits(component, DA7213_MIXOUT_R_CTRL, |
1743 | DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); | 1743 | DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); |
1744 | 1744 | ||
1745 | snd_soc_update_bits(codec, DA7213_HP_L_CTRL, | 1745 | snd_soc_component_update_bits(component, DA7213_HP_L_CTRL, |
1746 | DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); | 1746 | DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); |
1747 | snd_soc_update_bits(codec, DA7213_HP_R_CTRL, | 1747 | snd_soc_component_update_bits(component, DA7213_HP_R_CTRL, |
1748 | DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); | 1748 | DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); |
1749 | 1749 | ||
1750 | snd_soc_update_bits(codec, DA7213_LINE_CTRL, | 1750 | snd_soc_component_update_bits(component, DA7213_LINE_CTRL, |
1751 | DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); | 1751 | DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); |
1752 | 1752 | ||
1753 | /* Handle DT/Platform data */ | 1753 | /* Handle DT/Platform data */ |
1754 | da7213->pdata = dev_get_platdata(codec->dev); | 1754 | da7213->pdata = dev_get_platdata(component->dev); |
1755 | if (!da7213->pdata) | 1755 | if (!da7213->pdata) |
1756 | da7213->pdata = da7213_fw_to_pdata(codec); | 1756 | da7213->pdata = da7213_fw_to_pdata(component); |
1757 | 1757 | ||
1758 | /* Set platform data values */ | 1758 | /* Set platform data values */ |
1759 | if (da7213->pdata) { | 1759 | if (da7213->pdata) { |
@@ -1779,7 +1779,7 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1779 | DA7213_MICBIAS2_LEVEL_SHIFT); | 1779 | DA7213_MICBIAS2_LEVEL_SHIFT); |
1780 | break; | 1780 | break; |
1781 | } | 1781 | } |
1782 | snd_soc_update_bits(codec, DA7213_MICBIAS_CTRL, | 1782 | snd_soc_component_update_bits(component, DA7213_MICBIAS_CTRL, |
1783 | DA7213_MICBIAS1_LEVEL_MASK | | 1783 | DA7213_MICBIAS1_LEVEL_MASK | |
1784 | DA7213_MICBIAS2_LEVEL_MASK, micbias_lvl); | 1784 | DA7213_MICBIAS2_LEVEL_MASK, micbias_lvl); |
1785 | 1785 | ||
@@ -1805,14 +1805,14 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1805 | DA7213_DMIC_CLK_RATE_SHIFT); | 1805 | DA7213_DMIC_CLK_RATE_SHIFT); |
1806 | break; | 1806 | break; |
1807 | } | 1807 | } |
1808 | snd_soc_update_bits(codec, DA7213_MIC_CONFIG, | 1808 | snd_soc_component_update_bits(component, DA7213_MIC_CONFIG, |
1809 | DA7213_DMIC_DATA_SEL_MASK | | 1809 | DA7213_DMIC_DATA_SEL_MASK | |
1810 | DA7213_DMIC_SAMPLEPHASE_MASK | | 1810 | DA7213_DMIC_SAMPLEPHASE_MASK | |
1811 | DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); | 1811 | DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); |
1812 | } | 1812 | } |
1813 | 1813 | ||
1814 | /* Check if MCLK provided */ | 1814 | /* Check if MCLK provided */ |
1815 | da7213->mclk = devm_clk_get(codec->dev, "mclk"); | 1815 | da7213->mclk = devm_clk_get(component->dev, "mclk"); |
1816 | if (IS_ERR(da7213->mclk)) { | 1816 | if (IS_ERR(da7213->mclk)) { |
1817 | if (PTR_ERR(da7213->mclk) != -ENOENT) | 1817 | if (PTR_ERR(da7213->mclk) != -ENOENT) |
1818 | return PTR_ERR(da7213->mclk); | 1818 | return PTR_ERR(da7213->mclk); |
@@ -1823,18 +1823,19 @@ static int da7213_probe(struct snd_soc_codec *codec) | |||
1823 | return 0; | 1823 | return 0; |
1824 | } | 1824 | } |
1825 | 1825 | ||
1826 | static const struct snd_soc_codec_driver soc_codec_dev_da7213 = { | 1826 | static const struct snd_soc_component_driver soc_component_dev_da7213 = { |
1827 | .probe = da7213_probe, | 1827 | .probe = da7213_probe, |
1828 | .set_bias_level = da7213_set_bias_level, | 1828 | .set_bias_level = da7213_set_bias_level, |
1829 | 1829 | .controls = da7213_snd_controls, | |
1830 | .component_driver = { | 1830 | .num_controls = ARRAY_SIZE(da7213_snd_controls), |
1831 | .controls = da7213_snd_controls, | 1831 | .dapm_widgets = da7213_dapm_widgets, |
1832 | .num_controls = ARRAY_SIZE(da7213_snd_controls), | 1832 | .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets), |
1833 | .dapm_widgets = da7213_dapm_widgets, | 1833 | .dapm_routes = da7213_audio_map, |
1834 | .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets), | 1834 | .num_dapm_routes = ARRAY_SIZE(da7213_audio_map), |
1835 | .dapm_routes = da7213_audio_map, | 1835 | .idle_bias_on = 1, |
1836 | .num_dapm_routes = ARRAY_SIZE(da7213_audio_map), | 1836 | .use_pmdown_time = 1, |
1837 | }, | 1837 | .endianness = 1, |
1838 | .non_legacy_dai_naming = 1, | ||
1838 | }; | 1839 | }; |
1839 | 1840 | ||
1840 | static const struct regmap_config da7213_regmap_config = { | 1841 | static const struct regmap_config da7213_regmap_config = { |
@@ -1866,21 +1867,15 @@ static int da7213_i2c_probe(struct i2c_client *i2c, | |||
1866 | return ret; | 1867 | return ret; |
1867 | } | 1868 | } |
1868 | 1869 | ||
1869 | ret = snd_soc_register_codec(&i2c->dev, | 1870 | ret = devm_snd_soc_register_component(&i2c->dev, |
1870 | &soc_codec_dev_da7213, &da7213_dai, 1); | 1871 | &soc_component_dev_da7213, &da7213_dai, 1); |
1871 | if (ret < 0) { | 1872 | if (ret < 0) { |
1872 | dev_err(&i2c->dev, "Failed to register da7213 codec: %d\n", | 1873 | dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", |
1873 | ret); | 1874 | ret); |
1874 | } | 1875 | } |
1875 | return ret; | 1876 | return ret; |
1876 | } | 1877 | } |
1877 | 1878 | ||
1878 | static int da7213_remove(struct i2c_client *client) | ||
1879 | { | ||
1880 | snd_soc_unregister_codec(&client->dev); | ||
1881 | return 0; | ||
1882 | } | ||
1883 | |||
1884 | static const struct i2c_device_id da7213_i2c_id[] = { | 1879 | static const struct i2c_device_id da7213_i2c_id[] = { |
1885 | { "da7213", 0 }, | 1880 | { "da7213", 0 }, |
1886 | { } | 1881 | { } |
@@ -1895,7 +1890,6 @@ static struct i2c_driver da7213_i2c_driver = { | |||
1895 | .acpi_match_table = ACPI_PTR(da7213_acpi_match), | 1890 | .acpi_match_table = ACPI_PTR(da7213_acpi_match), |
1896 | }, | 1891 | }, |
1897 | .probe = da7213_i2c_probe, | 1892 | .probe = da7213_i2c_probe, |
1898 | .remove = da7213_remove, | ||
1899 | .id_table = da7213_i2c_id, | 1893 | .id_table = da7213_i2c_id, |
1900 | }; | 1894 | }; |
1901 | 1895 | ||
diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c index 96c644a15b11..ddc90ac0b19f 100644 --- a/sound/soc/codecs/da7218.c +++ b/sound/soc/codecs/da7218.c | |||
@@ -291,7 +291,7 @@ static const struct soc_enum da7218_cp_tau_delay = | |||
291 | */ | 291 | */ |
292 | 292 | ||
293 | /* ALC */ | 293 | /* ALC */ |
294 | static void da7218_alc_calib(struct snd_soc_codec *codec) | 294 | static void da7218_alc_calib(struct snd_soc_component *component) |
295 | { | 295 | { |
296 | u8 mic_1_ctrl, mic_2_ctrl; | 296 | u8 mic_1_ctrl, mic_2_ctrl; |
297 | u8 mixin_1_ctrl, mixin_2_ctrl; | 297 | u8 mixin_1_ctrl, mixin_2_ctrl; |
@@ -302,59 +302,59 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) | |||
302 | bool calibrated = false; | 302 | bool calibrated = false; |
303 | 303 | ||
304 | /* Save current state of MIC control registers */ | 304 | /* Save current state of MIC control registers */ |
305 | mic_1_ctrl = snd_soc_read(codec, DA7218_MIC_1_CTRL); | 305 | mic_1_ctrl = snd_soc_component_read32(component, DA7218_MIC_1_CTRL); |
306 | mic_2_ctrl = snd_soc_read(codec, DA7218_MIC_2_CTRL); | 306 | mic_2_ctrl = snd_soc_component_read32(component, DA7218_MIC_2_CTRL); |
307 | 307 | ||
308 | /* Save current state of input mixer control registers */ | 308 | /* Save current state of input mixer control registers */ |
309 | mixin_1_ctrl = snd_soc_read(codec, DA7218_MIXIN_1_CTRL); | 309 | mixin_1_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_1_CTRL); |
310 | mixin_2_ctrl = snd_soc_read(codec, DA7218_MIXIN_2_CTRL); | 310 | mixin_2_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_2_CTRL); |
311 | 311 | ||
312 | /* Save current state of input filter control registers */ | 312 | /* Save current state of input filter control registers */ |
313 | in_1l_filt_ctrl = snd_soc_read(codec, DA7218_IN_1L_FILTER_CTRL); | 313 | in_1l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1L_FILTER_CTRL); |
314 | in_1r_filt_ctrl = snd_soc_read(codec, DA7218_IN_1R_FILTER_CTRL); | 314 | in_1r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1R_FILTER_CTRL); |
315 | in_2l_filt_ctrl = snd_soc_read(codec, DA7218_IN_2L_FILTER_CTRL); | 315 | in_2l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2L_FILTER_CTRL); |
316 | in_2r_filt_ctrl = snd_soc_read(codec, DA7218_IN_2R_FILTER_CTRL); | 316 | in_2r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2R_FILTER_CTRL); |
317 | 317 | ||
318 | /* Save current state of input HPF control registers */ | 318 | /* Save current state of input HPF control registers */ |
319 | in_1_hpf_ctrl = snd_soc_read(codec, DA7218_IN_1_HPF_FILTER_CTRL); | 319 | in_1_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_1_HPF_FILTER_CTRL); |
320 | in_2_hpf_ctrl = snd_soc_read(codec, DA7218_IN_2_HPF_FILTER_CTRL); | 320 | in_2_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_2_HPF_FILTER_CTRL); |
321 | 321 | ||
322 | /* Enable then Mute MIC PGAs */ | 322 | /* Enable then Mute MIC PGAs */ |
323 | snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK, | 323 | snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK, |
324 | DA7218_MIC_1_AMP_EN_MASK); | 324 | DA7218_MIC_1_AMP_EN_MASK); |
325 | snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK, | 325 | snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK, |
326 | DA7218_MIC_2_AMP_EN_MASK); | 326 | DA7218_MIC_2_AMP_EN_MASK); |
327 | snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, | 327 | snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL, |
328 | DA7218_MIC_1_AMP_MUTE_EN_MASK, | 328 | DA7218_MIC_1_AMP_MUTE_EN_MASK, |
329 | DA7218_MIC_1_AMP_MUTE_EN_MASK); | 329 | DA7218_MIC_1_AMP_MUTE_EN_MASK); |
330 | snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, | 330 | snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL, |
331 | DA7218_MIC_2_AMP_MUTE_EN_MASK, | 331 | DA7218_MIC_2_AMP_MUTE_EN_MASK, |
332 | DA7218_MIC_2_AMP_MUTE_EN_MASK); | 332 | DA7218_MIC_2_AMP_MUTE_EN_MASK); |
333 | 333 | ||
334 | /* Enable input mixers unmuted */ | 334 | /* Enable input mixers unmuted */ |
335 | snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, | 335 | snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL, |
336 | DA7218_MIXIN_1_AMP_EN_MASK | | 336 | DA7218_MIXIN_1_AMP_EN_MASK | |
337 | DA7218_MIXIN_1_AMP_MUTE_EN_MASK, | 337 | DA7218_MIXIN_1_AMP_MUTE_EN_MASK, |
338 | DA7218_MIXIN_1_AMP_EN_MASK); | 338 | DA7218_MIXIN_1_AMP_EN_MASK); |
339 | snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, | 339 | snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL, |
340 | DA7218_MIXIN_2_AMP_EN_MASK | | 340 | DA7218_MIXIN_2_AMP_EN_MASK | |
341 | DA7218_MIXIN_2_AMP_MUTE_EN_MASK, | 341 | DA7218_MIXIN_2_AMP_MUTE_EN_MASK, |
342 | DA7218_MIXIN_2_AMP_EN_MASK); | 342 | DA7218_MIXIN_2_AMP_EN_MASK); |
343 | 343 | ||
344 | /* Enable input filters unmuted */ | 344 | /* Enable input filters unmuted */ |
345 | snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, | 345 | snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL, |
346 | DA7218_IN_1L_FILTER_EN_MASK | | 346 | DA7218_IN_1L_FILTER_EN_MASK | |
347 | DA7218_IN_1L_MUTE_EN_MASK, | 347 | DA7218_IN_1L_MUTE_EN_MASK, |
348 | DA7218_IN_1L_FILTER_EN_MASK); | 348 | DA7218_IN_1L_FILTER_EN_MASK); |
349 | snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, | 349 | snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL, |
350 | DA7218_IN_1R_FILTER_EN_MASK | | 350 | DA7218_IN_1R_FILTER_EN_MASK | |
351 | DA7218_IN_1R_MUTE_EN_MASK, | 351 | DA7218_IN_1R_MUTE_EN_MASK, |
352 | DA7218_IN_1R_FILTER_EN_MASK); | 352 | DA7218_IN_1R_FILTER_EN_MASK); |
353 | snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, | 353 | snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL, |
354 | DA7218_IN_2L_FILTER_EN_MASK | | 354 | DA7218_IN_2L_FILTER_EN_MASK | |
355 | DA7218_IN_2L_MUTE_EN_MASK, | 355 | DA7218_IN_2L_MUTE_EN_MASK, |
356 | DA7218_IN_2L_FILTER_EN_MASK); | 356 | DA7218_IN_2L_FILTER_EN_MASK); |
357 | snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, | 357 | snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL, |
358 | DA7218_IN_2R_FILTER_EN_MASK | | 358 | DA7218_IN_2R_FILTER_EN_MASK | |
359 | DA7218_IN_2R_MUTE_EN_MASK, | 359 | DA7218_IN_2R_MUTE_EN_MASK, |
360 | DA7218_IN_2R_FILTER_EN_MASK); | 360 | DA7218_IN_2R_FILTER_EN_MASK); |
@@ -364,16 +364,16 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) | |||
364 | * rates above 32KHz the ADC signals will be stopped and will cause | 364 | * rates above 32KHz the ADC signals will be stopped and will cause |
365 | * calibration to lock up. | 365 | * calibration to lock up. |
366 | */ | 366 | */ |
367 | snd_soc_update_bits(codec, DA7218_IN_1_HPF_FILTER_CTRL, | 367 | snd_soc_component_update_bits(component, DA7218_IN_1_HPF_FILTER_CTRL, |
368 | DA7218_IN_1_VOICE_EN_MASK, 0); | 368 | DA7218_IN_1_VOICE_EN_MASK, 0); |
369 | snd_soc_update_bits(codec, DA7218_IN_2_HPF_FILTER_CTRL, | 369 | snd_soc_component_update_bits(component, DA7218_IN_2_HPF_FILTER_CTRL, |
370 | DA7218_IN_2_VOICE_EN_MASK, 0); | 370 | DA7218_IN_2_VOICE_EN_MASK, 0); |
371 | 371 | ||
372 | /* Perform auto calibration */ | 372 | /* Perform auto calibration */ |
373 | snd_soc_update_bits(codec, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK, | 373 | snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK, |
374 | DA7218_CALIB_AUTO_EN_MASK); | 374 | DA7218_CALIB_AUTO_EN_MASK); |
375 | do { | 375 | do { |
376 | calib_ctrl = snd_soc_read(codec, DA7218_CALIB_CTRL); | 376 | calib_ctrl = snd_soc_component_read32(component, DA7218_CALIB_CTRL); |
377 | if (calib_ctrl & DA7218_CALIB_AUTO_EN_MASK) { | 377 | if (calib_ctrl & DA7218_CALIB_AUTO_EN_MASK) { |
378 | ++i; | 378 | ++i; |
379 | usleep_range(DA7218_ALC_CALIB_DELAY_MIN, | 379 | usleep_range(DA7218_ALC_CALIB_DELAY_MIN, |
@@ -386,51 +386,51 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) | |||
386 | 386 | ||
387 | /* If auto calibration fails, disable DC offset, hybrid ALC */ | 387 | /* If auto calibration fails, disable DC offset, hybrid ALC */ |
388 | if ((!calibrated) || (calib_ctrl & DA7218_CALIB_OVERFLOW_MASK)) { | 388 | if ((!calibrated) || (calib_ctrl & DA7218_CALIB_OVERFLOW_MASK)) { |
389 | dev_warn(codec->dev, | 389 | dev_warn(component->dev, |
390 | "ALC auto calibration failed - %s\n", | 390 | "ALC auto calibration failed - %s\n", |
391 | (calibrated) ? "overflow" : "timeout"); | 391 | (calibrated) ? "overflow" : "timeout"); |
392 | snd_soc_update_bits(codec, DA7218_CALIB_CTRL, | 392 | snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, |
393 | DA7218_CALIB_OFFSET_EN_MASK, 0); | 393 | DA7218_CALIB_OFFSET_EN_MASK, 0); |
394 | snd_soc_update_bits(codec, DA7218_ALC_CTRL1, | 394 | snd_soc_component_update_bits(component, DA7218_ALC_CTRL1, |
395 | DA7218_ALC_SYNC_MODE_MASK, 0); | 395 | DA7218_ALC_SYNC_MODE_MASK, 0); |
396 | 396 | ||
397 | } else { | 397 | } else { |
398 | /* Enable DC offset cancellation */ | 398 | /* Enable DC offset cancellation */ |
399 | snd_soc_update_bits(codec, DA7218_CALIB_CTRL, | 399 | snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, |
400 | DA7218_CALIB_OFFSET_EN_MASK, | 400 | DA7218_CALIB_OFFSET_EN_MASK, |
401 | DA7218_CALIB_OFFSET_EN_MASK); | 401 | DA7218_CALIB_OFFSET_EN_MASK); |
402 | 402 | ||
403 | /* Enable ALC hybrid mode */ | 403 | /* Enable ALC hybrid mode */ |
404 | snd_soc_update_bits(codec, DA7218_ALC_CTRL1, | 404 | snd_soc_component_update_bits(component, DA7218_ALC_CTRL1, |
405 | DA7218_ALC_SYNC_MODE_MASK, | 405 | DA7218_ALC_SYNC_MODE_MASK, |
406 | DA7218_ALC_SYNC_MODE_CH1 | | 406 | DA7218_ALC_SYNC_MODE_CH1 | |
407 | DA7218_ALC_SYNC_MODE_CH2); | 407 | DA7218_ALC_SYNC_MODE_CH2); |
408 | } | 408 | } |
409 | 409 | ||
410 | /* Restore input HPF control registers to original states */ | 410 | /* Restore input HPF control registers to original states */ |
411 | snd_soc_write(codec, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl); | 411 | snd_soc_component_write(component, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl); |
412 | snd_soc_write(codec, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl); | 412 | snd_soc_component_write(component, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl); |
413 | 413 | ||
414 | /* Restore input filter control registers to original states */ | 414 | /* Restore input filter control registers to original states */ |
415 | snd_soc_write(codec, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl); | 415 | snd_soc_component_write(component, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl); |
416 | snd_soc_write(codec, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl); | 416 | snd_soc_component_write(component, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl); |
417 | snd_soc_write(codec, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl); | 417 | snd_soc_component_write(component, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl); |
418 | snd_soc_write(codec, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl); | 418 | snd_soc_component_write(component, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl); |
419 | 419 | ||
420 | /* Restore input mixer control registers to original state */ | 420 | /* Restore input mixer control registers to original state */ |
421 | snd_soc_write(codec, DA7218_MIXIN_1_CTRL, mixin_1_ctrl); | 421 | snd_soc_component_write(component, DA7218_MIXIN_1_CTRL, mixin_1_ctrl); |
422 | snd_soc_write(codec, DA7218_MIXIN_2_CTRL, mixin_2_ctrl); | 422 | snd_soc_component_write(component, DA7218_MIXIN_2_CTRL, mixin_2_ctrl); |
423 | 423 | ||
424 | /* Restore MIC control registers to original states */ | 424 | /* Restore MIC control registers to original states */ |
425 | snd_soc_write(codec, DA7218_MIC_1_CTRL, mic_1_ctrl); | 425 | snd_soc_component_write(component, DA7218_MIC_1_CTRL, mic_1_ctrl); |
426 | snd_soc_write(codec, DA7218_MIC_2_CTRL, mic_2_ctrl); | 426 | snd_soc_component_write(component, DA7218_MIC_2_CTRL, mic_2_ctrl); |
427 | } | 427 | } |
428 | 428 | ||
429 | static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, | 429 | static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, |
430 | struct snd_ctl_elem_value *ucontrol) | 430 | struct snd_ctl_elem_value *ucontrol) |
431 | { | 431 | { |
432 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 432 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
433 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 433 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
434 | int ret; | 434 | int ret; |
435 | 435 | ||
436 | ret = snd_soc_put_volsw(kcontrol, ucontrol); | 436 | ret = snd_soc_put_volsw(kcontrol, ucontrol); |
@@ -440,7 +440,7 @@ static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, | |||
440 | * make sure calibrated offsets are updated. | 440 | * make sure calibrated offsets are updated. |
441 | */ | 441 | */ |
442 | if ((ret == 1) && (da7218->alc_en)) | 442 | if ((ret == 1) && (da7218->alc_en)) |
443 | da7218_alc_calib(codec); | 443 | da7218_alc_calib(component); |
444 | 444 | ||
445 | return ret; | 445 | return ret; |
446 | } | 446 | } |
@@ -450,8 +450,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, | |||
450 | { | 450 | { |
451 | struct soc_mixer_control *mc = | 451 | struct soc_mixer_control *mc = |
452 | (struct soc_mixer_control *) kcontrol->private_value; | 452 | (struct soc_mixer_control *) kcontrol->private_value; |
453 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 453 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
454 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 454 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
455 | unsigned int lvalue = ucontrol->value.integer.value[0]; | 455 | unsigned int lvalue = ucontrol->value.integer.value[0]; |
456 | unsigned int rvalue = ucontrol->value.integer.value[1]; | 456 | unsigned int rvalue = ucontrol->value.integer.value[1]; |
457 | unsigned int lshift = mc->shift; | 457 | unsigned int lshift = mc->shift; |
@@ -460,7 +460,7 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, | |||
460 | 460 | ||
461 | /* Force ALC offset calibration if enabling ALC */ | 461 | /* Force ALC offset calibration if enabling ALC */ |
462 | if ((lvalue || rvalue) && (!da7218->alc_en)) | 462 | if ((lvalue || rvalue) && (!da7218->alc_en)) |
463 | da7218_alc_calib(codec); | 463 | da7218_alc_calib(component); |
464 | 464 | ||
465 | /* Update bits to detail which channels are enabled/disabled */ | 465 | /* Update bits to detail which channels are enabled/disabled */ |
466 | da7218->alc_en &= ~mask; | 466 | da7218->alc_en &= ~mask; |
@@ -473,8 +473,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, | |||
473 | static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, | 473 | static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, |
474 | struct snd_ctl_elem_value *ucontrol) | 474 | struct snd_ctl_elem_value *ucontrol) |
475 | { | 475 | { |
476 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 476 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
477 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 477 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
478 | struct soc_mixer_control *mixer_ctrl = | 478 | struct soc_mixer_control *mixer_ctrl = |
479 | (struct soc_mixer_control *) kcontrol->private_value; | 479 | (struct soc_mixer_control *) kcontrol->private_value; |
480 | unsigned int reg = mixer_ctrl->reg; | 480 | unsigned int reg = mixer_ctrl->reg; |
@@ -497,8 +497,8 @@ static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, | |||
497 | static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, | 497 | static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, |
498 | struct snd_ctl_elem_value *ucontrol) | 498 | struct snd_ctl_elem_value *ucontrol) |
499 | { | 499 | { |
500 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 500 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
501 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 501 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
502 | struct soc_mixer_control *mixer_ctrl = | 502 | struct soc_mixer_control *mixer_ctrl = |
503 | (struct soc_mixer_control *) kcontrol->private_value; | 503 | (struct soc_mixer_control *) kcontrol->private_value; |
504 | unsigned int reg = mixer_ctrl->reg; | 504 | unsigned int reg = mixer_ctrl->reg; |
@@ -517,8 +517,8 @@ static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, | |||
517 | static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, | 517 | static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, |
518 | struct snd_ctl_elem_value *ucontrol) | 518 | struct snd_ctl_elem_value *ucontrol) |
519 | { | 519 | { |
520 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 520 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
521 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 521 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
522 | struct soc_mixer_control *mixer_ctrl = | 522 | struct soc_mixer_control *mixer_ctrl = |
523 | (struct soc_mixer_control *) kcontrol->private_value; | 523 | (struct soc_mixer_control *) kcontrol->private_value; |
524 | unsigned int lvalue = ucontrol->value.integer.value[0]; | 524 | unsigned int lvalue = ucontrol->value.integer.value[0]; |
@@ -537,15 +537,15 @@ static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, | |||
537 | * power the path (IN_FILTER widget events). This handling avoids | 537 | * power the path (IN_FILTER widget events). This handling avoids |
538 | * unwanted level detect events. | 538 | * unwanted level detect events. |
539 | */ | 539 | */ |
540 | return snd_soc_write(codec, mixer_ctrl->reg, | 540 | return snd_soc_component_write(component, mixer_ctrl->reg, |
541 | (da7218->in_filt_en & da7218->mic_lvl_det_en)); | 541 | (da7218->in_filt_en & da7218->mic_lvl_det_en)); |
542 | } | 542 | } |
543 | 543 | ||
544 | static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, | 544 | static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, |
545 | struct snd_ctl_elem_value *ucontrol) | 545 | struct snd_ctl_elem_value *ucontrol) |
546 | { | 546 | { |
547 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 547 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
548 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 548 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
549 | struct soc_mixer_control *mixer_ctrl = | 549 | struct soc_mixer_control *mixer_ctrl = |
550 | (struct soc_mixer_control *) kcontrol->private_value; | 550 | (struct soc_mixer_control *) kcontrol->private_value; |
551 | unsigned int lshift = mixer_ctrl->shift; | 551 | unsigned int lshift = mixer_ctrl->shift; |
@@ -564,8 +564,8 @@ static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, | |||
564 | static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, | 564 | static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, |
565 | struct snd_ctl_elem_value *ucontrol) | 565 | struct snd_ctl_elem_value *ucontrol) |
566 | { | 566 | { |
567 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 567 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
568 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 568 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
569 | struct soc_bytes_ext *bytes_ext = | 569 | struct soc_bytes_ext *bytes_ext = |
570 | (struct soc_bytes_ext *) kcontrol->private_value; | 570 | (struct soc_bytes_ext *) kcontrol->private_value; |
571 | 571 | ||
@@ -589,8 +589,8 @@ static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, | |||
589 | static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, | 589 | static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, |
590 | struct snd_ctl_elem_value *ucontrol) | 590 | struct snd_ctl_elem_value *ucontrol) |
591 | { | 591 | { |
592 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | 592 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
593 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 593 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
594 | struct soc_bytes_ext *bytes_ext = | 594 | struct soc_bytes_ext *bytes_ext = |
595 | (struct soc_bytes_ext *) kcontrol->private_value; | 595 | (struct soc_bytes_ext *) kcontrol->private_value; |
596 | u8 reg, out_filt1l; | 596 | u8 reg, out_filt1l; |
@@ -617,8 +617,8 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, | |||
617 | } | 617 | } |
618 | 618 | ||
619 | /* Make sure at least out filter1 enabled to allow programming */ | 619 | /* Make sure at least out filter1 enabled to allow programming */ |
620 | out_filt1l = snd_soc_read(codec, DA7218_OUT_1L_FILTER_CTRL); | 620 | out_filt1l = snd_soc_component_read32(component, DA7218_OUT_1L_FILTER_CTRL); |
621 | snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, | 621 | snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL, |
622 | out_filt1l | DA7218_OUT_1L_FILTER_EN_MASK); | 622 | out_filt1l | DA7218_OUT_1L_FILTER_EN_MASK); |
623 | 623 | ||
624 | for (i = 0; i < bytes_ext->max; ++i) { | 624 | for (i = 0; i < bytes_ext->max; ++i) { |
@@ -628,7 +628,7 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, | |||
628 | } | 628 | } |
629 | 629 | ||
630 | /* Restore filter to previous setting */ | 630 | /* Restore filter to previous setting */ |
631 | snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, out_filt1l); | 631 | snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL, out_filt1l); |
632 | 632 | ||
633 | return 0; | 633 | return 0; |
634 | } | 634 | } |
@@ -1349,8 +1349,8 @@ static const struct snd_kcontrol_new da7218_st_out_filtr_mix_controls[] = { | |||
1349 | static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, | 1349 | static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, |
1350 | struct snd_kcontrol *kcontrol, int event) | 1350 | struct snd_kcontrol *kcontrol, int event) |
1351 | { | 1351 | { |
1352 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 1352 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
1353 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1353 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1354 | u8 mask; | 1354 | u8 mask; |
1355 | 1355 | ||
1356 | switch (w->reg) { | 1356 | switch (w->reg) { |
@@ -1389,7 +1389,7 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, | |||
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | /* Enable configured level detection paths */ | 1391 | /* Enable configured level detection paths */ |
1392 | snd_soc_write(codec, DA7218_LVL_DET_CTRL, | 1392 | snd_soc_component_write(component, DA7218_LVL_DET_CTRL, |
1393 | (da7218->in_filt_en & da7218->mic_lvl_det_en)); | 1393 | (da7218->in_filt_en & da7218->mic_lvl_det_en)); |
1394 | 1394 | ||
1395 | return 0; | 1395 | return 0; |
@@ -1398,8 +1398,8 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, | |||
1398 | static int da7218_dai_event(struct snd_soc_dapm_widget *w, | 1398 | static int da7218_dai_event(struct snd_soc_dapm_widget *w, |
1399 | struct snd_kcontrol *kcontrol, int event) | 1399 | struct snd_kcontrol *kcontrol, int event) |
1400 | { | 1400 | { |
1401 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 1401 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
1402 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1402 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1403 | u8 pll_ctrl, pll_status, refosc_cal; | 1403 | u8 pll_ctrl, pll_status, refosc_cal; |
1404 | int i; | 1404 | int i; |
1405 | bool success; | 1405 | bool success; |
@@ -1408,14 +1408,14 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1408 | case SND_SOC_DAPM_POST_PMU: | 1408 | case SND_SOC_DAPM_POST_PMU: |
1409 | if (da7218->master) | 1409 | if (da7218->master) |
1410 | /* Enable DAI clks for master mode */ | 1410 | /* Enable DAI clks for master mode */ |
1411 | snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, | 1411 | snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, |
1412 | DA7218_DAI_CLK_EN_MASK, | 1412 | DA7218_DAI_CLK_EN_MASK, |
1413 | DA7218_DAI_CLK_EN_MASK); | 1413 | DA7218_DAI_CLK_EN_MASK); |
1414 | 1414 | ||
1415 | /* Tune reference oscillator */ | 1415 | /* Tune reference oscillator */ |
1416 | snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, | 1416 | snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL, |
1417 | DA7218_PLL_REFOSC_CAL_START_MASK); | 1417 | DA7218_PLL_REFOSC_CAL_START_MASK); |
1418 | snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, | 1418 | snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL, |
1419 | DA7218_PLL_REFOSC_CAL_START_MASK | | 1419 | DA7218_PLL_REFOSC_CAL_START_MASK | |
1420 | DA7218_PLL_REFOSC_CAL_EN_MASK); | 1420 | DA7218_PLL_REFOSC_CAL_EN_MASK); |
1421 | 1421 | ||
@@ -1423,7 +1423,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1423 | i = 0; | 1423 | i = 0; |
1424 | success = false; | 1424 | success = false; |
1425 | do { | 1425 | do { |
1426 | refosc_cal = snd_soc_read(codec, DA7218_PLL_REFOSC_CAL); | 1426 | refosc_cal = snd_soc_component_read32(component, DA7218_PLL_REFOSC_CAL); |
1427 | if (!(refosc_cal & DA7218_PLL_REFOSC_CAL_START_MASK)) { | 1427 | if (!(refosc_cal & DA7218_PLL_REFOSC_CAL_START_MASK)) { |
1428 | success = true; | 1428 | success = true; |
1429 | } else { | 1429 | } else { |
@@ -1434,15 +1434,15 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1434 | } while ((i < DA7218_REF_OSC_CHECK_TRIES) && (!success)); | 1434 | } while ((i < DA7218_REF_OSC_CHECK_TRIES) && (!success)); |
1435 | 1435 | ||
1436 | if (!success) | 1436 | if (!success) |
1437 | dev_warn(codec->dev, | 1437 | dev_warn(component->dev, |
1438 | "Reference oscillator failed calibration\n"); | 1438 | "Reference oscillator failed calibration\n"); |
1439 | 1439 | ||
1440 | /* PC synchronised to DAI */ | 1440 | /* PC synchronised to DAI */ |
1441 | snd_soc_write(codec, DA7218_PC_COUNT, | 1441 | snd_soc_component_write(component, DA7218_PC_COUNT, |
1442 | DA7218_PC_RESYNC_AUTO_MASK); | 1442 | DA7218_PC_RESYNC_AUTO_MASK); |
1443 | 1443 | ||
1444 | /* If SRM not enabled, we don't need to check status */ | 1444 | /* If SRM not enabled, we don't need to check status */ |
1445 | pll_ctrl = snd_soc_read(codec, DA7218_PLL_CTRL); | 1445 | pll_ctrl = snd_soc_component_read32(component, DA7218_PLL_CTRL); |
1446 | if ((pll_ctrl & DA7218_PLL_MODE_MASK) != DA7218_PLL_MODE_SRM) | 1446 | if ((pll_ctrl & DA7218_PLL_MODE_MASK) != DA7218_PLL_MODE_SRM) |
1447 | return 0; | 1447 | return 0; |
1448 | 1448 | ||
@@ -1450,7 +1450,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1450 | i = 0; | 1450 | i = 0; |
1451 | success = false; | 1451 | success = false; |
1452 | do { | 1452 | do { |
1453 | pll_status = snd_soc_read(codec, DA7218_PLL_STATUS); | 1453 | pll_status = snd_soc_component_read32(component, DA7218_PLL_STATUS); |
1454 | if (pll_status & DA7218_PLL_SRM_STATUS_SRM_LOCK) { | 1454 | if (pll_status & DA7218_PLL_SRM_STATUS_SRM_LOCK) { |
1455 | success = true; | 1455 | success = true; |
1456 | } else { | 1456 | } else { |
@@ -1460,16 +1460,16 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1460 | } while ((i < DA7218_SRM_CHECK_TRIES) && (!success)); | 1460 | } while ((i < DA7218_SRM_CHECK_TRIES) && (!success)); |
1461 | 1461 | ||
1462 | if (!success) | 1462 | if (!success) |
1463 | dev_warn(codec->dev, "SRM failed to lock\n"); | 1463 | dev_warn(component->dev, "SRM failed to lock\n"); |
1464 | 1464 | ||
1465 | return 0; | 1465 | return 0; |
1466 | case SND_SOC_DAPM_POST_PMD: | 1466 | case SND_SOC_DAPM_POST_PMD: |
1467 | /* PC free-running */ | 1467 | /* PC free-running */ |
1468 | snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); | 1468 | snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); |
1469 | 1469 | ||
1470 | if (da7218->master) | 1470 | if (da7218->master) |
1471 | /* Disable DAI clks for master mode */ | 1471 | /* Disable DAI clks for master mode */ |
1472 | snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, | 1472 | snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, |
1473 | DA7218_DAI_CLK_EN_MASK, 0); | 1473 | DA7218_DAI_CLK_EN_MASK, 0); |
1474 | 1474 | ||
1475 | return 0; | 1475 | return 0; |
@@ -1481,8 +1481,8 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, | |||
1481 | static int da7218_cp_event(struct snd_soc_dapm_widget *w, | 1481 | static int da7218_cp_event(struct snd_soc_dapm_widget *w, |
1482 | struct snd_kcontrol *kcontrol, int event) | 1482 | struct snd_kcontrol *kcontrol, int event) |
1483 | { | 1483 | { |
1484 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 1484 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
1485 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1485 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1486 | 1486 | ||
1487 | /* | 1487 | /* |
1488 | * If this is DA7217 and we're using single supply for differential | 1488 | * If this is DA7217 and we're using single supply for differential |
@@ -1493,11 +1493,11 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w, | |||
1493 | 1493 | ||
1494 | switch (event) { | 1494 | switch (event) { |
1495 | case SND_SOC_DAPM_PRE_PMU: | 1495 | case SND_SOC_DAPM_PRE_PMU: |
1496 | snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, | 1496 | snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK, |
1497 | DA7218_CP_EN_MASK); | 1497 | DA7218_CP_EN_MASK); |
1498 | return 0; | 1498 | return 0; |
1499 | case SND_SOC_DAPM_PRE_PMD: | 1499 | case SND_SOC_DAPM_PRE_PMD: |
1500 | snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, | 1500 | snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK, |
1501 | 0); | 1501 | 0); |
1502 | return 0; | 1502 | return 0; |
1503 | default: | 1503 | default: |
@@ -1508,17 +1508,17 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w, | |||
1508 | static int da7218_hp_pga_event(struct snd_soc_dapm_widget *w, | 1508 | static int da7218_hp_pga_event(struct snd_soc_dapm_widget *w, |
1509 | struct snd_kcontrol *kcontrol, int event) | 1509 | struct snd_kcontrol *kcontrol, int event) |
1510 | { | 1510 | { |
1511 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); | 1511 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
1512 | 1512 | ||
1513 | switch (event) { | 1513 | switch (event) { |
1514 | case SND_SOC_DAPM_POST_PMU: | 1514 | case SND_SOC_DAPM_POST_PMU: |
1515 | /* Enable headphone output */ | 1515 | /* Enable headphone output */ |
1516 | snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, | 1516 | snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, |
1517 | DA7218_HP_AMP_OE_MASK); | 1517 | DA7218_HP_AMP_OE_MASK); |
1518 | return 0; | 1518 | return 0; |
1519 | case SND_SOC_DAPM_PRE_PMD: | 1519 | case SND_SOC_DAPM_PRE_PMD: |
1520 | /* Headphone output high impedance */ | 1520 | /* Headphone output high impedance */ |
1521 | snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, 0); | 1521 | snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, 0); |
1522 | return 0; | 1522 | return 0; |
1523 | default: | 1523 | default: |
1524 | return -EINVAL; | 1524 | return -EINVAL; |
@@ -1813,8 +1813,8 @@ static const struct snd_soc_dapm_route da7218_audio_map[] = { | |||
1813 | static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, | 1813 | static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, |
1814 | int clk_id, unsigned int freq, int dir) | 1814 | int clk_id, unsigned int freq, int dir) |
1815 | { | 1815 | { |
1816 | struct snd_soc_codec *codec = codec_dai->codec; | 1816 | struct snd_soc_component *component = codec_dai->component; |
1817 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1817 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1818 | int ret; | 1818 | int ret; |
1819 | 1819 | ||
1820 | if (da7218->mclk_rate == freq) | 1820 | if (da7218->mclk_rate == freq) |
@@ -1828,12 +1828,12 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1828 | 1828 | ||
1829 | switch (clk_id) { | 1829 | switch (clk_id) { |
1830 | case DA7218_CLKSRC_MCLK_SQR: | 1830 | case DA7218_CLKSRC_MCLK_SQR: |
1831 | snd_soc_update_bits(codec, DA7218_PLL_CTRL, | 1831 | snd_soc_component_update_bits(component, DA7218_PLL_CTRL, |
1832 | DA7218_PLL_MCLK_SQR_EN_MASK, | 1832 | DA7218_PLL_MCLK_SQR_EN_MASK, |
1833 | DA7218_PLL_MCLK_SQR_EN_MASK); | 1833 | DA7218_PLL_MCLK_SQR_EN_MASK); |
1834 | break; | 1834 | break; |
1835 | case DA7218_CLKSRC_MCLK: | 1835 | case DA7218_CLKSRC_MCLK: |
1836 | snd_soc_update_bits(codec, DA7218_PLL_CTRL, | 1836 | snd_soc_component_update_bits(component, DA7218_PLL_CTRL, |
1837 | DA7218_PLL_MCLK_SQR_EN_MASK, 0); | 1837 | DA7218_PLL_MCLK_SQR_EN_MASK, 0); |
1838 | break; | 1838 | break; |
1839 | default: | 1839 | default: |
@@ -1859,8 +1859,8 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
1859 | static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | 1859 | static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, |
1860 | int source, unsigned int fref, unsigned int fout) | 1860 | int source, unsigned int fref, unsigned int fout) |
1861 | { | 1861 | { |
1862 | struct snd_soc_codec *codec = codec_dai->codec; | 1862 | struct snd_soc_component *component = codec_dai->component; |
1863 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1863 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1864 | 1864 | ||
1865 | u8 pll_ctrl, indiv_bits, indiv; | 1865 | u8 pll_ctrl, indiv_bits, indiv; |
1866 | u8 pll_frac_top, pll_frac_bot, pll_integer; | 1866 | u8 pll_frac_top, pll_frac_bot, pll_integer; |
@@ -1869,7 +1869,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1869 | 1869 | ||
1870 | /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ | 1870 | /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ |
1871 | if (da7218->mclk_rate < 2000000) { | 1871 | if (da7218->mclk_rate < 2000000) { |
1872 | dev_err(codec->dev, "PLL input clock %d below valid range\n", | 1872 | dev_err(component->dev, "PLL input clock %d below valid range\n", |
1873 | da7218->mclk_rate); | 1873 | da7218->mclk_rate); |
1874 | return -EINVAL; | 1874 | return -EINVAL; |
1875 | } else if (da7218->mclk_rate <= 4500000) { | 1875 | } else if (da7218->mclk_rate <= 4500000) { |
@@ -1888,7 +1888,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1888 | indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ; | 1888 | indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ; |
1889 | indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL; | 1889 | indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL; |
1890 | } else { | 1890 | } else { |
1891 | dev_err(codec->dev, "PLL input clock %d above valid range\n", | 1891 | dev_err(component->dev, "PLL input clock %d above valid range\n", |
1892 | da7218->mclk_rate); | 1892 | da7218->mclk_rate); |
1893 | return -EINVAL; | 1893 | return -EINVAL; |
1894 | } | 1894 | } |
@@ -1899,7 +1899,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1899 | switch (source) { | 1899 | switch (source) { |
1900 | case DA7218_SYSCLK_MCLK: | 1900 | case DA7218_SYSCLK_MCLK: |
1901 | pll_ctrl |= DA7218_PLL_MODE_BYPASS; | 1901 | pll_ctrl |= DA7218_PLL_MODE_BYPASS; |
1902 | snd_soc_update_bits(codec, DA7218_PLL_CTRL, | 1902 | snd_soc_component_update_bits(component, DA7218_PLL_CTRL, |
1903 | DA7218_PLL_INDIV_MASK | | 1903 | DA7218_PLL_INDIV_MASK | |
1904 | DA7218_PLL_MODE_MASK, pll_ctrl); | 1904 | DA7218_PLL_MODE_MASK, pll_ctrl); |
1905 | return 0; | 1905 | return 0; |
@@ -1910,7 +1910,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1910 | pll_ctrl |= DA7218_PLL_MODE_SRM; | 1910 | pll_ctrl |= DA7218_PLL_MODE_SRM; |
1911 | break; | 1911 | break; |
1912 | default: | 1912 | default: |
1913 | dev_err(codec->dev, "Invalid PLL config\n"); | 1913 | dev_err(component->dev, "Invalid PLL config\n"); |
1914 | return -EINVAL; | 1914 | return -EINVAL; |
1915 | } | 1915 | } |
1916 | 1916 | ||
@@ -1922,10 +1922,10 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1922 | pll_frac_bot = (frac_div) & DA7218_BYTE_MASK; | 1922 | pll_frac_bot = (frac_div) & DA7218_BYTE_MASK; |
1923 | 1923 | ||
1924 | /* Write PLL config & dividers */ | 1924 | /* Write PLL config & dividers */ |
1925 | snd_soc_write(codec, DA7218_PLL_FRAC_TOP, pll_frac_top); | 1925 | snd_soc_component_write(component, DA7218_PLL_FRAC_TOP, pll_frac_top); |
1926 | snd_soc_write(codec, DA7218_PLL_FRAC_BOT, pll_frac_bot); | 1926 | snd_soc_component_write(component, DA7218_PLL_FRAC_BOT, pll_frac_bot); |
1927 | snd_soc_write(codec, DA7218_PLL_INTEGER, pll_integer); | 1927 | snd_soc_component_write(component, DA7218_PLL_INTEGER, pll_integer); |
1928 | snd_soc_update_bits(codec, DA7218_PLL_CTRL, | 1928 | snd_soc_component_update_bits(component, DA7218_PLL_CTRL, |
1929 | DA7218_PLL_MODE_MASK | DA7218_PLL_INDIV_MASK, | 1929 | DA7218_PLL_MODE_MASK | DA7218_PLL_INDIV_MASK, |
1930 | pll_ctrl); | 1930 | pll_ctrl); |
1931 | 1931 | ||
@@ -1934,8 +1934,8 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, | |||
1934 | 1934 | ||
1935 | static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | 1935 | static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) |
1936 | { | 1936 | { |
1937 | struct snd_soc_codec *codec = codec_dai->codec; | 1937 | struct snd_soc_component *component = codec_dai->component; |
1938 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 1938 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
1939 | u8 dai_clk_mode = 0, dai_ctrl = 0; | 1939 | u8 dai_clk_mode = 0, dai_ctrl = 0; |
1940 | 1940 | ||
1941 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1941 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
@@ -2012,8 +2012,8 @@ static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
2012 | /* By default 64 BCLKs per WCLK is supported */ | 2012 | /* By default 64 BCLKs per WCLK is supported */ |
2013 | dai_clk_mode |= DA7218_DAI_BCLKS_PER_WCLK_64; | 2013 | dai_clk_mode |= DA7218_DAI_BCLKS_PER_WCLK_64; |
2014 | 2014 | ||
2015 | snd_soc_write(codec, DA7218_DAI_CLK_MODE, dai_clk_mode); | 2015 | snd_soc_component_write(component, DA7218_DAI_CLK_MODE, dai_clk_mode); |
2016 | snd_soc_update_bits(codec, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK, | 2016 | snd_soc_component_update_bits(component, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK, |
2017 | dai_ctrl); | 2017 | dai_ctrl); |
2018 | 2018 | ||
2019 | return 0; | 2019 | return 0; |
@@ -2023,16 +2023,16 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, | |||
2023 | unsigned int tx_mask, unsigned int rx_mask, | 2023 | unsigned int tx_mask, unsigned int rx_mask, |
2024 | int slots, int slot_width) | 2024 | int slots, int slot_width) |
2025 | { | 2025 | { |
2026 | struct snd_soc_codec *codec = dai->codec; | 2026 | struct snd_soc_component *component = dai->component; |
2027 | u8 dai_bclks_per_wclk; | 2027 | u8 dai_bclks_per_wclk; |
2028 | u32 frame_size; | 2028 | u32 frame_size; |
2029 | 2029 | ||
2030 | /* No channels enabled so disable TDM, revert to 64-bit frames */ | 2030 | /* No channels enabled so disable TDM, revert to 64-bit frames */ |
2031 | if (!tx_mask) { | 2031 | if (!tx_mask) { |
2032 | snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, | 2032 | snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL, |
2033 | DA7218_DAI_TDM_CH_EN_MASK | | 2033 | DA7218_DAI_TDM_CH_EN_MASK | |
2034 | DA7218_DAI_TDM_MODE_EN_MASK, 0); | 2034 | DA7218_DAI_TDM_MODE_EN_MASK, 0); |
2035 | snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, | 2035 | snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, |
2036 | DA7218_DAI_BCLKS_PER_WCLK_MASK, | 2036 | DA7218_DAI_BCLKS_PER_WCLK_MASK, |
2037 | DA7218_DAI_BCLKS_PER_WCLK_64); | 2037 | DA7218_DAI_BCLKS_PER_WCLK_64); |
2038 | return 0; | 2038 | return 0; |
@@ -2040,14 +2040,14 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, | |||
2040 | 2040 | ||
2041 | /* Check we have valid slots */ | 2041 | /* Check we have valid slots */ |
2042 | if (fls(tx_mask) > DA7218_DAI_TDM_MAX_SLOTS) { | 2042 | if (fls(tx_mask) > DA7218_DAI_TDM_MAX_SLOTS) { |
2043 | dev_err(codec->dev, "Invalid number of slots, max = %d\n", | 2043 | dev_err(component->dev, "Invalid number of slots, max = %d\n", |
2044 | DA7218_DAI_TDM_MAX_SLOTS); | 2044 | DA7218_DAI_TDM_MAX_SLOTS); |
2045 | return -EINVAL; | 2045 | return -EINVAL; |
2046 | } | 2046 | } |
2047 | 2047 | ||
2048 | /* Check we have a valid offset given (first 2 bytes of rx_mask) */ | 2048 | /* Check we have a valid offset given (first 2 bytes of rx_mask) */ |
2049 | if (rx_mask >> DA7218_2BYTE_SHIFT) { | 2049 | if (rx_mask >> DA7218_2BYTE_SHIFT) { |
2050 | dev_err(codec->dev, "Invalid slot offset, max = %d\n", | 2050 | dev_err(component->dev, "Invalid slot offset, max = %d\n", |
2051 | DA7218_2BYTE_MASK); | 2051 | DA7218_2BYTE_MASK); |
2052 | return -EINVAL; | 2052 | return -EINVAL; |
2053 | } | 2053 | } |
@@ -2068,18 +2068,18 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, | |||
2068 | dai_bclks_per_wclk = DA7218_DAI_BCLKS_PER_WCLK_256; | 2068 | dai_bclks_per_wclk = DA7218_DAI_BCLKS_PER_WCLK_256; |
2069 | break; | 2069 | break; |
2070 | default: | 2070 | default: |
2071 | dev_err(codec->dev, "Invalid frame size\n"); | 2071 | dev_err(component->dev, "Invalid frame size\n"); |
2072 | return -EINVAL; | 2072 | return -EINVAL; |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, | 2075 | snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, |
2076 | DA7218_DAI_BCLKS_PER_WCLK_MASK, | 2076 | DA7218_DAI_BCLKS_PER_WCLK_MASK, |
2077 | dai_bclks_per_wclk); | 2077 | dai_bclks_per_wclk); |
2078 | snd_soc_write(codec, DA7218_DAI_OFFSET_LOWER, | 2078 | snd_soc_component_write(component, DA7218_DAI_OFFSET_LOWER, |
2079 | (rx_mask & DA7218_BYTE_MASK)); | 2079 | (rx_mask & DA7218_BYTE_MASK)); |
2080 | snd_soc_write(codec, DA7218_DAI_OFFSET_UPPER, | 2080 | snd_soc_component_write(component, DA7218_DAI_OFFSET_UPPER, |
2081 | ((rx_mask >> DA7218_BYTE_SHIFT) & DA7218_BYTE_MASK)); | 2081 | ((rx_mask >> DA7218_BYTE_SHIFT) & DA7218_BYTE_MASK)); |
2082 | snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, | 2082 | snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL, |
2083 | DA7218_DAI_TDM_CH_EN_MASK | | 2083 | DA7218_DAI_TDM_CH_EN_MASK | |
2084 | DA7218_DAI_TDM_MODE_EN_MASK, | 2084 | DA7218_DAI_TDM_MODE_EN_MASK, |
2085 | (tx_mask << DA7218_DAI_TDM_CH_EN_SHIFT) | | 2085 | (tx_mask << DA7218_DAI_TDM_CH_EN_SHIFT) | |
@@ -2092,7 +2092,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, | |||
2092 | struct snd_pcm_hw_params *params, | 2092 | struct snd_pcm_hw_params *params, |
2093 | struct snd_soc_dai *dai) | 2093 | struct snd_soc_dai *dai) |
2094 | { | 2094 | { |
2095 | struct snd_soc_codec *codec = dai->codec; | 2095 | struct snd_soc_component *component = dai->component; |
2096 | u8 dai_ctrl = 0, fs; | 2096 | u8 dai_ctrl = 0, fs; |
2097 | unsigned int channels; | 2097 | unsigned int channels; |
2098 | 2098 | ||
@@ -2115,7 +2115,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, | |||
2115 | 2115 | ||
2116 | channels = params_channels(params); | 2116 | channels = params_channels(params); |
2117 | if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) { | 2117 | if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) { |
2118 | dev_err(codec->dev, | 2118 | dev_err(component->dev, |
2119 | "Invalid number of channels, only 1 to %d supported\n", | 2119 | "Invalid number of channels, only 1 to %d supported\n", |
2120 | DA7218_DAI_CH_NUM_MAX); | 2120 | DA7218_DAI_CH_NUM_MAX); |
2121 | return -EINVAL; | 2121 | return -EINVAL; |
@@ -2160,11 +2160,11 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, | |||
2160 | return -EINVAL; | 2160 | return -EINVAL; |
2161 | } | 2161 | } |
2162 | 2162 | ||
2163 | snd_soc_update_bits(codec, DA7218_DAI_CTRL, | 2163 | snd_soc_component_update_bits(component, DA7218_DAI_CTRL, |
2164 | DA7218_DAI_WORD_LENGTH_MASK | DA7218_DAI_CH_NUM_MASK, | 2164 | DA7218_DAI_WORD_LENGTH_MASK | DA7218_DAI_CH_NUM_MASK, |
2165 | dai_ctrl); | 2165 | dai_ctrl); |
2166 | /* SRs tied for ADCs and DACs. */ | 2166 | /* SRs tied for ADCs and DACs. */ |
2167 | snd_soc_write(codec, DA7218_SR, | 2167 | snd_soc_component_write(component, DA7218_SR, |
2168 | (fs << DA7218_SR_DAC_SHIFT) | (fs << DA7218_SR_ADC_SHIFT)); | 2168 | (fs << DA7218_SR_DAC_SHIFT) | (fs << DA7218_SR_ADC_SHIFT)); |
2169 | 2169 | ||
2170 | return 0; | 2170 | return 0; |
@@ -2208,15 +2208,15 @@ static struct snd_soc_dai_driver da7218_dai = { | |||
2208 | * HP Detect | 2208 | * HP Detect |
2209 | */ | 2209 | */ |
2210 | 2210 | ||
2211 | int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack) | 2211 | int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack) |
2212 | { | 2212 | { |
2213 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2213 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2214 | 2214 | ||
2215 | if (da7218->dev_id == DA7217_DEV_ID) | 2215 | if (da7218->dev_id == DA7217_DEV_ID) |
2216 | return -EINVAL; | 2216 | return -EINVAL; |
2217 | 2217 | ||
2218 | da7218->jack = jack; | 2218 | da7218->jack = jack; |
2219 | snd_soc_update_bits(codec, DA7218_HPLDET_JACK, | 2219 | snd_soc_component_update_bits(component, DA7218_HPLDET_JACK, |
2220 | DA7218_HPLDET_JACK_EN_MASK, | 2220 | DA7218_HPLDET_JACK_EN_MASK, |
2221 | jack ? DA7218_HPLDET_JACK_EN_MASK : 0); | 2221 | jack ? DA7218_HPLDET_JACK_EN_MASK : 0); |
2222 | 2222 | ||
@@ -2224,23 +2224,23 @@ int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack) | |||
2224 | } | 2224 | } |
2225 | EXPORT_SYMBOL_GPL(da7218_hpldet); | 2225 | EXPORT_SYMBOL_GPL(da7218_hpldet); |
2226 | 2226 | ||
2227 | static void da7218_micldet_irq(struct snd_soc_codec *codec) | 2227 | static void da7218_micldet_irq(struct snd_soc_component *component) |
2228 | { | 2228 | { |
2229 | char *envp[] = { | 2229 | char *envp[] = { |
2230 | "EVENT=MIC_LEVEL_DETECT", | 2230 | "EVENT=MIC_LEVEL_DETECT", |
2231 | NULL, | 2231 | NULL, |
2232 | }; | 2232 | }; |
2233 | 2233 | ||
2234 | kobject_uevent_env(&codec->dev->kobj, KOBJ_CHANGE, envp); | 2234 | kobject_uevent_env(&component->dev->kobj, KOBJ_CHANGE, envp); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | static void da7218_hpldet_irq(struct snd_soc_codec *codec) | 2237 | static void da7218_hpldet_irq(struct snd_soc_component *component) |
2238 | { | 2238 | { |
2239 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2239 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2240 | u8 jack_status; | 2240 | u8 jack_status; |
2241 | int report; | 2241 | int report; |
2242 | 2242 | ||
2243 | jack_status = snd_soc_read(codec, DA7218_EVENT_STATUS); | 2243 | jack_status = snd_soc_component_read32(component, DA7218_EVENT_STATUS); |
2244 | 2244 | ||
2245 | if (jack_status & DA7218_HPLDET_JACK_STS_MASK) | 2245 | if (jack_status & DA7218_HPLDET_JACK_STS_MASK) |
2246 | report = SND_JACK_HEADPHONE; | 2246 | report = SND_JACK_HEADPHONE; |
@@ -2256,24 +2256,24 @@ static void da7218_hpldet_irq(struct snd_soc_codec *codec) | |||
2256 | 2256 | ||
2257 | static irqreturn_t da7218_irq_thread(int irq, void *data) | 2257 | static irqreturn_t da7218_irq_thread(int irq, void *data) |
2258 | { | 2258 | { |
2259 | struct snd_soc_codec *codec = data; | 2259 | struct snd_soc_component *component = data; |
2260 | u8 status; | 2260 | u8 status; |
2261 | 2261 | ||
2262 | /* Read IRQ status reg */ | 2262 | /* Read IRQ status reg */ |
2263 | status = snd_soc_read(codec, DA7218_EVENT); | 2263 | status = snd_soc_component_read32(component, DA7218_EVENT); |
2264 | if (!status) | 2264 | if (!status) |
2265 | return IRQ_NONE; | 2265 | return IRQ_NONE; |
2266 | 2266 | ||
2267 | /* Mic level detect */ | 2267 | /* Mic level detect */ |
2268 | if (status & DA7218_LVL_DET_EVENT_MASK) | 2268 | if (status & DA7218_LVL_DET_EVENT_MASK) |
2269 | da7218_micldet_irq(codec); | 2269 | da7218_micldet_irq(component); |
2270 | 2270 | ||
2271 | /* HP detect */ | 2271 | /* HP detect */ |
2272 | if (status & DA7218_HPLDET_JACK_EVENT_MASK) | 2272 | if (status & DA7218_HPLDET_JACK_EVENT_MASK) |
2273 | da7218_hpldet_irq(codec); | 2273 | da7218_hpldet_irq(component); |
2274 | 2274 | ||
2275 | /* Clear interrupts */ | 2275 | /* Clear interrupts */ |
2276 | snd_soc_write(codec, DA7218_EVENT, status); | 2276 | snd_soc_component_write(component, DA7218_EVENT, status); |
2277 | 2277 | ||
2278 | return IRQ_HANDLED; | 2278 | return IRQ_HANDLED; |
2279 | } | 2279 | } |
@@ -2300,7 +2300,7 @@ static inline int da7218_of_get_id(struct device *dev) | |||
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | static enum da7218_micbias_voltage | 2302 | static enum da7218_micbias_voltage |
2303 | da7218_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) | 2303 | da7218_of_micbias_lvl(struct snd_soc_component *component, u32 val) |
2304 | { | 2304 | { |
2305 | switch (val) { | 2305 | switch (val) { |
2306 | case 1200: | 2306 | case 1200: |
@@ -2322,13 +2322,13 @@ static enum da7218_micbias_voltage | |||
2322 | case 3000: | 2322 | case 3000: |
2323 | return DA7218_MICBIAS_3_0V; | 2323 | return DA7218_MICBIAS_3_0V; |
2324 | default: | 2324 | default: |
2325 | dev_warn(codec->dev, "Invalid micbias level"); | 2325 | dev_warn(component->dev, "Invalid micbias level"); |
2326 | return DA7218_MICBIAS_1_6V; | 2326 | return DA7218_MICBIAS_1_6V; |
2327 | } | 2327 | } |
2328 | } | 2328 | } |
2329 | 2329 | ||
2330 | static enum da7218_mic_amp_in_sel | 2330 | static enum da7218_mic_amp_in_sel |
2331 | da7218_of_mic_amp_in_sel(struct snd_soc_codec *codec, const char *str) | 2331 | da7218_of_mic_amp_in_sel(struct snd_soc_component *component, const char *str) |
2332 | { | 2332 | { |
2333 | if (!strcmp(str, "diff")) { | 2333 | if (!strcmp(str, "diff")) { |
2334 | return DA7218_MIC_AMP_IN_SEL_DIFF; | 2334 | return DA7218_MIC_AMP_IN_SEL_DIFF; |
@@ -2337,39 +2337,39 @@ static enum da7218_mic_amp_in_sel | |||
2337 | } else if (!strcmp(str, "se_n")) { | 2337 | } else if (!strcmp(str, "se_n")) { |
2338 | return DA7218_MIC_AMP_IN_SEL_SE_N; | 2338 | return DA7218_MIC_AMP_IN_SEL_SE_N; |
2339 | } else { | 2339 | } else { |
2340 | dev_warn(codec->dev, "Invalid mic input type selection"); | 2340 | dev_warn(component->dev, "Invalid mic input type selection"); |
2341 | return DA7218_MIC_AMP_IN_SEL_DIFF; | 2341 | return DA7218_MIC_AMP_IN_SEL_DIFF; |
2342 | } | 2342 | } |
2343 | } | 2343 | } |
2344 | 2344 | ||
2345 | static enum da7218_dmic_data_sel | 2345 | static enum da7218_dmic_data_sel |
2346 | da7218_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) | 2346 | da7218_of_dmic_data_sel(struct snd_soc_component *component, const char *str) |
2347 | { | 2347 | { |
2348 | if (!strcmp(str, "lrise_rfall")) { | 2348 | if (!strcmp(str, "lrise_rfall")) { |
2349 | return DA7218_DMIC_DATA_LRISE_RFALL; | 2349 | return DA7218_DMIC_DATA_LRISE_RFALL; |
2350 | } else if (!strcmp(str, "lfall_rrise")) { | 2350 | } else if (!strcmp(str, "lfall_rrise")) { |
2351 | return DA7218_DMIC_DATA_LFALL_RRISE; | 2351 | return DA7218_DMIC_DATA_LFALL_RRISE; |
2352 | } else { | 2352 | } else { |
2353 | dev_warn(codec->dev, "Invalid DMIC data type selection"); | 2353 | dev_warn(component->dev, "Invalid DMIC data type selection"); |
2354 | return DA7218_DMIC_DATA_LRISE_RFALL; | 2354 | return DA7218_DMIC_DATA_LRISE_RFALL; |
2355 | } | 2355 | } |
2356 | } | 2356 | } |
2357 | 2357 | ||
2358 | static enum da7218_dmic_samplephase | 2358 | static enum da7218_dmic_samplephase |
2359 | da7218_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) | 2359 | da7218_of_dmic_samplephase(struct snd_soc_component *component, const char *str) |
2360 | { | 2360 | { |
2361 | if (!strcmp(str, "on_clkedge")) { | 2361 | if (!strcmp(str, "on_clkedge")) { |
2362 | return DA7218_DMIC_SAMPLE_ON_CLKEDGE; | 2362 | return DA7218_DMIC_SAMPLE_ON_CLKEDGE; |
2363 | } else if (!strcmp(str, "between_clkedge")) { | 2363 | } else if (!strcmp(str, "between_clkedge")) { |
2364 | return DA7218_DMIC_SAMPLE_BETWEEN_CLKEDGE; | 2364 | return DA7218_DMIC_SAMPLE_BETWEEN_CLKEDGE; |
2365 | } else { | 2365 | } else { |
2366 | dev_warn(codec->dev, "Invalid DMIC sample phase"); | 2366 | dev_warn(component->dev, "Invalid DMIC sample phase"); |
2367 | return DA7218_DMIC_SAMPLE_ON_CLKEDGE; | 2367 | return DA7218_DMIC_SAMPLE_ON_CLKEDGE; |
2368 | } | 2368 | } |
2369 | } | 2369 | } |
2370 | 2370 | ||
2371 | static enum da7218_dmic_clk_rate | 2371 | static enum da7218_dmic_clk_rate |
2372 | da7218_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) | 2372 | da7218_of_dmic_clkrate(struct snd_soc_component *component, u32 val) |
2373 | { | 2373 | { |
2374 | switch (val) { | 2374 | switch (val) { |
2375 | case 1500000: | 2375 | case 1500000: |
@@ -2377,13 +2377,13 @@ static enum da7218_dmic_clk_rate | |||
2377 | case 3000000: | 2377 | case 3000000: |
2378 | return DA7218_DMIC_CLK_3_0MHZ; | 2378 | return DA7218_DMIC_CLK_3_0MHZ; |
2379 | default: | 2379 | default: |
2380 | dev_warn(codec->dev, "Invalid DMIC clock rate"); | 2380 | dev_warn(component->dev, "Invalid DMIC clock rate"); |
2381 | return DA7218_DMIC_CLK_3_0MHZ; | 2381 | return DA7218_DMIC_CLK_3_0MHZ; |
2382 | } | 2382 | } |
2383 | } | 2383 | } |
2384 | 2384 | ||
2385 | static enum da7218_hpldet_jack_rate | 2385 | static enum da7218_hpldet_jack_rate |
2386 | da7218_of_jack_rate(struct snd_soc_codec *codec, u32 val) | 2386 | da7218_of_jack_rate(struct snd_soc_component *component, u32 val) |
2387 | { | 2387 | { |
2388 | switch (val) { | 2388 | switch (val) { |
2389 | case 5: | 2389 | case 5: |
@@ -2403,13 +2403,13 @@ static enum da7218_hpldet_jack_rate | |||
2403 | case 640: | 2403 | case 640: |
2404 | return DA7218_HPLDET_JACK_RATE_640US; | 2404 | return DA7218_HPLDET_JACK_RATE_640US; |
2405 | default: | 2405 | default: |
2406 | dev_warn(codec->dev, "Invalid jack detect rate"); | 2406 | dev_warn(component->dev, "Invalid jack detect rate"); |
2407 | return DA7218_HPLDET_JACK_RATE_40US; | 2407 | return DA7218_HPLDET_JACK_RATE_40US; |
2408 | } | 2408 | } |
2409 | } | 2409 | } |
2410 | 2410 | ||
2411 | static enum da7218_hpldet_jack_debounce | 2411 | static enum da7218_hpldet_jack_debounce |
2412 | da7218_of_jack_debounce(struct snd_soc_codec *codec, u32 val) | 2412 | da7218_of_jack_debounce(struct snd_soc_component *component, u32 val) |
2413 | { | 2413 | { |
2414 | switch (val) { | 2414 | switch (val) { |
2415 | case 0: | 2415 | case 0: |
@@ -2421,13 +2421,13 @@ static enum da7218_hpldet_jack_debounce | |||
2421 | case 4: | 2421 | case 4: |
2422 | return DA7218_HPLDET_JACK_DEBOUNCE_4; | 2422 | return DA7218_HPLDET_JACK_DEBOUNCE_4; |
2423 | default: | 2423 | default: |
2424 | dev_warn(codec->dev, "Invalid jack debounce"); | 2424 | dev_warn(component->dev, "Invalid jack debounce"); |
2425 | return DA7218_HPLDET_JACK_DEBOUNCE_2; | 2425 | return DA7218_HPLDET_JACK_DEBOUNCE_2; |
2426 | } | 2426 | } |
2427 | } | 2427 | } |
2428 | 2428 | ||
2429 | static enum da7218_hpldet_jack_thr | 2429 | static enum da7218_hpldet_jack_thr |
2430 | da7218_of_jack_thr(struct snd_soc_codec *codec, u32 val) | 2430 | da7218_of_jack_thr(struct snd_soc_component *component, u32 val) |
2431 | { | 2431 | { |
2432 | switch (val) { | 2432 | switch (val) { |
2433 | case 84: | 2433 | case 84: |
@@ -2439,76 +2439,76 @@ static enum da7218_hpldet_jack_thr | |||
2439 | case 96: | 2439 | case 96: |
2440 | return DA7218_HPLDET_JACK_THR_96PCT; | 2440 | return DA7218_HPLDET_JACK_THR_96PCT; |
2441 | default: | 2441 | default: |
2442 | dev_warn(codec->dev, "Invalid jack threshold level"); | 2442 | dev_warn(component->dev, "Invalid jack threshold level"); |
2443 | return DA7218_HPLDET_JACK_THR_84PCT; | 2443 | return DA7218_HPLDET_JACK_THR_84PCT; |
2444 | } | 2444 | } |
2445 | } | 2445 | } |
2446 | 2446 | ||
2447 | static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) | 2447 | static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_component *component) |
2448 | { | 2448 | { |
2449 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2449 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2450 | struct device_node *np = codec->dev->of_node; | 2450 | struct device_node *np = component->dev->of_node; |
2451 | struct device_node *hpldet_np; | 2451 | struct device_node *hpldet_np; |
2452 | struct da7218_pdata *pdata; | 2452 | struct da7218_pdata *pdata; |
2453 | struct da7218_hpldet_pdata *hpldet_pdata; | 2453 | struct da7218_hpldet_pdata *hpldet_pdata; |
2454 | const char *of_str; | 2454 | const char *of_str; |
2455 | u32 of_val32; | 2455 | u32 of_val32; |
2456 | 2456 | ||
2457 | pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); | 2457 | pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); |
2458 | if (!pdata) | 2458 | if (!pdata) |
2459 | return NULL; | 2459 | return NULL; |
2460 | 2460 | ||
2461 | if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0) | 2461 | if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0) |
2462 | pdata->micbias1_lvl = da7218_of_micbias_lvl(codec, of_val32); | 2462 | pdata->micbias1_lvl = da7218_of_micbias_lvl(component, of_val32); |
2463 | else | 2463 | else |
2464 | pdata->micbias1_lvl = DA7218_MICBIAS_1_6V; | 2464 | pdata->micbias1_lvl = DA7218_MICBIAS_1_6V; |
2465 | 2465 | ||
2466 | if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0) | 2466 | if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0) |
2467 | pdata->micbias2_lvl = da7218_of_micbias_lvl(codec, of_val32); | 2467 | pdata->micbias2_lvl = da7218_of_micbias_lvl(component, of_val32); |
2468 | else | 2468 | else |
2469 | pdata->micbias2_lvl = DA7218_MICBIAS_1_6V; | 2469 | pdata->micbias2_lvl = DA7218_MICBIAS_1_6V; |
2470 | 2470 | ||
2471 | if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str)) | 2471 | if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str)) |
2472 | pdata->mic1_amp_in_sel = | 2472 | pdata->mic1_amp_in_sel = |
2473 | da7218_of_mic_amp_in_sel(codec, of_str); | 2473 | da7218_of_mic_amp_in_sel(component, of_str); |
2474 | else | 2474 | else |
2475 | pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; | 2475 | pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; |
2476 | 2476 | ||
2477 | if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str)) | 2477 | if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str)) |
2478 | pdata->mic2_amp_in_sel = | 2478 | pdata->mic2_amp_in_sel = |
2479 | da7218_of_mic_amp_in_sel(codec, of_str); | 2479 | da7218_of_mic_amp_in_sel(component, of_str); |
2480 | else | 2480 | else |
2481 | pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; | 2481 | pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; |
2482 | 2482 | ||
2483 | if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str)) | 2483 | if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str)) |
2484 | pdata->dmic1_data_sel = da7218_of_dmic_data_sel(codec, of_str); | 2484 | pdata->dmic1_data_sel = da7218_of_dmic_data_sel(component, of_str); |
2485 | else | 2485 | else |
2486 | pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; | 2486 | pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; |
2487 | 2487 | ||
2488 | if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str)) | 2488 | if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str)) |
2489 | pdata->dmic1_samplephase = | 2489 | pdata->dmic1_samplephase = |
2490 | da7218_of_dmic_samplephase(codec, of_str); | 2490 | da7218_of_dmic_samplephase(component, of_str); |
2491 | else | 2491 | else |
2492 | pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; | 2492 | pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; |
2493 | 2493 | ||
2494 | if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0) | 2494 | if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0) |
2495 | pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); | 2495 | pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(component, of_val32); |
2496 | else | 2496 | else |
2497 | pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ; | 2497 | pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ; |
2498 | 2498 | ||
2499 | if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str)) | 2499 | if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str)) |
2500 | pdata->dmic2_data_sel = da7218_of_dmic_data_sel(codec, of_str); | 2500 | pdata->dmic2_data_sel = da7218_of_dmic_data_sel(component, of_str); |
2501 | else | 2501 | else |
2502 | pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; | 2502 | pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; |
2503 | 2503 | ||
2504 | if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str)) | 2504 | if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str)) |
2505 | pdata->dmic2_samplephase = | 2505 | pdata->dmic2_samplephase = |
2506 | da7218_of_dmic_samplephase(codec, of_str); | 2506 | da7218_of_dmic_samplephase(component, of_str); |
2507 | else | 2507 | else |
2508 | pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; | 2508 | pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; |
2509 | 2509 | ||
2510 | if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0) | 2510 | if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0) |
2511 | pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); | 2511 | pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(component, of_val32); |
2512 | else | 2512 | else |
2513 | pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ; | 2513 | pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ; |
2514 | 2514 | ||
@@ -2522,7 +2522,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) | |||
2522 | if (!hpldet_np) | 2522 | if (!hpldet_np) |
2523 | return pdata; | 2523 | return pdata; |
2524 | 2524 | ||
2525 | hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata), | 2525 | hpldet_pdata = devm_kzalloc(component->dev, sizeof(*hpldet_pdata), |
2526 | GFP_KERNEL); | 2526 | GFP_KERNEL); |
2527 | if (!hpldet_pdata) { | 2527 | if (!hpldet_pdata) { |
2528 | of_node_put(hpldet_np); | 2528 | of_node_put(hpldet_np); |
@@ -2533,14 +2533,14 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) | |||
2533 | if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us", | 2533 | if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us", |
2534 | &of_val32) >= 0) | 2534 | &of_val32) >= 0) |
2535 | hpldet_pdata->jack_rate = | 2535 | hpldet_pdata->jack_rate = |
2536 | da7218_of_jack_rate(codec, of_val32); | 2536 | da7218_of_jack_rate(component, of_val32); |
2537 | else | 2537 | else |
2538 | hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US; | 2538 | hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US; |
2539 | 2539 | ||
2540 | if (of_property_read_u32(hpldet_np, "dlg,jack-debounce", | 2540 | if (of_property_read_u32(hpldet_np, "dlg,jack-debounce", |
2541 | &of_val32) >= 0) | 2541 | &of_val32) >= 0) |
2542 | hpldet_pdata->jack_debounce = | 2542 | hpldet_pdata->jack_debounce = |
2543 | da7218_of_jack_debounce(codec, of_val32); | 2543 | da7218_of_jack_debounce(component, of_val32); |
2544 | else | 2544 | else |
2545 | hpldet_pdata->jack_debounce = | 2545 | hpldet_pdata->jack_debounce = |
2546 | DA7218_HPLDET_JACK_DEBOUNCE_2; | 2546 | DA7218_HPLDET_JACK_DEBOUNCE_2; |
@@ -2548,7 +2548,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) | |||
2548 | if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct", | 2548 | if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct", |
2549 | &of_val32) >= 0) | 2549 | &of_val32) >= 0) |
2550 | hpldet_pdata->jack_thr = | 2550 | hpldet_pdata->jack_thr = |
2551 | da7218_of_jack_thr(codec, of_val32); | 2551 | da7218_of_jack_thr(component, of_val32); |
2552 | else | 2552 | else |
2553 | hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT; | 2553 | hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT; |
2554 | 2554 | ||
@@ -2572,10 +2572,10 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) | |||
2572 | * Codec driver functions | 2572 | * Codec driver functions |
2573 | */ | 2573 | */ |
2574 | 2574 | ||
2575 | static int da7218_set_bias_level(struct snd_soc_codec *codec, | 2575 | static int da7218_set_bias_level(struct snd_soc_component *component, |
2576 | enum snd_soc_bias_level level) | 2576 | enum snd_soc_bias_level level) |
2577 | { | 2577 | { |
2578 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2578 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2579 | int ret; | 2579 | int ret; |
2580 | 2580 | ||
2581 | switch (level) { | 2581 | switch (level) { |
@@ -2583,11 +2583,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, | |||
2583 | break; | 2583 | break; |
2584 | case SND_SOC_BIAS_PREPARE: | 2584 | case SND_SOC_BIAS_PREPARE: |
2585 | /* Enable MCLK for transition to ON state */ | 2585 | /* Enable MCLK for transition to ON state */ |
2586 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { | 2586 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { |
2587 | if (da7218->mclk) { | 2587 | if (da7218->mclk) { |
2588 | ret = clk_prepare_enable(da7218->mclk); | 2588 | ret = clk_prepare_enable(da7218->mclk); |
2589 | if (ret) { | 2589 | if (ret) { |
2590 | dev_err(codec->dev, "Failed to enable mclk\n"); | 2590 | dev_err(component->dev, "Failed to enable mclk\n"); |
2591 | return ret; | 2591 | return ret; |
2592 | } | 2592 | } |
2593 | } | 2593 | } |
@@ -2595,14 +2595,14 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, | |||
2595 | 2595 | ||
2596 | break; | 2596 | break; |
2597 | case SND_SOC_BIAS_STANDBY: | 2597 | case SND_SOC_BIAS_STANDBY: |
2598 | if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { | 2598 | if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { |
2599 | /* Master bias */ | 2599 | /* Master bias */ |
2600 | snd_soc_update_bits(codec, DA7218_REFERENCES, | 2600 | snd_soc_component_update_bits(component, DA7218_REFERENCES, |
2601 | DA7218_BIAS_EN_MASK, | 2601 | DA7218_BIAS_EN_MASK, |
2602 | DA7218_BIAS_EN_MASK); | 2602 | DA7218_BIAS_EN_MASK); |
2603 | 2603 | ||
2604 | /* Internal LDO */ | 2604 | /* Internal LDO */ |
2605 | snd_soc_update_bits(codec, DA7218_LDO_CTRL, | 2605 | snd_soc_component_update_bits(component, DA7218_LDO_CTRL, |
2606 | DA7218_LDO_EN_MASK, | 2606 | DA7218_LDO_EN_MASK, |
2607 | DA7218_LDO_EN_MASK); | 2607 | DA7218_LDO_EN_MASK); |
2608 | } else { | 2608 | } else { |
@@ -2615,11 +2615,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, | |||
2615 | /* Only disable if jack detection disabled */ | 2615 | /* Only disable if jack detection disabled */ |
2616 | if (!da7218->jack) { | 2616 | if (!da7218->jack) { |
2617 | /* Internal LDO */ | 2617 | /* Internal LDO */ |
2618 | snd_soc_update_bits(codec, DA7218_LDO_CTRL, | 2618 | snd_soc_component_update_bits(component, DA7218_LDO_CTRL, |
2619 | DA7218_LDO_EN_MASK, 0); | 2619 | DA7218_LDO_EN_MASK, 0); |
2620 | 2620 | ||
2621 | /* Master bias */ | 2621 | /* Master bias */ |
2622 | snd_soc_update_bits(codec, DA7218_REFERENCES, | 2622 | snd_soc_component_update_bits(component, DA7218_REFERENCES, |
2623 | DA7218_BIAS_EN_MASK, 0); | 2623 | DA7218_BIAS_EN_MASK, 0); |
2624 | } | 2624 | } |
2625 | break; | 2625 | break; |
@@ -2634,9 +2634,9 @@ static const char *da7218_supply_names[DA7218_NUM_SUPPLIES] = { | |||
2634 | [DA7218_SUPPLY_VDDIO] = "VDDIO", | 2634 | [DA7218_SUPPLY_VDDIO] = "VDDIO", |
2635 | }; | 2635 | }; |
2636 | 2636 | ||
2637 | static int da7218_handle_supplies(struct snd_soc_codec *codec) | 2637 | static int da7218_handle_supplies(struct snd_soc_component *component) |
2638 | { | 2638 | { |
2639 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2639 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2640 | struct regulator *vddio; | 2640 | struct regulator *vddio; |
2641 | u8 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_2_5V_3_6V; | 2641 | u8 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_2_5V_3_6V; |
2642 | int i, ret; | 2642 | int i, ret; |
@@ -2645,10 +2645,10 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec) | |||
2645 | for (i = 0; i < DA7218_NUM_SUPPLIES; ++i) | 2645 | for (i = 0; i < DA7218_NUM_SUPPLIES; ++i) |
2646 | da7218->supplies[i].supply = da7218_supply_names[i]; | 2646 | da7218->supplies[i].supply = da7218_supply_names[i]; |
2647 | 2647 | ||
2648 | ret = devm_regulator_bulk_get(codec->dev, DA7218_NUM_SUPPLIES, | 2648 | ret = devm_regulator_bulk_get(component->dev, DA7218_NUM_SUPPLIES, |
2649 | da7218->supplies); | 2649 | da7218->supplies); |
2650 | if (ret) { | 2650 | if (ret) { |
2651 | dev_err(codec->dev, "Failed to get supplies\n"); | 2651 | dev_err(component->dev, "Failed to get supplies\n"); |
2652 | return ret; | 2652 | return ret; |
2653 | } | 2653 | } |
2654 | 2654 | ||
@@ -2656,29 +2656,29 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec) | |||
2656 | vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer; | 2656 | vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer; |
2657 | ret = regulator_get_voltage(vddio); | 2657 | ret = regulator_get_voltage(vddio); |
2658 | if (ret < 1500000) | 2658 | if (ret < 1500000) |
2659 | dev_warn(codec->dev, "Invalid VDDIO voltage\n"); | 2659 | dev_warn(component->dev, "Invalid VDDIO voltage\n"); |
2660 | else if (ret < 2500000) | 2660 | else if (ret < 2500000) |
2661 | io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_1_5V_2_5V; | 2661 | io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_1_5V_2_5V; |
2662 | 2662 | ||
2663 | /* Enable main supplies */ | 2663 | /* Enable main supplies */ |
2664 | ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies); | 2664 | ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies); |
2665 | if (ret) { | 2665 | if (ret) { |
2666 | dev_err(codec->dev, "Failed to enable supplies\n"); | 2666 | dev_err(component->dev, "Failed to enable supplies\n"); |
2667 | return ret; | 2667 | return ret; |
2668 | } | 2668 | } |
2669 | 2669 | ||
2670 | /* Ensure device in active mode */ | 2670 | /* Ensure device in active mode */ |
2671 | snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); | 2671 | snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); |
2672 | 2672 | ||
2673 | /* Update IO voltage level range */ | 2673 | /* Update IO voltage level range */ |
2674 | snd_soc_write(codec, DA7218_IO_CTRL, io_voltage_lvl); | 2674 | snd_soc_component_write(component, DA7218_IO_CTRL, io_voltage_lvl); |
2675 | 2675 | ||
2676 | return 0; | 2676 | return 0; |
2677 | } | 2677 | } |
2678 | 2678 | ||
2679 | static void da7218_handle_pdata(struct snd_soc_codec *codec) | 2679 | static void da7218_handle_pdata(struct snd_soc_component *component) |
2680 | { | 2680 | { |
2681 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2681 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2682 | struct da7218_pdata *pdata = da7218->pdata; | 2682 | struct da7218_pdata *pdata = da7218->pdata; |
2683 | 2683 | ||
2684 | if (pdata) { | 2684 | if (pdata) { |
@@ -2719,14 +2719,14 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2719 | break; | 2719 | break; |
2720 | } | 2720 | } |
2721 | 2721 | ||
2722 | snd_soc_write(codec, DA7218_MICBIAS_CTRL, micbias_lvl); | 2722 | snd_soc_component_write(component, DA7218_MICBIAS_CTRL, micbias_lvl); |
2723 | 2723 | ||
2724 | /* Mic */ | 2724 | /* Mic */ |
2725 | switch (pdata->mic1_amp_in_sel) { | 2725 | switch (pdata->mic1_amp_in_sel) { |
2726 | case DA7218_MIC_AMP_IN_SEL_DIFF: | 2726 | case DA7218_MIC_AMP_IN_SEL_DIFF: |
2727 | case DA7218_MIC_AMP_IN_SEL_SE_P: | 2727 | case DA7218_MIC_AMP_IN_SEL_SE_P: |
2728 | case DA7218_MIC_AMP_IN_SEL_SE_N: | 2728 | case DA7218_MIC_AMP_IN_SEL_SE_N: |
2729 | snd_soc_write(codec, DA7218_MIC_1_SELECT, | 2729 | snd_soc_component_write(component, DA7218_MIC_1_SELECT, |
2730 | pdata->mic1_amp_in_sel); | 2730 | pdata->mic1_amp_in_sel); |
2731 | break; | 2731 | break; |
2732 | } | 2732 | } |
@@ -2735,7 +2735,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2735 | case DA7218_MIC_AMP_IN_SEL_DIFF: | 2735 | case DA7218_MIC_AMP_IN_SEL_DIFF: |
2736 | case DA7218_MIC_AMP_IN_SEL_SE_P: | 2736 | case DA7218_MIC_AMP_IN_SEL_SE_P: |
2737 | case DA7218_MIC_AMP_IN_SEL_SE_N: | 2737 | case DA7218_MIC_AMP_IN_SEL_SE_N: |
2738 | snd_soc_write(codec, DA7218_MIC_2_SELECT, | 2738 | snd_soc_component_write(component, DA7218_MIC_2_SELECT, |
2739 | pdata->mic2_amp_in_sel); | 2739 | pdata->mic2_amp_in_sel); |
2740 | break; | 2740 | break; |
2741 | } | 2741 | } |
@@ -2765,7 +2765,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2765 | break; | 2765 | break; |
2766 | } | 2766 | } |
2767 | 2767 | ||
2768 | snd_soc_update_bits(codec, DA7218_DMIC_1_CTRL, | 2768 | snd_soc_component_update_bits(component, DA7218_DMIC_1_CTRL, |
2769 | DA7218_DMIC_1_DATA_SEL_MASK | | 2769 | DA7218_DMIC_1_DATA_SEL_MASK | |
2770 | DA7218_DMIC_1_SAMPLEPHASE_MASK | | 2770 | DA7218_DMIC_1_SAMPLEPHASE_MASK | |
2771 | DA7218_DMIC_1_CLK_RATE_MASK, dmic_cfg); | 2771 | DA7218_DMIC_1_CLK_RATE_MASK, dmic_cfg); |
@@ -2795,7 +2795,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2795 | break; | 2795 | break; |
2796 | } | 2796 | } |
2797 | 2797 | ||
2798 | snd_soc_update_bits(codec, DA7218_DMIC_2_CTRL, | 2798 | snd_soc_component_update_bits(component, DA7218_DMIC_2_CTRL, |
2799 | DA7218_DMIC_2_DATA_SEL_MASK | | 2799 | DA7218_DMIC_2_DATA_SEL_MASK | |
2800 | DA7218_DMIC_2_SAMPLEPHASE_MASK | | 2800 | DA7218_DMIC_2_SAMPLEPHASE_MASK | |
2801 | DA7218_DMIC_2_CLK_RATE_MASK, dmic_cfg); | 2801 | DA7218_DMIC_2_CLK_RATE_MASK, dmic_cfg); |
@@ -2806,9 +2806,9 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2806 | pdata->hp_diff_single_supply; | 2806 | pdata->hp_diff_single_supply; |
2807 | 2807 | ||
2808 | if (da7218->hp_single_supply) { | 2808 | if (da7218->hp_single_supply) { |
2809 | snd_soc_write(codec, DA7218_HP_DIFF_UNLOCK, | 2809 | snd_soc_component_write(component, DA7218_HP_DIFF_UNLOCK, |
2810 | DA7218_HP_DIFF_UNLOCK_VAL); | 2810 | DA7218_HP_DIFF_UNLOCK_VAL); |
2811 | snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, | 2811 | snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL, |
2812 | DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK, | 2812 | DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK, |
2813 | DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK); | 2813 | DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK); |
2814 | } | 2814 | } |
@@ -2857,7 +2857,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2857 | DA7218_HPLDET_JACK_THR_SHIFT); | 2857 | DA7218_HPLDET_JACK_THR_SHIFT); |
2858 | break; | 2858 | break; |
2859 | } | 2859 | } |
2860 | snd_soc_update_bits(codec, DA7218_HPLDET_JACK, | 2860 | snd_soc_component_update_bits(component, DA7218_HPLDET_JACK, |
2861 | DA7218_HPLDET_JACK_RATE_MASK | | 2861 | DA7218_HPLDET_JACK_RATE_MASK | |
2862 | DA7218_HPLDET_JACK_DEBOUNCE_MASK | | 2862 | DA7218_HPLDET_JACK_DEBOUNCE_MASK | |
2863 | DA7218_HPLDET_JACK_THR_MASK, | 2863 | DA7218_HPLDET_JACK_THR_MASK, |
@@ -2873,31 +2873,31 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) | |||
2873 | if (hpldet_pdata->discharge) | 2873 | if (hpldet_pdata->discharge) |
2874 | hpldet_cfg |= DA7218_HPLDET_DISCHARGE_EN_MASK; | 2874 | hpldet_cfg |= DA7218_HPLDET_DISCHARGE_EN_MASK; |
2875 | 2875 | ||
2876 | snd_soc_write(codec, DA7218_HPLDET_CTRL, hpldet_cfg); | 2876 | snd_soc_component_write(component, DA7218_HPLDET_CTRL, hpldet_cfg); |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | } | 2879 | } |
2880 | 2880 | ||
2881 | static int da7218_probe(struct snd_soc_codec *codec) | 2881 | static int da7218_probe(struct snd_soc_component *component) |
2882 | { | 2882 | { |
2883 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2883 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2884 | int ret; | 2884 | int ret; |
2885 | 2885 | ||
2886 | /* Regulator configuration */ | 2886 | /* Regulator configuration */ |
2887 | ret = da7218_handle_supplies(codec); | 2887 | ret = da7218_handle_supplies(component); |
2888 | if (ret) | 2888 | if (ret) |
2889 | return ret; | 2889 | return ret; |
2890 | 2890 | ||
2891 | /* Handle DT/Platform data */ | 2891 | /* Handle DT/Platform data */ |
2892 | if (codec->dev->of_node) | 2892 | if (component->dev->of_node) |
2893 | da7218->pdata = da7218_of_to_pdata(codec); | 2893 | da7218->pdata = da7218_of_to_pdata(component); |
2894 | else | 2894 | else |
2895 | da7218->pdata = dev_get_platdata(codec->dev); | 2895 | da7218->pdata = dev_get_platdata(component->dev); |
2896 | 2896 | ||
2897 | da7218_handle_pdata(codec); | 2897 | da7218_handle_pdata(component); |
2898 | 2898 | ||
2899 | /* Check if MCLK provided, if not the clock is NULL */ | 2899 | /* Check if MCLK provided, if not the clock is NULL */ |
2900 | da7218->mclk = devm_clk_get(codec->dev, "mclk"); | 2900 | da7218->mclk = devm_clk_get(component->dev, "mclk"); |
2901 | if (IS_ERR(da7218->mclk)) { | 2901 | if (IS_ERR(da7218->mclk)) { |
2902 | if (PTR_ERR(da7218->mclk) != -ENOENT) { | 2902 | if (PTR_ERR(da7218->mclk) != -ENOENT) { |
2903 | ret = PTR_ERR(da7218->mclk); | 2903 | ret = PTR_ERR(da7218->mclk); |
@@ -2908,74 +2908,74 @@ static int da7218_probe(struct snd_soc_codec *codec) | |||
2908 | } | 2908 | } |
2909 | 2909 | ||
2910 | /* Default PC to free-running */ | 2910 | /* Default PC to free-running */ |
2911 | snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); | 2911 | snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); |
2912 | 2912 | ||
2913 | /* | 2913 | /* |
2914 | * Default Output Filter mixers to off otherwise DAPM will power | 2914 | * Default Output Filter mixers to off otherwise DAPM will power |
2915 | * Mic to HP passthrough paths by default at startup. | 2915 | * Mic to HP passthrough paths by default at startup. |
2916 | */ | 2916 | */ |
2917 | snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1L, 0); | 2917 | snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1L, 0); |
2918 | snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1R, 0); | 2918 | snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1R, 0); |
2919 | 2919 | ||
2920 | /* Default CP to normal load, power mode */ | 2920 | /* Default CP to normal load, power mode */ |
2921 | snd_soc_update_bits(codec, DA7218_CP_CTRL, | 2921 | snd_soc_component_update_bits(component, DA7218_CP_CTRL, |
2922 | DA7218_CP_SMALL_SWITCH_FREQ_EN_MASK, 0); | 2922 | DA7218_CP_SMALL_SWITCH_FREQ_EN_MASK, 0); |
2923 | 2923 | ||
2924 | /* Default gain ramping */ | 2924 | /* Default gain ramping */ |
2925 | snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, | 2925 | snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL, |
2926 | DA7218_MIXIN_1_AMP_RAMP_EN_MASK, | 2926 | DA7218_MIXIN_1_AMP_RAMP_EN_MASK, |
2927 | DA7218_MIXIN_1_AMP_RAMP_EN_MASK); | 2927 | DA7218_MIXIN_1_AMP_RAMP_EN_MASK); |
2928 | snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, | 2928 | snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL, |
2929 | DA7218_MIXIN_2_AMP_RAMP_EN_MASK, | 2929 | DA7218_MIXIN_2_AMP_RAMP_EN_MASK, |
2930 | DA7218_MIXIN_2_AMP_RAMP_EN_MASK); | 2930 | DA7218_MIXIN_2_AMP_RAMP_EN_MASK); |
2931 | snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, | 2931 | snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL, |
2932 | DA7218_IN_1L_RAMP_EN_MASK, | 2932 | DA7218_IN_1L_RAMP_EN_MASK, |
2933 | DA7218_IN_1L_RAMP_EN_MASK); | 2933 | DA7218_IN_1L_RAMP_EN_MASK); |
2934 | snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, | 2934 | snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL, |
2935 | DA7218_IN_1R_RAMP_EN_MASK, | 2935 | DA7218_IN_1R_RAMP_EN_MASK, |
2936 | DA7218_IN_1R_RAMP_EN_MASK); | 2936 | DA7218_IN_1R_RAMP_EN_MASK); |
2937 | snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, | 2937 | snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL, |
2938 | DA7218_IN_2L_RAMP_EN_MASK, | 2938 | DA7218_IN_2L_RAMP_EN_MASK, |
2939 | DA7218_IN_2L_RAMP_EN_MASK); | 2939 | DA7218_IN_2L_RAMP_EN_MASK); |
2940 | snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, | 2940 | snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL, |
2941 | DA7218_IN_2R_RAMP_EN_MASK, | 2941 | DA7218_IN_2R_RAMP_EN_MASK, |
2942 | DA7218_IN_2R_RAMP_EN_MASK); | 2942 | DA7218_IN_2R_RAMP_EN_MASK); |
2943 | snd_soc_update_bits(codec, DA7218_DGS_GAIN_CTRL, | 2943 | snd_soc_component_update_bits(component, DA7218_DGS_GAIN_CTRL, |
2944 | DA7218_DGS_RAMP_EN_MASK, DA7218_DGS_RAMP_EN_MASK); | 2944 | DA7218_DGS_RAMP_EN_MASK, DA7218_DGS_RAMP_EN_MASK); |
2945 | snd_soc_update_bits(codec, DA7218_OUT_1L_FILTER_CTRL, | 2945 | snd_soc_component_update_bits(component, DA7218_OUT_1L_FILTER_CTRL, |
2946 | DA7218_OUT_1L_RAMP_EN_MASK, | 2946 | DA7218_OUT_1L_RAMP_EN_MASK, |
2947 | DA7218_OUT_1L_RAMP_EN_MASK); | 2947 | DA7218_OUT_1L_RAMP_EN_MASK); |
2948 | snd_soc_update_bits(codec, DA7218_OUT_1R_FILTER_CTRL, | 2948 | snd_soc_component_update_bits(component, DA7218_OUT_1R_FILTER_CTRL, |
2949 | DA7218_OUT_1R_RAMP_EN_MASK, | 2949 | DA7218_OUT_1R_RAMP_EN_MASK, |
2950 | DA7218_OUT_1R_RAMP_EN_MASK); | 2950 | DA7218_OUT_1R_RAMP_EN_MASK); |
2951 | snd_soc_update_bits(codec, DA7218_HP_L_CTRL, | 2951 | snd_soc_component_update_bits(component, DA7218_HP_L_CTRL, |
2952 | DA7218_HP_L_AMP_RAMP_EN_MASK, | 2952 | DA7218_HP_L_AMP_RAMP_EN_MASK, |
2953 | DA7218_HP_L_AMP_RAMP_EN_MASK); | 2953 | DA7218_HP_L_AMP_RAMP_EN_MASK); |
2954 | snd_soc_update_bits(codec, DA7218_HP_R_CTRL, | 2954 | snd_soc_component_update_bits(component, DA7218_HP_R_CTRL, |
2955 | DA7218_HP_R_AMP_RAMP_EN_MASK, | 2955 | DA7218_HP_R_AMP_RAMP_EN_MASK, |
2956 | DA7218_HP_R_AMP_RAMP_EN_MASK); | 2956 | DA7218_HP_R_AMP_RAMP_EN_MASK); |
2957 | 2957 | ||
2958 | /* Default infinite tone gen, start/stop by Kcontrol */ | 2958 | /* Default infinite tone gen, start/stop by Kcontrol */ |
2959 | snd_soc_write(codec, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK); | 2959 | snd_soc_component_write(component, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK); |
2960 | 2960 | ||
2961 | /* DA7217 specific config */ | 2961 | /* DA7217 specific config */ |
2962 | if (da7218->dev_id == DA7217_DEV_ID) { | 2962 | if (da7218->dev_id == DA7217_DEV_ID) { |
2963 | snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, | 2963 | snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL, |
2964 | DA7218_HP_AMP_DIFF_MODE_EN_MASK, | 2964 | DA7218_HP_AMP_DIFF_MODE_EN_MASK, |
2965 | DA7218_HP_AMP_DIFF_MODE_EN_MASK); | 2965 | DA7218_HP_AMP_DIFF_MODE_EN_MASK); |
2966 | 2966 | ||
2967 | /* Only DA7218 supports HP detect, mask off for DA7217 */ | 2967 | /* Only DA7218 supports HP detect, mask off for DA7217 */ |
2968 | snd_soc_write(codec, DA7218_EVENT_MASK, | 2968 | snd_soc_component_write(component, DA7218_EVENT_MASK, |
2969 | DA7218_HPLDET_JACK_EVENT_IRQ_MSK_MASK); | 2969 | DA7218_HPLDET_JACK_EVENT_IRQ_MSK_MASK); |
2970 | } | 2970 | } |
2971 | 2971 | ||
2972 | if (da7218->irq) { | 2972 | if (da7218->irq) { |
2973 | ret = devm_request_threaded_irq(codec->dev, da7218->irq, NULL, | 2973 | ret = devm_request_threaded_irq(component->dev, da7218->irq, NULL, |
2974 | da7218_irq_thread, | 2974 | da7218_irq_thread, |
2975 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, | 2975 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
2976 | "da7218", codec); | 2976 | "da7218", component); |
2977 | if (ret != 0) { | 2977 | if (ret != 0) { |
2978 | dev_err(codec->dev, "Failed to request IRQ %d: %d\n", | 2978 | dev_err(component->dev, "Failed to request IRQ %d: %d\n", |
2979 | da7218->irq, ret); | 2979 | da7218->irq, ret); |
2980 | goto err_disable_reg; | 2980 | goto err_disable_reg; |
2981 | } | 2981 | } |
@@ -2990,39 +2990,37 @@ err_disable_reg: | |||
2990 | return ret; | 2990 | return ret; |
2991 | } | 2991 | } |
2992 | 2992 | ||
2993 | static int da7218_remove(struct snd_soc_codec *codec) | 2993 | static void da7218_remove(struct snd_soc_component *component) |
2994 | { | 2994 | { |
2995 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 2995 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
2996 | 2996 | ||
2997 | regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); | 2997 | regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); |
2998 | |||
2999 | return 0; | ||
3000 | } | 2998 | } |
3001 | 2999 | ||
3002 | #ifdef CONFIG_PM | 3000 | #ifdef CONFIG_PM |
3003 | static int da7218_suspend(struct snd_soc_codec *codec) | 3001 | static int da7218_suspend(struct snd_soc_component *component) |
3004 | { | 3002 | { |
3005 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 3003 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
3006 | 3004 | ||
3007 | da7218_set_bias_level(codec, SND_SOC_BIAS_OFF); | 3005 | da7218_set_bias_level(component, SND_SOC_BIAS_OFF); |
3008 | 3006 | ||
3009 | /* Put device into standby mode if jack detection disabled */ | 3007 | /* Put device into standby mode if jack detection disabled */ |
3010 | if (!da7218->jack) | 3008 | if (!da7218->jack) |
3011 | snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, 0); | 3009 | snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, 0); |
3012 | 3010 | ||
3013 | return 0; | 3011 | return 0; |
3014 | } | 3012 | } |
3015 | 3013 | ||
3016 | static int da7218_resume(struct snd_soc_codec *codec) | 3014 | static int da7218_resume(struct snd_soc_component *component) |
3017 | { | 3015 | { |
3018 | struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); | 3016 | struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); |
3019 | 3017 | ||
3020 | /* Put device into active mode if previously moved to standby */ | 3018 | /* Put device into active mode if previously moved to standby */ |
3021 | if (!da7218->jack) | 3019 | if (!da7218->jack) |
3022 | snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, | 3020 | snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, |
3023 | DA7218_SYSTEM_ACTIVE_MASK); | 3021 | DA7218_SYSTEM_ACTIVE_MASK); |
3024 | 3022 | ||
3025 | da7218_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 3023 | da7218_set_bias_level(component, SND_SOC_BIAS_STANDBY); |
3026 | 3024 | ||
3027 | return 0; | 3025 | return 0; |
3028 | } | 3026 | } |
@@ -3031,21 +3029,22 @@ static int da7218_resume(struct snd_soc_codec *codec) | |||
3031 | #define da7218_resume NULL | 3029 | #define da7218_resume NULL |
3032 | #endif | 3030 | #endif |
3033 | 3031 | ||
3034 | static const struct snd_soc_codec_driver soc_codec_dev_da7218 = { | 3032 | static const struct snd_soc_component_driver soc_component_dev_da7218 = { |
3035 | .probe = da7218_probe, | 3033 | .probe = da7218_probe, |
3036 | .remove = da7218_remove, | 3034 | .remove = da7218_remove, |
3037 | .suspend = da7218_suspend, | 3035 | .suspend = da7218_suspend, |
3038 | .resume = da7218_resume, | 3036 | .resume = da7218_resume, |
3039 | .set_bias_level = da7218_set_bias_level, | 3037 | .set_bias_level = da7218_set_bias_level, |
3040 | 3038 | .controls = da7218_snd_controls, | |
3041 | .component_driver = { | 3039 | .num_controls = ARRAY_SIZE(da7218_snd_controls), |
3042 | .controls = da7218_snd_controls, | 3040 | .dapm_widgets = da7218_dapm_widgets, |
3043 | .num_controls = ARRAY_SIZE(da7218_snd_controls), | 3041 | .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets), |
3044 | .dapm_widgets = da7218_dapm_widgets, | 3042 | .dapm_routes = da7218_audio_map, |
3045 | .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets), | 3043 | .num_dapm_routes = ARRAY_SIZE(da7218_audio_map), |
3046 | .dapm_routes = da7218_audio_map, | 3044 | .idle_bias_on = 1, |
3047 | .num_dapm_routes = ARRAY_SIZE(da7218_audio_map), | 3045 | .use_pmdown_time = 1, |
3048 | }, | 3046 | .endianness = 1, |
3047 | .non_legacy_dai_naming = 1, | ||
3049 | }; | 3048 | }; |
3050 | 3049 | ||
3051 | 3050 | ||
@@ -3295,21 +3294,15 @@ static int da7218_i2c_probe(struct i2c_client *i2c, | |||
3295 | return ret; | 3294 | return ret; |
3296 | } | 3295 | } |
3297 | 3296 | ||
3298 | ret = snd_soc_register_codec(&i2c->dev, | 3297 | ret = devm_snd_soc_register_component(&i2c->dev, |
3299 | &soc_codec_dev_da7218, &da7218_dai, 1); | 3298 | &soc_component_dev_da7218, &da7218_dai, 1); |
3300 | if (ret < 0) { | 3299 | if (ret < 0) { |
3301 | dev_err(&i2c->dev, "Failed to register da7218 codec: %d\n", | 3300 | dev_err(&i2c->dev, "Failed to register da7218 component: %d\n", |
3302 | ret); | 3301 | ret); |
3303 | } | 3302 | } |
3304 | return ret; | 3303 | return ret; |
3305 | } | 3304 | } |
3306 | 3305 | ||
3307 | static int da7218_i2c_remove(struct i2c_client *client) | ||
3308 | { | ||
3309 | snd_soc_unregister_codec(&client->dev); | ||
3310 | return 0; | ||
3311 | } | ||
3312 | |||
3313 | static const struct i2c_device_id da7218_i2c_id[] = { | 3306 | static const struct i2c_device_id da7218_i2c_id[] = { |
3314 | { "da7217", DA7217_DEV_ID }, | 3307 | { "da7217", DA7217_DEV_ID }, |
3315 | { "da7218", DA7218_DEV_ID }, | 3308 | { "da7218", DA7218_DEV_ID }, |
@@ -3323,7 +3316,6 @@ static struct i2c_driver da7218_i2c_driver = { | |||
3323 | .of_match_table = of_match_ptr(da7218_of_match), | 3316 | .of_match_table = of_match_ptr(da7218_of_match), |
3324 | }, | 3317 | }, |
3325 | .probe = da7218_i2c_probe, | 3318 | .probe = da7218_i2c_probe, |
3326 | .remove = da7218_i2c_remove, | ||
3327 | .id_table = da7218_i2c_id, | 3319 | .id_table = da7218_i2c_id, |
3328 | }; | 3320 | }; |
3329 | 3321 | ||
diff --git a/sound/soc/codecs/da7218.h b/sound/soc/codecs/da7218.h index 4f7ec21069a4..19e6cee2e42e 100644 --- a/sound/soc/codecs/da7218.h +++ b/sound/soc/codecs/da7218.h | |||
@@ -1410,6 +1410,6 @@ struct da7218_priv { | |||
1410 | }; | 1410 | }; |
1411 | 1411 | ||
1412 | /* HP detect control */ | 1412 | /* HP detect control */ |
1413 | int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack); | 1413 | int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack); |
1414 | 1414 | ||
1415 | #endif /* _DA7218_H */ | 1415 | #endif /* _DA7218_H */ |
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index cb72c1e57da0..77a30f0f0c96 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
@@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc; | |||
93 | * Used for passing a codec structure pointer | 93 | * Used for passing a codec structure pointer |
94 | * from the board initialization code to the tty line discipline. | 94 | * from the board initialization code to the tty line discipline. |
95 | */ | 95 | */ |
96 | static struct snd_soc_codec *cx20442_codec; | 96 | static struct snd_soc_component *cx20442_codec; |
97 | 97 | ||
98 | static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, | 98 | static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, |
99 | struct snd_ctl_elem_value *ucontrol) | 99 | struct snd_ctl_elem_value *ucontrol) |
@@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, | |||
105 | int pin, changed = 0; | 105 | int pin, changed = 0; |
106 | 106 | ||
107 | /* Refuse any mode changes if we are not able to control the codec. */ | 107 | /* Refuse any mode changes if we are not able to control the codec. */ |
108 | if (!cx20442_codec->component.card->pop_time) | 108 | if (!cx20442_codec->card->pop_time) |
109 | return -EUNATCH; | 109 | return -EUNATCH; |
110 | 110 | ||
111 | if (ucontrol->value.enumerated.item[0] >= control->items) | 111 | if (ucontrol->value.enumerated.item[0] >= control->items) |
@@ -300,15 +300,15 @@ static int cx81801_open(struct tty_struct *tty) | |||
300 | /* Line discipline .close() */ | 300 | /* Line discipline .close() */ |
301 | static void cx81801_close(struct tty_struct *tty) | 301 | static void cx81801_close(struct tty_struct *tty) |
302 | { | 302 | { |
303 | struct snd_soc_codec *codec = tty->disc_data; | 303 | struct snd_soc_component *component = tty->disc_data; |
304 | struct snd_soc_dapm_context *dapm = &codec->component.card->dapm; | 304 | struct snd_soc_dapm_context *dapm = &component->card->dapm; |
305 | 305 | ||
306 | del_timer_sync(&cx81801_timer); | 306 | del_timer_sync(&cx81801_timer); |
307 | 307 | ||
308 | /* Prevent the hook switch from further changing the DAPM pins */ | 308 | /* Prevent the hook switch from further changing the DAPM pins */ |
309 | INIT_LIST_HEAD(&ams_delta_hook_switch.pins); | 309 | INIT_LIST_HEAD(&ams_delta_hook_switch.pins); |
310 | 310 | ||
311 | if (!codec) | 311 | if (!component) |
312 | return; | 312 | return; |
313 | 313 | ||
314 | v253_ops.close(tty); | 314 | v253_ops.close(tty); |
@@ -338,14 +338,14 @@ static int cx81801_hangup(struct tty_struct *tty) | |||
338 | static void cx81801_receive(struct tty_struct *tty, | 338 | static void cx81801_receive(struct tty_struct *tty, |
339 | const unsigned char *cp, char *fp, int count) | 339 | const unsigned char *cp, char *fp, int count) |
340 | { | 340 | { |
341 | struct snd_soc_codec *codec = tty->disc_data; | 341 | struct snd_soc_component *component = tty->disc_data; |
342 | const unsigned char *c; | 342 | const unsigned char *c; |
343 | int apply, ret; | 343 | int apply, ret; |
344 | 344 | ||
345 | if (!codec) | 345 | if (!component) |
346 | return; | 346 | return; |
347 | 347 | ||
348 | if (!codec->component.card->pop_time) { | 348 | if (!component->card->pop_time) { |
349 | /* First modem response, complete setup procedure */ | 349 | /* First modem response, complete setup procedure */ |
350 | 350 | ||
351 | /* Initialize timer used for config pulse generation */ | 351 | /* Initialize timer used for config pulse generation */ |
@@ -358,7 +358,7 @@ static void cx81801_receive(struct tty_struct *tty, | |||
358 | ARRAY_SIZE(ams_delta_hook_switch_pins), | 358 | ARRAY_SIZE(ams_delta_hook_switch_pins), |
359 | ams_delta_hook_switch_pins); | 359 | ams_delta_hook_switch_pins); |
360 | if (ret) | 360 | if (ret) |
361 | dev_warn(codec->dev, | 361 | dev_warn(component->dev, |
362 | "Failed to link hook switch to DAPM pins, " | 362 | "Failed to link hook switch to DAPM pins, " |
363 | "will continue with hook switch unlinked.\n"); | 363 | "will continue with hook switch unlinked.\n"); |
364 | 364 | ||
@@ -467,7 +467,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) | |||
467 | /* Codec is ready, now add/activate board specific controls */ | 467 | /* Codec is ready, now add/activate board specific controls */ |
468 | 468 | ||
469 | /* Store a pointer to the codec structure for tty ldisc use */ | 469 | /* Store a pointer to the codec structure for tty ldisc use */ |
470 | cx20442_codec = rtd->codec; | 470 | cx20442_codec = rtd->codec_dai->component; |
471 | 471 | ||
472 | /* Set up digital mute if not provided by the codec */ | 472 | /* Set up digital mute if not provided by the codec */ |
473 | if (!codec_dai->driver->ops) { | 473 | if (!codec_dai->driver->ops) { |