xref: /rk3399_rockchip-uboot/include/misc.h (revision 4395e06eb9907e22869cfe3bf6259a0f0cefca13)
1*4395e06eSThomas Chou /*
2*4395e06eSThomas Chou  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
3*4395e06eSThomas Chou  *
4*4395e06eSThomas Chou  * SPDX-License-Identifier:	GPL-2.0+
5*4395e06eSThomas Chou  */
6*4395e06eSThomas Chou 
7*4395e06eSThomas Chou #ifndef _MISC_H_
8*4395e06eSThomas Chou #define _MISC_H_
9*4395e06eSThomas Chou 
10*4395e06eSThomas Chou /*
11*4395e06eSThomas Chou  * Read the device to buffer, optional.
12*4395e06eSThomas Chou  *
13*4395e06eSThomas Chou  * @dev: the device
14*4395e06eSThomas Chou  * @offset: offset to read the device
15*4395e06eSThomas Chou  * @buf: pointer to data buffer
16*4395e06eSThomas Chou  * @size: data size in bytes to read the device
17*4395e06eSThomas Chou  * @return: 0 if OK, -ve on error
18*4395e06eSThomas Chou  */
19*4395e06eSThomas Chou int misc_read(struct udevice *dev, int offset, void *buf, int size);
20*4395e06eSThomas Chou /*
21*4395e06eSThomas Chou  * Write buffer to the device, optional.
22*4395e06eSThomas Chou  *
23*4395e06eSThomas Chou  * @dev: the device
24*4395e06eSThomas Chou  * @offset: offset to write the device
25*4395e06eSThomas Chou  * @buf: pointer to data buffer
26*4395e06eSThomas Chou  * @size: data size in bytes to write the device
27*4395e06eSThomas Chou  * @return: 0 if OK, -ve on error
28*4395e06eSThomas Chou  */
29*4395e06eSThomas Chou int misc_write(struct udevice *dev, int offset, void *buf, int size);
30*4395e06eSThomas Chou /*
31*4395e06eSThomas Chou  * Assert command to the device, optional.
32*4395e06eSThomas Chou  *
33*4395e06eSThomas Chou  * @dev: the device
34*4395e06eSThomas Chou  * @request: command to be sent to the device
35*4395e06eSThomas Chou  * @buf: pointer to buffer related to the requset
36*4395e06eSThomas Chou  * @return: 0 if OK, -ve on error
37*4395e06eSThomas Chou  */
38*4395e06eSThomas Chou int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
39*4395e06eSThomas Chou 
40*4395e06eSThomas Chou /*
41*4395e06eSThomas Chou  * struct misc_ops - Driver model Misc operations
42*4395e06eSThomas Chou  *
43*4395e06eSThomas Chou  * The uclass interface is implemented by all miscellaneous devices which
44*4395e06eSThomas Chou  * use driver model.
45*4395e06eSThomas Chou  */
46*4395e06eSThomas Chou struct misc_ops {
47*4395e06eSThomas Chou 	/*
48*4395e06eSThomas Chou 	 * Read the device to buffer, optional.
49*4395e06eSThomas Chou 	 *
50*4395e06eSThomas Chou 	 * @dev: the device
51*4395e06eSThomas Chou 	 * @offset: offset to read the device
52*4395e06eSThomas Chou 	 * @buf: pointer to data buffer
53*4395e06eSThomas Chou 	 * @size: data size in bytes to read the device
54*4395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
55*4395e06eSThomas Chou 	 */
56*4395e06eSThomas Chou 	int (*read)(struct udevice *dev, int offset, void *buf, int size);
57*4395e06eSThomas Chou 	/*
58*4395e06eSThomas Chou 	 * Write buffer to the device, optional.
59*4395e06eSThomas Chou 	 *
60*4395e06eSThomas Chou 	 * @dev: the device
61*4395e06eSThomas Chou 	 * @offset: offset to write the device
62*4395e06eSThomas Chou 	 * @buf: pointer to data buffer
63*4395e06eSThomas Chou 	 * @size: data size in bytes to write the device
64*4395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
65*4395e06eSThomas Chou 	 */
66*4395e06eSThomas Chou 	int (*write)(struct udevice *dev, int offset, const void *buf,
67*4395e06eSThomas Chou 		     int size);
68*4395e06eSThomas Chou 	/*
69*4395e06eSThomas Chou 	 * Assert command to the device, optional.
70*4395e06eSThomas Chou 	 *
71*4395e06eSThomas Chou 	 * @dev: the device
72*4395e06eSThomas Chou 	 * @request: command to be sent to the device
73*4395e06eSThomas Chou 	 * @buf: pointer to buffer related to the requset
74*4395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
75*4395e06eSThomas Chou 	 */
76*4395e06eSThomas Chou 	int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
77*4395e06eSThomas Chou };
78*4395e06eSThomas Chou 
79*4395e06eSThomas Chou #endif	/* _MISC_H_ */
80