pmbus.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * pmbus.h - Common defines and structures for PMBus devices
  4. *
  5. * Copyright (c) 2010, 2011 Ericsson AB.
  6. * Copyright (c) 2012 Guenter Roeck
  7. */
  8. #ifndef PMBUS_H
  9. #define PMBUS_H
  10. #include <linux/bitops.h>
  11. #include <linux/regulator/driver.h>
  12. /*
  13. * Registers
  14. */
  15. enum pmbus_regs {
  16. PMBUS_PAGE = 0x00,
  17. PMBUS_OPERATION = 0x01,
  18. PMBUS_ON_OFF_CONFIG = 0x02,
  19. PMBUS_CLEAR_FAULTS = 0x03,
  20. PMBUS_PHASE = 0x04,
  21. PMBUS_WRITE_PROTECT = 0x10,
  22. PMBUS_CAPABILITY = 0x19,
  23. PMBUS_QUERY = 0x1A,
  24. PMBUS_VOUT_MODE = 0x20,
  25. PMBUS_VOUT_COMMAND = 0x21,
  26. PMBUS_VOUT_TRIM = 0x22,
  27. PMBUS_VOUT_CAL_OFFSET = 0x23,
  28. PMBUS_VOUT_MAX = 0x24,
  29. PMBUS_VOUT_MARGIN_HIGH = 0x25,
  30. PMBUS_VOUT_MARGIN_LOW = 0x26,
  31. PMBUS_VOUT_TRANSITION_RATE = 0x27,
  32. PMBUS_VOUT_DROOP = 0x28,
  33. PMBUS_VOUT_SCALE_LOOP = 0x29,
  34. PMBUS_VOUT_SCALE_MONITOR = 0x2A,
  35. PMBUS_COEFFICIENTS = 0x30,
  36. PMBUS_POUT_MAX = 0x31,
  37. PMBUS_FAN_CONFIG_12 = 0x3A,
  38. PMBUS_FAN_COMMAND_1 = 0x3B,
  39. PMBUS_FAN_COMMAND_2 = 0x3C,
  40. PMBUS_FAN_CONFIG_34 = 0x3D,
  41. PMBUS_FAN_COMMAND_3 = 0x3E,
  42. PMBUS_FAN_COMMAND_4 = 0x3F,
  43. PMBUS_VOUT_OV_FAULT_LIMIT = 0x40,
  44. PMBUS_VOUT_OV_FAULT_RESPONSE = 0x41,
  45. PMBUS_VOUT_OV_WARN_LIMIT = 0x42,
  46. PMBUS_VOUT_UV_WARN_LIMIT = 0x43,
  47. PMBUS_VOUT_UV_FAULT_LIMIT = 0x44,
  48. PMBUS_VOUT_UV_FAULT_RESPONSE = 0x45,
  49. PMBUS_IOUT_OC_FAULT_LIMIT = 0x46,
  50. PMBUS_IOUT_OC_FAULT_RESPONSE = 0x47,
  51. PMBUS_IOUT_OC_LV_FAULT_LIMIT = 0x48,
  52. PMBUS_IOUT_OC_LV_FAULT_RESPONSE = 0x49,
  53. PMBUS_IOUT_OC_WARN_LIMIT = 0x4A,
  54. PMBUS_IOUT_UC_FAULT_LIMIT = 0x4B,
  55. PMBUS_IOUT_UC_FAULT_RESPONSE = 0x4C,
  56. PMBUS_OT_FAULT_LIMIT = 0x4F,
  57. PMBUS_OT_FAULT_RESPONSE = 0x50,
  58. PMBUS_OT_WARN_LIMIT = 0x51,
  59. PMBUS_UT_WARN_LIMIT = 0x52,
  60. PMBUS_UT_FAULT_LIMIT = 0x53,
  61. PMBUS_UT_FAULT_RESPONSE = 0x54,
  62. PMBUS_VIN_OV_FAULT_LIMIT = 0x55,
  63. PMBUS_VIN_OV_FAULT_RESPONSE = 0x56,
  64. PMBUS_VIN_OV_WARN_LIMIT = 0x57,
  65. PMBUS_VIN_UV_WARN_LIMIT = 0x58,
  66. PMBUS_VIN_UV_FAULT_LIMIT = 0x59,
  67. PMBUS_IIN_OC_FAULT_LIMIT = 0x5B,
  68. PMBUS_IIN_OC_WARN_LIMIT = 0x5D,
  69. PMBUS_POUT_OP_FAULT_LIMIT = 0x68,
  70. PMBUS_POUT_OP_WARN_LIMIT = 0x6A,
  71. PMBUS_PIN_OP_WARN_LIMIT = 0x6B,
  72. PMBUS_STATUS_BYTE = 0x78,
  73. PMBUS_STATUS_WORD = 0x79,
  74. PMBUS_STATUS_VOUT = 0x7A,
  75. PMBUS_STATUS_IOUT = 0x7B,
  76. PMBUS_STATUS_INPUT = 0x7C,
  77. PMBUS_STATUS_TEMPERATURE = 0x7D,
  78. PMBUS_STATUS_CML = 0x7E,
  79. PMBUS_STATUS_OTHER = 0x7F,
  80. PMBUS_STATUS_MFR_SPECIFIC = 0x80,
  81. PMBUS_STATUS_FAN_12 = 0x81,
  82. PMBUS_STATUS_FAN_34 = 0x82,
  83. PMBUS_READ_VIN = 0x88,
  84. PMBUS_READ_IIN = 0x89,
  85. PMBUS_READ_VCAP = 0x8A,
  86. PMBUS_READ_VOUT = 0x8B,
  87. PMBUS_READ_IOUT = 0x8C,
  88. PMBUS_READ_TEMPERATURE_1 = 0x8D,
  89. PMBUS_READ_TEMPERATURE_2 = 0x8E,
  90. PMBUS_READ_TEMPERATURE_3 = 0x8F,
  91. PMBUS_READ_FAN_SPEED_1 = 0x90,
  92. PMBUS_READ_FAN_SPEED_2 = 0x91,
  93. PMBUS_READ_FAN_SPEED_3 = 0x92,
  94. PMBUS_READ_FAN_SPEED_4 = 0x93,
  95. PMBUS_READ_DUTY_CYCLE = 0x94,
  96. PMBUS_READ_FREQUENCY = 0x95,
  97. PMBUS_READ_POUT = 0x96,
  98. PMBUS_READ_PIN = 0x97,
  99. PMBUS_REVISION = 0x98,
  100. PMBUS_MFR_ID = 0x99,
  101. PMBUS_MFR_MODEL = 0x9A,
  102. PMBUS_MFR_REVISION = 0x9B,
  103. PMBUS_MFR_LOCATION = 0x9C,
  104. PMBUS_MFR_DATE = 0x9D,
  105. PMBUS_MFR_SERIAL = 0x9E,
  106. PMBUS_MFR_VIN_MIN = 0xA0,
  107. PMBUS_MFR_VIN_MAX = 0xA1,
  108. PMBUS_MFR_IIN_MAX = 0xA2,
  109. PMBUS_MFR_PIN_MAX = 0xA3,
  110. PMBUS_MFR_VOUT_MIN = 0xA4,
  111. PMBUS_MFR_VOUT_MAX = 0xA5,
  112. PMBUS_MFR_IOUT_MAX = 0xA6,
  113. PMBUS_MFR_POUT_MAX = 0xA7,
  114. PMBUS_IC_DEVICE_ID = 0xAD,
  115. PMBUS_IC_DEVICE_REV = 0xAE,
  116. PMBUS_MFR_MAX_TEMP_1 = 0xC0,
  117. PMBUS_MFR_MAX_TEMP_2 = 0xC1,
  118. PMBUS_MFR_MAX_TEMP_3 = 0xC2,
  119. /*
  120. * Virtual registers.
  121. * Useful to support attributes which are not supported by standard PMBus
  122. * registers but exist as manufacturer specific registers on individual chips.
  123. * Must be mapped to real registers in device specific code.
  124. *
  125. * Semantics:
  126. * Virtual registers are all word size.
  127. * READ registers are read-only; writes are either ignored or return an error.
  128. * RESET registers are read/write. Reading reset registers returns zero
  129. * (used for detection), writing any value causes the associated history to be
  130. * reset.
  131. * Virtual registers have to be handled in device specific driver code. Chip
  132. * driver code returns non-negative register values if a virtual register is
  133. * supported, or a negative error code if not. The chip driver may return
  134. * -ENODATA or any other error code in this case, though an error code other
  135. * than -ENODATA is handled more efficiently and thus preferred. Either case,
  136. * the calling PMBus core code will abort if the chip driver returns an error
  137. * code when reading or writing virtual registers.
  138. */
  139. PMBUS_VIRT_BASE = 0x100,
  140. PMBUS_VIRT_READ_TEMP_AVG,
  141. PMBUS_VIRT_READ_TEMP_MIN,
  142. PMBUS_VIRT_READ_TEMP_MAX,
  143. PMBUS_VIRT_RESET_TEMP_HISTORY,
  144. PMBUS_VIRT_READ_VIN_AVG,
  145. PMBUS_VIRT_READ_VIN_MIN,
  146. PMBUS_VIRT_READ_VIN_MAX,
  147. PMBUS_VIRT_RESET_VIN_HISTORY,
  148. PMBUS_VIRT_READ_IIN_AVG,
  149. PMBUS_VIRT_READ_IIN_MIN,
  150. PMBUS_VIRT_READ_IIN_MAX,
  151. PMBUS_VIRT_RESET_IIN_HISTORY,
  152. PMBUS_VIRT_READ_PIN_AVG,
  153. PMBUS_VIRT_READ_PIN_MIN,
  154. PMBUS_VIRT_READ_PIN_MAX,
  155. PMBUS_VIRT_RESET_PIN_HISTORY,
  156. PMBUS_VIRT_READ_POUT_AVG,
  157. PMBUS_VIRT_READ_POUT_MIN,
  158. PMBUS_VIRT_READ_POUT_MAX,
  159. PMBUS_VIRT_RESET_POUT_HISTORY,
  160. PMBUS_VIRT_READ_VOUT_AVG,
  161. PMBUS_VIRT_READ_VOUT_MIN,
  162. PMBUS_VIRT_READ_VOUT_MAX,
  163. PMBUS_VIRT_RESET_VOUT_HISTORY,
  164. PMBUS_VIRT_READ_IOUT_AVG,
  165. PMBUS_VIRT_READ_IOUT_MIN,
  166. PMBUS_VIRT_READ_IOUT_MAX,
  167. PMBUS_VIRT_RESET_IOUT_HISTORY,
  168. PMBUS_VIRT_READ_TEMP2_AVG,
  169. PMBUS_VIRT_READ_TEMP2_MIN,
  170. PMBUS_VIRT_READ_TEMP2_MAX,
  171. PMBUS_VIRT_RESET_TEMP2_HISTORY,
  172. PMBUS_VIRT_READ_VMON,
  173. PMBUS_VIRT_VMON_UV_WARN_LIMIT,
  174. PMBUS_VIRT_VMON_OV_WARN_LIMIT,
  175. PMBUS_VIRT_VMON_UV_FAULT_LIMIT,
  176. PMBUS_VIRT_VMON_OV_FAULT_LIMIT,
  177. PMBUS_VIRT_STATUS_VMON,
  178. /*
  179. * RPM and PWM Fan control
  180. *
  181. * Drivers wanting to expose PWM control must define the behaviour of
  182. * PMBUS_VIRT_PWM_[1-4] and PMBUS_VIRT_PWM_ENABLE_[1-4] in the
  183. * {read,write}_word_data callback.
  184. *
  185. * pmbus core provides a default implementation for
  186. * PMBUS_VIRT_FAN_TARGET_[1-4].
  187. *
  188. * TARGET, PWM and PWM_ENABLE members must be defined sequentially;
  189. * pmbus core uses the difference between the provided register and
  190. * it's _1 counterpart to calculate the FAN/PWM ID.
  191. */
  192. PMBUS_VIRT_FAN_TARGET_1,
  193. PMBUS_VIRT_FAN_TARGET_2,
  194. PMBUS_VIRT_FAN_TARGET_3,
  195. PMBUS_VIRT_FAN_TARGET_4,
  196. PMBUS_VIRT_PWM_1,
  197. PMBUS_VIRT_PWM_2,
  198. PMBUS_VIRT_PWM_3,
  199. PMBUS_VIRT_PWM_4,
  200. PMBUS_VIRT_PWM_ENABLE_1,
  201. PMBUS_VIRT_PWM_ENABLE_2,
  202. PMBUS_VIRT_PWM_ENABLE_3,
  203. PMBUS_VIRT_PWM_ENABLE_4,
  204. /* Samples for average
  205. *
  206. * Drivers wanting to expose functionality for changing the number of
  207. * samples used for average values should implement support in
  208. * {read,write}_word_data callback for either PMBUS_VIRT_SAMPLES if it
  209. * applies to all types of measurements, or any number of specific
  210. * PMBUS_VIRT_*_SAMPLES registers to allow for individual control.
  211. */
  212. PMBUS_VIRT_SAMPLES,
  213. PMBUS_VIRT_IN_SAMPLES,
  214. PMBUS_VIRT_CURR_SAMPLES,
  215. PMBUS_VIRT_POWER_SAMPLES,
  216. PMBUS_VIRT_TEMP_SAMPLES,
  217. };
  218. /*
  219. * OPERATION
  220. */
  221. #define PB_OPERATION_CONTROL_ON BIT(7)
  222. /*
  223. * WRITE_PROTECT
  224. */
  225. #define PB_WP_ALL BIT(7) /* all but WRITE_PROTECT */
  226. #define PB_WP_OP BIT(6) /* all but WP, OPERATION, PAGE */
  227. #define PB_WP_VOUT BIT(5) /* all but WP, OPERATION, PAGE, VOUT, ON_OFF */
  228. #define PB_WP_ANY (PB_WP_ALL | PB_WP_OP | PB_WP_VOUT)
  229. /*
  230. * CAPABILITY
  231. */
  232. #define PB_CAPABILITY_SMBALERT BIT(4)
  233. #define PB_CAPABILITY_ERROR_CHECK BIT(7)
  234. /*
  235. * VOUT_MODE
  236. */
  237. #define PB_VOUT_MODE_MODE_MASK 0xe0
  238. #define PB_VOUT_MODE_PARAM_MASK 0x1f
  239. #define PB_VOUT_MODE_LINEAR 0x00
  240. #define PB_VOUT_MODE_VID 0x20
  241. #define PB_VOUT_MODE_DIRECT 0x40
  242. /*
  243. * Fan configuration
  244. */
  245. #define PB_FAN_2_PULSE_MASK (BIT(0) | BIT(1))
  246. #define PB_FAN_2_RPM BIT(2)
  247. #define PB_FAN_2_INSTALLED BIT(3)
  248. #define PB_FAN_1_PULSE_MASK (BIT(4) | BIT(5))
  249. #define PB_FAN_1_RPM BIT(6)
  250. #define PB_FAN_1_INSTALLED BIT(7)
  251. enum pmbus_fan_mode { percent = 0, rpm };
  252. /*
  253. * STATUS_BYTE, STATUS_WORD (lower)
  254. */
  255. #define PB_STATUS_NONE_ABOVE BIT(0)
  256. #define PB_STATUS_CML BIT(1)
  257. #define PB_STATUS_TEMPERATURE BIT(2)
  258. #define PB_STATUS_VIN_UV BIT(3)
  259. #define PB_STATUS_IOUT_OC BIT(4)
  260. #define PB_STATUS_VOUT_OV BIT(5)
  261. #define PB_STATUS_OFF BIT(6)
  262. #define PB_STATUS_BUSY BIT(7)
  263. /*
  264. * STATUS_WORD (upper)
  265. */
  266. #define PB_STATUS_UNKNOWN BIT(8)
  267. #define PB_STATUS_OTHER BIT(9)
  268. #define PB_STATUS_FANS BIT(10)
  269. #define PB_STATUS_POWER_GOOD_N BIT(11)
  270. #define PB_STATUS_WORD_MFR BIT(12)
  271. #define PB_STATUS_INPUT BIT(13)
  272. #define PB_STATUS_IOUT_POUT BIT(14)
  273. #define PB_STATUS_VOUT BIT(15)
  274. /*
  275. * STATUS_IOUT
  276. */
  277. #define PB_POUT_OP_WARNING BIT(0)
  278. #define PB_POUT_OP_FAULT BIT(1)
  279. #define PB_POWER_LIMITING BIT(2)
  280. #define PB_CURRENT_SHARE_FAULT BIT(3)
  281. #define PB_IOUT_UC_FAULT BIT(4)
  282. #define PB_IOUT_OC_WARNING BIT(5)
  283. #define PB_IOUT_OC_LV_FAULT BIT(6)
  284. #define PB_IOUT_OC_FAULT BIT(7)
  285. /*
  286. * STATUS_VOUT, STATUS_INPUT
  287. */
  288. #define PB_VOLTAGE_VIN_OFF BIT(3)
  289. #define PB_VOLTAGE_UV_FAULT BIT(4)
  290. #define PB_VOLTAGE_UV_WARNING BIT(5)
  291. #define PB_VOLTAGE_OV_WARNING BIT(6)
  292. #define PB_VOLTAGE_OV_FAULT BIT(7)
  293. /*
  294. * STATUS_INPUT
  295. */
  296. #define PB_PIN_OP_WARNING BIT(0)
  297. #define PB_IIN_OC_WARNING BIT(1)
  298. #define PB_IIN_OC_FAULT BIT(2)
  299. /*
  300. * STATUS_TEMPERATURE
  301. */
  302. #define PB_TEMP_UT_FAULT BIT(4)
  303. #define PB_TEMP_UT_WARNING BIT(5)
  304. #define PB_TEMP_OT_WARNING BIT(6)
  305. #define PB_TEMP_OT_FAULT BIT(7)
  306. /*
  307. * STATUS_FAN
  308. */
  309. #define PB_FAN_AIRFLOW_WARNING BIT(0)
  310. #define PB_FAN_AIRFLOW_FAULT BIT(1)
  311. #define PB_FAN_FAN2_SPEED_OVERRIDE BIT(2)
  312. #define PB_FAN_FAN1_SPEED_OVERRIDE BIT(3)
  313. #define PB_FAN_FAN2_WARNING BIT(4)
  314. #define PB_FAN_FAN1_WARNING BIT(5)
  315. #define PB_FAN_FAN2_FAULT BIT(6)
  316. #define PB_FAN_FAN1_FAULT BIT(7)
  317. /*
  318. * CML_FAULT_STATUS
  319. */
  320. #define PB_CML_FAULT_OTHER_MEM_LOGIC BIT(0)
  321. #define PB_CML_FAULT_OTHER_COMM BIT(1)
  322. #define PB_CML_FAULT_PROCESSOR BIT(3)
  323. #define PB_CML_FAULT_MEMORY BIT(4)
  324. #define PB_CML_FAULT_PACKET_ERROR BIT(5)
  325. #define PB_CML_FAULT_INVALID_DATA BIT(6)
  326. #define PB_CML_FAULT_INVALID_COMMAND BIT(7)
  327. enum pmbus_sensor_classes {
  328. PSC_VOLTAGE_IN = 0,
  329. PSC_VOLTAGE_OUT,
  330. PSC_CURRENT_IN,
  331. PSC_CURRENT_OUT,
  332. PSC_POWER,
  333. PSC_TEMPERATURE,
  334. PSC_FAN,
  335. PSC_PWM,
  336. PSC_NUM_CLASSES /* Number of power sensor classes */
  337. };
  338. #define PMBUS_PAGES 32 /* Per PMBus specification */
  339. #define PMBUS_PHASES 10 /* Maximum number of phases per page */
  340. /* Functionality bit mask */
  341. #define PMBUS_HAVE_VIN BIT(0)
  342. #define PMBUS_HAVE_VCAP BIT(1)
  343. #define PMBUS_HAVE_VOUT BIT(2)
  344. #define PMBUS_HAVE_IIN BIT(3)
  345. #define PMBUS_HAVE_IOUT BIT(4)
  346. #define PMBUS_HAVE_PIN BIT(5)
  347. #define PMBUS_HAVE_POUT BIT(6)
  348. #define PMBUS_HAVE_FAN12 BIT(7)
  349. #define PMBUS_HAVE_FAN34 BIT(8)
  350. #define PMBUS_HAVE_TEMP BIT(9)
  351. #define PMBUS_HAVE_TEMP2 BIT(10)
  352. #define PMBUS_HAVE_TEMP3 BIT(11)
  353. #define PMBUS_HAVE_STATUS_VOUT BIT(12)
  354. #define PMBUS_HAVE_STATUS_IOUT BIT(13)
  355. #define PMBUS_HAVE_STATUS_INPUT BIT(14)
  356. #define PMBUS_HAVE_STATUS_TEMP BIT(15)
  357. #define PMBUS_HAVE_STATUS_FAN12 BIT(16)
  358. #define PMBUS_HAVE_STATUS_FAN34 BIT(17)
  359. #define PMBUS_HAVE_VMON BIT(18)
  360. #define PMBUS_HAVE_STATUS_VMON BIT(19)
  361. #define PMBUS_HAVE_PWM12 BIT(20)
  362. #define PMBUS_HAVE_PWM34 BIT(21)
  363. #define PMBUS_HAVE_SAMPLES BIT(22)
  364. #define PMBUS_PHASE_VIRTUAL BIT(30) /* Phases on this page are virtual */
  365. #define PMBUS_PAGE_VIRTUAL BIT(31) /* Page is virtual */
  366. enum pmbus_data_format { linear = 0, ieee754, direct, vid };
  367. enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv };
  368. struct pmbus_driver_info {
  369. int pages; /* Total number of pages */
  370. u8 phases[PMBUS_PAGES]; /* Number of phases per page */
  371. enum pmbus_data_format format[PSC_NUM_CLASSES];
  372. enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */
  373. /*
  374. * Support one set of coefficients for each sensor type
  375. * Used for chips providing data in direct mode.
  376. */
  377. int m[PSC_NUM_CLASSES]; /* mantissa for direct data format */
  378. int b[PSC_NUM_CLASSES]; /* offset */
  379. int R[PSC_NUM_CLASSES]; /* exponent */
  380. u32 func[PMBUS_PAGES]; /* Functionality, per page */
  381. u32 pfunc[PMBUS_PHASES];/* Functionality, per phase */
  382. /*
  383. * The following functions map manufacturing specific register values
  384. * to PMBus standard register values. Specify only if mapping is
  385. * necessary.
  386. * Functions return the register value (read) or zero (write) if
  387. * successful. A return value of -ENODATA indicates that there is no
  388. * manufacturer specific register, but that a standard PMBus register
  389. * may exist. Any other negative return value indicates that the
  390. * register does not exist, and that no attempt should be made to read
  391. * the standard register.
  392. */
  393. int (*read_byte_data)(struct i2c_client *client, int page, int reg);
  394. int (*read_word_data)(struct i2c_client *client, int page, int phase,
  395. int reg);
  396. int (*write_byte_data)(struct i2c_client *client, int page, int reg,
  397. u8 byte);
  398. int (*write_word_data)(struct i2c_client *client, int page, int reg,
  399. u16 word);
  400. int (*write_byte)(struct i2c_client *client, int page, u8 value);
  401. /*
  402. * The identify function determines supported PMBus functionality.
  403. * This function is only necessary if a chip driver supports multiple
  404. * chips, and the chip functionality is not pre-determined.
  405. */
  406. int (*identify)(struct i2c_client *client,
  407. struct pmbus_driver_info *info);
  408. /* Regulator functionality, if supported by this chip driver. */
  409. int num_regulators;
  410. const struct regulator_desc *reg_desc;
  411. /* custom attributes */
  412. const struct attribute_group **groups;
  413. };
  414. /* Regulator ops */
  415. extern const struct regulator_ops pmbus_regulator_ops;
  416. /* Macros for filling in array of struct regulator_desc */
  417. #define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step) \
  418. [_id] = { \
  419. .name = (_name # _id), \
  420. .id = (_id), \
  421. .of_match = of_match_ptr(_name # _id), \
  422. .regulators_node = of_match_ptr("regulators"), \
  423. .ops = &pmbus_regulator_ops, \
  424. .type = REGULATOR_VOLTAGE, \
  425. .owner = THIS_MODULE, \
  426. .n_voltages = _voltages, \
  427. .uV_step = _step, \
  428. }
  429. #define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, 0)
  430. /* Function declarations */
  431. void pmbus_clear_cache(struct i2c_client *client);
  432. void pmbus_set_update(struct i2c_client *client, u8 reg, bool update);
  433. int pmbus_set_page(struct i2c_client *client, int page, int phase);
  434. int pmbus_read_word_data(struct i2c_client *client, int page, int phase,
  435. u8 reg);
  436. int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
  437. u16 word);
  438. int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
  439. int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
  440. int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
  441. u8 value);
  442. int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
  443. u8 mask, u8 value);
  444. void pmbus_clear_faults(struct i2c_client *client);
  445. bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
  446. bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
  447. int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
  448. const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
  449. *client);
  450. int pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id,
  451. enum pmbus_fan_mode mode);
  452. int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id,
  453. enum pmbus_fan_mode mode);
  454. int pmbus_update_fan(struct i2c_client *client, int page, int id,
  455. u8 config, u8 mask, u16 command);
  456. struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client);
  457. #endif /* PMBUS_H */