Lines Matching +full:mclk +full:- +full:fs

1 // SPDX-License-Identifier: GPL-2.0-or-later
23 #define PMCP2 BIT(1) /* Charge Pump 2: Class-G HP Amp */
118 * from -12.5 to 3 dB in 0.5 dB steps (mute instead of -12.5 dB)
120 static DECLARE_TLV_DB_SCALE(dac_tlv, -1250, 50, 0);
123 * HP-Amp Analog volume control:
124 * from -4.2 to 6 dB in 2 dB steps (mute instead of -4.2 dB)
126 static DECLARE_TLV_DB_SCALE(hpg_tlv, -4200, 20, 0);
132 "+-VDD Operation",
133 "+-1/2VDD Operation"
138 * 0, 0 : Sharp Roll-Off Filter
139 * 0, 1 : Slow Roll-Off Filter
140 * 1, 0 : Short delay Sharp Roll-Off Filter
141 * 1, 1 : Short delay Slow Roll-Off Filter
144 "Sharp Roll-Off Filter",
145 "Slow Roll-Off Filter",
146 "Short delay Sharp Roll-Off Filter",
147 "Short delay Slow Roll-Off Filter",
169 SOC_SINGLE_TLV("HP-Amp Analog Volume",
194 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in ak4375_dac_event()
253 struct snd_soc_component *component = dai->component; in ak4375_hw_params()
257 ak4375->rate = params_rate(params); in ak4375_hw_params()
259 if (ak4375->rate <= 96000) in ak4375_hw_params()
260 ak4375->pld = 0; in ak4375_hw_params()
262 ak4375->pld = 1; in ak4375_hw_params()
264 freq_in = 32 * ak4375->rate / (ak4375->pld + 1); in ak4375_hw_params()
266 if ((ak4375->rate % 8000) == 0) in ak4375_hw_params()
277 struct snd_soc_component *component = dai->component; in ak4375_dai_set_pll()
279 unsigned int mclk, plm, mdiv, div; in ak4375_dai_set_pll() local
280 u8 cms, fs, cm; in ak4375_dai_set_pll() local
283 fs = cms & ~FS_MASK; in ak4375_dai_set_pll()
286 switch (ak4375->rate) { in ak4375_dai_set_pll()
288 fs |= FS_8KHZ; in ak4375_dai_set_pll()
291 fs |= FS_11_025KHZ; in ak4375_dai_set_pll()
294 fs |= FS_16KHZ; in ak4375_dai_set_pll()
297 fs |= FS_22_05KHZ; in ak4375_dai_set_pll()
300 fs |= FS_32KHZ; in ak4375_dai_set_pll()
303 fs |= FS_44_1KHZ; in ak4375_dai_set_pll()
306 fs |= FS_48KHZ; in ak4375_dai_set_pll()
309 fs |= FS_88_2KHZ; in ak4375_dai_set_pll()
312 fs |= FS_96KHZ; in ak4375_dai_set_pll()
315 fs |= FS_176_4KHZ; in ak4375_dai_set_pll()
318 fs |= FS_192KHZ; in ak4375_dai_set_pll()
321 return -EINVAL; in ak4375_dai_set_pll()
324 if (ak4375->rate <= 24000) { in ak4375_dai_set_pll()
326 mclk = 512 * ak4375->rate; in ak4375_dai_set_pll()
327 mdiv = freq_out / mclk - 1; in ak4375_dai_set_pll()
329 } else if (ak4375->rate <= 96000) { in ak4375_dai_set_pll()
331 mclk = 256 * ak4375->rate; in ak4375_dai_set_pll()
332 mdiv = freq_out / mclk - 1; in ak4375_dai_set_pll()
336 mclk = 128 * ak4375->rate; in ak4375_dai_set_pll()
342 snd_soc_component_update_bits(component, AK4375_05_CLOCK_MODE_SELECT, FS_MASK, fs); in ak4375_dai_set_pll()
346 (ak4375->pld & 0xff00) >> 8); in ak4375_dai_set_pll()
348 ak4375->pld & 0x00ff); in ak4375_dai_set_pll()
350 plm = freq_out / freq_in - 1; in ak4375_dai_set_pll()
361 dev_dbg(ak4375->dev, "rate=%d mclk=%d f_in=%d f_out=%d PLD=%d PLM=%d MDIV=%d DIV=%d\n", in ak4375_dai_set_pll()
362 ak4375->rate, mclk, freq_in, freq_out, ak4375->pld, plm, mdiv, div); in ak4375_dai_set_pll()
369 struct snd_soc_component *component = dai->component; in ak4375_mute()
373 dev_dbg(ak4375->dev, "mute=%d val=%d\n", mute, val); in ak4375_mute()
376 ak4375->mute_save = val & DACMUTE_MASK; in ak4375_mute()
379 val |= ak4375->mute_save; in ak4375_mute()
402 .name = "ak4375-hifi",
417 gpiod_set_value_cansleep(ak4375->pdn_gpiod, 0); in ak4375_power_off()
420 regulator_bulk_disable(ARRAY_SIZE(ak4375->supplies), ak4375->supplies); in ak4375_power_off()
427 ret = regulator_bulk_enable(ARRAY_SIZE(ak4375->supplies), ak4375->supplies); in ak4375_power_on()
429 dev_err(ak4375->dev, "Failed to enable regulators: %d\n", ret); in ak4375_power_on()
435 gpiod_set_value_cansleep(ak4375->pdn_gpiod, 1); in ak4375_power_on()
445 regcache_cache_only(ak4375->regmap, true); in ak4375_runtime_suspend()
460 regcache_cache_only(ak4375->regmap, false); in ak4375_runtime_resume()
461 regcache_mark_dirty(ak4375->regmap); in ak4375_runtime_resume()
463 return regcache_sync(ak4375->regmap); in ak4375_runtime_resume()
505 ak4375 = devm_kzalloc(&i2c->dev, sizeof(*ak4375), GFP_KERNEL); in ak4375_i2c_probe()
507 return -ENOMEM; in ak4375_i2c_probe()
509 ak4375->regmap = devm_regmap_init_i2c(i2c, &ak4375_regmap); in ak4375_i2c_probe()
510 if (IS_ERR(ak4375->regmap)) in ak4375_i2c_probe()
511 return PTR_ERR(ak4375->regmap); in ak4375_i2c_probe()
514 ak4375->dev = &i2c->dev; in ak4375_i2c_probe()
516 drvdata = of_device_get_match_data(&i2c->dev); in ak4375_i2c_probe()
519 ak4375->supplies[i].supply = supply_names[i]; in ak4375_i2c_probe()
521 ret = devm_regulator_bulk_get(ak4375->dev, ARRAY_SIZE(ak4375->supplies), ak4375->supplies); in ak4375_i2c_probe()
523 dev_err(ak4375->dev, "Failed to get regulators: %d\n", ret); in ak4375_i2c_probe()
527 ak4375->pdn_gpiod = devm_gpiod_get_optional(ak4375->dev, "pdn", GPIOD_OUT_LOW); in ak4375_i2c_probe()
528 if (IS_ERR(ak4375->pdn_gpiod)) in ak4375_i2c_probe()
529 return dev_err_probe(ak4375->dev, PTR_ERR(ak4375->pdn_gpiod), in ak4375_i2c_probe()
537 regcache_cache_bypass(ak4375->regmap, true); in ak4375_i2c_probe()
539 ret = regmap_read(ak4375->regmap, AK4375_15_AUDIO_IF_FORMAT, &deviceid); in ak4375_i2c_probe()
541 dev_err(ak4375->dev, "unable to read DEVICEID!\n"); in ak4375_i2c_probe()
545 regcache_cache_bypass(ak4375->regmap, false); in ak4375_i2c_probe()
551 dev_err(ak4375->dev, "found untested AK4331\n"); in ak4375_i2c_probe()
552 return -EINVAL; in ak4375_i2c_probe()
554 dev_dbg(ak4375->dev, "found AK4375\n"); in ak4375_i2c_probe()
557 dev_dbg(ak4375->dev, "found AK4375A\n"); in ak4375_i2c_probe()
560 dev_err(ak4375->dev, "found unsupported AK4376/A!\n"); in ak4375_i2c_probe()
561 return -EINVAL; in ak4375_i2c_probe()
563 dev_err(ak4375->dev, "found unsupported AK4377!\n"); in ak4375_i2c_probe()
564 return -EINVAL; in ak4375_i2c_probe()
566 dev_err(ak4375->dev, "unrecognized DEVICEID!\n"); in ak4375_i2c_probe()
567 return -EINVAL; in ak4375_i2c_probe()
570 pm_runtime_set_active(ak4375->dev); in ak4375_i2c_probe()
571 pm_runtime_enable(ak4375->dev); in ak4375_i2c_probe()
573 ret = devm_snd_soc_register_component(ak4375->dev, drvdata->comp_drv, in ak4375_i2c_probe()
574 drvdata->dai_drv, 1); in ak4375_i2c_probe()
576 dev_err(ak4375->dev, "Failed to register CODEC: %d\n", ret); in ak4375_i2c_probe()
585 pm_runtime_disable(&i2c->dev); in ak4375_i2c_remove()
589 { .compatible = "asahi-kasei,ak4375", .data = &ak4375_drvdata },