Lines Matching +full:pdm +full:- +full:clk +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0
3 // Analog Devices ADAU7118 8 channel PDM-to-I2S/TDM Converter driver
36 struct regmap *map; member
65 /* PDM Clocks */
128 snd_soc_component_get_drvdata(dai->component); in adau7118_set_channel_map()
131 dev_dbg(st->dev, "Set channel map, %d", tx_num); in adau7118_set_channel_map()
134 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_channel_map()
148 snd_soc_component_get_drvdata(dai->component); in adau7118_set_fmt()
152 dev_dbg(st->dev, "Set format, fmt:%d\n", fmt); in adau7118_set_fmt()
156 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_fmt()
162 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_fmt()
168 st->right_j = true; in adau7118_set_fmt()
171 dev_err(st->dev, "Invalid format %d", in adau7118_set_fmt()
173 return -EINVAL; in adau7118_set_fmt()
193 dev_err(st->dev, "Invalid Inv mask %d", in adau7118_set_fmt()
195 return -EINVAL; in adau7118_set_fmt()
198 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_fmt()
211 snd_soc_component_get_drvdata(dai->component); in adau7118_set_tristate()
214 dev_dbg(st->dev, "Set tristate, %d\n", tristate); in adau7118_set_tristate()
216 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_tristate()
231 snd_soc_component_get_drvdata(dai->component); in adau7118_set_tdm_slot()
235 dev_dbg(st->dev, "Set tdm, slots:%d width:%d\n", slots, slot_width); in adau7118_set_tdm_slot()
248 dev_err(st->dev, "Invalid slot width:%d\n", slot_width); in adau7118_set_tdm_slot()
249 return -EINVAL; in adau7118_set_tdm_slot()
252 ret = snd_soc_component_update_bits(dai->component, in adau7118_set_tdm_slot()
258 st->slot_width = slot_width; in adau7118_set_tdm_slot()
259 st->slots = slots; in adau7118_set_tdm_slot()
269 snd_soc_component_get_drvdata(dai->component); in adau7118_hw_params()
274 if (!st->slots) { in adau7118_hw_params()
276 ret = snd_soc_component_update_bits(dai->component, in adau7118_hw_params()
285 slots_width = st->slot_width; in adau7118_hw_params()
289 dev_err(st->dev, "Invalid data_width:%d, slots_width:%d", in adau7118_hw_params()
291 return -EINVAL; in adau7118_hw_params()
294 if (st->right_j) { in adau7118_hw_params()
295 switch (slots_width - data_width) { in adau7118_hw_params()
309 dev_err(st->dev, in adau7118_hw_params()
312 return -EINVAL; in adau7118_hw_params()
315 ret = snd_soc_component_update_bits(dai->component, in adau7118_hw_params()
332 dev_dbg(st->dev, "Set bias level %d\n", level); in adau7118_set_bias_level()
343 ret = regulator_enable(st->iovdd); in adau7118_set_bias_level()
348 ret = regulator_enable(st->dvdd); in adau7118_set_bias_level()
350 regulator_disable(st->iovdd); in adau7118_set_bias_level()
354 if (st->hw_mode) in adau7118_set_bias_level()
357 regcache_cache_only(st->map, false); in adau7118_set_bias_level()
364 ret = regulator_disable(st->dvdd); in adau7118_set_bias_level()
368 ret = regulator_disable(st->iovdd); in adau7118_set_bias_level()
372 if (st->hw_mode) in adau7118_set_bias_level()
376 regcache_mark_dirty(st->map); in adau7118_set_bias_level()
377 regcache_cache_only(st->map, true); in adau7118_set_bias_level()
392 if (st->hw_mode) { in adau7118_component_probe()
401 snd_soc_component_init_regmap(component, st->map); in adau7118_component_probe()
423 .name = "adau7118-hifi-capture",
457 ret = regulator_disable(st->dvdd); in adau7118_regulator_disable()
461 regulator_disable(st->iovdd); in adau7118_regulator_disable()
466 st->iovdd = devm_regulator_get(st->dev, "iovdd"); in adau7118_regulator_setup()
467 if (IS_ERR(st->iovdd)) { in adau7118_regulator_setup()
468 dev_err(st->dev, "Could not get iovdd: %ld\n", in adau7118_regulator_setup()
469 PTR_ERR(st->iovdd)); in adau7118_regulator_setup()
470 return PTR_ERR(st->iovdd); in adau7118_regulator_setup()
473 st->dvdd = devm_regulator_get(st->dev, "dvdd"); in adau7118_regulator_setup()
474 if (IS_ERR(st->dvdd)) { in adau7118_regulator_setup()
475 dev_err(st->dev, "Could not get dvdd: %ld\n", in adau7118_regulator_setup()
476 PTR_ERR(st->dvdd)); in adau7118_regulator_setup()
477 return PTR_ERR(st->dvdd); in adau7118_regulator_setup()
480 if (!st->hw_mode) { in adau7118_regulator_setup()
481 regcache_mark_dirty(st->map); in adau7118_regulator_setup()
482 regcache_cache_only(st->map, true); in adau7118_regulator_setup()
485 return devm_add_action_or_reset(st->dev, adau7118_regulator_disable, in adau7118_regulator_setup()
496 if (st->hw_mode) in adau7118_parset_dt()
499 ret = device_property_read_u32(st->dev, "adi,decimation-ratio", in adau7118_parset_dt()
513 dev_err(st->dev, "Invalid dec ratio: %u", dec_ratio); in adau7118_parset_dt()
514 return -EINVAL; in adau7118_parset_dt()
517 ret = regmap_update_bits(st->map, in adau7118_parset_dt()
524 ret = device_property_read_u32_array(st->dev, "adi,pdm-clk-map", in adau7118_parset_dt()
527 int pdm; in adau7118_parset_dt() local
530 for (pdm = 0; pdm < ARRAY_SIZE(clk_map); pdm++) in adau7118_parset_dt()
531 _clk_map |= (clk_map[pdm] << (pdm + 4)); in adau7118_parset_dt()
533 ret = regmap_update_bits(st->map, in adau7118_parset_dt()
543 int adau7118_probe(struct device *dev, struct regmap *map, bool hw_mode) in adau7118_probe() argument
550 return -ENOMEM; in adau7118_probe()
552 st->dev = dev; in adau7118_probe()
553 st->hw_mode = hw_mode; in adau7118_probe()
557 st->map = map; in adau7118_probe()
563 ret = regmap_update_bits(map, ADAU7118_REG_RESET, in adau7118_probe()
585 MODULE_DESCRIPTION("ADAU7118 8 channel PDM-to-I2S/TDM Converter driver");