]> git.ipfire.org Git - people/ms/u-boot.git/blame - include/misc.h
common: arm: davinci: Move header file out of common
[people/ms/u-boot.git] / include / misc.h
CommitLineData
4395e06e
TC
1/*
2 * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#ifndef _MISC_H_
8#define _MISC_H_
9
10/*
11 * Read the device to buffer, optional.
12 *
13 * @dev: the device
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
18 */
19int misc_read(struct udevice *dev, int offset, void *buf, int size);
20/*
21 * Write buffer to the device, optional.
22 *
23 * @dev: the device
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
28 */
29int misc_write(struct udevice *dev, int offset, void *buf, int size);
30/*
31 * Assert command to the device, optional.
32 *
33 * @dev: the device
34 * @request: command to be sent to the device
f5abb409 35 * @buf: pointer to buffer related to the request
4395e06e
TC
36 * @return: 0 if OK, -ve on error
37 */
38int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
39
b647f554
SW
40/*
41 * Send a message to the device and wait for a response.
42 *
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.
48 *
49 * @dev: the device.
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
57 */
58int misc_call(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
59 void *rx_msg, int rx_size);
60
4395e06e
TC
61/*
62 * struct misc_ops - Driver model Misc operations
63 *
64 * The uclass interface is implemented by all miscellaneous devices which
65 * use driver model.
66 */
67struct misc_ops {
68 /*
69 * Read the device to buffer, optional.
70 *
71 * @dev: the device
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
76 */
77 int (*read)(struct udevice *dev, int offset, void *buf, int size);
78 /*
79 * Write buffer to the device, optional.
80 *
81 * @dev: the device
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
86 */
87 int (*write)(struct udevice *dev, int offset, const void *buf,
88 int size);
89 /*
90 * Assert command to the device, optional.
91 *
92 * @dev: the device
93 * @request: command to be sent to the device
f5abb409 94 * @buf: pointer to buffer related to the request
4395e06e
TC
95 * @return: 0 if OK, -ve on error
96 */
97 int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
b647f554
SW
98 /*
99 * Send a message to the device and wait for a response.
100 *
101 * @dev: the device
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
109 */
110 int (*call)(struct udevice *dev, int msgid, void *tx_msg, int tx_size,
111 void *rx_msg, int rx_size);
4395e06e
TC
112};
113
114#endif /* _MISC_H_ */