aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 22:10:09 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 04:43:35 -0500
commit2822e66bb812489aff9c41f4b265fcc2d8613989 (patch)
tree19b31838946f5451e4ecad3f2419e17cf971f1b2
parent7928b2cbe55b2a410a0f5c1f154610059c57b1b2 (diff)
ASoC: wm9090: replace codec to component
Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/wm9090.c109
1 files changed, 53 insertions, 56 deletions
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c
index 5a131385cb2f..a9f1a0360a19 100644
--- a/sound/soc/codecs/wm9090.c
+++ b/sound/soc/codecs/wm9090.c
@@ -143,23 +143,23 @@ static bool wm9090_readable(struct device *dev, unsigned int reg)
143 } 143 }
144} 144}
145 145
146static void wait_for_dc_servo(struct snd_soc_codec *codec) 146static void wait_for_dc_servo(struct snd_soc_component *component)
147{ 147{
148 unsigned int reg; 148 unsigned int reg;
149 int count = 0; 149 int count = 0;
150 150
151 dev_dbg(codec->dev, "Waiting for DC servo...\n"); 151 dev_dbg(component->dev, "Waiting for DC servo...\n");
152 do { 152 do {
153 count++; 153 count++;
154 msleep(1); 154 msleep(1);
155 reg = snd_soc_read(codec, WM9090_DC_SERVO_READBACK_0); 155 reg = snd_soc_component_read32(component, WM9090_DC_SERVO_READBACK_0);
156 dev_dbg(codec->dev, "DC servo status: %x\n", reg); 156 dev_dbg(component->dev, "DC servo status: %x\n", reg);
157 } while ((reg & WM9090_DCS_CAL_COMPLETE_MASK) 157 } while ((reg & WM9090_DCS_CAL_COMPLETE_MASK)
158 != WM9090_DCS_CAL_COMPLETE_MASK && count < 1000); 158 != WM9090_DCS_CAL_COMPLETE_MASK && count < 1000);
159 159
160 if ((reg & WM9090_DCS_CAL_COMPLETE_MASK) 160 if ((reg & WM9090_DCS_CAL_COMPLETE_MASK)
161 != WM9090_DCS_CAL_COMPLETE_MASK) 161 != WM9090_DCS_CAL_COMPLETE_MASK)
162 dev_err(codec->dev, "Timed out waiting for DC Servo\n"); 162 dev_err(component->dev, "Timed out waiting for DC Servo\n");
163} 163}
164 164
165static const DECLARE_TLV_DB_RANGE(in_tlv, 165static const DECLARE_TLV_DB_RANGE(in_tlv,
@@ -251,22 +251,22 @@ SOC_SINGLE_TLV("MIXOUTR IN2B Volume", WM9090_OUTPUT_MIXER4, 0, 3, 1,
251static int hp_ev(struct snd_soc_dapm_widget *w, 251static int hp_ev(struct snd_soc_dapm_widget *w,
252 struct snd_kcontrol *kcontrol, int event) 252 struct snd_kcontrol *kcontrol, int event)
253{ 253{
254 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 254 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
255 unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0); 255 unsigned int reg = snd_soc_component_read32(component, WM9090_ANALOGUE_HP_0);
256 256
257 switch (event) { 257 switch (event) {
258 case SND_SOC_DAPM_POST_PMU: 258 case SND_SOC_DAPM_POST_PMU:
259 snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, 259 snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1,
260 WM9090_CP_ENA, WM9090_CP_ENA); 260 WM9090_CP_ENA, WM9090_CP_ENA);
261 261
262 msleep(5); 262 msleep(5);
263 263
264 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, 264 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
265 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, 265 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA,
266 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA); 266 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA);
267 267
268 reg |= WM9090_HPOUT1L_DLY | WM9090_HPOUT1R_DLY; 268 reg |= WM9090_HPOUT1L_DLY | WM9090_HPOUT1R_DLY;
269 snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); 269 snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
270 270
271 /* Start the DC servo. We don't currently use the 271 /* Start the DC servo. We don't currently use the
272 * ability to save the state since we don't have full 272 * ability to save the state since we don't have full
@@ -274,16 +274,16 @@ static int hp_ev(struct snd_soc_dapm_widget *w,
274 * DC offsets; see the WM8904 driver for an example of 274 * DC offsets; see the WM8904 driver for an example of
275 * doing so. 275 * doing so.
276 */ 276 */
277 snd_soc_write(codec, WM9090_DC_SERVO_0, 277 snd_soc_component_write(component, WM9090_DC_SERVO_0,
278 WM9090_DCS_ENA_CHAN_0 | 278 WM9090_DCS_ENA_CHAN_0 |
279 WM9090_DCS_ENA_CHAN_1 | 279 WM9090_DCS_ENA_CHAN_1 |
280 WM9090_DCS_TRIG_STARTUP_1 | 280 WM9090_DCS_TRIG_STARTUP_1 |
281 WM9090_DCS_TRIG_STARTUP_0); 281 WM9090_DCS_TRIG_STARTUP_0);
282 wait_for_dc_servo(codec); 282 wait_for_dc_servo(component);
283 283
284 reg |= WM9090_HPOUT1R_OUTP | WM9090_HPOUT1R_RMV_SHORT | 284 reg |= WM9090_HPOUT1R_OUTP | WM9090_HPOUT1R_RMV_SHORT |
285 WM9090_HPOUT1L_OUTP | WM9090_HPOUT1L_RMV_SHORT; 285 WM9090_HPOUT1L_OUTP | WM9090_HPOUT1L_RMV_SHORT;
286 snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); 286 snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
287 break; 287 break;
288 288
289 case SND_SOC_DAPM_PRE_PMD: 289 case SND_SOC_DAPM_PRE_PMD:
@@ -294,15 +294,15 @@ static int hp_ev(struct snd_soc_dapm_widget *w,
294 WM9090_HPOUT1R_DLY | 294 WM9090_HPOUT1R_DLY |
295 WM9090_HPOUT1R_OUTP); 295 WM9090_HPOUT1R_OUTP);
296 296
297 snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); 297 snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg);
298 298
299 snd_soc_write(codec, WM9090_DC_SERVO_0, 0); 299 snd_soc_component_write(component, WM9090_DC_SERVO_0, 0);
300 300
301 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, 301 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
302 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, 302 WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA,
303 0); 303 0);
304 304
305 snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, 305 snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1,
306 WM9090_CP_ENA, 0); 306 WM9090_CP_ENA, 0);
307 break; 307 break;
308 } 308 }
@@ -419,10 +419,10 @@ static const struct snd_soc_dapm_route audio_map_in2_diff[] = {
419 { "IN2A PGA", NULL, "IN2-" }, 419 { "IN2A PGA", NULL, "IN2-" },
420}; 420};
421 421
422static int wm9090_add_controls(struct snd_soc_codec *codec) 422static int wm9090_add_controls(struct snd_soc_component *component)
423{ 423{
424 struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); 424 struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component);
425 struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); 425 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
426 int i; 426 int i;
427 427
428 snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets, 428 snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets,
@@ -430,7 +430,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
430 430
431 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); 431 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
432 432
433 snd_soc_add_codec_controls(codec, wm9090_controls, 433 snd_soc_add_component_controls(component, wm9090_controls,
434 ARRAY_SIZE(wm9090_controls)); 434 ARRAY_SIZE(wm9090_controls));
435 435
436 if (wm9090->pdata.lin1_diff) { 436 if (wm9090->pdata.lin1_diff) {
@@ -439,7 +439,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
439 } else { 439 } else {
440 snd_soc_dapm_add_routes(dapm, audio_map_in1_se, 440 snd_soc_dapm_add_routes(dapm, audio_map_in1_se,
441 ARRAY_SIZE(audio_map_in1_se)); 441 ARRAY_SIZE(audio_map_in1_se));
442 snd_soc_add_codec_controls(codec, wm9090_in1_se_controls, 442 snd_soc_add_component_controls(component, wm9090_in1_se_controls,
443 ARRAY_SIZE(wm9090_in1_se_controls)); 443 ARRAY_SIZE(wm9090_in1_se_controls));
444 } 444 }
445 445
@@ -449,18 +449,18 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
449 } else { 449 } else {
450 snd_soc_dapm_add_routes(dapm, audio_map_in2_se, 450 snd_soc_dapm_add_routes(dapm, audio_map_in2_se,
451 ARRAY_SIZE(audio_map_in2_se)); 451 ARRAY_SIZE(audio_map_in2_se));
452 snd_soc_add_codec_controls(codec, wm9090_in2_se_controls, 452 snd_soc_add_component_controls(component, wm9090_in2_se_controls,
453 ARRAY_SIZE(wm9090_in2_se_controls)); 453 ARRAY_SIZE(wm9090_in2_se_controls));
454 } 454 }
455 455
456 if (wm9090->pdata.agc_ena) { 456 if (wm9090->pdata.agc_ena) {
457 for (i = 0; i < ARRAY_SIZE(wm9090->pdata.agc); i++) 457 for (i = 0; i < ARRAY_SIZE(wm9090->pdata.agc); i++)
458 snd_soc_write(codec, WM9090_AGC_CONTROL_0 + i, 458 snd_soc_component_write(component, WM9090_AGC_CONTROL_0 + i,
459 wm9090->pdata.agc[i]); 459 wm9090->pdata.agc[i]);
460 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, 460 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3,
461 WM9090_AGC_ENA, WM9090_AGC_ENA); 461 WM9090_AGC_ENA, WM9090_AGC_ENA);
462 } else { 462 } else {
463 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, 463 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3,
464 WM9090_AGC_ENA, 0); 464 WM9090_AGC_ENA, 0);
465 } 465 }
466 466
@@ -472,19 +472,19 @@ static int wm9090_add_controls(struct snd_soc_codec *codec)
472 * The machine driver should call this from their set_bias_level; if there 472 * The machine driver should call this from their set_bias_level; if there
473 * isn't one then this can just be set as the set_bias_level function. 473 * isn't one then this can just be set as the set_bias_level function.
474 */ 474 */
475static int wm9090_set_bias_level(struct snd_soc_codec *codec, 475static int wm9090_set_bias_level(struct snd_soc_component *component,
476 enum snd_soc_bias_level level) 476 enum snd_soc_bias_level level)
477{ 477{
478 struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); 478 struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component);
479 479
480 switch (level) { 480 switch (level) {
481 case SND_SOC_BIAS_ON: 481 case SND_SOC_BIAS_ON:
482 break; 482 break;
483 483
484 case SND_SOC_BIAS_PREPARE: 484 case SND_SOC_BIAS_PREPARE:
485 snd_soc_update_bits(codec, WM9090_ANTIPOP2, WM9090_VMID_ENA, 485 snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA,
486 WM9090_VMID_ENA); 486 WM9090_VMID_ENA);
487 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, 487 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
488 WM9090_BIAS_ENA | 488 WM9090_BIAS_ENA |
489 WM9090_VMID_RES_MASK, 489 WM9090_VMID_RES_MASK,
490 WM9090_BIAS_ENA | 490 WM9090_BIAS_ENA |
@@ -493,7 +493,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
493 break; 493 break;
494 494
495 case SND_SOC_BIAS_STANDBY: 495 case SND_SOC_BIAS_STANDBY:
496 if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { 496 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
497 /* Restore the register cache */ 497 /* Restore the register cache */
498 regcache_sync(wm9090->regmap); 498 regcache_sync(wm9090->regmap);
499 } 499 }
@@ -502,9 +502,9 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
502 * ground referenced outputs and class D speaker mean that 502 * ground referenced outputs and class D speaker mean that
503 * latency is not an issue. 503 * latency is not an issue.
504 */ 504 */
505 snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, 505 snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1,
506 WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, 0); 506 WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, 0);
507 snd_soc_update_bits(codec, WM9090_ANTIPOP2, 507 snd_soc_component_update_bits(component, WM9090_ANTIPOP2,
508 WM9090_VMID_ENA, 0); 508 WM9090_VMID_ENA, 0);
509 break; 509 break;
510 510
@@ -515,45 +515,49 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec,
515 return 0; 515 return 0;
516} 516}
517 517
518static int wm9090_probe(struct snd_soc_codec *codec) 518static int wm9090_probe(struct snd_soc_component *component)
519{ 519{
520 /* Configure some defaults; they will be written out when we 520 /* Configure some defaults; they will be written out when we
521 * bring the bias up. 521 * bring the bias up.
522 */ 522 */
523 snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, 523 snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_A_VOLUME,
524 WM9090_IN1_VU | WM9090_IN1A_ZC, 524 WM9090_IN1_VU | WM9090_IN1A_ZC,
525 WM9090_IN1_VU | WM9090_IN1A_ZC); 525 WM9090_IN1_VU | WM9090_IN1A_ZC);
526 snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, 526 snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_B_VOLUME,
527 WM9090_IN1_VU | WM9090_IN1B_ZC, 527 WM9090_IN1_VU | WM9090_IN1B_ZC,
528 WM9090_IN1_VU | WM9090_IN1B_ZC); 528 WM9090_IN1_VU | WM9090_IN1B_ZC);
529 snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, 529 snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_A_VOLUME,
530 WM9090_IN2_VU | WM9090_IN2A_ZC, 530 WM9090_IN2_VU | WM9090_IN2A_ZC,
531 WM9090_IN2_VU | WM9090_IN2A_ZC); 531 WM9090_IN2_VU | WM9090_IN2A_ZC);
532 snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, 532 snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_B_VOLUME,
533 WM9090_IN2_VU | WM9090_IN2B_ZC, 533 WM9090_IN2_VU | WM9090_IN2B_ZC,
534 WM9090_IN2_VU | WM9090_IN2B_ZC); 534 WM9090_IN2_VU | WM9090_IN2B_ZC);
535 snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, 535 snd_soc_component_update_bits(component, WM9090_SPEAKER_VOLUME_LEFT,
536 WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, 536 WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC,
537 WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); 537 WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC);
538 snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, 538 snd_soc_component_update_bits(component, WM9090_LEFT_OUTPUT_VOLUME,
539 WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, 539 WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC,
540 WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); 540 WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC);
541 snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, 541 snd_soc_component_update_bits(component, WM9090_RIGHT_OUTPUT_VOLUME,
542 WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, 542 WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC,
543 WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC); 543 WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC);
544 544
545 snd_soc_update_bits(codec, WM9090_CLOCKING_1, 545 snd_soc_component_update_bits(component, WM9090_CLOCKING_1,
546 WM9090_TOCLK_ENA, WM9090_TOCLK_ENA); 546 WM9090_TOCLK_ENA, WM9090_TOCLK_ENA);
547 547
548 wm9090_add_controls(codec); 548 wm9090_add_controls(component);
549 549
550 return 0; 550 return 0;
551} 551}
552 552
553static const struct snd_soc_codec_driver soc_codec_dev_wm9090 = { 553static const struct snd_soc_component_driver soc_component_dev_wm9090 = {
554 .probe = wm9090_probe, 554 .probe = wm9090_probe,
555 .set_bias_level = wm9090_set_bias_level, 555 .set_bias_level = wm9090_set_bias_level,
556 .suspend_bias_off = true, 556 .suspend_bias_off = 1,
557 .idle_bias_on = 1,
558 .use_pmdown_time = 1,
559 .endianness = 1,
560 .non_legacy_dai_naming = 1,
557}; 561};
558 562
559static const struct regmap_config wm9090_regmap = { 563static const struct regmap_config wm9090_regmap = {
@@ -607,8 +611,8 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,
607 611
608 i2c_set_clientdata(i2c, wm9090); 612 i2c_set_clientdata(i2c, wm9090);
609 613
610 ret = snd_soc_register_codec(&i2c->dev, 614 ret = devm_snd_soc_register_component(&i2c->dev,
611 &soc_codec_dev_wm9090, NULL, 0); 615 &soc_component_dev_wm9090, NULL, 0);
612 if (ret != 0) { 616 if (ret != 0) {
613 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 617 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
614 return ret; 618 return ret;
@@ -617,12 +621,6 @@ static int wm9090_i2c_probe(struct i2c_client *i2c,
617 return 0; 621 return 0;
618} 622}
619 623
620static int wm9090_i2c_remove(struct i2c_client *i2c)
621{
622 snd_soc_unregister_codec(&i2c->dev);
623 return 0;
624}
625
626static const struct i2c_device_id wm9090_id[] = { 624static const struct i2c_device_id wm9090_id[] = {
627 { "wm9090", 0 }, 625 { "wm9090", 0 },
628 { "wm9093", 0 }, 626 { "wm9093", 0 },
@@ -635,7 +633,6 @@ static struct i2c_driver wm9090_i2c_driver = {
635 .name = "wm9090", 633 .name = "wm9090",
636 }, 634 },
637 .probe = wm9090_i2c_probe, 635 .probe = wm9090_i2c_probe,
638 .remove = wm9090_i2c_remove,
639 .id_table = wm9090_id, 636 .id_table = wm9090_id,
640}; 637};
641 638