Lines Matching +full:boost +full:- +full:low +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs35l32.c -- CS35L32 ALSA SoC audio driver
26 #include <sound/soc-dapm.h>
29 #include <dt-bindings/sound/cs35l32.h>
53 { 0x09, 0x20 }, /* Low Battery Threshold */
122 SND_SOC_DAPM_SUPPLY("BOOST", CS35L32_PWRCTL1, 2, 1, NULL, 0),
138 {"Speaker", NULL, "BOOST"},
153 struct snd_soc_component *component = codec_dai->component; in cs35l32_set_dai_fmt()
166 return -EINVAL; in cs35l32_set_dai_fmt()
174 struct snd_soc_component *component = dai->component; in cs35l32_set_tristate()
187 .name = "cs35l32-monitor",
202 int clk_id, int source, unsigned int freq, int dir) in cs35l32_component_set_sysclk() argument
206 switch (freq) { in cs35l32_component_set_sysclk()
220 return -EINVAL; in cs35l32_component_set_sysclk()
271 struct device_node *np = i2c_client->dev.of_node; in cs35l32_handle_of_data()
274 if (of_property_read_u32(np, "cirrus,sdout-share", &val) >= 0) in cs35l32_handle_of_data()
275 pdata->sdout_share = val; in cs35l32_handle_of_data()
277 if (of_property_read_u32(np, "cirrus,boost-manager", &val)) in cs35l32_handle_of_data()
278 val = -1u; in cs35l32_handle_of_data()
285 pdata->boost_mng = val; in cs35l32_handle_of_data()
287 case -1u: in cs35l32_handle_of_data()
289 dev_err(&i2c_client->dev, in cs35l32_handle_of_data()
290 "Wrong cirrus,boost-manager DT value %d\n", val); in cs35l32_handle_of_data()
291 pdata->boost_mng = CS35L32_BOOST_MGR_BYPASS; in cs35l32_handle_of_data()
294 if (of_property_read_u32(np, "cirrus,sdout-datacfg", &val)) in cs35l32_handle_of_data()
295 val = -1u; in cs35l32_handle_of_data()
301 pdata->sdout_datacfg = val; in cs35l32_handle_of_data()
303 case -1u: in cs35l32_handle_of_data()
305 dev_err(&i2c_client->dev, in cs35l32_handle_of_data()
306 "Wrong cirrus,sdout-datacfg DT value %d\n", val); in cs35l32_handle_of_data()
307 pdata->sdout_datacfg = CS35L32_DATA_CFG_LR; in cs35l32_handle_of_data()
310 if (of_property_read_u32(np, "cirrus,battery-threshold", &val)) in cs35l32_handle_of_data()
311 val = -1u; in cs35l32_handle_of_data()
317 pdata->batt_thresh = val; in cs35l32_handle_of_data()
319 case -1u: in cs35l32_handle_of_data()
321 dev_err(&i2c_client->dev, in cs35l32_handle_of_data()
322 "Wrong cirrus,battery-threshold DT value %d\n", val); in cs35l32_handle_of_data()
323 pdata->batt_thresh = CS35L32_BATT_THRESH_3_3V; in cs35l32_handle_of_data()
326 if (of_property_read_u32(np, "cirrus,battery-recovery", &val)) in cs35l32_handle_of_data()
327 val = -1u; in cs35l32_handle_of_data()
335 pdata->batt_recov = val; in cs35l32_handle_of_data()
337 case -1u: in cs35l32_handle_of_data()
339 dev_err(&i2c_client->dev, in cs35l32_handle_of_data()
340 "Wrong cirrus,battery-recovery DT value %d\n", val); in cs35l32_handle_of_data()
341 pdata->batt_recov = CS35L32_BATT_RECOV_3_4V; in cs35l32_handle_of_data()
351 dev_get_platdata(&i2c_client->dev); in cs35l32_i2c_probe()
355 cs35l32 = devm_kzalloc(&i2c_client->dev, sizeof(*cs35l32), GFP_KERNEL); in cs35l32_i2c_probe()
357 return -ENOMEM; in cs35l32_i2c_probe()
361 cs35l32->regmap = devm_regmap_init_i2c(i2c_client, &cs35l32_regmap); in cs35l32_i2c_probe()
362 if (IS_ERR(cs35l32->regmap)) { in cs35l32_i2c_probe()
363 ret = PTR_ERR(cs35l32->regmap); in cs35l32_i2c_probe()
364 dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); in cs35l32_i2c_probe()
369 cs35l32->pdata = *pdata; in cs35l32_i2c_probe()
371 pdata = devm_kzalloc(&i2c_client->dev, sizeof(*pdata), in cs35l32_i2c_probe()
374 return -ENOMEM; in cs35l32_i2c_probe()
376 if (i2c_client->dev.of_node) { in cs35l32_i2c_probe()
378 &cs35l32->pdata); in cs35l32_i2c_probe()
384 for (i = 0; i < ARRAY_SIZE(cs35l32->supplies); i++) in cs35l32_i2c_probe()
385 cs35l32->supplies[i].supply = cs35l32_supply_names[i]; in cs35l32_i2c_probe()
387 ret = devm_regulator_bulk_get(&i2c_client->dev, in cs35l32_i2c_probe()
388 ARRAY_SIZE(cs35l32->supplies), in cs35l32_i2c_probe()
389 cs35l32->supplies); in cs35l32_i2c_probe()
391 dev_err(&i2c_client->dev, in cs35l32_i2c_probe()
396 ret = regulator_bulk_enable(ARRAY_SIZE(cs35l32->supplies), in cs35l32_i2c_probe()
397 cs35l32->supplies); in cs35l32_i2c_probe()
399 dev_err(&i2c_client->dev, in cs35l32_i2c_probe()
405 cs35l32->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, in cs35l32_i2c_probe()
407 if (IS_ERR(cs35l32->reset_gpio)) { in cs35l32_i2c_probe()
408 ret = PTR_ERR(cs35l32->reset_gpio); in cs35l32_i2c_probe()
412 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); in cs35l32_i2c_probe()
415 devid = cirrus_read_device_id(cs35l32->regmap, CS35L32_DEVID_AB); in cs35l32_i2c_probe()
418 dev_err(&i2c_client->dev, "Failed to read device ID: %d\n", ret); in cs35l32_i2c_probe()
423 ret = -ENODEV; in cs35l32_i2c_probe()
424 dev_err(&i2c_client->dev, in cs35l32_i2c_probe()
430 ret = regmap_read(cs35l32->regmap, CS35L32_REV_ID, ®); in cs35l32_i2c_probe()
432 dev_err(&i2c_client->dev, "Get Revision ID failed\n"); in cs35l32_i2c_probe()
436 ret = regmap_register_patch(cs35l32->regmap, cs35l32_monitor_patch, in cs35l32_i2c_probe()
439 dev_err(&i2c_client->dev, "Failed to apply errata patch\n"); in cs35l32_i2c_probe()
443 dev_info(&i2c_client->dev, in cs35l32_i2c_probe()
447 if (cs35l32->pdata.boost_mng) in cs35l32_i2c_probe()
448 regmap_update_bits(cs35l32->regmap, CS35L32_AUDIO_LED_MNGR, in cs35l32_i2c_probe()
450 cs35l32->pdata.boost_mng); in cs35l32_i2c_probe()
453 if (cs35l32->pdata.sdout_share) in cs35l32_i2c_probe()
454 regmap_update_bits(cs35l32->regmap, CS35L32_ADSP_CTL, in cs35l32_i2c_probe()
456 cs35l32->pdata.sdout_share << 3); in cs35l32_i2c_probe()
459 if (cs35l32->pdata.sdout_datacfg) in cs35l32_i2c_probe()
460 regmap_update_bits(cs35l32->regmap, CS35L32_ADSP_CTL, in cs35l32_i2c_probe()
462 cs35l32->pdata.sdout_datacfg << 4); in cs35l32_i2c_probe()
464 /* Setup Low Battery Recovery */ in cs35l32_i2c_probe()
465 if (cs35l32->pdata.batt_recov) in cs35l32_i2c_probe()
466 regmap_update_bits(cs35l32->regmap, CS35L32_BATT_THRESHOLD, in cs35l32_i2c_probe()
468 cs35l32->pdata.batt_recov << 1); in cs35l32_i2c_probe()
470 /* Setup Low Battery Threshold */ in cs35l32_i2c_probe()
471 if (cs35l32->pdata.batt_thresh) in cs35l32_i2c_probe()
472 regmap_update_bits(cs35l32->regmap, CS35L32_BATT_THRESHOLD, in cs35l32_i2c_probe()
474 cs35l32->pdata.batt_thresh << 4); in cs35l32_i2c_probe()
477 regmap_update_bits(cs35l32->regmap, CS35L32_PWRCTL1, CS35L32_PDN_AMP, in cs35l32_i2c_probe()
481 regmap_read(cs35l32->regmap, CS35L32_INT_STATUS_1, ®); in cs35l32_i2c_probe()
483 ret = devm_snd_soc_register_component(&i2c_client->dev, in cs35l32_i2c_probe()
492 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0); in cs35l32_i2c_probe()
494 regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies), in cs35l32_i2c_probe()
495 cs35l32->supplies); in cs35l32_i2c_probe()
504 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0); in cs35l32_i2c_remove()
512 regcache_cache_only(cs35l32->regmap, true); in cs35l32_runtime_suspend()
513 regcache_mark_dirty(cs35l32->regmap); in cs35l32_runtime_suspend()
516 gpiod_set_value_cansleep(cs35l32->reset_gpio, 0); in cs35l32_runtime_suspend()
519 regulator_bulk_disable(ARRAY_SIZE(cs35l32->supplies), in cs35l32_runtime_suspend()
520 cs35l32->supplies); in cs35l32_runtime_suspend()
531 ret = regulator_bulk_enable(ARRAY_SIZE(cs35l32->supplies), in cs35l32_runtime_resume()
532 cs35l32->supplies); in cs35l32_runtime_resume()
539 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); in cs35l32_runtime_resume()
541 regcache_cache_only(cs35l32->regmap, false); in cs35l32_runtime_resume()
542 regcache_sync(cs35l32->regmap); in cs35l32_runtime_resume()