Lines Matching defs:rt1308
3 // rt1308-sdw.c -- rt1308 ALSA SoC audio driver
25 #include "rt1308.h"
26 #include "rt1308-sdw.h"
87 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
90 clk_freq = (rt1308->params.curr_dr_freq >> 1);
115 regmap_write(rt1308->regmap, 0xe0, value);
116 regmap_write(rt1308->regmap, 0xf0, value);
167 static void rt1308_apply_calib_params(struct rt1308_sdw_priv *rt1308)
173 regmap_write(rt1308->regmap, 0xc7f0, 0x04);
174 regmap_write(rt1308->regmap, 0xc7f1, 0xfe);
176 regmap_write(rt1308->regmap, 0xc7f0, 0x44);
178 regmap_write(rt1308->regmap, 0xc240, 0x10);
180 regmap_read(rt1308->regmap, 0xc861, &tmp);
182 regmap_read(rt1308->regmap, 0xc860, &tmp);
184 regmap_read(rt1308->regmap, 0xc863, &tmp);
186 regmap_read(rt1308->regmap, 0xc862, &tmp);
188 regmap_read(rt1308->regmap, 0xc871, &tmp);
190 regmap_read(rt1308->regmap, 0xc870, &tmp);
192 regmap_read(rt1308->regmap, 0xc873, &tmp);
194 regmap_read(rt1308->regmap, 0xc872, &tmp);
196 dev_dbg(&rt1308->sdw_slave->dev, "%s m_btl_l=0x%x, m_btl_r=0x%x\n", __func__,
198 dev_dbg(&rt1308->sdw_slave->dev, "%s c_btl_l=0x%x, c_btl_r=0x%x\n", __func__,
202 static void rt1308_apply_bq_params(struct rt1308_sdw_priv *rt1308)
206 for (i = 0; i < rt1308->bq_params_cnt; i += 3) {
207 reg = rt1308->bq_params[i] | (rt1308->bq_params[i + 1] << 8);
208 data = rt1308->bq_params[i + 2];
209 regmap_write(rt1308->regmap, reg, data);
215 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
219 if (rt1308->hw_init)
222 regcache_cache_only(rt1308->regmap, false);
223 if (rt1308->first_hw_init)
224 regcache_cache_bypass(rt1308->regmap, true);
229 if (!rt1308->first_hw_init)
235 regmap_read(rt1308->regmap, 0xcf01, &hibernation_flag);
236 if ((hibernation_flag != 0x00) && rt1308->first_hw_init)
240 regmap_write(rt1308->regmap, RT1308_SDW_RESET, 0);
242 regmap_read(rt1308->regmap, 0xc710, &tmp);
243 rt1308->hw_ver = tmp;
244 dev_dbg(dev, "%s, hw_ver=0x%x\n", __func__, rt1308->hw_ver);
247 regmap_write(rt1308->regmap, 0xc103, 0xc0);
248 regmap_write(rt1308->regmap, 0xc030, 0x17);
249 regmap_write(rt1308->regmap, 0xc031, 0x81);
250 regmap_write(rt1308->regmap, 0xc032, 0x26);
251 regmap_write(rt1308->regmap, 0xc040, 0x80);
252 regmap_write(rt1308->regmap, 0xc041, 0x80);
253 regmap_write(rt1308->regmap, 0xc042, 0x06);
254 regmap_write(rt1308->regmap, 0xc052, 0x0a);
255 regmap_write(rt1308->regmap, 0xc080, 0x0a);
256 regmap_write(rt1308->regmap, 0xc060, 0x02);
257 regmap_write(rt1308->regmap, 0xc061, 0x75);
258 regmap_write(rt1308->regmap, 0xc062, 0x05);
259 regmap_write(rt1308->regmap, 0xc171, 0x07);
260 regmap_write(rt1308->regmap, 0xc173, 0x0d);
261 if (rt1308->hw_ver == RT1308_VER_C) {
262 regmap_write(rt1308->regmap, 0xc311, 0x7f);
263 regmap_write(rt1308->regmap, 0xc300, 0x09);
265 regmap_write(rt1308->regmap, 0xc311, 0x4f);
266 regmap_write(rt1308->regmap, 0xc300, 0x0b);
268 regmap_write(rt1308->regmap, 0xc900, 0x5a);
269 regmap_write(rt1308->regmap, 0xc1a0, 0x84);
270 regmap_write(rt1308->regmap, 0xc1a1, 0x01);
271 regmap_write(rt1308->regmap, 0xc360, 0x78);
272 regmap_write(rt1308->regmap, 0xc361, 0x87);
273 regmap_write(rt1308->regmap, 0xc0a1, 0x71);
274 regmap_write(rt1308->regmap, 0xc210, 0x00);
275 regmap_write(rt1308->regmap, 0xc070, 0x00);
276 regmap_write(rt1308->regmap, 0xc100, 0xd7);
277 regmap_write(rt1308->regmap, 0xc101, 0xd7);
280 rt1308_apply_bq_params(rt1308);
282 regmap_write(rt1308->regmap, 0xcf01, 0x01);
285 if (rt1308->first_hw_init) {
286 regcache_cache_bypass(rt1308->regmap, false);
287 regcache_mark_dirty(rt1308->regmap);
289 rt1308->first_hw_init = true;
292 rt1308->hw_init = true;
305 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev);
308 rt1308->hw_init = false;
314 if (rt1308->hw_init || status != SDW_SLAVE_ATTACHED)
324 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(&slave->dev);
327 memcpy(&rt1308->params, params, sizeof(*params));
350 struct rt1308_sdw_priv *rt1308 =
360 rt1308_apply_calib_params(rt1308);
513 struct rt1308_sdw_priv *rt1308 =
522 rt1308->rx_mask = rx_mask;
523 rt1308->slots = slots;
533 struct rt1308_sdw_priv *rt1308 =
546 if (!rt1308->sdw_slave)
558 if (rt1308->slots) {
559 stream_config.ch_count = rt1308->slots;
560 port_config.ch_mask = rt1308->rx_mask;
563 retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config,
577 struct rt1308_sdw_priv *rt1308 =
582 if (!rt1308->sdw_slave)
585 sdw_stream_remove_slave(rt1308->sdw_slave, sdw_stream);
600 static int rt1308_sdw_parse_dt(struct rt1308_sdw_priv *rt1308, struct device *dev)
604 device_property_read_u32(dev, "realtek,bq-params-cnt", &rt1308->bq_params_cnt);
605 if (rt1308->bq_params_cnt) {
606 rt1308->bq_params = devm_kzalloc(dev, rt1308->bq_params_cnt, GFP_KERNEL);
607 if (!rt1308->bq_params) {
611 ret = device_property_read_u8_array(dev, "realtek,bq-params", rt1308->bq_params, rt1308->bq_params_cnt);
617 dev_dbg(dev, "bq_params_cnt=%d\n", rt1308->bq_params_cnt);
623 struct rt1308_sdw_priv *rt1308 = snd_soc_component_get_drvdata(component);
626 rt1308->component = component;
627 rt1308_sdw_parse_dt(rt1308, &rt1308->sdw_slave->dev);
629 if (!rt1308->first_hw_init)
637 rt1308_apply_bq_params(rt1308);
668 .name = "rt1308-aif",
683 struct rt1308_sdw_priv *rt1308;
686 rt1308 = devm_kzalloc(dev, sizeof(*rt1308), GFP_KERNEL);
687 if (!rt1308)
690 dev_set_drvdata(dev, rt1308);
691 rt1308->sdw_slave = slave;
692 rt1308->regmap = regmap;
694 regcache_cache_only(rt1308->regmap, true);
700 rt1308->hw_init = false;
701 rt1308->first_hw_init = false;
758 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
760 if (!rt1308->hw_init)
763 regcache_cache_only(rt1308->regmap, true);
773 struct rt1308_sdw_priv *rt1308 = dev_get_drvdata(dev);
776 if (!rt1308->first_hw_init)
793 regcache_cache_only(rt1308->regmap, false);
794 regcache_sync_region(rt1308->regmap, 0xc000, 0xcfff);
806 .name = "rt1308",