aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 21:10:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 21:10:45 -0400
commitc3a416a669eb83cfa9ccb52db030e72d654bd105 (patch)
tree518d00dc803fbb7d3772fc26a78b6bf3b797baf3 /Documentation
parent8c194f3bd322a8bd44d079092d870549b8ae62d1 (diff)
parent2bbd681ba2bfa0f3805fb541b0840b96893c5727 (diff)
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 ...
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-davinci.txt3
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-digicolor.txt25
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-jz4780.txt35
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-xlp9xx.txt22
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt1
-rw-r--r--Documentation/i2c/slave-eeprom-backend14
-rw-r--r--Documentation/i2c/slave-interface179
-rw-r--r--Documentation/i2c/summary4
8 files changed, 279 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-davinci.txt b/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
index 2dc935b4113d..a4e1cbc810c1 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c-davinci.txt
@@ -10,6 +10,9 @@ Required properties:
10Recommended properties : 10Recommended properties :
11- interrupts : standard interrupt property. 11- interrupts : standard interrupt property.
12- clock-frequency : desired I2C bus clock frequency in Hz. 12- 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.
13 16
14Example (enbw_cmc board): 17Example (enbw_cmc board):
15 i2c@1c22000 { 18 i2c@1c22000 {
diff --git a/Documentation/devicetree/bindings/i2c/i2c-digicolor.txt b/Documentation/devicetree/bindings/i2c/i2c-digicolor.txt
new file mode 100644
index 000000000000..457a098d4f7e
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-digicolor.txt
@@ -0,0 +1,25 @@
1Conexant Digicolor I2C controller
2
3Required 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
11Optional 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
15Example:
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 };
diff --git a/Documentation/devicetree/bindings/i2c/i2c-jz4780.txt b/Documentation/devicetree/bindings/i2c/i2c-jz4780.txt
new file mode 100644
index 000000000000..231e4cc4008c
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-jz4780.txt
@@ -0,0 +1,35 @@
1* Ingenic JZ4780 I2C Bus controller
2
3Required 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
10Recommended properties:
11- pinctrl-names: should be "default";
12- pinctrl-0: phandle to pinctrl function
13
14Optional properties:
15- interrupt-parent: Should be the phandle of the interrupt controller that
16 delivers interrupts to the I2C block.
17
18Example
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
diff --git a/Documentation/devicetree/bindings/i2c/i2c-xlp9xx.txt b/Documentation/devicetree/bindings/i2c/i2c-xlp9xx.txt
new file mode 100644
index 000000000000..f818ef507ab7
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-xlp9xx.txt
@@ -0,0 +1,22 @@
1Device tree configuration for the I2C controller on the XLP9xx/5xx SoC
2
3Required properties:
4- compatible : should be "netlogic,xlp980-i2c"
5- reg : bus address start and address range size of device
6- interrupts : interrupt number
7
8Optional properties:
9- clock-frequency : frequency of bus clock in Hz
10 Defaults to 100 KHz when the property is not specified
11
12Example:
13
14i2c0: 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};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 9b98bd89cfe2..8764b5b78772 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -125,6 +125,7 @@ mxicy Macronix International Co., Ltd.
125national National Semiconductor 125national National Semiconductor
126neonode Neonode Inc. 126neonode Neonode Inc.
127netgear NETGEAR 127netgear NETGEAR
128netlogic Broadcom Corporation (formerly NetLogic Microsystems)
128newhaven Newhaven Display International 129newhaven Newhaven Display International
129nintendo Nintendo 130nintendo Nintendo
130nokia Nokia 131nokia Nokia
diff --git a/Documentation/i2c/slave-eeprom-backend b/Documentation/i2c/slave-eeprom-backend
new file mode 100644
index 000000000000..c8444ef82acf
--- /dev/null
+++ b/Documentation/i2c/slave-eeprom-backend
@@ -0,0 +1,14 @@
1Linux I2C slave eeprom backend
2==============================
3
4by Wolfram Sang <wsa@sang-engineering.com> in 2014-15
5
6This is a proof-of-concept backend which acts like an EEPROM on the connected
7I2C bus. The memory contents can be modified from userspace via this file
8located in sysfs:
9
10 /sys/bus/i2c/devices/<device-direcory>/slave-eeprom
11
12As of 2015, Linux doesn't support poll on binary sysfs files, so there is no
13notfication when another master changed the content.
14
diff --git a/Documentation/i2c/slave-interface b/Documentation/i2c/slave-interface
new file mode 100644
index 000000000000..389bb5d61854
--- /dev/null
+++ b/Documentation/i2c/slave-interface
@@ -0,0 +1,179 @@
1Linux I2C slave interface description
2=====================================
3
4by Wolfram Sang <wsa@sang-engineering.com> in 2014-15
5
6Linux can also be an I2C slave in case I2C controllers have slave support.
7Besides this HW requirement, one also needs a software backend providing the
8actual functionality. An example for this is the slave-eeprom driver, which
9acts as a dual memory driver. While another I2C master on the bus can access it
10like a regular EEPROM, the Linux I2C slave can access the content via sysfs and
11retrieve/provide information as needed. The software backend driver and the I2C
12bus driver communicate via events. Here is a small graph visualizing the data
13flow and the means by which data is transported. The dotted line marks only one
14example. The backend could also use e.g. a character device, be in-kernel
15only, 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
26Note: Technically, there is also the I2C core between the backend and the
27driver. However, at this time of writing, the layer is transparent.
28
29
30User manual
31===========
32
33I2C slave backends behave like standard I2C clients. So, you can instantiate
34them like described in the document 'instantiating-devices'. A quick example
35for instantiating the slave-eeprom driver from userspace:
36
37 # echo 0-0064 > /sys/bus/i2c/drivers/i2c-slave-eeprom/bind
38
39Each backend should come with separate documentation to describe its specific
40behaviour and setup.
41
42
43Developer manual
44================
45
46I2C slave events
47----------------
48
49The 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
54types described hereafter. 'val' holds an u8 value for the data byte to be
55read/written and is thus bidirectional. The pointer to val must always be
56provided even if val is not used for an event, i.e. don't use NULL here. 'ret'
57is the return value from the backend. Mandatory events must be provided by the
58bus drivers and must be checked for by backend drivers.
59
60Event types:
61
62* I2C_SLAVE_WRITE_REQUESTED (mandatory)
63
64'val': unused
65'ret': always 0
66
67Another I2C master wants to write data to us. This event should be sent once
68our own address and the write bit was detected. The data did not arrive yet, so
69there is nothing to process or return. Wakeup or initialization probably needs
70to 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
77Another I2C master wants to read data from us. This event should be sent once
78our own address and the read bit was detected. After returning, the bus driver
79should 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
86Another I2C master has sent a byte to us which needs to be set in 'val'. If 'ret'
87is zero, the bus driver should ack this byte. If 'ret' is an errno, then the byte
88should be nacked.
89
90* I2C_SLAVE_READ_PROCESSED (mandatory)
91
92'val': backend returns next byte to be sent
93'ret': always 0
94
95The 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
97only means that the previous byte is shifted out to the bus! To ensure seamless
98transmission, most hardware requests the next byte when the previous one is
99still shifted out. If the master sends NACK and stops reading after the byte
100currently shifted out, this byte requested here is never used. It very likely
101needs to be sent again on the next I2C_SLAVE_READ_REQUEST, depending a bit on
102your backend, though.
103
104* I2C_SLAVE_STOP (mandatory)
105
106'val': unused
107'ret': always 0
108
109A stop condition was received. This can happen anytime and the backend should
110reset its state machine for I2C transfers to be able to receive new requests.
111
112
113Software backends
114-----------------
115
116If 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
123Check the i2c-slave-eeprom driver as an example.
124
125
126Bus driver support
127------------------
128
129If 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
140Check the i2c-rcar driver as an example.
141
142
143About ACK/NACK
144--------------
145
146It is good behaviour to always ACK the address phase, so the master knows if a
147device is basically present or if it mysteriously disappeared. Using NACK to
148state being busy is troublesome. SMBus demands to always ACK the address phase,
149while the I2C specification is more loose on that. Most I2C controllers also
150automatically ACK when detecting their slave addresses, so there is no option
151to NACK them. For those reasons, this API does not support NACK in the address
152phase.
153
154Currently, there is no slave event to report if the master did ACK or NACK a
155byte when it reads from us. We could make this an optional event if the need
156arises. However, cases should be extremely rare because the master is expected
157to send STOP after that and we have an event for that. Also, keep in mind not
158all I2C controllers have the possibility to report that event.
159
160
161About buffers
162-------------
163
164During development of this API, the question of using buffers instead of just
165bytes came up. Such an extension might be possible, usefulness is unclear at
166this 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
diff --git a/Documentation/i2c/summary b/Documentation/i2c/summary
index 13ab076dcd92..809541ab352f 100644
--- a/Documentation/i2c/summary
+++ b/Documentation/i2c/summary
@@ -41,7 +41,3 @@ integrated than Algorithm and Adapter.
41 41
42For a given configuration, you will need a driver for your I2C bus, and 42For a given configuration, you will need a driver for your I2C bus, and
43drivers for your I2C devices (usually one driver for each device). 43drivers for your I2C devices (usually one driver for each device).
44
45At this time, Linux only operates I2C (or SMBus) in master mode; you can't
46use these APIs to make a Linux system behave as a slave/device, either to
47speak a custom protocol or to emulate some other device.