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 int 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()
95 if (ipc_imem->mmio->mux_protocol == MUX_AGGREGATION && in ipc_imem_wwan_channel_init()
96 ipc_imem->nr_of_channels == IPC_MEM_IP_CHL_ID_0) { in ipc_imem_wwan_channel_init()
102 ipc_imem_channel_init(ipc_imem, IPC_CTYPE_WWAN, chnl_cfg, in ipc_imem_wwan_channel_init()
106 ipc_imem->wwan = ipc_wwan_init(ipc_imem, ipc_imem->dev); in ipc_imem_wwan_channel_init()
107 if (!ipc_imem->wwan) { in ipc_imem_wwan_channel_init()
108 dev_err(ipc_imem->dev, in ipc_imem_wwan_channel_init()
117 static int ipc_imem_map_skb_to_dma(struct iosm_imem *ipc_imem, in ipc_imem_map_skb_to_dma() argument
120 struct iosm_pcie *ipc_pcie = ipc_imem->pcie; in ipc_imem_map_skb_to_dma()
143 static bool ipc_imem_is_channel_active(struct iosm_imem *ipc_imem, in ipc_imem_is_channel_active() argument
149 phase = ipc_imem->phase; in ipc_imem_is_channel_active()
163 dev_err(ipc_imem->dev, in ipc_imem_is_channel_active()
173 dev_err(ipc_imem->dev, "ch[%d]: confused phase %d", in ipc_imem_is_channel_active()
179 dev_err(ipc_imem->dev, "ch[%d]: confused channel state %d", in ipc_imem_is_channel_active()
196 void ipc_imem_sys_port_close(struct iosm_imem *ipc_imem, in ipc_imem_sys_port_close() argument
203 curr_phase = ipc_imem->phase; in ipc_imem_sys_port_close()
209 dev_err(ipc_imem->dev, in ipc_imem_sys_port_close()
216 dev_err(ipc_imem->dev, "ch[%d]: invalid channel state %d", in ipc_imem_sys_port_close()
225 ipc_imem->app_notify_ul_pend = 1; in ipc_imem_sys_port_close()
231 (&ipc_imem->ul_pend_sem, in ipc_imem_sys_port_close()
234 dev_dbg(ipc_imem->dev, in ipc_imem_sys_port_close()
241 ipc_imem->app_notify_ul_pend = 0; in ipc_imem_sys_port_close()
247 ipc_protocol_get_head_tail_index(ipc_imem->ipc_protocol, in ipc_imem_sys_port_close()
251 ipc_imem->app_notify_dl_pend = 1; in ipc_imem_sys_port_close()
257 (&ipc_imem->dl_pend_sem, in ipc_imem_sys_port_close()
260 dev_dbg(ipc_imem->dev, in ipc_imem_sys_port_close()
267 ipc_imem->app_notify_dl_pend = 0; in ipc_imem_sys_port_close()
278 ipc_imem_pipe_close(ipc_imem, &channel->ul_pipe); in ipc_imem_sys_port_close()
279 ipc_imem_pipe_close(ipc_imem, &channel->dl_pipe); in ipc_imem_sys_port_close()
285 struct ipc_mem_channel *ipc_imem_sys_port_open(struct iosm_imem *ipc_imem, in ipc_imem_sys_port_open() argument
292 if (ipc_imem_phase_update(ipc_imem) != IPC_P_RUN) { in ipc_imem_sys_port_open()
293 dev_err(ipc_imem->dev, "PORT open refused, phase %s", in ipc_imem_sys_port_open()
294 ipc_imem_phase_get_string(ipc_imem->phase)); in ipc_imem_sys_port_open()
298 ch_id = ipc_imem_channel_alloc(ipc_imem, chl_id, IPC_CTYPE_CTRL); in ipc_imem_sys_port_open()
301 dev_err(ipc_imem->dev, "reservation of an PORT chnl id failed"); in ipc_imem_sys_port_open()
305 channel = ipc_imem_channel_open(ipc_imem, ch_id, hp_id); in ipc_imem_sys_port_open()
308 dev_err(ipc_imem->dev, "PORT channel id open failed"); in ipc_imem_sys_port_open()
319 struct iosm_imem *ipc_imem = ipc_cdev->ipc_imem; in ipc_imem_sys_cdev_write() local
322 if (!ipc_imem_is_channel_active(ipc_imem, channel) || in ipc_imem_sys_cdev_write()
323 ipc_imem->phase == IPC_P_OFF_REQ) in ipc_imem_sys_cdev_write()
326 ret = ipc_imem_map_skb_to_dma(ipc_imem, skb); in ipc_imem_sys_cdev_write()
334 ret = ipc_imem_call_cdev_write(ipc_imem); in ipc_imem_sys_cdev_write()
346 struct ipc_mem_channel *ipc_imem_sys_devlink_open(struct iosm_imem *ipc_imem) in ipc_imem_sys_devlink_open() argument
352 phase = ipc_imem_phase_update(ipc_imem); in ipc_imem_sys_devlink_open()
357 channel_id = ipc_imem_channel_alloc(ipc_imem, in ipc_imem_sys_devlink_open()
362 dev_err(ipc_imem->dev, in ipc_imem_sys_devlink_open()
367 ipc_imem->ipc_devlink->devlink_sio.channel_id = channel_id; in ipc_imem_sys_devlink_open()
368 channel = &ipc_imem->channels[channel_id]; in ipc_imem_sys_devlink_open()
371 if (ipc_imem_devlink_trigger_chip_info(ipc_imem)) { in ipc_imem_sys_devlink_open()
372 dev_err(ipc_imem->dev, "Enqueue of chip info failed"); in ipc_imem_sys_devlink_open()
381 ipc_imem->cp_version = ipc_mmio_get_cp_version(ipc_imem->mmio); in ipc_imem_sys_devlink_open()
382 if (ipc_imem->cp_version == -1) { in ipc_imem_sys_devlink_open()
383 dev_err(ipc_imem->dev, "invalid CP version"); in ipc_imem_sys_devlink_open()
387 channel_id = ipc_imem->ipc_devlink->devlink_sio.channel_id; in ipc_imem_sys_devlink_open()
388 return ipc_imem_channel_open(ipc_imem, channel_id, in ipc_imem_sys_devlink_open()
393 dev_err(ipc_imem->dev, "SIO open refused, phase %d", phase); in ipc_imem_sys_devlink_open()
402 struct iosm_imem *ipc_imem = ipc_devlink->pcie->imem; in ipc_imem_sys_devlink_close() local
409 channel = ipc_imem->ipc_devlink->devlink_sio.channel; in ipc_imem_sys_devlink_close()
412 exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); in ipc_imem_sys_devlink_close()
425 (&ipc_imem->ul_pend_sem, in ipc_imem_sys_devlink_close()
428 dev_dbg(ipc_imem->dev, in ipc_imem_sys_devlink_close()
436 ipc_protocol_get_head_tail_index(ipc_imem->ipc_protocol, in ipc_imem_sys_devlink_close()
441 (&ipc_imem->dl_pend_sem, in ipc_imem_sys_devlink_close()
444 dev_dbg(ipc_imem->dev, in ipc_imem_sys_devlink_close()
460 ipc_imem_pipe_cleanup(ipc_imem, &channel->ul_pipe); in ipc_imem_sys_devlink_close()
461 ipc_imem_pipe_cleanup(ipc_imem, &channel->dl_pipe); in ipc_imem_sys_devlink_close()
462 ipc_imem->nr_of_channels--; in ipc_imem_sys_devlink_close()
473 static int ipc_imem_sys_psi_transfer(struct iosm_imem *ipc_imem, in ipc_imem_sys_psi_transfer() argument
483 ret = ipc_pcie_addr_map(ipc_imem->pcie, buf, count, &mapping, in ipc_imem_sys_psi_transfer()
491 ipc_mmio_set_psi_addr_and_size(ipc_imem->mmio, mapping, count); in ipc_imem_sys_psi_transfer()
492 ipc_doorbell_fire(ipc_imem->pcie, 0, IPC_MEM_EXEC_STAGE_BOOT); in ipc_imem_sys_psi_transfer()
499 dev_err(ipc_imem->dev, "Failed PSI transfer to CP, Error-%d", in ipc_imem_sys_psi_transfer()
504 if (ipc_imem->rom_exit_code != IMEM_ROM_EXIT_OPEN_EXT && in ipc_imem_sys_psi_transfer()
505 ipc_imem->rom_exit_code != IMEM_ROM_EXIT_CERT_EXT) { in ipc_imem_sys_psi_transfer()
506 ret = (-1) * ((int)ipc_imem->rom_exit_code); in ipc_imem_sys_psi_transfer()
510 dev_dbg(ipc_imem->dev, "PSI image successfully downloaded"); in ipc_imem_sys_psi_transfer()
517 exec_stage = ipc_mmio_get_exec_stage(ipc_imem->mmio); in ipc_imem_sys_psi_transfer()
529 ipc_imem->phase = IPC_P_PSI; in ipc_imem_sys_psi_transfer()
532 dev_dbg(ipc_imem->dev, "execution_stage[%X] eq. PSI", exec_stage); in ipc_imem_sys_psi_transfer()
537 ipc_imem_ipc_init_check(ipc_imem); in ipc_imem_sys_psi_transfer()
542 dev_err(ipc_imem->dev, in ipc_imem_sys_psi_transfer()
547 if (ipc_mmio_get_ipc_state(ipc_imem->mmio) != in ipc_imem_sys_psi_transfer()
549 dev_err(ipc_imem->dev, in ipc_imem_sys_psi_transfer()
552 ipc_imem_phase_get_string(ipc_imem->phase), in ipc_imem_sys_psi_transfer()
553 ipc_mmio_get_ipc_state(ipc_imem->mmio)); in ipc_imem_sys_psi_transfer()
559 if (!ipc_imem_sys_devlink_open(ipc_imem)) { in ipc_imem_sys_psi_transfer()
560 dev_err(ipc_imem->dev, "can't open flash_channel"); in ipc_imem_sys_psi_transfer()
566 ipc_pcie_addr_unmap(ipc_imem->pcie, count, mapping, DMA_TO_DEVICE); in ipc_imem_sys_psi_transfer()
574 struct iosm_imem *ipc_imem = ipc_devlink->pcie->imem; in ipc_imem_sys_devlink_write() local
580 channel = ipc_imem->ipc_devlink->devlink_sio.channel; in ipc_imem_sys_devlink_write()
585 if (ipc_imem->phase == IPC_P_ROM) { in ipc_imem_sys_devlink_write()
586 ret = ipc_imem_sys_psi_transfer(ipc_imem, channel, buf, count); in ipc_imem_sys_devlink_write()
591 ipc_imem_msg_send_feature_set(ipc_imem, in ipc_imem_sys_devlink_write()
613 if (!ipc_imem_call_cdev_write(ipc_imem)) { in ipc_imem_sys_devlink_write()
617 dev_err(ipc_imem->dev, in ipc_imem_sys_devlink_write()