diff options
author | Lei YU <mine260309@gmail.com> | 2017-07-13 17:02:23 +0800 |
---|---|---|
committer | Lei YU <mine260309@gmail.com> | 2017-08-28 10:31:42 +0800 |
commit | 0ab90ca75b825db8e2427ea62ea3ee212c9accbb (patch) | |
tree | 6d7934495cf7233f54f5bd882469056c4f700142 /i2c_occ.hpp | |
parent | 3ace7576176afed9196fb308c766de6b1252d3ea (diff) | |
download | openpower-occ-control-0ab90ca75b825db8e2427ea62ea3ee212c9accbb.tar.gz openpower-occ-control-0ab90ca75b825db8e2427ea62ea3ee212c9accbb.zip |
Add I2C OCC support for P8 systems
P8 system uses I2C OCC and it uses different driver for occ-hwmon.
Add `--enable-i2c-occ` configure option to enable the support.
It searches i2c device names in sysfs to get all occ-hwmon devices and
use the i2c device name to bind/unbind the driver.
The occ control object path for I2C OCC hwmon becomes something like
/org/open_power/control/3_0050, where 3_0050 is the i2c address.
Change-Id: I8b9d8d4429c563528dc88fb2679b265c53d7a2d5
Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'i2c_occ.hpp')
-rw-r--r-- | i2c_occ.hpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/i2c_occ.hpp b/i2c_occ.hpp new file mode 100644 index 0000000..31b6721 --- /dev/null +++ b/i2c_occ.hpp @@ -0,0 +1,69 @@ +#pragma once + +#include <experimental/filesystem> +#include <vector> + +#ifdef I2C_OCC + +namespace i2c_occ +{ + +namespace fs = std::experimental::filesystem; + +/** @brief Get file content + * + * Get at most NAME_LENGTH bytes of content from file. If the file is smaller + * than NAME_LENGTH bytes, return the valid parts. + * + * @param[in] f - The path of file + * + * @return The string of file content + */ +std::string getFileContent(const fs::path& f); + +/** @brief Find all devices of occ hwmon + * + * It iterates in path, finds all occ hwmon devices + * + * E.g. If "path/3-0050/name" exists and its content is "p8-occ-hwmon", + * "3-0050" is returned. + * + * @param[in] path - The path to search + * + * @return A vector of strings containing the occ hwmon device path + */ +std::vector<std::string> getOccHwmonDevices(const char* path); + +/** @brief Convert i2c name to DBus path + * + * It converts '-' to '_' so that it becomes a valid DBus path. + * E.g. 3-0050 converts to 3_0050 + * + * @param[in,out] path - The i2c name to convert + */ +void i2cToDbus(std::string& name); + +/** @brief Convert DBus path to i2c name + * + * It converts '_' to '_' so that it becomes a valid i2c name + * E.g. 3_0050 converts to 3-0050 + * + * @param[in,out] path - The DBus path to convert + */ +void dbusToI2c(std::string& path); + +/** @brief Get i2c name from full DBus path + * + * It extract the i2c name from the full DBus path. + * E.g. /org/open_power/control/3_0050 returns "3-0050" + * + * @param[in] dbusPath - The full DBus path + * + * @return The i2c name + */ +std::string getI2cDeviceName(const std::string& dbusPath); + +} // namespace i2c_occ + +#endif + |