Lines Matching refs:amd_manager
30 static int amd_init_sdw_manager(struct amd_sdw_manager *amd_manager) in amd_init_sdw_manager() argument
35 writel(AMD_SDW_ENABLE, amd_manager->mmio + ACP_SW_EN); in amd_init_sdw_manager()
36 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_EN_STATUS, val, val, ACP_DELAY_US, in amd_init_sdw_manager()
42 writel(AMD_SDW_BUS_RESET_REQ, amd_manager->mmio + ACP_SW_BUS_RESET_CTRL); in amd_init_sdw_manager()
43 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_BUS_RESET_CTRL, val, in amd_init_sdw_manager()
48 writel(AMD_SDW_BUS_RESET_CLEAR_REQ, amd_manager->mmio + ACP_SW_BUS_RESET_CTRL); in amd_init_sdw_manager()
49 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_BUS_RESET_CTRL, val, !val, in amd_init_sdw_manager()
52 dev_err(amd_manager->dev, "Failed to reset SoundWire manager instance%d\n", in amd_init_sdw_manager()
53 amd_manager->instance); in amd_init_sdw_manager()
57 writel(AMD_SDW_DISABLE, amd_manager->mmio + ACP_SW_EN); in amd_init_sdw_manager()
58 return readl_poll_timeout(amd_manager->mmio + ACP_SW_EN_STATUS, val, !val, ACP_DELAY_US, in amd_init_sdw_manager()
62 static int amd_enable_sdw_manager(struct amd_sdw_manager *amd_manager) in amd_enable_sdw_manager() argument
66 writel(AMD_SDW_ENABLE, amd_manager->mmio + ACP_SW_EN); in amd_enable_sdw_manager()
67 return readl_poll_timeout(amd_manager->mmio + ACP_SW_EN_STATUS, val, val, ACP_DELAY_US, in amd_enable_sdw_manager()
71 static int amd_disable_sdw_manager(struct amd_sdw_manager *amd_manager) in amd_disable_sdw_manager() argument
75 writel(AMD_SDW_DISABLE, amd_manager->mmio + ACP_SW_EN); in amd_disable_sdw_manager()
81 val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_disable_sdw_manager()
84 return readl_poll_timeout(amd_manager->mmio + ACP_SW_EN_STATUS, val, !val, ACP_DELAY_US, in amd_disable_sdw_manager()
88 static void amd_enable_sdw_interrupts(struct amd_sdw_manager *amd_manager) in amd_enable_sdw_interrupts() argument
92 mutex_lock(amd_manager->acp_sdw_lock); in amd_enable_sdw_interrupts()
93 val = sdw_manager_reg_mask_array[amd_manager->instance]; in amd_enable_sdw_interrupts()
94 amd_updatel(amd_manager->acp_mmio, ACP_EXTERNAL_INTR_CNTL(amd_manager->instance), val, val); in amd_enable_sdw_interrupts()
95 mutex_unlock(amd_manager->acp_sdw_lock); in amd_enable_sdw_interrupts()
97 writel(AMD_SDW_IRQ_MASK_0TO7, amd_manager->mmio + in amd_enable_sdw_interrupts()
99 writel(AMD_SDW_IRQ_MASK_8TO11, amd_manager->mmio + in amd_enable_sdw_interrupts()
101 writel(AMD_SDW_IRQ_ERROR_MASK, amd_manager->mmio + ACP_SW_ERROR_INTR_MASK); in amd_enable_sdw_interrupts()
104 static void amd_disable_sdw_interrupts(struct amd_sdw_manager *amd_manager) in amd_disable_sdw_interrupts() argument
108 mutex_lock(amd_manager->acp_sdw_lock); in amd_disable_sdw_interrupts()
109 irq_mask = sdw_manager_reg_mask_array[amd_manager->instance]; in amd_disable_sdw_interrupts()
110 amd_updatel(amd_manager->acp_mmio, ACP_EXTERNAL_INTR_CNTL(amd_manager->instance), in amd_disable_sdw_interrupts()
112 mutex_unlock(amd_manager->acp_sdw_lock); in amd_disable_sdw_interrupts()
114 writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_0TO7); in amd_disable_sdw_interrupts()
115 writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_8TO11); in amd_disable_sdw_interrupts()
116 writel(0x00, amd_manager->mmio + ACP_SW_ERROR_INTR_MASK); in amd_disable_sdw_interrupts()
119 static int amd_deinit_sdw_manager(struct amd_sdw_manager *amd_manager) in amd_deinit_sdw_manager() argument
121 amd_disable_sdw_interrupts(amd_manager); in amd_deinit_sdw_manager()
122 return amd_disable_sdw_manager(amd_manager); in amd_deinit_sdw_manager()
125 static void amd_sdw_set_frameshape(struct amd_sdw_manager *amd_manager) in amd_sdw_set_frameshape() argument
129 frame_size = (amd_manager->rows_index << 3) | amd_manager->cols_index; in amd_sdw_set_frameshape()
130 writel(frame_size, amd_manager->mmio + ACP_SW_FRAMESIZE); in amd_sdw_set_frameshape()
133 static void amd_sdw_wake_enable(struct amd_sdw_manager *amd_manager, bool enable) in amd_sdw_wake_enable() argument
137 wake_ctrl = readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_8TO11); in amd_sdw_wake_enable()
143 writel(wake_ctrl, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_8TO11); in amd_sdw_wake_enable()
172 static u64 amd_sdw_send_cmd_get_resp(struct amd_sdw_manager *amd_manager, u32 lower_data, in amd_sdw_send_cmd_get_resp() argument
180 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_IMM_CMD_STS, sts, in amd_sdw_send_cmd_get_resp()
183 dev_err(amd_manager->dev, "SDW%x previous cmd status clear failed\n", in amd_sdw_send_cmd_get_resp()
184 amd_manager->instance); in amd_sdw_send_cmd_get_resp()
189 dev_err(amd_manager->dev, "SDW%x manager is in bad state\n", amd_manager->instance); in amd_sdw_send_cmd_get_resp()
190 writel(0x00, amd_manager->mmio + ACP_SW_IMM_CMD_STS); in amd_sdw_send_cmd_get_resp()
192 writel(upper_data, amd_manager->mmio + ACP_SW_IMM_CMD_UPPER_WORD); in amd_sdw_send_cmd_get_resp()
193 writel(lower_data, amd_manager->mmio + ACP_SW_IMM_CMD_LOWER_QWORD); in amd_sdw_send_cmd_get_resp()
195 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_IMM_CMD_STS, sts, in amd_sdw_send_cmd_get_resp()
198 dev_err(amd_manager->dev, "SDW%x cmd response timeout occurred\n", in amd_sdw_send_cmd_get_resp()
199 amd_manager->instance); in amd_sdw_send_cmd_get_resp()
202 upper_resp = readl(amd_manager->mmio + ACP_SW_IMM_RESP_UPPER_WORD); in amd_sdw_send_cmd_get_resp()
203 lower_resp = readl(amd_manager->mmio + ACP_SW_IMM_RESP_LOWER_QWORD); in amd_sdw_send_cmd_get_resp()
205 writel(AMD_SDW_IMM_RES_VALID, amd_manager->mmio + ACP_SW_IMM_CMD_STS); in amd_sdw_send_cmd_get_resp()
206 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_IMM_CMD_STS, sts, in amd_sdw_send_cmd_get_resp()
209 dev_err(amd_manager->dev, "SDW%x cmd status retry failed\n", in amd_sdw_send_cmd_get_resp()
210 amd_manager->instance); in amd_sdw_send_cmd_get_resp()
219 amd_program_scp_addr(struct amd_sdw_manager *amd_manager, struct sdw_msg *msg) in amd_program_scp_addr() argument
231 response_buf[0] = amd_sdw_send_cmd_get_resp(amd_manager, lower_data, upper_data); in amd_program_scp_addr()
235 response_buf[1] = amd_sdw_send_cmd_get_resp(amd_manager, lower_data, upper_data); in amd_program_scp_addr()
239 dev_err_ratelimited(amd_manager->dev, in amd_program_scp_addr()
245 dev_err_ratelimited(amd_manager->dev, in amd_program_scp_addr()
250 dev_dbg_ratelimited(amd_manager->dev, "SCP_addrpage ignored for Slave %d\n", in amd_program_scp_addr()
258 static int amd_prep_msg(struct amd_sdw_manager *amd_manager, struct sdw_msg *msg) in amd_prep_msg() argument
263 ret = amd_program_scp_addr(amd_manager, msg); in amd_prep_msg()
274 dev_err(amd_manager->dev, "Invalid msg cmd: %d\n", msg->flags); in amd_prep_msg()
280 static enum sdw_command_response amd_sdw_fill_msg_resp(struct amd_sdw_manager *amd_manager, in amd_sdw_fill_msg_resp() argument
289 dev_err_ratelimited(amd_manager->dev, "command timeout for Slave %d\n", in amd_sdw_fill_msg_resp()
293 dev_err_ratelimited(amd_manager->dev, in amd_sdw_fill_msg_resp()
298 dev_err_ratelimited(amd_manager->dev, "command is ignored for Slave %d\n", in amd_sdw_fill_msg_resp()
305 static unsigned int _amd_sdw_xfer_msg(struct amd_sdw_manager *amd_manager, struct sdw_msg *msg, in _amd_sdw_xfer_msg() argument
312 response = amd_sdw_send_cmd_get_resp(amd_manager, lower_data, upper_data); in _amd_sdw_xfer_msg()
313 return amd_sdw_fill_msg_resp(amd_manager, msg, response, cmd_offset); in _amd_sdw_xfer_msg()
318 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in amd_sdw_xfer_msg() local
321 ret = amd_prep_msg(amd_manager, msg); in amd_sdw_xfer_msg()
325 ret = _amd_sdw_xfer_msg(amd_manager, msg, i); in amd_sdw_xfer_msg()
332 static void amd_sdw_fill_slave_status(struct amd_sdw_manager *amd_manager, u16 index, u32 status) in amd_sdw_fill_slave_status() argument
338 amd_manager->status[index] = status; in amd_sdw_fill_slave_status()
341 amd_manager->status[index] = SDW_SLAVE_RESERVED; in amd_sdw_fill_slave_status()
346 static void amd_sdw_process_ping_status(u64 response, struct amd_sdw_manager *amd_manager) in amd_sdw_process_ping_status() argument
355 dev_dbg(amd_manager->dev, "slave_stat:0x%llx\n", slave_stat); in amd_sdw_process_ping_status()
358 dev_dbg(amd_manager->dev, "val:0x%x\n", val); in amd_sdw_process_ping_status()
359 amd_sdw_fill_slave_status(amd_manager, dev_index, val); in amd_sdw_process_ping_status()
363 static void amd_sdw_read_and_process_ping_status(struct amd_sdw_manager *amd_manager) in amd_sdw_read_and_process_ping_status() argument
367 mutex_lock(&amd_manager->bus.msg_lock); in amd_sdw_read_and_process_ping_status()
368 response = amd_sdw_send_cmd_get_resp(amd_manager, 0, 0); in amd_sdw_read_and_process_ping_status()
369 mutex_unlock(&amd_manager->bus.msg_lock); in amd_sdw_read_and_process_ping_status()
370 amd_sdw_process_ping_status(response, amd_manager); in amd_sdw_read_and_process_ping_status()
375 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in amd_sdw_read_ping_status() local
379 response = amd_sdw_send_cmd_get_resp(amd_manager, 0, 0); in amd_sdw_read_ping_status()
383 dev_dbg(amd_manager->dev, "slave_stat:0x%x\n", slave_stat); in amd_sdw_read_ping_status()
432 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in amd_sdw_port_params() local
435 dev_dbg(amd_manager->dev, "p_params->num:0x%x\n", p_params->num); in amd_sdw_port_params()
436 switch (amd_manager->instance) { in amd_sdw_port_params()
447 dpn_frame_fmt = readl(amd_manager->mmio + frame_fmt_reg); in amd_sdw_port_params()
451 writel(dpn_frame_fmt, amd_manager->mmio + frame_fmt_reg); in amd_sdw_port_params()
459 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in amd_sdw_transport_params() local
468 switch (amd_manager->instance) { in amd_sdw_transport_params()
486 writel(AMD_SDW_SSP_COUNTER_VAL, amd_manager->mmio + ACP_SW_SSP_COUNTER); in amd_sdw_transport_params()
488 dpn_frame_fmt = readl(amd_manager->mmio + frame_fmt_reg); in amd_sdw_transport_params()
492 writel(dpn_frame_fmt, amd_manager->mmio + frame_fmt_reg); in amd_sdw_transport_params()
495 writel(dpn_sampleinterval, amd_manager->mmio + sample_int_reg); in amd_sdw_transport_params()
499 writel(dpn_hctrl, amd_manager->mmio + hctrl_dp0_reg); in amd_sdw_transport_params()
503 writel(dpn_offsetctrl, amd_manager->mmio + offset_reg); in amd_sdw_transport_params()
509 dpn_lanectrl = readl(amd_manager->mmio + lane_ctrl_ch_en_reg); in amd_sdw_transport_params()
511 writel(dpn_lanectrl, amd_manager->mmio + lane_ctrl_ch_en_reg); in amd_sdw_transport_params()
519 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in amd_sdw_port_enable() local
523 switch (amd_manager->instance) { in amd_sdw_port_enable()
538 dpn_ch_enable = readl(amd_manager->mmio + lane_ctrl_ch_en_reg); in amd_sdw_port_enable()
541 writel(dpn_ch_enable, amd_manager->mmio + lane_ctrl_ch_en_reg); in amd_sdw_port_enable()
543 writel(0, amd_manager->mmio + lane_ctrl_ch_en_reg); in amd_sdw_port_enable()
549 struct amd_sdw_manager *amd_manager = to_amd_sdw(bus); in sdw_master_read_amd_prop() local
572 amd_manager->wake_en_mask = wake_en_mask; in sdw_master_read_amd_prop()
574 amd_manager->power_mode_mask = power_mode_mask; in sdw_master_read_amd_prop()
604 struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); in amd_sdw_hw_params() local
610 dai_runtime = amd_manager->dai_runtime_array[dai->id]; in amd_sdw_hw_params()
619 dev_dbg(amd_manager->dev, "dir:%d dai->id:0x%x\n", dir, dai->id); in amd_sdw_hw_params()
636 ret = sdw_stream_add_master(&amd_manager->bus, &sconfig, in amd_sdw_hw_params()
639 dev_err(amd_manager->dev, "add manager to stream failed:%d\n", ret); in amd_sdw_hw_params()
646 struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); in amd_sdw_hw_free() local
650 dai_runtime = amd_manager->dai_runtime_array[dai->id]; in amd_sdw_hw_free()
654 ret = sdw_stream_remove_master(&amd_manager->bus, dai_runtime->stream); in amd_sdw_hw_free()
663 struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); in amd_set_sdw_stream() local
666 dai_runtime = amd_manager->dai_runtime_array[dai->id]; in amd_set_sdw_stream()
680 dai_runtime->bus = &amd_manager->bus; in amd_set_sdw_stream()
682 amd_manager->dai_runtime_array[dai->id] = dai_runtime; in amd_set_sdw_stream()
692 amd_manager->dai_runtime_array[dai->id] = NULL; in amd_set_sdw_stream()
704 struct amd_sdw_manager *amd_manager = snd_soc_dai_get_drvdata(dai); in amd_get_sdw_stream() local
707 dai_runtime = amd_manager->dai_runtime_array[dai->id]; in amd_get_sdw_stream()
725 static int amd_sdw_register_dais(struct amd_sdw_manager *amd_manager) in amd_sdw_register_dais() argument
733 dev = amd_manager->dev; in amd_sdw_register_dais()
734 num_dais = amd_manager->num_dout_ports + amd_manager->num_din_ports; in amd_sdw_register_dais()
744 amd_manager->dai_runtime_array = dai_runtime_array; in amd_sdw_register_dais()
746 dais[i].name = devm_kasprintf(dev, GFP_KERNEL, "SDW%d Pin%d", amd_manager->instance, in amd_sdw_register_dais()
750 if (i < amd_manager->num_dout_ports) in amd_sdw_register_dais()
770 struct amd_sdw_manager *amd_manager = in amd_sdw_update_slave_status_work() local
774 if (amd_manager->status[0] == SDW_SLAVE_ATTACHED) { in amd_sdw_update_slave_status_work()
775 writel(0, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_0TO7); in amd_sdw_update_slave_status_work()
776 writel(0, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_MASK_8TO11); in amd_sdw_update_slave_status_work()
780 sdw_handle_slave_status(&amd_manager->bus, amd_manager->status); in amd_sdw_update_slave_status_work()
788 if (amd_manager->status[0] == SDW_SLAVE_ATTACHED) { in amd_sdw_update_slave_status_work()
790 writel(AMD_SDW_IRQ_MASK_0TO7, amd_manager->mmio + in amd_sdw_update_slave_status_work()
792 writel(AMD_SDW_IRQ_MASK_8TO11, amd_manager->mmio + in amd_sdw_update_slave_status_work()
794 amd_sdw_read_and_process_ping_status(amd_manager); in amd_sdw_update_slave_status_work()
797 dev_err_ratelimited(amd_manager->dev, in amd_sdw_update_slave_status_work()
805 struct amd_sdw_manager *amd_manager) in amd_sdw_update_slave_status() argument
812 memset(amd_manager->status, 0, sizeof(amd_manager->status)); in amd_sdw_update_slave_status()
815 dev_dbg(amd_manager->dev, "status_change_0to7:0x%x status_change_8to11:0x%x\n", in amd_sdw_update_slave_status()
822 amd_sdw_fill_slave_status(amd_manager, dev_index, val); in amd_sdw_update_slave_status()
828 static void amd_sdw_process_wake_event(struct amd_sdw_manager *amd_manager) in amd_sdw_process_wake_event() argument
830 pm_request_resume(amd_manager->dev); in amd_sdw_process_wake_event()
831 writel(0x00, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance)); in amd_sdw_process_wake_event()
832 writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11); in amd_sdw_process_wake_event()
837 struct amd_sdw_manager *amd_manager = in amd_sdw_irq_thread() local
842 status_change_8to11 = readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11); in amd_sdw_irq_thread()
843 status_change_0to7 = readl(amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7); in amd_sdw_irq_thread()
844 dev_dbg(amd_manager->dev, "[SDW%d] SDW INT: 0to7=0x%x, 8to11=0x%x\n", in amd_sdw_irq_thread()
845 amd_manager->instance, status_change_0to7, status_change_8to11); in amd_sdw_irq_thread()
847 return amd_sdw_process_wake_event(amd_manager); in amd_sdw_irq_thread()
850 amd_sdw_read_and_process_ping_status(amd_manager); in amd_sdw_irq_thread()
853 amd_sdw_update_slave_status(status_change_0to7, status_change_8to11, amd_manager); in amd_sdw_irq_thread()
856 schedule_work(&amd_manager->amd_sdw_work); in amd_sdw_irq_thread()
857 writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_8TO11); in amd_sdw_irq_thread()
858 writel(0x00, amd_manager->mmio + ACP_SW_STATE_CHANGE_STATUS_0TO7); in amd_sdw_irq_thread()
861 int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager) in amd_sdw_manager_start() argument
866 prop = &amd_manager->bus.prop; in amd_sdw_manager_start()
868 ret = amd_init_sdw_manager(amd_manager); in amd_sdw_manager_start()
871 amd_enable_sdw_interrupts(amd_manager); in amd_sdw_manager_start()
872 ret = amd_enable_sdw_manager(amd_manager); in amd_sdw_manager_start()
875 amd_sdw_set_frameshape(amd_manager); in amd_sdw_manager_start()
878 pm_runtime_set_autosuspend_delay(amd_manager->dev, AMD_SDW_MASTER_SUSPEND_DELAY_MS); in amd_sdw_manager_start()
879 pm_runtime_use_autosuspend(amd_manager->dev); in amd_sdw_manager_start()
880 pm_runtime_mark_last_busy(amd_manager->dev); in amd_sdw_manager_start()
881 pm_runtime_set_active(amd_manager->dev); in amd_sdw_manager_start()
882 pm_runtime_enable(amd_manager->dev); in amd_sdw_manager_start()
893 struct amd_sdw_manager *amd_manager; in amd_sdw_manager_probe() local
896 amd_manager = devm_kzalloc(dev, sizeof(struct amd_sdw_manager), GFP_KERNEL); in amd_sdw_manager_probe()
897 if (!amd_manager) in amd_sdw_manager_probe()
904 amd_manager->acp_mmio = devm_ioremap(dev, res->start, resource_size(res)); in amd_sdw_manager_probe()
905 if (!amd_manager->acp_mmio) { in amd_sdw_manager_probe()
909 amd_manager->instance = pdata->instance; in amd_sdw_manager_probe()
910 amd_manager->mmio = amd_manager->acp_mmio + in amd_sdw_manager_probe()
911 (amd_manager->instance * SDW_MANAGER_REG_OFFSET); in amd_sdw_manager_probe()
912 amd_manager->acp_sdw_lock = pdata->acp_sdw_lock; in amd_sdw_manager_probe()
913 amd_manager->cols_index = sdw_find_col_index(AMD_SDW_DEFAULT_COLUMNS); in amd_sdw_manager_probe()
914 amd_manager->rows_index = sdw_find_row_index(AMD_SDW_DEFAULT_ROWS); in amd_sdw_manager_probe()
915 amd_manager->dev = dev; in amd_sdw_manager_probe()
916 amd_manager->bus.ops = &amd_sdw_ops; in amd_sdw_manager_probe()
917 amd_manager->bus.port_ops = &amd_sdw_port_ops; in amd_sdw_manager_probe()
918 amd_manager->bus.compute_params = &amd_sdw_compute_params; in amd_sdw_manager_probe()
919 amd_manager->bus.clk_stop_timeout = 200; in amd_sdw_manager_probe()
920 amd_manager->bus.link_id = amd_manager->instance; in amd_sdw_manager_probe()
928 amd_manager->bus.controller_id = 0; in amd_sdw_manager_probe()
930 switch (amd_manager->instance) { in amd_sdw_manager_probe()
932 amd_manager->num_dout_ports = AMD_SDW0_MAX_TX_PORTS; in amd_sdw_manager_probe()
933 amd_manager->num_din_ports = AMD_SDW0_MAX_RX_PORTS; in amd_sdw_manager_probe()
936 amd_manager->num_dout_ports = AMD_SDW1_MAX_TX_PORTS; in amd_sdw_manager_probe()
937 amd_manager->num_din_ports = AMD_SDW1_MAX_RX_PORTS; in amd_sdw_manager_probe()
943 params = &amd_manager->bus.params; in amd_sdw_manager_probe()
947 prop = &amd_manager->bus.prop; in amd_sdw_manager_probe()
952 ret = sdw_bus_master_add(&amd_manager->bus, dev, dev->fwnode); in amd_sdw_manager_probe()
957 ret = amd_sdw_register_dais(amd_manager); in amd_sdw_manager_probe()
960 sdw_bus_master_delete(&amd_manager->bus); in amd_sdw_manager_probe()
963 dev_set_drvdata(dev, amd_manager); in amd_sdw_manager_probe()
964 INIT_WORK(&amd_manager->amd_sdw_irq_thread, amd_sdw_irq_thread); in amd_sdw_manager_probe()
965 INIT_WORK(&amd_manager->amd_sdw_work, amd_sdw_update_slave_status_work); in amd_sdw_manager_probe()
971 struct amd_sdw_manager *amd_manager = dev_get_drvdata(&pdev->dev); in amd_sdw_manager_remove() local
975 amd_disable_sdw_interrupts(amd_manager); in amd_sdw_manager_remove()
976 sdw_bus_master_delete(&amd_manager->bus); in amd_sdw_manager_remove()
977 ret = amd_disable_sdw_manager(amd_manager); in amd_sdw_manager_remove()
982 static int amd_sdw_clock_stop(struct amd_sdw_manager *amd_manager) in amd_sdw_clock_stop() argument
987 ret = sdw_bus_prep_clk_stop(&amd_manager->bus); in amd_sdw_clock_stop()
989 dev_err(amd_manager->dev, "prepare clock stop failed %d", ret); in amd_sdw_clock_stop()
992 ret = sdw_bus_clk_stop(&amd_manager->bus); in amd_sdw_clock_stop()
994 dev_err(amd_manager->dev, "bus clock stop failed %d", ret); in amd_sdw_clock_stop()
998 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL, val, in amd_sdw_clock_stop()
1001 dev_err(amd_manager->dev, "SDW%x clock stop failed\n", amd_manager->instance); in amd_sdw_clock_stop()
1005 amd_manager->clk_stopped = true; in amd_sdw_clock_stop()
1006 if (amd_manager->wake_en_mask) in amd_sdw_clock_stop()
1007 writel(0x01, amd_manager->acp_mmio + ACP_SW_WAKE_EN(amd_manager->instance)); in amd_sdw_clock_stop()
1009 dev_dbg(amd_manager->dev, "SDW%x clock stop successful\n", amd_manager->instance); in amd_sdw_clock_stop()
1013 static int amd_sdw_clock_stop_exit(struct amd_sdw_manager *amd_manager) in amd_sdw_clock_stop_exit() argument
1018 if (amd_manager->clk_stopped) { in amd_sdw_clock_stop_exit()
1019 val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_sdw_clock_stop_exit()
1021 writel(val, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_sdw_clock_stop_exit()
1022 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL, val, in amd_sdw_clock_stop_exit()
1026 writel(0, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_sdw_clock_stop_exit()
1027 ret = sdw_bus_exit_clk_stop(&amd_manager->bus); in amd_sdw_clock_stop_exit()
1029 dev_err(amd_manager->dev, "bus failed to exit clock stop %d\n", in amd_sdw_clock_stop_exit()
1031 amd_manager->clk_stopped = false; in amd_sdw_clock_stop_exit()
1034 if (amd_manager->clk_stopped) { in amd_sdw_clock_stop_exit()
1035 dev_err(amd_manager->dev, "SDW%x clock stop exit failed\n", amd_manager->instance); in amd_sdw_clock_stop_exit()
1038 dev_dbg(amd_manager->dev, "SDW%x clock stop exit successful\n", amd_manager->instance); in amd_sdw_clock_stop_exit()
1065 struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); in amd_pm_prepare() local
1066 struct sdw_bus *bus = &amd_manager->bus; in amd_pm_prepare()
1079 if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { in amd_pm_prepare()
1099 struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); in amd_suspend() local
1100 struct sdw_bus *bus = &amd_manager->bus; in amd_suspend()
1109 if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { in amd_suspend()
1110 amd_sdw_wake_enable(amd_manager, false); in amd_suspend()
1111 return amd_sdw_clock_stop(amd_manager); in amd_suspend()
1112 } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { in amd_suspend()
1117 ret = amd_sdw_clock_stop(amd_manager); in amd_suspend()
1120 return amd_deinit_sdw_manager(amd_manager); in amd_suspend()
1127 struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); in amd_suspend_runtime() local
1128 struct sdw_bus *bus = &amd_manager->bus; in amd_suspend_runtime()
1136 if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { in amd_suspend_runtime()
1137 amd_sdw_wake_enable(amd_manager, true); in amd_suspend_runtime()
1138 return amd_sdw_clock_stop(amd_manager); in amd_suspend_runtime()
1139 } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { in amd_suspend_runtime()
1140 ret = amd_sdw_clock_stop(amd_manager); in amd_suspend_runtime()
1143 return amd_deinit_sdw_manager(amd_manager); in amd_suspend_runtime()
1150 struct amd_sdw_manager *amd_manager = dev_get_drvdata(dev); in amd_resume_runtime() local
1151 struct sdw_bus *bus = &amd_manager->bus; in amd_resume_runtime()
1161 if (amd_manager->power_mode_mask & AMD_SDW_CLK_STOP_MODE) { in amd_resume_runtime()
1162 return amd_sdw_clock_stop_exit(amd_manager); in amd_resume_runtime()
1163 } else if (amd_manager->power_mode_mask & AMD_SDW_POWER_OFF_MODE) { in amd_resume_runtime()
1164 val = readl(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_resume_runtime()
1167 writel(val, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_resume_runtime()
1168 ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL, val, in amd_resume_runtime()
1172 writel(0, amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL); in amd_resume_runtime()
1173 amd_manager->clk_stopped = false; in amd_resume_runtime()
1177 amd_init_sdw_manager(amd_manager); in amd_resume_runtime()
1178 amd_enable_sdw_interrupts(amd_manager); in amd_resume_runtime()
1179 ret = amd_enable_sdw_manager(amd_manager); in amd_resume_runtime()
1182 amd_sdw_set_frameshape(amd_manager); in amd_resume_runtime()