1015e3adeSMatt Spinler #pragma once 2015e3adeSMatt Spinler 39c7897ceSBrandon Wyman #include <filesystem> 4015e3adeSMatt Spinler #include <string> 5015e3adeSMatt Spinler #include <vector> 6015e3adeSMatt Spinler 7ab093328SLei YU namespace phosphor 8015e3adeSMatt Spinler { 9015e3adeSMatt Spinler namespace pmbus 10015e3adeSMatt Spinler { 11015e3adeSMatt Spinler 129c7897ceSBrandon Wyman namespace fs = std::filesystem; 13ff5f339cSBrandon Wyman 144175ffb7SAdriana Kobylak // The file name Linux uses to capture the READ_VIN from pmbus. 154175ffb7SAdriana Kobylak constexpr auto READ_VIN = "in1_input"; 164175ffb7SAdriana Kobylak 17ae35ac5dSBrandon Wyman // The file name Linux uses to capture the MFR_POUT_MAX from pmbus. 18ae35ac5dSBrandon Wyman constexpr auto MFR_POUT_MAX = "max_power_out"; 19ae35ac5dSBrandon Wyman // The max_power_out value expected to be read for 1400W IBM CFFPS type. 20ae35ac5dSBrandon Wyman constexpr auto IBM_CFFPS_1400W = 30725; 21ae35ac5dSBrandon Wyman 224175ffb7SAdriana Kobylak namespace in_input 234175ffb7SAdriana Kobylak { 244175ffb7SAdriana Kobylak // VIN thresholds in Volts 254175ffb7SAdriana Kobylak constexpr auto VIN_VOLTAGE_MIN = 20; 264175ffb7SAdriana Kobylak constexpr auto VIN_VOLTAGE_110_THRESHOLD = 160; 274175ffb7SAdriana Kobylak 284175ffb7SAdriana Kobylak // VIN actual values in Volts 294175ffb7SAdriana Kobylak // VIN_VOLTAGE_0: VIN < VIN_VOLTAGE_MIN 304175ffb7SAdriana Kobylak // VIN_VOLTAGE_110: VIN_VOLTAGE_MIN < VIN < VIN_VOLTAGE_110_THRESHOLD 314175ffb7SAdriana Kobylak // VIN_VOLTAGE_220: VIN_VOLTAGE_110_THRESHOLD < VIN 324175ffb7SAdriana Kobylak constexpr auto VIN_VOLTAGE_0 = 0; 334175ffb7SAdriana Kobylak constexpr auto VIN_VOLTAGE_110 = 110; 344175ffb7SAdriana Kobylak constexpr auto VIN_VOLTAGE_220 = 220; 354175ffb7SAdriana Kobylak } // namespace in_input 364175ffb7SAdriana Kobylak 3710295547SBrandon Wyman // The file name Linux uses to capture the STATUS_WORD from pmbus. 38e7e432b4SMatt Spinler constexpr auto STATUS_WORD = "status0"; 3910295547SBrandon Wyman 40253dc9b9SBrandon Wyman // The file name Linux uses to capture the STATUS_INPUT from pmbus. 41253dc9b9SBrandon Wyman constexpr auto STATUS_INPUT = "status0_input"; 42e7e432b4SMatt Spinler 43764c797eSBrandon Wyman // Voltage out status. 44764c797eSBrandon Wyman // Overvoltage fault or warning, Undervoltage fault or warning, maximum or 45764c797eSBrandon Wyman // minimum warning, .... 46e7e432b4SMatt Spinler // Uses Page substitution 47e7e432b4SMatt Spinler constexpr auto STATUS_VOUT = "statusP_vout"; 48e7e432b4SMatt Spinler 49de16d053SMatt Spinler namespace status_vout 50de16d053SMatt Spinler { 51de16d053SMatt Spinler // Mask of bits that are only warnings 52de16d053SMatt Spinler constexpr auto WARNING_MASK = 0x6A; 53f0f02b9aSMatt Spinler } // namespace status_vout 54de16d053SMatt Spinler 55764c797eSBrandon Wyman // Current output status bits. 56764c797eSBrandon Wyman constexpr auto STATUS_IOUT = "status0_iout"; 57764c797eSBrandon Wyman 58764c797eSBrandon Wyman // Manufacturing specific status bits 59764c797eSBrandon Wyman constexpr auto STATUS_MFR = "status0_mfr"; 60764c797eSBrandon Wyman 6112661f1eSBrandon Wyman // Reports on the status of any fans installed in position 1 and 2. 6208cac06bSBrandon Wyman constexpr auto STATUS_FANS_1_2 = "status0_fan12"; 6312661f1eSBrandon Wyman 6412661f1eSBrandon Wyman // Reports on temperature faults or warnings. Overtemperature fault, 6512661f1eSBrandon Wyman // overtemperature warning, undertemperature warning, undertemperature fault. 6612661f1eSBrandon Wyman constexpr auto STATUS_TEMPERATURE = "status0_temp"; 6712661f1eSBrandon Wyman 6885c7bf41SBrandon Wyman // Reports on the communication, memory, logic fault(s). 6985c7bf41SBrandon Wyman constexpr auto STATUS_CML = "status0_cml"; 7085c7bf41SBrandon Wyman 71e7e432b4SMatt Spinler namespace status_word 72e7e432b4SMatt Spinler { 73e7e432b4SMatt Spinler constexpr auto VOUT_FAULT = 0x8000; 74764c797eSBrandon Wyman 75764c797eSBrandon Wyman // The IBM CFF power supply driver does map this bit to power1_alarm in the 76764c797eSBrandon Wyman // hwmon space, but since the other bits that need to be checked do not have 77764c797eSBrandon Wyman // a similar mapping, the code will just read STATUS_WORD and use bit masking 78764c797eSBrandon Wyman // to see if the INPUT FAULT OR WARNING bit is on. 79764c797eSBrandon Wyman constexpr auto INPUT_FAULT_WARN = 0x2000; 80764c797eSBrandon Wyman 813f1242f3SBrandon Wyman // The bit mask representing the MFRSPECIFIC fault, bit 4 of STATUS_WORD high 823f1242f3SBrandon Wyman // byte. A manufacturer specific fault or warning has occurred. 833f1242f3SBrandon Wyman constexpr auto MFR_SPECIFIC_FAULT = 0x1000; 843f1242f3SBrandon Wyman 85764c797eSBrandon Wyman // The bit mask representing the POWER_GOOD Negated bit of the STATUS_WORD. 86764c797eSBrandon Wyman constexpr auto POWER_GOOD_NEGATED = 0x0800; 87764c797eSBrandon Wyman 8812661f1eSBrandon Wyman // The bit mask representing the FAN FAULT or WARNING bit of the STATUS_WORD. 8912661f1eSBrandon Wyman // Bit 2 of the high byte of STATUS_WORD. 9012661f1eSBrandon Wyman constexpr auto FAN_FAULT = 0x0400; 9112661f1eSBrandon Wyman 92764c797eSBrandon Wyman // The bit mask representing the UNITI_IS_OFF bit of the STATUS_WORD. 93764c797eSBrandon Wyman constexpr auto UNIT_IS_OFF = 0x0040; 94764c797eSBrandon Wyman 95ab05c079SBrandon Wyman // Bit 5 of the STATUS_BYTE, or lower byte of STATUS_WORD is used to indicate 96ab05c079SBrandon Wyman // an output overvoltage fault. 97ab05c079SBrandon Wyman constexpr auto VOUT_OV_FAULT = 0x0020; 98ab05c079SBrandon Wyman 99b165c251SBrandon Wyman // The bit mask representing that an output overcurrent fault has occurred. 100b165c251SBrandon Wyman constexpr auto IOUT_OC_FAULT = 0x0010; 101b165c251SBrandon Wyman 102764c797eSBrandon Wyman // The IBM CFF power supply driver does map this bit to in1_alarm, however, 103764c797eSBrandon Wyman // since a number of the other bits are not mapped that way for STATUS_WORD, 104764c797eSBrandon Wyman // this code will just read the entire STATUS_WORD and use bit masking to find 105764c797eSBrandon Wyman // out if that fault is on. 106764c797eSBrandon Wyman constexpr auto VIN_UV_FAULT = 0x0008; 107764c797eSBrandon Wyman 108875b363cSBrandon Wyman // The bit mask representing the TEMPERATURE FAULT or WARNING bit of the 109875b363cSBrandon Wyman // STATUS_WORD. Bit 2 of the low byte (STATUS_BYTE). 110875b363cSBrandon Wyman constexpr auto TEMPERATURE_FAULT_WARN = 0x0004; 111875b363cSBrandon Wyman 11285c7bf41SBrandon Wyman // The bit mask representing the CML (Communication, Memory, and/or Logic) fault 11385c7bf41SBrandon Wyman // bit of the STATUS_WORD. Bit 1 of the low byte (STATUS_BYTE). 11485c7bf41SBrandon Wyman constexpr auto CML_FAULT = 0x0002; 115f0f02b9aSMatt Spinler } // namespace status_word 116875b363cSBrandon Wyman 117e8c9cd64SLei YU namespace status_vout 118e8c9cd64SLei YU { 119e8c9cd64SLei YU // The IBM CFF power supply driver maps MFR's OV_FAULT and VAUX_FAULT to this 120e8c9cd64SLei YU // bit. 121e8c9cd64SLei YU constexpr auto OV_FAULT = 0x80; 122e8c9cd64SLei YU 123e8c9cd64SLei YU // The IBM CFF power supply driver maps MFR's UV_FAULT to this bit. 124e8c9cd64SLei YU constexpr auto UV_FAULT = 0x10; 125e8c9cd64SLei YU } // namespace status_vout 126e8c9cd64SLei YU 127875b363cSBrandon Wyman namespace status_temperature 128875b363cSBrandon Wyman { 129875b363cSBrandon Wyman // Overtemperature Fault 130875b363cSBrandon Wyman constexpr auto OT_FAULT = 0x80; 131f0f02b9aSMatt Spinler } // namespace status_temperature 132e7e432b4SMatt Spinler 13359a35793SBrandon Wyman constexpr auto ON_OFF_CONFIG = "on_off_config"; 13459a35793SBrandon Wyman 13559a35793SBrandon Wyman // From PMBus Specification Part II Revsion 1.2: 13659a35793SBrandon Wyman // The ON_OFF_CONFIG command configures the combination of CONTROL pin input 13759a35793SBrandon Wyman // and serial bus commands needed to turn the unit on and off. This includes how 13859a35793SBrandon Wyman // the unit responds when power is applied. 13959a35793SBrandon Wyman // Bits [7:5] - 000 - Reserved 14059a35793SBrandon Wyman // Bit 4 - 1 - Unit does not power up until commanded by the CONTROL pin and 14159a35793SBrandon Wyman // OPERATION command (as programmed in bits [3:0]). 14259a35793SBrandon Wyman // Bit 3 - 0 - Unit ignores the on/off portion of the OPERATION command from 14359a35793SBrandon Wyman // serial bus. 14459a35793SBrandon Wyman // Bit 2 - 1 - Unit requires the CONTROL pin to be asserted to start the unit. 14559a35793SBrandon Wyman // Bit 1 - 0 - Polarity of the CONTROL pin. Active low (Pull pin low to start 14659a35793SBrandon Wyman // the unit). 14759a35793SBrandon Wyman // Bit 0 - 1 - Turn off the output and stop transferring energy to the output as 14859a35793SBrandon Wyman // fast as possible. 14959a35793SBrandon Wyman constexpr auto ON_OFF_CONFIG_CONTROL_PIN_ONLY = 0x15; 15059a35793SBrandon Wyman 151015e3adeSMatt Spinler /** 1524dc4678eSMatt Spinler * Where the access should be done 15357868bc5SMatt Spinler */ 15457868bc5SMatt Spinler enum class Type 15557868bc5SMatt Spinler { 1564dc4678eSMatt Spinler Base, // base device directory 1574dc4678eSMatt Spinler Hwmon, // hwmon directory 1584dc4678eSMatt Spinler Debug, // pmbus debug directory 1594dc4678eSMatt Spinler DeviceDebug, // device debug directory 1604dc4678eSMatt Spinler HwmonDeviceDebug // hwmon device debug directory 16157868bc5SMatt Spinler }; 16257868bc5SMatt Spinler 16357868bc5SMatt Spinler /** 1648d195771SBrandon Wyman * @class PMBusBase 1658d195771SBrandon Wyman * 1668d195771SBrandon Wyman * This is a base class for PMBus to assist with unit testing via mocking. 1678d195771SBrandon Wyman */ 1688d195771SBrandon Wyman class PMBusBase 1698d195771SBrandon Wyman { 1708d195771SBrandon Wyman public: 1718d195771SBrandon Wyman virtual ~PMBusBase() = default; 1723f1242f3SBrandon Wyman 17332453e9bSBrandon Wyman virtual uint64_t read(const std::string& name, Type type, 17432453e9bSBrandon Wyman bool errTrace = true) = 0; 1751d7a7df8SBrandon Wyman virtual std::string readString(const std::string& name, Type type) = 0; 176c3324424SBrandon Wyman virtual std::vector<uint8_t> readBinary(const std::string& name, Type type, 177c3324424SBrandon Wyman size_t length) = 0; 17859a35793SBrandon Wyman virtual void writeBinary(const std::string& name, std::vector<uint8_t> data, 17959a35793SBrandon Wyman Type type) = 0; 1809564e945SBrandon Wyman virtual void findHwmonDir() = 0; 1814176d6beSBrandon Wyman virtual const fs::path& path() const = 0; 1826710ba2cSBrandon Wyman virtual std::string insertPageNum(const std::string& templateName, 1836710ba2cSBrandon Wyman size_t page) = 0; 184fb0ccb8eSShawn McCarney virtual fs::path getPath(Type type) = 0; 1858d195771SBrandon Wyman }; 1868d195771SBrandon Wyman 1878d195771SBrandon Wyman /** 1888d195771SBrandon Wyman * Wrapper function for PMBus 1898d195771SBrandon Wyman * 1908d195771SBrandon Wyman * @param[in] bus - I2C bus 1918d195771SBrandon Wyman * @param[in] address - I2C address (as a 2-byte string, e.g. 0069) 1928d195771SBrandon Wyman * 1938d195771SBrandon Wyman * @return PMBusBase pointer 1948d195771SBrandon Wyman */ 1958d195771SBrandon Wyman std::unique_ptr<PMBusBase> createPMBus(std::uint8_t bus, 1968d195771SBrandon Wyman const std::string& address); 1978d195771SBrandon Wyman 1988d195771SBrandon Wyman /** 199015e3adeSMatt Spinler * @class PMBus 200015e3adeSMatt Spinler * 201015e3adeSMatt Spinler * This class is an interface to communicating with PMBus devices 202015e3adeSMatt Spinler * by reading and writing sysfs files. 20357868bc5SMatt Spinler * 20457868bc5SMatt Spinler * Based on the Type parameter, the accesses can either be done 20557868bc5SMatt Spinler * in the base device directory (the one passed into the constructor), 20657868bc5SMatt Spinler * or in the hwmon directory for the device. 207015e3adeSMatt Spinler */ 2088d195771SBrandon Wyman class PMBus : public PMBusBase 209015e3adeSMatt Spinler { 210015e3adeSMatt Spinler public: 211015e3adeSMatt Spinler PMBus() = delete; 2128d195771SBrandon Wyman virtual ~PMBus() = default; 213015e3adeSMatt Spinler PMBus(const PMBus&) = default; 214015e3adeSMatt Spinler PMBus& operator=(const PMBus&) = default; 215015e3adeSMatt Spinler PMBus(PMBus&&) = default; 216015e3adeSMatt Spinler PMBus& operator=(PMBus&&) = default; 217015e3adeSMatt Spinler 218015e3adeSMatt Spinler /** 219015e3adeSMatt Spinler * Constructor 220015e3adeSMatt Spinler * 221015e3adeSMatt Spinler * @param[in] path - path to the sysfs directory 222015e3adeSMatt Spinler */ PMBus(const std::string & path)223f0f02b9aSMatt Spinler PMBus(const std::string& path) : basePath(path) 224015e3adeSMatt Spinler { 225ff5f339cSBrandon Wyman findHwmonDir(); 226015e3adeSMatt Spinler } 227015e3adeSMatt Spinler 228015e3adeSMatt Spinler /** 2298f0d953fSMatt Spinler * Constructor 2308f0d953fSMatt Spinler * 2318f0d953fSMatt Spinler * This version is required when DeviceDebug 2328f0d953fSMatt Spinler * access will be used. 2338f0d953fSMatt Spinler * 2348f0d953fSMatt Spinler * @param[in] path - path to the sysfs directory 2358f0d953fSMatt Spinler * @param[in] driverName - the device driver name 2368f0d953fSMatt Spinler * @param[in] instance - chip instance number 2378f0d953fSMatt Spinler */ PMBus(const std::string & path,const std::string & driverName,size_t instance)238f0f02b9aSMatt Spinler PMBus(const std::string& path, const std::string& driverName, 2398f0d953fSMatt Spinler size_t instance) : 240f5402197SPatrick Williams basePath(path), driverName(driverName), instance(instance) 2418f0d953fSMatt Spinler { 2428f0d953fSMatt Spinler findHwmonDir(); 2438f0d953fSMatt Spinler } 2448f0d953fSMatt Spinler 2458f0d953fSMatt Spinler /** 2468d195771SBrandon Wyman * Wrapper function for PMBus 2478d195771SBrandon Wyman * 2488d195771SBrandon Wyman * @param[in] bus - I2C bus 2498d195771SBrandon Wyman * @param[in] address - I2C address (as a 2-byte string, e.g. 0069) 2508d195771SBrandon Wyman * 2518d195771SBrandon Wyman * @return PMBusBase pointer 2528d195771SBrandon Wyman */ 253f5402197SPatrick Williams static std::unique_ptr<PMBusBase> 254f5402197SPatrick Williams createPMBus(std::uint8_t bus, const std::string& address); 2558d195771SBrandon Wyman 2568d195771SBrandon Wyman /** 257015e3adeSMatt Spinler * Reads a file in sysfs that represents a single bit, 258015e3adeSMatt Spinler * therefore doing a PMBus read. 259015e3adeSMatt Spinler * 260015e3adeSMatt Spinler * @param[in] name - path concatenated to 261015e3adeSMatt Spinler * basePath to read 2628f0d953fSMatt Spinler * @param[in] type - Path type 263015e3adeSMatt Spinler * 264015e3adeSMatt Spinler * @return bool - false if result was 0, else true 265015e3adeSMatt Spinler */ 26657868bc5SMatt Spinler bool readBit(const std::string& name, Type type); 267015e3adeSMatt Spinler 268015e3adeSMatt Spinler /** 269015e3adeSMatt Spinler * Reads a file in sysfs that represents a single bit, 270015e3adeSMatt Spinler * where the page number passed in is substituted 271015e3adeSMatt Spinler * into the name in place of the 'P' character in it. 272015e3adeSMatt Spinler * 273015e3adeSMatt Spinler * @param[in] name - path concatenated to 274015e3adeSMatt Spinler * basePath to read 275015e3adeSMatt Spinler * @param[in] page - page number 2768f0d953fSMatt Spinler * @param[in] type - Path type 277015e3adeSMatt Spinler * 278015e3adeSMatt Spinler * @return bool - false if result was 0, else true 279015e3adeSMatt Spinler */ 280f0f02b9aSMatt Spinler bool readBitInPage(const std::string& name, size_t page, Type type); 281f855e82aSBrandon Wyman /** 2823b7b38baSBrandon Wyman * Checks if the file for the given name and type exists. 2833b7b38baSBrandon Wyman * 2843b7b38baSBrandon Wyman * @param[in] name - path concatenated to basePath to read 2853b7b38baSBrandon Wyman * @param[in] type - Path type 2863b7b38baSBrandon Wyman * 2873b7b38baSBrandon Wyman * @return bool - True if file exists, false if it does not. 2883b7b38baSBrandon Wyman */ 2893b7b38baSBrandon Wyman bool exists(const std::string& name, Type type); 2903b7b38baSBrandon Wyman 2913b7b38baSBrandon Wyman /** 292f855e82aSBrandon Wyman * Read byte(s) from file in sysfs. 293f855e82aSBrandon Wyman * 294f855e82aSBrandon Wyman * @param[in] name - path concatenated to basePath to read 2958f0d953fSMatt Spinler * @param[in] type - Path type 29632453e9bSBrandon Wyman * @param[in] errTrace - true to enable tracing error (defaults to true) 297f855e82aSBrandon Wyman * 298f855e82aSBrandon Wyman * @return uint64_t - Up to 8 bytes of data read from file. 299f855e82aSBrandon Wyman */ 30032453e9bSBrandon Wyman uint64_t read(const std::string& name, Type type, 30132453e9bSBrandon Wyman bool errTrace = true) override; 302015e3adeSMatt Spinler 303015e3adeSMatt Spinler /** 304fbae7b6cSMatt Spinler * Read a string from file in sysfs. 305fbae7b6cSMatt Spinler * 306fbae7b6cSMatt Spinler * @param[in] name - path concatenated to basePath to read 307fbae7b6cSMatt Spinler * @param[in] type - Path type 308fbae7b6cSMatt Spinler * 309fbae7b6cSMatt Spinler * @return string - The data read from the file. 310fbae7b6cSMatt Spinler */ 3111d7a7df8SBrandon Wyman std::string readString(const std::string& name, Type type) override; 312fbae7b6cSMatt Spinler 313fbae7b6cSMatt Spinler /** 314fa23e330SMatt Spinler * Read data from a binary file in sysfs. 315fa23e330SMatt Spinler * 316fa23e330SMatt Spinler * @param[in] name - path concatenated to basePath to read 317fa23e330SMatt Spinler * @param[in] type - Path type 318fa23e330SMatt Spinler * @param[in] length - length of data to read, in bytes 319fa23e330SMatt Spinler * 320fa23e330SMatt Spinler * @return vector<uint8_t> - The data read from the file. 321fa23e330SMatt Spinler */ 322f0f02b9aSMatt Spinler std::vector<uint8_t> readBinary(const std::string& name, Type type, 323*12c4a420SJayanth Othayoth size_t length) override; 324fa23e330SMatt Spinler 325fa23e330SMatt Spinler /** 326015e3adeSMatt Spinler * Writes an integer value to the file, therefore doing 327015e3adeSMatt Spinler * a PMBus write. 328015e3adeSMatt Spinler * 329015e3adeSMatt Spinler * @param[in] name - path concatenated to 330015e3adeSMatt Spinler * basePath to write 331015e3adeSMatt Spinler * @param[in] value - the value to write 3328f0d953fSMatt Spinler * @param[in] type - Path type 333015e3adeSMatt Spinler */ 33457868bc5SMatt Spinler void write(const std::string& name, int value, Type type); 335015e3adeSMatt Spinler 336015e3adeSMatt Spinler /** 33759a35793SBrandon Wyman * Writes binary data to a file in sysfs. 33859a35793SBrandon Wyman * 33959a35793SBrandon Wyman * @param[in] name - path concatenated to basePath to write 34059a35793SBrandon Wyman * @param[in] data - The data to write to the file 34159a35793SBrandon Wyman * @param[in] type - Path type 34259a35793SBrandon Wyman */ 34359a35793SBrandon Wyman void writeBinary(const std::string& name, std::vector<uint8_t> data, 34459a35793SBrandon Wyman Type type) override; 34559a35793SBrandon Wyman 34659a35793SBrandon Wyman /** 347015e3adeSMatt Spinler * Returns the sysfs base path of this device 348015e3adeSMatt Spinler */ path() const3494176d6beSBrandon Wyman const fs::path& path() const override 350015e3adeSMatt Spinler { 351015e3adeSMatt Spinler return basePath; 352015e3adeSMatt Spinler } 353015e3adeSMatt Spinler 354015e3adeSMatt Spinler /** 355015e3adeSMatt Spinler * Replaces the 'P' in the string passed in with 356015e3adeSMatt Spinler * the page number passed in. 357015e3adeSMatt Spinler * 358015e3adeSMatt Spinler * For example: 359015e3adeSMatt Spinler * insertPageNum("inP_enable", 42) 360015e3adeSMatt Spinler * returns "in42_enable" 361015e3adeSMatt Spinler * 362015e3adeSMatt Spinler * @param[in] templateName - the name string, with a 'P' in it 363015e3adeSMatt Spinler * @param[in] page - the page number to insert where the P was 364015e3adeSMatt Spinler * 365015e3adeSMatt Spinler * @return string - the new string with the page number in it 366015e3adeSMatt Spinler */ 3676710ba2cSBrandon Wyman std::string insertPageNum(const std::string& templateName, 3686710ba2cSBrandon Wyman size_t page) override; 369015e3adeSMatt Spinler 37057868bc5SMatt Spinler /** 37157868bc5SMatt Spinler * Finds the path relative to basePath to the hwmon directory 37257868bc5SMatt Spinler * for the device and stores it in hwmonRelPath. 37357868bc5SMatt Spinler */ 3749564e945SBrandon Wyman void findHwmonDir() override; 375ff5f339cSBrandon Wyman 376ff5f339cSBrandon Wyman /** 377ff5f339cSBrandon Wyman * Returns the path to use for the passed in type. 378ff5f339cSBrandon Wyman * 3798f0d953fSMatt Spinler * @param[in] type - Path type 380ff5f339cSBrandon Wyman * 3818f0d953fSMatt Spinler * @return fs::path - the full path 382ff5f339cSBrandon Wyman */ 383fb0ccb8eSShawn McCarney fs::path getPath(Type type) override; 38457868bc5SMatt Spinler 385015e3adeSMatt Spinler private: 386015e3adeSMatt Spinler /** 387ba05348fSMatt Spinler * Returns the device name 388ba05348fSMatt Spinler * 389ba05348fSMatt Spinler * This is found in the 'name' file in basePath. 390ba05348fSMatt Spinler * 391ba05348fSMatt Spinler * @return string - the device name 392ba05348fSMatt Spinler */ 393ba05348fSMatt Spinler std::string getDeviceName(); 394ba05348fSMatt Spinler 395ba05348fSMatt Spinler /** 396015e3adeSMatt Spinler * The sysfs device path 397015e3adeSMatt Spinler */ 398ff5f339cSBrandon Wyman fs::path basePath; 399015e3adeSMatt Spinler 40057868bc5SMatt Spinler /** 401ff5f339cSBrandon Wyman * The directory name under the basePath hwmon directory 40257868bc5SMatt Spinler */ 403ff5f339cSBrandon Wyman fs::path hwmonDir; 404ff5f339cSBrandon Wyman 405ff5f339cSBrandon Wyman /** 4068f0d953fSMatt Spinler * The device driver name. Used for finding the device 4078f0d953fSMatt Spinler * debug directory. Not required if that directory 4088f0d953fSMatt Spinler * isn't used. 4098f0d953fSMatt Spinler */ 4108f0d953fSMatt Spinler std::string driverName; 4118f0d953fSMatt Spinler 4128f0d953fSMatt Spinler /** 4138f0d953fSMatt Spinler * The device instance number. 4148f0d953fSMatt Spinler * 415cab48342SGunnar Mills * Used in conjunction with the driver name for finding 4168f0d953fSMatt Spinler * the debug directory. Not required if that directory 4178f0d953fSMatt Spinler * isn't used. 4188f0d953fSMatt Spinler */ 4198f0d953fSMatt Spinler size_t instance = 0; 4208f0d953fSMatt Spinler 4218f0d953fSMatt Spinler /** 422ff5f339cSBrandon Wyman * The pmbus debug path with status files 423ff5f339cSBrandon Wyman */ 4248f0d953fSMatt Spinler const fs::path debugPath = "/sys/kernel/debug/"; 425015e3adeSMatt Spinler }; 426015e3adeSMatt Spinler 427f0f02b9aSMatt Spinler } // namespace pmbus 428ab093328SLei YU } // namespace phosphor 429