Lines Matching +full:ports +full:- +full:offset2
1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
2 // Copyright(c) 2015-17 Intel Corporation.
32 #define CDNS_IP_MCP_CONFIG 0x0 /* IP offset added at run-time */
49 #define CDNS_IP_MCP_CONTROL 0x4 /* IP offset added at run-time */
57 #define CDNS_IP_MCP_CMDCTRL 0x8 /* IP offset added at run-time */
132 #define CDNS_IP_MCP_CMD_BASE 0x80 /* IP offset added at run-time */
133 #define CDNS_IP_MCP_RESP_BASE 0x80 /* IP offset added at run-time */
205 return readl(cdns->registers + offset); in cdns_readl()
210 writel(value, cdns->registers + offset); in cdns_writel()
215 return cdns_readl(cdns, cdns->ip_offset + offset); in cdns_ip_readl()
220 return cdns_writel(cdns, cdns->ip_offset + offset, value); in cdns_ip_writel()
236 cdns_updatel(cdns, cdns->ip_offset + offset, mask, val); in cdns_ip_updatel()
246 reg_read = readl(cdns->registers + offset); in cdns_set_wait()
250 timeout--; in cdns_set_wait()
254 return -ETIMEDOUT; in cdns_set_wait()
259 writel(value, cdns->registers + offset); in cdns_clear_bit()
274 dev_err(cdns->dev, "Cannot program MCP_CONFIG_UPDATE in ClockStopMode\n"); in cdns_config_update()
275 return -EINVAL; in cdns_config_update()
281 dev_err(cdns->dev, "Config update timedout\n"); in cdns_config_update()
287 * sdw_cdns_config_update() - Update configurations
298 * sdw_cdns_config_update_set_wait() - wait until configuration update bit is self-cleared
319 return scnprintf(buf + pos, RD_BUF - pos, in cdns_sprintf()
325 struct sdw_cdns *cdns = s->private; in cdns_reg_show()
333 return -ENOMEM; in cdns_reg_show()
336 ret += scnprintf(buf + ret, RD_BUF - ret, "\nMCP Registers\n"); in cdns_reg_show()
341 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
347 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
354 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
357 num_ports = cdns->num_ports; in cdns_reg_show()
360 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
361 "\nDP-%d\n", i); in cdns_reg_show()
367 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
370 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
371 "\nDP-%d\n", i); in cdns_reg_show()
378 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
384 ret += scnprintf(buf + ret, RD_BUF - ret, in cdns_reg_show()
387 /* number of PDI and ports is interchangeable */ in cdns_reg_show()
404 return -EINVAL; in cdns_hw_reset()
411 dev_dbg(cdns->dev, "link hw_reset done: %d\n", ret); in cdns_hw_reset()
425 return -EINVAL; in cdns_parity_error_injection()
427 bus = &cdns->bus; in cdns_parity_error_injection()
431 * Slave devices will re-attach and be re-enumerated. in cdns_parity_error_injection()
433 ret = pm_runtime_resume_and_get(bus->dev); in cdns_parity_error_injection()
434 if (ret < 0 && ret != -EACCES) { in cdns_parity_error_injection()
435 dev_err_ratelimited(cdns->dev, in cdns_parity_error_injection()
451 mutex_lock(&bus->bus_lock); in cdns_parity_error_injection()
464 ret = sdw_bread_no_pm_unlocked(&cdns->bus, 0xf, SDW_SCP_DEVID_0); in cdns_parity_error_injection()
465 dev_info(cdns->dev, "parity error injection, read: %d\n", ret); in cdns_parity_error_injection()
482 mutex_unlock(&bus->bus_lock); in cdns_parity_error_injection()
488 pm_runtime_mark_last_busy(bus->dev); in cdns_parity_error_injection()
489 pm_runtime_put_autosuspend(bus->dev); in cdns_parity_error_injection()
500 unsigned int pdi_out_num = cdns->pcm.num_bd + cdns->pcm.num_out; in cdns_set_pdi_loopback_source()
503 return -EINVAL; in cdns_set_pdi_loopback_source()
508 cdns->pdi_loopback_source = value; in cdns_set_pdi_loopback_source()
517 unsigned int pdi_in_num = cdns->pcm.num_bd + cdns->pcm.num_in; in cdns_set_pdi_loopback_target()
520 return -EINVAL; in cdns_set_pdi_loopback_target()
525 cdns->pdi_loopback_target = value; in cdns_set_pdi_loopback_target()
532 * sdw_cdns_debugfs_init() - Cadence debugfs init
538 debugfs_create_file("cdns-registers", 0400, root, cdns, &cdns_reg_fops); in sdw_cdns_debugfs_init()
540 debugfs_create_file("cdns-hw-reset", 0200, root, cdns, in sdw_cdns_debugfs_init()
543 debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns, in sdw_cdns_debugfs_init()
546 cdns->pdi_loopback_source = -1; in sdw_cdns_debugfs_init()
547 cdns->pdi_loopback_target = -1; in sdw_cdns_debugfs_init()
549 debugfs_create_file("cdns-pdi-loopback-source", 0200, root, cdns, in sdw_cdns_debugfs_init()
552 debugfs_create_file("cdns-pdi-loopback-target", 0200, root, cdns, in sdw_cdns_debugfs_init()
572 if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) { in cdns_fill_msg_resp()
574 dev_vdbg(cdns->dev, "Msg Ack not received, cmd %d\n", i); in cdns_fill_msg_resp()
576 if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { in cdns_fill_msg_resp()
578 dev_err_ratelimited(cdns->dev, "Msg NACK received, cmd %d\n", i); in cdns_fill_msg_resp()
583 dev_err_ratelimited(cdns->dev, "Msg NACKed for Slave %d\n", msg->dev_num); in cdns_fill_msg_resp()
588 dev_dbg_ratelimited(cdns->dev, "Msg ignored for Slave %d\n", msg->dev_num); in cdns_fill_msg_resp()
592 if (msg->flags == SDW_MSG_FLAG_READ) { in cdns_fill_msg_resp()
595 msg->buf[i + offset] = FIELD_GET(CDNS_MCP_RESP_RDATA, in cdns_fill_msg_resp()
596 cdns->response_buf[i]); in cdns_fill_msg_resp()
608 BUILD_BUG_ON(ARRAY_SIZE(cdns->response_buf) < CDNS_MCP_CMD_LEN + 2); in cdns_read_response()
612 if (num_resp > ARRAY_SIZE(cdns->response_buf)) { in cdns_read_response()
613 dev_warn(cdns->dev, "RX AVAIL %d too long\n", num_resp); in cdns_read_response()
614 num_resp = ARRAY_SIZE(cdns->response_buf); in cdns_read_response()
620 cdns->response_buf[i] = cdns_ip_readl(cdns, cmd_base); in cdns_read_response()
634 if (cdns->msg_count != count) { in _cdns_xfer_msg()
636 cdns->msg_count = count; in _cdns_xfer_msg()
640 addr = msg->addr + offset; in _cdns_xfer_msg()
643 data = FIELD_PREP(CDNS_MCP_CMD_DEV_ADDR, msg->dev_num); in _cdns_xfer_msg()
648 if (msg->flags == SDW_MSG_FLAG_WRITE) in _cdns_xfer_msg()
649 data |= msg->buf[i + offset]; in _cdns_xfer_msg()
651 data |= FIELD_PREP(CDNS_MCP_CMD_SSP_TAG, msg->ssp_sync); in _cdns_xfer_msg()
660 time = wait_for_completion_timeout(&cdns->tx_complete, in _cdns_xfer_msg()
663 dev_err(cdns->dev, "IO transfer timed out, cmd %d device %d addr %x len %d\n", in _cdns_xfer_msg()
664 cmd, msg->dev_num, msg->addr, msg->len); in _cdns_xfer_msg()
665 msg->len = 0; in _cdns_xfer_msg()
685 if (cdns->msg_count != CDNS_SCP_RX_FIFOLEVEL) { in cdns_program_scp_addr()
687 cdns->msg_count = CDNS_SCP_RX_FIFOLEVEL; in cdns_program_scp_addr()
690 data[0] = FIELD_PREP(CDNS_MCP_CMD_DEV_ADDR, msg->dev_num); in cdns_program_scp_addr()
697 data[0] |= msg->addr_page1; in cdns_program_scp_addr()
698 data[1] |= msg->addr_page2; in cdns_program_scp_addr()
705 time = wait_for_completion_timeout(&cdns->tx_complete, in cdns_program_scp_addr()
708 dev_err(cdns->dev, "SCP Msg trf timed out\n"); in cdns_program_scp_addr()
709 msg->len = 0; in cdns_program_scp_addr()
715 if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) { in cdns_program_scp_addr()
717 dev_err(cdns->dev, "Program SCP Ack not received\n"); in cdns_program_scp_addr()
718 if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { in cdns_program_scp_addr()
720 dev_err(cdns->dev, "Program SCP NACK received\n"); in cdns_program_scp_addr()
727 dev_err_ratelimited(cdns->dev, in cdns_program_scp_addr()
728 "SCP_addrpage NACKed for Slave %d\n", msg->dev_num); in cdns_program_scp_addr()
733 dev_dbg_ratelimited(cdns->dev, in cdns_program_scp_addr()
734 "SCP_addrpage ignored for Slave %d\n", msg->dev_num); in cdns_program_scp_addr()
745 if (msg->page) { in cdns_prep_msg()
748 msg->len = 0; in cdns_prep_msg()
753 switch (msg->flags) { in cdns_prep_msg()
763 dev_err(cdns->dev, "Invalid msg cmd: %d\n", msg->flags); in cdns_prep_msg()
764 return -EINVAL; in cdns_prep_msg()
780 for (i = 0; i < msg->len / CDNS_MCP_CMD_LEN; i++) { in cdns_xfer_msg()
787 if (!(msg->len % CDNS_MCP_CMD_LEN)) in cdns_xfer_msg()
791 msg->len % CDNS_MCP_CMD_LEN, false); in cdns_xfer_msg()
799 struct sdw_defer *defer = &bus->defer_msg; in cdns_xfer_msg_defer()
800 struct sdw_msg *msg = defer->msg; in cdns_xfer_msg_defer()
804 if (msg->len > 1) in cdns_xfer_msg_defer()
805 return -ENOTSUPP; in cdns_xfer_msg_defer()
811 return _cdns_xfer_msg(cdns, msg, cmd, 0, msg->len, true); in cdns_xfer_msg_defer()
897 mutex_lock(&cdns->status_update_lock); in cdns_update_slave_status()
898 ret = sdw_handle_slave_status(&cdns->bus, status); in cdns_update_slave_status()
899 mutex_unlock(&cdns->status_update_lock); in cdns_update_slave_status()
907 * sdw_cdns_irq() - Cadence interrupt handler
917 if (!cdns->link_up) in sdw_cdns_irq()
930 struct sdw_bus *bus = &cdns->bus; in sdw_cdns_irq()
931 struct sdw_defer *defer = &bus->defer_msg; in sdw_cdns_irq()
935 if (defer && defer->msg) { in sdw_cdns_irq()
936 cdns_fill_msg_resp(cdns, defer->msg, in sdw_cdns_irq()
937 defer->length, 0); in sdw_cdns_irq()
938 complete(&defer->complete); in sdw_cdns_irq()
940 complete(&cdns->tx_complete); in sdw_cdns_irq()
946 dev_err_ratelimited(cdns->dev, "Parity error\n"); in sdw_cdns_irq()
951 dev_err_ratelimited(cdns->dev, "Bus clash for control word\n"); in sdw_cdns_irq()
959 dev_err_ratelimited(cdns->dev, "Bus clash for data word\n"); in sdw_cdns_irq()
962 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL && in sdw_cdns_irq()
966 /* just log which ports report an error */ in sdw_cdns_irq()
968 dev_err_ratelimited(cdns->dev, "DP interrupt: PortIntStat %8x\n", in sdw_cdns_irq()
989 if (cdns->interrupt_enabled) in sdw_cdns_irq()
990 schedule_work(&cdns->work); in sdw_cdns_irq()
1012 dev_dbg(cdns->dev, "Peripheral %d status: %d\n", i, status[i]); in cdns_check_attached_status_dwork()
1016 mutex_lock(&cdns->status_update_lock); in cdns_check_attached_status_dwork()
1017 ret = sdw_handle_slave_status(&cdns->bus, status); in cdns_check_attached_status_dwork()
1018 mutex_unlock(&cdns->status_update_lock); in cdns_check_attached_status_dwork()
1020 dev_err(cdns->dev, "%s: sdw_handle_slave_status failed: %d\n", __func__, ret); in cdns_check_attached_status_dwork()
1024 * cdns_update_slave_status_work - update slave status in a work since we will need to handle
1049 * bits that re-assert. in cdns_update_slave_status_work()
1057 dev_dbg_ratelimited(cdns->dev, "Slave status change: 0x%llx\n", slave_intstat); in cdns_update_slave_status_work()
1070 * the deviceB never being detected - until a change of status in cdns_update_slave_status_work()
1073 * To avoid this race condition, re-check if any device0 needs in cdns_update_slave_status_work()
1075 * ALERTS since they are not allowed until a non-zero in cdns_update_slave_status_work()
1079 * #0 there could be status changes on other devices - these must in cdns_update_slave_status_work()
1089 dev_dbg_ratelimited(cdns->dev, in cdns_update_slave_status_work()
1095 dev_err_ratelimited(cdns->dev, in cdns_update_slave_status_work()
1107 /* paranoia check to make sure self-cleared bits are indeed cleared */
1123 dev_err(cdns->dev, "%s failed: IP_MCP_CONTROL_SW_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1129 dev_err(cdns->dev, "%s failed: MCP_CONTROL_CMD_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1131 dev_err(cdns->dev, "%s failed: MCP_CONTROL_SOFT_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1133 dev_err(cdns->dev, "%s failed: MCP_CONTROL_CLK_STOP_CLR is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1137 dev_err(cdns->dev, "%s failed: MCP_CONFIG_UPDATE_BIT is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1142 dev_err(cdns->dev, "%s failed: MCP_CONTROL_HW_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1146 dev_dbg(cdns->dev, "%s: MCP_CONTROL_HW_RST is not cleared at iteration %d\n", string, i); in sdw_cdns_check_self_clearing_bits()
1161 * sdw_cdns_exit_reset() - Program reset parameters and start bus operations
1179 * cdns_enable_slave_interrupts() - Enable SDW slave interrupts
1197 * sdw_cdns_enable_interrupt() - Enable SDW interrupts
1221 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL) in sdw_cdns_enable_interrupt()
1246 cdns->interrupt_enabled = state; in sdw_cdns_enable_interrupt()
1249 * Complete any on-going status updates before updating masks, in sdw_cdns_enable_interrupt()
1258 cancel_work_sync(&cdns->work); in sdw_cdns_enable_interrupt()
1278 pdi = devm_kcalloc(cdns->dev, num, sizeof(*pdi), GFP_KERNEL); in cdns_allocate_pdi()
1280 return -ENOMEM; in cdns_allocate_pdi()
1291 * sdw_cdns_pdi_init() - PDI initialization routine
1303 cdns->pcm.num_bd = config.pcm_bd; in sdw_cdns_pdi_init()
1304 cdns->pcm.num_in = config.pcm_in; in sdw_cdns_pdi_init()
1305 cdns->pcm.num_out = config.pcm_out; in sdw_cdns_pdi_init()
1308 stream = &cdns->pcm; in sdw_cdns_pdi_init()
1313 ret = cdns_allocate_pdi(cdns, &stream->bd, in sdw_cdns_pdi_init()
1314 stream->num_bd, offset); in sdw_cdns_pdi_init()
1318 offset += stream->num_bd; in sdw_cdns_pdi_init()
1320 ret = cdns_allocate_pdi(cdns, &stream->in, in sdw_cdns_pdi_init()
1321 stream->num_in, offset); in sdw_cdns_pdi_init()
1325 offset += stream->num_in; in sdw_cdns_pdi_init()
1327 ret = cdns_allocate_pdi(cdns, &stream->out, in sdw_cdns_pdi_init()
1328 stream->num_out, offset); in sdw_cdns_pdi_init()
1333 stream->num_pdi = stream->num_bd + stream->num_in + stream->num_out; in sdw_cdns_pdi_init()
1334 cdns->num_ports = stream->num_pdi; in sdw_cdns_pdi_init()
1357 struct sdw_bus *bus = &cdns->bus; in cdns_init_clock_ctrl()
1358 struct sdw_master_prop *prop = &bus->prop; in cdns_init_clock_ctrl()
1364 divider = (prop->mclk_freq / prop->max_clk_freq) - 1; in cdns_init_clock_ctrl()
1375 val = cdns_set_initial_frame_shape(prop->default_row, in cdns_init_clock_ctrl()
1376 prop->default_col); in cdns_init_clock_ctrl()
1380 ssp_interval = prop->default_frame_rate / SDW_CADENCE_GSYNC_HZ; in cdns_init_clock_ctrl()
1386 * sdw_cdns_init() - Cadence initialization
1398 cdns->msg_count = cdns_readl(cdns, CDNS_MCP_FIFOLEVEL); in sdw_cdns_init()
1429 if (cdns->bus.multi_link) in sdw_cdns_init()
1430 /* Set Multi-master mode to take gsync into account */ in sdw_cdns_init()
1446 struct sdw_master_prop *prop = &bus->prop; in cdns_bus_conf()
1451 if (!params->curr_dr_freq) { in cdns_bus_conf()
1452 dev_err(cdns->dev, "NULL curr_dr_freq\n"); in cdns_bus_conf()
1453 return -EINVAL; in cdns_bus_conf()
1456 divider = prop->mclk_freq * SDW_DOUBLE_RATE_FACTOR / in cdns_bus_conf()
1457 params->curr_dr_freq; in cdns_bus_conf()
1458 divider--; /* divider is 1/(N+1) */ in cdns_bus_conf()
1460 if (params->next_bank) in cdns_bus_conf()
1477 int target_num = p_params->num; in cdns_port_params()
1478 int source_num = p_params->num; in cdns_port_params()
1482 if (target_num == cdns->pdi_loopback_target && in cdns_port_params()
1483 cdns->pdi_loopback_source != -1) { in cdns_port_params()
1484 source_num = cdns->pdi_loopback_source; in cdns_port_params()
1500 u32p_replace_bits(&dpn_config, p_params->bps - 1, CDNS_DPN_CONFIG_WL); in cdns_port_params()
1501 u32p_replace_bits(&dpn_config, p_params->flow_mode, CDNS_DPN_CONFIG_PORT_FLOW); in cdns_port_params()
1502 u32p_replace_bits(&dpn_config, p_params->data_mode, CDNS_DPN_CONFIG_PORT_DAT); in cdns_port_params()
1527 int source_num = t_params->port_num; in cdns_transport_params()
1528 int target_num = t_params->port_num; in cdns_transport_params()
1531 if (target_num == cdns->pdi_loopback_target && in cdns_transport_params()
1532 cdns->pdi_loopback_source != -1) { in cdns_transport_params()
1533 source_num = cdns->pdi_loopback_source; in cdns_transport_params()
1539 * both PCM and PDM ports. in cdns_transport_params()
1567 u32p_replace_bits(&dpn_config, t_params->blk_grp_ctrl, CDNS_DPN_CONFIG_BGC); in cdns_transport_params()
1568 u32p_replace_bits(&dpn_config, t_params->blk_pkg_mode, CDNS_DPN_CONFIG_BPM); in cdns_transport_params()
1574 u32p_replace_bits(&dpn_offsetctrl, t_params->offset1, CDNS_DPN_OFFSET_CTRL_1); in cdns_transport_params()
1575 u32p_replace_bits(&dpn_offsetctrl, t_params->offset2, CDNS_DPN_OFFSET_CTRL_2); in cdns_transport_params()
1583 u32p_replace_bits(&dpn_hctrl, t_params->hstart, CDNS_DPN_HCTRL_HSTART); in cdns_transport_params()
1584 u32p_replace_bits(&dpn_hctrl, t_params->hstop, CDNS_DPN_HCTRL_HSTOP); in cdns_transport_params()
1585 u32p_replace_bits(&dpn_hctrl, t_params->lane_ctrl, CDNS_DPN_HCTRL_LCTRL); in cdns_transport_params()
1592 dpn_samplectrl = t_params->sample_interval - 1; in cdns_transport_params()
1607 dpn_chnen_off = CDNS_DPN_B1_CH_EN(enable_ch->port_num); in cdns_port_enable()
1609 dpn_chnen_off = CDNS_DPN_B0_CH_EN(enable_ch->port_num); in cdns_port_enable()
1611 ch_mask = enable_ch->ch_mask * enable_ch->enable; in cdns_port_enable()
1650 dev_dbg(cdns->dev, "Clock is already stopped\n"); in sdw_cdns_clock_stop()
1663 * master into a state in which it ignores wake-up trials in sdw_cdns_clock_stop()
1671 list_for_each_entry(slave, &cdns->bus.slaves, node) { in sdw_cdns_clock_stop()
1672 if (slave->status == SDW_SLAVE_ATTACHED || in sdw_cdns_clock_stop()
1673 slave->status == SDW_SLAVE_ALERT) { in sdw_cdns_clock_stop()
1682 dev_err(cdns->dev, "%s: config_update failed\n", __func__); in sdw_cdns_clock_stop()
1688 ret = sdw_bus_prep_clk_stop(&cdns->bus); in sdw_cdns_clock_stop()
1689 if (ret < 0 && ret != -ENODATA) { in sdw_cdns_clock_stop()
1690 dev_err(cdns->dev, "prepare clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1699 ret = sdw_bus_clk_stop(&cdns->bus); in sdw_cdns_clock_stop()
1700 if (ret < 0 && slave_present && ret != -ENODATA) { in sdw_cdns_clock_stop()
1701 dev_err(cdns->dev, "bus clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1709 dev_err(cdns->dev, "Clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1720 * may require a Severe Reset and re-enumeration after a wake.
1732 dev_err(cdns->dev, "Couldn't exit from clock stop\n"); in sdw_cdns_clock_restart()
1738 dev_err(cdns->dev, "clock stop exit failed %d\n", ret); in sdw_cdns_clock_restart()
1757 dev_err(cdns->dev, "%s: config_update failed\n", __func__); in sdw_cdns_clock_restart()
1761 ret = sdw_bus_exit_clk_stop(&cdns->bus); in sdw_cdns_clock_restart()
1763 dev_err(cdns->dev, "bus failed to exit clock stop %d\n", ret); in sdw_cdns_clock_restart()
1771 * sdw_cdns_probe() - Cadence probe routine
1776 init_completion(&cdns->tx_complete); in sdw_cdns_probe()
1777 cdns->bus.port_ops = &cdns_port_ops; in sdw_cdns_probe()
1779 mutex_init(&cdns->status_update_lock); in sdw_cdns_probe()
1781 INIT_WORK(&cdns->work, cdns_update_slave_status_work); in sdw_cdns_probe()
1782 INIT_DELAYED_WORK(&cdns->attach_dwork, cdns_check_attached_status_dwork); in sdw_cdns_probe()
1794 dai_runtime = cdns->dai_runtime_array[dai->id]; in cdns_set_sdw_stream()
1799 dev_err(dai->dev, in cdns_set_sdw_stream()
1801 dai->name); in cdns_set_sdw_stream()
1802 return -EINVAL; in cdns_set_sdw_stream()
1808 return -ENOMEM; in cdns_set_sdw_stream()
1810 dai_runtime->stream_type = SDW_STREAM_PCM; in cdns_set_sdw_stream()
1812 dai_runtime->bus = &cdns->bus; in cdns_set_sdw_stream()
1813 dai_runtime->link_id = cdns->instance; in cdns_set_sdw_stream()
1815 dai_runtime->stream = stream; in cdns_set_sdw_stream()
1816 dai_runtime->direction = direction; in cdns_set_sdw_stream()
1818 cdns->dai_runtime_array[dai->id] = dai_runtime; in cdns_set_sdw_stream()
1822 dev_err(dai->dev, in cdns_set_sdw_stream()
1824 dai->name); in cdns_set_sdw_stream()
1825 return -EINVAL; in cdns_set_sdw_stream()
1830 cdns->dai_runtime_array[dai->id] = NULL; in cdns_set_sdw_stream()
1837 * cdns_find_pdi() - Find a free PDI
1879 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL) in sdw_cdns_config_stream()
1882 offset = CDNS_PORTCTRL + pdi->num * CDNS_PORT_OFFSET; in sdw_cdns_config_stream()
1887 val = pdi->num; in sdw_cdns_config_stream()
1889 val |= FIELD_PREP(CDNS_PDI_CONFIG_CHANNEL, (1 << ch) - 1); in sdw_cdns_config_stream()
1890 cdns_writel(cdns, CDNS_PDI_CONFIG(pdi->num), val); in sdw_cdns_config_stream()
1895 * sdw_cdns_alloc_pdi() - Allocate a PDI
1910 pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in, in sdw_cdns_alloc_pdi()
1913 pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out, in sdw_cdns_alloc_pdi()
1916 /* check if we found a PDI, else find in bi-directional */ in sdw_cdns_alloc_pdi()
1918 pdi = cdns_find_pdi(cdns, 0, stream->num_bd, stream->bd, in sdw_cdns_alloc_pdi()
1922 pdi->l_ch_num = 0; in sdw_cdns_alloc_pdi()
1923 pdi->h_ch_num = ch - 1; in sdw_cdns_alloc_pdi()
1924 pdi->dir = dir; in sdw_cdns_alloc_pdi()
1925 pdi->ch_count = ch; in sdw_cdns_alloc_pdi()