17ebd8b66SMauro Carvalho Chehab================================== 27ebd8b66SMauro Carvalho ChehabPMBus core driver and internal API 37ebd8b66SMauro Carvalho Chehab================================== 47ebd8b66SMauro Carvalho Chehab 57ebd8b66SMauro Carvalho ChehabIntroduction 67ebd8b66SMauro Carvalho Chehab============ 77ebd8b66SMauro Carvalho Chehab 87ebd8b66SMauro Carvalho Chehab[from pmbus.org] The Power Management Bus (PMBus) is an open standard 97ebd8b66SMauro Carvalho Chehabpower-management protocol with a fully defined command language that facilitates 107ebd8b66SMauro Carvalho Chehabcommunication with power converters and other devices in a power system. The 117ebd8b66SMauro Carvalho Chehabprotocol is implemented over the industry-standard SMBus serial interface and 127ebd8b66SMauro Carvalho Chehabenables programming, control, and real-time monitoring of compliant power 137ebd8b66SMauro Carvalho Chehabconversion products. This flexible and highly versatile standard allows for 147ebd8b66SMauro Carvalho Chehabcommunication between devices based on both analog and digital technologies, and 157ebd8b66SMauro Carvalho Chehabprovides true interoperability which will reduce design complexity and shorten 167ebd8b66SMauro Carvalho Chehabtime to market for power system designers. Pioneered by leading power supply and 177ebd8b66SMauro Carvalho Chehabsemiconductor companies, this open power system standard is maintained and 187ebd8b66SMauro Carvalho Chehabpromoted by the PMBus Implementers Forum (PMBus-IF), comprising 30+ adopters 197ebd8b66SMauro Carvalho Chehabwith the objective to provide support to, and facilitate adoption among, users. 207ebd8b66SMauro Carvalho Chehab 217ebd8b66SMauro Carvalho ChehabUnfortunately, while PMBus commands are standardized, there are no mandatory 227ebd8b66SMauro Carvalho Chehabcommands, and manufacturers can add as many non-standard commands as they like. 237ebd8b66SMauro Carvalho ChehabAlso, different PMBUs devices act differently if non-supported commands are 247ebd8b66SMauro Carvalho Chehabexecuted. Some devices return an error, some devices return 0xff or 0xffff and 257ebd8b66SMauro Carvalho Chehabset a status error flag, and some devices may simply hang up. 267ebd8b66SMauro Carvalho Chehab 277ebd8b66SMauro Carvalho ChehabDespite all those difficulties, a generic PMBus device driver is still useful 287ebd8b66SMauro Carvalho Chehaband supported since kernel version 2.6.39. However, it was necessary to support 297ebd8b66SMauro Carvalho Chehabdevice specific extensions in addition to the core PMBus driver, since it is 307ebd8b66SMauro Carvalho Chehabsimply unknown what new device specific functionality PMBus device developers 317ebd8b66SMauro Carvalho Chehabcome up with next. 327ebd8b66SMauro Carvalho Chehab 337ebd8b66SMauro Carvalho ChehabTo make device specific extensions as scalable as possible, and to avoid having 347ebd8b66SMauro Carvalho Chehabto modify the core PMBus driver repeatedly for new devices, the PMBus driver was 357ebd8b66SMauro Carvalho Chehabsplit into core, generic, and device specific code. The core code (in 367ebd8b66SMauro Carvalho Chehabpmbus_core.c) provides generic functionality. The generic code (in pmbus.c) 377ebd8b66SMauro Carvalho Chehabprovides support for generic PMBus devices. Device specific code is responsible 387ebd8b66SMauro Carvalho Chehabfor device specific initialization and, if needed, maps device specific 397ebd8b66SMauro Carvalho Chehabfunctionality into generic functionality. This is to some degree comparable 407ebd8b66SMauro Carvalho Chehabto PCI code, where generic code is augmented as needed with quirks for all kinds 417ebd8b66SMauro Carvalho Chehabof devices. 427ebd8b66SMauro Carvalho Chehab 437ebd8b66SMauro Carvalho ChehabPMBus device capabilities auto-detection 447ebd8b66SMauro Carvalho Chehab======================================== 457ebd8b66SMauro Carvalho Chehab 467ebd8b66SMauro Carvalho ChehabFor generic PMBus devices, code in pmbus.c attempts to auto-detect all supported 477ebd8b66SMauro Carvalho ChehabPMBus commands. Auto-detection is somewhat limited, since there are simply too 487ebd8b66SMauro Carvalho Chehabmany variables to consider. For example, it is almost impossible to autodetect 497ebd8b66SMauro Carvalho Chehabwhich PMBus commands are paged and which commands are replicated across all 507ebd8b66SMauro Carvalho Chehabpages (see the PMBus specification for details on multi-page PMBus devices). 517ebd8b66SMauro Carvalho Chehab 527ebd8b66SMauro Carvalho ChehabFor this reason, it often makes sense to provide a device specific driver if not 537ebd8b66SMauro Carvalho Chehaball commands can be auto-detected. The data structures in this driver can be 547ebd8b66SMauro Carvalho Chehabused to inform the core driver about functionality supported by individual 557ebd8b66SMauro Carvalho Chehabchips. 567ebd8b66SMauro Carvalho Chehab 577ebd8b66SMauro Carvalho ChehabSome commands are always auto-detected. This applies to all limit commands 587ebd8b66SMauro Carvalho Chehab(lcrit, min, max, and crit attributes) as well as associated alarm attributes. 597ebd8b66SMauro Carvalho ChehabLimits and alarm attributes are auto-detected because there are simply too many 607ebd8b66SMauro Carvalho Chehabpossible combinations to provide a manual configuration interface. 617ebd8b66SMauro Carvalho Chehab 627ebd8b66SMauro Carvalho ChehabPMBus internal API 637ebd8b66SMauro Carvalho Chehab================== 647ebd8b66SMauro Carvalho Chehab 657ebd8b66SMauro Carvalho ChehabThe API between core and device specific PMBus code is defined in 667ebd8b66SMauro Carvalho Chehabdrivers/hwmon/pmbus/pmbus.h. In addition to the internal API, pmbus.h defines 677ebd8b66SMauro Carvalho Chehabstandard PMBus commands and virtual PMBus commands. 687ebd8b66SMauro Carvalho Chehab 697ebd8b66SMauro Carvalho ChehabStandard PMBus commands 707ebd8b66SMauro Carvalho Chehab----------------------- 717ebd8b66SMauro Carvalho Chehab 727ebd8b66SMauro Carvalho ChehabStandard PMBus commands (commands values 0x00 to 0xff) are defined in the PMBUs 737ebd8b66SMauro Carvalho Chehabspecification. 747ebd8b66SMauro Carvalho Chehab 757ebd8b66SMauro Carvalho ChehabVirtual PMBus commands 767ebd8b66SMauro Carvalho Chehab---------------------- 777ebd8b66SMauro Carvalho Chehab 787ebd8b66SMauro Carvalho ChehabVirtual PMBus commands are provided to enable support for non-standard 797ebd8b66SMauro Carvalho Chehabfunctionality which has been implemented by several chip vendors and is thus 807ebd8b66SMauro Carvalho Chehabdesirable to support. 817ebd8b66SMauro Carvalho Chehab 827ebd8b66SMauro Carvalho ChehabVirtual PMBus commands start with command value 0x100 and can thus easily be 837ebd8b66SMauro Carvalho Chehabdistinguished from standard PMBus commands (which can not have values larger 847ebd8b66SMauro Carvalho Chehabthan 0xff). Support for virtual PMBus commands is device specific and thus has 857ebd8b66SMauro Carvalho Chehabto be implemented in device specific code. 867ebd8b66SMauro Carvalho Chehab 877ebd8b66SMauro Carvalho ChehabVirtual commands are named PMBUS_VIRT_xxx and start with PMBUS_VIRT_BASE. All 887ebd8b66SMauro Carvalho Chehabvirtual commands are word sized. 897ebd8b66SMauro Carvalho Chehab 907ebd8b66SMauro Carvalho ChehabThere are currently two types of virtual commands. 917ebd8b66SMauro Carvalho Chehab 927ebd8b66SMauro Carvalho Chehab- READ commands are read-only; writes are either ignored or return an error. 937ebd8b66SMauro Carvalho Chehab- RESET commands are read/write. Reading reset registers returns zero 947ebd8b66SMauro Carvalho Chehab (used for detection), writing any value causes the associated history to be 957ebd8b66SMauro Carvalho Chehab reset. 967ebd8b66SMauro Carvalho Chehab 977ebd8b66SMauro Carvalho ChehabVirtual commands have to be handled in device specific driver code. Chip driver 987ebd8b66SMauro Carvalho Chehabcode returns non-negative values if a virtual command is supported, or a 997ebd8b66SMauro Carvalho Chehabnegative error code if not. The chip driver may return -ENODATA or any other 1007ebd8b66SMauro Carvalho ChehabLinux error code in this case, though an error code other than -ENODATA is 1017ebd8b66SMauro Carvalho Chehabhandled more efficiently and thus preferred. Either case, the calling PMBus 1027ebd8b66SMauro Carvalho Chehabcore code will abort if the chip driver returns an error code when reading 1037ebd8b66SMauro Carvalho Chehabor writing virtual registers (in other words, the PMBus core code will never 1047ebd8b66SMauro Carvalho Chehabsend a virtual command to a chip). 1057ebd8b66SMauro Carvalho Chehab 1067ebd8b66SMauro Carvalho ChehabPMBus driver information 1077ebd8b66SMauro Carvalho Chehab------------------------ 1087ebd8b66SMauro Carvalho Chehab 1097ebd8b66SMauro Carvalho ChehabPMBus driver information, defined in struct pmbus_driver_info, is the main means 1107ebd8b66SMauro Carvalho Chehabfor device specific drivers to pass information to the core PMBus driver. 1117ebd8b66SMauro Carvalho ChehabSpecifically, it provides the following information. 1127ebd8b66SMauro Carvalho Chehab 1137ebd8b66SMauro Carvalho Chehab- For devices supporting its data in Direct Data Format, it provides coefficients 1147ebd8b66SMauro Carvalho Chehab for converting register values into normalized data. This data is usually 1157ebd8b66SMauro Carvalho Chehab provided by chip manufacturers in device datasheets. 1167ebd8b66SMauro Carvalho Chehab- Supported chip functionality can be provided to the core driver. This may be 1177ebd8b66SMauro Carvalho Chehab necessary for chips which react badly if non-supported commands are executed, 1187ebd8b66SMauro Carvalho Chehab and/or to speed up device detection and initialization. 1197ebd8b66SMauro Carvalho Chehab- Several function entry points are provided to support overriding and/or 1207ebd8b66SMauro Carvalho Chehab augmenting generic command execution. This functionality can be used to map 1217ebd8b66SMauro Carvalho Chehab non-standard PMBus commands to standard commands, or to augment standard 1227ebd8b66SMauro Carvalho Chehab command return values with device specific information. 1237ebd8b66SMauro Carvalho Chehab 124f30ce040SGuenter RoeckPEC Support 125f30ce040SGuenter Roeck=========== 126f30ce040SGuenter Roeck 127f30ce040SGuenter RoeckMany PMBus devices support SMBus PEC (Packet Error Checking). If supported 128f30ce040SGuenter Roeckby both the I2C adapter and by the PMBus chip, it is by default enabled. 129f30ce040SGuenter RoeckIf PEC is supported, the PMBus core driver adds an attribute named 'pec' to 130f30ce040SGuenter Roeckthe I2C device. This attribute can be used to control PEC support in the 131f30ce040SGuenter Roeckcommunication with the PMBus chip. 132f30ce040SGuenter Roeck 1337ebd8b66SMauro Carvalho ChehabAPI functions 1347ebd8b66SMauro Carvalho Chehab============= 1357ebd8b66SMauro Carvalho Chehab 1367ebd8b66SMauro Carvalho ChehabFunctions provided by chip driver 1377ebd8b66SMauro Carvalho Chehab--------------------------------- 1387ebd8b66SMauro Carvalho Chehab 1397ebd8b66SMauro Carvalho ChehabAll functions return the command return value (read) or zero (write) if 1407ebd8b66SMauro Carvalho Chehabsuccessful. A return value of -ENODATA indicates that there is no manufacturer 1417ebd8b66SMauro Carvalho Chehabspecific command, but that a standard PMBus command may exist. Any other 1427ebd8b66SMauro Carvalho Chehabnegative return value indicates that the commands does not exist for this 1437ebd8b66SMauro Carvalho Chehabchip, and that no attempt should be made to read or write the standard 1447ebd8b66SMauro Carvalho Chehabcommand. 1457ebd8b66SMauro Carvalho Chehab 1467ebd8b66SMauro Carvalho ChehabAs mentioned above, an exception to this rule applies to virtual commands, 1477ebd8b66SMauro Carvalho Chehabwhich *must* be handled in driver specific code. See "Virtual PMBus Commands" 1487ebd8b66SMauro Carvalho Chehababove for more details. 1497ebd8b66SMauro Carvalho Chehab 1507ebd8b66SMauro Carvalho ChehabCommand execution in the core PMBus driver code is as follows:: 1517ebd8b66SMauro Carvalho Chehab 1527ebd8b66SMauro Carvalho Chehab if (chip_access_function) { 1537ebd8b66SMauro Carvalho Chehab status = chip_access_function(); 1547ebd8b66SMauro Carvalho Chehab if (status != -ENODATA) 1557ebd8b66SMauro Carvalho Chehab return status; 1567ebd8b66SMauro Carvalho Chehab } 1577ebd8b66SMauro Carvalho Chehab if (command >= PMBUS_VIRT_BASE) /* For word commands/registers only */ 1587ebd8b66SMauro Carvalho Chehab return -EINVAL; 1597ebd8b66SMauro Carvalho Chehab return generic_access(); 1607ebd8b66SMauro Carvalho Chehab 1617ebd8b66SMauro Carvalho ChehabChip drivers may provide pointers to the following functions in struct 1627ebd8b66SMauro Carvalho Chehabpmbus_driver_info. All functions are optional. 1637ebd8b66SMauro Carvalho Chehab 1647ebd8b66SMauro Carvalho Chehab:: 1657ebd8b66SMauro Carvalho Chehab 1667ebd8b66SMauro Carvalho Chehab int (*read_byte_data)(struct i2c_client *client, int page, int reg); 1677ebd8b66SMauro Carvalho Chehab 1687ebd8b66SMauro Carvalho ChehabRead byte from page <page>, register <reg>. 1697ebd8b66SMauro Carvalho Chehab<page> may be -1, which means "current page". 1707ebd8b66SMauro Carvalho Chehab 1717ebd8b66SMauro Carvalho Chehab 1727ebd8b66SMauro Carvalho Chehab:: 1737ebd8b66SMauro Carvalho Chehab 17443f33b6eSGuenter Roeck int (*read_word_data)(struct i2c_client *client, int page, int phase, 17543f33b6eSGuenter Roeck int reg); 1767ebd8b66SMauro Carvalho Chehab 17712087a36SRandy DunlapRead word from page <page>, phase <phase>, register <reg>. If the chip does not 17843f33b6eSGuenter Roecksupport multiple phases, the phase parameter can be ignored. If the chip 17943f33b6eSGuenter Roecksupports multiple phases, a phase value of 0xff indicates all phases. 1807ebd8b66SMauro Carvalho Chehab 1817ebd8b66SMauro Carvalho Chehab:: 1827ebd8b66SMauro Carvalho Chehab 1837ebd8b66SMauro Carvalho Chehab int (*write_word_data)(struct i2c_client *client, int page, int reg, 1847ebd8b66SMauro Carvalho Chehab u16 word); 1857ebd8b66SMauro Carvalho Chehab 1867ebd8b66SMauro Carvalho ChehabWrite word to page <page>, register <reg>. 1877ebd8b66SMauro Carvalho Chehab 1887ebd8b66SMauro Carvalho Chehab:: 1897ebd8b66SMauro Carvalho Chehab 1907ebd8b66SMauro Carvalho Chehab int (*write_byte)(struct i2c_client *client, int page, u8 value); 1917ebd8b66SMauro Carvalho Chehab 1927ebd8b66SMauro Carvalho ChehabWrite byte to page <page>, register <reg>. 1937ebd8b66SMauro Carvalho Chehab<page> may be -1, which means "current page". 1947ebd8b66SMauro Carvalho Chehab 1957ebd8b66SMauro Carvalho Chehab:: 1967ebd8b66SMauro Carvalho Chehab 1977ebd8b66SMauro Carvalho Chehab int (*identify)(struct i2c_client *client, struct pmbus_driver_info *info); 1987ebd8b66SMauro Carvalho Chehab 1997ebd8b66SMauro Carvalho ChehabDetermine supported PMBus functionality. This function is only necessary 2007ebd8b66SMauro Carvalho Chehabif a chip driver supports multiple chips, and the chip functionality is not 2017ebd8b66SMauro Carvalho Chehabpre-determined. It is currently only used by the generic pmbus driver 2027ebd8b66SMauro Carvalho Chehab(pmbus.c). 2037ebd8b66SMauro Carvalho Chehab 2047ebd8b66SMauro Carvalho ChehabFunctions exported by core driver 2057ebd8b66SMauro Carvalho Chehab--------------------------------- 2067ebd8b66SMauro Carvalho Chehab 2077ebd8b66SMauro Carvalho ChehabChip drivers are expected to use the following functions to read or write 2087ebd8b66SMauro Carvalho ChehabPMBus registers. Chip drivers may also use direct I2C commands. If direct I2C 2097ebd8b66SMauro Carvalho Chehabcommands are used, the chip driver code must not directly modify the current 2107ebd8b66SMauro Carvalho Chehabpage, since the selected page is cached in the core driver and the core driver 2117ebd8b66SMauro Carvalho Chehabwill assume that it is selected. Using pmbus_set_page() to select a new page 2127ebd8b66SMauro Carvalho Chehabis mandatory. 2137ebd8b66SMauro Carvalho Chehab 2147ebd8b66SMauro Carvalho Chehab:: 2157ebd8b66SMauro Carvalho Chehab 21643f33b6eSGuenter Roeck int pmbus_set_page(struct i2c_client *client, u8 page, u8 phase); 2177ebd8b66SMauro Carvalho Chehab 21843f33b6eSGuenter RoeckSet PMBus page register to <page> and <phase> for subsequent commands. 21943f33b6eSGuenter RoeckIf the chip does not support multiple phases, the phase parameter is 22043f33b6eSGuenter Roeckignored. Otherwise, a phase value of 0xff selects all phases. 2217ebd8b66SMauro Carvalho Chehab 2227ebd8b66SMauro Carvalho Chehab:: 2237ebd8b66SMauro Carvalho Chehab 22443f33b6eSGuenter Roeck int pmbus_read_word_data(struct i2c_client *client, u8 page, u8 phase, 22543f33b6eSGuenter Roeck u8 reg); 2267ebd8b66SMauro Carvalho Chehab 22743f33b6eSGuenter RoeckRead word data from <page>, <phase>, <reg>. Similar to 22843f33b6eSGuenter Roecki2c_smbus_read_word_data(), but selects page and phase first. If the chip does 22943f33b6eSGuenter Roecknot support multiple phases, the phase parameter is ignored. Otherwise, a phase 23043f33b6eSGuenter Roeckvalue of 0xff selects all phases. 2317ebd8b66SMauro Carvalho Chehab 2327ebd8b66SMauro Carvalho Chehab:: 2337ebd8b66SMauro Carvalho Chehab 2347ebd8b66SMauro Carvalho Chehab int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, 2357ebd8b66SMauro Carvalho Chehab u16 word); 2367ebd8b66SMauro Carvalho Chehab 2377ebd8b66SMauro Carvalho ChehabWrite word data to <page>, <reg>. Similar to i2c_smbus_write_word_data(), but 2387ebd8b66SMauro Carvalho Chehabselects page first. 2397ebd8b66SMauro Carvalho Chehab 2407ebd8b66SMauro Carvalho Chehab:: 2417ebd8b66SMauro Carvalho Chehab 2427ebd8b66SMauro Carvalho Chehab int pmbus_read_byte_data(struct i2c_client *client, int page, u8 reg); 2437ebd8b66SMauro Carvalho Chehab 2447ebd8b66SMauro Carvalho ChehabRead byte data from <page>, <reg>. Similar to i2c_smbus_read_byte_data(), but 2457ebd8b66SMauro Carvalho Chehabselects page first. <page> may be -1, which means "current page". 2467ebd8b66SMauro Carvalho Chehab 2477ebd8b66SMauro Carvalho Chehab:: 2487ebd8b66SMauro Carvalho Chehab 2497ebd8b66SMauro Carvalho Chehab int pmbus_write_byte(struct i2c_client *client, int page, u8 value); 2507ebd8b66SMauro Carvalho Chehab 2517ebd8b66SMauro Carvalho ChehabWrite byte data to <page>, <reg>. Similar to i2c_smbus_write_byte(), but 2527ebd8b66SMauro Carvalho Chehabselects page first. <page> may be -1, which means "current page". 2537ebd8b66SMauro Carvalho Chehab 2547ebd8b66SMauro Carvalho Chehab:: 2557ebd8b66SMauro Carvalho Chehab 2567ebd8b66SMauro Carvalho Chehab void pmbus_clear_faults(struct i2c_client *client); 2577ebd8b66SMauro Carvalho Chehab 2587ebd8b66SMauro Carvalho ChehabExecute PMBus "Clear Fault" command on all chip pages. 2597ebd8b66SMauro Carvalho ChehabThis function calls the device specific write_byte function if defined. 2607ebd8b66SMauro Carvalho ChehabTherefore, it must _not_ be called from that function. 2617ebd8b66SMauro Carvalho Chehab 2627ebd8b66SMauro Carvalho Chehab:: 2637ebd8b66SMauro Carvalho Chehab 2647ebd8b66SMauro Carvalho Chehab bool pmbus_check_byte_register(struct i2c_client *client, int page, int reg); 2657ebd8b66SMauro Carvalho Chehab 2667ebd8b66SMauro Carvalho ChehabCheck if byte register exists. Return true if the register exists, false 2677ebd8b66SMauro Carvalho Chehabotherwise. 2687ebd8b66SMauro Carvalho ChehabThis function calls the device specific write_byte function if defined to 2697ebd8b66SMauro Carvalho Chehabobtain the chip status. Therefore, it must _not_ be called from that function. 2707ebd8b66SMauro Carvalho Chehab 2717ebd8b66SMauro Carvalho Chehab:: 2727ebd8b66SMauro Carvalho Chehab 2737ebd8b66SMauro Carvalho Chehab bool pmbus_check_word_register(struct i2c_client *client, int page, int reg); 2747ebd8b66SMauro Carvalho Chehab 2757ebd8b66SMauro Carvalho ChehabCheck if word register exists. Return true if the register exists, false 2767ebd8b66SMauro Carvalho Chehabotherwise. 2777ebd8b66SMauro Carvalho ChehabThis function calls the device specific write_byte function if defined to 2787ebd8b66SMauro Carvalho Chehabobtain the chip status. Therefore, it must _not_ be called from that function. 2797ebd8b66SMauro Carvalho Chehab 2807ebd8b66SMauro Carvalho Chehab:: 2817ebd8b66SMauro Carvalho Chehab 282dd431939SStephen Kitt int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info); 2837ebd8b66SMauro Carvalho Chehab 2847ebd8b66SMauro Carvalho ChehabExecute probe function. Similar to standard probe function for other drivers, 2857ebd8b66SMauro Carvalho Chehabwith the pointer to struct pmbus_driver_info as additional argument. Calls 2867ebd8b66SMauro Carvalho Chehabidentify function if supported. Must only be called from device probe 2877ebd8b66SMauro Carvalho Chehabfunction. 2887ebd8b66SMauro Carvalho Chehab 2897ebd8b66SMauro Carvalho Chehab:: 2907ebd8b66SMauro Carvalho Chehab 2917ebd8b66SMauro Carvalho Chehab const struct pmbus_driver_info 2927ebd8b66SMauro Carvalho Chehab *pmbus_get_driver_info(struct i2c_client *client); 2937ebd8b66SMauro Carvalho Chehab 2947ebd8b66SMauro Carvalho ChehabReturn pointer to struct pmbus_driver_info as passed to pmbus_do_probe(). 2957ebd8b66SMauro Carvalho Chehab 2967ebd8b66SMauro Carvalho Chehab 2977ebd8b66SMauro Carvalho ChehabPMBus driver platform data 2987ebd8b66SMauro Carvalho Chehab========================== 2997ebd8b66SMauro Carvalho Chehab 3007ebd8b66SMauro Carvalho ChehabPMBus platform data is defined in include/linux/pmbus.h. Platform data 301b976760dSErik Rosencurrently provides a flags field with four bits used:: 3027ebd8b66SMauro Carvalho Chehab 303b976760dSErik Rosen #define PMBUS_SKIP_STATUS_CHECK BIT(0) 304b976760dSErik Rosen 305b976760dSErik Rosen #define PMBUS_WRITE_PROTECTED BIT(1) 306b976760dSErik Rosen 307b976760dSErik Rosen #define PMBUS_NO_CAPABILITY BIT(2) 308b976760dSErik Rosen 309b976760dSErik Rosen #define PMBUS_READ_STATUS_AFTER_FAILED_CHECK BIT(3) 3107ebd8b66SMauro Carvalho Chehab 3117ebd8b66SMauro Carvalho Chehab struct pmbus_platform_data { 3127ebd8b66SMauro Carvalho Chehab u32 flags; /* Device specific flags */ 313b976760dSErik Rosen 314b976760dSErik Rosen /* regulator support */ 315b976760dSErik Rosen int num_regulators; 316b976760dSErik Rosen struct regulator_init_data *reg_init_data; 3177ebd8b66SMauro Carvalho Chehab }; 3187ebd8b66SMauro Carvalho Chehab 3197ebd8b66SMauro Carvalho Chehab 3207ebd8b66SMauro Carvalho ChehabFlags 3217ebd8b66SMauro Carvalho Chehab----- 3227ebd8b66SMauro Carvalho Chehab 3237ebd8b66SMauro Carvalho ChehabPMBUS_SKIP_STATUS_CHECK 324b976760dSErik Rosen 3257ebd8b66SMauro Carvalho ChehabDuring register detection, skip checking the status register for 3267ebd8b66SMauro Carvalho Chehabcommunication or command errors. 3277ebd8b66SMauro Carvalho Chehab 3287ebd8b66SMauro Carvalho ChehabSome PMBus chips respond with valid data when trying to read an unsupported 3297ebd8b66SMauro Carvalho Chehabregister. For such chips, checking the status register is mandatory when 3307ebd8b66SMauro Carvalho Chehabtrying to determine if a chip register exists or not. 3317ebd8b66SMauro Carvalho ChehabOther PMBus chips don't support the STATUS_CML register, or report 3327ebd8b66SMauro Carvalho Chehabcommunication errors for no explicable reason. For such chips, checking the 3337ebd8b66SMauro Carvalho Chehabstatus register must be disabled. 3347ebd8b66SMauro Carvalho Chehab 3357ebd8b66SMauro Carvalho ChehabSome i2c controllers do not support single-byte commands (write commands with 3367ebd8b66SMauro Carvalho Chehabno data, i2c_smbus_write_byte()). With such controllers, clearing the status 3377ebd8b66SMauro Carvalho Chehabregister is impossible, and the PMBUS_SKIP_STATUS_CHECK flag must be set. 338b976760dSErik Rosen 339b976760dSErik RosenPMBUS_WRITE_PROTECTED 340b976760dSErik Rosen 341b976760dSErik RosenSet if the chip is write protected and write protection is not determined 342b976760dSErik Rosenby the standard WRITE_PROTECT command. 343b976760dSErik Rosen 344b976760dSErik RosenPMBUS_NO_CAPABILITY 345b976760dSErik Rosen 346b976760dSErik RosenSome PMBus chips don't respond with valid data when reading the CAPABILITY 347b976760dSErik Rosenregister. For such chips, this flag should be set so that the PMBus core 348*d56b699dSBjorn Helgaasdriver doesn't use CAPABILITY to determine its behavior. 349b976760dSErik Rosen 350b976760dSErik RosenPMBUS_READ_STATUS_AFTER_FAILED_CHECK 351b976760dSErik Rosen 352b976760dSErik RosenRead the STATUS register after each failed register check. 353b976760dSErik Rosen 354b976760dSErik RosenSome PMBus chips end up in an undefined state when trying to read an 355b976760dSErik Rosenunsupported register. For such chips, it is necessary to reset the 356b976760dSErik Rosenchip pmbus controller to a known state after a failed register check. 357b976760dSErik RosenThis can be done by reading a known register. By setting this flag the 358b976760dSErik Rosendriver will try to read the STATUS register after each failed 359b976760dSErik Rosenregister check. This read may fail, but it will put the chip into a 360b976760dSErik Rosenknown state. 361