Lines Matching refs:rt5682
43 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_sdw_read() local
46 regmap_write(rt5682->sdw_regmap, RT5682_SDW_CMD, 0); in rt5682_sdw_read()
47 regmap_write(rt5682->sdw_regmap, RT5682_SDW_ADDR_H, (reg >> 8) & 0xff); in rt5682_sdw_read()
48 regmap_write(rt5682->sdw_regmap, RT5682_SDW_ADDR_L, (reg & 0xff)); in rt5682_sdw_read()
49 regmap_read(rt5682->sdw_regmap, RT5682_SDW_DATA_H, &data_h); in rt5682_sdw_read()
50 regmap_read(rt5682->sdw_regmap, RT5682_SDW_DATA_L, &data_l); in rt5682_sdw_read()
62 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_sdw_write() local
64 regmap_write(rt5682->sdw_regmap, RT5682_SDW_CMD, 1); in rt5682_sdw_write()
65 regmap_write(rt5682->sdw_regmap, RT5682_SDW_ADDR_H, (reg >> 8) & 0xff); in rt5682_sdw_write()
66 regmap_write(rt5682->sdw_regmap, RT5682_SDW_ADDR_L, (reg & 0xff)); in rt5682_sdw_write()
67 regmap_write(rt5682->sdw_regmap, RT5682_SDW_DATA_H, (val >> 8) & 0xff); in rt5682_sdw_write()
68 regmap_write(rt5682->sdw_regmap, RT5682_SDW_DATA_L, (val & 0xff)); in rt5682_sdw_write()
132 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); in rt5682_sdw_hw_params() local
146 if (!rt5682->slave) in rt5682_sdw_hw_params()
167 retval = sdw_stream_add_slave(rt5682->slave, &stream_config, in rt5682_sdw_hw_params()
243 regmap_update_bits(rt5682->regmap, RT5682_SDW_REF_CLK, in rt5682_sdw_hw_params()
245 regmap_update_bits(rt5682->regmap, RT5682_ADDA_CLK_1, in rt5682_sdw_hw_params()
248 regmap_update_bits(rt5682->regmap, RT5682_SDW_REF_CLK, in rt5682_sdw_hw_params()
250 regmap_update_bits(rt5682->regmap, RT5682_ADDA_CLK_1, in rt5682_sdw_hw_params()
261 struct rt5682_priv *rt5682 = snd_soc_component_get_drvdata(component); in rt5682_sdw_hw_free() local
265 if (!rt5682->slave) in rt5682_sdw_hw_free()
268 sdw_stream_remove_slave(rt5682->slave, stream->sdw_stream); in rt5682_sdw_hw_free()
335 struct rt5682_priv *rt5682; in rt5682_sdw_init() local
338 rt5682 = devm_kzalloc(dev, sizeof(*rt5682), GFP_KERNEL); in rt5682_sdw_init()
339 if (!rt5682) in rt5682_sdw_init()
342 dev_set_drvdata(dev, rt5682); in rt5682_sdw_init()
343 rt5682->slave = slave; in rt5682_sdw_init()
344 rt5682->sdw_regmap = regmap; in rt5682_sdw_init()
345 rt5682->is_sdw = true; in rt5682_sdw_init()
347 mutex_init(&rt5682->disable_irq_lock); in rt5682_sdw_init()
349 rt5682->regmap = devm_regmap_init(dev, NULL, dev, in rt5682_sdw_init()
351 if (IS_ERR(rt5682->regmap)) { in rt5682_sdw_init()
352 ret = PTR_ERR(rt5682->regmap); in rt5682_sdw_init()
362 rt5682->hw_init = false; in rt5682_sdw_init()
363 rt5682->first_hw_init = false; in rt5682_sdw_init()
365 mutex_init(&rt5682->calibrate_mutex); in rt5682_sdw_init()
366 INIT_DELAYED_WORK(&rt5682->jack_detect_work, in rt5682_sdw_init()
379 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_io_init() local
383 rt5682->disable_irq = false; in rt5682_io_init()
385 if (rt5682->hw_init) in rt5682_io_init()
391 if (!rt5682->first_hw_init) { in rt5682_io_init()
407 if (rt5682->first_hw_init) { in rt5682_io_init()
408 regcache_cache_only(rt5682->regmap, false); in rt5682_io_init()
409 regcache_cache_bypass(rt5682->regmap, true); in rt5682_io_init()
413 regmap_read(rt5682->regmap, RT5682_DEVICE_ID, &val); in rt5682_io_init()
427 rt5682_calibrate(rt5682); in rt5682_io_init()
429 if (rt5682->first_hw_init) { in rt5682_io_init()
430 regcache_cache_bypass(rt5682->regmap, false); in rt5682_io_init()
431 regcache_mark_dirty(rt5682->regmap); in rt5682_io_init()
432 regcache_sync(rt5682->regmap); in rt5682_io_init()
435 regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_2, in rt5682_io_init()
441 rt5682_apply_patch_list(rt5682, dev); in rt5682_io_init()
443 regmap_write(rt5682->regmap, RT5682_DEPOP_1, 0x0000); in rt5682_io_init()
445 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_1, in rt5682_io_init()
448 regmap_write(rt5682->regmap, RT5682_MICBIAS_2, 0x0080); in rt5682_io_init()
449 regmap_write(rt5682->regmap, RT5682_TEST_MODE_CTRL_1, 0x0000); in rt5682_io_init()
450 regmap_update_bits(rt5682->regmap, RT5682_BIAS_CUR_CTRL_8, in rt5682_io_init()
452 regmap_update_bits(rt5682->regmap, RT5682_CHARGE_PUMP_1, in rt5682_io_init()
454 regmap_update_bits(rt5682->regmap, RT5682_HP_CHARGE_PUMP_1, in rt5682_io_init()
458 regmap_write(rt5682->regmap, RT5682_PLL2_INTERNAL, 0xa266); in rt5682_io_init()
459 regmap_write(rt5682->regmap, RT5682_PLL2_CTRL_1, 0x1700); in rt5682_io_init()
460 regmap_write(rt5682->regmap, RT5682_PLL2_CTRL_2, 0x0006); in rt5682_io_init()
461 regmap_write(rt5682->regmap, RT5682_PLL2_CTRL_3, 0x2600); in rt5682_io_init()
462 regmap_write(rt5682->regmap, RT5682_PLL2_CTRL_4, 0x0c8f); in rt5682_io_init()
463 regmap_write(rt5682->regmap, RT5682_PLL_TRACK_2, 0x3000); in rt5682_io_init()
464 regmap_write(rt5682->regmap, RT5682_PLL_TRACK_3, 0x4000); in rt5682_io_init()
465 regmap_update_bits(rt5682->regmap, RT5682_GLB_CLK, in rt5682_io_init()
469 regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_2, in rt5682_io_init()
471 regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd142); in rt5682_io_init()
472 regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_5, 0x0700, 0x0600); in rt5682_io_init()
473 regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_3, in rt5682_io_init()
475 regmap_update_bits(rt5682->regmap, RT5682_SAR_IL_CMD_1, in rt5682_io_init()
477 regmap_update_bits(rt5682->regmap, RT5682_RC_CLK_CTRL, in rt5682_io_init()
481 regmap_update_bits(rt5682->regmap, RT5682_PWR_ANLG_2, in rt5682_io_init()
483 regmap_update_bits(rt5682->regmap, RT5682_IRQ_CTRL_2, in rt5682_io_init()
489 &rt5682->jack_detect_work, msecs_to_jiffies(250)); in rt5682_io_init()
492 rt5682->hw_init = true; in rt5682_io_init()
493 rt5682->first_hw_init = true; in rt5682_io_init()
534 struct rt5682_priv *rt5682 = dev_get_drvdata(&slave->dev); in rt5682_update_status() local
537 rt5682->status = status; in rt5682_update_status()
540 rt5682->hw_init = false; in rt5682_update_status()
546 if (rt5682->hw_init || rt5682->status != SDW_SLAVE_ATTACHED) in rt5682_update_status()
627 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_clock_config() local
630 clk_freq = (rt5682->params.curr_dr_freq >> 1); in rt5682_clock_config()
655 regmap_write(rt5682->sdw_regmap, 0xe0, value); in rt5682_clock_config()
656 regmap_write(rt5682->sdw_regmap, 0xf0, value); in rt5682_clock_config()
666 struct rt5682_priv *rt5682 = dev_get_drvdata(&slave->dev); in rt5682_bus_config() local
669 memcpy(&rt5682->params, params, sizeof(*params)); in rt5682_bus_config()
681 struct rt5682_priv *rt5682 = dev_get_drvdata(&slave->dev); in rt5682_interrupt_callback() local
686 mutex_lock(&rt5682->disable_irq_lock); in rt5682_interrupt_callback()
687 if (status->control_port & 0x4 && !rt5682->disable_irq) { in rt5682_interrupt_callback()
689 &rt5682->jack_detect_work, msecs_to_jiffies(rt5682->irq_work_delay_time)); in rt5682_interrupt_callback()
691 mutex_unlock(&rt5682->disable_irq_lock); in rt5682_interrupt_callback()
720 struct rt5682_priv *rt5682 = dev_get_drvdata(&slave->dev); in rt5682_sdw_remove() local
722 if (rt5682->hw_init) in rt5682_sdw_remove()
723 cancel_delayed_work_sync(&rt5682->jack_detect_work); in rt5682_sdw_remove()
725 if (rt5682->first_hw_init) in rt5682_sdw_remove()
739 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_dev_suspend() local
741 if (!rt5682->hw_init) in rt5682_dev_suspend()
744 cancel_delayed_work_sync(&rt5682->jack_detect_work); in rt5682_dev_suspend()
746 regcache_cache_only(rt5682->regmap, true); in rt5682_dev_suspend()
747 regcache_mark_dirty(rt5682->regmap); in rt5682_dev_suspend()
754 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_dev_system_suspend() local
758 if (!rt5682->hw_init) in rt5682_dev_system_suspend()
766 mutex_lock(&rt5682->disable_irq_lock); in rt5682_dev_system_suspend()
767 rt5682->disable_irq = true; in rt5682_dev_system_suspend()
770 mutex_unlock(&rt5682->disable_irq_lock); in rt5682_dev_system_suspend()
783 struct rt5682_priv *rt5682 = dev_get_drvdata(dev); in rt5682_dev_resume() local
786 if (!rt5682->first_hw_init) in rt5682_dev_resume()
803 regcache_cache_only(rt5682->regmap, false); in rt5682_dev_resume()
804 regcache_sync(rt5682->regmap); in rt5682_dev_resume()