xref: /rk3399_rockchip-uboot/include/misc.h (revision f5abb40997eb68ef11102b726d8be747b3dd126e)
14395e06eSThomas Chou /*
24395e06eSThomas Chou  * Copyright (C) 2015 Thomas Chou <thomas@wytron.com.tw>
34395e06eSThomas Chou  *
44395e06eSThomas Chou  * SPDX-License-Identifier:	GPL-2.0+
54395e06eSThomas Chou  */
64395e06eSThomas Chou 
74395e06eSThomas Chou #ifndef _MISC_H_
84395e06eSThomas Chou #define _MISC_H_
94395e06eSThomas Chou 
104395e06eSThomas Chou /*
114395e06eSThomas Chou  * Read the device to buffer, optional.
124395e06eSThomas Chou  *
134395e06eSThomas Chou  * @dev: the device
144395e06eSThomas Chou  * @offset: offset to read the device
154395e06eSThomas Chou  * @buf: pointer to data buffer
164395e06eSThomas Chou  * @size: data size in bytes to read the device
174395e06eSThomas Chou  * @return: 0 if OK, -ve on error
184395e06eSThomas Chou  */
194395e06eSThomas Chou int misc_read(struct udevice *dev, int offset, void *buf, int size);
204395e06eSThomas Chou /*
214395e06eSThomas Chou  * Write buffer to the device, optional.
224395e06eSThomas Chou  *
234395e06eSThomas Chou  * @dev: the device
244395e06eSThomas Chou  * @offset: offset to write the device
254395e06eSThomas Chou  * @buf: pointer to data buffer
264395e06eSThomas Chou  * @size: data size in bytes to write the device
274395e06eSThomas Chou  * @return: 0 if OK, -ve on error
284395e06eSThomas Chou  */
294395e06eSThomas Chou int misc_write(struct udevice *dev, int offset, void *buf, int size);
304395e06eSThomas Chou /*
314395e06eSThomas Chou  * Assert command to the device, optional.
324395e06eSThomas Chou  *
334395e06eSThomas Chou  * @dev: the device
344395e06eSThomas Chou  * @request: command to be sent to the device
35*f5abb409SRobert P. J. Day  * @buf: pointer to buffer related to the request
364395e06eSThomas Chou  * @return: 0 if OK, -ve on error
374395e06eSThomas Chou  */
384395e06eSThomas Chou int misc_ioctl(struct udevice *dev, unsigned long request, void *buf);
394395e06eSThomas Chou 
404395e06eSThomas Chou /*
414395e06eSThomas Chou  * struct misc_ops - Driver model Misc operations
424395e06eSThomas Chou  *
434395e06eSThomas Chou  * The uclass interface is implemented by all miscellaneous devices which
444395e06eSThomas Chou  * use driver model.
454395e06eSThomas Chou  */
464395e06eSThomas Chou struct misc_ops {
474395e06eSThomas Chou 	/*
484395e06eSThomas Chou 	 * Read the device to buffer, optional.
494395e06eSThomas Chou 	 *
504395e06eSThomas Chou 	 * @dev: the device
514395e06eSThomas Chou 	 * @offset: offset to read the device
524395e06eSThomas Chou 	 * @buf: pointer to data buffer
534395e06eSThomas Chou 	 * @size: data size in bytes to read the device
544395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
554395e06eSThomas Chou 	 */
564395e06eSThomas Chou 	int (*read)(struct udevice *dev, int offset, void *buf, int size);
574395e06eSThomas Chou 	/*
584395e06eSThomas Chou 	 * Write buffer to the device, optional.
594395e06eSThomas Chou 	 *
604395e06eSThomas Chou 	 * @dev: the device
614395e06eSThomas Chou 	 * @offset: offset to write the device
624395e06eSThomas Chou 	 * @buf: pointer to data buffer
634395e06eSThomas Chou 	 * @size: data size in bytes to write the device
644395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
654395e06eSThomas Chou 	 */
664395e06eSThomas Chou 	int (*write)(struct udevice *dev, int offset, const void *buf,
674395e06eSThomas Chou 		     int size);
684395e06eSThomas Chou 	/*
694395e06eSThomas Chou 	 * Assert command to the device, optional.
704395e06eSThomas Chou 	 *
714395e06eSThomas Chou 	 * @dev: the device
724395e06eSThomas Chou 	 * @request: command to be sent to the device
73*f5abb409SRobert P. J. Day 	 * @buf: pointer to buffer related to the request
744395e06eSThomas Chou 	 * @return: 0 if OK, -ve on error
754395e06eSThomas Chou 	 */
764395e06eSThomas Chou 	int (*ioctl)(struct udevice *dev, unsigned long request, void *buf);
774395e06eSThomas Chou };
784395e06eSThomas Chou 
794395e06eSThomas Chou #endif	/* _MISC_H_ */
80