Thomas Chou | 4395e06 | 2015-10-07 20:20:51 +0800 | [diff] [blame] | 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 | */ |
| 19 | int 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 | */ |
| 29 | int 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. Day | f5abb40 | 2015-12-14 06:28:51 -0500 | [diff] [blame] | 35 | * @buf: pointer to buffer related to the request |
Thomas Chou | 4395e06 | 2015-10-07 20:20:51 +0800 | [diff] [blame] | 36 | * @return: 0 if OK, -ve on error |
| 37 | */ |
| 38 | int 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 | */ |
| 46 | struct 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. Day | f5abb40 | 2015-12-14 06:28:51 -0500 | [diff] [blame] | 73 | * @buf: pointer to buffer related to the request |
Thomas Chou | 4395e06 | 2015-10-07 20:20:51 +0800 | [diff] [blame] | 74 | * @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_ */ |