Lines Matching +full:power +full:- +full:supplies

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8523.c -- WM8523 ALSA SoC Audio driver
40 struct regulator_bulk_data supplies[WM8523_NUM_SUPPLIES]; member
47 { 2, 0x0000 }, /* R2 - PSCTRL1 */
48 { 3, 0x1812 }, /* R3 - AIF_CTRL1 */
49 { 4, 0x0000 }, /* R4 - AIF_CTRL2 */
50 { 5, 0x0001 }, /* R5 - DAC_CTRL3 */
51 { 6, 0x0190 }, /* R6 - DAC_GAINL */
52 { 7, 0x0190 }, /* R7 - DAC_GAINR */
53 { 8, 0x0000 }, /* R8 - ZERO_DETECT */
67 static const DECLARE_TLV_DB_SCALE(dac_tlv, -10000, 25, 0);
124 struct snd_soc_component *component = dai->component; in wm8523_startup()
128 * MCLK supplied to the CODEC - enforce this. in wm8523_startup()
130 if (!wm8523->sysclk) { in wm8523_startup()
131 dev_err(component->dev, in wm8523_startup()
133 return -EINVAL; in wm8523_startup()
136 snd_pcm_hw_constraint_list(substream->runtime, 0, in wm8523_startup()
138 &wm8523->rate_constraint); in wm8523_startup()
147 struct snd_soc_component *component = dai->component; in wm8523_hw_params()
155 if (wm8523->sysclk / params_rate(params) == in wm8523_hw_params()
162 dev_err(component->dev, "MCLK/fs ratio %d unsupported\n", in wm8523_hw_params()
163 wm8523->sysclk / params_rate(params)); in wm8523_hw_params()
164 return -EINVAL; in wm8523_hw_params()
171 /* Find a fs->bclk ratio */ in wm8523_hw_params()
177 dev_err(component->dev, in wm8523_hw_params()
180 return -EINVAL; in wm8523_hw_params()
211 struct snd_soc_component *component = codec_dai->component; in wm8523_set_dai_sysclk()
216 wm8523->sysclk = freq; in wm8523_set_dai_sysclk()
218 wm8523->rate_constraint.count = 0; in wm8523_set_dai_sysclk()
238 dev_dbg(component->dev, "Supported sample rate: %dHz\n", in wm8523_set_dai_sysclk()
240 wm8523->rate_constraint_list[i] = val; in wm8523_set_dai_sysclk()
241 wm8523->rate_constraint.count++; in wm8523_set_dai_sysclk()
244 dev_dbg(component->dev, "Skipping sample rate: %dHz\n", in wm8523_set_dai_sysclk()
250 if (wm8523->rate_constraint.count == 0) in wm8523_set_dai_sysclk()
251 return -EINVAL; in wm8523_set_dai_sysclk()
260 struct snd_soc_component *component = codec_dai->component; in wm8523_set_dai_fmt()
273 return -EINVAL; in wm8523_set_dai_fmt()
292 return -EINVAL; in wm8523_set_dai_fmt()
308 return -EINVAL; in wm8523_set_dai_fmt()
327 /* Full power on */ in wm8523_set_bias_level()
334 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), in wm8523_set_bias_level()
335 wm8523->supplies); in wm8523_set_bias_level()
337 dev_err(component->dev, in wm8523_set_bias_level()
338 "Failed to enable supplies: %d\n", in wm8523_set_bias_level()
344 regcache_sync(wm8523->regmap); in wm8523_set_bias_level()
346 /* Initial power up */ in wm8523_set_bias_level()
353 /* Power up to mute */ in wm8523_set_bias_level()
360 /* The chip runs through the power down sequence for us. */ in wm8523_set_bias_level()
365 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), in wm8523_set_bias_level()
366 wm8523->supplies); in wm8523_set_bias_level()
385 .name = "wm8523-hifi",
400 wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; in wm8523_probe()
401 wm8523->rate_constraint.count = in wm8523_probe()
402 ARRAY_SIZE(wm8523->rate_constraint_list); in wm8523_probe()
404 /* Change some default settings - latch VU and enable ZC */ in wm8523_probe()
451 wm8523 = devm_kzalloc(&i2c->dev, sizeof(struct wm8523_priv), in wm8523_i2c_probe()
454 return -ENOMEM; in wm8523_i2c_probe()
456 wm8523->regmap = devm_regmap_init_i2c(i2c, &wm8523_regmap); in wm8523_i2c_probe()
457 if (IS_ERR(wm8523->regmap)) { in wm8523_i2c_probe()
458 ret = PTR_ERR(wm8523->regmap); in wm8523_i2c_probe()
459 dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret); in wm8523_i2c_probe()
463 for (i = 0; i < ARRAY_SIZE(wm8523->supplies); i++) in wm8523_i2c_probe()
464 wm8523->supplies[i].supply = wm8523_supply_names[i]; in wm8523_i2c_probe()
466 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8523->supplies), in wm8523_i2c_probe()
467 wm8523->supplies); in wm8523_i2c_probe()
469 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in wm8523_i2c_probe()
473 ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), in wm8523_i2c_probe()
474 wm8523->supplies); in wm8523_i2c_probe()
476 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in wm8523_i2c_probe()
480 ret = regmap_read(wm8523->regmap, WM8523_DEVICE_ID, &val); in wm8523_i2c_probe()
482 dev_err(&i2c->dev, "Failed to read ID register\n"); in wm8523_i2c_probe()
486 dev_err(&i2c->dev, "Device is not a WM8523, ID is %x\n", ret); in wm8523_i2c_probe()
487 ret = -EINVAL; in wm8523_i2c_probe()
491 ret = regmap_read(wm8523->regmap, WM8523_REVISION, &val); in wm8523_i2c_probe()
493 dev_err(&i2c->dev, "Failed to read revision register\n"); in wm8523_i2c_probe()
496 dev_info(&i2c->dev, "revision %c\n", in wm8523_i2c_probe()
499 ret = regmap_write(wm8523->regmap, WM8523_DEVICE_ID, 0x8523); in wm8523_i2c_probe()
501 dev_err(&i2c->dev, "Failed to reset device: %d\n", ret); in wm8523_i2c_probe()
505 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); in wm8523_i2c_probe()
509 ret = devm_snd_soc_register_component(&i2c->dev, in wm8523_i2c_probe()
515 regulator_bulk_disable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); in wm8523_i2c_probe()