pch.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2015 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #ifndef __pch_h
  7. #define __pch_h
  8. #include <linux/bitops.h>
  9. #define PCH_RCBA 0xf0
  10. #define BIOS_CTRL_BIOSWE BIT(0)
  11. /* All the supported PCH ioctls */
  12. enum pch_req_t {
  13. /* Returns HDA config info if Azalia V1CTL enabled, -ENOENT if not */
  14. PCH_REQ_HDA_CONFIG,
  15. /* Fills out a struct pch_pmbase_info if available */
  16. PCH_REQ_PMBASE_INFO,
  17. PCH_REQ_TEST1, /* Test requests for sandbox driver */
  18. PCH_REQ_TEST2,
  19. PCH_REQ_TEST3,
  20. PCH_REQ_COUNT, /* Number of ioctrls supported */
  21. };
  22. /**
  23. * struct pch_pmbase_info - Information filled in by PCH_REQ_PMBASE_INFO
  24. *
  25. * @pmbase: IO address of power-management controller
  26. * @gpio0_en_ofs: Offset of GPIO0 enable register
  27. * @pm1_sts_ofs: Offset of status register
  28. * @pm1_cnt_ofs: Offset of control register
  29. */
  30. struct pch_pmbase_info {
  31. u16 base;
  32. u8 gpio0_en_ofs;
  33. u8 pm1_sts_ofs;
  34. u8 pm1_cnt_ofs;
  35. };
  36. /**
  37. * struct pch_ops - Operations for the Platform Controller Hub
  38. *
  39. * Consider using ioctl() to add rarely used or driver-specific operations.
  40. */
  41. struct pch_ops {
  42. /**
  43. * get_spi_base() - get the address of SPI base
  44. *
  45. * @dev: PCH device to check
  46. * @sbasep: Returns address of SPI base if available, else 0
  47. * @return 0 if OK, -ve on error (e.g. there is no SPI base)
  48. */
  49. int (*get_spi_base)(struct udevice *dev, ulong *sbasep);
  50. /**
  51. * set_spi_protect() - set whether SPI flash is protected or not
  52. *
  53. * @dev: PCH device to adjust
  54. * @protect: true to protect, false to unprotect
  55. *
  56. * @return 0 on success, -ENOSYS if not implemented
  57. */
  58. int (*set_spi_protect)(struct udevice *dev, bool protect);
  59. /**
  60. * get_gpio_base() - get the address of GPIO base
  61. *
  62. * @dev: PCH device to check
  63. * @gbasep: Returns address of GPIO base if available, else 0
  64. * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
  65. */
  66. int (*get_gpio_base)(struct udevice *dev, u32 *gbasep);
  67. /**
  68. * get_io_base() - get the address of IO base
  69. *
  70. * @dev: PCH device to check
  71. * @iobasep: Returns address of IO base if available, else 0
  72. * @return 0 if OK, -ve on error (e.g. there is no IO base)
  73. */
  74. int (*get_io_base)(struct udevice *dev, u32 *iobasep);
  75. /**
  76. * ioctl() - perform misc read/write operations
  77. *
  78. * This is a catch-all operation intended to avoid adding lots of
  79. * methods to this uclass, of which few are commonly used. Uncommon
  80. * operations that pertain only to a few devices in this uclass should
  81. * use this method instead of adding new methods.
  82. *
  83. * @dev: PCH device to check
  84. * @req: PCH request ID
  85. * @data: Input/output data
  86. * @size: Size of input data (and maximum size of output data)
  87. * @return size of output data on sucesss, -ve on error
  88. */
  89. int (*ioctl)(struct udevice *dev, enum pch_req_t req, void *data,
  90. int size);
  91. };
  92. #define pch_get_ops(dev) ((struct pch_ops *)(dev)->driver->ops)
  93. /**
  94. * pch_get_spi_base() - get the address of SPI base
  95. *
  96. * @dev: PCH device to check
  97. * @sbasep: Returns address of SPI base if available, else 0
  98. * @return 0 if OK, -ve on error (e.g. there is no SPI base)
  99. */
  100. int pch_get_spi_base(struct udevice *dev, ulong *sbasep);
  101. /**
  102. * set_spi_protect() - set whether SPI flash is protected or not
  103. *
  104. * @dev: PCH device to adjust
  105. * @protect: true to protect, false to unprotect
  106. *
  107. * @return 0 on success, -ENOSYS if not implemented
  108. */
  109. int pch_set_spi_protect(struct udevice *dev, bool protect);
  110. /**
  111. * pch_get_gpio_base() - get the address of GPIO base
  112. *
  113. * @dev: PCH device to check
  114. * @gbasep: Returns address of GPIO base if available, else 0
  115. * @return 0 if OK, -ve on error (e.g. there is no GPIO base)
  116. */
  117. int pch_get_gpio_base(struct udevice *dev, u32 *gbasep);
  118. /**
  119. * pch_get_io_base() - get the address of IO base
  120. *
  121. * @dev: PCH device to check
  122. * @iobasep: Returns address of IO base if available, else 0
  123. * @return 0 if OK, -ve on error (e.g. there is no IO base)
  124. */
  125. int pch_get_io_base(struct udevice *dev, u32 *iobasep);
  126. /**
  127. * pch_ioctl() - perform misc read/write operations
  128. *
  129. * This is a catch-all operation intended to avoid adding lots of
  130. * methods to this uclass, of which few are commonly used. Uncommon
  131. * operations that pertain only to a few devices in this uclass should
  132. * use this method instead of adding new methods.
  133. *
  134. * @dev: PCH device to check
  135. * @req: PCH request ID
  136. * @data: Input/output data
  137. * @size: Size of input data (and maximum size of output data)
  138. * @return size of output data on sucesss, -ve on error
  139. */
  140. int pch_ioctl(struct udevice *dev, ulong req, void *data, int size);
  141. #endif