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