Lines Matching refs:cdns

198 static inline u32 cdns_readl(struct sdw_cdns *cdns, int offset)  in cdns_readl()  argument
200 return readl(cdns->registers + offset); in cdns_readl()
203 static inline void cdns_writel(struct sdw_cdns *cdns, int offset, u32 value) in cdns_writel() argument
205 writel(value, cdns->registers + offset); in cdns_writel()
208 static inline void cdns_updatel(struct sdw_cdns *cdns, in cdns_updatel() argument
213 tmp = cdns_readl(cdns, offset); in cdns_updatel()
215 cdns_writel(cdns, offset, tmp); in cdns_updatel()
218 static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value) in cdns_set_wait() argument
225 reg_read = readl(cdns->registers + offset); in cdns_set_wait()
236 static int cdns_clear_bit(struct sdw_cdns *cdns, int offset, u32 value) in cdns_clear_bit() argument
238 writel(value, cdns->registers + offset); in cdns_clear_bit()
241 return cdns_set_wait(cdns, offset, value, 0); in cdns_clear_bit()
248 static int cdns_config_update(struct sdw_cdns *cdns) in cdns_config_update() argument
252 if (sdw_cdns_is_clock_stop(cdns)) { in cdns_config_update()
253 dev_err(cdns->dev, "Cannot program MCP_CONFIG_UPDATE in ClockStopMode\n"); in cdns_config_update()
257 ret = cdns_clear_bit(cdns, CDNS_MCP_CONFIG_UPDATE, in cdns_config_update()
260 dev_err(cdns->dev, "Config update timedout\n"); in cdns_config_update()
272 static ssize_t cdns_sprintf(struct sdw_cdns *cdns, in cdns_sprintf() argument
276 "%4x\t%8x\n", reg, cdns_readl(cdns, reg)); in cdns_sprintf()
281 struct sdw_cdns *cdns = s->private; in cdns_reg_show() local
295 ret += cdns_sprintf(cdns, buf, ret, i); in cdns_reg_show()
301 ret += cdns_sprintf(cdns, buf, ret, i); in cdns_reg_show()
305 ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_SSP_CTRL0); in cdns_reg_show()
306 ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_SSP_CTRL1); in cdns_reg_show()
307 ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_CLK_CTRL0); in cdns_reg_show()
308 ret += cdns_sprintf(cdns, buf, ret, CDNS_MCP_CLK_CTRL1); in cdns_reg_show()
313 num_ports = cdns->num_ports; in cdns_reg_show()
320 ret += cdns_sprintf(cdns, buf, ret, j); in cdns_reg_show()
331 ret += cdns_sprintf(cdns, buf, ret, j); in cdns_reg_show()
337 ret += cdns_sprintf(cdns, buf, ret, in cdns_reg_show()
345 ret += cdns_sprintf(cdns, buf, ret, CDNS_PDI_CONFIG(i)); in cdns_reg_show()
356 struct sdw_cdns *cdns = data; in cdns_hw_reset() local
365 ret = sdw_cdns_exit_reset(cdns); in cdns_hw_reset()
367 dev_dbg(cdns->dev, "link hw_reset done: %d\n", ret); in cdns_hw_reset()
376 struct sdw_cdns *cdns = data; in cdns_parity_error_injection() local
383 bus = &cdns->bus; in cdns_parity_error_injection()
391 dev_err_ratelimited(cdns->dev, in cdns_parity_error_injection()
410 cdns_updatel(cdns, CDNS_MCP_CMDCTRL, in cdns_parity_error_injection()
415 cdns_updatel(cdns, CDNS_MCP_CONFIG_UPDATE, in cdns_parity_error_injection()
420 ret = sdw_bread_no_pm_unlocked(&cdns->bus, 0xf, SDW_SCP_DEVID_0); in cdns_parity_error_injection()
421 dev_info(cdns->dev, "parity error injection, read: %d\n", ret); in cdns_parity_error_injection()
424 cdns_updatel(cdns, CDNS_MCP_CMDCTRL, in cdns_parity_error_injection()
429 cdns_updatel(cdns, CDNS_MCP_CONFIG_UPDATE, in cdns_parity_error_injection()
454 struct sdw_cdns *cdns = data; in cdns_set_pdi_loopback_source() local
455 unsigned int pdi_out_num = cdns->pcm.num_bd + cdns->pcm.num_out; in cdns_set_pdi_loopback_source()
463 cdns->pdi_loopback_source = value; in cdns_set_pdi_loopback_source()
471 struct sdw_cdns *cdns = data; in cdns_set_pdi_loopback_target() local
472 unsigned int pdi_in_num = cdns->pcm.num_bd + cdns->pcm.num_in; in cdns_set_pdi_loopback_target()
480 cdns->pdi_loopback_target = value; in cdns_set_pdi_loopback_target()
491 void sdw_cdns_debugfs_init(struct sdw_cdns *cdns, struct dentry *root) in sdw_cdns_debugfs_init() argument
493 debugfs_create_file("cdns-registers", 0400, root, cdns, &cdns_reg_fops); in sdw_cdns_debugfs_init()
495 debugfs_create_file("cdns-hw-reset", 0200, root, cdns, in sdw_cdns_debugfs_init()
498 debugfs_create_file("cdns-parity-error-injection", 0200, root, cdns, in sdw_cdns_debugfs_init()
501 cdns->pdi_loopback_source = -1; in sdw_cdns_debugfs_init()
502 cdns->pdi_loopback_target = -1; in sdw_cdns_debugfs_init()
504 debugfs_create_file("cdns-pdi-loopback-source", 0200, root, cdns, in sdw_cdns_debugfs_init()
507 debugfs_create_file("cdns-pdi-loopback-target", 0200, root, cdns, in sdw_cdns_debugfs_init()
519 cdns_fill_msg_resp(struct sdw_cdns *cdns, in cdns_fill_msg_resp() argument
527 if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) { in cdns_fill_msg_resp()
529 dev_vdbg(cdns->dev, "Msg Ack not received, cmd %d\n", i); in cdns_fill_msg_resp()
531 if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { in cdns_fill_msg_resp()
533 dev_err_ratelimited(cdns->dev, "Msg NACK received, cmd %d\n", i); in cdns_fill_msg_resp()
538 dev_err_ratelimited(cdns->dev, "Msg NACKed for Slave %d\n", msg->dev_num); in cdns_fill_msg_resp()
543 dev_dbg_ratelimited(cdns->dev, "Msg ignored for Slave %d\n", msg->dev_num); in cdns_fill_msg_resp()
551 cdns->response_buf[i]); in cdns_fill_msg_resp()
558 _cdns_xfer_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int cmd, in _cdns_xfer_msg() argument
566 if (cdns->msg_count != count) { in _cdns_xfer_msg()
567 cdns_writel(cdns, CDNS_MCP_FIFOLEVEL, count); in _cdns_xfer_msg()
568 cdns->msg_count = count; in _cdns_xfer_msg()
584 cdns_writel(cdns, base, data); in _cdns_xfer_msg()
592 time = wait_for_completion_timeout(&cdns->tx_complete, in _cdns_xfer_msg()
595 dev_err(cdns->dev, "IO transfer timed out, cmd %d device %d addr %x len %d\n", in _cdns_xfer_msg()
601 return cdns_fill_msg_resp(cdns, msg, count, offset); in _cdns_xfer_msg()
605 cdns_program_scp_addr(struct sdw_cdns *cdns, struct sdw_msg *msg) in cdns_program_scp_addr() argument
613 if (cdns->msg_count != CDNS_SCP_RX_FIFOLEVEL) { in cdns_program_scp_addr()
614 cdns_writel(cdns, CDNS_MCP_FIFOLEVEL, CDNS_SCP_RX_FIFOLEVEL); in cdns_program_scp_addr()
615 cdns->msg_count = CDNS_SCP_RX_FIFOLEVEL; in cdns_program_scp_addr()
629 cdns_writel(cdns, base, data[0]); in cdns_program_scp_addr()
631 cdns_writel(cdns, base, data[1]); in cdns_program_scp_addr()
633 time = wait_for_completion_timeout(&cdns->tx_complete, in cdns_program_scp_addr()
636 dev_err(cdns->dev, "SCP Msg trf timed out\n"); in cdns_program_scp_addr()
643 if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) { in cdns_program_scp_addr()
645 dev_err(cdns->dev, "Program SCP Ack not received\n"); in cdns_program_scp_addr()
646 if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { in cdns_program_scp_addr()
648 dev_err(cdns->dev, "Program SCP NACK received\n"); in cdns_program_scp_addr()
655 dev_err_ratelimited(cdns->dev, in cdns_program_scp_addr()
661 dev_dbg_ratelimited(cdns->dev, in cdns_program_scp_addr()
669 static int cdns_prep_msg(struct sdw_cdns *cdns, struct sdw_msg *msg, int *cmd) in cdns_prep_msg() argument
674 ret = cdns_program_scp_addr(cdns, msg); in cdns_prep_msg()
691 dev_err(cdns->dev, "Invalid msg cmd: %d\n", msg->flags); in cdns_prep_msg()
701 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_xfer_msg() local
704 ret = cdns_prep_msg(cdns, msg, &cmd); in cdns_xfer_msg()
709 ret = _cdns_xfer_msg(cdns, msg, cmd, i * CDNS_MCP_CMD_LEN, in cdns_xfer_msg()
718 return _cdns_xfer_msg(cdns, msg, cmd, i * CDNS_MCP_CMD_LEN, in cdns_xfer_msg()
727 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_xfer_msg_defer() local
734 ret = cdns_prep_msg(cdns, msg, &cmd); in cdns_xfer_msg_defer()
738 cdns->defer = defer; in cdns_xfer_msg_defer()
739 cdns->defer->length = msg->len; in cdns_xfer_msg_defer()
741 return _cdns_xfer_msg(cdns, msg, cmd, 0, msg->len, true); in cdns_xfer_msg_defer()
748 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_reset_page_addr() local
755 return cdns_program_scp_addr(cdns, &msg); in cdns_reset_page_addr()
761 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_read_ping_status() local
763 return cdns_readl(cdns, CDNS_MCP_SLAVE_STAT); in cdns_read_ping_status()
771 static void cdns_read_response(struct sdw_cdns *cdns) in cdns_read_response() argument
776 num_resp = cdns_readl(cdns, CDNS_MCP_FIFOSTAT); in cdns_read_response()
782 cdns->response_buf[i] = cdns_readl(cdns, cmd_base); in cdns_read_response()
787 static int cdns_update_slave_status(struct sdw_cdns *cdns, in cdns_update_slave_status() argument
833 val = cdns_readl(cdns, CDNS_MCP_SLAVE_STAT); in cdns_update_slave_status()
855 return sdw_handle_slave_status(&cdns->bus, status); in cdns_update_slave_status()
867 struct sdw_cdns *cdns = dev_id; in sdw_cdns_irq() local
871 if (!cdns->link_up) in sdw_cdns_irq()
874 int_status = cdns_readl(cdns, CDNS_MCP_INTSTAT); in sdw_cdns_irq()
884 cdns_read_response(cdns); in sdw_cdns_irq()
886 if (cdns->defer) { in sdw_cdns_irq()
887 cdns_fill_msg_resp(cdns, cdns->defer->msg, in sdw_cdns_irq()
888 cdns->defer->length, 0); in sdw_cdns_irq()
889 complete(&cdns->defer->complete); in sdw_cdns_irq()
890 cdns->defer = NULL; in sdw_cdns_irq()
892 complete(&cdns->tx_complete); in sdw_cdns_irq()
898 dev_err_ratelimited(cdns->dev, "Parity error\n"); in sdw_cdns_irq()
903 dev_err_ratelimited(cdns->dev, "Bus clash for control word\n"); in sdw_cdns_irq()
911 dev_err_ratelimited(cdns->dev, "Bus clash for data word\n"); in sdw_cdns_irq()
914 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL && in sdw_cdns_irq()
919 port_intstat = cdns_readl(cdns, CDNS_MCP_PORT_INTSTAT); in sdw_cdns_irq()
920 dev_err_ratelimited(cdns->dev, "DP interrupt: PortIntStat %8x\n", in sdw_cdns_irq()
924 cdns_writel(cdns, CDNS_MCP_PORT_INTSTAT, port_intstat); in sdw_cdns_irq()
929 cdns_updatel(cdns, CDNS_MCP_INTMASK, in sdw_cdns_irq()
941 if (cdns->interrupt_enabled) in sdw_cdns_irq()
942 schedule_work(&cdns->work); in sdw_cdns_irq()
945 cdns_writel(cdns, CDNS_MCP_INTSTAT, int_status); in sdw_cdns_irq()
958 struct sdw_cdns *cdns = in cdns_update_slave_status_work() local
969 cdns_writel(cdns, CDNS_MCP_INTSTAT, CDNS_MCP_INT_SLAVE_MASK); in cdns_update_slave_status_work()
971 slave0 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0); in cdns_update_slave_status_work()
972 slave1 = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1); in cdns_update_slave_status_work()
978 cdns_writel(cdns, CDNS_MCP_SLAVE_INTSTAT0, slave0); in cdns_update_slave_status_work()
979 cdns_writel(cdns, CDNS_MCP_SLAVE_INTSTAT1, slave1); in cdns_update_slave_status_work()
984 dev_dbg_ratelimited(cdns->dev, "Slave status change: 0x%llx\n", slave_intstat); in cdns_update_slave_status_work()
987 cdns_update_slave_status(cdns, slave_intstat); in cdns_update_slave_status_work()
1011 device0_status = cdns_readl(cdns, CDNS_MCP_SLAVE_STAT); in cdns_update_slave_status_work()
1016 dev_dbg_ratelimited(cdns->dev, in cdns_update_slave_status_work()
1022 dev_err_ratelimited(cdns->dev, in cdns_update_slave_status_work()
1029 cdns_updatel(cdns, CDNS_MCP_INTMASK, in cdns_update_slave_status_work()
1035 void sdw_cdns_check_self_clearing_bits(struct sdw_cdns *cdns, const char *string, in sdw_cdns_check_self_clearing_bits() argument
1045 mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL); in sdw_cdns_check_self_clearing_bits()
1049 dev_err(cdns->dev, "%s failed: MCP_CONTROL_CMD_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1051 dev_err(cdns->dev, "%s failed: MCP_CONTROL_SOFT_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1053 dev_err(cdns->dev, "%s failed: MCP_CONTROL_SW_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1055 dev_err(cdns->dev, "%s failed: MCP_CONTROL_CLK_STOP_CLR is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1056 mcp_config_update = cdns_readl(cdns, CDNS_MCP_CONFIG_UPDATE); in sdw_cdns_check_self_clearing_bits()
1058 dev_err(cdns->dev, "%s failed: MCP_CONFIG_UPDATE_BIT is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1063 dev_err(cdns->dev, "%s failed: MCP_CONTROL_HW_RST is not cleared\n", string); in sdw_cdns_check_self_clearing_bits()
1067 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()
1071 mcp_control = cdns_readl(cdns, CDNS_MCP_CONTROL); in sdw_cdns_check_self_clearing_bits()
1085 int sdw_cdns_exit_reset(struct sdw_cdns *cdns) in sdw_cdns_exit_reset() argument
1090 cdns_updatel(cdns, CDNS_MCP_CONTROL, in sdw_cdns_exit_reset()
1095 cdns_updatel(cdns, CDNS_MCP_CONFIG_UPDATE, in sdw_cdns_exit_reset()
1110 static void cdns_enable_slave_interrupts(struct sdw_cdns *cdns, bool state) in cdns_enable_slave_interrupts() argument
1114 mask = cdns_readl(cdns, CDNS_MCP_INTMASK); in cdns_enable_slave_interrupts()
1120 cdns_writel(cdns, CDNS_MCP_INTMASK, mask); in cdns_enable_slave_interrupts()
1128 int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns, bool state) in sdw_cdns_enable_interrupt() argument
1148 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL) in sdw_cdns_enable_interrupt()
1168 slave_state = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT0); in sdw_cdns_enable_interrupt()
1169 cdns_writel(cdns, CDNS_MCP_SLAVE_INTSTAT0, slave_state); in sdw_cdns_enable_interrupt()
1170 slave_state = cdns_readl(cdns, CDNS_MCP_SLAVE_INTSTAT1); in sdw_cdns_enable_interrupt()
1171 cdns_writel(cdns, CDNS_MCP_SLAVE_INTSTAT1, slave_state); in sdw_cdns_enable_interrupt()
1173 cdns->interrupt_enabled = state; in sdw_cdns_enable_interrupt()
1185 cancel_work_sync(&cdns->work); in sdw_cdns_enable_interrupt()
1187 cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK0, slave_intmask0); in sdw_cdns_enable_interrupt()
1188 cdns_writel(cdns, CDNS_MCP_SLAVE_INTMASK1, slave_intmask1); in sdw_cdns_enable_interrupt()
1189 cdns_writel(cdns, CDNS_MCP_INTMASK, mask); in sdw_cdns_enable_interrupt()
1195 static int cdns_allocate_pdi(struct sdw_cdns *cdns, in cdns_allocate_pdi() argument
1205 pdi = devm_kcalloc(cdns->dev, num, sizeof(*pdi), GFP_KERNEL); in cdns_allocate_pdi()
1223 int sdw_cdns_pdi_init(struct sdw_cdns *cdns, in sdw_cdns_pdi_init() argument
1230 cdns->pcm.num_bd = config.pcm_bd; in sdw_cdns_pdi_init()
1231 cdns->pcm.num_in = config.pcm_in; in sdw_cdns_pdi_init()
1232 cdns->pcm.num_out = config.pcm_out; in sdw_cdns_pdi_init()
1235 stream = &cdns->pcm; in sdw_cdns_pdi_init()
1240 ret = cdns_allocate_pdi(cdns, &stream->bd, in sdw_cdns_pdi_init()
1247 ret = cdns_allocate_pdi(cdns, &stream->in, in sdw_cdns_pdi_init()
1254 ret = cdns_allocate_pdi(cdns, &stream->out, in sdw_cdns_pdi_init()
1261 cdns->num_ports = stream->num_pdi; in sdw_cdns_pdi_init()
1282 static void cdns_init_clock_ctrl(struct sdw_cdns *cdns) in cdns_init_clock_ctrl() argument
1284 struct sdw_bus *bus = &cdns->bus; in cdns_init_clock_ctrl()
1293 cdns_updatel(cdns, CDNS_MCP_CLK_CTRL0, in cdns_init_clock_ctrl()
1295 cdns_updatel(cdns, CDNS_MCP_CLK_CTRL1, in cdns_init_clock_ctrl()
1304 cdns_writel(cdns, CDNS_MCP_FRAME_SHAPE_INIT, val); in cdns_init_clock_ctrl()
1308 cdns_writel(cdns, CDNS_MCP_SSP_CTRL0, ssp_interval); in cdns_init_clock_ctrl()
1309 cdns_writel(cdns, CDNS_MCP_SSP_CTRL1, ssp_interval); in cdns_init_clock_ctrl()
1316 int sdw_cdns_init(struct sdw_cdns *cdns) in sdw_cdns_init() argument
1320 cdns_init_clock_ctrl(cdns); in sdw_cdns_init()
1322 sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0); in sdw_cdns_init()
1325 cdns->msg_count = cdns_readl(cdns, CDNS_MCP_FIFOLEVEL); in sdw_cdns_init()
1328 cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_CMD_RST, in sdw_cdns_init()
1332 cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_CMD_ACCEPT, in sdw_cdns_init()
1336 val = cdns_readl(cdns, CDNS_MCP_CONFIG); in sdw_cdns_init()
1351 if (cdns->bus.multi_link) in sdw_cdns_init()
1359 cdns_writel(cdns, CDNS_MCP_CONFIG, val); in sdw_cdns_init()
1369 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_bus_conf() local
1374 dev_err(cdns->dev, "NULL curr_dr_freq\n"); in cdns_bus_conf()
1387 cdns_updatel(cdns, mcp_clkctrl_off, CDNS_MCP_CLK_MCLKD_MASK, divider); in cdns_bus_conf()
1396 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_port_params() local
1404 if (target_num == cdns->pdi_loopback_target && in cdns_port_params()
1405 cdns->pdi_loopback_source != -1) { in cdns_port_params()
1406 source_num = cdns->pdi_loopback_source; in cdns_port_params()
1418 dpn_config = cdns_readl(cdns, dpn_config_off_source); in cdns_port_params()
1427 cdns_writel(cdns, dpn_config_off_target, dpn_config); in cdns_port_params()
1436 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_transport_params() local
1453 if (target_num == cdns->pdi_loopback_target && in cdns_transport_params()
1454 cdns->pdi_loopback_source != -1) { in cdns_transport_params()
1455 source_num = cdns->pdi_loopback_source; in cdns_transport_params()
1487 dpn_config = cdns_readl(cdns, dpn_config_off_source); in cdns_transport_params()
1492 cdns_writel(cdns, dpn_config_off_target, dpn_config); in cdns_transport_params()
1499 dpn_offsetctrl = cdns_readl(cdns, dpn_offsetctrl_off_source); in cdns_transport_params()
1501 cdns_writel(cdns, dpn_offsetctrl_off_target, dpn_offsetctrl); in cdns_transport_params()
1509 dpn_hctrl = cdns_readl(cdns, dpn_hctrl_off_source); in cdns_transport_params()
1511 cdns_writel(cdns, dpn_hctrl_off_target, dpn_hctrl); in cdns_transport_params()
1516 dpn_samplectrl = cdns_readl(cdns, dpn_samplectrl_off_source); in cdns_transport_params()
1517 cdns_writel(cdns, dpn_samplectrl_off_target, dpn_samplectrl); in cdns_transport_params()
1525 struct sdw_cdns *cdns = bus_to_cdns(bus); in cdns_port_enable() local
1534 cdns_writel(cdns, dpn_chnen_off, ch_mask); in cdns_port_enable()
1550 bool sdw_cdns_is_clock_stop(struct sdw_cdns *cdns) in sdw_cdns_is_clock_stop() argument
1552 return !!(cdns_readl(cdns, CDNS_MCP_STAT) & CDNS_MCP_STAT_CLK_STOP); in sdw_cdns_is_clock_stop()
1562 int sdw_cdns_clock_stop(struct sdw_cdns *cdns, bool block_wake) in sdw_cdns_clock_stop() argument
1568 sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0); in sdw_cdns_clock_stop()
1571 if (sdw_cdns_is_clock_stop(cdns)) { in sdw_cdns_clock_stop()
1572 dev_dbg(cdns->dev, "Clock is already stopped\n"); in sdw_cdns_clock_stop()
1581 cdns_enable_slave_interrupts(cdns, false); in sdw_cdns_clock_stop()
1589 cdns_updatel(cdns, CDNS_MCP_CONTROL, in sdw_cdns_clock_stop()
1593 list_for_each_entry(slave, &cdns->bus.slaves, node) { in sdw_cdns_clock_stop()
1602 ret = cdns_config_update(cdns); in sdw_cdns_clock_stop()
1604 dev_err(cdns->dev, "%s: config_update failed\n", __func__); in sdw_cdns_clock_stop()
1610 ret = sdw_bus_prep_clk_stop(&cdns->bus); in sdw_cdns_clock_stop()
1612 dev_err(cdns->dev, "prepare clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1621 ret = sdw_bus_clk_stop(&cdns->bus); in sdw_cdns_clock_stop()
1623 dev_err(cdns->dev, "bus clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1627 ret = cdns_set_wait(cdns, CDNS_MCP_STAT, in sdw_cdns_clock_stop()
1631 dev_err(cdns->dev, "Clock stop failed %d\n", ret); in sdw_cdns_clock_stop()
1644 int sdw_cdns_clock_restart(struct sdw_cdns *cdns, bool bus_reset) in sdw_cdns_clock_restart() argument
1649 cdns_enable_slave_interrupts(cdns, true); in sdw_cdns_clock_restart()
1651 ret = cdns_clear_bit(cdns, CDNS_MCP_CONTROL, in sdw_cdns_clock_restart()
1654 dev_err(cdns->dev, "Couldn't exit from clock stop\n"); in sdw_cdns_clock_restart()
1658 ret = cdns_set_wait(cdns, CDNS_MCP_STAT, CDNS_MCP_STAT_CLK_STOP, 0); in sdw_cdns_clock_restart()
1660 dev_err(cdns->dev, "clock stop exit failed %d\n", ret); in sdw_cdns_clock_restart()
1664 cdns_updatel(cdns, CDNS_MCP_CONTROL, in sdw_cdns_clock_restart()
1667 cdns_updatel(cdns, CDNS_MCP_CONTROL, CDNS_MCP_CONTROL_CMD_ACCEPT, in sdw_cdns_clock_restart()
1673 cdns_updatel(cdns, CDNS_MCP_CONFIG, in sdw_cdns_clock_restart()
1677 ret = cdns_config_update(cdns); in sdw_cdns_clock_restart()
1679 dev_err(cdns->dev, "%s: config_update failed\n", __func__); in sdw_cdns_clock_restart()
1683 ret = sdw_bus_exit_clk_stop(&cdns->bus); in sdw_cdns_clock_restart()
1685 dev_err(cdns->dev, "bus failed to exit clock stop %d\n", ret); in sdw_cdns_clock_restart()
1696 int sdw_cdns_probe(struct sdw_cdns *cdns) in sdw_cdns_probe() argument
1698 init_completion(&cdns->tx_complete); in sdw_cdns_probe()
1699 cdns->bus.port_ops = &cdns_port_ops; in sdw_cdns_probe()
1701 INIT_WORK(&cdns->work, cdns_update_slave_status_work); in sdw_cdns_probe()
1709 struct sdw_cdns *cdns = snd_soc_dai_get_drvdata(dai); in cdns_set_sdw_stream() local
1733 dma->bus = &cdns->bus; in cdns_set_sdw_stream()
1734 dma->link_id = cdns->instance; in cdns_set_sdw_stream()
1768 static struct sdw_cdns_pdi *cdns_find_pdi(struct sdw_cdns *cdns, in cdns_find_pdi() argument
1791 void sdw_cdns_config_stream(struct sdw_cdns *cdns, in sdw_cdns_config_stream() argument
1799 if (cdns->bus.params.m_data_mode != SDW_PORT_DATA_MODE_NORMAL) in sdw_cdns_config_stream()
1803 cdns_updatel(cdns, offset, in sdw_cdns_config_stream()
1810 cdns_writel(cdns, CDNS_PDI_CONFIG(pdi->num), val); in sdw_cdns_config_stream()
1823 struct sdw_cdns_pdi *sdw_cdns_alloc_pdi(struct sdw_cdns *cdns, in sdw_cdns_alloc_pdi() argument
1830 pdi = cdns_find_pdi(cdns, 0, stream->num_in, stream->in, in sdw_cdns_alloc_pdi()
1833 pdi = cdns_find_pdi(cdns, 0, stream->num_out, stream->out, in sdw_cdns_alloc_pdi()
1838 pdi = cdns_find_pdi(cdns, 2, stream->num_bd, stream->bd, in sdw_cdns_alloc_pdi()