Skip to content
This repository was archived by the owner on Feb 9, 2023. It is now read-only.

Commit 4141cf6

Browse files
committed
Merge branch 'i2c/for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: "I2C has the following changes for you: - new flag to mark DMA safe buffers in i2c_msg. Also, some infrastructure around it. And docs. - huge refactoring of the at24 driver led by the new maintainer Bartosz - update I2C bus recovery to send STOP after recovery - conversion from gpio to gpiod for I2C bus recovery - adding a fault-injector to the i2c-gpio driver - lots of small driver improvements, and bigger ones to i2c-sh_mobile" * 'i2c/for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (99 commits) i2c: mv64xxx: Add myself as maintainer for this driver i2c: mv64xxx: Fix clock resource by adding an optional bus clock i2c: mv64xxx: Remove useless test before clk_disable_unprepare i2c: mxs: use true and false for boolean values i2c: meson: update doc description to fix build warnings i2c: meson: add configurable divider factors dt-bindings: i2c: update documentation for the Meson-AXG i2c: imx-lpi2c: add runtime pm support i2c: rcar: fix some trivial typos in comments i2c: davinci: fix the cpufreq transition i2c: rk3x: add proper kerneldoc header i2c: rk3x: account for const type of of_device_id.data i2c: acorn: remove outdated path from file header i2c: acorn: add MODULE_LICENSE tag i2c: rcar: implement bus recovery i2c: send STOP after successful bus recovery i2c: ensure SDA is released in recovery if SDA is controllable i2c: add 'set_sda' to bus_recovery_info i2c: add identifier in declarations for i2c_bus_recovery i2c: make kerneldoc about bus recovery more precise ...
2 parents 3462ac5 + e38c856 commit 4141cf6

45 files changed

Lines changed: 1381 additions & 1012 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
EEPROMs (I2C)
2+
3+
Required properties:
4+
5+
- compatible: Must be a "<manufacturer>,<model>" pair. The following <model>
6+
values are supported (assuming "atmel" as manufacturer):
7+
8+
"atmel,24c00",
9+
"atmel,24c01",
10+
"atmel,24cs01",
11+
"atmel,24c02",
12+
"atmel,24cs02",
13+
"atmel,24mac402",
14+
"atmel,24mac602",
15+
"atmel,spd",
16+
"atmel,24c04",
17+
"atmel,24cs04",
18+
"atmel,24c08",
19+
"atmel,24cs08",
20+
"atmel,24c16",
21+
"atmel,24cs16",
22+
"atmel,24c32",
23+
"atmel,24cs32",
24+
"atmel,24c64",
25+
"atmel,24cs64",
26+
"atmel,24c128",
27+
"atmel,24c256",
28+
"atmel,24c512",
29+
"atmel,24c1024",
30+
31+
If <manufacturer> is not "atmel", then a fallback must be used
32+
with the same <model> and "atmel" as manufacturer.
33+
34+
Example:
35+
compatible = "microchip,24c128", "atmel,24c128";
36+
37+
Supported manufacturers are:
38+
39+
"catalyst",
40+
"microchip",
41+
"ramtron",
42+
"renesas",
43+
"nxp",
44+
"st",
45+
46+
Some vendors use different model names for chips which are just
47+
variants of the above. Known such exceptions are listed below:
48+
49+
"renesas,r1ex24002" - the fallback is "atmel,24c02"
50+
51+
- reg: The I2C address of the EEPROM.
52+
53+
Optional properties:
54+
55+
- pagesize: The length of the pagesize for writing. Please consult the
56+
manual of your device, that value varies a lot. A wrong value
57+
may result in data loss! If not specified, a safety value of
58+
'1' is used which will be very slow.
59+
60+
- read-only: This parameterless property disables writes to the eeprom.
61+
62+
- size: Total eeprom size in bytes.
63+
64+
- no-read-rollover: This parameterless property indicates that the
65+
multi-address eeprom does not automatically roll over
66+
reads to the next slave address. Please consult the
67+
manual of your device.
68+
69+
- wp-gpios: GPIO to which the write-protect pin of the chip is connected.
70+
71+
Example:
72+
73+
eeprom@52 {
74+
compatible = "atmel,24c32";
75+
reg = <0x52>;
76+
pagesize = <32>;
77+
wp-gpios = <&gpio1 3 0>;
78+
};

Documentation/devicetree/bindings/eeprom/eeprom.txt

Lines changed: 0 additions & 47 deletions
This file was deleted.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
Amlogic Meson I2C controller
22

33
Required properties:
4-
- compatible: must be "amlogic,meson6-i2c" or "amlogic,meson-gxbb-i2c"
4+
- compatible: must be:
5+
"amlogic,meson6-i2c" for Meson8 and compatible SoCs
6+
"amlogic,meson-gxbb-i2c" for GXBB and compatible SoCs
7+
"amlogic,meson-axg-i2c"for AXG and compatible SoCs
8+
59
- reg: physical address and length of the device registers
610
- interrupts: a single interrupt specifier
711
- clocks: clock for the device

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The MediaTek's I2C controller is used to interface with I2C devices.
55
Required properties:
66
- compatible: value should be either of the following.
77
"mediatek,mt2701-i2c", "mediatek,mt6577-i2c": for MediaTek MT2701
8+
"mediatek,mt2712-i2c": for MediaTek MT2712
89
"mediatek,mt6577-i2c": for MediaTek MT6577
910
"mediatek,mt6589-i2c": for MediaTek MT6589
1011
"mediatek,mt7622-i2c": for MediaTek MT7622

Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
* NXP PCA954x I2C bus switch
22

3+
The driver supports NXP PCA954x and PCA984x I2C mux/switch devices.
4+
35
Required Properties:
46

57
- compatible: Must contain one of the following.
6-
"nxp,pca9540", "nxp,pca9542", "nxp,pca9543", "nxp,pca9544",
7-
"nxp,pca9545", "nxp,pca9546", "nxp,pca9547", "nxp,pca9548"
8+
"nxp,pca9540",
9+
"nxp,pca9542",
10+
"nxp,pca9543",
11+
"nxp,pca9544",
12+
"nxp,pca9545",
13+
"nxp,pca9546", "nxp,pca9846",
14+
"nxp,pca9547", "nxp,pca9847",
15+
"nxp,pca9548", "nxp,pca9848",
16+
"nxp,pca9849"
817

918
- reg: The I2C address of the device.
1019

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ default frequency is 100kHz
2525
whenever you're using the "allwinner,sun6i-a31-i2c"
2626
compatible.
2727

28+
- clocks: : pointers to the reference clocks for this device, the
29+
first one is the one used for the clock on the i2c bus,
30+
the second one is the clock used to acces the registers
31+
of the controller
32+
33+
- clock-names : names of used clocks, mandatory if the second clock is
34+
used, the name must be "core", and "reg" (the latter is
35+
only for Armada 7K/8K).
36+
2837
Examples:
2938

3039
i2c@11000 {
@@ -42,3 +51,14 @@ For the Armada XP:
4251
interrupts = <29>;
4352
clock-frequency = <100000>;
4453
};
54+
55+
For the Armada 7040:
56+
57+
i2c@701000 {
58+
compatible = "marvell,mv78230-i2c";
59+
reg = <0x701000 0x20>;
60+
interrupts = <29>;
61+
clock-frequency = <100000>;
62+
clock-names = "core", "reg";
63+
clocks = <&core_clock>, <&reg_clock>;
64+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
=================
2+
Linux I2C and DMA
3+
=================
4+
5+
Given that i2c is a low-speed bus, over which the majority of messages
6+
transferred are small, it is not considered a prime user of DMA access. At this
7+
time of writing, only 10% of I2C bus master drivers have DMA support
8+
implemented. And the vast majority of transactions are so small that setting up
9+
DMA for it will likely add more overhead than a plain PIO transfer.
10+
11+
Therefore, it is *not* mandatory that the buffer of an I2C message is DMA safe.
12+
It does not seem reasonable to apply additional burdens when the feature is so
13+
rarely used. However, it is recommended to use a DMA-safe buffer if your
14+
message size is likely applicable for DMA. Most drivers have this threshold
15+
around 8 bytes (as of today, this is mostly an educated guess, however). For
16+
any message of 16 byte or larger, it is probably a really good idea. Please
17+
note that other subsystems you use might add requirements. E.g., if your
18+
I2C bus master driver is using USB as a bridge, then you need to have DMA
19+
safe buffers always, because USB requires it.
20+
21+
Clients
22+
-------
23+
24+
For clients, if you use a DMA safe buffer in i2c_msg, set the I2C_M_DMA_SAFE
25+
flag with it. Then, the I2C core and drivers know they can safely operate DMA
26+
on it. Note that using this flag is optional. I2C host drivers which are not
27+
updated to use this flag will work like before. And like before, they risk
28+
using an unsafe DMA buffer. To improve this situation, using I2C_M_DMA_SAFE in
29+
more and more clients and host drivers is the planned way forward. Note also
30+
that setting this flag makes only sense in kernel space. User space data is
31+
copied into kernel space anyhow. The I2C core makes sure the destination
32+
buffers in kernel space are always DMA capable. Also, when the core emulates
33+
SMBus transactions via I2C, the buffers for block transfers are DMA safe. Users
34+
of i2c_master_send() and i2c_master_recv() functions can now use DMA safe
35+
variants (i2c_master_send_dmasafe() and i2c_master_recv_dmasafe()) once they
36+
know their buffers are DMA safe. Users of i2c_transfer() must set the
37+
I2C_M_DMA_SAFE flag manually.
38+
39+
Masters
40+
-------
41+
42+
Bus master drivers wishing to implement safe DMA can use helper functions from
43+
the I2C core. One gives you a DMA-safe buffer for a given i2c_msg as long as a
44+
certain threshold is met::
45+
46+
dma_buf = i2c_get_dma_safe_msg_buf(msg, threshold_in_byte);
47+
48+
If a buffer is returned, it is either msg->buf for the I2C_M_DMA_SAFE case or a
49+
bounce buffer. But you don't need to care about that detail, just use the
50+
returned buffer. If NULL is returned, the threshold was not met or a bounce
51+
buffer could not be allocated. Fall back to PIO in that case.
52+
53+
In any case, a buffer obtained from above needs to be released. It ensures data
54+
is copied back to the message and a potentially used bounce buffer is freed::
55+
56+
i2c_release_dma_safe_msg_buf(msg, dma_buf);
57+
58+
The bounce buffer handling from the core is generic and simple. It will always
59+
allocate a new bounce buffer. If you want a more sophisticated handling (e.g.
60+
reusing pre-allocated buffers), you are free to implement your own.
61+
62+
Please also check the in-kernel documentation for details. The i2c-sh_mobile
63+
driver can be used as a reference example how to use the above helpers.
64+
65+
Final note: If you plan to use DMA with I2C (or with anything else, actually)
66+
make sure you have CONFIG_DMA_API_DEBUG enabled during development. It can help
67+
you find various issues which can be complex to debug otherwise.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
Linux I2C fault injection
2+
=========================
3+
4+
The GPIO based I2C bus master driver can be configured to provide fault
5+
injection capabilities. It is then meant to be connected to another I2C bus
6+
which is driven by the I2C bus master driver under test. The GPIO fault
7+
injection driver can create special states on the bus which the other I2C bus
8+
master driver should handle gracefully.
9+
10+
Once the Kconfig option I2C_GPIO_FAULT_INJECTOR is enabled, there will be an
11+
'i2c-fault-injector' subdirectory in the Kernel debugfs filesystem, usually
12+
mounted at /sys/kernel/debug. There will be a separate subdirectory per GPIO
13+
driven I2C bus. Each subdirectory will contain files to trigger the fault
14+
injection. They will be described now along with their intended use-cases.
15+
16+
"scl"
17+
-----
18+
19+
By reading this file, you get the current state of SCL. By writing, you can
20+
change its state to either force it low or to release it again. So, by using
21+
"echo 0 > scl" you force SCL low and thus, no communication will be possible
22+
because the bus master under test will not be able to clock. It should detect
23+
the condition of SCL being unresponsive and report an error to the upper
24+
layers.
25+
26+
"sda"
27+
-----
28+
29+
By reading this file, you get the current state of SDA. By writing, you can
30+
change its state to either force it low or to release it again. So, by using
31+
"echo 0 > sda" you force SDA low and thus, data cannot be transmitted. The bus
32+
master under test should detect this condition and trigger a bus recovery (see
33+
I2C specification version 4, section 3.1.16) using the helpers of the Linux I2C
34+
core (see 'struct bus_recovery_info'). However, the bus recovery will not
35+
succeed because SDA is still pinned low until you manually release it again
36+
with "echo 1 > sda". A test with an automatic release can be done with the
37+
'incomplete_transfer' file.
38+
39+
"incomplete_transfer"
40+
---------------------
41+
42+
This file is write only and you need to write the address of an existing I2C
43+
client device to it. Then, a transfer to this device will be started, but it
44+
will stop at the ACK phase after the address of the client has been
45+
transmitted. Because the device will ACK its presence, this results in SDA
46+
being pulled low by the device while SCL is high. So, similar to the "sda" file
47+
above, the bus master under test should detect this condition and try a bus
48+
recovery. This time, however, it should succeed and the device should release
49+
SDA after toggling SCL. Please note: there are I2C client devices which detect
50+
a stuck SDA on their side and release it on their own after a few milliseconds.
51+
Also, there are external devices deglitching and monitoring the I2C bus. They
52+
can also detect a stuck SDA and will init a bus recovery on their own. If you
53+
want to implement bus recovery in a bus master driver, make sure you checked
54+
your hardware setup carefully before.

MAINTAINERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,9 @@ F: include/linux/async_tx.h
22882288
AT24 EEPROM DRIVER
22892289
M: Bartosz Golaszewski <[email protected]>
22902290
2291+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
22912292
S: Maintained
2293+
F: Documentation/devicetree/bindings/eeprom/at24.txt
22922294
F: drivers/misc/eeprom/at24.c
22932295
F: include/linux/platform_data/at24.h
22942296

@@ -6580,6 +6582,12 @@ F: drivers/i2c/i2c-mux.c
65806582
F: drivers/i2c/muxes/
65816583
F: include/linux/i2c-mux.h
65826584

6585+
I2C MV64XXX MARVELL AND ALLWINNER DRIVER
6586+
M: Gregory CLEMENT <[email protected]>
6587+
6588+
S: Maintained
6589+
F: drivers/i2c/busses/i2c-mv64xxx.c
6590+
65836591
I2C OVER PARALLEL PORT
65846592
M: Jean Delvare <[email protected]>
65856593

arch/arm/mach-davinci/board-dm355-evm.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/mtd/rawnand.h>
1818
#include <linux/i2c.h>
1919
#include <linux/gpio.h>
20+
#include <linux/gpio/machine.h>
2021
#include <linux/clk.h>
2122
#include <linux/videodev2.h>
2223
#include <media/i2c/tvp514x.h>
@@ -108,11 +109,20 @@ static struct platform_device davinci_nand_device = {
108109
},
109110
};
110111

112+
static struct gpiod_lookup_table i2c_recovery_gpiod_table = {
113+
.dev_id = "i2c_davinci",
114+
.table = {
115+
GPIO_LOOKUP("davinci_gpio", 15, "sda",
116+
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
117+
GPIO_LOOKUP("davinci_gpio", 14, "scl",
118+
GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN),
119+
},
120+
};
121+
111122
static struct davinci_i2c_platform_data i2c_pdata = {
112123
.bus_freq = 400 /* kHz */,
113124
.bus_delay = 0 /* usec */,
114-
.sda_pin = 15,
115-
.scl_pin = 14,
125+
.gpio_recovery = true,
116126
};
117127

118128
static int dm355evm_mmc_gpios = -EINVAL;
@@ -141,6 +151,7 @@ static struct i2c_board_info dm355evm_i2c_info[] = {
141151

142152
static void __init evm_init_i2c(void)
143153
{
154+
gpiod_add_lookup_table(&i2c_recovery_gpiod_table);
144155
davinci_init_i2c(&i2c_pdata);
145156

146157
gpio_request(5, "dm355evm_msp");

0 commit comments

Comments
 (0)