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)
May 6 2024, 4:35 PM
Unknown Object (File)
Apr 28 2024, 5:35 AM
Unknown Object (File)
Feb 14 2024, 4:54 PM
Unknown Object (File)
Feb 14 2024, 4:29 PM
Unknown Object (File)
Dec 28 2023, 11:08 AM
Unknown Object (File)
Dec 19 2023, 11:54 PM
Unknown Object (File)
Nov 7 2023, 12:18 AM
Unknown Object (File)
Nov 6 2023, 10:04 PM
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.