xref: /freebsd/sys/contrib/device-tree/Bindings/i2c/i2c.txt (revision c9ccf3a32da427475985b85d7df023ccfb138c27)
1c66ec88fSEmmanuel VadotGeneric device tree bindings for I2C busses
2c66ec88fSEmmanuel Vadot===========================================
3c66ec88fSEmmanuel Vadot
4c66ec88fSEmmanuel VadotThis document describes generic bindings which can be used to describe I2C
5c66ec88fSEmmanuel Vadotbusses and their child devices in a device tree.
6c66ec88fSEmmanuel Vadot
7c66ec88fSEmmanuel VadotRequired properties (per bus)
8c66ec88fSEmmanuel Vadot-----------------------------
9c66ec88fSEmmanuel Vadot
10c66ec88fSEmmanuel Vadot- #address-cells  - should be <1>. Read more about addresses below.
11c66ec88fSEmmanuel Vadot- #size-cells     - should be <0>.
12c66ec88fSEmmanuel Vadot- compatible      - name of I2C bus controller
13c66ec88fSEmmanuel Vadot
14c66ec88fSEmmanuel VadotFor other required properties e.g. to describe register sets,
15c66ec88fSEmmanuel Vadotclocks, etc. check the binding documentation of the specific driver.
16c66ec88fSEmmanuel Vadot
17c66ec88fSEmmanuel VadotThe cells properties above define that an address of children of an I2C bus
18c66ec88fSEmmanuel Vadotare described by a single value.
19c66ec88fSEmmanuel Vadot
20c66ec88fSEmmanuel VadotOptional properties (per bus)
21c66ec88fSEmmanuel Vadot-----------------------------
22c66ec88fSEmmanuel Vadot
23c66ec88fSEmmanuel VadotThese properties may not be supported by all drivers. However, if a driver
24c66ec88fSEmmanuel Vadotwants to support one of the below features, it should adapt these bindings.
25c66ec88fSEmmanuel Vadot
26c66ec88fSEmmanuel Vadot- clock-frequency
27c66ec88fSEmmanuel Vadot	frequency of bus clock in Hz.
28c66ec88fSEmmanuel Vadot
29c66ec88fSEmmanuel Vadot- i2c-bus
30c66ec88fSEmmanuel Vadot	For I2C adapters that have child nodes that are a mixture of both I2C
31c66ec88fSEmmanuel Vadot	devices and non-I2C devices, the 'i2c-bus' subnode can be used for
32c66ec88fSEmmanuel Vadot	populating I2C devices. If the 'i2c-bus' subnode is present, only
33c66ec88fSEmmanuel Vadot	subnodes of this will be considered as I2C slaves. The properties,
34c66ec88fSEmmanuel Vadot	'#address-cells' and '#size-cells' must be defined under this subnode
35c66ec88fSEmmanuel Vadot	if present.
36c66ec88fSEmmanuel Vadot
37c66ec88fSEmmanuel Vadot- i2c-scl-falling-time-ns
38c66ec88fSEmmanuel Vadot	Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C
39c66ec88fSEmmanuel Vadot	specification.
40c66ec88fSEmmanuel Vadot
41c66ec88fSEmmanuel Vadot- i2c-scl-internal-delay-ns
42c66ec88fSEmmanuel Vadot	Number of nanoseconds the IP core additionally needs to setup SCL.
43c66ec88fSEmmanuel Vadot
44c66ec88fSEmmanuel Vadot- i2c-scl-rising-time-ns
45c66ec88fSEmmanuel Vadot	Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C
46c66ec88fSEmmanuel Vadot	specification.
47c66ec88fSEmmanuel Vadot
48c66ec88fSEmmanuel Vadot- i2c-sda-falling-time-ns
49c66ec88fSEmmanuel Vadot	Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C
50c66ec88fSEmmanuel Vadot	specification.
51c66ec88fSEmmanuel Vadot
52c66ec88fSEmmanuel Vadot- i2c-analog-filter
53c66ec88fSEmmanuel Vadot	Enable analog filter for i2c lines.
54c66ec88fSEmmanuel Vadot
55c66ec88fSEmmanuel Vadot- i2c-digital-filter
56c66ec88fSEmmanuel Vadot	Enable digital filter for i2c lines.
57c66ec88fSEmmanuel Vadot
58c66ec88fSEmmanuel Vadot- i2c-digital-filter-width-ns
59c66ec88fSEmmanuel Vadot	Width of spikes which can be filtered by digital filter
60c66ec88fSEmmanuel Vadot	(i2c-digital-filter). This width is specified in nanoseconds.
61c66ec88fSEmmanuel Vadot
62c66ec88fSEmmanuel Vadot- i2c-analog-filter-cutoff-frequency
63c66ec88fSEmmanuel Vadot	Frequency that the analog filter (i2c-analog-filter) uses to distinguish
64c66ec88fSEmmanuel Vadot	which signal to filter. Signal with higher frequency than specified will
65c66ec88fSEmmanuel Vadot	be filtered out. Only lower frequency will pass (this is applicable to
66c66ec88fSEmmanuel Vadot	a low-pass analog filter). Typical value should be above the normal
67c66ec88fSEmmanuel Vadot	i2c bus clock frequency (clock-frequency).
68c66ec88fSEmmanuel Vadot	Specified in Hz.
69c66ec88fSEmmanuel Vadot
70c66ec88fSEmmanuel Vadot- multi-master
71c66ec88fSEmmanuel Vadot	states that there is another master active on this bus. The OS can use
72c66ec88fSEmmanuel Vadot	this information to adapt power management to keep the arbitration awake
73c66ec88fSEmmanuel Vadot	all the time, for example. Can not be combined with 'single-master'.
74c66ec88fSEmmanuel Vadot
75c66ec88fSEmmanuel Vadot- pinctrl
76c66ec88fSEmmanuel Vadot	add extra pinctrl to configure SCL/SDA pins to GPIO function for bus
77c66ec88fSEmmanuel Vadot	recovery, call it "gpio" or "recovery" (deprecated) state
78c66ec88fSEmmanuel Vadot
79c66ec88fSEmmanuel Vadot- scl-gpios
80c66ec88fSEmmanuel Vadot	specify the gpio related to SCL pin. Used for GPIO bus recovery.
81c66ec88fSEmmanuel Vadot
82c66ec88fSEmmanuel Vadot- sda-gpios
83c66ec88fSEmmanuel Vadot	specify the gpio related to SDA pin. Optional for GPIO bus recovery.
84c66ec88fSEmmanuel Vadot
85c66ec88fSEmmanuel Vadot- single-master
86c66ec88fSEmmanuel Vadot	states that there is no other master active on this bus. The OS can use
87c66ec88fSEmmanuel Vadot	this information to detect a stalled bus more reliably, for example.
88c66ec88fSEmmanuel Vadot	Can not be combined with 'multi-master'.
89c66ec88fSEmmanuel Vadot
906be33864SEmmanuel Vadot- smbus
916be33864SEmmanuel Vadot	states that additional SMBus restrictions and features apply to this bus.
925956d97fSEmmanuel Vadot	An example of feature is SMBusHostNotify. Examples of restrictions are
935956d97fSEmmanuel Vadot	more reserved addresses and timeout definitions.
945956d97fSEmmanuel Vadot
955956d97fSEmmanuel Vadot- smbus-alert
965956d97fSEmmanuel Vadot	states that the optional SMBus-Alert feature apply to this bus.
976be33864SEmmanuel Vadot
98*c9ccf3a3SEmmanuel Vadot- mctp-controller
99*c9ccf3a3SEmmanuel Vadot	indicates that the system is accessible via this bus as an endpoint for
100*c9ccf3a3SEmmanuel Vadot	MCTP over I2C transport.
101*c9ccf3a3SEmmanuel Vadot
102c66ec88fSEmmanuel VadotRequired properties (per child device)
103c66ec88fSEmmanuel Vadot--------------------------------------
104c66ec88fSEmmanuel Vadot
105c66ec88fSEmmanuel Vadot- compatible
106c66ec88fSEmmanuel Vadot	name of I2C slave device
107c66ec88fSEmmanuel Vadot
108c66ec88fSEmmanuel Vadot- reg
109c66ec88fSEmmanuel Vadot	One or many I2C slave addresses. These are usually a 7 bit addresses.
110c66ec88fSEmmanuel Vadot	However, flags can be attached to an address. I2C_TEN_BIT_ADDRESS is
111c66ec88fSEmmanuel Vadot	used to mark a 10 bit address. It is needed to avoid the ambiguity
112c66ec88fSEmmanuel Vadot	between e.g. a 7 bit address of 0x50 and a 10 bit address of 0x050
113c66ec88fSEmmanuel Vadot	which, in theory, can be on the same bus.
114c66ec88fSEmmanuel Vadot	Another flag is I2C_OWN_SLAVE_ADDRESS to mark addresses on which we
115c66ec88fSEmmanuel Vadot	listen to be devices ourselves.
116c66ec88fSEmmanuel Vadot
117c66ec88fSEmmanuel VadotOptional properties (per child device)
118c66ec88fSEmmanuel Vadot--------------------------------------
119c66ec88fSEmmanuel Vadot
120c66ec88fSEmmanuel VadotThese properties may not be supported by all drivers. However, if a driver
121c66ec88fSEmmanuel Vadotwants to support one of the below features, it should adapt these bindings.
122c66ec88fSEmmanuel Vadot
123c66ec88fSEmmanuel Vadot- host-notify
124c66ec88fSEmmanuel Vadot	device uses SMBus host notify protocol instead of interrupt line.
125c66ec88fSEmmanuel Vadot
126c66ec88fSEmmanuel Vadot- interrupts
127c66ec88fSEmmanuel Vadot	interrupts used by the device.
128c66ec88fSEmmanuel Vadot
129c66ec88fSEmmanuel Vadot- interrupt-names
130c66ec88fSEmmanuel Vadot	"irq", "wakeup" and "smbus_alert" names are recognized by I2C core,
131c66ec88fSEmmanuel Vadot	other names are	left to individual drivers.
132c66ec88fSEmmanuel Vadot
133c66ec88fSEmmanuel Vadot- reg-names
134c66ec88fSEmmanuel Vadot	Names of map programmable addresses.
135c66ec88fSEmmanuel Vadot	It can contain any map needing another address than default one.
136c66ec88fSEmmanuel Vadot
137c66ec88fSEmmanuel Vadot- wakeup-source
138c66ec88fSEmmanuel Vadot	device can be used as a wakeup source.
139c66ec88fSEmmanuel Vadot
140c66ec88fSEmmanuel VadotBinding may contain optional "interrupts" property, describing interrupts
141c66ec88fSEmmanuel Vadotused by the device. I2C core will assign "irq" interrupt (or the very first
142c66ec88fSEmmanuel Vadotinterrupt if not using interrupt names) as primary interrupt for the slave.
143c66ec88fSEmmanuel Vadot
144c66ec88fSEmmanuel VadotAlternatively, devices supporting SMBus Host Notify, and connected to
145c66ec88fSEmmanuel Vadotadapters that support this feature, may use "host-notify" property. I2C
146c66ec88fSEmmanuel Vadotcore will create a virtual interrupt for Host Notify and assign it as
147c66ec88fSEmmanuel Vadotprimary interrupt for the slave.
148c66ec88fSEmmanuel Vadot
149c66ec88fSEmmanuel VadotAlso, if device is marked as a wakeup source, I2C core will set up "wakeup"
150c66ec88fSEmmanuel Vadotinterrupt for the device. If "wakeup" interrupt name is not present in the
151c66ec88fSEmmanuel Vadotbinding, then primary interrupt will be used as wakeup interrupt.
152