misc.h 2.0 KB

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