Lines Matching defs:rt5514
3 * rt5514.c -- RT5514 ALSA SoC audio codec driver
30 #include "rt5514.h"
32 #include "rt5514-spi.h"
118 static void rt5514_enable_dsp_prepare(struct rt5514_priv *rt5514)
121 regmap_write(rt5514->i2c_regmap, 0x18002000, 0x000010ec);
123 regmap_write(rt5514->i2c_regmap, 0x18002200, 0x00028604);
125 regmap_write(rt5514->i2c_regmap, 0xfafafafa, 0x00000001);
127 regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x0005514b);
128 regmap_write(rt5514->i2c_regmap, 0x18002f00, 0x00055149);
130 regmap_write(rt5514->i2c_regmap, 0xfafafafa, 0x00000000);
132 regmap_write(rt5514->i2c_regmap, 0x18002070, 0x00000040);
134 regmap_write(rt5514->i2c_regmap, 0x18002240, 0x0000000a);
136 regmap_write(rt5514->i2c_regmap, 0x18002100, 0x0000000b);
138 regmap_write(rt5514->i2c_regmap, 0x18002004, 0x00808b81);
140 regmap_write(rt5514->i2c_regmap, 0x18002f08, 0x00000005);
142 regmap_write(rt5514->i2c_regmap, 0x18001114, 0x00000001);
144 regmap_write(rt5514->i2c_regmap, 0x18001118, 0x00000001);
291 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
293 ucontrol->value.integer.value[0] = rt5514->dsp_enabled;
298 static int rt5514_calibration(struct rt5514_priv *rt5514, bool on)
301 regmap_write(rt5514->regmap, RT5514_ANA_CTRL_PLL3, 0x0000000a);
302 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
304 regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301,
306 regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL4,
307 0x80000000 | rt5514->pll3_cal_value);
308 regmap_write(rt5514->regmap, RT5514_PLL3_CALIB_CTRL1,
310 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
312 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
315 regmap_update_bits(rt5514->regmap, RT5514_PLL3_CALIB_CTRL5,
317 regmap_update_bits(rt5514->regmap, RT5514_PWR_ANA1, 0x301, 0);
318 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL, 0xf,
329 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
333 if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled)
337 rt5514->dsp_enabled = ucontrol->value.integer.value[0];
339 if (rt5514->dsp_enabled) {
340 if (rt5514->pdata.dsp_calib_clk_name &&
341 !IS_ERR(rt5514->dsp_calib_clk)) {
342 if (clk_set_rate(rt5514->dsp_calib_clk,
343 rt5514->pdata.dsp_calib_clk_rate))
347 if (clk_prepare_enable(rt5514->dsp_calib_clk))
351 rt5514_calibration(rt5514, true);
362 rt5514->pll3_cal_value = buf[0] | buf[1] << 8 |
365 rt5514_calibration(rt5514, false);
366 clk_disable_unprepare(rt5514->dsp_calib_clk);
369 rt5514_enable_dsp_prepare(rt5514);
398 regmap_write(rt5514->i2c_regmap, 0x18002f00,
401 if (rt5514->pdata.dsp_calib_clk_name &&
402 !IS_ERR(rt5514->dsp_calib_clk)) {
405 regmap_write(rt5514->i2c_regmap, 0x1800211c,
406 rt5514->pll3_cal_value);
407 regmap_write(rt5514->i2c_regmap, 0x18002124,
409 regmap_write(rt5514->i2c_regmap, 0x18002124,
411 regmap_write(rt5514->i2c_regmap, 0x18002124,
415 regmap_multi_reg_write(rt5514->i2c_regmap,
417 regcache_mark_dirty(rt5514->regmap);
418 regcache_sync(rt5514->regmap);
519 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
522 idx = rt5514_calc_dmic_clk(component, rt5514->sysclk);
526 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
530 if (rt5514->pdata.dmic_init_delay)
531 msleep(rt5514->pdata.dmic_init_delay);
540 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
542 if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1)
552 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
554 return (rt5514->sysclk > rt5514->lrck * 384);
755 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
759 rt5514->lrck = params_rate(params);
760 pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck);
773 rt5514->bclk = rt5514->lrck * (32 << bclk_ms);
776 rt5514->bclk, rt5514->lrck);
796 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1, RT5514_I2S_DL_MASK,
798 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1,
801 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
812 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
855 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1,
866 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
869 if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src)
886 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
889 rt5514->sysclk = freq;
890 rt5514->sysclk_src = clk_id;
901 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
908 rt5514->pll_in = 0;
909 rt5514->pll_out = 0;
910 regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL2,
917 if (source == rt5514->pll_src && freq_in == rt5514->pll_in &&
918 freq_out == rt5514->pll_out)
923 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL,
928 regmap_update_bits(rt5514->regmap, RT5514_PLL_SOURCE_CTRL,
947 regmap_write(rt5514->regmap, RT5514_ANA_CTRL_PLL1_1,
951 regmap_update_bits(rt5514->regmap, RT5514_ANA_CTRL_PLL1_2,
954 rt5514->pll_in = freq_in;
955 rt5514->pll_out = freq_out;
956 rt5514->pll_src = source;
965 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1038 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL1, RT5514_TDM_MODE |
1043 regmap_update_bits(rt5514->regmap, RT5514_I2S_CTRL2,
1053 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1058 if (IS_ERR(rt5514->mclk))
1062 clk_disable_unprepare(rt5514->mclk);
1064 ret = clk_prepare_enable(rt5514->mclk);
1077 if (rt5514->dsp_enabled) {
1078 rt5514->dsp_enabled = 0;
1079 regmap_multi_reg_write(rt5514->i2c_regmap,
1082 regcache_mark_dirty(rt5514->regmap);
1083 regcache_sync(rt5514->regmap);
1097 struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component);
1101 rt5514->mclk = devm_clk_get(component->dev, "mclk");
1102 if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER)
1105 if (rt5514->pdata.dsp_calib_clk_name) {
1106 rt5514->dsp_calib_clk = devm_clk_get(&pdev->dev,
1107 rt5514->pdata.dsp_calib_clk_name);
1108 if (PTR_ERR(rt5514->dsp_calib_clk) == -EPROBE_DEFER)
1112 rt5514->component = component;
1113 rt5514->pll3_cal_value = 0x0078b000;
1121 struct rt5514_priv *rt5514 = i2c_get_clientdata(client);
1123 regmap_read(rt5514->i2c_regmap, reg | RT5514_DSP_MAPPING, val);
1131 struct rt5514_priv *rt5514 = i2c_get_clientdata(client);
1133 regmap_write(rt5514->i2c_regmap, reg | RT5514_DSP_MAPPING, val);
1152 .name = "rt5514-aif1",
1207 { "rt5514", 0 },
1214 { .compatible = "realtek,rt5514", },
1228 static int rt5514_parse_dp(struct rt5514_priv *rt5514, struct device *dev)
1231 &rt5514->pdata.dmic_init_delay);
1233 &rt5514->pdata.dsp_calib_clk_name);
1235 &rt5514->pdata.dsp_calib_clk_rate);
1242 struct rt5514_priv *rt5514 = dev_get_drvdata(dev);
1246 * Add a bogus read to avoid rt5514's confusion after s2r in case it
1250 regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1259 struct rt5514_priv *rt5514;
1263 rt5514 = devm_kzalloc(&i2c->dev, sizeof(struct rt5514_priv),
1265 if (rt5514 == NULL)
1268 i2c_set_clientdata(i2c, rt5514);
1271 rt5514->pdata = *pdata;
1273 rt5514_parse_dp(rt5514, &i2c->dev);
1275 rt5514->i2c_regmap = devm_regmap_init_i2c(i2c, &rt5514_i2c_regmap);
1276 if (IS_ERR(rt5514->i2c_regmap)) {
1277 ret = PTR_ERR(rt5514->i2c_regmap);
1283 rt5514->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt5514_regmap);
1284 if (IS_ERR(rt5514->regmap)) {
1285 ret = PTR_ERR(rt5514->regmap);
1292 * The rt5514 can get confused if the i2c lines glitch together, as
1297 ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1299 ret = regmap_read(rt5514->regmap, RT5514_VENDOR_ID2, &val);
1302 "Device with ID register %x is not rt5514\n", val);
1306 ret = regmap_multi_reg_write(rt5514->i2c_regmap, rt5514_i2c_patch,
1312 ret = regmap_register_patch(rt5514->regmap, rt5514_patch,
1328 .name = "rt5514",