Skip to content

Commit c3a416a

Browse files
committed
Merge branch 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: "Most notable: - introducing the i2c_quirk infrastructure. Now, flaws of I2C controllers can be described and the core will check if the flaws collide with the messages to be sent - wait_for_completion return type cleanup series - new drivers for Digicolor, Netlogic XLP, Ingenic JZ4780 - updates to the I2C slave framework which include API changes. Its only user was updated, too. Documentation was finally added - changed dynamic bus numbering for the DT case. This could change bus numbers for users. However, it fixes a collision where dynamic and static busses request the same id. - driver bugfixes, cleanups" * 'i2c/for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits) i2c: xlp9xx: Driver for Netlogic XLP9XX/5XX I2C controller of: Add vendor prefix 'netlogic' i2c: davinci: use ICPFUNC to toggle I2C as gpio for bus recovery i2c: davinci: use bus recovery infrastructure i2c: change input parameter to i2c_adapter for prepare/unprepare_recovery i2c: i2c-mux-gpio: remove error messages for probe deferrals i2c: jz4780: Add i2c bus controller driver for Ingenic JZ4780 i2c: dln2: set the device tree node of the adapter i2c: davinci: fixup wait_for_completion_timeout handling i2c: mpc: Fix ISR return value i2c: slave-eeprom: add more info when to increase the pointer i2c: slave: add documentation for i2c-slave-eeprom Documentation: i2c: describe the new slave mode i2c: slave: rework the slave API i2c: add support for the Digicolor I2C controller i2c: busses with dynamic ids should start after fixed ids for DT of: base: add function to get highest id of an alias stem i2c: designware: Suppress error message if platform_get_irq() < 0 i2c: mpc: assign the correct prescaler from SVR i2c: img-scb: fixup of wait_for_completion_timeout return handling ...
2 parents 8c194f3 + 2bbd681 commit c3a416a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2483
-276
lines changed

Documentation/devicetree/bindings/i2c/i2c-davinci.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Required properties:
1010
Recommended properties :
1111
- interrupts : standard interrupt property.
1212
- clock-frequency : desired I2C bus clock frequency in Hz.
13+
- ti,has-pfunc: boolean; if defined, it indicates that SoC supports PFUNC
14+
registers. PFUNC registers allow to switch I2C pins to function as
15+
GPIOs, so they can by toggled manually.
1316

1417
Example (enbw_cmc board):
1518
i2c@1c22000 {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Conexant Digicolor I2C controller
2+
3+
Required properties:
4+
- compatible: must be "cnxt,cx92755-i2c"
5+
- reg: physical address and length of the device registers
6+
- interrupts: a single interrupt specifier
7+
- clocks: clock for the device
8+
- #address-cells: should be <1>
9+
- #size-cells: should be <0>
10+
11+
Optional properties:
12+
- clock-frequency: the desired I2C bus clock frequency in Hz; in
13+
absence of this property the default value is used (100 kHz).
14+
15+
Example:
16+
17+
i2c: i2c@f0000120 {
18+
compatible = "cnxt,cx92755-i2c";
19+
reg = <0xf0000120 0x10>;
20+
interrupts = <28>;
21+
clocks = <&main_clk>;
22+
clock-frequency = <100000>;
23+
#address-cells = <1>;
24+
#size-cells = <0>;
25+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
* Ingenic JZ4780 I2C Bus controller
2+
3+
Required properties:
4+
- compatible: should be "ingenic,jz4780-i2c"
5+
- reg: Should contain the address & size of the I2C controller registers.
6+
- interrupts: Should specify the interrupt provided by parent.
7+
- clocks: Should contain a single clock specifier for the JZ4780 I2C clock.
8+
- clock-frequency: desired I2C bus clock frequency in Hz.
9+
10+
Recommended properties:
11+
- pinctrl-names: should be "default";
12+
- pinctrl-0: phandle to pinctrl function
13+
14+
Optional properties:
15+
- interrupt-parent: Should be the phandle of the interrupt controller that
16+
delivers interrupts to the I2C block.
17+
18+
Example
19+
20+
/ {
21+
i2c4: i2c4@0x10054000 {
22+
compatible = "ingenic,jz4780-i2c";
23+
reg = <0x10054000 0x1000>;
24+
25+
interrupt-parent = <&intc>;
26+
interrupts = <56>;
27+
28+
clocks = <&cgu JZ4780_CLK_SMB4>;
29+
clock-frequency = <100000>;
30+
pinctrl-names = "default";
31+
pinctrl-0 = <&pins_i2c4_data>;
32+
33+
};
34+
};
35+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Device tree configuration for the I2C controller on the XLP9xx/5xx SoC
2+
3+
Required properties:
4+
- compatible : should be "netlogic,xlp980-i2c"
5+
- reg : bus address start and address range size of device
6+
- interrupts : interrupt number
7+
8+
Optional properties:
9+
- clock-frequency : frequency of bus clock in Hz
10+
Defaults to 100 KHz when the property is not specified
11+
12+
Example:
13+
14+
i2c0: i2c@113100 {
15+
compatible = "netlogic,xlp980-i2c";
16+
#address-cells = <1>;
17+
#size-cells = <0>;
18+
reg = <0 0x113100 0x100>;
19+
clock-frequency = <400000>;
20+
interrupts = <30>;
21+
interrupt-parent = <&pic>;
22+
};

Documentation/devicetree/bindings/vendor-prefixes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ mxicy Macronix International Co., Ltd.
125125
national National Semiconductor
126126
neonode Neonode Inc.
127127
netgear NETGEAR
128+
netlogic Broadcom Corporation (formerly NetLogic Microsystems)
128129
newhaven Newhaven Display International
129130
nintendo Nintendo
130131
nokia Nokia
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Linux I2C slave eeprom backend
2+
==============================
3+
4+
by Wolfram Sang <[email protected]> in 2014-15
5+
6+
This is a proof-of-concept backend which acts like an EEPROM on the connected
7+
I2C bus. The memory contents can be modified from userspace via this file
8+
located in sysfs:
9+
10+
/sys/bus/i2c/devices/<device-direcory>/slave-eeprom
11+
12+
As of 2015, Linux doesn't support poll on binary sysfs files, so there is no
13+
notfication when another master changed the content.
14+

Documentation/i2c/slave-interface

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
Linux I2C slave interface description
2+
=====================================
3+
4+
by Wolfram Sang <[email protected]> in 2014-15
5+
6+
Linux can also be an I2C slave in case I2C controllers have slave support.
7+
Besides this HW requirement, one also needs a software backend providing the
8+
actual functionality. An example for this is the slave-eeprom driver, which
9+
acts as a dual memory driver. While another I2C master on the bus can access it
10+
like a regular EEPROM, the Linux I2C slave can access the content via sysfs and
11+
retrieve/provide information as needed. The software backend driver and the I2C
12+
bus driver communicate via events. Here is a small graph visualizing the data
13+
flow and the means by which data is transported. The dotted line marks only one
14+
example. The backend could also use e.g. a character device, be in-kernel
15+
only, or something completely different:
16+
17+
18+
e.g. sysfs I2C slave events I/O registers
19+
+-----------+ v +---------+ v +--------+ v +------------+
20+
| Userspace +........+ Backend +-----------+ Driver +-----+ Controller |
21+
+-----------+ +---------+ +--------+ +------------+
22+
| |
23+
----------------------------------------------------------------+-- I2C
24+
--------------------------------------------------------------+---- Bus
25+
26+
Note: Technically, there is also the I2C core between the backend and the
27+
driver. However, at this time of writing, the layer is transparent.
28+
29+
30+
User manual
31+
===========
32+
33+
I2C slave backends behave like standard I2C clients. So, you can instantiate
34+
them like described in the document 'instantiating-devices'. A quick example
35+
for instantiating the slave-eeprom driver from userspace:
36+
37+
# echo 0-0064 > /sys/bus/i2c/drivers/i2c-slave-eeprom/bind
38+
39+
Each backend should come with separate documentation to describe its specific
40+
behaviour and setup.
41+
42+
43+
Developer manual
44+
================
45+
46+
I2C slave events
47+
----------------
48+
49+
The bus driver sends an event to the backend using the following function:
50+
51+
ret = i2c_slave_event(client, event, &val)
52+
53+
'client' describes the i2c slave device. 'event' is one of the special event
54+
types described hereafter. 'val' holds an u8 value for the data byte to be
55+
read/written and is thus bidirectional. The pointer to val must always be
56+
provided even if val is not used for an event, i.e. don't use NULL here. 'ret'
57+
is the return value from the backend. Mandatory events must be provided by the
58+
bus drivers and must be checked for by backend drivers.
59+
60+
Event types:
61+
62+
* I2C_SLAVE_WRITE_REQUESTED (mandatory)
63+
64+
'val': unused
65+
'ret': always 0
66+
67+
Another I2C master wants to write data to us. This event should be sent once
68+
our own address and the write bit was detected. The data did not arrive yet, so
69+
there is nothing to process or return. Wakeup or initialization probably needs
70+
to be done, though.
71+
72+
* I2C_SLAVE_READ_REQUESTED (mandatory)
73+
74+
'val': backend returns first byte to be sent
75+
'ret': always 0
76+
77+
Another I2C master wants to read data from us. This event should be sent once
78+
our own address and the read bit was detected. After returning, the bus driver
79+
should transmit the first byte.
80+
81+
* I2C_SLAVE_WRITE_RECEIVED (mandatory)
82+
83+
'val': bus driver delivers received byte
84+
'ret': 0 if the byte should be acked, some errno if the byte should be nacked
85+
86+
Another I2C master has sent a byte to us which needs to be set in 'val'. If 'ret'
87+
is zero, the bus driver should ack this byte. If 'ret' is an errno, then the byte
88+
should be nacked.
89+
90+
* I2C_SLAVE_READ_PROCESSED (mandatory)
91+
92+
'val': backend returns next byte to be sent
93+
'ret': always 0
94+
95+
The bus driver requests the next byte to be sent to another I2C master in
96+
'val'. Important: This does not mean that the previous byte has been acked, it
97+
only means that the previous byte is shifted out to the bus! To ensure seamless
98+
transmission, most hardware requests the next byte when the previous one is
99+
still shifted out. If the master sends NACK and stops reading after the byte
100+
currently shifted out, this byte requested here is never used. It very likely
101+
needs to be sent again on the next I2C_SLAVE_READ_REQUEST, depending a bit on
102+
your backend, though.
103+
104+
* I2C_SLAVE_STOP (mandatory)
105+
106+
'val': unused
107+
'ret': always 0
108+
109+
A stop condition was received. This can happen anytime and the backend should
110+
reset its state machine for I2C transfers to be able to receive new requests.
111+
112+
113+
Software backends
114+
-----------------
115+
116+
If you want to write a software backend:
117+
118+
* use a standard i2c_driver and its matching mechanisms
119+
* write the slave_callback which handles the above slave events
120+
(best using a state machine)
121+
* register this callback via i2c_slave_register()
122+
123+
Check the i2c-slave-eeprom driver as an example.
124+
125+
126+
Bus driver support
127+
------------------
128+
129+
If you want to add slave support to the bus driver:
130+
131+
* implement calls to register/unregister the slave and add those to the
132+
struct i2c_algorithm. When registering, you probably need to set the i2c
133+
slave address and enable slave specific interrupts. If you use runtime pm, you
134+
should use pm_runtime_forbid() because your device usually needs to be powered
135+
on always to be able to detect its slave address. When unregistering, do the
136+
inverse of the above.
137+
138+
* Catch the slave interrupts and send appropriate i2c_slave_events to the backend.
139+
140+
Check the i2c-rcar driver as an example.
141+
142+
143+
About ACK/NACK
144+
--------------
145+
146+
It is good behaviour to always ACK the address phase, so the master knows if a
147+
device is basically present or if it mysteriously disappeared. Using NACK to
148+
state being busy is troublesome. SMBus demands to always ACK the address phase,
149+
while the I2C specification is more loose on that. Most I2C controllers also
150+
automatically ACK when detecting their slave addresses, so there is no option
151+
to NACK them. For those reasons, this API does not support NACK in the address
152+
phase.
153+
154+
Currently, there is no slave event to report if the master did ACK or NACK a
155+
byte when it reads from us. We could make this an optional event if the need
156+
arises. However, cases should be extremely rare because the master is expected
157+
to send STOP after that and we have an event for that. Also, keep in mind not
158+
all I2C controllers have the possibility to report that event.
159+
160+
161+
About buffers
162+
-------------
163+
164+
During development of this API, the question of using buffers instead of just
165+
bytes came up. Such an extension might be possible, usefulness is unclear at
166+
this time of writing. Some points to keep in mind when using buffers:
167+
168+
* Buffers should be opt-in and slave drivers will always have to support
169+
byte-based transactions as the ultimate fallback because this is how the
170+
majority of HW works.
171+
172+
* For backends simulating hardware registers, buffers are not helpful because
173+
on writes an action should be immediately triggered. For reads, the data in
174+
the buffer might get stale.
175+
176+
* A master can send STOP at any time. For partially transferred buffers, this
177+
means additional code to handle this exception. Such code tends to be
178+
error-prone.
179+

Documentation/i2c/summary

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,3 @@ integrated than Algorithm and Adapter.
4141

4242
For a given configuration, you will need a driver for your I2C bus, and
4343
drivers for your I2C devices (usually one driver for each device).
44-
45-
At this time, Linux only operates I2C (or SMBus) in master mode; you can't
46-
use these APIs to make a Linux system behave as a slave/device, either to
47-
speak a custom protocol or to emulate some other device.

drivers/i2c/busses/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,15 @@ config I2C_DESIGNWARE_BAYTRAIL
485485
the platform firmware controlling it. You should say Y if running on
486486
a BayTrail system using the AXP288.
487487

488+
config I2C_DIGICOLOR
489+
tristate "Conexant Digicolor I2C driver"
490+
depends on ARCH_DIGICOLOR
491+
help
492+
Support for Conexant Digicolor SoCs (CX92755) I2C controller driver.
493+
494+
This driver can also be built as a module. If so, the module
495+
will be called i2c-digicolor.
496+
488497
config I2C_EFM32
489498
tristate "EFM32 I2C controller"
490499
depends on ARCH_EFM32 || COMPILE_TEST
@@ -574,6 +583,15 @@ config I2C_IOP3XX
574583
This driver can also be built as a module. If so, the module
575584
will be called i2c-iop3xx.
576585

586+
config I2C_JZ4780
587+
tristate "JZ4780 I2C controller interface support"
588+
depends on MACH_JZ4780 || COMPILE_TEST
589+
help
590+
If you say yes to this option, support will be included for the
591+
Ingenic JZ4780 I2C controller.
592+
593+
If you don't know what to do here, say N.
594+
577595
config I2C_KEMPLD
578596
tristate "Kontron COM I2C Controller"
579597
depends on MFD_KEMPLD
@@ -898,6 +916,16 @@ config I2C_XLR
898916
This driver can also be built as a module. If so, the module
899917
will be called i2c-xlr.
900918

919+
config I2C_XLP9XX
920+
tristate "XLP9XX I2C support"
921+
depends on CPU_XLP || COMPILE_TEST
922+
help
923+
This driver enables support for the on-chip I2C interface of
924+
the Broadcom XLP9xx/XLP5xx MIPS processors.
925+
926+
This driver can also be built as a module. If so, the module will
927+
be called i2c-xlp9xx.
928+
901929
config I2C_RCAR
902930
tristate "Renesas R-Car I2C Controller"
903931
depends on ARCH_SHMOBILE || COMPILE_TEST

drivers/i2c/busses/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ i2c-designware-platform-objs := i2c-designware-platdrv.o
4545
i2c-designware-platform-$(CONFIG_I2C_DESIGNWARE_BAYTRAIL) += i2c-designware-baytrail.o
4646
obj-$(CONFIG_I2C_DESIGNWARE_PCI) += i2c-designware-pci.o
4747
i2c-designware-pci-objs := i2c-designware-pcidrv.o
48+
obj-$(CONFIG_I2C_DIGICOLOR) += i2c-digicolor.o
4849
obj-$(CONFIG_I2C_EFM32) += i2c-efm32.o
4950
obj-$(CONFIG_I2C_EG20T) += i2c-eg20t.o
5051
obj-$(CONFIG_I2C_EXYNOS5) += i2c-exynos5.o
@@ -55,6 +56,7 @@ obj-$(CONFIG_I2C_IBM_IIC) += i2c-ibm_iic.o
5556
obj-$(CONFIG_I2C_IMG) += i2c-img-scb.o
5657
obj-$(CONFIG_I2C_IMX) += i2c-imx.o
5758
obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o
59+
obj-$(CONFIG_I2C_JZ4780) += i2c-jz4780.o
5860
obj-$(CONFIG_I2C_KEMPLD) += i2c-kempld.o
5961
obj-$(CONFIG_I2C_MESON) += i2c-meson.o
6062
obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
@@ -87,6 +89,7 @@ obj-$(CONFIG_I2C_WMT) += i2c-wmt.o
8789
obj-$(CONFIG_I2C_OCTEON) += i2c-octeon.o
8890
obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o
8991
obj-$(CONFIG_I2C_XLR) += i2c-xlr.o
92+
obj-$(CONFIG_I2C_XLP9XX) += i2c-xlp9xx.o
9093
obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o
9194

9295
# External I2C/SMBus adapter drivers

0 commit comments

Comments
 (0)