1 /* SPDX-License-Identifier: GPL-2.0+ */
10 * Read the device to buffer, optional.
13 * @offset: offset to read the device
14 * @buf: pointer to data buffer
15 * @size: data size in bytes to read the device
16 * @return: 0 if OK, -ve on error
18 int misc_read(struct udevice *dev, int offset, void *buf, int size);
20 * Write buffer to the device, optional.
23 * @offset: offset to write the device
24 * @buf: pointer to data buffer
25 * @size: data size in bytes to write the device
26 * @return: 0 if OK, -ve on error
28 int misc_write(struct udevice *dev, int offset, void *buf, int size);
30 * Assert command to the device, optional.
33 * @request: command to be sent to the device
34 * @buf: pointer to buffer related to the request
35 * @return: 0 if OK, -ve on error
37 int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
40 * Send a message to the device and wait for a response.
42 * The caller provides the message type/ID and payload to be sent.
43 * The callee constructs any message header required, transmits it to the
44 * target, waits for a response, checks any error code in the response,
45 * strips any message header from the response, and returns the error code
46 * (or a parsed version of it) and the response message payload.
49 * @msgid: the message ID/number to send.
50 * tx_msg: the request/transmit message payload.
51 * tx_size: the size of the buffer pointed at by tx_msg.
52 * rx_msg: the buffer to receive the response message payload. May be NULL if
53 * the caller only cares about the error code.
54 * rx_size: the size of the buffer pointed at by rx_msg.
55 * @return the response message size if OK, -ve on error
57 int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
58 void *rx_msg, int rx_size);
61 * struct misc_ops - Driver model Misc operations
63 * The uclass interface is implemented by all miscellaneous devices which
68 * Read the device to buffer, optional.
71 * @offset: offset to read the device
72 * @buf: pointer to data buffer
73 * @size: data size in bytes to read the device
74 * @return: 0 if OK, -ve on error
76 int (*read)(struct udevice *dev, int offset, void *buf, int size);
78 * Write buffer to the device, optional.
81 * @offset: offset to write the device
82 * @buf: pointer to data buffer
83 * @size: data size in bytes to write the device
84 * @return: 0 if OK, -ve on error
86 int (*write)(struct udevice *dev, int offset, const void *buf,
89 * Assert command to the device, optional.
92 * @request: command to be sent to the device
93 * @buf: pointer to buffer related to the request
94 * @return: 0 if OK, -ve on error
96 int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
98 * Send a message to the device and wait for a response.
101 * @msgid: the message ID/number to send
102 * tx_msg: the request/transmit message payload
103 * tx_size: the size of the buffer pointed at by tx_msg
104 * rx_msg: the buffer to receive the response message payload. May be
105 * NULL if the caller only cares about the error code.
106 * rx_size: the size of the buffer pointed at by rx_msg
107 * @return the response message size if OK, -ve on error
109 int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
110 void *rx_msg, int rx_size);
113 #endif /* _MISC_H_ */