Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysfs i2c: support smbus-only adapters #15

Open
vamposdecampos opened this issue Mar 9, 2022 · 1 comment
Open

sysfs i2c: support smbus-only adapters #15

vamposdecampos opened this issue Mar 9, 2022 · 1 comment

Comments

@vamposdecampos
Copy link

There are kernel i2c bus adapters that don't support generic I2C, but only support smbus operations. For example:

; i2cdetect -l | grep smbus
i2c-0	smbus     	SMBus I801 adapter at 5040      	SMBus adapter

; i2cdetect -F 0
Functionalities implemented by /dev/i2c-0:
I2C                              no
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               no
SMBus Block Write                yes
SMBus Block Read                 yes
SMBus Block Process Call         yes
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes

; i2ctransfer -y 0  w1@0x50 0x10 r4
Error: Adapter does not have I2C transfers capability

; cat /proc/version
Linux version 5.4.0-100-generic (buildd@lcy02-amd64-002) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022

; grep . /sys/class/dmi/id/*_* | grep -v -E '_(serial|uuid):'
/sys/class/dmi/id/bios_date:05/13/2013
/sys/class/dmi/id/bios_vendor:Dell Inc.
/sys/class/dmi/id/bios_version:A15
/sys/class/dmi/id/board_name:0C05GV
/sys/class/dmi/id/board_vendor:Dell Inc.
/sys/class/dmi/id/board_version:A02
/sys/class/dmi/id/chassis_type:8
/sys/class/dmi/id/chassis_vendor:Dell Inc.
/sys/class/dmi/id/chassis_version:A15
/sys/class/dmi/id/product_family:103C_5335KV
/sys/class/dmi/id/product_name:Vostro 3560
/sys/class/dmi/id/product_sku:Vostro 3560
/sys/class/dmi/id/product_version:A15
/sys/class/dmi/id/sys_vendor:Dell Inc.

or, this one:

i2c-0	smbus     	SMBus PIIX4 adapter port 0 at 0b00	SMBus adapter

; i2cdetect -F 0
Functionalities implemented by /dev/i2c-0:
I2C                              no
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               no
SMBus Block Write                yes
SMBus Block Read                 yes
SMBus Block Process Call         no
SMBus PEC                        no
I2C Block Write                  no
I2C Block Read                   no

; grep . /sys/class/dmi/id/*_* | grep -v -E '_(serial|uuid):'
/sys/class/dmi/id/bios_date:06/16/2014
/sys/class/dmi/id/bios_vendor:AMI
/sys/class/dmi/id/bios_version:L40 v2.05
/sys/class/dmi/id/board_name:2187
/sys/class/dmi/id/board_vendor:Hewlett-Packard
/sys/class/dmi/id/board_version:A01
/sys/class/dmi/id/chassis_asset_tag:MXL43323XR 
/sys/class/dmi/id/chassis_type:3
/sys/class/dmi/id/chassis_vendor:To Be Filled By O.E.M.
/sys/class/dmi/id/chassis_version:To Be Filled By O.E.M.
/sys/class/dmi/id/product_family:103C_53302C G=D
/sys/class/dmi/id/product_name:HP t620 Dual Core TC
/sys/class/dmi/id/product_sku:J5F65UP#ABA
/sys/class/dmi/id/sys_vendor:Hewlett-Packard

; cat /proc/version
Linux version 5.4.0-94-generic (buildd@lcy02-amd64-053) (gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)) #106-Ubuntu SMP Thu Jan 6 23:58:14 UTC 2022

For these, one would need to use the I2C_SMBUS_* ioctls, which doesn't fit with the Conn.Tx interface.
Perhaps one way is, in sysfs/i2c.go (if the bus functionality bits don't contain funcI2C), convert Tx() raw-[]byte arguments to the appropriate smbus call.

I can take a stab at this, but not sure exactly when.

Do you plan to:

@maruel
Copy link
Member

maruel commented Apr 18, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants