1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* Copyright (c) 2021, Linaro Ltd <loic.poulain@linaro.org> */
7 #include <linux/device.h>
8 #include <linux/kernel.h>
9 #include <linux/skbuff.h>
12 * enum wwan_port_type - WWAN port types
13 * @WWAN_PORT_AT: AT commands
14 * @WWAN_PORT_MBIM: Mobile Broadband Interface Model control
15 * @WWAN_PORT_QMI: Qcom modem/MSM interface for modem control
16 * @WWAN_PORT_QCDM: Qcom Modem diagnostic interface
17 * @WWAN_PORT_FIREHOSE: XML based command protocol
18 * @WWAN_PORT_MAX: Number of supported port types
31 /** struct wwan_port_ops - The WWAN port operations
32 * @start: The routine for starting the WWAN port device.
33 * @stop: The routine for stopping the WWAN port device.
34 * @tx: The routine that sends WWAN port protocol data to the device.
36 * The wwan_port_ops structure contains a list of low-level operations
37 * that control a WWAN port device. All functions are mandatory.
39 struct wwan_port_ops {
40 int (*start)(struct wwan_port *port);
41 void (*stop)(struct wwan_port *port);
42 int (*tx)(struct wwan_port *port, struct sk_buff *skb);
46 * wwan_create_port - Add a new WWAN port
47 * @parent: Device to use as parent and shared by all WWAN ports
48 * @type: WWAN port type
49 * @ops: WWAN port operations
50 * @drvdata: Pointer to caller driver data
52 * Allocate and register a new WWAN port. The port will be automatically exposed
53 * to user as a character device and attached to the right virtual WWAN device,
54 * based on the parent pointer. The parent pointer is the device shared by all
55 * components of a same WWAN modem (e.g. USB dev, PCI dev, MHI controller...).
57 * drvdata will be placed in the WWAN port device driver data and can be
58 * retrieved with wwan_port_get_drvdata().
60 * This function must be balanced with a call to wwan_remove_port().
62 * Returns a valid pointer to wwan_port on success or PTR_ERR on failure
64 struct wwan_port *wwan_create_port(struct device *parent,
65 enum wwan_port_type type,
66 const struct wwan_port_ops *ops,
70 * wwan_remove_port - Remove a WWAN port
71 * @port: WWAN port to remove
73 * Remove a previously created port.
75 void wwan_remove_port(struct wwan_port *port);
78 * wwan_port_rx - Receive data from the WWAN port
79 * @port: WWAN port for which data is received
80 * @skb: Pointer to the rx buffer
82 * A port driver calls this function upon data reception (MBIM, AT...).
84 void wwan_port_rx(struct wwan_port *port, struct sk_buff *skb);
87 * wwan_port_txoff - Stop TX on WWAN port
88 * @port: WWAN port for which TX must be stopped
90 * Used for TX flow control, a port driver calls this function to indicate TX
91 * is temporary unavailable (e.g. due to ring buffer fullness).
93 void wwan_port_txoff(struct wwan_port *port);
97 * wwan_port_txon - Restart TX on WWAN port
98 * @port: WWAN port for which TX must be restarted
100 * Used for TX flow control, a port driver calls this function to indicate TX
101 * is available again.
103 void wwan_port_txon(struct wwan_port *port);
106 * wwan_port_get_drvdata - Retrieve driver data from a WWAN port
107 * @port: Related WWAN port
109 void *wwan_port_get_drvdata(struct wwan_port *port);
111 #endif /* __WWAN_H */