History log of /openbmc/phosphor-power/tools/i2c/i2c.hpp (Results 1 – 14 of 14)
Revision Date Author Comments
# 28a2ca4b 13-Dec-2024 Jayanth Othayoth <ojayanth@gmail.com>

clang-tidy: Remove unused private field

The following errors were reported during clang-tidy enablement due
to unused private field.

'''
tools/i2c/i2c.hpp:43:13: error: private field 'busId' is no

clang-tidy: Remove unused private field

The following errors were reported during clang-tidy enablement due
to unused private field.

'''
tools/i2c/i2c.hpp:43:13: error: private field 'busId' is not used [-Werror
'''

The fix involves removing these unused private field 'busId'.

Tested: Build and unit testing verified.

Change-Id: I1fac353707e250ff661d4f42abdb1a2e9bb3a689
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>

show more ...


# 12c4a420 06-Dec-2024 Jayanth Othayoth <ojayanth@gmail.com>

clang-tidy: Fix override errors

The following errors were reported during the clang-tidy enablement
build due to overridden functions not being marked with the override
keyword. The proposed fix is

clang-tidy: Fix override errors

The following errors were reported during the clang-tidy enablement
build due to overridden functions not being marked with the override
keyword. The proposed fix is to add the override keyword where it
was missing.

'''
1m../tools/i2c/i2c.hpp:176:10:
error: 'open' overrides a member function but is not marked 'override' [-Werror
1m../tools/i2c/i2c.hpp:179:10:
error: 'isOpen' overrides a member function but is not marked 'override' [-Werror
1m../tools/i2c/i2c.hpp:185:10:
error: 'close' overrides a member function but is not marked 'override' [-Werror
'''

Tested: Verified Build and unit testing.

Change-Id: Iad01481761c6a4339e051c183c3dd238baf19d70
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>

show more ...


# a3ff7e71 15-Oct-2024 Shawn McCarney <shawnmm@us.ibm.com>

I2CInterface: Add process call methods

Add C++ methods to perform the following SMBus commands:
* Process Call
* Block Write-Block Read Process Call

For Block Write-Block Read Process Call, impleme

I2CInterface: Add process call methods

Add C++ methods to perform the following SMBus commands:
* Process Call
* Block Write-Block Read Process Call

For Block Write-Block Read Process Call, implement support for writes up
to 255 bytes. SMBus 2.0 supported a maximum of 32 bytes, and SMBus 3.0
supports a maximum of 255 bytes. The current Linux SMBus function only
supports 32 byte writes. Provide an alternate implementation using the
lower level I2C_RDWR ioctl() to support up to 255 bytes.

Tested:
* Verified Process Call worked correctly
* Verified Block Write-Block Read Process Call worked correctly
* When using SMBus function
* When using I2C_RDWR ioctl()
* Tested error cases
* See complete test plan at
https://gist.github.com/smccarney/96eda4c7c11fe4f89e4491c768f76047

Change-Id: Icc1ba840741b1e26a50fe32bad8b2181a01dbb24
Signed-off-by: Shawn McCarney <shawnmm@us.ibm.com>

show more ...


# f5402197 16-Aug-2024 Patrick Williams <patrick@stwcx.xyz>

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda forma

clang-format: re-format for clang-18

clang-format-18 isn't compatible with the clang-format-17 output, so we
need to reformat the code with the latest version. The way clang-18
handles lambda formatting also changed, so we have made changes to the
organization default style format to better handle lambda formatting.

See I5e08687e696dd240402a2780158664b7113def0e for updated style.
See Iea0776aaa7edd483fa395e23de25ebf5a6288f71 for clang-18 enablement.

Change-Id: I7b90380845efee6bf6a1fe342a793d71aa9ff181
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>

show more ...


# b9cf0d2b 27-Feb-2023 George Liu <liuxiwei@inspur.com>

tools: Fix some warnings by cppcheck

Warning message:
tools/i2c/i2c.hpp:30:9: performance: Variable 'busStr' is assigned in
constructor body. Consider performing initialization in
initialization lis

tools: Fix some warnings by cppcheck

Warning message:
tools/i2c/i2c.hpp:30:9: performance: Variable 'busStr' is assigned in
constructor body. Consider performing initialization in
initialization list. [useInitializationList]
busStr = "/dev/i2c-" + std::to_string(busId);
^

tools/power-utils/updater.cpp:213:18: style: Local variable 'devPath'
shadows outer variable [shadowVariable]
auto devPath = internal::getDevicePath(p);
^
tools/power-utils/updater.hpp:108:17: note: Shadowed declaration
std::string devPath;
^
tools/power-utils/updater.cpp:213:18: note: Shadow variable
auto devPath = internal::getDevicePath(p);
^

Tested: Verify that there are no such warnings in local CI.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibc7536345ee40579256c398646ad00a05b686ab3

show more ...


# 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 ...


# 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 ...


# 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 ...