Page MenuHomeFreeBSD

add iic interface to ig4 driver, move isl and cyapa to iicbus
ClosedPublic

Authored by avg on Oct 7 2016, 7:22 AM.
Tags
None
Referenced Files
F102727804: D8172.id.diff
Sat, Nov 16, 10:49 AM
Unknown Object (File)
Sat, Nov 2, 11:39 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Unknown Object (File)
Sat, Nov 2, 11:35 PM
Subscribers

Details

Summary

The hardware does not expose a classic SMBus interface.
Instead it has a lower level interface that can express a far richer
i2c protocol than what smbus offers. However, the interface does not
provide a way to explicitly generate the i2c stop and start conditions.
It's only possible to request that the stop condition is generated
after transferring the next byte in either direction. So, at least
one data byte must always be transferred.
Thus, some i2c sequences are impossible to generate, e.g., an equivalent
of smbus quick command (<start>-<slave addr>-<r/w bit>-<stop>).

At the same time isl(4) and cyapa(4) are moved to iicbus and now they use
iicbus_transfer for communication. Previously they used smbus_trans()
interface that is not defined by the SMBus protocol and was implemented
only by ig4(4). In fact, that interface was impossible to implement
for the typical SMBus controllers (like intpm(4) or ichsmb(4)) where
a type of the SMBus command must be programmed.

The plan is to remove smbus_trans() and all its uses.
As an aside, the smbus_trans() method deviates from the standard,
but perhaps backwards, FreeBSD convention of using 8-bit slave
addresses (shifted by 1 bit to the left). The method expects
7-bit addresses.

There is a user facing consequence of this change: the user now must
provide device hints for isl and cyapa that specify an iicbus to use
and a slave address on it.
It would be nice to make these drivers more plug-and-play.
Linux has a special platform driver that uses DMI information to attach
drivers to specific buses and addresses. We could have something like
that too.

Right now smbus(4) driver tries to discover all slaves on the bus.
That is very dangerous. Fortunately, the probing code uses smbus_trans()
to do its job, so it is really enabled for ig4 only.
The plan is to remove that auto-probing code.

Test Plan

Tested by @grembo on the suppored hardware.

Diff Detail

Event Timeline

avg retitled this revision from to add iic interface to ig4 driver, move isl and cyapa to iicbus.
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added reviewers: grembo, imp, jhb.
avg edited edge metadata.
wblock added inline comments.
share/man/man4/cyapa.4
99

This is kind of difficult to understand. Maybe

On a system using
.Xr device.hints 5 ,
106

Please avoid "you", it's too informal. Maybe:

being attached to.

Except that's an unpleasant end to the sentence. Maybe just:

is the target
.Xr iicbus 4 .
219

s/based on its/from the/

share/man/man4/ig4.4
65

This sentence is hard to understand. Maybe:

This sysctl is a zero-based bit mask.
When any of the bits are set, a register dump is printed for
every operation of an
.Nm
device with the same unit number.

"operation" is not clear. Maybe it means "use", probably needs to be more specific.

share/man/man4/isl.4
65

See above for suggested rewording.

72

Does not need "is the", these are shown as items with a definition.

74

Also see above for rewording.

76

Not needed.

123

See above for rewording.

sys/dev/ichiic/ig4_iic.c
577

Typo:
s/explcitly/explicitly/

579

Typo:
s/tranferred/transferred/

584

s/send/sent/

avg marked 12 inline comments as done.Oct 12 2016, 7:57 AM

improvements for man pages, comment fixes, all suggested by wblock

avg edited edge metadata.

add chromebook_platform driver that adds appropriate i2c devices

The driver should have a knowledge about hardware, so that it can add
a named device to a correct i2c bus with a correct slave address.
The rationale is that auto-probing for i2c device is dangerous and
configuring them via the hints is error-prone.

Currently the driver is very simple and only slightly improves over the
state on the matters in head.
In the future the driver will grow model specific tables that precisely
describe each model.

iicbus(4) is changed to support this driver.
Now the 'addr' ivar is set-once instead of read-only.
That is, it is possible to set the ivar for a new device added with
BUS_ADD_CHILD. But it is not possible to change the ivar later on.
Also, it's not possible to change the ivar for a device added via the hints.

If this driver is used, then cyapa(4) and isl(4) should not require any hints.
The manual pages will be updated to reflect this.

avg edited edge metadata.

remove the third clause from the license text

avg edited edge metadata.

add a block comment dash

avg edited edge metadata.
  • add a manual page for chromebook_platform
  • allow it to be compiled into the kernel
  • fix iicbus requirement for compiling isl, cyapa and ig4 into the kernel
avg edited edge metadata.

fix typo

share/man/man4/isl.4
66

Needs a comma:
.Xr device.hints 5 ,

sys/dev/chromebook_platform/chromebook_platform.c
66

s/stop gap/stopgap/

(It's a compound word.)

avg edited edge metadata.

syntax and grammar fixes

avg marked 2 inline comments as done.Oct 15 2016, 9:40 AM
wblock added a reviewer: wblock.

Thank you!

This revision is now accepted and ready to land.Oct 16 2016, 5:51 PM
avg edited edge metadata.

add chromebook_platform to SUBDIR in modules/Makefile

This revision now requires review to proceed.Oct 17 2016, 7:35 AM

Based on Michael's testing I would like to commit this change ASAP if there are no objections.

This revision was automatically updated to reflect the committed changes.