Lines Matching refs:ipc_imem
16 int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id) in ipc_imem_sys_wwan_open() argument
18 dev_dbg(ipc_imem->dev, "%s if id: %d", in ipc_imem_sys_wwan_open()
19 ipc_imem_phase_get_string(ipc_imem->phase), if_id); in ipc_imem_sys_wwan_open()
22 if (ipc_imem_phase_update(ipc_imem) != IPC_P_RUN) { in ipc_imem_sys_wwan_open()
23 dev_err(ipc_imem->dev, "net:%d : refused phase %s", if_id, in ipc_imem_sys_wwan_open()
24 ipc_imem_phase_get_string(ipc_imem->phase)); in ipc_imem_sys_wwan_open()
28 return ipc_mux_open_session(ipc_imem->mux, if_id); in ipc_imem_sys_wwan_open()
32 void ipc_imem_sys_wwan_close(struct iosm_imem *ipc_imem, int if_id, in ipc_imem_sys_wwan_close() argument
35 if (ipc_imem->mux && if_id >= IP_MUX_SESSION_START && in ipc_imem_sys_wwan_close()
37 ipc_mux_close_session(ipc_imem->mux, if_id); in ipc_imem_sys_wwan_close()
41 static int ipc_imem_tq_cdev_write(struct iosm_imem *ipc_imem, int arg, in ipc_imem_tq_cdev_write() argument
44 ipc_imem_ul_send(ipc_imem); in ipc_imem_tq_cdev_write()
50 static int ipc_imem_call_cdev_write(struct iosm_imem *ipc_imem) in ipc_imem_call_cdev_write() argument
52 return ipc_task_queue_send_task(ipc_imem, ipc_imem_tq_cdev_write, 0, in ipc_imem_call_cdev_write()
57 int ipc_imem_sys_wwan_transmit(struct iosm_imem *ipc_imem, in ipc_imem_sys_wwan_transmit() argument
62 if (!ipc_imem || channel_id < 0) in ipc_imem_sys_wwan_transmit()
66 if (ipc_imem->phase != IPC_P_RUN) { in ipc_imem_sys_wwan_transmit()
67 dev_dbg(ipc_imem->dev, "phase %s transmit", in ipc_imem_sys_wwan_transmit()
68 ipc_imem_phase_get_string(ipc_imem->phase)); in ipc_imem_sys_wwan_transmit()
74 ret = ipc_mux_ul_trigger_encode(ipc_imem->mux, if_id, skb); in ipc_imem_sys_wwan_transmit()
80 void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem, in ipc_imem_wwan_channel_init() argument
85 ipc_imem->cp_version = ipc_mmio_get_cp_version(ipc_imem->mmio); in ipc_imem_wwan_channel_init()
88 if (ipc_imem->cp_version == -1) { in ipc_imem_wwan_channel_init()
89 dev_err(ipc_imem->dev, "invalid CP version"); in ipc_imem_wwan_channel_init()
93 ipc_chnl_cfg_get(&chnl_cfg, ipc_imem->nr_of_channels); in ipc_imem_wwan_channel_init()
94 ipc_imem_channel_init(ipc_imem, IPC_CTYPE_WWAN, chnl_cfg, in ipc_imem_wwan_channel_init()
98 ipc_imem->wwan = ipc_wwan_init(ipc_imem, ipc_imem->dev); in ipc_imem_wwan_channel_init()
99 if (!ipc_imem->wwan) in ipc_imem_wwan_channel_init()
100 dev_err(ipc_imem->dev, in ipc_imem_wwan_channel_init()
105 static int ipc_imem_map_skb_to_dma(struct iosm_imem *ipc_imem, in ipc_imem_map_skb_to_dma() argument
108 struct iosm_pcie *ipc_pcie = ipc_imem->pcie; in ipc_imem_map_skb_to_dma()
131 static bool ipc_imem_is_channel_active(struct iosm_imem *ipc_imem, in ipc_imem_is_channel_active() argument
137 phase = ipc_imem->phase; in ipc_imem_is_channel_active()
151 dev_err(ipc_imem->dev, in ipc_imem_is_channel_active()
161 dev_err(ipc_imem->dev, "ch[%d]: confused phase %d", in ipc_imem_is_channel_active()
167 dev_err(ipc_imem->dev, "ch[%d]: confused channel state %d", in ipc_imem_is_channel_active()
184 void ipc_imem_sys_port_close(struct iosm_imem *ipc_imem, in ipc_imem_sys_port_close() argument
191 curr_phase = ipc_imem->phase; in ipc_imem_sys_port_close()
197 dev_err(ipc_imem->dev, in ipc_imem_sys_port_close()
204 dev_err(ipc_imem->dev, "ch[%d]: invalid channel state %d", in ipc_imem_sys_port_close()
213 ipc_imem->app_notify_ul_pend = 1; in ipc_imem_sys_port_close()
219 (&ipc_imem->ul_pend_sem, in ipc_imem_sys_port_close()
222 dev_dbg(ipc_imem->dev, in ipc_imem_sys_port_close()
229 ipc_imem->app_notify_ul_pend = 0; in ipc_imem_sys_port_close()
235 ipc_protocol_get_head_tail_index(ipc_imem->ipc_protocol, in ipc_imem_sys_port_close()
239 ipc_imem->app_notify_dl_pend = 1; in ipc_imem_sys_port_close()
245 (&ipc_imem->dl_pend_sem, in ipc_imem_sys_port_close()
248 dev_dbg(ipc_imem->dev, in ipc_imem_sys_port_close()
255 ipc_imem->app_notify_dl_pend = 0; in ipc_imem_sys_port_close()
266 ipc_imem_pipe_close(ipc_imem, &channel->ul_pipe); in ipc_imem_sys_port_close()
267 ipc_imem_pipe_close(ipc_imem, &channel->dl_pipe); in ipc_imem_sys_port_close()
273 struct ipc_mem_channel *ipc_imem_sys_port_open(struct iosm_imem *ipc_imem, in ipc_imem_sys_port_open() argument
280 if (ipc_imem_phase_update(ipc_imem) != IPC_P_RUN) { in ipc_imem_sys_port_open()
281 dev_err(ipc_imem->dev, "PORT open refused, phase %s", in ipc_imem_sys_port_open()
282 ipc_imem_phase_get_string(ipc_imem->phase)); in ipc_imem_sys_port_open()
286 ch_id = ipc_imem_channel_alloc(ipc_imem, chl_id, IPC_CTYPE_CTRL); in ipc_imem_sys_port_open()
289 dev_err(ipc_imem->dev, "reservation of an PORT chnl id failed"); in ipc_imem_sys_port_open()
293 channel = ipc_imem_channel_open(ipc_imem, ch_id, hp_id); in ipc_imem_sys_port_open()
296 dev_err(ipc_imem->dev, "PORT channel id open failed"); in ipc_imem_sys_port_open()
307 struct iosm_imem *ipc_imem = ipc_cdev->ipc_imem; in ipc_imem_sys_cdev_write() local
310 if (!ipc_imem_is_channel_active(ipc_imem, channel) || in ipc_imem_sys_cdev_write()
311 ipc_imem->phase == IPC_P_OFF_REQ) in ipc_imem_sys_cdev_write()
314 ret = ipc_imem_map_skb_to_dma(ipc_imem, skb); in ipc_imem_sys_cdev_write()
322 ret = ipc_imem_call_cdev_write(ipc_imem); in ipc_imem_sys_cdev_write()
334 struct ipc_mem_channel *ipc_imem_sys_devlink_open(struct iosm_imem *ipc_imem) in ipc_imem_sys_devlink_open() argument
340 phase = ipc_imem_phase_update(ipc_imem); in ipc_imem_sys_devlink_open()
345 channel_id = ipc_imem_channel_alloc(ipc_imem, in ipc_imem_sys_devlink_open()
350 dev_err(ipc_imem->dev, in ipc_imem_sys_devlink_open()
355 ipc_imem->ipc_devlink->devlink_sio.channel_id = channel_id; in ipc_imem_sys_devlink_open()
356 channel = &ipc_imem->channels[channel_id]; in ipc_imem_sys_devlink_open()
359 if (ipc_imem_devlink_trigger_chip_info(ipc_imem)) { in ipc_imem_sys_devlink_open()
360 dev_err(ipc_imem->dev, "Enqueue of chip info failed"); in ipc_imem_sys_devlink_open()
369 ipc_imem->cp_version = ipc_mmio_get_cp_version(ipc_imem->mmio); in ipc_imem_sys_devlink_open()
370 if (ipc_imem->cp_version == -1) { in ipc_imem_sys_devlink_open()
371 dev_err(ipc_imem->dev, "invalid CP version"); in ipc_imem_sys_devlink_open()
375 channel_id = ipc_imem->ipc_devlink->devlink_sio.channel_id; in ipc_imem_sys_devlink_open()
376 return ipc_imem_channel_open(ipc_imem, channel_id, in ipc_imem_sys_devlink_open()
381 dev_err(ipc_imem->dev, "SIO open refused, phase %d", phase); in ipc_imem_sys_devlink_open()
390 struct iosm_imem *ipc_imem = ipc_devlink->pcie->imem; in ipc_imem_sys_devlink_close() local
397 channel = ipc_imem->ipc_devlink->devlink_sio.channel; in ipc_imem_sys_devlink_close()
400 exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); in ipc_imem_sys_devlink_close()
413 (&ipc_imem->ul_pend_sem, in ipc_imem_sys_devlink_close()
416 dev_dbg(ipc_imem->dev, in ipc_imem_sys_devlink_close()
424 ipc_protocol_get_head_tail_index(ipc_imem->ipc_protocol, in ipc_imem_sys_devlink_close()
429 (&ipc_imem->dl_pend_sem, in ipc_imem_sys_devlink_close()
432 dev_dbg(ipc_imem->dev, in ipc_imem_sys_devlink_close()
448 ipc_imem_pipe_cleanup(ipc_imem, &channel->ul_pipe); in ipc_imem_sys_devlink_close()
449 ipc_imem_pipe_cleanup(ipc_imem, &channel->dl_pipe); in ipc_imem_sys_devlink_close()
450 ipc_imem->nr_of_channels--; in ipc_imem_sys_devlink_close()
461 static int ipc_imem_sys_psi_transfer(struct iosm_imem *ipc_imem, in ipc_imem_sys_psi_transfer() argument
471 ret = ipc_pcie_addr_map(ipc_imem->pcie, buf, count, &mapping, in ipc_imem_sys_psi_transfer()
479 ipc_mmio_set_psi_addr_and_size(ipc_imem->mmio, mapping, count); in ipc_imem_sys_psi_transfer()
480 ipc_doorbell_fire(ipc_imem->pcie, 0, IPC_MEM_EXEC_STAGE_BOOT); in ipc_imem_sys_psi_transfer()
487 dev_err(ipc_imem->dev, "Failed PSI transfer to CP, Error-%d", in ipc_imem_sys_psi_transfer()
492 if (ipc_imem->rom_exit_code != IMEM_ROM_EXIT_OPEN_EXT && in ipc_imem_sys_psi_transfer()
493 ipc_imem->rom_exit_code != IMEM_ROM_EXIT_CERT_EXT) { in ipc_imem_sys_psi_transfer()
494 ret = (-1) * ((int)ipc_imem->rom_exit_code); in ipc_imem_sys_psi_transfer()
498 dev_dbg(ipc_imem->dev, "PSI image successfully downloaded"); in ipc_imem_sys_psi_transfer()
505 exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); in ipc_imem_sys_psi_transfer()
517 ipc_imem->phase = IPC_P_PSI; in ipc_imem_sys_psi_transfer()
520 dev_dbg(ipc_imem->dev, "execution_stage[%X] eq. PSI", exec_stage); in ipc_imem_sys_psi_transfer()
525 ipc_imem_ipc_init_check(ipc_imem); in ipc_imem_sys_psi_transfer()
530 dev_err(ipc_imem->dev, in ipc_imem_sys_psi_transfer()
535 if (ipc_mmio_get_ipc_state(ipc_imem->mmio) != in ipc_imem_sys_psi_transfer()
537 dev_err(ipc_imem->dev, in ipc_imem_sys_psi_transfer()
540 ipc_imem_phase_get_string(ipc_imem->phase), in ipc_imem_sys_psi_transfer()
541 ipc_mmio_get_ipc_state(ipc_imem->mmio)); in ipc_imem_sys_psi_transfer()
547 if (!ipc_imem_sys_devlink_open(ipc_imem)) { in ipc_imem_sys_psi_transfer()
548 dev_err(ipc_imem->dev, "can't open flash_channel"); in ipc_imem_sys_psi_transfer()
554 ipc_pcie_addr_unmap(ipc_imem->pcie, count, mapping, DMA_TO_DEVICE); in ipc_imem_sys_psi_transfer()
562 struct iosm_imem *ipc_imem = ipc_devlink->pcie->imem; in ipc_imem_sys_devlink_write() local
568 channel = ipc_imem->ipc_devlink->devlink_sio.channel; in ipc_imem_sys_devlink_write()
573 if (ipc_imem->phase == IPC_P_ROM) { in ipc_imem_sys_devlink_write()
574 ret = ipc_imem_sys_psi_transfer(ipc_imem, channel, buf, count); in ipc_imem_sys_devlink_write()
579 ipc_imem_msg_send_feature_set(ipc_imem, in ipc_imem_sys_devlink_write()
601 if (!ipc_imem_call_cdev_write(ipc_imem)) { in ipc_imem_sys_devlink_write()
605 dev_err(ipc_imem->dev, in ipc_imem_sys_devlink_write()