Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * pmbus.h - Common defines and structures for PMBus devices
0004  *
0005  * Copyright (c) 2010, 2011 Ericsson AB.
0006  * Copyright (c) 2012 Guenter Roeck
0007  */
0008 
0009 #ifndef PMBUS_H
0010 #define PMBUS_H
0011 
0012 #include <linux/bitops.h>
0013 #include <linux/regulator/driver.h>
0014 
0015 /*
0016  * Registers
0017  */
0018 enum pmbus_regs {
0019     PMBUS_PAGE          = 0x00,
0020     PMBUS_OPERATION         = 0x01,
0021     PMBUS_ON_OFF_CONFIG     = 0x02,
0022     PMBUS_CLEAR_FAULTS      = 0x03,
0023     PMBUS_PHASE         = 0x04,
0024 
0025     PMBUS_WRITE_PROTECT     = 0x10,
0026 
0027     PMBUS_CAPABILITY        = 0x19,
0028     PMBUS_QUERY         = 0x1A,
0029 
0030     PMBUS_VOUT_MODE         = 0x20,
0031     PMBUS_VOUT_COMMAND      = 0x21,
0032     PMBUS_VOUT_TRIM         = 0x22,
0033     PMBUS_VOUT_CAL_OFFSET       = 0x23,
0034     PMBUS_VOUT_MAX          = 0x24,
0035     PMBUS_VOUT_MARGIN_HIGH      = 0x25,
0036     PMBUS_VOUT_MARGIN_LOW       = 0x26,
0037     PMBUS_VOUT_TRANSITION_RATE  = 0x27,
0038     PMBUS_VOUT_DROOP        = 0x28,
0039     PMBUS_VOUT_SCALE_LOOP       = 0x29,
0040     PMBUS_VOUT_SCALE_MONITOR    = 0x2A,
0041 
0042     PMBUS_COEFFICIENTS      = 0x30,
0043     PMBUS_POUT_MAX          = 0x31,
0044 
0045     PMBUS_FAN_CONFIG_12     = 0x3A,
0046     PMBUS_FAN_COMMAND_1     = 0x3B,
0047     PMBUS_FAN_COMMAND_2     = 0x3C,
0048     PMBUS_FAN_CONFIG_34     = 0x3D,
0049     PMBUS_FAN_COMMAND_3     = 0x3E,
0050     PMBUS_FAN_COMMAND_4     = 0x3F,
0051 
0052     PMBUS_VOUT_OV_FAULT_LIMIT   = 0x40,
0053     PMBUS_VOUT_OV_FAULT_RESPONSE    = 0x41,
0054     PMBUS_VOUT_OV_WARN_LIMIT    = 0x42,
0055     PMBUS_VOUT_UV_WARN_LIMIT    = 0x43,
0056     PMBUS_VOUT_UV_FAULT_LIMIT   = 0x44,
0057     PMBUS_VOUT_UV_FAULT_RESPONSE    = 0x45,
0058     PMBUS_IOUT_OC_FAULT_LIMIT   = 0x46,
0059     PMBUS_IOUT_OC_FAULT_RESPONSE    = 0x47,
0060     PMBUS_IOUT_OC_LV_FAULT_LIMIT    = 0x48,
0061     PMBUS_IOUT_OC_LV_FAULT_RESPONSE = 0x49,
0062     PMBUS_IOUT_OC_WARN_LIMIT    = 0x4A,
0063     PMBUS_IOUT_UC_FAULT_LIMIT   = 0x4B,
0064     PMBUS_IOUT_UC_FAULT_RESPONSE    = 0x4C,
0065 
0066     PMBUS_OT_FAULT_LIMIT        = 0x4F,
0067     PMBUS_OT_FAULT_RESPONSE     = 0x50,
0068     PMBUS_OT_WARN_LIMIT     = 0x51,
0069     PMBUS_UT_WARN_LIMIT     = 0x52,
0070     PMBUS_UT_FAULT_LIMIT        = 0x53,
0071     PMBUS_UT_FAULT_RESPONSE     = 0x54,
0072     PMBUS_VIN_OV_FAULT_LIMIT    = 0x55,
0073     PMBUS_VIN_OV_FAULT_RESPONSE = 0x56,
0074     PMBUS_VIN_OV_WARN_LIMIT     = 0x57,
0075     PMBUS_VIN_UV_WARN_LIMIT     = 0x58,
0076     PMBUS_VIN_UV_FAULT_LIMIT    = 0x59,
0077 
0078     PMBUS_IIN_OC_FAULT_LIMIT    = 0x5B,
0079     PMBUS_IIN_OC_WARN_LIMIT     = 0x5D,
0080 
0081     PMBUS_POUT_OP_FAULT_LIMIT   = 0x68,
0082     PMBUS_POUT_OP_WARN_LIMIT    = 0x6A,
0083     PMBUS_PIN_OP_WARN_LIMIT     = 0x6B,
0084 
0085     PMBUS_STATUS_BYTE       = 0x78,
0086     PMBUS_STATUS_WORD       = 0x79,
0087     PMBUS_STATUS_VOUT       = 0x7A,
0088     PMBUS_STATUS_IOUT       = 0x7B,
0089     PMBUS_STATUS_INPUT      = 0x7C,
0090     PMBUS_STATUS_TEMPERATURE    = 0x7D,
0091     PMBUS_STATUS_CML        = 0x7E,
0092     PMBUS_STATUS_OTHER      = 0x7F,
0093     PMBUS_STATUS_MFR_SPECIFIC   = 0x80,
0094     PMBUS_STATUS_FAN_12     = 0x81,
0095     PMBUS_STATUS_FAN_34     = 0x82,
0096 
0097     PMBUS_READ_VIN          = 0x88,
0098     PMBUS_READ_IIN          = 0x89,
0099     PMBUS_READ_VCAP         = 0x8A,
0100     PMBUS_READ_VOUT         = 0x8B,
0101     PMBUS_READ_IOUT         = 0x8C,
0102     PMBUS_READ_TEMPERATURE_1    = 0x8D,
0103     PMBUS_READ_TEMPERATURE_2    = 0x8E,
0104     PMBUS_READ_TEMPERATURE_3    = 0x8F,
0105     PMBUS_READ_FAN_SPEED_1      = 0x90,
0106     PMBUS_READ_FAN_SPEED_2      = 0x91,
0107     PMBUS_READ_FAN_SPEED_3      = 0x92,
0108     PMBUS_READ_FAN_SPEED_4      = 0x93,
0109     PMBUS_READ_DUTY_CYCLE       = 0x94,
0110     PMBUS_READ_FREQUENCY        = 0x95,
0111     PMBUS_READ_POUT         = 0x96,
0112     PMBUS_READ_PIN          = 0x97,
0113 
0114     PMBUS_REVISION          = 0x98,
0115     PMBUS_MFR_ID            = 0x99,
0116     PMBUS_MFR_MODEL         = 0x9A,
0117     PMBUS_MFR_REVISION      = 0x9B,
0118     PMBUS_MFR_LOCATION      = 0x9C,
0119     PMBUS_MFR_DATE          = 0x9D,
0120     PMBUS_MFR_SERIAL        = 0x9E,
0121 
0122     PMBUS_MFR_VIN_MIN       = 0xA0,
0123     PMBUS_MFR_VIN_MAX       = 0xA1,
0124     PMBUS_MFR_IIN_MAX       = 0xA2,
0125     PMBUS_MFR_PIN_MAX       = 0xA3,
0126     PMBUS_MFR_VOUT_MIN      = 0xA4,
0127     PMBUS_MFR_VOUT_MAX      = 0xA5,
0128     PMBUS_MFR_IOUT_MAX      = 0xA6,
0129     PMBUS_MFR_POUT_MAX      = 0xA7,
0130 
0131     PMBUS_IC_DEVICE_ID      = 0xAD,
0132     PMBUS_IC_DEVICE_REV     = 0xAE,
0133 
0134     PMBUS_MFR_MAX_TEMP_1        = 0xC0,
0135     PMBUS_MFR_MAX_TEMP_2        = 0xC1,
0136     PMBUS_MFR_MAX_TEMP_3        = 0xC2,
0137 
0138 /*
0139  * Virtual registers.
0140  * Useful to support attributes which are not supported by standard PMBus
0141  * registers but exist as manufacturer specific registers on individual chips.
0142  * Must be mapped to real registers in device specific code.
0143  *
0144  * Semantics:
0145  * Virtual registers are all word size.
0146  * READ registers are read-only; writes are either ignored or return an error.
0147  * RESET registers are read/write. Reading reset registers returns zero
0148  * (used for detection), writing any value causes the associated history to be
0149  * reset.
0150  * Virtual registers have to be handled in device specific driver code. Chip
0151  * driver code returns non-negative register values if a virtual register is
0152  * supported, or a negative error code if not. The chip driver may return
0153  * -ENODATA or any other error code in this case, though an error code other
0154  * than -ENODATA is handled more efficiently and thus preferred. Either case,
0155  * the calling PMBus core code will abort if the chip driver returns an error
0156  * code when reading or writing virtual registers.
0157  */
0158     PMBUS_VIRT_BASE         = 0x100,
0159     PMBUS_VIRT_READ_TEMP_AVG,
0160     PMBUS_VIRT_READ_TEMP_MIN,
0161     PMBUS_VIRT_READ_TEMP_MAX,
0162     PMBUS_VIRT_RESET_TEMP_HISTORY,
0163     PMBUS_VIRT_READ_VIN_AVG,
0164     PMBUS_VIRT_READ_VIN_MIN,
0165     PMBUS_VIRT_READ_VIN_MAX,
0166     PMBUS_VIRT_RESET_VIN_HISTORY,
0167     PMBUS_VIRT_READ_IIN_AVG,
0168     PMBUS_VIRT_READ_IIN_MIN,
0169     PMBUS_VIRT_READ_IIN_MAX,
0170     PMBUS_VIRT_RESET_IIN_HISTORY,
0171     PMBUS_VIRT_READ_PIN_AVG,
0172     PMBUS_VIRT_READ_PIN_MIN,
0173     PMBUS_VIRT_READ_PIN_MAX,
0174     PMBUS_VIRT_RESET_PIN_HISTORY,
0175     PMBUS_VIRT_READ_POUT_AVG,
0176     PMBUS_VIRT_READ_POUT_MIN,
0177     PMBUS_VIRT_READ_POUT_MAX,
0178     PMBUS_VIRT_RESET_POUT_HISTORY,
0179     PMBUS_VIRT_READ_VOUT_AVG,
0180     PMBUS_VIRT_READ_VOUT_MIN,
0181     PMBUS_VIRT_READ_VOUT_MAX,
0182     PMBUS_VIRT_RESET_VOUT_HISTORY,
0183     PMBUS_VIRT_READ_IOUT_AVG,
0184     PMBUS_VIRT_READ_IOUT_MIN,
0185     PMBUS_VIRT_READ_IOUT_MAX,
0186     PMBUS_VIRT_RESET_IOUT_HISTORY,
0187     PMBUS_VIRT_READ_TEMP2_AVG,
0188     PMBUS_VIRT_READ_TEMP2_MIN,
0189     PMBUS_VIRT_READ_TEMP2_MAX,
0190     PMBUS_VIRT_RESET_TEMP2_HISTORY,
0191 
0192     PMBUS_VIRT_READ_VMON,
0193     PMBUS_VIRT_VMON_UV_WARN_LIMIT,
0194     PMBUS_VIRT_VMON_OV_WARN_LIMIT,
0195     PMBUS_VIRT_VMON_UV_FAULT_LIMIT,
0196     PMBUS_VIRT_VMON_OV_FAULT_LIMIT,
0197     PMBUS_VIRT_STATUS_VMON,
0198 
0199     /*
0200      * RPM and PWM Fan control
0201      *
0202      * Drivers wanting to expose PWM control must define the behaviour of
0203      * PMBUS_VIRT_PWM_[1-4] and PMBUS_VIRT_PWM_ENABLE_[1-4] in the
0204      * {read,write}_word_data callback.
0205      *
0206      * pmbus core provides a default implementation for
0207      * PMBUS_VIRT_FAN_TARGET_[1-4].
0208      *
0209      * TARGET, PWM and PWM_ENABLE members must be defined sequentially;
0210      * pmbus core uses the difference between the provided register and
0211      * it's _1 counterpart to calculate the FAN/PWM ID.
0212      */
0213     PMBUS_VIRT_FAN_TARGET_1,
0214     PMBUS_VIRT_FAN_TARGET_2,
0215     PMBUS_VIRT_FAN_TARGET_3,
0216     PMBUS_VIRT_FAN_TARGET_4,
0217     PMBUS_VIRT_PWM_1,
0218     PMBUS_VIRT_PWM_2,
0219     PMBUS_VIRT_PWM_3,
0220     PMBUS_VIRT_PWM_4,
0221     PMBUS_VIRT_PWM_ENABLE_1,
0222     PMBUS_VIRT_PWM_ENABLE_2,
0223     PMBUS_VIRT_PWM_ENABLE_3,
0224     PMBUS_VIRT_PWM_ENABLE_4,
0225 
0226     /* Samples for average
0227      *
0228      * Drivers wanting to expose functionality for changing the number of
0229      * samples used for average values should implement support in
0230      * {read,write}_word_data callback for either PMBUS_VIRT_SAMPLES if it
0231      * applies to all types of measurements, or any number of specific
0232      * PMBUS_VIRT_*_SAMPLES registers to allow for individual control.
0233      */
0234     PMBUS_VIRT_SAMPLES,
0235     PMBUS_VIRT_IN_SAMPLES,
0236     PMBUS_VIRT_CURR_SAMPLES,
0237     PMBUS_VIRT_POWER_SAMPLES,
0238     PMBUS_VIRT_TEMP_SAMPLES,
0239 };
0240 
0241 /*
0242  * OPERATION
0243  */
0244 #define PB_OPERATION_CONTROL_ON     BIT(7)
0245 
0246 /*
0247  * WRITE_PROTECT
0248  */
0249 #define PB_WP_ALL   BIT(7)  /* all but WRITE_PROTECT */
0250 #define PB_WP_OP    BIT(6)  /* all but WP, OPERATION, PAGE */
0251 #define PB_WP_VOUT  BIT(5)  /* all but WP, OPERATION, PAGE, VOUT, ON_OFF */
0252 
0253 #define PB_WP_ANY   (PB_WP_ALL | PB_WP_OP | PB_WP_VOUT)
0254 
0255 /*
0256  * CAPABILITY
0257  */
0258 #define PB_CAPABILITY_SMBALERT      BIT(4)
0259 #define PB_CAPABILITY_ERROR_CHECK   BIT(7)
0260 
0261 /*
0262  * VOUT_MODE
0263  */
0264 #define PB_VOUT_MODE_MODE_MASK      0xe0
0265 #define PB_VOUT_MODE_PARAM_MASK     0x1f
0266 
0267 #define PB_VOUT_MODE_LINEAR     0x00
0268 #define PB_VOUT_MODE_VID        0x20
0269 #define PB_VOUT_MODE_DIRECT     0x40
0270 
0271 /*
0272  * Fan configuration
0273  */
0274 #define PB_FAN_2_PULSE_MASK     (BIT(0) | BIT(1))
0275 #define PB_FAN_2_RPM            BIT(2)
0276 #define PB_FAN_2_INSTALLED      BIT(3)
0277 #define PB_FAN_1_PULSE_MASK     (BIT(4) | BIT(5))
0278 #define PB_FAN_1_RPM            BIT(6)
0279 #define PB_FAN_1_INSTALLED      BIT(7)
0280 
0281 enum pmbus_fan_mode { percent = 0, rpm };
0282 
0283 /*
0284  * STATUS_BYTE, STATUS_WORD (lower)
0285  */
0286 #define PB_STATUS_NONE_ABOVE        BIT(0)
0287 #define PB_STATUS_CML           BIT(1)
0288 #define PB_STATUS_TEMPERATURE       BIT(2)
0289 #define PB_STATUS_VIN_UV        BIT(3)
0290 #define PB_STATUS_IOUT_OC       BIT(4)
0291 #define PB_STATUS_VOUT_OV       BIT(5)
0292 #define PB_STATUS_OFF           BIT(6)
0293 #define PB_STATUS_BUSY          BIT(7)
0294 
0295 /*
0296  * STATUS_WORD (upper)
0297  */
0298 #define PB_STATUS_UNKNOWN       BIT(8)
0299 #define PB_STATUS_OTHER         BIT(9)
0300 #define PB_STATUS_FANS          BIT(10)
0301 #define PB_STATUS_POWER_GOOD_N      BIT(11)
0302 #define PB_STATUS_WORD_MFR      BIT(12)
0303 #define PB_STATUS_INPUT         BIT(13)
0304 #define PB_STATUS_IOUT_POUT     BIT(14)
0305 #define PB_STATUS_VOUT          BIT(15)
0306 
0307 /*
0308  * STATUS_IOUT
0309  */
0310 #define PB_POUT_OP_WARNING      BIT(0)
0311 #define PB_POUT_OP_FAULT        BIT(1)
0312 #define PB_POWER_LIMITING       BIT(2)
0313 #define PB_CURRENT_SHARE_FAULT      BIT(3)
0314 #define PB_IOUT_UC_FAULT        BIT(4)
0315 #define PB_IOUT_OC_WARNING      BIT(5)
0316 #define PB_IOUT_OC_LV_FAULT     BIT(6)
0317 #define PB_IOUT_OC_FAULT        BIT(7)
0318 
0319 /*
0320  * STATUS_VOUT, STATUS_INPUT
0321  */
0322 #define PB_VOLTAGE_VIN_OFF      BIT(3)
0323 #define PB_VOLTAGE_UV_FAULT     BIT(4)
0324 #define PB_VOLTAGE_UV_WARNING       BIT(5)
0325 #define PB_VOLTAGE_OV_WARNING       BIT(6)
0326 #define PB_VOLTAGE_OV_FAULT     BIT(7)
0327 
0328 /*
0329  * STATUS_INPUT
0330  */
0331 #define PB_PIN_OP_WARNING       BIT(0)
0332 #define PB_IIN_OC_WARNING       BIT(1)
0333 #define PB_IIN_OC_FAULT         BIT(2)
0334 
0335 /*
0336  * STATUS_TEMPERATURE
0337  */
0338 #define PB_TEMP_UT_FAULT        BIT(4)
0339 #define PB_TEMP_UT_WARNING      BIT(5)
0340 #define PB_TEMP_OT_WARNING      BIT(6)
0341 #define PB_TEMP_OT_FAULT        BIT(7)
0342 
0343 /*
0344  * STATUS_FAN
0345  */
0346 #define PB_FAN_AIRFLOW_WARNING      BIT(0)
0347 #define PB_FAN_AIRFLOW_FAULT        BIT(1)
0348 #define PB_FAN_FAN2_SPEED_OVERRIDE  BIT(2)
0349 #define PB_FAN_FAN1_SPEED_OVERRIDE  BIT(3)
0350 #define PB_FAN_FAN2_WARNING     BIT(4)
0351 #define PB_FAN_FAN1_WARNING     BIT(5)
0352 #define PB_FAN_FAN2_FAULT       BIT(6)
0353 #define PB_FAN_FAN1_FAULT       BIT(7)
0354 
0355 /*
0356  * CML_FAULT_STATUS
0357  */
0358 #define PB_CML_FAULT_OTHER_MEM_LOGIC    BIT(0)
0359 #define PB_CML_FAULT_OTHER_COMM     BIT(1)
0360 #define PB_CML_FAULT_PROCESSOR      BIT(3)
0361 #define PB_CML_FAULT_MEMORY     BIT(4)
0362 #define PB_CML_FAULT_PACKET_ERROR   BIT(5)
0363 #define PB_CML_FAULT_INVALID_DATA   BIT(6)
0364 #define PB_CML_FAULT_INVALID_COMMAND    BIT(7)
0365 
0366 enum pmbus_sensor_classes {
0367     PSC_VOLTAGE_IN = 0,
0368     PSC_VOLTAGE_OUT,
0369     PSC_CURRENT_IN,
0370     PSC_CURRENT_OUT,
0371     PSC_POWER,
0372     PSC_TEMPERATURE,
0373     PSC_FAN,
0374     PSC_PWM,
0375     PSC_NUM_CLASSES     /* Number of power sensor classes */
0376 };
0377 
0378 #define PMBUS_PAGES 32  /* Per PMBus specification */
0379 #define PMBUS_PHASES    10  /* Maximum number of phases per page */
0380 
0381 /* Functionality bit mask */
0382 #define PMBUS_HAVE_VIN      BIT(0)
0383 #define PMBUS_HAVE_VCAP     BIT(1)
0384 #define PMBUS_HAVE_VOUT     BIT(2)
0385 #define PMBUS_HAVE_IIN      BIT(3)
0386 #define PMBUS_HAVE_IOUT     BIT(4)
0387 #define PMBUS_HAVE_PIN      BIT(5)
0388 #define PMBUS_HAVE_POUT     BIT(6)
0389 #define PMBUS_HAVE_FAN12    BIT(7)
0390 #define PMBUS_HAVE_FAN34    BIT(8)
0391 #define PMBUS_HAVE_TEMP     BIT(9)
0392 #define PMBUS_HAVE_TEMP2    BIT(10)
0393 #define PMBUS_HAVE_TEMP3    BIT(11)
0394 #define PMBUS_HAVE_STATUS_VOUT  BIT(12)
0395 #define PMBUS_HAVE_STATUS_IOUT  BIT(13)
0396 #define PMBUS_HAVE_STATUS_INPUT BIT(14)
0397 #define PMBUS_HAVE_STATUS_TEMP  BIT(15)
0398 #define PMBUS_HAVE_STATUS_FAN12 BIT(16)
0399 #define PMBUS_HAVE_STATUS_FAN34 BIT(17)
0400 #define PMBUS_HAVE_VMON     BIT(18)
0401 #define PMBUS_HAVE_STATUS_VMON  BIT(19)
0402 #define PMBUS_HAVE_PWM12    BIT(20)
0403 #define PMBUS_HAVE_PWM34    BIT(21)
0404 #define PMBUS_HAVE_SAMPLES  BIT(22)
0405 
0406 #define PMBUS_PHASE_VIRTUAL BIT(30) /* Phases on this page are virtual */
0407 #define PMBUS_PAGE_VIRTUAL  BIT(31) /* Page is virtual */
0408 
0409 enum pmbus_data_format { linear = 0, ieee754, direct, vid };
0410 enum vrm_version { vr11 = 0, vr12, vr13, imvp9, amd625mv };
0411 
0412 struct pmbus_driver_info {
0413     int pages;      /* Total number of pages */
0414     u8 phases[PMBUS_PAGES]; /* Number of phases per page */
0415     enum pmbus_data_format format[PSC_NUM_CLASSES];
0416     enum vrm_version vrm_version[PMBUS_PAGES]; /* vrm version per page */
0417     /*
0418      * Support one set of coefficients for each sensor type
0419      * Used for chips providing data in direct mode.
0420      */
0421     int m[PSC_NUM_CLASSES]; /* mantissa for direct data format */
0422     int b[PSC_NUM_CLASSES]; /* offset */
0423     int R[PSC_NUM_CLASSES]; /* exponent */
0424 
0425     u32 func[PMBUS_PAGES];  /* Functionality, per page */
0426     u32 pfunc[PMBUS_PHASES];/* Functionality, per phase */
0427     /*
0428      * The following functions map manufacturing specific register values
0429      * to PMBus standard register values. Specify only if mapping is
0430      * necessary.
0431      * Functions return the register value (read) or zero (write) if
0432      * successful. A return value of -ENODATA indicates that there is no
0433      * manufacturer specific register, but that a standard PMBus register
0434      * may exist. Any other negative return value indicates that the
0435      * register does not exist, and that no attempt should be made to read
0436      * the standard register.
0437      */
0438     int (*read_byte_data)(struct i2c_client *client, int page, int reg);
0439     int (*read_word_data)(struct i2c_client *client, int page, int phase,
0440                   int reg);
0441     int (*write_byte_data)(struct i2c_client *client, int page, int reg,
0442                   u8 byte);
0443     int (*write_word_data)(struct i2c_client *client, int page, int reg,
0444                    u16 word);
0445     int (*write_byte)(struct i2c_client *client, int page, u8 value);
0446     /*
0447      * The identify function determines supported PMBus functionality.
0448      * This function is only necessary if a chip driver supports multiple
0449      * chips, and the chip functionality is not pre-determined.
0450      */
0451     int (*identify)(struct i2c_client *client,
0452             struct pmbus_driver_info *info);
0453 
0454     /* Regulator functionality, if supported by this chip driver. */
0455     int num_regulators;
0456     const struct regulator_desc *reg_desc;
0457 
0458     /* custom attributes */
0459     const struct attribute_group **groups;
0460 };
0461 
0462 /* Regulator ops */
0463 
0464 extern const struct regulator_ops pmbus_regulator_ops;
0465 
0466 /* Macros for filling in array of struct regulator_desc */
0467 #define PMBUS_REGULATOR_STEP(_name, _id, _voltages, _step)  \
0468     [_id] = {                       \
0469         .name = (_name # _id),              \
0470         .supply_name = "vin",               \
0471         .id = (_id),                    \
0472         .of_match = of_match_ptr(_name # _id),      \
0473         .regulators_node = of_match_ptr("regulators"),  \
0474         .ops = &pmbus_regulator_ops,            \
0475         .type = REGULATOR_VOLTAGE,          \
0476         .owner = THIS_MODULE,               \
0477         .n_voltages = _voltages,            \
0478         .uV_step = _step,               \
0479     }
0480 
0481 #define PMBUS_REGULATOR(_name, _id) PMBUS_REGULATOR_STEP(_name, _id, 0, 0)
0482 
0483 /* Function declarations */
0484 
0485 void pmbus_clear_cache(struct i2c_client *client);
0486 void pmbus_set_update(struct i2c_client *client, u8 reg, bool update);
0487 int pmbus_set_page(struct i2c_client *client, int page, int phase);
0488 int pmbus_read_word_data(struct i2c_client *client, int page, int phase,
0489              u8 reg);
0490 int pmbus_write_word_data(struct i2c_client *client, int page, u8 reg,
0491               u16 word);
0492 int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg);
0493 int pmbus_write_byte(struct i2c_client *client, int page, u8 value);
0494 int pmbus_write_byte_data(struct i2c_client *client, int page, u8 reg,
0495               u8 value);
0496 int pmbus_update_byte_data(struct i2c_client *client, int page, u8 reg,
0497                u8 mask, u8 value);
0498 void pmbus_clear_faults(struct i2c_client *client);
0499 bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg);
0500 bool pmbus_check_word_register(struct i2c_client *client, int page, int reg);
0501 int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info);
0502 const struct pmbus_driver_info *pmbus_get_driver_info(struct i2c_client
0503                               *client);
0504 int pmbus_get_fan_rate_device(struct i2c_client *client, int page, int id,
0505                   enum pmbus_fan_mode mode);
0506 int pmbus_get_fan_rate_cached(struct i2c_client *client, int page, int id,
0507                   enum pmbus_fan_mode mode);
0508 int pmbus_update_fan(struct i2c_client *client, int page, int id,
0509              u8 config, u8 mask, u16 command);
0510 struct dentry *pmbus_get_debugfs_dir(struct i2c_client *client);
0511 
0512 #endif /* PMBUS_H */