Lines Matching refs:rt1011
34 static int rt1011_calibrate(struct rt1011_priv *rt1011,
683 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_reg_init() local
685 regmap_multi_reg_write(rt1011->regmap, in rt1011_reg_init()
1041 struct rt1011_priv *rt1011 = in rt1011_recv_spk_mode_get() local
1044 ucontrol->value.integer.value[0] = rt1011->recv_spk_mode; in rt1011_recv_spk_mode_get()
1054 struct rt1011_priv *rt1011 = in rt1011_recv_spk_mode_put() local
1057 if (ucontrol->value.integer.value[0] == rt1011->recv_spk_mode) in rt1011_recv_spk_mode_put()
1061 rt1011->recv_spk_mode = ucontrol->value.integer.value[0]; in rt1011_recv_spk_mode_put()
1063 if (rt1011->recv_spk_mode) { in rt1011_recv_spk_mode_put()
1117 struct rt1011_priv *rt1011 = in rt1011_bq_drc_coeff_get() local
1139 bq_drc_info = rt1011->bq_drc_params[mode_idx]; in rt1011_bq_drc_coeff_get()
1154 struct rt1011_priv *rt1011 = in rt1011_bq_drc_coeff_put() local
1174 bq_drc_info = rt1011->bq_drc_params[mode_idx]; in rt1011_bq_drc_coeff_put()
1218 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_r0_cali_get() local
1220 ucontrol->value.integer.value[0] = rt1011->cali_done; in rt1011_r0_cali_get()
1229 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_r0_cali_put() local
1231 rt1011->cali_done = 0; in rt1011_r0_cali_put()
1234 rt1011_calibrate(rt1011, 1); in rt1011_r0_cali_put()
1239 static int rt1011_r0_load(struct rt1011_priv *rt1011) in rt1011_r0_load() argument
1241 if (!rt1011->r0_reg) in rt1011_r0_load()
1245 regmap_write(rt1011->regmap, RT1011_INIT_RECIPROCAL_REG_24_16, in rt1011_r0_load()
1246 ((rt1011->r0_reg>>16) & 0x1ff)); in rt1011_r0_load()
1247 regmap_write(rt1011->regmap, RT1011_INIT_RECIPROCAL_REG_15_0, in rt1011_r0_load()
1248 (rt1011->r0_reg & 0xffff)); in rt1011_r0_load()
1249 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_4, 0x4080); in rt1011_r0_load()
1258 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_r0_load_mode_get() local
1260 ucontrol->value.integer.value[0] = rt1011->r0_reg; in rt1011_r0_load_mode_get()
1269 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_r0_load_mode_put() local
1273 if (ucontrol->value.integer.value[0] == rt1011->r0_reg) in rt1011_r0_load_mode_put()
1279 dev = regmap_get_device(rt1011->regmap); in rt1011_r0_load_mode_put()
1281 rt1011->r0_reg = ucontrol->value.integer.value[0]; in rt1011_r0_load_mode_put()
1284 r0_integer = format / rt1011->r0_reg / 128; in rt1011_r0_load_mode_put()
1285 r0_factor = ((format / rt1011->r0_reg * 100) / 128) in rt1011_r0_load_mode_put()
1288 r0_integer, r0_factor, rt1011->r0_reg); in rt1011_r0_load_mode_put()
1290 if (rt1011->r0_reg) in rt1011_r0_load_mode_put()
1291 rt1011_r0_load(rt1011); in rt1011_r0_load_mode_put()
1326 struct rt1011_priv *rt1011 = in rt1011_i2s_ref_put() local
1329 rt1011->i2s_ref = ucontrol->value.enumerated.item[0]; in rt1011_i2s_ref_put()
1330 switch (rt1011->i2s_ref) { in rt1011_i2s_ref_put()
1332 regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240); in rt1011_i2s_ref_put()
1333 regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8); in rt1011_i2s_ref_put()
1334 regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x1022); in rt1011_i2s_ref_put()
1335 regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4); in rt1011_i2s_ref_put()
1338 regmap_write(rt1011->regmap, RT1011_TDM_TOTAL_SET, 0x0240); in rt1011_i2s_ref_put()
1339 regmap_write(rt1011->regmap, RT1011_TDM1_SET_2, 0x8); in rt1011_i2s_ref_put()
1340 regmap_write(rt1011->regmap, RT1011_TDM1_SET_1, 0x10a2); in rt1011_i2s_ref_put()
1341 regmap_write(rt1011->regmap, RT1011_ADCDAT_OUT_SOURCE, 0x4); in rt1011_i2s_ref_put()
1355 struct rt1011_priv *rt1011 = in rt1011_i2s_ref_get() local
1358 ucontrol->value.enumerated.item[0] = rt1011->i2s_ref; in rt1011_i2s_ref_get()
1411 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_is_sys_clk_from_pll() local
1413 if (rt1011->sysclk_src == RT1011_FS_SYS_PRE_S_PLL1) in rt1011_is_sys_clk_from_pll()
1578 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_hw_params() local
1582 rt1011->lrck = params_rate(params); in rt1011_hw_params()
1583 pre_div = rt1011_get_clk_info(rt1011->sysclk, rt1011->lrck); in rt1011_hw_params()
1587 rt1011->lrck * 64, rt1011->lrck * 256); in rt1011_hw_params()
1589 rt1011->lrck * 256, SND_SOC_CLOCK_IN); in rt1011_hw_params()
1600 rt1011->bclk = rt1011->lrck * (32 << bclk_ms); in rt1011_hw_params()
1606 rt1011->lrck, pre_div, dai->id); in rt1011_hw_params()
1735 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_set_component_sysclk() local
1738 if (freq == rt1011->sysclk && clk_id == rt1011->sysclk_src) in rt1011_set_component_sysclk()
1766 rt1011->sysclk = freq; in rt1011_set_component_sysclk()
1767 rt1011->sysclk_src = clk_id; in rt1011_set_component_sysclk()
1779 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_set_component_pll() local
1783 if (source == rt1011->pll_src && freq_in == rt1011->pll_in && in rt1011_set_component_pll()
1784 freq_out == rt1011->pll_out) in rt1011_set_component_pll()
1790 rt1011->pll_in = 0; in rt1011_set_component_pll()
1791 rt1011->pll_out = 0; in rt1011_set_component_pll()
1839 rt1011->pll_in = freq_in; in rt1011_set_component_pll()
1840 rt1011->pll_out = freq_out; in rt1011_set_component_pll()
1841 rt1011->pll_src = source; in rt1011_set_component_pll()
2055 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_probe() local
2058 rt1011->component = component; in rt1011_probe()
2060 schedule_work(&rt1011->cali_work); in rt1011_probe()
2062 rt1011->i2s_ref = 0; in rt1011_probe()
2063 rt1011->bq_drc_params = devm_kcalloc(component->dev, in rt1011_probe()
2066 if (!rt1011->bq_drc_params) in rt1011_probe()
2070 rt1011->bq_drc_params[i] = devm_kcalloc(component->dev, in rt1011_probe()
2073 if (!rt1011->bq_drc_params[i]) in rt1011_probe()
2082 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_remove() local
2084 cancel_work_sync(&rt1011->cali_work); in rt1011_remove()
2085 rt1011_reset(rt1011->regmap); in rt1011_remove()
2091 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_suspend() local
2093 regcache_cache_only(rt1011->regmap, true); in rt1011_suspend()
2094 regcache_mark_dirty(rt1011->regmap); in rt1011_suspend()
2101 struct rt1011_priv *rt1011 = snd_soc_component_get_drvdata(component); in rt1011_resume() local
2103 regcache_cache_only(rt1011->regmap, false); in rt1011_resume()
2104 regcache_sync(rt1011->regmap); in rt1011_resume()
2216 static int rt1011_calibrate(struct rt1011_priv *rt1011, unsigned char cali_flag) in rt1011_calibrate() argument
2222 struct device *dev = regmap_get_device(rt1011->regmap); in rt1011_calibrate()
2224 snd_soc_component_get_dapm(rt1011->component); in rt1011_calibrate()
2228 regcache_cache_bypass(rt1011->regmap, true); in rt1011_calibrate()
2230 regmap_write(rt1011->regmap, RT1011_RESET, 0x0000); in rt1011_calibrate()
2231 regmap_write(rt1011->regmap, RT1011_SYSTEM_RESET_3, 0x740f); in rt1011_calibrate()
2232 regmap_write(rt1011->regmap, RT1011_SYSTEM_RESET_3, 0x770f); in rt1011_calibrate()
2235 regmap_write(rt1011->regmap, RT1011_CLK_2, 0x9400); in rt1011_calibrate()
2236 regmap_write(rt1011->regmap, RT1011_PLL_1, 0x0800); in rt1011_calibrate()
2237 regmap_write(rt1011->regmap, RT1011_PLL_2, 0x0020); in rt1011_calibrate()
2238 regmap_write(rt1011->regmap, RT1011_CLK_DET, 0x0800); in rt1011_calibrate()
2241 regmap_write(rt1011->regmap, RT1011_ADC_SET_5, 0x0a20); in rt1011_calibrate()
2242 regmap_write(rt1011->regmap, RT1011_DAC_SET_2, 0xe232); in rt1011_calibrate()
2243 regmap_write(rt1011->regmap, RT1011_ADC_SET_4, 0xc000); in rt1011_calibrate()
2246 regmap_write(rt1011->regmap, RT1011_SPK_PRO_DC_DET_1, 0xb00c); in rt1011_calibrate()
2247 regmap_write(rt1011->regmap, RT1011_SPK_PRO_DC_DET_2, 0xcccc); in rt1011_calibrate()
2250 regmap_write(rt1011->regmap, RT1011_POWER_1, 0xe0e0); in rt1011_calibrate()
2251 regmap_write(rt1011->regmap, RT1011_POWER_3, 0x5003); in rt1011_calibrate()
2252 regmap_write(rt1011->regmap, RT1011_POWER_9, 0xa860); in rt1011_calibrate()
2253 regmap_write(rt1011->regmap, RT1011_DAC_SET_2, 0xa032); in rt1011_calibrate()
2256 regmap_write(rt1011->regmap, RT1011_POWER_2, 0x0007); in rt1011_calibrate()
2257 regmap_write(rt1011->regmap, RT1011_POWER_3, 0x5ff7); in rt1011_calibrate()
2258 regmap_write(rt1011->regmap, RT1011_A_TEMP_SEN, 0x7f44); in rt1011_calibrate()
2259 regmap_write(rt1011->regmap, RT1011_A_TIMING_1, 0x4054); in rt1011_calibrate()
2260 regmap_write(rt1011->regmap, RT1011_BAT_GAIN_1, 0x309c); in rt1011_calibrate()
2263 regmap_write(rt1011->regmap, RT1011_DC_CALIB_CLASSD_3, 0xcb00); in rt1011_calibrate()
2264 regmap_write(rt1011->regmap, RT1011_BOOST_CON_1, 0xe080); in rt1011_calibrate()
2265 regmap_write(rt1011->regmap, RT1011_POWER_4, 0x16f2); in rt1011_calibrate()
2266 regmap_write(rt1011->regmap, RT1011_POWER_6, 0x36ad); in rt1011_calibrate()
2269 regmap_write(rt1011->regmap, RT1011_MIXER_1, 0x3f1d); in rt1011_calibrate()
2272 regmap_write(rt1011->regmap, RT1011_EFUSE_CONTROL_1, 0x0d0a); in rt1011_calibrate()
2275 regmap_read(rt1011->regmap, RT1011_EFUSE_ADC_OFFSET_18_16, &value); in rt1011_calibrate()
2277 regmap_read(rt1011->regmap, RT1011_EFUSE_ADC_OFFSET_15_0, &value); in rt1011_calibrate()
2280 regmap_read(rt1011->regmap, RT1011_EFUSE_DAC_OFFSET_G0_20_16, &value); in rt1011_calibrate()
2282 regmap_read(rt1011->regmap, RT1011_EFUSE_DAC_OFFSET_G0_15_0, &value); in rt1011_calibrate()
2285 regmap_read(rt1011->regmap, RT1011_EFUSE_DAC_OFFSET_G1_20_16, &value); in rt1011_calibrate()
2287 regmap_read(rt1011->regmap, RT1011_EFUSE_DAC_OFFSET_G1_15_0, &value); in rt1011_calibrate()
2293 regmap_write(rt1011->regmap, RT1011_ADC_SET_1, 0x2925); in rt1011_calibrate()
2295 regmap_write(rt1011->regmap, RT1011_CLASS_D_POS, 0x010e); in rt1011_calibrate()
2296 regmap_write(rt1011->regmap, in rt1011_calibrate()
2300 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_0, 0x8000); in rt1011_calibrate()
2301 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_7, 0xf000); in rt1011_calibrate()
2302 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_4, 0x4040); in rt1011_calibrate()
2303 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_0, 0xc000); in rt1011_calibrate()
2304 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_6, 0x07c2); in rt1011_calibrate()
2309 regmap_read(rt1011->regmap, in rt1011_calibrate()
2312 regmap_read(rt1011->regmap, in rt1011_calibrate()
2332 rt1011->r0_reg = r0[0]; in rt1011_calibrate()
2333 rt1011->cali_done = 1; in rt1011_calibrate()
2340 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_0, 0x0000); in rt1011_calibrate()
2342 regmap_write(rt1011->regmap, RT1011_POWER_9, 0xa840); in rt1011_calibrate()
2343 regmap_write(rt1011->regmap, RT1011_SPK_TEMP_PROTECT_6, 0x0702); in rt1011_calibrate()
2344 regmap_write(rt1011->regmap, RT1011_MIXER_1, 0xffdd); in rt1011_calibrate()
2345 regmap_write(rt1011->regmap, RT1011_CLASSD_INTERNAL_SET_1, 0x0701); in rt1011_calibrate()
2346 regmap_write(rt1011->regmap, RT1011_DAC_SET_3, 0xe004); in rt1011_calibrate()
2347 regmap_write(rt1011->regmap, RT1011_A_TEMP_SEN, 0x7f40); in rt1011_calibrate()
2348 regmap_write(rt1011->regmap, RT1011_POWER_1, 0x0000); in rt1011_calibrate()
2349 regmap_write(rt1011->regmap, RT1011_POWER_2, 0x0000); in rt1011_calibrate()
2350 regmap_write(rt1011->regmap, RT1011_POWER_3, 0x0002); in rt1011_calibrate()
2351 regmap_write(rt1011->regmap, RT1011_POWER_4, 0x00f2); in rt1011_calibrate()
2353 regmap_write(rt1011->regmap, RT1011_RESET, 0x0000); in rt1011_calibrate()
2357 regmap_write(rt1011->regmap, in rt1011_calibrate()
2360 regmap_write(rt1011->regmap, in rt1011_calibrate()
2363 regmap_write(rt1011->regmap, in rt1011_calibrate()
2368 regcache_cache_bypass(rt1011->regmap, false); in rt1011_calibrate()
2369 regcache_mark_dirty(rt1011->regmap); in rt1011_calibrate()
2370 regcache_sync(rt1011->regmap); in rt1011_calibrate()
2378 struct rt1011_priv *rt1011 = in rt1011_calibration_work() local
2380 struct snd_soc_component *component = rt1011->component; in rt1011_calibration_work()
2383 if (rt1011->r0_calib) in rt1011_calibration_work()
2384 rt1011_calibrate(rt1011, 0); in rt1011_calibration_work()
2386 rt1011_calibrate(rt1011, 1); in rt1011_calibration_work()
2393 rt1011->cali_done = 0; in rt1011_calibration_work()
2399 if (rt1011->temperature_calib <= 0xff && in rt1011_calibration_work()
2400 rt1011->temperature_calib > 0) { in rt1011_calibration_work()
2403 (rt1011->temperature_calib << 2)); in rt1011_calibration_work()
2406 if (rt1011->r0_calib) { in rt1011_calibration_work()
2407 rt1011->r0_reg = rt1011->r0_calib; in rt1011_calibration_work()
2410 r0_integer = format / rt1011->r0_reg / 128; in rt1011_calibration_work()
2411 r0_factor = ((format / rt1011->r0_reg * 100) / 128) in rt1011_calibration_work()
2414 r0_integer, r0_factor, rt1011->r0_reg); in rt1011_calibration_work()
2416 rt1011_r0_load(rt1011); in rt1011_calibration_work()
2422 static int rt1011_parse_dp(struct rt1011_priv *rt1011, struct device *dev) in rt1011_parse_dp() argument
2425 &rt1011->temperature_calib); in rt1011_parse_dp()
2427 &rt1011->r0_calib); in rt1011_parse_dp()
2430 __func__, rt1011->r0_calib, rt1011->temperature_calib); in rt1011_parse_dp()
2437 struct rt1011_priv *rt1011; in rt1011_i2c_probe() local
2441 rt1011 = devm_kzalloc(&i2c->dev, sizeof(struct rt1011_priv), in rt1011_i2c_probe()
2443 if (!rt1011) in rt1011_i2c_probe()
2446 i2c_set_clientdata(i2c, rt1011); in rt1011_i2c_probe()
2448 rt1011_parse_dp(rt1011, &i2c->dev); in rt1011_i2c_probe()
2450 rt1011->regmap = devm_regmap_init_i2c(i2c, &rt1011_regmap); in rt1011_i2c_probe()
2451 if (IS_ERR(rt1011->regmap)) { in rt1011_i2c_probe()
2452 ret = PTR_ERR(rt1011->regmap); in rt1011_i2c_probe()
2458 regmap_read(rt1011->regmap, RT1011_DEVICE_ID, &val); in rt1011_i2c_probe()
2465 INIT_WORK(&rt1011->cali_work, rt1011_calibration_work); in rt1011_i2c_probe()
2475 struct rt1011_priv *rt1011 = i2c_get_clientdata(client); in rt1011_i2c_shutdown() local
2477 rt1011_reset(rt1011->regmap); in rt1011_i2c_shutdown()