xref: /linux/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h (revision 3d0fe49454652117522f60bfbefb978ba0e5300b)
1 /* SPDX-License-Identifier: GPL-2.0-only
2  *
3  * Copyright (C) 2020-21 Intel Corporation.
4  */
5 
6 #ifndef IOSM_IPC_IMEM_OPS_H
7 #define IOSM_IPC_IMEM_OPS_H
8 
9 #include "iosm_ipc_mux_codec.h"
10 
11 /* Maximum wait time for blocking read */
12 #define IPC_READ_TIMEOUT 3000
13 
14 /* The delay in ms for defering the unregister */
15 #define SIO_UNREGISTER_DEFER_DELAY_MS 1
16 
17 /* Default delay till CP PSI image is running and modem updates the
18  * execution stage.
19  * unit : milliseconds
20  */
21 #define PSI_START_DEFAULT_TIMEOUT 3000
22 
23 /* Default time out when closing SIO, till the modem is in
24  * running state.
25  * unit : milliseconds
26  */
27 #define BOOT_CHECK_DEFAULT_TIMEOUT 400
28 
29 /* IP MUX channel range */
30 #define IP_MUX_SESSION_START 0
31 #define IP_MUX_SESSION_END 7
32 
33 /* Default IP MUX channel */
34 #define IP_MUX_SESSION_DEFAULT	0
35 
36 /**
37  * ipc_imem_sys_port_open - Open a port link to CP.
38  * @ipc_imem:	Imem instance.
39  * @chl_id:	Channel Identifier.
40  * @hp_id:	HP Identifier.
41  *
42  * Return: channel instance on success, NULL for failure
43  */
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);
48 
49 /**
50  * ipc_imem_sys_cdev_write - Route the uplink buffer to CP.
51  * @ipc_cdev:		iosm_cdev instance.
52  * @skb:		Pointer to skb.
53  *
54  * Return: 0 on success and failure value on error
55  */
56 int ipc_imem_sys_cdev_write(struct iosm_cdev *ipc_cdev, struct sk_buff *skb);
57 
58 /**
59  * ipc_imem_sys_wwan_open - Open packet data online channel between network
60  *			layer and CP.
61  * @ipc_imem:		Imem instance.
62  * @if_id:		ip link tag of the net device.
63  *
64  * Return: Channel ID on success and failure value on error
65  */
66 int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id);
67 
68 /**
69  * ipc_imem_sys_wwan_close - Close packet data online channel between network
70  *			 layer and CP.
71  * @ipc_imem:		Imem instance.
72  * @if_id:		IP link id net device.
73  * @channel_id:		Channel ID to be closed.
74  */
75 void ipc_imem_sys_wwan_close(struct iosm_imem *ipc_imem, int if_id,
76 			     int channel_id);
77 
78 /**
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
84  *
85  * Return: 0 on success and failure value on error
86  */
87 int ipc_imem_sys_wwan_transmit(struct iosm_imem *ipc_imem, int if_id,
88 			       int channel_id, struct sk_buff *skb);
89 /**
90  * ipc_imem_wwan_channel_init - Initializes WWAN channels and the channel for
91  *				MUX.
92  * @ipc_imem:		Pointer to iosm_imem struct.
93  * @mux_type:		Type of mux protocol.
94  *
95  * Return: 0 on success and failure value on error
96  */
97 int ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem,
98 			       enum ipc_mux_protocol mux_type);
99 
100 /**
101  * ipc_imem_sys_devlink_open - Open a Flash/CD Channel link to CP
102  * @ipc_imem:   iosm_imem instance
103  *
104  * Return:	channel instance on success, NULL for failure
105  */
106 struct ipc_mem_channel *ipc_imem_sys_devlink_open(struct iosm_imem *ipc_imem);
107 
108 /**
109  * ipc_imem_sys_devlink_close - Release a Flash/CD channel link to CP
110  * @ipc_devlink:	Pointer to ipc_devlink data-struct
111  *
112  */
113 void ipc_imem_sys_devlink_close(struct iosm_devlink *ipc_devlink);
114 
115 /**
116  * ipc_imem_sys_devlink_notify_rx - Receive downlink characters from CP,
117  *				the downlink skbuf is added at the end of the
118  *				downlink or rx list
119  * @ipc_devlink:	Pointer to ipc_devlink data-struct
120  * @skb:		Pointer to sk buffer
121  */
122 void ipc_imem_sys_devlink_notify_rx(struct iosm_devlink *ipc_devlink,
123 				    struct sk_buff *skb);
124 
125 /**
126  * ipc_imem_sys_devlink_read - Copy the rx data and free the skbuf
127  * @ipc_devlink:	Devlink instance
128  * @data:		Buffer to read the data from modem
129  * @bytes_to_read:	Size of destination buffer
130  * @bytes_read:		Number of bytes read
131  *
132  * Return: 0 on success and failure value on error
133  */
134 int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data,
135 			      u32 bytes_to_read, u32 *bytes_read);
136 
137 /**
138  * ipc_imem_sys_devlink_write - Route the uplink buffer to CP
139  * @ipc_devlink:	Devlink_sio instance
140  * @buf:		Pointer to buffer
141  * @count:		Number of data bytes to write
142  * Return:		0 on success and failure value on error
143  */
144 int ipc_imem_sys_devlink_write(struct iosm_devlink *ipc_devlink,
145 			       unsigned char *buf, int count);
146 
147 #endif
148