Lines Matching +full:1 +full:x64 +full:- +full:bit
1 // SPDX-License-Identifier: GPL-2.0-only
3 // rt1318-sdw.c -- rt1318 SDCA ALSA SoC amplifier audio driver
19 #include <sound/soc-dapm.h>
21 #include "rt1318-sdw.h"
29 { 0xc007, 0x64 },
135 { 0xdba8, 0x64 },
137 { 0xdda8, 0x64 },
175 { 0xc007, 0x64 },
218 { 0xdd94, 0x64 },
347 struct sdw_slave_prop *prop = &slave->prop; in rt1318_read_prop()
350 u32 bit; in rt1318_read_prop() local
354 prop->scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; in rt1318_read_prop()
355 prop->quirks = SDW_SLAVE_QUIRKS_INVALID_INITIAL_PARITY; in rt1318_read_prop()
357 prop->paging_support = true; in rt1318_read_prop()
360 prop->source_ports = BIT(2); in rt1318_read_prop()
361 prop->sink_ports = BIT(1); in rt1318_read_prop()
363 nval = hweight32(prop->source_ports); in rt1318_read_prop()
364 prop->src_dpn_prop = devm_kcalloc(&slave->dev, nval, in rt1318_read_prop()
365 sizeof(*prop->src_dpn_prop), GFP_KERNEL); in rt1318_read_prop()
366 if (!prop->src_dpn_prop) in rt1318_read_prop()
367 return -ENOMEM; in rt1318_read_prop()
370 dpn = prop->src_dpn_prop; in rt1318_read_prop()
371 addr = prop->source_ports; in rt1318_read_prop()
372 for_each_set_bit(bit, &addr, 32) { in rt1318_read_prop()
373 dpn[i].num = bit; in rt1318_read_prop()
381 nval = hweight32(prop->sink_ports); in rt1318_read_prop()
382 prop->sink_dpn_prop = devm_kcalloc(&slave->dev, nval, in rt1318_read_prop()
383 sizeof(*prop->sink_dpn_prop), GFP_KERNEL); in rt1318_read_prop()
384 if (!prop->sink_dpn_prop) in rt1318_read_prop()
385 return -ENOMEM; in rt1318_read_prop()
388 dpn = prop->sink_dpn_prop; in rt1318_read_prop()
389 addr = prop->sink_ports; in rt1318_read_prop()
390 for_each_set_bit(bit, &addr, 32) { in rt1318_read_prop()
391 dpn[j].num = bit; in rt1318_read_prop()
399 prop->clk_stop_timeout = 20; in rt1318_read_prop()
408 if (rt1318->hw_init) in rt1318_io_init()
411 regcache_cache_only(rt1318->regmap, false); in rt1318_io_init()
412 if (rt1318->first_hw_init) { in rt1318_io_init()
413 regcache_cache_bypass(rt1318->regmap, true); in rt1318_io_init()
419 pm_runtime_set_active(&slave->dev); in rt1318_io_init()
422 pm_runtime_get_noresume(&slave->dev); in rt1318_io_init()
425 regmap_multi_reg_write(rt1318->regmap, rt1318_blind_write, in rt1318_io_init()
428 if (rt1318->first_hw_init) { in rt1318_io_init()
429 regcache_cache_bypass(rt1318->regmap, false); in rt1318_io_init()
430 regcache_mark_dirty(rt1318->regmap); in rt1318_io_init()
434 rt1318->first_hw_init = true; in rt1318_io_init()
435 rt1318->hw_init = true; in rt1318_io_init()
437 pm_runtime_mark_last_busy(&slave->dev); in rt1318_io_init()
438 pm_runtime_put_autosuspend(&slave->dev); in rt1318_io_init()
440 dev_dbg(&slave->dev, "%s hw_init complete\n", __func__); in rt1318_io_init()
447 struct rt1318_sdw_priv *rt1318 = dev_get_drvdata(&slave->dev); in rt1318_update_status()
450 rt1318->hw_init = false; in rt1318_update_status()
456 if (rt1318->hw_init || status != SDW_SLAVE_ATTACHED) in rt1318_update_status()
460 return rt1318_io_init(&slave->dev, slave); in rt1318_update_status()
467 snd_soc_dapm_to_component(w->dapm); in rt1318_classd_event()
473 regmap_write(rt1318->regmap, in rt1318_classd_event()
479 regmap_write(rt1318->regmap, in rt1318_classd_event()
519 0, 1, 1);
566 struct snd_soc_component *component = dai->component; in rt1318_sdw_hw_params()
576 dev_dbg(dai->dev, "%s %s", __func__, dai->name); in rt1318_sdw_hw_params()
580 return -EINVAL; in rt1318_sdw_hw_params()
582 if (!rt1318->sdw_slave) in rt1318_sdw_hw_params()
583 return -EINVAL; in rt1318_sdw_hw_params()
586 /* port 1 for playback */ in rt1318_sdw_hw_params()
587 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in rt1318_sdw_hw_params()
589 port = 1; in rt1318_sdw_hw_params()
596 ch_mask = (1 << num_channels) - 1; in rt1318_sdw_hw_params()
606 retval = sdw_stream_add_slave(rt1318->sdw_slave, &stream_config, in rt1318_sdw_hw_params()
607 &port_config, 1, sdw_stream); in rt1318_sdw_hw_params()
609 dev_err(dai->dev, "%s: Unable to configure port\n", __func__); in rt1318_sdw_hw_params()
634 dev_err(component->dev, "%s: Rate %d is not supported\n", in rt1318_sdw_hw_params()
636 return -EINVAL; in rt1318_sdw_hw_params()
640 regmap_write(rt1318->regmap, in rt1318_sdw_hw_params()
650 struct snd_soc_component *component = dai->component; in rt1318_sdw_pcm_hw_free()
656 if (!rt1318->sdw_slave) in rt1318_sdw_pcm_hw_free()
657 return -EINVAL; in rt1318_sdw_pcm_hw_free()
659 sdw_stream_remove_slave(rt1318->sdw_slave, sdw_stream); in rt1318_sdw_pcm_hw_free()
677 rt1318->component = component; in rt1318_sdw_component_probe()
679 if (!rt1318->first_hw_init) in rt1318_sdw_component_probe()
682 ret = pm_runtime_resume(component->dev); in rt1318_sdw_component_probe()
683 dev_dbg(&rt1318->sdw_slave->dev, "%s pm_runtime_resume, ret=%d", __func__, ret); in rt1318_sdw_component_probe()
684 if (ret < 0 && ret != -EACCES) in rt1318_sdw_component_probe()
698 .endianness = 1,
715 .name = "rt1318-aif",
718 .channels_min = 1,
725 .channels_min = 1,
742 return -ENOMEM; in rt1318_sdw_init()
745 rt1318->sdw_slave = slave; in rt1318_sdw_init()
746 rt1318->regmap = regmap; in rt1318_sdw_init()
748 regcache_cache_only(rt1318->regmap, true); in rt1318_sdw_init()
754 rt1318->hw_init = false; in rt1318_sdw_init()
755 rt1318->first_hw_init = false; in rt1318_sdw_init()
776 * fail with -EACCESS because of race conditions between card creation and enumeration in rt1318_sdw_init()
794 return rt1318_sdw_init(&slave->dev, regmap, slave); in rt1318_sdw_probe()
799 pm_runtime_disable(&slave->dev); in rt1318_sdw_remove()
814 if (!rt1318->hw_init) in rt1318_dev_suspend()
817 regcache_cache_only(rt1318->regmap, true); in rt1318_dev_suspend()
829 if (!rt1318->first_hw_init) in rt1318_dev_resume()
832 if (!slave->unattach_request) in rt1318_dev_resume()
835 time = wait_for_completion_timeout(&slave->initialization_complete, in rt1318_dev_resume()
838 dev_err(&slave->dev, "%s: Initialization not complete, timed out\n", __func__); in rt1318_dev_resume()
839 return -ETIMEDOUT; in rt1318_dev_resume()
843 slave->unattach_request = 0; in rt1318_dev_resume()
844 regcache_cache_only(rt1318->regmap, false); in rt1318_dev_resume()
845 regcache_sync(rt1318->regmap); in rt1318_dev_resume()
857 .name = "rt1318-sdca",