.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * pmbus.h - Common defines and structures for PMBus devices |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2010, 2011 Ericsson AB. |
---|
5 | 6 | * 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. |
---|
20 | 7 | */ |
---|
21 | 8 | |
---|
22 | 9 | #ifndef PMBUS_H |
---|
.. | .. |
---|
34 | 21 | PMBUS_ON_OFF_CONFIG = 0x02, |
---|
35 | 22 | PMBUS_CLEAR_FAULTS = 0x03, |
---|
36 | 23 | PMBUS_PHASE = 0x04, |
---|
| 24 | + |
---|
| 25 | + PMBUS_WRITE_PROTECT = 0x10, |
---|
37 | 26 | |
---|
38 | 27 | PMBUS_CAPABILITY = 0x19, |
---|
39 | 28 | PMBUS_QUERY = 0x1A, |
---|
.. | .. |
---|
130 | 119 | PMBUS_MFR_DATE = 0x9D, |
---|
131 | 120 | PMBUS_MFR_SERIAL = 0x9E, |
---|
132 | 121 | |
---|
| 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 | + |
---|
133 | 138 | /* |
---|
134 | 139 | * Virtual registers. |
---|
135 | 140 | * Useful to support attributes which are not supported by standard PMBus |
---|
.. | .. |
---|
217 | 222 | PMBUS_VIRT_PWM_ENABLE_2, |
---|
218 | 223 | PMBUS_VIRT_PWM_ENABLE_3, |
---|
219 | 224 | 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, |
---|
220 | 239 | }; |
---|
221 | 240 | |
---|
222 | 241 | /* |
---|
223 | 242 | * OPERATION |
---|
224 | 243 | */ |
---|
225 | 244 | #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) |
---|
226 | 254 | |
---|
227 | 255 | /* |
---|
228 | 256 | * CAPABILITY |
---|
.. | .. |
---|
291 | 319 | /* |
---|
292 | 320 | * STATUS_VOUT, STATUS_INPUT |
---|
293 | 321 | */ |
---|
| 322 | +#define PB_VOLTAGE_VIN_OFF BIT(3) |
---|
294 | 323 | #define PB_VOLTAGE_UV_FAULT BIT(4) |
---|
295 | 324 | #define PB_VOLTAGE_UV_WARNING BIT(5) |
---|
296 | 325 | #define PB_VOLTAGE_OV_WARNING BIT(6) |
---|
.. | .. |
---|
347 | 376 | }; |
---|
348 | 377 | |
---|
349 | 378 | #define PMBUS_PAGES 32 /* Per PMBus specification */ |
---|
| 379 | +#define PMBUS_PHASES 8 /* Maximum number of phases per page */ |
---|
350 | 380 | |
---|
351 | 381 | /* Functionality bit mask */ |
---|
352 | 382 | #define PMBUS_HAVE_VIN BIT(0) |
---|
.. | .. |
---|
371 | 401 | #define PMBUS_HAVE_STATUS_VMON BIT(19) |
---|
372 | 402 | #define PMBUS_HAVE_PWM12 BIT(20) |
---|
373 | 403 | #define PMBUS_HAVE_PWM34 BIT(21) |
---|
| 404 | +#define PMBUS_HAVE_SAMPLES BIT(22) |
---|
374 | 405 | |
---|
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 */ |
---|
376 | 408 | |
---|
377 | 409 | 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 }; |
---|
379 | 411 | |
---|
380 | 412 | struct pmbus_driver_info { |
---|
381 | 413 | int pages; /* Total number of pages */ |
---|
| 414 | + u8 phases[PMBUS_PAGES]; /* Number of phases per page */ |
---|
382 | 415 | 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 */ |
---|
384 | 417 | /* |
---|
385 | 418 | * Support one set of coefficients for each sensor type |
---|
386 | 419 | * Used for chips providing data in direct mode. |
---|
.. | .. |
---|
390 | 423 | int R[PSC_NUM_CLASSES]; /* exponent */ |
---|
391 | 424 | |
---|
392 | 425 | u32 func[PMBUS_PAGES]; /* Functionality, per page */ |
---|
| 426 | + u32 pfunc[PMBUS_PHASES];/* Functionality, per phase */ |
---|
393 | 427 | /* |
---|
394 | 428 | * The following functions map manufacturing specific register values |
---|
395 | 429 | * to PMBus standard register values. Specify only if mapping is |
---|
.. | .. |
---|
402 | 436 | * the standard register. |
---|
403 | 437 | */ |
---|
404 | 438 | 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); |
---|
406 | 441 | int (*write_word_data)(struct i2c_client *client, int page, int reg, |
---|
407 | 442 | u16 word); |
---|
408 | 443 | int (*write_byte)(struct i2c_client *client, int page, u8 value); |
---|
.. | .. |
---|
417 | 452 | /* Regulator functionality, if supported by this chip driver. */ |
---|
418 | 453 | int num_regulators; |
---|
419 | 454 | const struct regulator_desc *reg_desc; |
---|
| 455 | + |
---|
| 456 | + /* custom attributes */ |
---|
| 457 | + const struct attribute_group **groups; |
---|
420 | 458 | }; |
---|
421 | 459 | |
---|
422 | 460 | /* Regulator ops */ |
---|
.. | .. |
---|
438 | 476 | /* Function declarations */ |
---|
439 | 477 | |
---|
440 | 478 | 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); |
---|
444 | 484 | int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); |
---|
445 | 485 | int pmbus_write_byte(struct i2c_client *client, int page, u8 value); |
---|
446 | 486 | int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg, |
---|
.. | .. |
---|
450 | 490 | void pmbus_clear_faults(struct i2c_client *client); |
---|
451 | 491 | bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); |
---|
452 | 492 | 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); |
---|
455 | 494 | int pmbus_do_remove(struct i2c_client *client); |
---|
456 | 495 | const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client |
---|
457 | 496 | *client); |
---|