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",
449 st->iovdd = devm_regulator_get(st->dev, "iovdd"); in adau7118_regulator_setup()
450 if (IS_ERR(st->iovdd)) { in adau7118_regulator_setup()
451 dev_err(st->dev, "Could not get iovdd: %ld\n", in adau7118_regulator_setup()
452 PTR_ERR(st->iovdd)); in adau7118_regulator_setup()
453 return PTR_ERR(st->iovdd); in adau7118_regulator_setup()
456 st->dvdd = devm_regulator_get(st->dev, "dvdd"); in adau7118_regulator_setup()
457 if (IS_ERR(st->dvdd)) { in adau7118_regulator_setup()
458 dev_err(st->dev, "Could not get dvdd: %ld\n", in adau7118_regulator_setup()
459 PTR_ERR(st->dvdd)); in adau7118_regulator_setup()
460 return PTR_ERR(st->dvdd); in adau7118_regulator_setup()
463 if (!st->hw_mode) { in adau7118_regulator_setup()
464 regcache_mark_dirty(st->map); in adau7118_regulator_setup()
465 regcache_cache_only(st->map, true); in adau7118_regulator_setup()
478 if (st->hw_mode) in adau7118_parset_dt()
481 ret = device_property_read_u32(st->dev, "adi,decimation-ratio", in adau7118_parset_dt()
495 dev_err(st->dev, "Invalid dec ratio: %u", dec_ratio); in adau7118_parset_dt()
496 return -EINVAL; in adau7118_parset_dt()
499 ret = regmap_update_bits(st->map, in adau7118_parset_dt()
506 ret = device_property_read_u32_array(st->dev, "adi,pdm-clk-map", in adau7118_parset_dt()
509 int pdm; in adau7118_parset_dt() local
512 for (pdm = 0; pdm < ARRAY_SIZE(clk_map); pdm++) in adau7118_parset_dt()
513 _clk_map |= (clk_map[pdm] << (pdm + 4)); in adau7118_parset_dt()
515 ret = regmap_update_bits(st->map, in adau7118_parset_dt()
525 int adau7118_probe(struct device *dev, struct regmap *map, bool hw_mode) in adau7118_probe() argument
532 return -ENOMEM; in adau7118_probe()
534 st->dev = dev; in adau7118_probe()
535 st->hw_mode = hw_mode; in adau7118_probe()
539 st->map = map; in adau7118_probe()
545 ret = regmap_update_bits(map, ADAU7118_REG_RESET, in adau7118_probe()
567 MODULE_DESCRIPTION("ADAU7118 8 channel PDM-to-I2S/TDM Converter driver");