Skip to content

Commit 32250e4

Browse files
committed
Merge branch 'i2c/for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c updates from Wolfram Sang: "Quite some driver updates: - piix4 can now handle multiplexed adapters - brcmstb, xlr, eg20t, designware drivers support more SoCs - emev2 gained i2c slave support - img-scb and rcar got bigger refactoring to remove issues - lots of common driver updates i2c core changes: - new quirk flag when an adapter does not support clock stretching, so clients can be configured to avoid that if possible - added a helper function to retrieve timing parameters from firmware (with rcar being the first user) - "multi-master" DT binding added so drivers can adapt to this setting (like disabling PM to keep arbitration working) - RuntimePM for the logical adapter device is now always enabled by the core to ensure propagation from childs to the parent (the HW device) - new macro builtin_i2c_driver to reduce boilerplate" * 'i2c/for-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (70 commits) i2c: create builtin_i2c_driver to avoid registration boilerplate i2c: imx: fix i2c resource leak with dma transfer dt-bindings: i2c: eeprom: add another EEPROM device dt-bindings: move I2C eeprom descriptions to the proper file i2c: designware: Do not require clock when SSCN and FFCN are provided DT: i2c: trivial-devices: Add Epson RX8010 and MPL3115 i2c: s3c2410: remove superfluous runtime PM calls i2c: always enable RuntimePM for the adapter device i2c: designware: retry transfer on transient failure i2c: ibm_iic: rename i2c_timings struct due to clash with generic version i2c: designware: Add support for AMD Seattle I2C i2c: imx: Remove unneeded comments i2c: st: use to_platform_device() i2c: designware: use to_pci_dev() i2c: brcmstb: Adding support for CM and DSL SoCs i2c: mediatek: fix i2c multi transfer issue in high speed mode i2c: imx: improve code readability i2c: imx: Improve message log when DMA is not used i2c: imx: add runtime pm support to improve the performance i2c: imx: init bus recovery info before adding i2c adapter ...
2 parents 5339f9d + c698d63 commit 32250e4

32 files changed

+1252
-418
lines changed

Documentation/devicetree/bindings/eeprom/eeprom.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ EEPROMs (I2C)
22

33
Required properties:
44

5-
- compatible : should be "<manufacturer>,<type>"
6-
If there is no specific driver for <manufacturer>, a generic
7-
driver based on <type> is selected. Possible types are:
8-
24c00, 24c01, 24c02, 24c04, 24c08, 24c16, 24c32, 24c64,
9-
24c128, 24c256, 24c512, 24c1024, spd
5+
- compatible : should be "<manufacturer>,<type>", like these:
6+
7+
"atmel,24c00", "atmel,24c01", "atmel,24c02", "atmel,24c04",
8+
"atmel,24c08", "atmel,24c16", "atmel,24c32", "atmel,24c64",
9+
"atmel,24c128", "atmel,24c256", "atmel,24c512", "atmel,24c1024"
10+
11+
"catalyst,24c32"
12+
13+
"ramtron,24c64"
14+
15+
"renesas,r1ex24002"
16+
17+
If there is no specific driver for <manufacturer>, a generic
18+
driver based on <type> is selected. Possible types are:
19+
"24c00", "24c01", "24c02", "24c04", "24c08", "24c16", "24c32", "24c64",
20+
"24c128", "24c256", "24c512", "24c1024", "spd"
1021

1122
- reg : the I2C address of the EEPROM
1223

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ I2C for Atmel platforms
33
Required properties :
44
- compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c",
55
"atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c",
6-
"atmel,at91sam9x5-i2c" or "atmel,sama5d2-i2c"
6+
"atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c"
77
- reg: physical base address of the controller and length of memory mapped
88
region.
99
- interrupts: interrupt number to the cpu.
@@ -17,6 +17,8 @@ Optional properties:
1717
- dma-names: should contain "tx" and "rx".
1818
- atmel,fifo-size: maximum number of data the RX and TX FIFOs can store for FIFO
1919
capable I2C controllers.
20+
- i2c-sda-hold-time-ns: TWD hold time, only available for "atmel,sama5d4-i2c"
21+
and "atmel,sama5d2-i2c".
2022
- Child nodes conforming to i2c bus binding
2123

2224
Examples :
@@ -52,6 +54,7 @@ i2c0: i2c@f8034600 {
5254
#size-cells = <0>;
5355
clocks = <&flx0>;
5456
atmel,fifo-size = <16>;
57+
i2c-sda-hold-time-ns = <336>;
5558

5659
wm8731: wm8731@1a {
5760
compatible = "wm8731";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Broadcom stb bsc iic master controller
22

33
Required properties:
44

5-
- compatible: should be "brcm,brcmstb-i2c"
5+
- compatible: should be "brcm,brcmstb-i2c" or "brcm,brcmper-i2c"
66
- clock-frequency: 32-bit decimal value of iic master clock freqency in Hz
77
valid values are 375000, 390000, 187500, 200000
88
93750, 97500, 46875 and 50000

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ Optional properties:
2020
propoerty indicates the default frequency 100 kHz.
2121
- clocks: clock specifier.
2222

23+
- i2c-scl-falling-time-ns: see i2c.txt
24+
- i2c-scl-internal-delay-ns: see i2c.txt
25+
- i2c-scl-rising-time-ns: see i2c.txt
26+
2327
Examples :
2428

2529
i2c0: i2c@e6508000 {

Documentation/devicetree/bindings/i2c/i2c.txt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,38 @@ Optional properties
2929
These properties may not be supported by all drivers. However, if a driver
3030
wants to support one of the below features, it should adapt the bindings below.
3131

32-
- clock-frequency - frequency of bus clock in Hz.
33-
- wakeup-source - device can be used as a wakeup source.
32+
- clock-frequency
33+
frequency of bus clock in Hz.
3434

35-
- interrupts - interrupts used by the device.
36-
- interrupt-names - "irq" and "wakeup" names are recognized by I2C core,
37-
other names are left to individual drivers.
35+
- i2c-scl-falling-time-ns
36+
Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C
37+
specification.
38+
39+
- i2c-scl-internal-delay-ns
40+
Number of nanoseconds the IP core additionally needs to setup SCL.
41+
42+
- i2c-scl-rising-time-ns
43+
Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C
44+
specification.
45+
46+
- i2c-sda-falling-time-ns
47+
Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C
48+
specification.
49+
50+
- interrupts
51+
interrupts used by the device.
52+
53+
- interrupt-names
54+
"irq" and "wakeup" names are recognized by I2C core, other names are
55+
left to individual drivers.
56+
57+
- multi-master
58+
states that there is another master active on this bus. The OS can use
59+
this information to adapt power management to keep the arbitration awake
60+
all the time, for example.
61+
62+
- wakeup-source
63+
device can be used as a wakeup source.
3864

3965
Binding may contain optional "interrupts" property, describing interrupts
4066
used by the device. I2C core will assign "irq" interrupt (or the very first

Documentation/devicetree/bindings/i2c/trivial-devices.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,9 @@ adi,adxl345 Three-Axis Digital Accelerometer
2222
adi,adxl346 Three-Axis Digital Accelerometer (backward-compatibility value "adi,adxl345" must be listed too)
2323
ams,iaq-core AMS iAQ-Core VOC Sensor
2424
at,24c08 i2c serial eeprom (24cxx)
25-
atmel,24c00 i2c serial eeprom (24cxx)
26-
atmel,24c01 i2c serial eeprom (24cxx)
27-
atmel,24c02 i2c serial eeprom (24cxx)
28-
atmel,24c04 i2c serial eeprom (24cxx)
29-
atmel,24c16 i2c serial eeprom (24cxx)
30-
atmel,24c32 i2c serial eeprom (24cxx)
31-
atmel,24c64 i2c serial eeprom (24cxx)
32-
atmel,24c128 i2c serial eeprom (24cxx)
33-
atmel,24c256 i2c serial eeprom (24cxx)
34-
atmel,24c512 i2c serial eeprom (24cxx)
35-
atmel,24c1024 i2c serial eeprom (24cxx)
3625
atmel,at97sc3204t i2c trusted platform module (TPM)
3726
capella,cm32181 CM32181: Ambient Light Sensor
3827
capella,cm3232 CM3232: Ambient Light Sensor
39-
catalyst,24c32 i2c serial eeprom
4028
cirrus,cs42l51 Cirrus Logic CS42L51 audio codec
4129
dallas,ds1307 64 x 8, Serial, I2C Real-Time Clock
4230
dallas,ds1338 I2C RTC with 56-Byte NV RAM
@@ -50,11 +38,13 @@ dallas,ds4510 CPU Supervisor with Nonvolatile Memory and Programmable I/O
5038
dallas,ds75 Digital Thermometer and Thermostat
5139
dlg,da9053 DA9053: flexible system level PMIC with multicore support
5240
dlg,da9063 DA9063: system PMIC for quad-core application processors
41+
epson,rx8010 I2C-BUS INTERFACE REAL TIME CLOCK MODULE
5342
epson,rx8025 High-Stability. I2C-Bus INTERFACE REAL TIME CLOCK MODULE
5443
epson,rx8581 I2C-BUS INTERFACE REAL TIME CLOCK MODULE
5544
fsl,mag3110 MAG3110: Xtrinsic High Accuracy, 3D Magnetometer
5645
fsl,mc13892 MC13892: Power Management Integrated Circuit (PMIC) for i.MX35/51
5746
fsl,mma8450 MMA8450Q: Xtrinsic Low-power, 3-axis Xtrinsic Accelerometer
47+
fsl,mpl3115 MPL3115: Absolute Digital Pressure Sensor
5848
fsl,mpr121 MPR121: Proximity Capacitive Touch Sensor Controller
5949
fsl,sgtl5000 SGTL5000: Ultra Low-Power Audio Codec
6050
gmt,g751 G751: Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface
@@ -81,7 +71,6 @@ ovti,ov5642 OV5642: Color CMOS QSXGA (5-megapixel) Image Sensor with OmniBSI an
8171
pericom,pt7c4338 Real-time Clock Module
8272
plx,pex8648 48-Lane, 12-Port PCI Express Gen 2 (5.0 GT/s) Switch
8373
pulsedlight,lidar-lite-v2 Pulsedlight LIDAR range-finding sensor
84-
ramtron,24c64 i2c serial eeprom (24cxx)
8574
ricoh,r2025sd I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
8675
ricoh,r2221tl I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
8776
ricoh,rs5c372a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC

drivers/i2c/algos/i2c-algo-bit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ const struct i2c_algorithm i2c_bit_algo = {
617617
};
618618
EXPORT_SYMBOL(i2c_bit_algo);
619619

620+
const struct i2c_adapter_quirks i2c_bit_quirk_no_clk_stretch = {
621+
.flags = I2C_AQ_NO_CLK_STRETCH,
622+
};
623+
620624
/*
621625
* registering functions to load algorithms at runtime
622626
*/
@@ -635,6 +639,8 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
635639
/* register new adapter to i2c module... */
636640
adap->algo = &i2c_bit_algo;
637641
adap->retries = 3;
642+
if (bit_adap->getscl == NULL)
643+
adap->quirks = &i2c_bit_quirk_no_clk_stretch;
638644

639645
ret = add_adapter(adap);
640646
if (ret < 0)

drivers/i2c/busses/Kconfig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ config I2C_EFM32
516516

517517
config I2C_EG20T
518518
tristate "Intel EG20T PCH/LAPIS Semicon IOH(ML7213/ML7223/ML7831) I2C"
519-
depends on PCI && (X86_32 || COMPILE_TEST)
519+
depends on PCI && (X86_32 || MIPS || COMPILE_TEST)
520520
help
521521
This driver is for PCH(Platform controller Hub) I2C of EG20T which
522522
is an IOH(Input/Output Hub) for x86 embedded processor.
@@ -532,6 +532,7 @@ config I2C_EG20T
532532
config I2C_EMEV2
533533
tristate "EMMA Mobile series I2C adapter"
534534
depends on HAVE_CLK
535+
select I2C_SLAVE
535536
help
536537
If you say yes to this option, support will be included for the
537538
I2C interface on the Renesas Electronics EM/EV family of processors.
@@ -963,11 +964,11 @@ config I2C_XILINX
963964
will be called xilinx_i2c.
964965

965966
config I2C_XLR
966-
tristate "XLR I2C support"
967-
depends on CPU_XLR
967+
tristate "Netlogic XLR and Sigma Designs I2C support"
968+
depends on CPU_XLR || ARCH_TANGOX
968969
help
969970
This driver enables support for the on-chip I2C interface of
970-
the Netlogic XLR/XLS MIPS processors.
971+
the Netlogic XLR/XLS MIPS processors and Sigma Designs SOCs.
971972

972973
This driver can also be built as a module. If so, the module
973974
will be called i2c-xlr.

drivers/i2c/busses/i2c-at91.c

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
#define AT91_TWI_IADR 0x000c /* Internal Address Register */
6565

6666
#define AT91_TWI_CWGR 0x0010 /* Clock Waveform Generator Reg */
67+
#define AT91_TWI_CWGR_HOLD_MAX 0x1f
68+
#define AT91_TWI_CWGR_HOLD(x) (((x) & AT91_TWI_CWGR_HOLD_MAX) << 24)
6769

6870
#define AT91_TWI_SR 0x0020 /* Status Register */
6971
#define AT91_TWI_TXCOMP BIT(0) /* Transmission Complete */
@@ -110,6 +112,7 @@ struct at91_twi_pdata {
110112
unsigned clk_offset;
111113
bool has_unre_flag;
112114
bool has_alt_cmd;
115+
bool has_hold_field;
113116
struct at_dma_slave dma_slave;
114117
};
115118

@@ -187,10 +190,11 @@ static void at91_init_twi_bus(struct at91_twi_dev *dev)
187190
*/
188191
static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
189192
{
190-
int ckdiv, cdiv, div;
193+
int ckdiv, cdiv, div, hold = 0;
191194
struct at91_twi_pdata *pdata = dev->pdata;
192195
int offset = pdata->clk_offset;
193196
int max_ckdiv = pdata->clk_max_div;
197+
u32 twd_hold_time_ns = 0;
194198

195199
div = max(0, (int)DIV_ROUND_UP(clk_get_rate(dev->clk),
196200
2 * twi_clk) - offset);
@@ -204,8 +208,33 @@ static void at91_calc_twi_clock(struct at91_twi_dev *dev, int twi_clk)
204208
cdiv = 255;
205209
}
206210

207-
dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv;
208-
dev_dbg(dev->dev, "cdiv %d ckdiv %d\n", cdiv, ckdiv);
211+
if (pdata->has_hold_field) {
212+
of_property_read_u32(dev->dev->of_node, "i2c-sda-hold-time-ns",
213+
&twd_hold_time_ns);
214+
215+
/*
216+
* hold time = HOLD + 3 x T_peripheral_clock
217+
* Use clk rate in kHz to prevent overflows when computing
218+
* hold.
219+
*/
220+
hold = DIV_ROUND_UP(twd_hold_time_ns
221+
* (clk_get_rate(dev->clk) / 1000), 1000000);
222+
hold -= 3;
223+
if (hold < 0)
224+
hold = 0;
225+
if (hold > AT91_TWI_CWGR_HOLD_MAX) {
226+
dev_warn(dev->dev,
227+
"HOLD field set to its maximum value (%d instead of %d)\n",
228+
AT91_TWI_CWGR_HOLD_MAX, hold);
229+
hold = AT91_TWI_CWGR_HOLD_MAX;
230+
}
231+
}
232+
233+
dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv
234+
| AT91_TWI_CWGR_HOLD(hold);
235+
236+
dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n",
237+
cdiv, ckdiv, hold, twd_hold_time_ns);
209238
}
210239

211240
static void at91_twi_dma_cleanup(struct at91_twi_dev *dev)
@@ -797,34 +826,39 @@ static struct at91_twi_pdata at91rm9200_config = {
797826
.clk_offset = 3,
798827
.has_unre_flag = true,
799828
.has_alt_cmd = false,
829+
.has_hold_field = false,
800830
};
801831

802832
static struct at91_twi_pdata at91sam9261_config = {
803833
.clk_max_div = 5,
804834
.clk_offset = 4,
805835
.has_unre_flag = false,
806836
.has_alt_cmd = false,
837+
.has_hold_field = false,
807838
};
808839

809840
static struct at91_twi_pdata at91sam9260_config = {
810841
.clk_max_div = 7,
811842
.clk_offset = 4,
812843
.has_unre_flag = false,
813844
.has_alt_cmd = false,
845+
.has_hold_field = false,
814846
};
815847

816848
static struct at91_twi_pdata at91sam9g20_config = {
817849
.clk_max_div = 7,
818850
.clk_offset = 4,
819851
.has_unre_flag = false,
820852
.has_alt_cmd = false,
853+
.has_hold_field = false,
821854
};
822855

823856
static struct at91_twi_pdata at91sam9g10_config = {
824857
.clk_max_div = 7,
825858
.clk_offset = 4,
826859
.has_unre_flag = false,
827860
.has_alt_cmd = false,
861+
.has_hold_field = false,
828862
};
829863

830864
static const struct platform_device_id at91_twi_devtypes[] = {
@@ -854,13 +888,23 @@ static struct at91_twi_pdata at91sam9x5_config = {
854888
.clk_offset = 4,
855889
.has_unre_flag = false,
856890
.has_alt_cmd = false,
891+
.has_hold_field = false,
892+
};
893+
894+
static struct at91_twi_pdata sama5d4_config = {
895+
.clk_max_div = 7,
896+
.clk_offset = 4,
897+
.has_unre_flag = false,
898+
.has_alt_cmd = false,
899+
.has_hold_field = true,
857900
};
858901

859902
static struct at91_twi_pdata sama5d2_config = {
860903
.clk_max_div = 7,
861904
.clk_offset = 4,
862905
.has_unre_flag = true,
863906
.has_alt_cmd = true,
907+
.has_hold_field = true,
864908
};
865909

866910
static const struct of_device_id atmel_twi_dt_ids[] = {
@@ -882,6 +926,9 @@ static const struct of_device_id atmel_twi_dt_ids[] = {
882926
}, {
883927
.compatible = "atmel,at91sam9x5-i2c",
884928
.data = &at91sam9x5_config,
929+
}, {
930+
.compatible = "atmel,sama5d4-i2c",
931+
.data = &sama5d4_config,
885932
}, {
886933
.compatible = "atmel,sama5d2-i2c",
887934
.data = &sama5d2_config,

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
222222
.functionality = bcm2835_i2c_func,
223223
};
224224

225+
/*
226+
* This HW was reported to have problems with clock stretching:
227+
* http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
228+
* https://www.raspberrypi.org/forums/viewtopic.php?p=146272
229+
*/
230+
static const struct i2c_adapter_quirks bcm2835_i2c_quirks = {
231+
.flags = I2C_AQ_NO_CLK_STRETCH,
232+
};
233+
225234
static int bcm2835_i2c_probe(struct platform_device *pdev)
226235
{
227236
struct bcm2835_i2c_dev *i2c_dev;
@@ -293,6 +302,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
293302
adap->algo = &bcm2835_i2c_algo;
294303
adap->dev.parent = &pdev->dev;
295304
adap->dev.of_node = pdev->dev.of_node;
305+
adap->quirks = &bcm2835_i2c_quirks;
296306

297307
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
298308

0 commit comments

Comments
 (0)