Lines Matching +full:rate +full:- +full:np +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only
3 * arizona.c - Wolfson Arizona class device shared support
67 dev_err(_fll->arizona->dev, "FLL%d: " fmt, _fll->id, ##__VA_ARGS__)
69 dev_warn(_fll->arizona->dev, "FLL%d: " fmt, _fll->id, ##__VA_ARGS__)
71 dev_dbg(_fll->arizona->dev, "FLL%d: " fmt, _fll->id, ##__VA_ARGS__)
74 dev_err(_dai->dev, "AIF%d: " fmt, _dai->id, ##__VA_ARGS__)
76 dev_warn(_dai->dev, "AIF%d: " fmt, _dai->id, ##__VA_ARGS__)
78 dev_dbg(_dai->dev, "AIF%d: " fmt, _dai->id, ##__VA_ARGS__)
84 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_spk_ev()
85 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in arizona_spk_ev()
93 dev_crit(arizona->dev, in arizona_spk_ev()
95 return -EBUSY; in arizona_spk_ev()
98 regmap_update_bits_async(arizona->regmap, in arizona_spk_ev()
100 1 << w->shift, 1 << w->shift); in arizona_spk_ev()
103 regmap_update_bits_async(arizona->regmap, in arizona_spk_ev()
105 1 << w->shift, 0); in arizona_spk_ev()
120 ret = regmap_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_3, in arizona_thermal_warn()
123 dev_err(arizona->dev, "Failed to read thermal status: %d\n", in arizona_thermal_warn()
126 dev_crit(arizona->dev, "Thermal warning\n"); in arizona_thermal_warn()
138 ret = regmap_read(arizona->regmap, ARIZONA_INTERRUPT_RAW_STATUS_3, in arizona_thermal_shutdown()
141 dev_err(arizona->dev, "Failed to read thermal status: %d\n", in arizona_thermal_shutdown()
144 dev_crit(arizona->dev, "Thermal shutdown\n"); in arizona_thermal_shutdown()
145 ret = regmap_update_bits(arizona->regmap, in arizona_thermal_shutdown()
150 dev_crit(arizona->dev, in arizona_thermal_shutdown()
174 struct arizona *arizona = priv->arizona; in arizona_init_spk()
181 switch (arizona->type) { in arizona_init_spk()
205 dev_err(arizona->dev, in arizona_init_spk_irqs()
213 dev_err(arizona->dev, in arizona_init_spk_irqs()
243 struct arizona *arizona = priv->arizona; in arizona_init_mono()
247 if (arizona->pdata.out_mono[i]) in arizona_init_mono()
259 struct arizona *arizona = priv->arizona; in arizona_init_gpio()
262 switch (arizona->type) { in arizona_init_gpio()
274 for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { in arizona_init_gpio()
275 switch (arizona->pdata.gpio_defaults[i] & ARIZONA_GPN_FN_MASK) { in arizona_init_gpio()
295 struct arizona_pdata *pdata = &arizona->pdata; in arizona_init_common()
299 BLOCKING_INIT_NOTIFIER_HEAD(&arizona->notifier); in arizona_init_common()
303 if (pdata->out_mono[i]) in arizona_init_common()
308 regmap_update_bits(arizona->regmap, in arizona_init_common()
314 if (pdata->spk_mute[i]) in arizona_init_common()
315 regmap_update_bits(arizona->regmap, in arizona_init_common()
319 pdata->spk_mute[i]); in arizona_init_common()
321 if (pdata->spk_fmt[i]) in arizona_init_common()
322 regmap_update_bits(arizona->regmap, in arizona_init_common()
325 pdata->spk_fmt[i]); in arizona_init_common()
330 val = pdata->dmic_ref[i] << ARIZONA_IN1_DMIC_SUP_SHIFT; in arizona_init_common()
331 if (pdata->inmode[i] & ARIZONA_INMODE_DMIC) in arizona_init_common()
334 switch (arizona->type) { in arizona_init_common()
337 regmap_update_bits(arizona->regmap, in arizona_init_common()
340 (pdata->inmode[i] & ARIZONA_INMODE_SE) in arizona_init_common()
343 regmap_update_bits(arizona->regmap, in arizona_init_common()
346 (pdata->inmode[i] & ARIZONA_INMODE_SE) in arizona_init_common()
353 if (pdata->inmode[i] & ARIZONA_INMODE_SE) in arizona_init_common()
362 regmap_update_bits(arizona->regmap, in arizona_init_common()
375 for (i = 0; i < ARRAY_SIZE(arizona->pdata.out_vol_limit); ++i) { in arizona_init_vol_limit()
376 if (arizona->pdata.out_vol_limit[i]) in arizona_init_vol_limit()
377 regmap_update_bits(arizona->regmap, in arizona_init_vol_limit()
380 arizona->pdata.out_vol_limit[i]); in arizona_init_vol_limit()
603 const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0);
633 "SYNCCLK rate", "8kHz", "16kHz", "ASYNCCLK rate",
677 ARIZONA_RATE_ENUM_SIZE - 1,
682 "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB",
683 "15ms/6dB", "30ms/6dB",
711 "Low-pass", "High-pass"
739 "30ms", "120ms", "250ms", "500ms",
891 for (i = 0; i < priv->num_inputs; i++) in arizona_in_set_vu()
909 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_in_ev()
913 if (w->shift % 2) in arizona_in_ev()
914 reg = ARIZONA_ADC_DIGITAL_VOLUME_1L + ((w->shift / 2) * 8); in arizona_in_ev()
916 reg = ARIZONA_ADC_DIGITAL_VOLUME_1R + ((w->shift / 2) * 8); in arizona_in_ev()
920 priv->in_pending++; in arizona_in_ev()
927 priv->in_pending--; in arizona_in_ev()
928 if (priv->in_pending == 0) { in arizona_in_ev()
956 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_out_ev()
958 struct arizona *arizona = priv->arizona; in arizona_out_ev()
962 switch (w->shift) { in arizona_out_ev()
969 priv->out_up_pending++; in arizona_out_ev()
970 priv->out_up_delay += 17; in arizona_out_ev()
974 priv->out_up_pending++; in arizona_out_ev()
975 switch (arizona->type) { in arizona_out_ev()
980 priv->out_up_delay += 10; in arizona_out_ev()
989 switch (w->shift) { in arizona_out_ev()
998 priv->out_up_pending--; in arizona_out_ev()
999 if (!priv->out_up_pending && priv->out_up_delay) { in arizona_out_ev()
1000 dev_dbg(component->dev, "Power up delay: %d\n", in arizona_out_ev()
1001 priv->out_up_delay); in arizona_out_ev()
1002 msleep(priv->out_up_delay); in arizona_out_ev()
1003 priv->out_up_delay = 0; in arizona_out_ev()
1012 switch (w->shift) { in arizona_out_ev()
1019 priv->out_down_pending++; in arizona_out_ev()
1020 priv->out_down_delay++; in arizona_out_ev()
1024 priv->out_down_pending++; in arizona_out_ev()
1025 switch (arizona->type) { in arizona_out_ev()
1031 priv->out_down_delay += 5; in arizona_out_ev()
1034 priv->out_down_delay++; in arizona_out_ev()
1043 switch (w->shift) { in arizona_out_ev()
1052 priv->out_down_pending--; in arizona_out_ev()
1053 if (!priv->out_down_pending && priv->out_down_delay) { in arizona_out_ev()
1054 dev_dbg(component->dev, "Power down delay: %d\n", in arizona_out_ev()
1055 priv->out_down_delay); in arizona_out_ev()
1056 msleep(priv->out_down_delay); in arizona_out_ev()
1057 priv->out_down_delay = 0; in arizona_out_ev()
1075 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_hp_ev()
1077 struct arizona *arizona = priv->arizona; in arizona_hp_ev()
1078 unsigned int mask = 1 << w->shift; in arizona_hp_ev()
1092 return -EINVAL; in arizona_hp_ev()
1096 priv->arizona->hp_ena &= ~mask; in arizona_hp_ev()
1097 priv->arizona->hp_ena |= val; in arizona_hp_ev()
1100 if (priv->arizona->hpdet_clamp) in arizona_hp_ev()
1103 regmap_update_bits_async(arizona->regmap, ARIZONA_OUTPUT_ENABLES_1, in arizona_hp_ev()
1113 struct arizona *arizona = priv->arizona; in arizona_dvfs_enable()
1116 ret = regulator_set_voltage(arizona->dcvdd, 1800000, 1800000); in arizona_dvfs_enable()
1118 dev_err(component->dev, "Failed to boost DCVDD: %d\n", ret); in arizona_dvfs_enable()
1122 ret = regmap_update_bits(arizona->regmap, in arizona_dvfs_enable()
1127 dev_err(component->dev, "Failed to enable subsys max: %d\n", ret); in arizona_dvfs_enable()
1128 regulator_set_voltage(arizona->dcvdd, 1200000, 1800000); in arizona_dvfs_enable()
1138 struct arizona *arizona = priv->arizona; in arizona_dvfs_disable()
1141 ret = regmap_update_bits(arizona->regmap, in arizona_dvfs_disable()
1145 dev_err(component->dev, "Failed to disable subsys max: %d\n", ret); in arizona_dvfs_disable()
1149 ret = regulator_set_voltage(arizona->dcvdd, 1200000, 1800000); in arizona_dvfs_disable()
1151 dev_err(component->dev, "Failed to unboost DCVDD: %d\n", ret); in arizona_dvfs_disable()
1163 mutex_lock(&priv->dvfs_lock); in arizona_dvfs_up()
1165 if (!priv->dvfs_cached && !priv->dvfs_reqs) { in arizona_dvfs_up()
1171 priv->dvfs_reqs |= flags; in arizona_dvfs_up()
1173 mutex_unlock(&priv->dvfs_lock); in arizona_dvfs_up()
1184 mutex_lock(&priv->dvfs_lock); in arizona_dvfs_down()
1186 old_reqs = priv->dvfs_reqs; in arizona_dvfs_down()
1187 priv->dvfs_reqs &= ~flags; in arizona_dvfs_down()
1189 if (!priv->dvfs_cached && old_reqs && !priv->dvfs_reqs) in arizona_dvfs_down()
1192 mutex_unlock(&priv->dvfs_lock); in arizona_dvfs_down()
1200 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_dvfs_sysclk_ev()
1204 mutex_lock(&priv->dvfs_lock); in arizona_dvfs_sysclk_ev()
1208 if (priv->dvfs_reqs) in arizona_dvfs_sysclk_ev()
1211 priv->dvfs_cached = false; in arizona_dvfs_sysclk_ev()
1218 priv->dvfs_cached = true; in arizona_dvfs_sysclk_ev()
1220 if (priv->dvfs_reqs) in arizona_dvfs_sysclk_ev()
1227 mutex_unlock(&priv->dvfs_lock); in arizona_dvfs_sysclk_ev()
1234 mutex_init(&priv->dvfs_lock); in arizona_init_dvfs()
1242 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_anc_ev()
1247 val = 1 << w->shift; in arizona_anc_ev()
1250 val = 1 << (w->shift + 1); in arizona_anc_ev()
1287 refclk = priv->sysclk; in arizona_set_opclk()
1291 refclk = priv->asyncclk; in arizona_set_opclk()
1294 return -EINVAL; in arizona_set_opclk()
1307 dev_dbg(component->dev, "Configured %dHz OPCLK\n", in arizona_set_opclk()
1321 dev_err(component->dev, "Unable to generate %dHz OPCLK\n", freq); in arizona_set_opclk()
1322 return -EINVAL; in arizona_set_opclk()
1328 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in arizona_clk_ev()
1329 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in arizona_clk_ev()
1334 ret = regmap_read(arizona->regmap, w->reg, &val); in arizona_clk_ev()
1336 dev_err(component->dev, "Failed to check clock source: %d\n", ret); in arizona_clk_ev()
1355 return clk_prepare_enable(arizona->mclk[clk_idx]); in arizona_clk_ev()
1357 clk_disable_unprepare(arizona->mclk[clk_idx]); in arizona_clk_ev()
1369 struct arizona *arizona = priv->arizona; in arizona_set_sysclk()
1380 clk = &priv->sysclk; in arizona_set_sysclk()
1386 clk = &priv->asyncclk; in arizona_set_sysclk()
1392 return -EINVAL; in arizona_set_sysclk()
1424 dev_dbg(arizona->dev, "%s cleared\n", name); in arizona_set_sysclk()
1428 return -EINVAL; in arizona_set_sysclk()
1436 dev_dbg(arizona->dev, "%s set to %uHz", name, freq); in arizona_set_sysclk()
1438 return regmap_update_bits(arizona->regmap, reg, mask, val); in arizona_set_sysclk()
1444 struct snd_soc_component *component = dai->component; in arizona_set_fmt()
1446 struct arizona *arizona = priv->arizona; in arizona_set_fmt()
1449 base = dai->driver->base; in arizona_set_fmt()
1462 return -EINVAL; in arizona_set_fmt()
1473 return -EINVAL; in arizona_set_fmt()
1480 return -EINVAL; in arizona_set_fmt()
1499 return -EINVAL; in arizona_set_fmt()
1516 return -EINVAL; in arizona_set_fmt()
1519 regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_BCLK_CTRL, in arizona_set_fmt()
1523 regmap_update_bits_async(arizona->regmap, base + ARIZONA_AIF_TX_PIN_CTRL, in arizona_set_fmt()
1526 regmap_update_bits_async(arizona->regmap, in arizona_set_fmt()
1530 regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FORMAT, in arizona_set_fmt()
1537 -1,
1559 -1,
1619 struct snd_soc_component *component = dai->component; in arizona_startup()
1621 struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; in arizona_startup()
1624 if (!substream->runtime) in arizona_startup()
1627 switch (dai_priv->clk) { in arizona_startup()
1629 base_rate = priv->sysclk; in arizona_startup()
1632 base_rate = priv->asyncclk; in arizona_startup()
1639 dai_priv->constraint.mask = ARIZONA_RATE_MASK; in arizona_startup()
1641 dai_priv->constraint.mask = ARIZONA_44K1_RATE_MASK; in arizona_startup()
1643 dai_priv->constraint.mask = ARIZONA_48K_RATE_MASK; in arizona_startup()
1645 return snd_pcm_hw_constraint_list(substream->runtime, 0, in arizona_startup()
1647 &dai_priv->constraint); in arizona_startup()
1651 unsigned int rate) in arizona_wm5102_set_dac_comp() argument
1654 struct arizona *arizona = priv->arizona; in arizona_wm5102_set_dac_comp()
1662 mutex_lock(&arizona->dac_comp_lock); in arizona_wm5102_set_dac_comp()
1664 dac_comp[1].def = arizona->dac_comp_coeff; in arizona_wm5102_set_dac_comp()
1665 if (rate >= 176400) in arizona_wm5102_set_dac_comp()
1666 dac_comp[2].def = arizona->dac_comp_enabled; in arizona_wm5102_set_dac_comp()
1668 mutex_unlock(&arizona->dac_comp_lock); in arizona_wm5102_set_dac_comp()
1670 regmap_multi_reg_write(arizona->regmap, in arizona_wm5102_set_dac_comp()
1679 struct snd_soc_component *component = dai->component; in arizona_hw_params_rate()
1681 struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; in arizona_hw_params_rate()
1682 int base = dai->driver->base; in arizona_hw_params_rate()
1687 * currently we use a single sample rate for SYSCLK. in arizona_hw_params_rate()
1693 arizona_aif_err(dai, "Unsupported sample rate %dHz\n", in arizona_hw_params_rate()
1695 return -EINVAL; in arizona_hw_params_rate()
1699 switch (priv->arizona->type) { in arizona_hw_params_rate()
1716 switch (dai_priv->clk) { in arizona_hw_params_rate()
1718 switch (priv->arizona->type) { in arizona_hw_params_rate()
1747 arizona_aif_err(dai, "Invalid clock %d\n", dai_priv->clk); in arizona_hw_params_rate()
1748 return -EINVAL; in arizona_hw_params_rate()
1779 struct snd_soc_component *component = dai->component; in arizona_hw_params()
1781 struct arizona *arizona = priv->arizona; in arizona_hw_params()
1782 int base = dai->driver->base; in arizona_hw_params()
1786 int chan_limit = arizona->pdata.max_channels_clocked[dai->id - 1]; in arizona_hw_params()
1787 int tdm_width = arizona->tdm_width[dai->id - 1]; in arizona_hw_params()
1788 int tdm_slots = arizona->tdm_slots[dai->id - 1]; in arizona_hw_params()
1833 arizona_aif_err(dai, "Unsupported sample rate %dHz\n", in arizona_hw_params()
1835 return -EINVAL; in arizona_hw_params()
1854 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1857 regmap_update_bits(arizona->regmap, in arizona_hw_params()
1866 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1869 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1872 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1875 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1879 regmap_update_bits(arizona->regmap, in arizona_hw_params()
1888 regmap_update_bits_async(arizona->regmap, in arizona_hw_params()
1891 regmap_update_bits(arizona->regmap, in arizona_hw_params()
1913 struct snd_soc_component *component = dai->component; in arizona_dai_set_sysclk()
1916 struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; in arizona_dai_set_sysclk()
1924 return -EINVAL; in arizona_dai_set_sysclk()
1927 if (clk_id == dai_priv->clk) in arizona_dai_set_sysclk()
1931 dev_err(component->dev, "Can't change clock on active DAI %d\n", in arizona_dai_set_sysclk()
1932 dai->id); in arizona_dai_set_sysclk()
1933 return -EBUSY; in arizona_dai_set_sysclk()
1936 dev_dbg(component->dev, "Setting AIF%d to %s\n", dai->id + 1, in arizona_dai_set_sysclk()
1940 routes[0].sink = dai->driver->capture.stream_name; in arizona_dai_set_sysclk()
1941 routes[1].sink = dai->driver->playback.stream_name; in arizona_dai_set_sysclk()
1943 routes[0].source = arizona_dai_clk_str(dai_priv->clk); in arizona_dai_set_sysclk()
1944 routes[1].source = arizona_dai_clk_str(dai_priv->clk); in arizona_dai_set_sysclk()
1951 dai_priv->clk = clk_id; in arizona_dai_set_sysclk()
1958 struct snd_soc_component *component = dai->component; in arizona_set_tristate()
1959 int base = dai->driver->base; in arizona_set_tristate()
1976 struct snd_soc_component *component = dai->component; in arizona_set_channels_to_mask()
1978 struct arizona *arizona = priv->arizona; in arizona_set_channels_to_mask()
1982 slot = ffs(mask) - 1; in arizona_set_channels_to_mask()
1986 regmap_write(arizona->regmap, base + i, slot); in arizona_set_channels_to_mask()
1998 struct snd_soc_component *component = dai->component; in arizona_set_tdm_slot()
2000 struct arizona *arizona = priv->arizona; in arizona_set_tdm_slot()
2001 int base = dai->driver->base; in arizona_set_tdm_slot()
2002 int rx_max_chan = dai->driver->playback.channels_max; in arizona_set_tdm_slot()
2003 int tx_max_chan = dai->driver->capture.channels_max; in arizona_set_tdm_slot()
2006 if (dai->id > ARIZONA_MAX_AIF) in arizona_set_tdm_slot()
2007 return -ENOTSUPP; in arizona_set_tdm_slot()
2010 tx_mask = (1 << tx_max_chan) - 1; in arizona_set_tdm_slot()
2011 rx_mask = (1 << rx_max_chan) - 1; in arizona_set_tdm_slot()
2019 arizona->tdm_width[dai->id - 1] = slot_width; in arizona_set_tdm_slot()
2020 arizona->tdm_slots[dai->id - 1] = slots; in arizona_set_tdm_slot()
2044 struct arizona_dai_priv *dai_priv = &priv->dai[id]; in arizona_init_dai()
2046 dai_priv->clk = ARIZONA_CLK_SYSCLK; in arizona_init_dai()
2047 dai_priv->constraint = arizona_constraint; in arizona_init_dai()
2111 if (fll->fout && Fout != fll->fout) { in arizona_validate_fll()
2114 return -EINVAL; in arizona_validate_fll()
2121 return -EINVAL; in arizona_validate_fll()
2124 Fvco_min = ARIZONA_FLL_MIN_FVCO * fll->vco_mult; in arizona_validate_fll()
2128 return -EINVAL; in arizona_validate_fll()
2147 return -EINVAL; in arizona_find_fratio()
2160 cfg->refdiv = 0; in arizona_calc_fratio()
2164 cfg->refdiv++; in arizona_calc_fratio()
2167 return -EINVAL; in arizona_calc_fratio()
2171 init_ratio = arizona_find_fratio(Fref, &cfg->fratio); in arizona_calc_fratio()
2178 switch (fll->arizona->type) { in arizona_calc_fratio()
2184 if (fll->arizona->rev < 3 || sync) in arizona_calc_fratio()
2193 cfg->fratio = init_ratio - 1; in arizona_calc_fratio()
2196 refdiv = cfg->refdiv; in arizona_calc_fratio()
2205 for (ratio = init_ratio; ratio > 0; ratio--) { in arizona_calc_fratio()
2207 cfg->refdiv = refdiv; in arizona_calc_fratio()
2208 cfg->fratio = ratio - 1; in arizona_calc_fratio()
2219 (fll->vco_mult * ratio) < Fref) { in arizona_calc_fratio()
2224 if (Fref > pseudo_fref_max[ratio - 1]) { in arizona_calc_fratio()
2227 pseudo_fref_max[ratio - 1], in arizona_calc_fratio()
2233 cfg->refdiv = refdiv; in arizona_calc_fratio()
2234 cfg->fratio = ratio - 1; in arizona_calc_fratio()
2252 return cfg->fratio + 1; in arizona_calc_fratio()
2262 arizona_fll_dbg(fll, "Fref=%u Fout=%u\n", Fref, fll->fout); in arizona_calc_fll()
2266 while (fll->fout * div < ARIZONA_FLL_MIN_FVCO * fll->vco_mult) { in arizona_calc_fll()
2269 return -EINVAL; in arizona_calc_fll()
2271 target = fll->fout * div / fll->vco_mult; in arizona_calc_fll()
2272 cfg->outdiv = div; in arizona_calc_fll()
2282 Fref = Fref / (1 << cfg->refdiv); in arizona_calc_fll()
2284 cfg->n = target / (ratio * Fref); in arizona_calc_fll()
2290 cfg->theta = (target - (cfg->n * ratio * Fref)) in arizona_calc_fll()
2292 cfg->lambda = (ratio * Fref) / gcd_fll; in arizona_calc_fll()
2294 cfg->theta = 0; in arizona_calc_fll()
2295 cfg->lambda = 0; in arizona_calc_fll()
2302 while (cfg->lambda >= (1 << 16)) { in arizona_calc_fll()
2303 cfg->theta >>= 1; in arizona_calc_fll()
2304 cfg->lambda >>= 1; in arizona_calc_fll()
2309 cfg->gain = fll_gains[i].gain; in arizona_calc_fll()
2316 return -EINVAL; in arizona_calc_fll()
2320 cfg->n, cfg->theta, cfg->lambda); in arizona_calc_fll()
2322 cfg->fratio, ratio, cfg->outdiv, in arizona_calc_fll()
2323 cfg->refdiv, 1 << cfg->refdiv); in arizona_calc_fll()
2324 arizona_fll_dbg(fll, "GAIN=0x%x(%d)\n", cfg->gain, 1 << cfg->gain); in arizona_calc_fll()
2333 regmap_update_bits_async(arizona->regmap, base + 3, in arizona_apply_fll()
2334 ARIZONA_FLL1_THETA_MASK, cfg->theta); in arizona_apply_fll()
2335 regmap_update_bits_async(arizona->regmap, base + 4, in arizona_apply_fll()
2336 ARIZONA_FLL1_LAMBDA_MASK, cfg->lambda); in arizona_apply_fll()
2337 regmap_update_bits_async(arizona->regmap, base + 5, in arizona_apply_fll()
2339 cfg->fratio << ARIZONA_FLL1_FRATIO_SHIFT); in arizona_apply_fll()
2340 regmap_update_bits_async(arizona->regmap, base + 6, in arizona_apply_fll()
2343 cfg->refdiv << ARIZONA_FLL1_CLK_REF_DIV_SHIFT | in arizona_apply_fll()
2347 regmap_update_bits(arizona->regmap, base + 0x7, in arizona_apply_fll()
2349 cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); in arizona_apply_fll()
2351 regmap_update_bits(arizona->regmap, base + 0x5, in arizona_apply_fll()
2353 cfg->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); in arizona_apply_fll()
2354 regmap_update_bits(arizona->regmap, base + 0x9, in arizona_apply_fll()
2356 cfg->gain << ARIZONA_FLL1_GAIN_SHIFT); in arizona_apply_fll()
2359 regmap_update_bits_async(arizona->regmap, base + 2, in arizona_apply_fll()
2361 ARIZONA_FLL1_CTRL_UPD | cfg->n); in arizona_apply_fll()
2366 struct arizona *arizona = fll->arizona; in arizona_is_enabled_fll()
2370 ret = regmap_read(arizona->regmap, base + 1, ®); in arizona_is_enabled_fll()
2382 struct arizona *arizona = fll->arizona; in arizona_set_fll_clks()
2387 ret = regmap_read(arizona->regmap, base + 6, &val); in arizona_set_fll_clks()
2399 clk = arizona->mclk[ARIZONA_MCLK1]; in arizona_set_fll_clks()
2402 clk = arizona->mclk[ARIZONA_MCLK2]; in arizona_set_fll_clks()
2418 struct arizona *arizona = fll->arizona; in arizona_enable_fll()
2420 int already_enabled = arizona_is_enabled_fll(fll, fll->base); in arizona_enable_fll()
2421 int sync_enabled = arizona_is_enabled_fll(fll, fll->base + 0x10); in arizona_enable_fll()
2433 regmap_update_bits(fll->arizona->regmap, fll->base + 1, in arizona_enable_fll()
2436 regmap_update_bits_async(fll->arizona->regmap, fll->base + 0x9, in arizona_enable_fll()
2439 if (arizona_is_enabled_fll(fll, fll->base + 0x10) > 0) in arizona_enable_fll()
2440 arizona_set_fll_clks(fll, fll->base + 0x10, false); in arizona_enable_fll()
2441 arizona_set_fll_clks(fll, fll->base, false); in arizona_enable_fll()
2448 if (fll->ref_src >= 0 && fll->ref_freq && in arizona_enable_fll()
2449 fll->ref_src != fll->sync_src) { in arizona_enable_fll()
2450 arizona_calc_fll(fll, &cfg, fll->ref_freq, false); in arizona_enable_fll()
2453 if (fll->sync_src >= 0 && cfg.lambda) in arizona_enable_fll()
2456 arizona_apply_fll(arizona, fll->base, &cfg, fll->ref_src, in arizona_enable_fll()
2458 if (fll->sync_src >= 0) { in arizona_enable_fll()
2459 arizona_calc_fll(fll, &cfg, fll->sync_freq, true); in arizona_enable_fll()
2461 arizona_apply_fll(arizona, fll->base + 0x10, &cfg, in arizona_enable_fll()
2462 fll->sync_src, true); in arizona_enable_fll()
2465 } else if (fll->sync_src >= 0) { in arizona_enable_fll()
2466 arizona_calc_fll(fll, &cfg, fll->sync_freq, false); in arizona_enable_fll()
2468 arizona_apply_fll(arizona, fll->base, &cfg, in arizona_enable_fll()
2469 fll->sync_src, false); in arizona_enable_fll()
2471 regmap_update_bits_async(arizona->regmap, fll->base + 0x11, in arizona_enable_fll()
2475 return -EINVAL; in arizona_enable_fll()
2485 if (use_sync && fll->sync_freq > 100000) in arizona_enable_fll()
2486 regmap_update_bits_async(arizona->regmap, fll->base + 0x17, in arizona_enable_fll()
2489 regmap_update_bits_async(arizona->regmap, fll->base + 0x17, in arizona_enable_fll()
2494 pm_runtime_get_sync(arizona->dev); in arizona_enable_fll()
2497 arizona_set_fll_clks(fll, fll->base + 0x10, true); in arizona_enable_fll()
2498 regmap_update_bits_async(arizona->regmap, fll->base + 0x11, in arizona_enable_fll()
2502 arizona_set_fll_clks(fll, fll->base, true); in arizona_enable_fll()
2503 regmap_update_bits_async(arizona->regmap, fll->base + 1, in arizona_enable_fll()
2507 regmap_update_bits_async(arizona->regmap, fll->base + 1, in arizona_enable_fll()
2518 regmap_read(arizona->regmap, in arizona_enable_fll()
2521 if (val & (ARIZONA_FLL1_CLOCK_OK_STS << (fll->id - 1))) in arizona_enable_fll()
2534 struct arizona *arizona = fll->arizona; in arizona_disable_fll()
2537 regmap_update_bits_async(arizona->regmap, fll->base + 1, in arizona_disable_fll()
2539 regmap_update_bits_check(arizona->regmap, fll->base + 1, in arizona_disable_fll()
2541 regmap_update_bits_check(arizona->regmap, fll->base + 0x11, in arizona_disable_fll()
2543 regmap_update_bits_async(arizona->regmap, fll->base + 1, in arizona_disable_fll()
2547 arizona_set_fll_clks(fll, fll->base + 0x10, false); in arizona_disable_fll()
2550 arizona_set_fll_clks(fll, fll->base, false); in arizona_disable_fll()
2551 pm_runtime_put_autosuspend(arizona->dev); in arizona_disable_fll()
2560 if (fll->ref_src == source && fll->ref_freq == Fref) in arizona_set_fll_refclk()
2563 if (fll->fout && Fref > 0) { in arizona_set_fll_refclk()
2564 ret = arizona_validate_fll(fll, Fref, fll->fout); in arizona_set_fll_refclk()
2569 fll->ref_src = source; in arizona_set_fll_refclk()
2570 fll->ref_freq = Fref; in arizona_set_fll_refclk()
2572 if (fll->fout && Fref > 0) in arizona_set_fll_refclk()
2584 if (fll->sync_src == source && in arizona_set_fll()
2585 fll->sync_freq == Fref && fll->fout == Fout) in arizona_set_fll()
2589 if (fll->ref_src >= 0) { in arizona_set_fll()
2590 ret = arizona_validate_fll(fll, fll->ref_freq, Fout); in arizona_set_fll()
2600 fll->sync_src = source; in arizona_set_fll()
2601 fll->sync_freq = Fref; in arizona_set_fll()
2602 fll->fout = Fout; in arizona_set_fll()
2618 fll->id = id; in arizona_init_fll()
2619 fll->base = base; in arizona_init_fll()
2620 fll->arizona = arizona; in arizona_init_fll()
2621 fll->sync_src = ARIZONA_FLL_SRC_NONE; in arizona_init_fll()
2624 regmap_read(arizona->regmap, ARIZONA_CLOCK_32K_1, &val); in arizona_init_fll()
2628 fll->ref_src = val & ARIZONA_CLK_32K_SRC_MASK; in arizona_init_fll()
2631 fll->ref_src = ARIZONA_FLL_SRC_NONE; in arizona_init_fll()
2633 fll->ref_freq = 32768; in arizona_init_fll()
2635 snprintf(fll->lock_name, sizeof(fll->lock_name), "FLL%d lock", id); in arizona_init_fll()
2636 snprintf(fll->clock_ok_name, sizeof(fll->clock_ok_name), in arizona_init_fll()
2639 regmap_update_bits(arizona->regmap, fll->base + 1, in arizona_init_fll()
2647 * arizona_set_output_mode - Set the mode of the specified output
2668 return -EINVAL; in arizona_set_output_mode()
2670 reg = ARIZONA_OUTPUT_PATH_CONFIG_1L + (output - 1) * 8; in arizona_set_output_mode()
2702 SOC_ENUM("DSP1 Rate", arizona_adsp2_rate_enum[0]),
2703 SOC_ENUM("DSP2 Rate", arizona_adsp2_rate_enum[1]),
2704 SOC_ENUM("DSP3 Rate", arizona_adsp2_rate_enum[2]),
2705 SOC_ENUM("DSP4 Rate", arizona_adsp2_rate_enum[3]),
2720 return (abs((a << 16) / (4096 - b)) >= 4096 << 4); in arizona_eq_filter_unstable()
2728 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in arizona_eq_coeff_put()
2729 struct soc_bytes *params = (void *)kcontrol->private_value; in arizona_eq_coeff_put()
2735 len = params->num_regs * regmap_get_val_bytes(arizona->regmap); in arizona_eq_coeff_put()
2737 data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA); in arizona_eq_coeff_put()
2739 return -ENOMEM; in arizona_eq_coeff_put()
2748 dev_err(arizona->dev, "Rejecting unstable EQ coefficients\n"); in arizona_eq_coeff_put()
2749 ret = -EINVAL; in arizona_eq_coeff_put()
2753 ret = regmap_read(arizona->regmap, params->base, &val); in arizona_eq_coeff_put()
2760 ret = regmap_raw_write(arizona->regmap, params->base, data, len); in arizona_eq_coeff_put()
2772 struct arizona *arizona = dev_get_drvdata(component->dev->parent); in arizona_lhpf_coeff_put()
2773 __be16 *data = (__be16 *)ucontrol->value.bytes.data; in arizona_lhpf_coeff_put()
2777 dev_err(arizona->dev, "Rejecting unstable LHPF coefficients\n"); in arizona_lhpf_coeff_put()
2778 return -EINVAL; in arizona_lhpf_coeff_put()
2787 struct arizona_pdata *pdata = &arizona->pdata; in arizona_of_get_audio_pdata()
2788 struct device_node *np = arizona->dev->of_node; in arizona_of_get_audio_pdata() local
2795 of_property_for_each_u32(np, "wlf,inmode", val) { in arizona_of_get_audio_pdata()
2796 if (count == ARRAY_SIZE(pdata->inmode)) in arizona_of_get_audio_pdata()
2799 pdata->inmode[count] = val; in arizona_of_get_audio_pdata()
2804 of_property_for_each_u32(np, "wlf,dmic-ref", val) { in arizona_of_get_audio_pdata()
2805 if (count == ARRAY_SIZE(pdata->dmic_ref)) in arizona_of_get_audio_pdata()
2808 pdata->dmic_ref[count] = val; in arizona_of_get_audio_pdata()
2813 of_property_for_each_u32(np, "wlf,out-mono", val) { in arizona_of_get_audio_pdata()
2814 if (count == ARRAY_SIZE(pdata->out_mono)) in arizona_of_get_audio_pdata()
2817 pdata->out_mono[count] = !!val; in arizona_of_get_audio_pdata()
2822 of_property_for_each_u32(np, "wlf,max-channels-clocked", val) { in arizona_of_get_audio_pdata()
2823 if (count == ARRAY_SIZE(pdata->max_channels_clocked)) in arizona_of_get_audio_pdata()
2826 pdata->max_channels_clocked[count] = val; in arizona_of_get_audio_pdata()
2831 of_property_for_each_u32(np, "wlf,out-volume-limit", val) { in arizona_of_get_audio_pdata()
2832 if (count == ARRAY_SIZE(pdata->out_vol_limit)) in arizona_of_get_audio_pdata()
2835 pdata->out_vol_limit[count] = val; in arizona_of_get_audio_pdata()
2839 ret = of_property_read_u32_array(np, "wlf,spk-fmt", in arizona_of_get_audio_pdata()
2843 for (count = 0; count < ARRAY_SIZE(pdata->spk_fmt); ++count) in arizona_of_get_audio_pdata()
2844 pdata->spk_fmt[count] = pdm_val[count]; in arizona_of_get_audio_pdata()
2846 ret = of_property_read_u32_array(np, "wlf,spk-mute", in arizona_of_get_audio_pdata()
2850 for (count = 0; count < ARRAY_SIZE(pdata->spk_mute); ++count) in arizona_of_get_audio_pdata()
2851 pdata->spk_mute[count] = pdm_val[count]; in arizona_of_get_audio_pdata()