770de580 | 05-Nov-2021 |
Shawn McCarney <shawnmm@us.ibm.com> |
Add retry support to I2CInterface
Enhance the I2CInterface class hierarchy to support retrying failed I2C operations.
Add an optional parameter to i2c::create() to specify the maximum number of ret
Add retry support to I2CInterface
Enhance the I2CInterface class hierarchy to support retrying failed I2C operations.
Add an optional parameter to i2c::create() to specify the maximum number of retries to perform for an I2C operation. Default to 0 retries so that existing code will not be affected.
Testing: * Tested each modified function * When I2C operation succeeds * When I2C operation fails * When no retries are done * When retries are done * When retried operation succeeds * When retried operation fails * See complete test plan at https://gist.github.com/smccarney/8d203a40d9984402ac495dc3d689c12d
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: I2b0e782e5caaafa9908ef5625687377b959b38ff
show more ...
|
0c9a33d6 | 13-Sep-2021 |
Adriana Kobylak <anoo@us.ibm.com> |
clang updates
The openbmc CI was recently updated to clang-12 which requires some formatting updates to the code: https://github.com/openbmc/openbmc-build-scripts/commit/4569bf49daaebff06be048242690
clang updates
The openbmc CI was recently updated to clang-12 which requires some formatting updates to the code: https://github.com/openbmc/openbmc-build-scripts/commit/4569bf49daaebff06be0482426908bb5497fad08
Make those updates and refresh the clang-format file with the one from docs: https://github.com/openbmc/docs/blob/master/style/cpp/.clang-format
Change-Id: Ieb3626526373a053ec84431e7560003f229f338d Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
show more ...
|
8429e884 | 13-Dec-2020 |
Lei YU <yulei.sh@bytedance.com> |
i2c: Initialize variable ret
The varialbe `ret` in some functions is not initialized and cause the build warning and treated as error:
error: 'ret' may be used uninitialized in this function
i2c: Initialize variable ret
The varialbe `ret` in some functions is not initialized and cause the build warning and treated as error:
error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
Fixes openbmc/phosphor-power#3.
Signed-off-by: Lei YU <yulei.sh@bytedance.com> Change-Id: Ica6b1af434736f6fd96a1bbb9e511bf1c8fb1d7a
show more ...
|
e632e14a | 29-Feb-2020 |
Shawn McCarney <shawnmm@us.ibm.com> |
Document byte order of I2CInterface read/write
Update the doxygen comments for the following two I2CInterface methods: * void read(uint8_t addr, uint16_t& data); * void write(uint8_t addr, uint16_t
Document byte order of I2CInterface read/write
Update the doxygen comments for the following two I2CInterface methods: * void read(uint8_t addr, uint16_t& data); * void write(uint8_t addr, uint16_t data);
Document that the two bytes are transmitted with the low order byte first.
The I2CInterface methods call the following two i2c-dev functions: * i2c_smbus_read_word_data() * i2c_smbus_write_word_data()
The SMBus Read Word and Write Word protocols require the low order byte to be sent first.
Testing: * Tested on Witherspoon using i2cget and i2cset. These command line tools call the same two i2c-dev functions. Verified that the low order byte is read/written first.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: I83ba69f8cde08ee719d34802afed691a61fe3e84
show more ...
|
dc8e9312 | 14-Feb-2020 |
Brandon Wyman <bjwyman@gmail.com> |
Add OE-SDK option to Meson
Add option to enable oe-sdk which will setup linker arguments to allow for building and running tests with the x86 SDK.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com> C
Add OE-SDK option to Meson
Add option to enable oe-sdk which will setup linker arguments to allow for building and running tests with the x86 SDK.
Signed-off-by: Brandon Wyman <bjwyman@gmail.com> Change-Id: I8279b7d862e29235d2d4eae39405cc35a51b762f
show more ...
|
ff481438 | 13-Feb-2020 |
Shawn McCarney <shawnmm@us.ibm.com> |
Only build tests if -Dtests=enabled specified
A meson build option named 'tests' is defined for this repository. It indicates whether gtest/gmock tests should be built.
However, some tests are cur
Only build tests if -Dtests=enabled specified
A meson build option named 'tests' is defined for this repository. It indicates whether gtest/gmock tests should be built.
However, some tests are currently always built even if -Dtests=enabled isn't specified. This causes build errors in some environments where gtest and gmock are not available.
Modify meson.build files to only descend into 'test' subdirectories and build test cases if -Dtests=enabled was specified.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: Ic0da2326e3d9c273ff76d54b5ac27cbe00d78876
show more ...
|
b1216b96 | 21-Jan-2020 |
Shawn McCarney <shawnmm@us.ibm.com> |
Create libi2c_dev_mock.a to solve linker errors
The i2c::create() function is currently defined in mocked_i2c_interface.hpp. This causes linker errors if that header file is included by multiple .c
Create libi2c_dev_mock.a to solve linker errors
The i2c::create() function is currently defined in mocked_i2c_interface.hpp. This causes linker errors if that header file is included by multiple .cpp files in the same test executable.
Moved i2c::create() to mocked_i2c_interface.cpp so that it is only defined once. Created the static library libi2c_dev_mock.a that contains mocked_i2c_interface.o.
Test executables that need the mock version of i2c::create() should link with libi2c_dev_mock.a.
Normal executables that need the real version of i2c::create() should link with libi2c_dev.a as before. This has not changed.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: Ic00203c5429c1a2162327905ba547602258c6b0d
show more ...
|
d1bc4cec | 13-Dec-2019 |
Brandon Wyman <bjwyman@gmail.com> |
Update .clang-format to latest version from docs
Signed-off-by: Brandon Wyman <bjwyman@gmail.com> Change-Id: Ie6e7f43e7554429704dca86b21320c90aed18791 |
38ed88d6 | 11-Dec-2019 |
Shawn McCarney <shawnmm@us.ibm.com> |
i2c: Cache adapter functionality
Enhance the I2CDevice class to cache the I2C adapter functionality value. The adapter functionality value should not change while the device interface is open.
Cac
i2c: Cache adapter functionality
Enhance the I2CDevice class to cache the I2C adapter functionality value. The adapter functionality value should not change while the device interface is open.
Caching the functionality value will reduce the number of ioctl() calls by 50% when doing long sequences of I2C operations.
Tested: * Verified adapter functionality value is cached * Verified read() method works on a Witherspoon * Verified close() method discards the cached functionality value
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: I2b17d91ae4e21aaf52cd4cec9eddb5aab7be37e5
show more ...
|
d45a9a6d | 10-Dec-2019 |
Shawn McCarney <shawnmm@us.ibm.com> |
i2c: Support explicit open/close and re-open
Add the ability to explicitly open and close the I2CInterface/I2CDevice. Also add support to re-open the I2CInterface/I2CDevice after it was closed.
Thi
i2c: Support explicit open/close and re-open
Add the ability to explicitly open and close the I2CInterface/I2CDevice. Also add support to re-open the I2CInterface/I2CDevice after it was closed.
This support is needed for use cases like the following:
* I2C device information (bus and address) is parsed from a configuration file at standby. However, an I2C connection to the device should not be opened yet. The device may not have power until the system has been booted. Additionally, if the device is a FRU, it could be replaced (remove + add) while at standby, leading to communication errors.
* The device is sometimes bound to a device driver. The I2C connection should only be open during the time periods when the device driver is not bound.
Tested: * Verified create() function with default value of OPEN, explicit value of OPEN, and explicit value of CLOSED. * Verified device interface can be explicitly opened, closed, and re-opened. * Verified read() and write() functions still work when device interface is open. * Verified open() fails with appropriate error if already open. * Verified read() fails with appropriate error if not open. * Verified write() fails with appropriate error if not open. * Verified close() fails with appropriate error if not open.
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com> Change-Id: I0182966f0b0614eac0de69eb95d960035f9d0426
show more ...
|
1d103428 | 29-Nov-2019 |
Lei YU <mine260309@gmail.com> |
i2c: Add i2c block transaction support
The previous code always uses SMBus block read/write. On some PSU (e.g. FP5280G2's PSU) the I2C block read/write is required, so add that support.
Specificall
i2c: Add i2c block transaction support
The previous code always uses SMBus block read/write. On some PSU (e.g. FP5280G2's PSU) the I2C block read/write is required, so add that support.
Specifically, add a Mode enum class and add the parameter for block read/write to indicate whether SMBus or I2C block read/write is to be called.
Tested: Verify the code works on FP5280G2 with I2C block write.
Note: Currently there is no case for I2C block read, so that function is not tested.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I5f77ffe6900d14f3703dae7241799a7b37c5a726
show more ...
|
34fb8bda | 07-Nov-2019 |
Lei YU <mine260309@gmail.com> |
i2c: Implement write function
Implement I2CDevice::write() by invoking i2c_smbus_write_xxx() APIs. The code is referenced from i2c-tools' i2cset.c:
https://github.com/ev3dev/i2c-tools/blob/ev3dev-
i2c: Implement write function
Implement I2CDevice::write() by invoking i2c_smbus_write_xxx() APIs. The code is referenced from i2c-tools' i2cset.c:
https://github.com/ev3dev/i2c-tools/blob/ev3dev-stretch/tools/i2cset.c
Tested: Verify on Witherspoon that it writes the PSU unlock upgrade command and boot flag successfully.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I9fb014c787ef3ebb2f7793a0d012b1d652ef069f
show more ...
|
92e89eb5 | 06-Nov-2019 |
Lei YU <mine260309@gmail.com> |
i2c: Implement read function
Implement I2CDevice::read() by invoking i2c_smbus_read_xxx() APIs. The code is referenced from i2c-tools' i2cget.c:
https://github.com/ev3dev/i2c-tools/blob/ev3dev-str
i2c: Implement read function
Implement I2CDevice::read() by invoking i2c_smbus_read_xxx() APIs. The code is referenced from i2c-tools' i2cget.c:
https://github.com/ev3dev/i2c-tools/blob/ev3dev-stretch/tools/i2cget.c
Tested: Verify on Witherspoon that it reads the PSU ppgrade mode status register (1 byte) and CRC16 register (2 bytes) correctly.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I8759b6a35229f81120acf77f08429f7f79458b8b
show more ...
|
7c2fbbb6 | 06-Nov-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Initially use i2c in updater
Create I2CDevice in updater and invoke read() in doUpdate(), that could be used in future. Use mocked I2CInterface in updater's unit test case.
Tested: Man
power-utils: Initially use i2c in updater
Create I2CDevice in updater and invoke read() in doUpdate(), that could be used in future. Use mocked I2CInterface in updater's unit test case.
Tested: Manually verify on Witherspoon that the i2c device is opened and closed during PSU code update.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Ie3d9f0565a2ceb000f489647a58ca967a2ef0c38
show more ...
|
9af82a5c | 06-Nov-2019 |
Lei YU <mine260309@gmail.com> |
i2c: Implement open and close
Implement open() and close() function, and invoke open() on creating I2CDevice, and invoke close() in destructor.
Tested: Manually write test codet and run on Withersp
i2c: Implement open and close
Implement open() and close() function, and invoke open() on creating I2CDevice, and invoke close() in destructor.
Tested: Manually write test codet and run on Witherspoon that it opens and closes the i2c device correctly.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I709fcc80474a4a0cef067748a78256ceb76430a5
show more ...
|
ab1327c3 | 04-Nov-2019 |
Lei YU <mine260309@gmail.com> |
tools: Initially add i2c tool and mock
The power-utils will invoke i2c get/set commands to the i2c device for PSU code update. Create a separated i2c tool because it is logically standalone and coul
tools: Initially add i2c tool and mock
The power-utils will invoke i2c get/set commands to the i2c device for PSU code update. Create a separated i2c tool because it is logically standalone and could be shared for other utils. Also add an I2CInterface and its mock to make it easier to test when developing i2c related operations.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: If5383547e6d84c0a79610e2d2d6f2fa8ee9dc061
show more ...
|
e8c9cd64 | 04-Nov-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Implement isReadyToUpdate
Check other PSUs' status word and status vout, return false when the status has input/output fault.
Tested: Verify on Witherspoon that the update is not start
power-utils: Implement isReadyToUpdate
Check other PSUs' status word and status vout, return false when the status has input/output fault.
Tested: Verify on Witherspoon that the update is not started and log Unable to update PSU when other PSU has input/ouput fault when the other PSU has input/output error; And the update continues when the other PSU has no errors.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Ia2a4a23a43c18a417b8a85fbd5339f487984e689
show more ...
|
575ed139 | 29-Oct-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Initially add isReadyToUpdate
Initially add isReadyToUpdate() that checks the pre-condition for PSU update. For now it only checks the power state and return false if power is on.
When
power-utils: Initially add isReadyToUpdate
Initially add isReadyToUpdate() that checks the pre-condition for PSU update. For now it only checks the power state and return false if power is on.
When it is not ready to update, there is no need to unbind/bind the driver, so move the unbind/bind calls into doUpdate() from ctor/dtor.
Tested: Verify it returns and logs "PSU not ready to update" when power is on, and continues the update when power is off.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I1cbb454baf735ceb3de883a7317753d46485696f
show more ...
|
cfc040c7 | 29-Oct-2019 |
Lei YU <mine260309@gmail.com> |
Refactor: Move isPoweredOn to utility
The check of power on will be used by other components, so move it to utility. There are several constexpr definitions are used by multiple components, move the
Refactor: Move isPoweredOn to utility
The check of power on will be used by other components, so move it to utility. There are several constexpr definitions are used by multiple components, move them into types.hpp so that we do not have duplicated constexprs.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I42ad142d6e7ae8da9c0cf6d8f5cb21dee229eba2
show more ...
|
9ab6d750 | 28-Oct-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Initially add Updater class
The Updater class is used to do PSU code update, initially add it that does unbind/bind driver and set PSU present to false/true during the update.
Tested:
power-utils: Initially add Updater class
The Updater class is used to do PSU code update, initially add it that does unbind/bind driver and set PSU present to false/true during the update.
Tested: Manually verify on Witherspoon that the driver is unbind/bind, and the PSU present property is set to false/true during the PSU update: psutils --update \ /xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0 \ /tmp/images/xxxxxxxx
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Ic0a9df7687303caeb9a7f21ba00dc33ee76482db
show more ...
|
d19df255 | 25-Oct-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Initially add --update option
This option is used to update the PSU firmware, usage:
psutils --update <psu-inventory-path> <image-dir>
Signed-off-by: Lei YU <mine260309@gmail.com> Ch
power-utils: Initially add --update option
This option is used to update the PSU firmware, usage:
psutils --update <psu-inventory-path> <image-dir>
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: I3958e360f04bb0ace9eea41d9f81e4533432701c
show more ...
|
093b5917 | 22-Oct-2019 |
Lei YU <mine260309@gmail.com> |
power-utils: Add --compare option
This option is to get a latest version from a list of PSU versions.
Due to the --compare option requires a list of strings and only one option is supported at the
power-utils: Add --compare option
This option is to get a latest version from a list of PSU versions.
Due to the --compare option requires a list of strings and only one option is supported at the same time, it's easier to switch to CLI11 to parse the arguments.
Also add --raw option that outputs the text without linefeed.
Tested: Verify both --get-version and --compare works on Witherspoon.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Idec75e3a5699eba8ba587e74824431993fe10c4c
show more ...
|
0bf1b782 | 29-Aug-2019 |
Lei YU <mine260309@gmail.com> |
Add power-utils
The power-utils is added to support psu code manager as vendor-specifc tool. In this commit, the util returns the PSU version based on the PSU inventory path, where the inventory pat
Add power-utils
The power-utils is added to support psu code manager as vendor-specifc tool. In this commit, the util returns the PSU version based on the PSU inventory path, where the inventory path are mapped to the PSU sysfs device directory based on a json config.
Tested: Verify the version is returned correctly on Witherspoon: $ ./psutils --getversion \ /xyz/openbmc_project/inventory/system/chassis/motherboard/powersupply0 01100110 And it returns non-zero when it fails to get the version without throwing exception.
Signed-off-by: Lei YU <mine260309@gmail.com> Change-Id: Ib60f3aa50ce581d55fe4cd62642f30398e25be83
show more ...
|