2 * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
4 * SPDX-License-Identifier: GPL-2.0+
11 * Read the device to buffer, optional.
14 * @offset: offset to read the device
15 * @buf: pointer to data buffer
16 * @size: data size in bytes to read the device
17 * @return: 0 if OK, -ve on error
19 int misc_read(struct udevice *dev, int offset, void *buf, int size);
21 * Write buffer to the device, optional.
24 * @offset: offset to write the device
25 * @buf: pointer to data buffer
26 * @size: data size in bytes to write the device
27 * @return: 0 if OK, -ve on error
29 int misc_write(struct udevice *dev, int offset, void *buf, int size);
31 * Assert command to the device, optional.
34 * @request: command to be sent to the device
35 * @buf: pointer to buffer related to the request
36 * @return: 0 if OK, -ve on error
38 int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
41 * Send a message to the device and wait for a response.
43 * The caller provides the message type/ID and payload to be sent.
44 * The callee constructs any message header required, transmits it to the
45 * target, waits for a response, checks any error code in the response,
46 * strips any message header from the response, and returns the error code
47 * (or a parsed version of it) and the response message payload.
50 * @msgid: the message ID/number to send.
51 * tx_msg: the request/transmit message payload.
52 * tx_size: the size of the buffer pointed at by tx_msg.
53 * rx_msg: the buffer to receive the response message payload. May be NULL if
54 * the caller only cares about the error code.
55 * rx_size: the size of the buffer pointed at by rx_msg.
56 * @return the response message size if OK, -ve on error
58 int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
59 void *rx_msg, int rx_size);
62 * struct misc_ops - Driver model Misc operations
64 * The uclass interface is implemented by all miscellaneous devices which
69 * Read the device to buffer, optional.
72 * @offset: offset to read the device
73 * @buf: pointer to data buffer
74 * @size: data size in bytes to read the device
75 * @return: 0 if OK, -ve on error
77 int (*read)(struct udevice *dev, int offset, void *buf, int size);
79 * Write buffer to the device, optional.
82 * @offset: offset to write the device
83 * @buf: pointer to data buffer
84 * @size: data size in bytes to write the device
85 * @return: 0 if OK, -ve on error
87 int (*write)(struct udevice *dev, int offset, const void *buf,
90 * Assert command to the device, optional.
93 * @request: command to be sent to the device
94 * @buf: pointer to buffer related to the request
95 * @return: 0 if OK, -ve on error
97 int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
99 * Send a message to the device and wait for a response.
102 * @msgid: the message ID/number to send
103 * tx_msg: the request/transmit message payload
104 * tx_size: the size of the buffer pointed at by tx_msg
105 * rx_msg: the buffer to receive the response message payload. May be
106 * NULL if the caller only cares about the error code.
107 * rx_size: the size of the buffer pointed at by rx_msg
108 * @return the response message size if OK, -ve on error
110 int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
111 void *rx_msg, int rx_size);
114 #endif /* _MISC_H_ */