blob: 2b788143b54cc975e2e86d0af92f29ec72e90374 [file] [log] [blame]
Thomas Chou4395e062015-10-07 20:20:51 +08001/*
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
Robert P. J. Dayf5abb402015-12-14 06:28:51 -050035 * @buf: pointer to buffer related to the request
Thomas Chou4395e062015-10-07 20:20:51 +080036 * @return: 0 if OK, -ve on error
37 */
38int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
39
40/*
41 * struct misc_ops - Driver model Misc operations
42 *
43 * The uclass interface is implemented by all miscellaneous devices which
44 * use driver model.
45 */
46struct misc_ops {
47 /*
48 * Read the device to buffer, optional.
49 *
50 * @dev: the device
51 * @offset: offset to read the device
52 * @buf: pointer to data buffer
53 * @size: data size in bytes to read the device
54 * @return: 0 if OK, -ve on error
55 */
56 int (*read)(struct udevice *dev, int offset, void *buf, int size);
57 /*
58 * Write buffer to the device, optional.
59 *
60 * @dev: the device
61 * @offset: offset to write the device
62 * @buf: pointer to data buffer
63 * @size: data size in bytes to write the device
64 * @return: 0 if OK, -ve on error
65 */
66 int (*write)(struct udevice *dev, int offset, const void *buf,
67 int size);
68 /*
69 * Assert command to the device, optional.
70 *
71 * @dev: the device
72 * @request: command to be sent to the device
Robert P. J. Dayf5abb402015-12-14 06:28:51 -050073 * @buf: pointer to buffer related to the request
Thomas Chou4395e062015-10-07 20:20:51 +080074 * @return: 0 if OK, -ve on error
75 */
76 int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
77};
78
79#endif /* _MISC_H_ */