Page MenuHomeFreeBSD

Allow i2c bus speed to be configured via hints, FDT data, and sysctl.
ClosedPublic

Authored by ian on Nov 16 2014, 4:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 26, 6:49 PM
Unknown Object (File)
Thu, Nov 21, 2:31 PM
Unknown Object (File)
Thu, Nov 21, 12:04 PM
Unknown Object (File)
Sat, Nov 16, 2:52 AM
Unknown Object (File)
Mon, Nov 11, 10:02 AM
Unknown Object (File)
Sun, Nov 10, 12:56 PM
Unknown Object (File)
Sun, Nov 10, 9:37 AM
Unknown Object (File)
Sep 12 2024, 2:17 AM
Subscribers
None

Details

Reviewers
rpaulo
loos
Group Reviewers
ARM
Summary

The current support for controlling i2c bus speed is an inconsistant mess. There are 4 symbolic speed values defined, UNKNOWN, SLOW, FAST, FASTEST. It seems to be universally assumed that SLOW means the standard 100KHz rate from the original spec. Nothing ever calls iicbus_reset() with a speed of FAST, although some drivers would treat it as the 400KHz standard speed. Mostly iicbus_reset() is called with the speed set to UNKNOWN or FASTEST, and there's really no telling what any individual driver will do with those.

The speed of an i2c bus is limited by the speed of the slowest device on the bus. This means that generally the bus speed needs to be configured based on the board/system and the components within it. Historically for i2c we've configured with device hints. Newer systems use FDT data and it documents a clock-frequency property for i2c busses. Hobbyists and developers are likely to want on the fly changes. These changes provide all 3 methods, but do not require any existing drivers to change to use the new facilities.

This adds an iicbus method, iicbus_get_frequency(dev, speed) that gets the frequency for the requested symbolic speed. If the symbolic speed is SLOW or if there is no speed configured for the busm, the returned value is 100KHz, always. Otherwise, if bus speed is configured by hints, fdt, tunable, or sysctl, that speed is returned. It also adds a helper function, iicbus_init_frequency() that any bus driver subclassed from iicbus can initialize the frequency from some other source of info.

Example implementations are provided for Freescale and TI.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

ian retitled this revision from to Allow i2c bus speed to be configured via hints, FDT data, and sysctl..
ian updated this object.
ian edited the test plan for this revision. (Show Details)
ian added reviewers: loos, ARM.
ian set the repository for this revision to rS FreeBSD src repository - subversion.
rpaulo added a reviewer: rpaulo.
This revision is now accepted and ready to land.Nov 16 2014, 7:21 PM
loos edited edge metadata.