Lines Matching defs:rt5514
3 * rt5514.c -- RT5514 ALSA SoC audio codec driver
29 #include "rt5514.h"
31 #include "rt5514-spi.h"
117 static void rt5514_enable_dsp_prepare(struct rt5514_priv *rt5514)
120 regmap_write(rt5514->i2c_regmap, 0x18002000, 0x000010ec);
122 regmap_write(rt5514->i2c_regmap, 0x18002200, 0x00028604);
124 regmap_write(rt5514->i2c_regmap, 0xfafafafa, 0x00000001);
126 regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x0005514b);
127 regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x00055149);
129 regmap_write(rt5514->i2c_regmap, 0xfafafafa, 0x00000000);
131 regmap_write(rt5514->i2c_regmap, 0x18002070, 0x00000040);
133 regmap_write(rt5514->i2c_regmap, 0x18002240, 0x0000000a);
135 regmap_write(rt5514->i2c_regmap, 0x18002100, 0x0000000b);
137 regmap_write(rt5514->i2c_regmap, 0x18002004, 0x00808b81);
139 regmap_write(rt5514->i2c_regmap, 0x18002f08, 0x00000005);
141 regmap_write(rt5514->i2c_regmap, 0x18001114, 0x00000001);
143 regmap_write(rt5514->i2c_regmap, 0x18001118, 0x00000001);
290 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
292 ucontrol->value.integer.value[0] = rt5514->dsp_enabled;
297 static int rt5514_calibration(struct rt5514_priv *rt5514, bool on)
300 regmap_write(rt5514->regmap, RT5514_ANA_CTRL_PLL3, 0x0000000a);
301 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
303 regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301,
305 regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL4,
306 0x80000000 | rt5514->pll3_cal_value);
307 regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL1,
309 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
311 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
314 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
316 regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301, 0);
317 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
328 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
332 if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled)
336 rt5514->dsp_enabled = ucontrol->value.integer.value[0];
338 if (rt5514->dsp_enabled) {
339 if (rt5514->pdata.dsp_calib_clk_name &&
340 !IS_ERR(rt5514->dsp_calib_clk)) {
341 if (clk_set_rate(rt5514->dsp_calib_clk,
342 rt5514->pdata.dsp_calib_clk_rate))
346 if (clk_prepare_enable(rt5514->dsp_calib_clk))
350 rt5514_calibration(rt5514, true);
361 rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
364 rt5514_calibration(rt5514, false);
365 clk_disable_unprepare(rt5514->dsp_calib_clk);
368 rt5514_enable_dsp_prepare(rt5514);
397 regmap_write(rt5514->i2c_regmap, 0x18002f00,
400 if (rt5514->pdata.dsp_calib_clk_name &&
401 !IS_ERR(rt5514->dsp_calib_clk)) {
404 regmap_write(rt5514->i2c_regmap, 0x1800211c,
405 rt5514->pll3_cal_value);
406 regmap_write(rt5514->i2c_regmap, 0x18002124,
408 regmap_write(rt5514->i2c_regmap, 0x18002124,
410 regmap_write(rt5514->i2c_regmap, 0x18002124,
414 regmap_multi_reg_write(rt5514->i2c_regmap,
416 regcache_mark_dirty(rt5514->regmap);
417 regcache_sync(rt5514->regmap);
518 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
521 idx = rt5514_calc_dmic_clk(component, rt5514->sysclk);
525 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
529 if (rt5514->pdata.dmic_init_delay)
530 msleep(rt5514->pdata.dmic_init_delay);
539 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
541 if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1)
551 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
553 return (rt5514->sysclk > rt5514->lrck * 384);
754 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
758 rt5514->lrck = params_rate(params);
759 pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck);
772 rt5514->bclk = rt5514->lrck * (32 << bclk_ms);
775 rt5514->bclk, rt5514->lrck);
795 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1, RT5514_I2S_DL_MASK,
797 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
800 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
811 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
854 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1,
865 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
868 if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src)
885 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
888 rt5514->sysclk = freq;
889 rt5514->sysclk_src = clk_id;
900 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
907 rt5514->pll_in = 0;
908 rt5514->pll_out = 0;
909 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
916 if (source == rt5514->pll_src && freq_in == rt5514->pll_in &&
917 freq_out == rt5514->pll_out)
922 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL,
927 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL,
946 regmap_write(rt5514->regmap, RT5514_ANA_CTRL_PLL1_1,
950 regmap_update_bits(rt5514->regmap, RT5514_ANA_CTRL_PLL1_2,
953 rt5514->pll_in = freq_in;
954 rt5514->pll_out = freq_out;
955 rt5514->pll_src = source;
964 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1037 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1, RT5514_TDM_MODE |
1042 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL2,
1052 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1057 if (IS_ERR(rt5514->mclk))
1061 clk_disable_unprepare(rt5514->mclk);
1063 ret = clk_prepare_enable(rt5514->mclk);
1076 if (rt5514->dsp_enabled) {
1077 rt5514->dsp_enabled = 0;
1078 regmap_multi_reg_write(rt5514->i2c_regmap,
1081 regcache_mark_dirty(rt5514->regmap);
1082 regcache_sync(rt5514->regmap);
1096 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1100 rt5514->mclk = devm_clk_get(component->dev, "mclk");
1101 if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
1104 if (rt5514->pdata.dsp_calib_clk_name) {
1105 rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev,
1106 rt5514->pdata.dsp_calib_clk_name);
1107 if (PTR_ERR(rt5514->dsp_calib_clk) == -EPROBE_DEFER)
1111 rt5514->component = component;
1112 rt5514->pll3_cal_value = 0x0078b000;
1120 struct rt5514_priv *rt5514 = i2c_get_clientdata(client);
1122 regmap_read(rt5514->i2c_regmap, reg | RT5514_DSP_MAPPING, val);
1130 struct rt5514_priv *rt5514 = i2c_get_clientdata(client);
1132 regmap_write(rt5514->i2c_regmap, reg | RT5514_DSP_MAPPING, val);
1151 .name = "rt5514-aif1",
1205 { "rt5514", 0 },
1212 { .compatible = "realtek,rt5514", },
1226 static int rt5514_parse_dp(struct rt5514_priv *rt5514, struct device *dev)
1229 &rt5514->pdata.dmic_init_delay);
1231 &rt5514->pdata.dsp_calib_clk_name);
1233 &rt5514->pdata.dsp_calib_clk_rate);
1240 struct rt5514_priv *rt5514 = dev_get_drvdata(dev);
1244 * Add a bogus read to avoid rt5514's confusion after s2r in case it
1248 regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1256 struct rt5514_priv *rt5514;
1260 rt5514 = devm_kzalloc(&i2c->dev, sizeof(struct rt5514_priv),
1262 if (rt5514 == NULL)
1265 i2c_set_clientdata(i2c, rt5514);
1268 rt5514->pdata = *pdata;
1270 rt5514_parse_dp(rt5514, &i2c->dev);
1272 rt5514->i2c_regmap = devm_regmap_init_i2c(i2c, &rt5514_i2c_regmap);
1273 if (IS_ERR(rt5514->i2c_regmap)) {
1274 ret = PTR_ERR(rt5514->i2c_regmap);
1280 rt5514->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5514_regmap);
1281 if (IS_ERR(rt5514->regmap)) {
1282 ret = PTR_ERR(rt5514->regmap);
1289 * The rt5514 can get confused if the i2c lines glitch together, as
1294 ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1296 ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1299 "Device with ID register %x is not rt5514\n", val);
1303 ret = regmap_multi_reg_write(rt5514->i2c_regmap, rt5514_i2c_patch,
1309 ret = regmap_register_patch(rt5514->regmap, rt5514_patch,
1325 .name = "rt5514",