hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/hwmon/pmbus/pmbus.h
....@@ -1,22 +1,9 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * pmbus.h - Common defines and structures for PMBus devices
34 *
45 * Copyright (c) 2010, 2011 Ericsson AB.
56 * Copyright (c) 2012 Guenter Roeck
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, write to the Free Software
19
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
207 */
218
229 #ifndef PMBUS_H
....@@ -34,6 +21,8 @@
3421 PMBUS_ON_OFF_CONFIG = 0x02,
3522 PMBUS_CLEAR_FAULTS = 0x03,
3623 PMBUS_PHASE = 0x04,
24
+
25
+ PMBUS_WRITE_PROTECT = 0x10,
3726
3827 PMBUS_CAPABILITY = 0x19,
3928 PMBUS_QUERY = 0x1A,
....@@ -130,6 +119,22 @@
130119 PMBUS_MFR_DATE = 0x9D,
131120 PMBUS_MFR_SERIAL = 0x9E,
132121
122
+ PMBUS_MFR_VIN_MIN = 0xA0,
123
+ PMBUS_MFR_VIN_MAX = 0xA1,
124
+ PMBUS_MFR_IIN_MAX = 0xA2,
125
+ PMBUS_MFR_PIN_MAX = 0xA3,
126
+ PMBUS_MFR_VOUT_MIN = 0xA4,
127
+ PMBUS_MFR_VOUT_MAX = 0xA5,
128
+ PMBUS_MFR_IOUT_MAX = 0xA6,
129
+ PMBUS_MFR_POUT_MAX = 0xA7,
130
+
131
+ PMBUS_IC_DEVICE_ID = 0xAD,
132
+ PMBUS_IC_DEVICE_REV = 0xAE,
133
+
134
+ PMBUS_MFR_MAX_TEMP_1 = 0xC0,
135
+ PMBUS_MFR_MAX_TEMP_2 = 0xC1,
136
+ PMBUS_MFR_MAX_TEMP_3 = 0xC2,
137
+
133138 /*
134139 * Virtual registers.
135140 * Useful to support attributes which are not supported by standard PMBus
....@@ -217,12 +222,35 @@
217222 PMBUS_VIRT_PWM_ENABLE_2,
218223 PMBUS_VIRT_PWM_ENABLE_3,
219224 PMBUS_VIRT_PWM_ENABLE_4,
225
+
226
+ /* Samples for average
227
+ *
228
+ * Drivers wanting to expose functionality for changing the number of
229
+ * samples used for average values should implement support in
230
+ * {read,write}_word_data callback for either PMBUS_VIRT_SAMPLES if it
231
+ * applies to all types of measurements, or any number of specific
232
+ * PMBUS_VIRT_*_SAMPLES registers to allow for individual control.
233
+ */
234
+ PMBUS_VIRT_SAMPLES,
235
+ PMBUS_VIRT_IN_SAMPLES,
236
+ PMBUS_VIRT_CURR_SAMPLES,
237
+ PMBUS_VIRT_POWER_SAMPLES,
238
+ PMBUS_VIRT_TEMP_SAMPLES,
220239 };
221240
222241 /*
223242 * OPERATION
224243 */
225244 #define PB_OPERATION_CONTROL_ON BIT(7)
245
+
246
+/*
247
+ * WRITE_PROTECT
248
+ */
249
+#define PB_WP_ALL BIT(7) /* all but WRITE_PROTECT */
250
+#define PB_WP_OP BIT(6) /* all but WP, OPERATION, PAGE */
251
+#define PB_WP_VOUT BIT(5) /* all but WP, OPERATION, PAGE, VOUT, ON_OFF */
252
+
253
+#define PB_WP_ANY (PB_WP_ALL | PB_WP_OP | PB_WP_VOUT)
226254
227255 /*
228256 * CAPABILITY
....@@ -291,6 +319,7 @@
291319 /*
292320 * STATUS_VOUT, STATUS_INPUT
293321 */
322
+#define PB_VOLTAGE_VIN_OFF BIT(3)
294323 #define PB_VOLTAGE_UV_FAULT BIT(4)
295324 #define PB_VOLTAGE_UV_WARNING BIT(5)
296325 #define PB_VOLTAGE_OV_WARNING BIT(6)
....@@ -347,6 +376,7 @@
347376 };
348377
349378 #define PMBUS_PAGES 32 /* Per PMBus specification */
379
+#define PMBUS_PHASES 8 /* Maximum number of phases per page */
350380
351381 /* Functionality bit mask */
352382 #define PMBUS_HAVE_VIN BIT(0)
....@@ -371,16 +401,19 @@
371401 #define PMBUS_HAVE_STATUS_VMON BIT(19)
372402 #define PMBUS_HAVE_PWM12 BIT(20)
373403 #define PMBUS_HAVE_PWM34 BIT(21)
404
+#define PMBUS_HAVE_SAMPLES BIT(22)
374405
375
-#define PMBUS_PAGE_VIRTUAL BIT(31)
406
+#define PMBUS_PHASE_VIRTUAL BIT(30) /* Phases on this page are virtual */
407
+#define PMBUS_PAGE_VIRTUAL BIT(31) /* Page is virtual */
376408
377409 enum pmbus_data_format { linear = 0, direct, vid };
378
-enum vrm_version { vr11 = 0, vr12, vr13 };
410
+enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv };
379411
380412 struct pmbus_driver_info {
381413 int pages; /* Total number of pages */
414
+ u8 phases[PMBUS_PAGES]; /* Number of phases per page */
382415 enum pmbus_data_format format[PSC_NUM_CLASSES];
383
- enum vrm_version vrm_version;
416
+ enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */
384417 /*
385418 * Support one set of coefficients for each sensor type
386419 * Used for chips providing data in direct mode.
....@@ -390,6 +423,7 @@
390423 int R[PSC_NUM_CLASSES]; /* exponent */
391424
392425 u32 func[PMBUS_PAGES]; /* Functionality, per page */
426
+ u32 pfunc[PMBUS_PHASES];/* Functionality, per phase */
393427 /*
394428 * The following functions map manufacturing specific register values
395429 * to PMBus standard register values. Specify only if mapping is
....@@ -402,7 +436,8 @@
402436 * the standard register.
403437 */
404438 int (*read_byte_data)(struct i2c_client *client, int page, int reg);
405
- int (*read_word_data)(struct i2c_client *client, int page, int reg);
439
+ int (*read_word_data)(struct i2c_client *client, int page, int phase,
440
+ int reg);
406441 int (*write_word_data)(struct i2c_client *client, int page, int reg,
407442 u16 word);
408443 int (*write_byte)(struct i2c_client *client, int page, u8 value);
....@@ -417,6 +452,9 @@
417452 /* Regulator functionality, if supported by this chip driver. */
418453 int num_regulators;
419454 const struct regulator_desc *reg_desc;
455
+
456
+ /* custom attributes */
457
+ const struct attribute_group **groups;
420458 };
421459
422460 /* Regulator ops */
....@@ -438,9 +476,11 @@
438476 /* Function declarations */
439477
440478 void pmbus_clear_cache(struct i2c_client *client);
441
-int pmbus_set_page(struct i2c_client *client, int page);
442
-int pmbus_read_word_data(struct i2c_client *client, int page, u8 reg);
443
-int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg, u16 word);
479
+int pmbus_set_page(struct i2c_client *client, int page, int phase);
480
+int pmbus_read_word_data(struct i2c_client *client, int page, int phase,
481
+ u8 reg);
482
+int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
483
+ u16 word);
444484 int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
445485 int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
446486 int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
....@@ -450,8 +490,7 @@
450490 void pmbus_clear_faults(struct i2c_client *client);
451491 bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
452492 bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
453
-int pmbus_do_probe(struct i2c_client *client, const struct i2c_device_id *id,
454
- struct pmbus_driver_info *info);
493
+int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
455494 int pmbus_do_remove(struct i2c_client *client);
456495 const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
457496 *client);