1 /* SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2020-21 Intel Corporation.
6 #ifndef IOSM_IPC_IMEM_OPS_H
7 #define IOSM_IPC_IMEM_OPS_H
9 #include "iosm_ipc_mux_codec.h"
11 /* Maximum wait time for blocking read */
12 #define IPC_READ_TIMEOUT 3000
14 /* The delay in ms for defering the unregister */
15 #define SIO_UNREGISTER_DEFER_DELAY_MS 1
17 /* Default delay till CP PSI image is running and modem updates the
21 #define PSI_START_DEFAULT_TIMEOUT 3000
23 /* Default time out when closing SIO, till the modem is in
27 #define BOOT_CHECK_DEFAULT_TIMEOUT 400
29 /* IP MUX channel range */
30 #define IP_MUX_SESSION_START 0
31 #define IP_MUX_SESSION_END 7
33 /* Default IP MUX channel */
34 #define IP_MUX_SESSION_DEFAULT 0
37 * ipc_imem_sys_port_open - Open a port link to CP.
38 * @ipc_imem: Imem instance.
39 * @chl_id: Channel Indentifier.
40 * @hp_id: HP Indentifier.
42 * Return: channel instance on success, NULL for failure
44 struct ipc_mem_channel *ipc_imem_sys_port_open(struct iosm_imem *ipc_imem,
45 int chl_id, int hp_id);
46 void ipc_imem_sys_port_close(struct iosm_imem *ipc_imem,
47 struct ipc_mem_channel *channel);
50 * ipc_imem_sys_cdev_write - Route the uplink buffer to CP.
51 * @ipc_cdev: iosm_cdev instance.
52 * @skb: Pointer to skb.
54 * Return: 0 on success and failure value on error
56 int ipc_imem_sys_cdev_write(struct iosm_cdev *ipc_cdev, struct sk_buff *skb);
59 * ipc_imem_sys_wwan_open - Open packet data online channel between network
61 * @ipc_imem: Imem instance.
62 * @if_id: ip link tag of the net device.
64 * Return: Channel ID on success and failure value on error
66 int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id);
69 * ipc_imem_sys_wwan_close - Close packet data online channel between network
71 * @ipc_imem: Imem instance.
72 * @if_id: IP link id net device.
73 * @channel_id: Channel ID to be closed.
75 void ipc_imem_sys_wwan_close(struct iosm_imem *ipc_imem, int if_id,
79 * ipc_imem_sys_wwan_transmit - Function for transfer UL data
80 * @ipc_imem: Imem instance.
81 * @if_id: link ID of the device.
82 * @channel_id: Channel ID used
83 * @skb: Pointer to sk buffer
85 * Return: 0 on success and failure value on error
87 int ipc_imem_sys_wwan_transmit(struct iosm_imem *ipc_imem, int if_id,
88 int channel_id, struct sk_buff *skb);
90 * ipc_imem_wwan_channel_init - Initializes WWAN channels and the channel for
92 * @ipc_imem: Pointer to iosm_imem struct.
93 * @mux_type: Type of mux protocol.
95 void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem,
96 enum ipc_mux_protocol mux_type);
99 * ipc_imem_sys_devlink_open - Open a Flash/CD Channel link to CP
100 * @ipc_imem: iosm_imem instance
102 * Return: channel instance on success, NULL for failure
104 struct ipc_mem_channel *ipc_imem_sys_devlink_open(struct iosm_imem *ipc_imem);
107 * ipc_imem_sys_devlink_close - Release a Flash/CD channel link to CP
108 * @ipc_devlink: Pointer to ipc_devlink data-struct
111 void ipc_imem_sys_devlink_close(struct iosm_devlink *ipc_devlink);
114 * ipc_imem_sys_devlink_notify_rx - Receive downlink characters from CP,
115 * the downlink skbuf is added at the end of the
116 * downlink or rx list
117 * @ipc_devlink: Pointer to ipc_devlink data-struct
118 * @skb: Pointer to sk buffer
120 void ipc_imem_sys_devlink_notify_rx(struct iosm_devlink *ipc_devlink,
121 struct sk_buff *skb);
124 * ipc_imem_sys_devlink_read - Copy the rx data and free the skbuf
125 * @ipc_devlink: Devlink instance
126 * @data: Buffer to read the data from modem
127 * @bytes_to_read: Size of destination buffer
128 * @bytes_read: Number of bytes read
130 * Return: 0 on success and failure value on error
132 int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data,
133 u32 bytes_to_read, u32 *bytes_read);
136 * ipc_imem_sys_devlink_write - Route the uplink buffer to CP
137 * @ipc_devlink: Devlink_sio instance
138 * @buf: Pointer to buffer
139 * @count: Number of data bytes to write
140 * Return: 0 on success and failure value on error
142 int ipc_imem_sys_devlink_write(struct iosm_devlink *ipc_devlink,
143 unsigned char *buf, int count);