Lines Matching +full:back +full:- +full:powering
1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-17 Intel Corporation.
33 timeout--; in intel_wait_bit()
37 return -EAGAIN; in intel_wait_bit()
69 return scnprintf(buf + pos, RD_BUF - pos, "%4x\t%4x\n", reg, value); in intel_sprintf()
74 struct sdw_intel *sdw = s_file->private; in intel_reg_show()
75 void __iomem *s = sdw->link_res->shim; in intel_reg_show()
76 void __iomem *a = sdw->link_res->alh; in intel_reg_show()
83 return -ENOMEM; in intel_reg_show()
88 ret += scnprintf(buf + ret, RD_BUF - ret, "\nShim\n"); in intel_reg_show()
96 ret += scnprintf(buf + ret, RD_BUF - ret, "\nLink%d\n", i); in intel_reg_show()
104 ret += scnprintf(buf + ret, RD_BUF - ret, "\n PCMSyCH registers\n"); in intel_reg_show()
108 * cleanup to remove hard-coded Intel configurations in intel_reg_show()
117 ret += scnprintf(buf + ret, RD_BUF - ret, "\n IOCTL, CTMCTL\n"); in intel_reg_show()
123 ret += scnprintf(buf + ret, RD_BUF - ret, "\nWake registers\n"); in intel_reg_show()
127 ret += scnprintf(buf + ret, RD_BUF - ret, "\nALH STRMzCFG\n"); in intel_reg_show()
140 struct sdw_bus *bus = &sdw->cdns.bus; in intel_set_m_datamode()
143 return -EINVAL; in intel_set_m_datamode()
145 /* Userspace changed the hardware state behind the kernel's back */ in intel_set_m_datamode()
148 bus->params.m_data_mode = value; in intel_set_m_datamode()
158 struct sdw_bus *bus = &sdw->cdns.bus; in intel_set_s_datamode()
161 return -EINVAL; in intel_set_s_datamode()
163 /* Userspace changed the hardware state behind the kernel's back */ in intel_set_s_datamode()
166 bus->params.s_data_mode = value; in intel_set_s_datamode()
175 struct dentry *root = sdw->cdns.bus.debugfs; in intel_debugfs_init()
180 sdw->debugfs = debugfs_create_dir("intel-sdw", root); in intel_debugfs_init()
182 debugfs_create_file("intel-registers", 0400, sdw->debugfs, sdw, in intel_debugfs_init()
185 debugfs_create_file("intel-m-datamode", 0200, sdw->debugfs, sdw, in intel_debugfs_init()
188 debugfs_create_file("intel-s-datamode", 0200, sdw->debugfs, sdw, in intel_debugfs_init()
191 sdw_cdns_debugfs_init(&sdw->cdns, sdw->debugfs); in intel_debugfs_init()
196 debugfs_remove_recursive(sdw->debugfs); in intel_debugfs_exit()
209 void __iomem *shim = sdw->link_res->shim; in intel_shim_glue_to_master_ip()
210 unsigned int link_id = sdw->instance; in intel_shim_glue_to_master_ip()
239 unsigned int link_id = sdw->instance; in intel_shim_master_ip_to_glue()
240 void __iomem *shim = sdw->link_res->shim; in intel_shim_master_ip_to_glue()
260 void __iomem *shim = sdw->link_res->shim; in intel_shim_init()
261 unsigned int link_id = sdw->instance; in intel_shim_init()
296 shim = sdw->link_res->shim; in intel_shim_check_wake()
299 return wake_sts & BIT(sdw->instance); in intel_shim_check_wake()
304 void __iomem *shim = sdw->link_res->shim; in intel_shim_wake()
305 unsigned int link_id = sdw->instance; in intel_shim_wake()
308 mutex_lock(sdw->link_res->shim_lock); in intel_shim_wake()
325 mutex_unlock(sdw->link_res->shim_lock); in intel_shim_wake()
330 void __iomem *shim = sdw->link_res->shim; in intel_check_cmdsync_unlocked()
339 unsigned int link_id = sdw->instance; in intel_link_power_up()
340 void __iomem *shim = sdw->link_res->shim; in intel_link_power_up()
341 u32 *shim_mask = sdw->link_res->shim_mask; in intel_link_power_up()
342 struct sdw_bus *bus = &sdw->cdns.bus; in intel_link_power_up()
343 struct sdw_master_prop *prop = &bus->prop; in intel_link_power_up()
352 mutex_lock(sdw->link_res->shim_lock); in intel_link_power_up()
356 * to generate the SoundWire SSP - which defines a 'safe' in intel_link_power_up()
367 if (prop->mclk_freq % 6000000) { in intel_link_power_up()
368 if (prop->mclk_freq % 2400000) { in intel_link_power_up()
373 dev_err(sdw->cdns.dev, "%s: invalid clock configuration, mclk %d lcap_mlcs %d\n", in intel_link_power_up()
374 __func__, prop->mclk_freq, lcap_mlcs); in intel_link_power_up()
375 ret = -EINVAL; in intel_link_power_up()
393 dev_dbg(sdw->cdns.dev, "powering up all links\n"); in intel_link_power_up()
396 dev_dbg(sdw->cdns.dev, in intel_link_power_up()
410 /* only power-up enabled links */ in intel_link_power_up()
411 spa_mask = FIELD_PREP(SDW_SHIM_LCTL_SPA_MASK, sdw->link_res->link_mask); in intel_link_power_up()
412 cpa_mask = FIELD_PREP(SDW_SHIM_LCTL_CPA_MASK, sdw->link_res->link_mask); in intel_link_power_up()
418 dev_err(sdw->cdns.dev, "Failed to power up link: %d\n", ret); in intel_link_power_up()
426 dev_err(sdw->cdns.dev, in intel_link_power_up()
441 sdw->cdns.link_up = true; in intel_link_power_up()
446 mutex_unlock(sdw->link_res->shim_lock); in intel_link_power_up()
454 unsigned int link_id = sdw->instance; in intel_link_power_down()
455 void __iomem *shim = sdw->link_res->shim; in intel_link_power_down()
456 u32 *shim_mask = sdw->link_res->shim_mask; in intel_link_power_down()
459 mutex_lock(sdw->link_res->shim_lock); in intel_link_power_down()
462 dev_err(sdw->cdns.dev, in intel_link_power_down()
463 "%s: Unbalanced power-up/down calls\n", __func__); in intel_link_power_down()
465 sdw->cdns.link_up = false; in intel_link_power_down()
473 dev_dbg(sdw->cdns.dev, "powering down all links\n"); in intel_link_power_down()
478 /* only power-down enabled links */ in intel_link_power_down()
479 spa_mask = FIELD_PREP(SDW_SHIM_LCTL_SPA_MASK, ~sdw->link_res->link_mask); in intel_link_power_down()
480 cpa_mask = FIELD_PREP(SDW_SHIM_LCTL_CPA_MASK, sdw->link_res->link_mask); in intel_link_power_down()
486 dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__); in intel_link_power_down()
489 * we leave the sdw->cdns.link_up flag as false since we've disabled in intel_link_power_down()
495 mutex_unlock(sdw->link_res->shim_lock); in intel_link_power_down()
502 void __iomem *shim = sdw->link_res->shim; in intel_shim_sync_arm()
505 mutex_lock(sdw->link_res->shim_lock); in intel_shim_sync_arm()
509 sync_reg |= (SDW_SHIM_SYNC_CMDSYNC << sdw->instance); in intel_shim_sync_arm()
512 mutex_unlock(sdw->link_res->shim_lock); in intel_shim_sync_arm()
517 void __iomem *shim = sdw->link_res->shim; in intel_shim_sync_go_unlocked()
539 mutex_lock(sdw->link_res->shim_lock); in intel_shim_sync_go()
543 mutex_unlock(sdw->link_res->shim_lock); in intel_shim_sync_go()
554 void __iomem *shim = sdw->link_res->shim; in intel_pdi_init()
555 unsigned int link_id = sdw->instance; in intel_pdi_init()
561 config->pcm_bd = FIELD_GET(SDW_SHIM_PCMSCAP_BSS, pcm_cap); in intel_pdi_init()
562 config->pcm_in = FIELD_GET(SDW_SHIM_PCMSCAP_ISS, pcm_cap); in intel_pdi_init()
563 config->pcm_out = FIELD_GET(SDW_SHIM_PCMSCAP_OSS, pcm_cap); in intel_pdi_init()
565 dev_dbg(sdw->cdns.dev, "PCM cap bd:%d in:%d out:%d\n", in intel_pdi_init()
566 config->pcm_bd, config->pcm_in, config->pcm_out); in intel_pdi_init()
572 void __iomem *shim = sdw->link_res->shim; in intel_pdi_get_ch_cap()
573 unsigned int link_id = sdw->instance; in intel_pdi_get_ch_cap()
601 pdi->ch_count = intel_pdi_get_ch_cap(sdw, pdi->num); in intel_pdi_get_ch_update()
602 ch_count += pdi->ch_count; in intel_pdi_get_ch_update()
613 intel_pdi_get_ch_update(sdw, stream->bd, stream->num_bd, in intel_pdi_stream_ch_update()
614 &stream->num_ch_bd); in intel_pdi_stream_ch_update()
616 intel_pdi_get_ch_update(sdw, stream->in, stream->num_in, in intel_pdi_stream_ch_update()
617 &stream->num_ch_in); in intel_pdi_stream_ch_update()
619 intel_pdi_get_ch_update(sdw, stream->out, stream->num_out, in intel_pdi_stream_ch_update()
620 &stream->num_ch_out); in intel_pdi_stream_ch_update()
628 void __iomem *shim = sdw->link_res->shim; in intel_pdi_shim_configure()
629 unsigned int link_id = sdw->instance; in intel_pdi_shim_configure()
633 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3; in intel_pdi_shim_configure()
634 if (pdi->num >= 2) in intel_pdi_shim_configure()
635 pdi->intel_alh_id += 2; in intel_pdi_shim_configure()
641 if (pdi->type != SDW_STREAM_PCM) in intel_pdi_shim_configure()
644 if (pdi->dir == SDW_DATA_DIR_RX) in intel_pdi_shim_configure()
649 u32p_replace_bits(&pdi_conf, pdi->intel_alh_id, SDW_SHIM_PCMSYCM_STREAM); in intel_pdi_shim_configure()
650 u32p_replace_bits(&pdi_conf, pdi->l_ch_num, SDW_SHIM_PCMSYCM_LCHN); in intel_pdi_shim_configure()
651 u32p_replace_bits(&pdi_conf, pdi->h_ch_num, SDW_SHIM_PCMSYCM_HCHN); in intel_pdi_shim_configure()
653 intel_writew(shim, SDW_SHIM_PCMSYCHM(link_id, pdi->num), pdi_conf); in intel_pdi_shim_configure()
659 void __iomem *alh = sdw->link_res->alh; in intel_pdi_alh_configure()
660 unsigned int link_id = sdw->instance; in intel_pdi_alh_configure()
664 pdi->intel_alh_id = (link_id * 16) + pdi->num + 3; in intel_pdi_alh_configure()
665 if (pdi->num >= 2) in intel_pdi_alh_configure()
666 pdi->intel_alh_id += 2; in intel_pdi_alh_configure()
669 conf = intel_readl(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id)); in intel_pdi_alh_configure()
672 u32p_replace_bits(&conf, pdi->ch_count - 1, SDW_ALH_STRMZCFG_CHN); in intel_pdi_alh_configure()
674 intel_writel(alh, SDW_ALH_STRMZCFG(pdi->intel_alh_id), conf); in intel_pdi_alh_configure()
683 struct sdw_intel_link_res *res = sdw->link_res; in intel_params_stream()
692 if (res->ops && res->ops->params_stream && res->dev) in intel_params_stream()
693 return res->ops->params_stream(res->dev, in intel_params_stream()
695 return -EIO; in intel_params_stream()
707 struct sdw_intel_link_res *res = sdw->link_res; in intel_free_stream()
714 if (res->ops && res->ops->free_stream && res->dev) in intel_free_stream()
715 return res->ops->free_stream(res->dev, &free_data); in intel_free_stream()
732 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_hw_params()
734 return -EIO; in intel_hw_params()
737 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in intel_hw_params()
742 pdi = sdw_cdns_alloc_pdi(cdns, &cdns->pcm, ch, dir, dai->id); in intel_hw_params()
745 return -EINVAL; in intel_hw_params()
747 /* do run-time configurations for SHIM, ALH and PDI/PORT */ in intel_hw_params()
753 dai_runtime->paused = false; in intel_hw_params()
754 dai_runtime->suspended = false; in intel_hw_params()
755 dai_runtime->pdi = pdi; in intel_hw_params()
759 sdw->instance, in intel_hw_params()
760 pdi->intel_alh_id); in intel_hw_params()
767 sconfig.type = dai_runtime->stream_type; in intel_hw_params()
775 return -ENOMEM; in intel_hw_params()
777 pconfig->num = pdi->num; in intel_hw_params()
778 pconfig->ch_mask = (1 << ch) - 1; in intel_hw_params()
780 ret = sdw_stream_add_master(&cdns->bus, &sconfig, in intel_hw_params()
781 pconfig, 1, dai_runtime->stream); in intel_hw_params()
783 dev_err(cdns->dev, "add master to stream failed:%d\n", ret); in intel_hw_params()
797 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_prepare()
799 dev_err(dai->dev, "failed to get dai runtime in %s\n", in intel_prepare()
801 return -EIO; in intel_prepare()
804 if (dai_runtime->suspended) { in intel_prepare()
808 hw_params = &rtd->dpcm[substream->stream].hw_params; in intel_prepare()
810 dai_runtime->suspended = false; in intel_prepare()
822 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in intel_prepare()
827 intel_pdi_shim_configure(sdw, dai_runtime->pdi); in intel_prepare()
828 intel_pdi_alh_configure(sdw, dai_runtime->pdi); in intel_prepare()
829 sdw_cdns_config_stream(cdns, ch, dir, dai_runtime->pdi); in intel_prepare()
834 sdw->instance, in intel_prepare()
835 dai_runtime->pdi->intel_alh_id); in intel_prepare()
849 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_hw_free()
851 return -EIO; in intel_hw_free()
854 * The sdw stream state will transition to RELEASED when stream-> in intel_hw_free()
856 * DEPREPARED for the first cpu-dai and to RELEASED for the last in intel_hw_free()
857 * cpu-dai. in intel_hw_free()
859 ret = sdw_stream_remove_master(&cdns->bus, dai_runtime->stream); in intel_hw_free()
861 dev_err(dai->dev, "remove master from stream %s failed: %d\n", in intel_hw_free()
862 dai_runtime->stream->name, ret); in intel_hw_free()
866 ret = intel_free_stream(sdw, substream, dai, sdw->instance); in intel_hw_free()
868 dev_err(dai->dev, "intel_free_stream: failed %d\n", ret); in intel_hw_free()
872 dai_runtime->pdi = NULL; in intel_hw_free()
889 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_get_sdw_stream()
891 return ERR_PTR(-EINVAL); in intel_get_sdw_stream()
893 return dai_runtime->stream; in intel_get_sdw_stream()
902 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_trigger()
904 dev_err(dai->dev, "failed to get dai runtime in %s\n", in intel_trigger()
906 return -EIO; in intel_trigger()
919 dai_runtime->suspended = true; in intel_trigger()
924 dai_runtime->paused = true; in intel_trigger()
928 dai_runtime->paused = false; in intel_trigger()
947 ret = pm_runtime_resume(component->dev); in intel_component_probe()
948 if (ret < 0 && ret != -EACCES) in intel_component_probe()
968 dai_runtime = cdns->dai_runtime_array[dai->id]; in intel_component_dais_suspend()
973 if (dai_runtime->suspended) in intel_component_dais_suspend()
976 if (dai_runtime->paused) in intel_component_dais_suspend()
977 dai_runtime->suspended = true; in intel_component_dais_suspend()
1010 dais[i].name = devm_kasprintf(cdns->dev, GFP_KERNEL, in intel_create_dai()
1012 cdns->instance, i); in intel_create_dai()
1014 return -ENOMEM; in intel_create_dai()
1036 struct sdw_cdns *cdns = &sdw->cdns; in intel_register_dai()
1047 intel_pdi_stream_ch_update(sdw, &sdw->cdns.pcm); in intel_register_dai()
1050 num_dai = cdns->pcm.num_pdi; in intel_register_dai()
1052 dai_runtime_array = devm_kcalloc(cdns->dev, num_dai, in intel_register_dai()
1056 return -ENOMEM; in intel_register_dai()
1057 cdns->dai_runtime_array = dai_runtime_array; in intel_register_dai()
1059 dais = devm_kcalloc(cdns->dev, num_dai, sizeof(*dais), GFP_KERNEL); in intel_register_dai()
1061 return -ENOMEM; in intel_register_dai()
1064 stream = &cdns->pcm; in intel_register_dai()
1066 ret = intel_create_dai(cdns, dais, INTEL_PDI_IN, cdns->pcm.num_in, in intel_register_dai()
1067 off, stream->num_ch_in); in intel_register_dai()
1071 off += cdns->pcm.num_in; in intel_register_dai()
1072 ret = intel_create_dai(cdns, dais, INTEL_PDI_OUT, cdns->pcm.num_out, in intel_register_dai()
1073 off, stream->num_ch_out); in intel_register_dai()
1077 off += cdns->pcm.num_out; in intel_register_dai()
1078 ret = intel_create_dai(cdns, dais, INTEL_PDI_BD, cdns->pcm.num_bd, in intel_register_dai()
1079 off, stream->num_ch_bd); in intel_register_dai()
1083 return devm_snd_soc_register_component(cdns->dev, &dai_component, in intel_register_dai()