i2c: Add support for device-tree based chip initialization
Subsystems (3)
PATCH 1/1 i2c: Add support for device-tree based chip initialization
Some I2C devices are not or not correctly initialized by the firmware. Configuration would be possible via platform data, but that would require per-driver platform data and a lot of code, and changing it would not be possible without re-compiling the kernel. It is more elegant to do it generically via devicetree properties.
Add a generic I2C devicetree property named "reg-init". This property provides a sequence of device initialization commands to be executed prior to calling the probe function for a given device.
Signed-off-by Guenter Roeck <[email protected]>
--- .../devicetree/bindings/i2c/trivial-devices.txt | 24 +++++++ drivers/i2c/i2c-core.c | 68 ++++++++++++++++++++ 2 files changed, 92 insertions(+)
Documentation/devicetree/bindings/i2c/trivial-devices.txt +24 -0
@@ -2,6 +2,30 @@ This is a list of trivial i2c devices that have simple device tree bindings, consisting only of a compatible field, an address and possibly an interrupt line. +Device initialization is supported with an optional reg-init property. +This property contains a sequence of commands to be written into the chip. +Each command consists of four values: Register, command type, mask, and data. + Register: + Register or command address + Command type: + 0: SMBus write byte + 1: SMBus write byte data + 2: SMBus write word data + Mask: + If set, the register is read and masked with this value. + Data: + Data to be written (or with original data and mask if set) + +Example: + max6696@1a { + compatible = "maxim,max6696"; + reg = <0x1a>; + reg-init = < + 0x09 1 0x00 0x24 + 0x21 1 0x00 0x05 + >; + }; + If a device needs more specific bindings, such as properties to describe some aspect of it, there needs to be a specific binding document for it just like any other devices.
drivers/i2c/i2c-core.c +68 -0
81 lines not on this page · raw message
Signature · 1 line
1.7.9.7