History

Merge branch 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang: - new driver for ICY, an Amiga Zorro card :) - axxia driver gained slave mode support, NXP driver gained ACPI - the slave EEPROM backend gained 16 bit address support - and lots of regular driver updates and reworks * 'i2c/for-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (52 commits) i2c: tegra: Move suspend handling to NOIRQ phase i2c: imx: ACPI support for NXP i2c controller i2c: uniphier(-f): remove all dev_dbg() i2c: uniphier(-f): use devm_platform_ioremap_resource() i2c: slave-eeprom: Add comment about address handling i2c: exynos5: Remove IRQF_ONESHOT i2c: stm32f7: Make structure stm32f7_i2c_algo constant i2c: cht-wc: drop check because i2c_unregister_device() is NULL safe i2c-eeprom_slave: Add support for more eeprom models i2c: fsi: Add of_put_node() before break i2c: synquacer: Make synquacer_i2c_ops constant i2c: hix5hd2: Remove IRQF_ONESHOT i2c: i801: Use iTCO version 6 in Cannon Lake PCH and beyond watchdog: iTCO: Add support for Cannon Lake PCH iTCO i2c: iproc: Make bcm_iproc_i2c_quirks constant i2c: iproc: Add full name of devicetree node to adapter name i2c: piix4: Add ACPI support i2c: piix4: Fix probing of reserved ports on AMD Family 16h Model 30h i2c: ocores: use request_any_context_irq() to register IRQ handler i2c: designware: Fix optional reset error handling ...

Linus Torvalds committed 7 years ago

Commit 351c8a02 parents 3cf7487 8ebf15e42 files · +795 −267Browse files

Unified · Split

42 files
  1. Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt +3 −1
  2. Documentation/devicetree/bindings/i2c/renesas,i2c.txt +0 −0
  3. Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt +0 −0
  4. Documentation/devicetree/bindings/i2c/renesas,iic.txt +0 −0
  5. Documentation/devicetree/bindings/i2c/renesas,riic.txt +0 −0
  6. MAINTAINERS +10 −4
  7. drivers/acpi/acpi_apd.c +7 −0
  8. drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +9 −9
  9. drivers/i2c/busses/Kconfig +16 −1
  10. drivers/i2c/busses/Makefile +1 −0
  11. drivers/i2c/busses/i2c-axxia.c +144 −8
  12. drivers/i2c/busses/i2c-bcm-iproc.c +4 −2
  13. drivers/i2c/busses/i2c-bcm2835.c +7 −4
  14. drivers/i2c/busses/i2c-cht-wc.c +47 −2
  15. drivers/i2c/busses/i2c-designware-master.c +5 −9
  16. drivers/i2c/busses/i2c-designware-pcidrv.c +34 −7
  17. drivers/i2c/busses/i2c-designware-platdrv.c +10 −12
  18. drivers/i2c/busses/i2c-exynos5.c +1 −3
  19. drivers/i2c/busses/i2c-fsi.c +3 −1
  20. drivers/i2c/busses/i2c-hix5hd2.c +1 −2
  21. drivers/i2c/busses/i2c-i801.c +89 −56
  22. drivers/i2c/busses/i2c-icy.c +230 −0
  23. drivers/i2c/busses/i2c-imx-lpi2c.c +1 −3
  24. drivers/i2c/busses/i2c-imx.c +13 −4
  25. drivers/i2c/busses/i2c-ismt.c +0 −2
  26. drivers/i2c/busses/i2c-mxs.c +1 −3
  27. drivers/i2c/busses/i2c-ocores.c +3 −2
  28. drivers/i2c/busses/i2c-piix4.c +27 −7
  29. drivers/i2c/busses/i2c-sprd.c +13 −12
  30. drivers/i2c/busses/i2c-stm32f7.c +1 −1
  31. drivers/i2c/busses/i2c-synquacer.c +1 −1
  32. drivers/i2c/busses/i2c-taos-evm.c +1 −1
  33. drivers/i2c/busses/i2c-tegra.c +27 −29
  34. drivers/i2c/busses/i2c-uniphier-f.c +2 −24
  35. drivers/i2c/busses/i2c-uniphier.c +4 −18
  36. drivers/i2c/i2c-core-base.c +9 −11
  37. drivers/i2c/i2c-slave-eeprom.c +31 −11
  38. drivers/media/i2c/adv748x/adv748x-core.c +3 −3
  39. drivers/media/i2c/adv7604.c +12 −10
  40. drivers/misc/eeprom/at24.c +0 −1
  41. drivers/watchdog/iTCO_wdt.c +24 −2
  42. include/linux/i2c.h +1 −1
Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt+3−1
@@ -1,7 +1,9 @@
11 Broadcom BCM2835 I2C controller
22
33 Required properties:
4−- compatible : Should be "brcm,bcm2835-i2c".
4+- compatible : Should be one of:
5+ "brcm,bcm2711-i2c"
6+ "brcm,bcm2835-i2c"
57 - reg: Should contain register location and length.
68 - interrupts: Should contain interrupt.
79 - clocks : The clock feeding the I2C controller.
Documentation/devicetree/bindings/i2c/renesas,i2c.txtrenamed from Documentation/devicetree/bindings/i2c/i2c-rcar.txt+0−0

File renamed without changes.

Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txtrenamed from Documentation/devicetree/bindings/i2c/i2c-emev2.txt+0−0

File renamed without changes.

Documentation/devicetree/bindings/i2c/renesas,iic.txtrenamed from Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt+0−0

File renamed without changes.

Documentation/devicetree/bindings/i2c/renesas,riic.txtrenamed from Documentation/devicetree/bindings/i2c/i2c-riic.txt+0−0

File renamed without changes.

MAINTAINERS+10−4
@@ -7865,6 +7865,12 @@ S: Maintained · 7864 unmodified lines
78657865 F: drivers/mfd/lpc_ich.c
78667866 F: drivers/gpio/gpio-ich.c
78677867
7868+ICY I2C DRIVER
7869+M: Max Staudt <max@enpas.org>
7870+L: linux-i2c@vger.kernel.org
7871+S: Maintained
7872+F: drivers/i2c/busses/i2c-icy.c
7873+
78687874 IDE SUBSYSTEM
78697875 M: "David S. Miller" <davem@davemloft.net>
78707876 L: linux-ide@vger.kernel.org
@@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/ · 5920 unmodified lines
1379113797 RENESAS EMEV2 I2C DRIVER
1379213798 M: Wolfram Sang <wsa+renesas@sang-engineering.com>
1379313799 S: Supported
13794−F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt
13800+F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
1379513801 F: drivers/i2c/busses/i2c-emev2.c
1379613802
1379713803 RENESAS ETHERNET DRIVERS
@@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c · 15 unmodified lines
1381313819 RENESAS R-CAR I2C DRIVERS
1381413820 M: Wolfram Sang <wsa+renesas@sang-engineering.com>
1381513821 S: Supported
13816−F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt
13817−F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
13822+F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt
13823+F: Documentation/devicetree/bindings/i2c/renesas,iic.txt
1381813824 F: drivers/i2c/busses/i2c-rcar.c
1381913825 F: drivers/i2c/busses/i2c-sh_mobile.c
1382013826
1382113827 RENESAS RIIC DRIVER
1382213828 M: Chris Brandt <chris.brandt@renesas.com>
1382313829 S: Supported
13824−F: Documentation/devicetree/bindings/i2c/i2c-riic.txt
13830+F: Documentation/devicetree/bindings/i2c/renesas,riic.txt
1382513831 F: drivers/i2c/busses/i2c-riic.c
1382613832
1382713833 RENESAS USB PHY DRIVER
drivers/acpi/acpi_apd.c+7−0
@@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = { · 159 unmodified lines
160160 .setup = acpi_apd_setup,
161161 .fixed_clk_rate = 250000000,
162162 };
163+
163164 static const struct apd_device_desc thunderx2_i2c_desc = {
164165 .setup = acpi_apd_setup,
165166 .fixed_clk_rate = 125000000,
166167 };
167168
169+static const struct apd_device_desc nxp_i2c_desc = {
170+ .setup = acpi_apd_setup,
171+ .fixed_clk_rate = 350000000,
172+};
173+
168174 static const struct apd_device_desc hip08_spi_desc = {
169175 .setup = acpi_apd_setup,
170176 .fixed_clk_rate = 250000000,
@@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = { · 67 unmodified lines
238244 { "HISI02A1", APD_ADDR(hip07_i2c_desc) },
239245 { "HISI02A2", APD_ADDR(hip08_i2c_desc) },
240246 { "HISI0173", APD_ADDR(hip08_spi_desc) },
247+ { "NXP0001", APD_ADDR(nxp_i2c_desc) },
241248 #endif
242249 { }
243250 };
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c+9−9
@@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv) · 977 unmodified lines
978978 {
979979 int ret;
980980
981− adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec",
981+ adv->i2c_cec = i2c_new_ancillary_device(adv->i2c_main, "cec",
982982 ADV7511_CEC_I2C_ADDR_DEFAULT);
983− if (!adv->i2c_cec)
984− return -EINVAL;
983+ if (IS_ERR(adv->i2c_cec))
984+ return PTR_ERR(adv->i2c_cec);
985985 i2c_set_clientdata(adv->i2c_cec, adv);
986986
987987 adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec,
@@ -1162,20 +1162,20 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) · 174 unmodified lines
11621162
11631163 adv7511_packet_disable(adv7511, 0xffff);
11641164
1165− adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid",
1165+ adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid",
11661166 ADV7511_EDID_I2C_ADDR_DEFAULT);
1167− if (!adv7511->i2c_edid) {
1168− ret = -EINVAL;
1167+ if (IS_ERR(adv7511->i2c_edid)) {
1168+ ret = PTR_ERR(adv7511->i2c_edid);
11691169 goto uninit_regulators;
11701170 }
11711171
11721172 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
11731173 adv7511->i2c_edid->addr << 1);
11741174
1175− adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet",
1175+ adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet",
11761176 ADV7511_PACKET_I2C_ADDR_DEFAULT);
1177− if (!adv7511->i2c_packet) {
1178− ret = -EINVAL;
1177+ if (IS_ERR(adv7511->i2c_packet)) {
1178+ ret = PTR_ERR(adv7511->i2c_packet);
11791179 goto err_i2c_unregister_edid;
11801180 }
11811181
drivers/i2c/busses/Kconfig+16−1
@@ -429,6 +429,7 @@ config I2C_AXXIA · 428 unmodified lines
429429 tristate "Axxia I2C controller"
430430 depends on ARCH_AXXIA || COMPILE_TEST
431431 default ARCH_AXXIA
432+ select I2C_SLAVE
432433 help
433434 Say yes if you want to support the I2C bus on Axxia platforms.
434435
@@ -977,7 +978,7 @@ config I2C_SIRF · 542 unmodified lines
977978 will be called i2c-sirf.
978979
979980 config I2C_SPRD
980− bool "Spreadtrum I2C interface"
981+ tristate "Spreadtrum I2C interface"
981982 depends on I2C=y && ARCH_SPRD
982983 help
983984 If you say yes to this option, support will be included for the
@@ -1309,6 +1310,20 @@ config I2C_ELEKTOR · 325 unmodified lines
13091310 This support is also available as a module. If so, the module
13101311 will be called i2c-elektor.
13111312
1313+config I2C_ICY
1314+ tristate "ICY Zorro card"
1315+ depends on ZORRO
1316+ select I2C_ALGOPCF
1317+ help
1318+ This supports the PCF8584 Zorro bus I2C adapter, known as ICY.
1319+ Say Y if you own such an adapter.
1320+
1321+ This support is also available as a module. If so, the module
1322+ will be called i2c-icy.
1323+
1324+ If you have a 2019 edition board with an LTC2990 sensor at address
1325+ 0x4c, loading the module 'ltc2990' is sufficient to enable it.
1326+
13121327 config I2C_MLXCPLD
13131328 tristate "Mellanox I2C driver"
13141329 depends on X86_64
drivers/i2c/busses/Makefile+1−0
@@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o · 139 unmodified lines
140140 obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o
141141 obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o
142142 obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
143+obj-$(CONFIG_I2C_ICY) += i2c-icy.o
143144 obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o
144145 obj-$(CONFIG_I2C_OPAL) += i2c-opal.o
145146 obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
drivers/i2c/busses/i2c-axxia.c+144−8
@@ -77,6 +77,40 @@ · 76 unmodified lines
7777 MST_STATUS_IP)
7878 #define MST_TX_BYTES_XFRD 0x50
7979 #define MST_RX_BYTES_XFRD 0x54
80+#define SLV_ADDR_DEC_CTL 0x58
81+#define SLV_ADDR_DEC_GCE BIT(0) /* ACK to General Call Address from own master (loopback) */
82+#define SLV_ADDR_DEC_OGCE BIT(1) /* ACK to General Call Address from external masters */
83+#define SLV_ADDR_DEC_SA1E BIT(2) /* ACK to addr_1 enabled */
84+#define SLV_ADDR_DEC_SA1M BIT(3) /* 10-bit addressing for addr_1 enabled */
85+#define SLV_ADDR_DEC_SA2E BIT(4) /* ACK to addr_2 enabled */
86+#define SLV_ADDR_DEC_SA2M BIT(5) /* 10-bit addressing for addr_2 enabled */
87+#define SLV_ADDR_1 0x5c
88+#define SLV_ADDR_2 0x60
89+#define SLV_RX_CTL 0x64
90+#define SLV_RX_ACSA1 BIT(0) /* Generate ACK for writes to addr_1 */
91+#define SLV_RX_ACSA2 BIT(1) /* Generate ACK for writes to addr_2 */
92+#define SLV_RX_ACGCA BIT(2) /* ACK data phase transfers to General Call Address */
93+#define SLV_DATA 0x68
94+#define SLV_RX_FIFO 0x6c
95+#define SLV_FIFO_DV1 BIT(0) /* Data Valid for addr_1 */
96+#define SLV_FIFO_DV2 BIT(1) /* Data Valid for addr_2 */
97+#define SLV_FIFO_AS BIT(2) /* (N)ACK Sent */
98+#define SLV_FIFO_TNAK BIT(3) /* Timeout NACK */
99+#define SLV_FIFO_STRC BIT(4) /* First byte after start condition received */
100+#define SLV_FIFO_RSC BIT(5) /* Repeated Start Condition */
101+#define SLV_FIFO_STPC BIT(6) /* Stop Condition */
102+#define SLV_FIFO_DV (SLV_FIFO_DV1 | SLV_FIFO_DV2)
103+#define SLV_INT_ENABLE 0x70
104+#define SLV_INT_STATUS 0x74
105+#define SLV_STATUS_RFH BIT(0) /* FIFO service */
106+#define SLV_STATUS_WTC BIT(1) /* Write transfer complete */
107+#define SLV_STATUS_SRS1 BIT(2) /* Slave read from addr 1 */
108+#define SLV_STATUS_SRRS1 BIT(3) /* Repeated start from addr 1 */
109+#define SLV_STATUS_SRND1 BIT(4) /* Read request not following start condition */
110+#define SLV_STATUS_SRC1 BIT(5) /* Read canceled */
111+#define SLV_STATUS_SRAT1 BIT(6) /* Slave Read timed out */
112+#define SLV_STATUS_SRDRE1 BIT(7) /* Data written after timed out */
113+#define SLV_READ_DUMMY 0x78
80114 #define SCL_HIGH_PERIOD 0x80
81115 #define SCL_LOW_PERIOD 0x84
82116 #define SPIKE_FLTR_LEN 0x88
@@ -111,6 +145,8 @@ struct axxia_i2c_dev { · 28 unmodified lines
111145 struct clk *i2c_clk;
112146 u32 bus_clk_rate;
113147 bool last;
148+ struct i2c_client *slave;
149+ int irq;
114150 };
115151
116152 static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask)
@@ -276,13 +312,65 @@ static int axxia_i2c_fill_tx_fifo(struct axxia_i2c_dev *idev) · 159 unmodified lines
276312 return ret;
277313 }
278314
315+static void axxia_i2c_slv_fifo_event(struct axxia_i2c_dev *idev)
316+{
317+ u32 fifo_status = readl(idev->base + SLV_RX_FIFO);
318+ u8 val;
319+
320+ dev_dbg(idev->dev, "slave irq fifo_status=0x%x\n", fifo_status);
321+
322+ if (fifo_status & SLV_FIFO_DV1) {
323+ if (fifo_status & SLV_FIFO_STRC)
324+ i2c_slave_event(idev->slave,
325+ I2C_SLAVE_WRITE_REQUESTED, &val);
326+
327+ val = readl(idev->base + SLV_DATA);
328+ i2c_slave_event(idev->slave, I2C_SLAVE_WRITE_RECEIVED, &val);
329+ }
330+ if (fifo_status & SLV_FIFO_STPC) {
331+ readl(idev->base + SLV_DATA); /* dummy read */
332+ i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
333+ }
334+ if (fifo_status & SLV_FIFO_RSC)
335+ readl(idev->base + SLV_DATA); /* dummy read */
336+}
337+
338+static irqreturn_t axxia_i2c_slv_isr(struct axxia_i2c_dev *idev)
339+{
340+ u32 status = readl(idev->base + SLV_INT_STATUS);
341+ u8 val;
342+
343+ dev_dbg(idev->dev, "slave irq status=0x%x\n", status);
344+
345+ if (status & SLV_STATUS_RFH)
346+ axxia_i2c_slv_fifo_event(idev);
347+ if (status & SLV_STATUS_SRS1) {
348+ i2c_slave_event(idev->slave, I2C_SLAVE_READ_REQUESTED, &val);
349+ writel(val, idev->base + SLV_DATA);
350+ }
351+ if (status & SLV_STATUS_SRND1) {
352+ i2c_slave_event(idev->slave, I2C_SLAVE_READ_PROCESSED, &val);
353+ writel(val, idev->base + SLV_DATA);
354+ }
355+ if (status & SLV_STATUS_SRC1)
356+ i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val);
357+
358+ writel(INT_SLV, idev->base + INTERRUPT_STATUS);
359+ return IRQ_HANDLED;
360+}
361+
279362 static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
280363 {
281364 struct axxia_i2c_dev *idev = _dev;
365+ irqreturn_t ret = IRQ_NONE;
282366 u32 status;
283367
284− if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST))
285− return IRQ_NONE;
368+ status = readl(idev->base + INTERRUPT_STATUS);
369+
370+ if (status & INT_SLV)
371+ ret = axxia_i2c_slv_isr(idev);
372+ if (!(status & INT_MST))
373+ return ret;
286374
287375 /* Read interrupt status bits */
288376 status = readl(idev->base + MST_INT_STATUS);
@@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap) · 294 unmodified lines
583671 return caps;
584672 }
585673
674+static int axxia_i2c_reg_slave(struct i2c_client *slave)
675+{
676+ struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
677+ u32 slv_int_mask = SLV_STATUS_RFH;
678+ u32 dec_ctl;
679+
680+ if (idev->slave)
681+ return -EBUSY;
682+
683+ idev->slave = slave;
684+
685+ /* Enable slave mode as well */
686+ writel(GLOBAL_MST_EN | GLOBAL_SLV_EN, idev->base + GLOBAL_CONTROL);
687+ writel(INT_MST | INT_SLV, idev->base + INTERRUPT_ENABLE);
688+
689+ /* Set slave address */
690+ dec_ctl = SLV_ADDR_DEC_SA1E;
691+ if (slave->flags & I2C_CLIENT_TEN)
692+ dec_ctl |= SLV_ADDR_DEC_SA1M;
693+
694+ writel(SLV_RX_ACSA1, idev->base + SLV_RX_CTL);
695+ writel(dec_ctl, idev->base + SLV_ADDR_DEC_CTL);
696+ writel(slave->addr, idev->base + SLV_ADDR_1);
697+
698+ /* Enable interrupts */
699+ slv_int_mask |= SLV_STATUS_SRS1 | SLV_STATUS_SRRS1 | SLV_STATUS_SRND1;
700+ slv_int_mask |= SLV_STATUS_SRC1;
701+ writel(slv_int_mask, idev->base + SLV_INT_ENABLE);
702+
703+ return 0;
704+}
705+
706+static int axxia_i2c_unreg_slave(struct i2c_client *slave)
707+{
708+ struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter);
709+
710+ /* Disable slave mode */
711+ writel(GLOBAL_MST_EN, idev->base + GLOBAL_CONTROL);
712+ writel(INT_MST, idev->base + INTERRUPT_ENABLE);
713+
714+ synchronize_irq(idev->irq);
715+
716+ idev->slave = NULL;
717+
718+ return 0;
719+}
720+
586721 static const struct i2c_algorithm axxia_i2c_algo = {
587722 .master_xfer = axxia_i2c_xfer,
588723 .functionality = axxia_i2c_func,
724+ .reg_slave = axxia_i2c_reg_slave,
725+ .unreg_slave = axxia_i2c_unreg_slave,
589726 };
590727
591728 static const struct i2c_adapter_quirks axxia_i2c_quirks = {
@@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 7 unmodified lines
599736 struct axxia_i2c_dev *idev = NULL;
600737 struct resource *res;
601738 void __iomem *base;
602− int irq;
603739 int ret = 0;
604740
605741 idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
@@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 5 unmodified lines
611747 if (IS_ERR(base))
612748 return PTR_ERR(base);
613749
614− irq = platform_get_irq(pdev, 0);
615− if (irq < 0) {
750+ idev->irq = platform_get_irq(pdev, 0);
751+ if (idev->irq < 0) {
616752 dev_err(&pdev->dev, "missing interrupt resource\n");
617− return irq;
753+ return idev->irq;
618754 }
619755
620756 idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c");
@@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 22 unmodified lines
643779 goto error_disable_clk;
644780 }
645781
646− ret = devm_request_irq(&pdev->dev, irq, axxia_i2c_isr, 0,
782+ ret = devm_request_irq(&pdev->dev, idev->irq, axxia_i2c_isr, 0,
647783 pdev->name, idev);
648784 if (ret) {
649− dev_err(&pdev->dev, "failed to claim IRQ%d\n", irq);
785+ dev_err(&pdev->dev, "failed to claim IRQ%d\n", idev->irq);
650786 goto error_disable_clk;
651787 }
652788
drivers/i2c/busses/i2c-bcm-iproc.c+4−2
@@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = { · 807 unmodified lines
808808 .unreg_slave = bcm_iproc_i2c_unreg_slave,
809809 };
810810
811−static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
811+static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
812812 .max_read_len = M_RX_MAX_READ_LEN,
813813 };
814814
@@ -922,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev) · 107 unmodified lines
922922
923923 adap = &iproc_i2c->adapter;
924924 i2c_set_adapdata(adap, iproc_i2c);
925− strlcpy(adap->name, "Broadcom iProc I2C adapter", sizeof(adap->name));
925+ snprintf(adap->name, sizeof(adap->name),
926+ "Broadcom iProc (%s)",
927+ of_node_full_name(iproc_i2c->device->of_node));
926928 adap->algo = &bcm_iproc_algo;
927929 adap->quirks = &bcm_iproc_i2c_quirks;
928930 adap->dev.parent = &pdev->dev;
drivers/i2c/busses/i2c-bcm2835.c+7−4
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/interrupt.h>
1313 #include <linux/io.h>
1414 #include <linux/module.h>
15+#include <linux/of_device.h>
1516 #include <linux/platform_device.h>
1617 #include <linux/slab.h>
1718
@@ -389,7 +390,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = { · 371 unmodified lines
389390 };
390391
391392 /*
392− * This HW was reported to have problems with clock stretching:
393+ * The BCM2835 was reported to have problems with clock stretching:
393394 * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
394395 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272
395396 */
@@ -471,11 +472,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) · 75 unmodified lines
471472 i2c_set_adapdata(adap, i2c_dev);
472473 adap->owner = THIS_MODULE;
473474 adap->class = I2C_CLASS_DEPRECATED;
474− strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name));
475+ snprintf(adap->name, sizeof(adap->name), "bcm2835 (%s)",
476+ of_node_full_name(pdev->dev.of_node));
475477 adap->algo = &bcm2835_i2c_algo;
476478 adap->dev.parent = &pdev->dev;
477479 adap->dev.of_node = pdev->dev.of_node;
478− adap->quirks = &bcm2835_i2c_quirks;
480+ adap->quirks = of_device_get_match_data(&pdev->dev);
479481
480482 bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
481483
@@ -501,7 +503,8 @@ static int bcm2835_i2c_remove(struct platform_device *pdev) · 19 unmodified lines
501503 }
502504
503505 static const struct of_device_id bcm2835_i2c_of_match[] = {
504− { .compatible = "brcm,bcm2835-i2c" },
506+ { .compatible = "brcm,bcm2711-i2c" },
507+ { .compatible = "brcm,bcm2835-i2c", .data = &bcm2835_i2c_quirks },
505508 {},
506509 };
507510 MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
drivers/i2c/busses/i2c-cht-wc.c+47−2
@@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = { · 177 unmodified lines
178178 .smbus_xfer = cht_wc_i2c_adap_smbus_xfer,
179179 };
180180
181+/*
182+ * We are an i2c-adapter which itself is part of an i2c-client. This means that
183+ * transfers done through us take adapter->bus_lock twice, once for our parent
184+ * i2c-adapter and once to take our own bus_lock. Lockdep does not like this
185+ * nested locking, to make lockdep happy in the case of busses with muxes, the
186+ * i2c-core's i2c_adapter_lock_bus function calls:
187+ * rt_mutex_lock_nested(&adapter->bus_lock, i2c_adapter_depth(adapter));
188+ *
189+ * But i2c_adapter_depth only works when the direct parent of the adapter is
190+ * another adapter, as it is only meant for muxes. In our case there is an
191+ * i2c-client and MFD instantiated platform_device in the parent->child chain
192+ * between the 2 devices.
193+ *
194+ * So we override the default i2c_lock_operations and pass a hardcoded
195+ * depth of 1 to rt_mutex_lock_nested, to make lockdep happy.
196+ *
197+ * Note that if there were to be a mux attached to our adapter, this would
198+ * break things again since the i2c-mux code expects the root-adapter to have
199+ * a locking depth of 0. But we always have only 1 client directly attached
200+ * in the form of the Charger IC paired with the CHT Whiskey Cove PMIC.
201+ */
202+static void cht_wc_i2c_adap_lock_bus(struct i2c_adapter *adapter,
203+ unsigned int flags)
204+{
205+ rt_mutex_lock_nested(&adapter->bus_lock, 1);
206+}
207+
208+static int cht_wc_i2c_adap_trylock_bus(struct i2c_adapter *adapter,
209+ unsigned int flags)
210+{
211+ return rt_mutex_trylock(&adapter->bus_lock);
212+}
213+
214+static void cht_wc_i2c_adap_unlock_bus(struct i2c_adapter *adapter,
215+ unsigned int flags)
216+{
217+ rt_mutex_unlock(&adapter->bus_lock);
218+}
219+
220+static const struct i2c_lock_operations cht_wc_i2c_adap_lock_ops = {
221+ .lock_bus = cht_wc_i2c_adap_lock_bus,
222+ .trylock_bus = cht_wc_i2c_adap_trylock_bus,
223+ .unlock_bus = cht_wc_i2c_adap_unlock_bus,
224+};
225+
181226 /**** irqchip for the client connected to the extchgr i2c adapter ****/
182227 static void cht_wc_i2c_irq_lock(struct irq_data *data)
183228 {
@@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) · 102 unmodified lines
286331 adap->adapter.owner = THIS_MODULE;
287332 adap->adapter.class = I2C_CLASS_HWMON;
288333 adap->adapter.algo = &cht_wc_i2c_adap_algo;
334+ adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops;
289335 strlcpy(adap->adapter.name, "PMIC I2C Adapter",
290336 sizeof(adap->adapter.name));
291337 adap->adapter.dev.parent = &pdev->dev;
@@ -363,8 +409,7 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev) · 71 unmodified lines
363409 {
364410 struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
365411
366− if (adap->client)
367− i2c_unregister_device(adap->client);
412+ i2c_unregister_device(adap->client);
368413 i2c_del_adapter(&adap->adapter);
369414 irq_domain_remove(adap->irq_domain);
370415
drivers/i2c/busses/i2c-designware-master.c+5−9
@@ -655,15 +655,11 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) · 654 unmodified lines
655655 struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
656656 struct i2c_adapter *adap = &dev->adapter;
657657 struct gpio_desc *gpio;
658− int r;
659−
660− gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH);
661− if (IS_ERR(gpio)) {
662− r = PTR_ERR(gpio);
663− if (r == -ENOENT || r == -ENOSYS)
664− return 0;
665− return r;
666− }
658+
659+ gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH);
660+ if (IS_ERR_OR_NULL(gpio))
661+ return PTR_ERR_OR_ZERO(gpio);
662+
667663 rinfo->scl_gpiod = gpio;
668664
669665 gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN);
drivers/i2c/busses/i2c-designware-pcidrv.c+34−7
@@ -33,6 +33,7 @@ enum dw_pci_ctl_id_t { · 32 unmodified lines
3333 baytrail,
3434 cherrytrail,
3535 haswell,
36+ elkhartlake,
3637 };
3738
3839 struct dw_scl_sda_cfg {
@@ -168,13 +169,20 @@ static struct dw_pci_controller dw_pci_controllers[] = { · 129 unmodified lines
168169 .flags = MODEL_CHERRYTRAIL,
169170 .scl_sda_cfg = &byt_config,
170171 },
172+ [elkhartlake] = {
173+ .bus_num = -1,
174+ .bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST,
175+ .tx_fifo_depth = 32,
176+ .rx_fifo_depth = 32,
177+ .functionality = I2C_FUNC_10BIT_ADDR,
178+ .clk_khz = 100000,
179+ },
171180 };
172181
173182 #ifdef CONFIG_PM
174183 static int i2c_dw_pci_suspend(struct device *dev)
175184 {
176− struct pci_dev *pdev = to_pci_dev(dev);
177− struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
185+ struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
178186
179187 i_dev->suspended = true;
180188 i_dev->disable(i_dev);
@@ -184,8 +192,7 @@ static int i2c_dw_pci_suspend(struct device *dev) · 3 unmodified lines
184192
185193 static int i2c_dw_pci_resume(struct device *dev)
186194 {
187− struct pci_dev *pdev = to_pci_dev(dev);
188− struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
195+ struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
189196 int ret;
190197
191198 ret = i_dev->init(i_dev);
@@ -227,6 +234,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, · 35 unmodified lines
227234 return r;
228235 }
229236
237+ pci_set_master(pdev);
238+
230239 r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
231240 if (r) {
232241 dev_err(&pdev->dev, "I/O memory remapping failed\n");
@@ -237,18 +246,24 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, · 4 unmodified lines
237246 if (!dev)
238247 return -ENOMEM;
239248
249+ r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
250+ if (r < 0)
251+ return r;
252+
240253 dev->clk = NULL;
241254 dev->controller = controller;
242255 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
243256 dev->base = pcim_iomap_table(pdev)[0];
244257 dev->dev = &pdev->dev;
245− dev->irq = pdev->irq;
258+ dev->irq = pci_irq_vector(pdev, 0);
246259 dev->flags |= controller->flags;
247260
248261 if (controller->setup) {
249262 r = controller->setup(pdev, controller);
250− if (r)
263+ if (r) {
264+ pci_free_irq_vectors(pdev);
251265 return r;
266+ }
252267 }
253268
254269 dev->functionality = controller->functionality |
@@ -276,8 +291,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, · 21 unmodified lines
276291 adap->nr = controller->bus_num;
277292
278293 r = i2c_dw_probe(dev);
279− if (r)
294+ if (r) {
295+ pci_free_irq_vectors(pdev);
280296 return r;
297+ }
281298
282299 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
283300 pm_runtime_use_autosuspend(&pdev->dev);
@@ -296,6 +313,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev) · 12 unmodified lines
296313 pm_runtime_get_noresume(&pdev->dev);
297314
298315 i2c_del_adapter(&dev->adapter);
316+ pci_free_irq_vectors(pdev);
299317 }
300318
301319 /* work with hotplug and coldplug */
@@ -331,6 +349,15 @@ static const struct pci_device_id i2_designware_pci_ids[] = { · 29 unmodified lines
331349 { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail },
332350 { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail },
333351 { PCI_VDEVICE(INTEL, 0x22C7), cherrytrail },
352+ /* Elkhart Lake (PSE I2C) */
353+ { PCI_VDEVICE(INTEL, 0x4bb9), elkhartlake },
354+ { PCI_VDEVICE(INTEL, 0x4bba), elkhartlake },
355+ { PCI_VDEVICE(INTEL, 0x4bbb), elkhartlake },
356+ { PCI_VDEVICE(INTEL, 0x4bbc), elkhartlake },
357+ { PCI_VDEVICE(INTEL, 0x4bbd), elkhartlake },
358+ { PCI_VDEVICE(INTEL, 0x4bbe), elkhartlake },
359+ { PCI_VDEVICE(INTEL, 0x4bbf), elkhartlake },
360+ { PCI_VDEVICE(INTEL, 0x4bc0), elkhartlake },
334361 { 0,}
335362 };
336363 MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
drivers/i2c/busses/i2c-designware-platdrv.c+10−12
@@ -279,12 +279,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 278 unmodified lines
279279 platform_set_drvdata(pdev, dev);
280280
281281 dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
282− if (IS_ERR(dev->rst)) {
283− if (PTR_ERR(dev->rst) == -EPROBE_DEFER)
284− return -EPROBE_DEFER;
285− } else {
286− reset_control_deassert(dev->rst);
287− }
282+ if (IS_ERR(dev->rst))
283+ return PTR_ERR(dev->rst);
284+
285+ reset_control_deassert(dev->rst);
288286
289287 t = &dev->timings;
290288 if (pdata)
@@ -346,8 +344,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 55 unmodified lines
346344
347345 /* Optional interface clock */
348346 dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
349− if (IS_ERR(dev->pclk))
350− return PTR_ERR(dev->pclk);
347+ if (IS_ERR(dev->pclk)) {
348+ ret = PTR_ERR(dev->pclk);
349+ goto exit_reset;
350+ }
351351
352352 dev->clk = devm_clk_get(&pdev->dev, NULL);
353353 if (!i2c_dw_prepare_clk(dev, true)) {
@@ -400,8 +400,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 46 unmodified lines
400400 exit_probe:
401401 dw_i2c_plat_pm_cleanup(dev);
402402 exit_reset:
403− if (!IS_ERR_OR_NULL(dev->rst))
404− reset_control_assert(dev->rst);
403+ reset_control_assert(dev->rst);
405404 return ret;
406405 }
407406
@@ -419,8 +418,7 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) · 11 unmodified lines
419418 pm_runtime_put_sync(&pdev->dev);
420419 dw_i2c_plat_pm_cleanup(dev);
421420
422− if (!IS_ERR_OR_NULL(dev->rst))
423− reset_control_assert(dev->rst);
421+ reset_control_assert(dev->rst);
424422
425423 return 0;
426424 }
drivers/i2c/busses/i2c-exynos5.c+1−3
@@ -791,9 +791,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev) · 790 unmodified lines
791791 }
792792
793793 ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
794− IRQF_NO_SUSPEND | IRQF_ONESHOT,
795− dev_name(&pdev->dev), i2c);
796−
794+ IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c);
797795 if (ret != 0) {
798796 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq);
799797 goto err_clk;
drivers/i2c/busses/i2c-fsi.c+3−1
@@ -707,8 +707,10 @@ static int fsi_i2c_probe(struct device *dev) · 706 unmodified lines
707707 continue;
708708
709709 port = kzalloc(sizeof(*port), GFP_KERNEL);
710− if (!port)
710+ if (!port) {
711+ of_node_put(np);
711712 break;
713+ }
712714
713715 port->master = i2c;
714716 port->port = port_no;
drivers/i2c/busses/i2c-hix5hd2.c+1−2
@@ -445,8 +445,7 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev) · 444 unmodified lines
445445 hix5hd2_i2c_init(priv);
446446
447447 ret = devm_request_irq(&pdev->dev, irq, hix5hd2_i2c_irq,
448− IRQF_NO_SUSPEND | IRQF_ONESHOT,
449− dev_name(&pdev->dev), priv);
448+ IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv);
450449 if (ret != 0) {
451450 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq);
452451 goto err_clk;
drivers/i2c/busses/i2c-i801.c+89−56
@@ -292,7 +292,8 @@ struct i801_priv { · 291 unmodified lines
292292 #define FEATURE_HOST_NOTIFY BIT(5)
293293 /* Not really a feature, but it's convenient to handle it as such */
294294 #define FEATURE_IDF BIT(15)
295−#define FEATURE_TCO BIT(16)
295+#define FEATURE_TCO_SPT BIT(16)
296+#define FEATURE_TCO_CNL BIT(17)
296297
297298 static const char *i801_feature_names[] = {
298299 "SMBus PEC",
@@ -1500,57 +1501,23 @@ static inline unsigned int i801_get_adapter_class(struct i801_priv *priv) · 1201 unmodified lines
15001501 }
15011502 #endif
15021503
1503−static const struct itco_wdt_platform_data tco_platform_data = {
1504+static const struct itco_wdt_platform_data spt_tco_platform_data = {
15041505 .name = "Intel PCH",
15051506 .version = 4,
15061507 };
15071508
15081509 static DEFINE_SPINLOCK(p2sb_spinlock);
15091510
1510−static void i801_add_tco(struct i801_priv *priv)
1511+static struct platform_device *
1512+i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
1513+ struct resource *tco_res)
15111514 {
1512− struct pci_dev *pci_dev = priv->pci_dev;
1513− struct resource tco_res[3], *res;
1514− struct platform_device *pdev;
1515+ struct resource *res;
15151516 unsigned int devfn;
1516− u32 tco_base, tco_ctl;
1517− u32 base_addr, ctrl_val;
15181517 u64 base64_addr;
1518+ u32 base_addr;
15191519 u8 hidden;
15201520
1521− if (!(priv->features & FEATURE_TCO))
1522− return;
1523−
1524− pci_read_config_dword(pci_dev, TCOBASE, &tco_base);
1525− pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl);
1526− if (!(tco_ctl & TCOCTL_EN))
1527− return;
1528−
1529− memset(tco_res, 0, sizeof(tco_res));
1530−
1531− res = &tco_res[ICH_RES_IO_TCO];
1532− res->start = tco_base & ~1;
1533− res->end = res->start + 32 - 1;
1534− res->flags = IORESOURCE_IO;
1535−
1536− /*
1537− * Power Management registers.
1538− */
1539− devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2);
1540− pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr);
1541−
1542− res = &tco_res[ICH_RES_IO_SMI];
1543− res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF;
1544− res->end = res->start + 3;
1545− res->flags = IORESOURCE_IO;
1546−
1547− /*
1548− * Enable the ACPI I/O space.
1549− */
1550− pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val);
1551− ctrl_val |= ACPICTRL_EN;
1552− pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val);
1553−
15541521 /*
15551522 * We must access the NO_REBOOT bit over the Primary to Sideband
15561523 * bridge (P2SB). The BIOS prevents the P2SB device from being
@@ -1586,15 +1553,76 @@ static void i801_add_tco(struct i801_priv *priv) · 29 unmodified lines
15861553 res->end = res->start + 3;
15871554 res->flags = IORESOURCE_MEM;
15881555
1589− pdev = platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1590− tco_res, 3, &tco_platform_data,
1591− sizeof(tco_platform_data));
1592− if (IS_ERR(pdev)) {
1593− dev_warn(&pci_dev->dev, "failed to create iTCO device\n");
1556+ return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1557+ tco_res, 3, &spt_tco_platform_data,
1558+ sizeof(spt_tco_platform_data));
1559+}
1560+
1561+static const struct itco_wdt_platform_data cnl_tco_platform_data = {
1562+ .name = "Intel PCH",
1563+ .version = 6,
1564+};
1565+
1566+static struct platform_device *
1567+i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev,
1568+ struct resource *tco_res)
1569+{
1570+ return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1571+ tco_res, 2, &cnl_tco_platform_data,
1572+ sizeof(cnl_tco_platform_data));
1573+}
1574+
1575+static void i801_add_tco(struct i801_priv *priv)
1576+{
1577+ u32 base_addr, tco_base, tco_ctl, ctrl_val;
1578+ struct pci_dev *pci_dev = priv->pci_dev;
1579+ struct resource tco_res[3], *res;
1580+ unsigned int devfn;
1581+
1582+ /* If we have ACPI based watchdog use that instead */
1583+ if (acpi_has_watchdog())
15941584 return;
1595− }
15961585
1597− priv->tco_pdev = pdev;
1586+ if (!(priv->features & (FEATURE_TCO_SPT | FEATURE_TCO_CNL)))
1587+ return;
1588+
1589+ pci_read_config_dword(pci_dev, TCOBASE, &tco_base);
1590+ pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl);
1591+ if (!(tco_ctl & TCOCTL_EN))
1592+ return;
1593+
1594+ memset(tco_res, 0, sizeof(tco_res));
1595+
1596+ res = &tco_res[ICH_RES_IO_TCO];
1597+ res->start = tco_base & ~1;
1598+ res->end = res->start + 32 - 1;
1599+ res->flags = IORESOURCE_IO;
1600+
1601+ /*
1602+ * Power Management registers.
1603+ */
1604+ devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2);
1605+ pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr);
1606+
1607+ res = &tco_res[ICH_RES_IO_SMI];
1608+ res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF;
1609+ res->end = res->start + 3;
1610+ res->flags = IORESOURCE_IO;
1611+
1612+ /*
1613+ * Enable the ACPI I/O space.
1614+ */
1615+ pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val);
1616+ ctrl_val |= ACPICTRL_EN;
1617+ pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val);
1618+
1619+ if (priv->features & FEATURE_TCO_CNL)
1620+ priv->tco_pdev = i801_add_tco_cnl(priv, pci_dev, tco_res);
1621+ else
1622+ priv->tco_pdev = i801_add_tco_spt(priv, pci_dev, tco_res);
1623+
1624+ if (IS_ERR(priv->tco_pdev))
1625+ dev_warn(&pci_dev->dev, "failed to create iTCO device\n");
15981626 }
15991627
16001628 #ifdef CONFIG_ACPI
@@ -1704,13 +1732,21 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 103 unmodified lines
17041732 switch (dev->device) {
17051733 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS:
17061734 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS:
1707− case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS:
1708− case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS:
17091735 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS:
17101736 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS:
1711− case PCI_DEVICE_ID_INTEL_CDF_SMBUS:
17121737 case PCI_DEVICE_ID_INTEL_DNV_SMBUS:
17131738 case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS:
1739+ priv->features |= FEATURE_I2C_BLOCK_READ;
1740+ priv->features |= FEATURE_IRQ;
1741+ priv->features |= FEATURE_SMBUS_PEC;
1742+ priv->features |= FEATURE_BLOCK_BUFFER;
1743+ priv->features |= FEATURE_TCO_SPT;
1744+ priv->features |= FEATURE_HOST_NOTIFY;
1745+ break;
1746+
1747+ case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS:
1748+ case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS:
1749+ case PCI_DEVICE_ID_INTEL_CDF_SMBUS:
17141750 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS:
17151751 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS:
17161752 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS:
@@ -1720,9 +1756,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 3 unmodified lines
17201756 priv->features |= FEATURE_IRQ;
17211757 priv->features |= FEATURE_SMBUS_PEC;
17221758 priv->features |= FEATURE_BLOCK_BUFFER;
1723− /* If we have ACPI based watchdog use that instead */
1724− if (!acpi_has_watchdog())
1725− priv->features |= FEATURE_TCO;
1759+ priv->features |= FEATURE_TCO_CNL;
17261760 priv->features |= FEATURE_HOST_NOTIFY;
17271761 break;
17281762
@@ -1921,8 +1955,7 @@ static int i801_suspend(struct device *dev) · 192 unmodified lines
19211955
19221956 static int i801_resume(struct device *dev)
19231957 {
1924− struct pci_dev *pci_dev = to_pci_dev(dev);
1925− struct i801_priv *priv = pci_get_drvdata(pci_dev);
1958+ struct i801_priv *priv = dev_get_drvdata(dev);
19261959
19271960 i801_enable_host_notify(&priv->adapter);
19281961
drivers/i2c/busses/i2c-icy.c+230−0
@@ -0,0 +1,230 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * I2C driver for stand-alone PCF8584 style adapters on Zorro cards
4+ *
5+ * Original ICY documentation can be found on Aminet:
6+ * https://aminet.net/package/docs/hard/icy
7+ *
8+ * There has been a modern community re-print of this design in 2019:
9+ * https://www.a1k.org/forum/index.php?threads/70106/
10+ *
11+ * The card is basically a Philips PCF8584 connected straight to the
12+ * beginning of the AutoConfig'd address space (register S1 on base+2),
13+ * with /INT on /INT2 on the Zorro bus.
14+ *
15+ * Copyright (c) 2019 Max Staudt <max@enpas.org>
16+ *
17+ * This started as a fork of i2c-elektor.c and has evolved since.
18+ * Thanks go to its authors for providing a base to grow on.
19+ *
20+ *
21+ * IRQ support is currently not implemented.
22+ *
23+ * As it turns out, i2c-algo-pcf is really written with i2c-elektor's
24+ * edge-triggered ISA interrupts in mind, while the Amiga's Zorro bus has
25+ * level-triggered interrupts. This means that once an interrupt occurs, we
26+ * have to tell the PCF8584 to shut up immediately, or it will keep the
27+ * interrupt line busy and cause an IRQ storm.
28+
29+ * However, because of the PCF8584's host-side protocol, there is no good
30+ * way to just quieten it without side effects. Rather, we have to perform
31+ * the next read/write operation straight away, which will reset the /INT
32+ * pin. This entails re-designing the core of i2c-algo-pcf in the future.
33+ * For now, we never request an IRQ from the PCF8584, and poll it instead.
34+ */
35+
36+#include <linux/delay.h>
37+#include <linux/init.h>
38+#include <linux/io.h>
39+#include <linux/ioport.h>
40+#include <linux/kernel.h>
41+#include <linux/module.h>
42+
43+#include <linux/i2c.h>
44+#include <linux/i2c-algo-pcf.h>
45+
46+#include <asm/amigaints.h>
47+#include <linux/zorro.h>
48+
49+#include "../algos/i2c-algo-pcf.h"
50+
51+struct icy_i2c {
52+ struct i2c_adapter adapter;
53+
54+ void __iomem *reg_s0;
55+ void __iomem *reg_s1;
56+ struct fwnode_handle *ltc2990_fwnode;
57+ struct i2c_client *ltc2990_client;
58+};
59+
60+/*
61+ * Functions called by i2c-algo-pcf
62+ */
63+static void icy_pcf_setpcf(void *data, int ctl, int val)
64+{
65+ struct icy_i2c *i2c = (struct icy_i2c *)data;
66+
67+ u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0;
68+
69+ z_writeb(val, address);
70+}
71+
72+static int icy_pcf_getpcf(void *data, int ctl)
73+{
74+ struct icy_i2c *i2c = (struct icy_i2c *)data;
75+
76+ u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0;
77+
78+ return z_readb(address);
79+}
80+
81+static int icy_pcf_getown(void *data)
82+{
83+ return 0x55;
84+}
85+
86+static int icy_pcf_getclock(void *data)
87+{
88+ return 0x1c;
89+}
90+
91+static void icy_pcf_waitforpin(void *data)
92+{
93+ usleep_range(50, 150);
94+}
95+
96+/*
97+ * Main i2c-icy part
98+ */
99+static unsigned short const icy_ltc2990_addresses[] = {
100+ 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END
101+};
102+
103+/*
104+ * Additional sensors exposed once this property is applied:
105+ *
106+ * in1 will be the voltage of the 5V rail, divided by 2.
107+ * in2 will be the voltage of the 12V rail, divided by 4.
108+ * temp3 will be measured using a PCB loop next the chip.
109+ */
110+static const u32 icy_ltc2990_meas_mode[] = {0, 3};
111+
112+static const struct property_entry icy_ltc2990_props[] = {
113+ PROPERTY_ENTRY_U32_ARRAY("lltc,meas-mode", icy_ltc2990_meas_mode),
114+ { }
115+};
116+
117+static int icy_probe(struct zorro_dev *z,
118+ const struct zorro_device_id *ent)
119+{
120+ struct icy_i2c *i2c;
121+ struct i2c_algo_pcf_data *algo_data;
122+ struct fwnode_handle *new_fwnode;
123+ struct i2c_board_info ltc2990_info = {
124+ .type = "ltc2990",
125+ .addr = 0x4c,
126+ };
127+
128+ i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL);
129+ if (!i2c)
130+ return -ENOMEM;
131+
132+ algo_data = devm_kzalloc(&z->dev, sizeof(*algo_data), GFP_KERNEL);
133+ if (!algo_data)
134+ return -ENOMEM;
135+
136+ dev_set_drvdata(&z->dev, i2c);
137+ i2c->adapter.dev.parent = &z->dev;
138+ i2c->adapter.owner = THIS_MODULE;
139+ /* i2c->adapter.algo assigned by i2c_pcf_add_bus() */
140+ i2c->adapter.algo_data = algo_data;
141+ strlcpy(i2c->adapter.name, "ICY I2C Zorro adapter",
142+ sizeof(i2c->adapter.name));
143+
144+ if (!devm_request_mem_region(&z->dev,
145+ z->resource.start,
146+ 4, i2c->adapter.name))
147+ return -ENXIO;
148+
149+ /* Driver private data */
150+ i2c->reg_s0 = ZTWO_VADDR(z->resource.start);
151+ i2c->reg_s1 = ZTWO_VADDR(z->resource.start + 2);
152+
153+ algo_data->data = i2c;
154+ algo_data->setpcf = icy_pcf_setpcf;
155+ algo_data->getpcf = icy_pcf_getpcf;
156+ algo_data->getown = icy_pcf_getown;
157+ algo_data->getclock = icy_pcf_getclock;
158+ algo_data->waitforpin = icy_pcf_waitforpin;
159+
160+ if (i2c_pcf_add_bus(&i2c->adapter)) {
161+ dev_err(&z->dev, "i2c_pcf_add_bus() failed\n");
162+ return -ENXIO;
163+ }
164+
165+ dev_info(&z->dev, "ICY I2C controller at %pa, IRQ not implemented\n",
166+ &z->resource.start);
167+
168+ /*
169+ * The 2019 a1k.org PCBs have an LTC2990 at 0x4c, so start
170+ * it automatically once ltc2990 is modprobed.
171+ *
172+ * in0 is the voltage of the internal 5V power supply.
173+ * temp1 is the temperature inside the chip.
174+ *
175+ * See property_entry above for in1, in2, temp3.
176+ */
177+ new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL);
178+ if (IS_ERR(new_fwnode)) {
179+ dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n",
180+ PTR_ERR(new_fwnode));
181+ } else {
182+ /*
183+ * Store the fwnode so we can destroy it on .remove().
184+ * Only store it on success, as fwnode_remove_software_node()
185+ * is NULL safe, but not PTR_ERR safe.
186+ */
187+ i2c->ltc2990_fwnode = new_fwnode;
188+ ltc2990_info.fwnode = new_fwnode;
189+
190+ i2c->ltc2990_client =
191+ i2c_new_probed_device(&i2c->adapter,
192+ &ltc2990_info,
193+ icy_ltc2990_addresses,
194+ NULL);
195+ }
196+
197+ return 0;
198+}
199+
200+static void icy_remove(struct zorro_dev *z)
201+{
202+ struct icy_i2c *i2c = dev_get_drvdata(&z->dev);
203+
204+ i2c_unregister_device(i2c->ltc2990_client);
205+ fwnode_remove_software_node(i2c->ltc2990_fwnode);
206+
207+ i2c_del_adapter(&i2c->adapter);
208+}
209+
210+static const struct zorro_device_id icy_zorro_tbl[] = {
211+ { ZORRO_ID(VMC, 15, 0), },
212+ { 0 }
213+};
214+
215+MODULE_DEVICE_TABLE(zorro, icy_zorro_tbl);
216+
217+static struct zorro_driver icy_driver = {
218+ .name = "i2c-icy",
219+ .id_table = icy_zorro_tbl,
220+ .probe = icy_probe,
221+ .remove = icy_remove,
222+};
223+
224+module_driver(icy_driver,
225+ zorro_register_driver,
226+ zorro_unregister_driver);
227+
228+MODULE_AUTHOR("Max Staudt <max@enpas.org>");
229+MODULE_DESCRIPTION("I2C bus via PCF8584 on ICY Zorro card");
230+MODULE_LICENSE("GPL v2");
drivers/i2c/busses/i2c-imx-lpi2c.c+1−3
@@ -545,7 +545,6 @@ MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); · 544 unmodified lines
545545 static int lpi2c_imx_probe(struct platform_device *pdev)
546546 {
547547 struct lpi2c_imx_struct *lpi2c_imx;
548− struct resource *res;
549548 unsigned int temp;
550549 int irq, ret;
551550
@@ -553,8 +552,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev) · 1 unmodified line
553552 if (!lpi2c_imx)
554553 return -ENOMEM;
555554
556− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
557− lpi2c_imx->base = devm_ioremap_resource(&pdev->dev, res);
555+ lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0);
558556 if (IS_ERR(lpi2c_imx->base))
559557 return PTR_ERR(lpi2c_imx->base);
560558
drivers/i2c/busses/i2c-imx.c+13−4
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 *
2121 */
2222
23+#include <linux/acpi.h>
2324 #include <linux/clk.h>
2425 #include <linux/completion.h>
2526 #include <linux/delay.h>
@@ -255,6 +256,12 @@ static const struct of_device_id i2c_imx_dt_ids[] = { · 229 unmodified lines
255256 };
256257 MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids);
257258
259+static const struct acpi_device_id i2c_imx_acpi_ids[] = {
260+ {"NXP0001", .driver_data = (kernel_ulong_t)&vf610_i2c_hwdata},
261+ { }
262+};
263+MODULE_DEVICE_TABLE(acpi, i2c_imx_acpi_ids);
264+
258265 static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx)
259266 {
260267 return i2c_imx->hwdata->devtype == IMX1_I2C;
@@ -1048,14 +1055,13 @@ static const struct i2c_algorithm i2c_imx_algo = { · 787 unmodified lines
10481055
10491056 static int i2c_imx_probe(struct platform_device *pdev)
10501057 {
1051− const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
1052− &pdev->dev);
10531058 struct imx_i2c_struct *i2c_imx;
10541059 struct resource *res;
10551060 struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
10561061 void __iomem *base;
10571062 int irq, ret;
10581063 dma_addr_t phy_addr;
1064+ const struct imx_i2c_hwdata *match;
10591065
10601066 dev_dbg(&pdev->dev, "<%s>\n", __func__);
10611067
@@ -1075,8 +1081,9 @@ static int i2c_imx_probe(struct platform_device *pdev) · 13 unmodified lines
10751081 if (!i2c_imx)
10761082 return -ENOMEM;
10771083
1078− if (of_id)
1079− i2c_imx->hwdata = of_id->data;
1084+ match = device_get_match_data(&pdev->dev);
1085+ if (match)
1086+ i2c_imx->hwdata = match;
10801087 else
10811088 i2c_imx->hwdata = (struct imx_i2c_hwdata *)
10821089 platform_get_device_id(pdev)->driver_data;
@@ -1089,6 +1096,7 @@ static int i2c_imx_probe(struct platform_device *pdev) · 6 unmodified lines
10891096 i2c_imx->adapter.nr = pdev->id;
10901097 i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
10911098 i2c_imx->base = base;
1099+ ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev));
10921100
10931101 /* Get I2C clock */
10941102 i2c_imx->clk = devm_clk_get(&pdev->dev, NULL);
@@ -1247,6 +1255,7 @@ static struct platform_driver i2c_imx_driver = { · 152 unmodified lines
12471255 .name = DRIVER_NAME,
12481256 .pm = &i2c_imx_pm_ops,
12491257 .of_match_table = i2c_imx_dt_ids,
1258+ .acpi_match_table = i2c_imx_acpi_ids,
12501259 },
12511260 .id_table = imx_i2c_devtype,
12521261 };
drivers/i2c/busses/i2c-ismt.c+0−2
@@ -781,8 +781,6 @@ static int ismt_dev_init(struct ismt_priv *priv) · 780 unmodified lines
781781 if (!priv->hw)
782782 return -ENOMEM;
783783
784− memset(priv->hw, 0, (ISMT_DESC_ENTRIES * sizeof(struct ismt_desc)));
785−
786784 priv->head = 0;
787785 init_completion(&priv->cmp);
788786
drivers/i2c/busses/i2c-mxs.c+1−3
@@ -802,7 +802,6 @@ static int mxs_i2c_probe(struct platform_device *pdev) · 801 unmodified lines
802802 struct device *dev = &pdev->dev;
803803 struct mxs_i2c_dev *i2c;
804804 struct i2c_adapter *adap;
805− struct resource *res;
806805 int err, irq;
807806
808807 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
@@ -814,8 +813,7 @@ static int mxs_i2c_probe(struct platform_device *pdev) · 5 unmodified lines
814813 i2c->dev_type = device_id->driver_data;
815814 }
816815
817− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
818− i2c->regs = devm_ioremap_resource(&pdev->dev, res);
816+ i2c->regs = devm_platform_ioremap_resource(pdev, 0);
819817 if (IS_ERR(i2c->regs))
820818 return PTR_ERR(i2c->regs);
821819
drivers/i2c/busses/i2c-ocores.c+3−2
@@ -703,8 +703,9 @@ static int ocores_i2c_probe(struct platform_device *pdev) · 702 unmodified lines
703703 }
704704
705705 if (ocores_algorithm.master_xfer != ocores_xfer_polling) {
706− ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0,
707− pdev->name, i2c);
706+ ret = devm_request_any_context_irq(&pdev->dev, irq,
707+ ocores_isr, 0,
708+ pdev->name, i2c);
708709 if (ret) {
709710 dev_err(&pdev->dev, "Cannot claim IRQ\n");
710711 goto err_clk;
drivers/i2c/busses/i2c-piix4.c+27−7
@@ -72,7 +72,8 @@ · 71 unmodified lines
7272 #define PIIX4_BLOCK_DATA 0x14
7373
7474 /* Multi-port constants */
75−#define PIIX4_MAX_ADAPTERS 4
75+#define PIIX4_MAX_ADAPTERS 4
76+#define HUDSON2_MAIN_PORTS 2 /* HUDSON2, KERNCZ reserves ports 3, 4 */
7677
7778 /* SB800 constants */
7879 #define SB800_PIIX4_SMB_IDX 0xcd6
@@ -806,10 +807,12 @@ MODULE_DEVICE_TABLE (pci, piix4_ids); · 727 unmodified lines
806807
807808 static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
808809 static struct i2c_adapter *piix4_aux_adapter;
810+static int piix4_adapter_count;
809811
810812 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
811813 bool sb800_main, u8 port, bool notify_imc,
812− const char *name, struct i2c_adapter **padap)
814+ u8 hw_port_nr, const char *name,
815+ struct i2c_adapter **padap)
813816 {
814817 struct i2c_adapter *adap;
815818 struct i2c_piix4_adapdata *adapdata;
@@ -841,6 +844,12 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 25 unmodified lines
841844 /* set up the sysfs linkage to our parent device */
842845 adap->dev.parent = &dev->dev;
843846
847+ if (has_acpi_companion(&dev->dev)) {
848+ acpi_preset_companion(&adap->dev,
849+ ACPI_COMPANION(&dev->dev),
850+ hw_port_nr);
851+ }
852+
844853 snprintf(adap->name, sizeof(adap->name),
845854 "SMBus PIIX4 adapter%s at %04x", name, smba);
846855
@@ -865,8 +874,19 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba, · 18 unmodified lines
865874 int port;
866875 int retval;
867876
868− for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
877+ if (dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS ||
878+ (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS &&
879+ dev->revision >= 0x1F)) {
880+ piix4_adapter_count = HUDSON2_MAIN_PORTS;
881+ } else {
882+ piix4_adapter_count = PIIX4_MAX_ADAPTERS;
883+ }
884+
885+ for (port = 0; port < piix4_adapter_count; port++) {
886+ u8 hw_port_nr = port == 0 ? 0 : port + 1;
887+
869888 retval = piix4_add_adapter(dev, smba, true, port, notify_imc,
889+ hw_port_nr,
870890 piix4_main_port_names_sb800[port],
871891 &piix4_main_adapters[port]);
872892 if (retval < 0)
@@ -937,8 +957,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 64 unmodified lines
937957 return retval;
938958
939959 /* Try to register main SMBus adapter, give up if we can't */
940− retval = piix4_add_adapter(dev, retval, false, 0, false, "",
941− &piix4_main_adapters[0]);
960+ retval = piix4_add_adapter(dev, retval, false, 0, false, 0,
961+ "", &piix4_main_adapters[0]);
942962 if (retval < 0)
943963 return retval;
944964 }
@@ -964,7 +984,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 19 unmodified lines
964984 if (retval > 0) {
965985 /* Try to add the aux adapter if it exists,
966986 * piix4_add_adapter will clean up if this fails */
967− piix4_add_adapter(dev, retval, false, 0, false,
987+ piix4_add_adapter(dev, retval, false, 0, false, 1,
968988 is_sb800 ? piix4_aux_port_name_sb800 : "",
969989 &piix4_aux_adapter);
970990 }
@@ -987,7 +1007,7 @@ static void piix4_adap_remove(struct i2c_adapter *adap) · 16 unmodified lines
9871007
9881008 static void piix4_remove(struct pci_dev *dev)
9891009 {
990− int port = PIIX4_MAX_ADAPTERS;
1010+ int port = piix4_adapter_count;
9911011
9921012 while (--port >= 0) {
9931013 if (piix4_main_adapters[port]) {
drivers/i2c/busses/i2c-sprd.c+13−12
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include <linux/init.h>
1313 #include <linux/interrupt.h>
1414 #include <linux/kernel.h>
15+#include <linux/module.h>
1516 #include <linux/of.h>
1617 #include <linux/of_device.h>
1718 #include <linux/platform_device.h>
@@ -465,9 +466,9 @@ static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev) · 447 unmodified lines
465466
466467 i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable");
467468 if (IS_ERR(i2c_dev->clk)) {
468− dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n",
469− i2c_dev->adap.nr);
470− i2c_dev->clk = NULL;
469+ dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n",
470+ i2c_dev->adap.nr);
471+ return PTR_ERR(i2c_dev->clk);
471472 }
472473
473474 return 0;
@@ -477,7 +478,6 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 3 unmodified lines
477478 {
478479 struct device *dev = &pdev->dev;
479480 struct sprd_i2c *i2c_dev;
480− struct resource *res;
481481 u32 prop;
482482 int ret;
483483
@@ -487,8 +487,7 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 3 unmodified lines
487487 if (!i2c_dev)
488488 return -ENOMEM;
489489
490− res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
491− i2c_dev->base = devm_ioremap_resource(dev, res);
490+ i2c_dev->base = devm_platform_ioremap_resource(pdev, 0);
492491 if (IS_ERR(i2c_dev->base))
493492 return PTR_ERR(i2c_dev->base);
494493
@@ -520,7 +519,10 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 25 unmodified lines
520519 if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
521520 return -EINVAL;
522521
523− sprd_i2c_clk_init(i2c_dev);
522+ ret = sprd_i2c_clk_init(i2c_dev);
523+ if (ret)
524+ return ret;
525+
524526 platform_set_drvdata(pdev, i2c_dev);
525527
526528 ret = clk_prepare_enable(i2c_dev->clk);
@@ -644,8 +646,7 @@ static struct platform_driver sprd_i2c_driver = { · 117 unmodified lines
644646 },
645647 };
646648
647−static int sprd_i2c_init(void)
648−{
649− return platform_driver_register(&sprd_i2c_driver);
650−}
651−arch_initcall_sync(sprd_i2c_init);
649+module_platform_driver(sprd_i2c_driver);
650+
651+MODULE_DESCRIPTION("Spreadtrum I2C master controller driver");
652+MODULE_LICENSE("GPL v2");
drivers/i2c/busses/i2c-stm32f7.c+1−1
@@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap) · 1808 unmodified lines
18091809 I2C_FUNC_SMBUS_I2C_BLOCK;
18101810 }
18111811
1812−static struct i2c_algorithm stm32f7_i2c_algo = {
1812+static const struct i2c_algorithm stm32f7_i2c_algo = {
18131813 .master_xfer = stm32f7_i2c_xfer,
18141814 .smbus_xfer = stm32f7_i2c_smbus_xfer,
18151815 .functionality = stm32f7_i2c_func,
drivers/i2c/busses/i2c-synquacer.c+1−1
@@ -526,7 +526,7 @@ static const struct i2c_algorithm synquacer_i2c_algo = { · 525 unmodified lines
526526 .functionality = synquacer_i2c_functionality,
527527 };
528528
529−static struct i2c_adapter synquacer_i2c_ops = {
529+static const struct i2c_adapter synquacer_i2c_ops = {
530530 .owner = THIS_MODULE,
531531 .name = "synquacer_i2c-adapter",
532532 .algo = &synquacer_i2c_algo,
drivers/i2c/busses/i2c-taos-evm.c+1−1
@@ -39,7 +39,7 @@ struct taos_data { · 38 unmodified lines
3939 };
4040
4141 /* TAOS TSL2550 EVM */
42−static struct i2c_board_info tsl2550_info = {
42+static const struct i2c_board_info tsl2550_info = {
4343 I2C_BOARD_INFO("tsl2550", 0x39),
4444 };
4545
drivers/i2c/busses/i2c-tegra.c+27−29
@@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev) · 635 unmodified lines
636636 dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
637637 }
638638
639−static int tegra_i2c_runtime_resume(struct device *dev)
639+static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
640640 {
641641 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
642642 int ret;
@@ -665,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev) · 22 unmodified lines
665665 return 0;
666666 }
667667
668−static int tegra_i2c_runtime_suspend(struct device *dev)
668+static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)
669669 {
670670 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
671671
@@ -713,12 +713,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) · 41 unmodified lines
713713 u32 tsu_thd;
714714 u8 tlow, thigh;
715715
716− err = pm_runtime_get_sync(i2c_dev->dev);
717− if (err < 0) {
718− dev_err(i2c_dev->dev, "runtime resume failed %d\n", err);
719− return err;
720− }
721−
722716 reset_control_assert(i2c_dev->rst);
723717 udelay(2);
724718 reset_control_deassert(i2c_dev->rst);
@@ -772,7 +766,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) · 47 unmodified lines
772766 if (err) {
773767 dev_err(i2c_dev->dev,
774768 "failed changing clock rate: %d\n", err);
775− goto err;
769+ return err;
776770 }
777771 }
778772
@@ -787,23 +781,21 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) · 8 unmodified lines
787781
788782 err = tegra_i2c_flush_fifos(i2c_dev);
789783 if (err)
790− goto err;
784+ return err;
791785
792786 if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg)
793787 i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE);
794788
795789 err = tegra_i2c_wait_for_config_load(i2c_dev);
796790 if (err)
797− goto err;
791+ return err;
798792
799793 if (i2c_dev->irq_disabled) {
800794 i2c_dev->irq_disabled = false;
801795 enable_irq(i2c_dev->irq);
802796 }
803797
804−err:
805− pm_runtime_put(i2c_dev->dev);
806− return err;
798+ return 0;
807799 }
808800
809801 static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev)
@@ -1616,12 +1608,14 @@ static int tegra_i2c_probe(struct platform_device *pdev) · 806 unmodified lines
16161608 }
16171609
16181610 pm_runtime_enable(&pdev->dev);
1619− if (!pm_runtime_enabled(&pdev->dev)) {
1611+ if (!pm_runtime_enabled(&pdev->dev))
16201612 ret = tegra_i2c_runtime_resume(&pdev->dev);
1621− if (ret < 0) {
1622− dev_err(&pdev->dev, "runtime resume failed\n");
1623− goto unprepare_div_clk;
1624− }
1613+ else
1614+ ret = pm_runtime_get_sync(i2c_dev->dev);
1615+
1616+ if (ret < 0) {
1617+ dev_err(&pdev->dev, "runtime resume failed\n");
1618+ goto unprepare_div_clk;
16251619 }
16261620
16271621 if (i2c_dev->is_multimaster_mode) {
@@ -1666,6 +1660,8 @@ static int tegra_i2c_probe(struct platform_device *pdev) · 38 unmodified lines
16661660 if (ret)
16671661 goto release_dma;
16681662
1663+ pm_runtime_put(&pdev->dev);
1664+
16691665 return 0;
16701666
16711667 release_dma:
@@ -1711,8 +1707,7 @@ static int tegra_i2c_remove(struct platform_device *pdev) · 39 unmodified lines
17111707 return 0;
17121708 }
17131709
1714−#ifdef CONFIG_PM_SLEEP
1715−static int tegra_i2c_suspend(struct device *dev)
1710+static int __maybe_unused tegra_i2c_suspend(struct device *dev)
17161711 {
17171712 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
17181713
@@ -1721,38 +1716,41 @@ static int tegra_i2c_suspend(struct device *dev) · 2 unmodified lines
17211716 return 0;
17221717 }
17231718
1724−static int tegra_i2c_resume(struct device *dev)
1719+static int __maybe_unused tegra_i2c_resume(struct device *dev)
17251720 {
17261721 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
17271722 int err;
17281723
1724+ err = tegra_i2c_runtime_resume(dev);
1725+ if (err)
1726+ return err;
1727+
17291728 err = tegra_i2c_init(i2c_dev, false);
17301729 if (err)
17311730 return err;
17321731
1732+ err = tegra_i2c_runtime_suspend(dev);
1733+ if (err)
1734+ return err;
1735+
17331736 i2c_mark_adapter_resumed(&i2c_dev->adapter);
17341737
17351738 return 0;
17361739 }
17371740
17381741 static const struct dev_pm_ops tegra_i2c_pm = {
1739− SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
1742+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
17401743 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
17411744 NULL)
17421745 };
17431746
1744−#define TEGRA_I2C_PM (&tegra_i2c_pm)
1745−#else
1746−#define TEGRA_I2C_PM NULL
1747−#endif
1748−
17491747 static struct platform_driver tegra_i2c_driver = {
17501748 .probe = tegra_i2c_probe,
17511749 .remove = tegra_i2c_remove,
17521750 .driver = {
17531751 .name = "tegra-i2c",
17541752 .of_match_table = tegra_i2c_of_match,
1755− .pm = TEGRA_I2C_PM,
1753+ .pm = &tegra_i2c_pm,
17561754 },
17571755 };
17581756
drivers/i2c/busses/i2c-uniphier-f.c+2−24
@@ -108,7 +108,6 @@ static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv, · 107 unmodified lines
108108 if (fifo_space-- <= 0)
109109 break;
110110
111− dev_dbg(&priv->adap.dev, "write data: %02x\n", *priv->buf);
112111 writel(*priv->buf++, priv->membase + UNIPHIER_FI2C_DTTX);
113112 priv->len--;
114113 }
@@ -124,7 +123,6 @@ static void uniphier_fi2c_drain_rxfifo(struct uniphier_fi2c_priv *priv) · 9 unmodified lines
124123 break;
125124
126125 *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX);
127− dev_dbg(&priv->adap.dev, "read data: %02x\n", priv->buf[-1]);
128126 priv->len--;
129127 }
130128 }
@@ -142,8 +140,6 @@ static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv, · 11 unmodified lines
142140
143141 static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv)
144142 {
145− dev_dbg(&priv->adap.dev, "stop condition\n");
146−
147143 priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP;
148144 uniphier_fi2c_set_irqs(priv);
149145 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STO,
@@ -160,21 +156,15 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) · 10 unmodified lines
160156 irq_status = readl(priv->membase + UNIPHIER_FI2C_INT);
161157 irq_status &= priv->enabled_irqs;
162158
163− dev_dbg(&priv->adap.dev,
164− "interrupt: enabled_irqs=%04x, irq_status=%04x\n",
165− priv->enabled_irqs, irq_status);
166−
167159 if (irq_status & UNIPHIER_FI2C_INT_STOP)
168160 goto complete;
169161
170162 if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) {
171− dev_dbg(&priv->adap.dev, "arbitration lost\n");
172163 priv->error = -EAGAIN;
173164 goto complete;
174165 }
175166
176167 if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) {
177− dev_dbg(&priv->adap.dev, "could not get ACK\n");
178168 priv->error = -ENXIO;
179169 if (priv->flags & UNIPHIER_FI2C_RD) {
180170 /*
@@ -215,18 +205,14 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) · 34 unmodified lines
215205 if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) {
216206 if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE &&
217207 !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) {
218− dev_dbg(&priv->adap.dev,
219− "enable read byte count IRQ\n");
220208 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB;
221209 uniphier_fi2c_set_irqs(priv);
222210 priv->flags |= UNIPHIER_FI2C_BYTE_WISE;
223211 }
224− if (priv->len <= 1) {
225− dev_dbg(&priv->adap.dev, "set NACK\n");
212+ if (priv->len <= 1)
226213 writel(UNIPHIER_FI2C_CR_MST |
227214 UNIPHIER_FI2C_CR_NACK,
228215 priv->membase + UNIPHIER_FI2C_CR);
229− }
230216 }
231217
232218 goto handled;
@@ -334,10 +320,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, · 101 unmodified lines
334320 bool is_read = msg->flags & I2C_M_RD;
335321 unsigned long time_left, flags;
336322
337− dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, repeat=%d, stop=%d\n",
338− is_read ? "receive" : "transmit", msg->addr, msg->len,
339− repeat, stop);
340−
341323 priv->len = msg->len;
342324 priv->buf = msg->buf;
343325 priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS;
@@ -359,7 +341,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, · 15 unmodified lines
359341 else
360342 uniphier_fi2c_tx_init(priv, msg->addr, repeat);
361343
362− dev_dbg(&adap->dev, "start condition\n");
363344 /*
364345 * For a repeated START condition, writing a slave address to the FIFO
365346 * kicks the controller. So, the UNIPHIER_FI2C_CR register should be
@@ -383,7 +364,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, · 17 unmodified lines
383364 uniphier_fi2c_recover(priv);
384365 return -ETIMEDOUT;
385366 }
386− dev_dbg(&adap->dev, "complete\n");
387367
388368 if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) {
389369 u32 status;
@@ -538,7 +518,6 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) · 148 unmodified lines
538518 {
539519 struct device *dev = &pdev->dev;
540520 struct uniphier_fi2c_priv *priv;
541− struct resource *regs;
542521 u32 bus_speed;
543522 unsigned long clk_rate;
544523 int irq, ret;
@@ -547,8 +526,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) · 2 unmodified lines
547526 if (!priv)
548527 return -ENOMEM;
549528
550− regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
551− priv->membase = devm_ioremap_resource(dev, regs);
529+ priv->membase = devm_platform_ioremap_resource(pdev, 0);
552530 if (IS_ERR(priv->membase))
553531 return PTR_ERR(priv->membase);
554532
drivers/i2c/busses/i2c-uniphier.c+4−18
@@ -71,7 +71,6 @@ static int uniphier_i2c_xfer_byte(struct i2c_adapter *adap, u32 txdata, · 70 unmodified lines
7171 reinit_completion(&priv->comp);
7272
7373 txdata |= UNIPHIER_I2C_DTRM_IRQEN;
74− dev_dbg(&adap->dev, "write data: 0x%04x\n", txdata);
7574 writel(txdata, priv->membase + UNIPHIER_I2C_DTRM);
7675
7776 time_left = wait_for_completion_timeout(&priv->comp, adap->timeout);
@@ -81,8 +80,6 @@ static int uniphier_i2c_xfer_byte(struct i2c_adapter *adap, u32 txdata, · 3 unmodified lines
8180 }
8281
8382 rxdata = readl(priv->membase + UNIPHIER_I2C_DREC);
84− dev_dbg(&adap->dev, "read data: 0x%04x\n", rxdata);
85−
8683 if (rxdatap)
8784 *rxdatap = rxdata;
8885
@@ -98,14 +95,11 @@ static int uniphier_i2c_send_byte(struct i2c_adapter *adap, u32 txdata) · 9 unmodified lines
9895 if (ret)
9996 return ret;
10097
101− if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) {
102− dev_dbg(&adap->dev, "arbitration lost\n");
98+ if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB))
10399 return -EAGAIN;
104− }
105− if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) {
106− dev_dbg(&adap->dev, "could not get ACK\n");
100+
101+ if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB))
107102 return -ENXIO;
108− }
109103
110104 return 0;
111105 }
@@ -115,7 +109,6 @@ static int uniphier_i2c_tx(struct i2c_adapter *adap, u16 addr, u16 len, · 3 unmodified lines
115109 {
116110 int ret;
117111
118− dev_dbg(&adap->dev, "start condition\n");
119112 ret = uniphier_i2c_send_byte(adap, addr << 1 |
120113 UNIPHIER_I2C_DTRM_STA |
121114 UNIPHIER_I2C_DTRM_NACK);
@@ -137,7 +130,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len, · 15 unmodified lines
137130 {
138131 int ret;
139132
140− dev_dbg(&adap->dev, "start condition\n");
141133 ret = uniphier_i2c_send_byte(adap, addr << 1 |
142134 UNIPHIER_I2C_DTRM_STA |
143135 UNIPHIER_I2C_DTRM_NACK |
@@ -161,7 +153,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len, · 17 unmodified lines
161153
162154 static int uniphier_i2c_stop(struct i2c_adapter *adap)
163155 {
164− dev_dbg(&adap->dev, "stop condition\n");
165156 return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO |
166157 UNIPHIER_I2C_DTRM_NACK);
167158 }
@@ -173,9 +164,6 @@ static int uniphier_i2c_master_xfer_one(struct i2c_adapter *adap, · 5 unmodified lines
173164 bool recovery = false;
174165 int ret;
175166
176− dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, stop=%d\n",
177− is_read ? "receive" : "transmit", msg->addr, msg->len, stop);
178−
179167 if (is_read)
180168 ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf);
181169 else
@@ -326,7 +314,6 @@ static int uniphier_i2c_probe(struct platform_device *pdev) · 144 unmodified lines
326314 {
327315 struct device *dev = &pdev->dev;
328316 struct uniphier_i2c_priv *priv;
329− struct resource *regs;
330317 u32 bus_speed;
331318 unsigned long clk_rate;
332319 int irq, ret;
@@ -335,8 +322,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev) · 2 unmodified lines
335322 if (!priv)
336323 return -ENOMEM;
337324
338− regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
339− priv->membase = devm_ioremap_resource(dev, regs);
325+ priv->membase = devm_platform_ioremap_resource(pdev, 0);
340326 if (IS_ERR(priv->membase))
341327 return PTR_ERR(priv->membase);
342328
drivers/i2c/i2c-core-base.c+9−11
@@ -350,13 +350,11 @@ static int i2c_device_probe(struct device *dev) · 349 unmodified lines
350350 return -ENODEV;
351351
352352 if (client->flags & I2C_CLIENT_WAKE) {
353− int wakeirq = -ENOENT;
353+ int wakeirq;
354354
355− if (dev->of_node) {
356− wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
357− if (wakeirq == -EPROBE_DEFER)
358− return wakeirq;
359− }
355+ wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
356+ if (wakeirq == -EPROBE_DEFER)
357+ return wakeirq;
360358
361359 device_init_wakeup(&client->dev, true);
362360
@@ -966,7 +964,7 @@ struct i2c_client *devm_i2c_new_dummy_device(struct device *dev, · 603 unmodified lines
966964 EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device);
967965
968966 /**
969− * i2c_new_secondary_device - Helper to get the instantiated secondary address
967+ * i2c_new_ancillary_device - Helper to get the instantiated secondary address
970968 * and create the associated device
971969 * @client: Handle to the primary client
972970 * @name: Handle to specify which secondary address to get
@@ -985,9 +983,9 @@ EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device); · 12 unmodified lines
985983 * cell whose "reg-names" value matches the slave name.
986984 *
987985 * This returns the new i2c client, which should be saved for later use with
988− * i2c_unregister_device(); or NULL to indicate an error.
986+ * i2c_unregister_device(); or an ERR_PTR to describe the error.
989987 */
990−struct i2c_client *i2c_new_secondary_device(struct i2c_client *client,
988+struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client,
991989 const char *name,
992990 u16 default_addr)
993991 {
@@ -1002,9 +1000,9 @@ struct i2c_client *i2c_new_secondary_device(struct i2c_client *client, · 8 unmodified lines
10021000 }
10031001
10041002 dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr);
1005− return i2c_new_dummy(client->adapter, addr);
1003+ return i2c_new_dummy_device(client->adapter, addr);
10061004 }
1007−EXPORT_SYMBOL_GPL(i2c_new_secondary_device);
1005+EXPORT_SYMBOL_GPL(i2c_new_ancillary_device);
10081006
10091007 /* ------------------------------------------------------------------------- */
10101008
drivers/i2c/i2c-slave-eeprom.c+31−11
@@ -11,6 +11,13 @@ · 10 unmodified lines
1111 * pointer, yet implementation is deferred until the need actually arises.
1212 */
1313
14+/*
15+ * FIXME: What to do if only 8 bits of a 16 bit address are sent?
16+ * The ST-M24C64 sends only 0xff then. Needs verification with other
17+ * EEPROMs, though. We currently use the 8 bit as a valid address.
18+ */
19+
20+#include <linux/bitfield.h>
1421 #include <linux/i2c.h>
1522 #include <linux/init.h>
1623 #include <linux/module.h>
@@ -21,12 +28,18 @@ · 4 unmodified lines
2128
2229 struct eeprom_data {
2330 struct bin_attribute bin;
24− bool first_write;
2531 spinlock_t buffer_lock;
26− u8 buffer_idx;
32+ u16 buffer_idx;
33+ u16 address_mask;
34+ u8 num_address_bytes;
35+ u8 idx_write_cnt;
2736 u8 buffer[];
2837 };
2938
39+#define I2C_SLAVE_BYTELEN GENMASK(15, 0)
40+#define I2C_SLAVE_FLAG_ADDR16 BIT(16)
41+#define I2C_SLAVE_DEVICE_MAGIC(_len, _flags) ((_flags) | (_len))
42+
3043 static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
3144 enum i2c_slave_event event, u8 *val)
3245 {
@@ -34,12 +47,14 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, · 1 unmodified line
3447
3548 switch (event) {
3649 case I2C_SLAVE_WRITE_RECEIVED:
37− if (eeprom->first_write) {
38− eeprom->buffer_idx = *val;
39− eeprom->first_write = false;
50+ if (eeprom->idx_write_cnt < eeprom->num_address_bytes) {
51+ if (eeprom->idx_write_cnt == 0)
52+ eeprom->buffer_idx = 0;
53+ eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8);
54+ eeprom->idx_write_cnt++;
4055 } else {
4156 spin_lock(&eeprom->buffer_lock);
42− eeprom->buffer[eeprom->buffer_idx++] = *val;
57+ eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val;
4358 spin_unlock(&eeprom->buffer_lock);
4459 }
4560 break;
@@ -50,7 +65,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, · 4 unmodified lines
5065 /* fallthrough */
5166 case I2C_SLAVE_READ_REQUESTED:
5267 spin_lock(&eeprom->buffer_lock);
53− *val = eeprom->buffer[eeprom->buffer_idx];
68+ *val = eeprom->buffer[eeprom->buffer_idx & eeprom->address_mask];
5469 spin_unlock(&eeprom->buffer_lock);
5570 /*
5671 * Do not increment buffer_idx here, because we don't know if
@@ -61,7 +76,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, · 4 unmodified lines
6176
6277 case I2C_SLAVE_STOP:
6378 case I2C_SLAVE_WRITE_REQUESTED:
64− eeprom->first_write = true;
79+ eeprom->idx_write_cnt = 0;
6580 break;
6681
6782 default:
@@ -105,13 +120,16 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de · 37 unmodified lines
105120 {
106121 struct eeprom_data *eeprom;
107122 int ret;
108− unsigned size = id->driver_data;
123+ unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data);
124+ unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, id->driver_data);
109125
110126 eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL);
111127 if (!eeprom)
112128 return -ENOMEM;
113129
114− eeprom->first_write = true;
130+ eeprom->idx_write_cnt = 0;
131+ eeprom->num_address_bytes = flag_addr16 ? 2 : 1;
132+ eeprom->address_mask = size - 1;
115133 spin_lock_init(&eeprom->buffer_lock);
116134 i2c_set_clientdata(client, eeprom);
117135
@@ -146,7 +164,9 @@ static int i2c_slave_eeprom_remove(struct i2c_client *client) · 28 unmodified lines
146164 }
147165
148166 static const struct i2c_device_id i2c_slave_eeprom_id[] = {
149− { "slave-24c02", 2048 / 8 },
167+ { "slave-24c02", I2C_SLAVE_DEVICE_MAGIC(2048 / 8, 0) },
168+ { "slave-24c32", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) },
169+ { "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) },
150170 { }
151171 };
152172 MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);
drivers/media/i2c/adv748x/adv748x-core.c+3−3
@@ -183,14 +183,14 @@ static int adv748x_initialise_clients(struct adv748x_state *state) · 182 unmodified lines
183183 int ret;
184184
185185 for (i = ADV748X_PAGE_DPLL; i < ADV748X_PAGE_MAX; ++i) {
186− state->i2c_clients[i] = i2c_new_secondary_device(
186+ state->i2c_clients[i] = i2c_new_ancillary_device(
187187 state->client,
188188 adv748x_default_addresses[i].name,
189189 adv748x_default_addresses[i].default_addr);
190190
191− if (state->i2c_clients[i] == NULL) {
191+ if (IS_ERR(state->i2c_clients[i])) {
192192 adv_err(state, "failed to create i2c client %u\n", i);
193− return -ENOMEM;
193+ return PTR_ERR(state->i2c_clients[i]);
194194 }
195195
196196 ret = adv748x_configure_regmap(state, i);
drivers/media/i2c/adv7604.c+12−10
@@ -2862,10 +2862,8 @@ static void adv76xx_unregister_clients(struct adv76xx_state *state) · 2861 unmodified lines
28622862 {
28632863 unsigned int i;
28642864
2865− for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) {
2866− if (state->i2c_clients[i])
2867− i2c_unregister_device(state->i2c_clients[i]);
2868− }
2865+ for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i)
2866+ i2c_unregister_device(state->i2c_clients[i]);
28692867 }
28702868
28712869 static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd,
@@ -2878,14 +2876,14 @@ static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd, · 6 unmodified lines
28782876 struct i2c_client *new_client;
28792877
28802878 if (pdata && pdata->i2c_addresses[page])
2881− new_client = i2c_new_dummy(client->adapter,
2879+ new_client = i2c_new_dummy_device(client->adapter,
28822880 pdata->i2c_addresses[page]);
28832881 else
2884− new_client = i2c_new_secondary_device(client,
2882+ new_client = i2c_new_ancillary_device(client,
28852883 adv76xx_default_addresses[page].name,
28862884 adv76xx_default_addresses[page].default_addr);
28872885
2888− if (new_client)
2886+ if (!IS_ERR(new_client))
28892887 io_write(sd, io_reg, new_client->addr << 1);
28902888
28912889 return new_client;
@@ -3516,15 +3514,19 @@ static int adv76xx_probe(struct i2c_client *client, · 624 unmodified lines
35163514 }
35173515
35183516 for (i = 1; i < ADV76XX_PAGE_MAX; ++i) {
3517+ struct i2c_client *dummy_client;
3518+
35193519 if (!(BIT(i) & state->info->page_mask))
35203520 continue;
35213521
3522− state->i2c_clients[i] = adv76xx_dummy_client(sd, i);
3523− if (!state->i2c_clients[i]) {
3524− err = -EINVAL;
3522+ dummy_client = adv76xx_dummy_client(sd, i);
3523+ if (IS_ERR(dummy_client)) {
3524+ err = PTR_ERR(dummy_client);
35253525 v4l2_err(sd, "failed to create i2c client %u\n", i);
35263526 goto err_i2c;
35273527 }
3528+
3529+ state->i2c_clients[i] = dummy_client;
35283530 }
35293531
35303532 INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug,
drivers/misc/eeprom/at24.c+0−1
@@ -14,7 +14,6 @@ · 13 unmodified lines
1414 #include <linux/delay.h>
1515 #include <linux/mutex.h>
1616 #include <linux/mod_devicetable.h>
17−#include <linux/log2.h>
1817 #include <linux/bitops.h>
1918 #include <linux/jiffies.h>
2019 #include <linux/property.h>
drivers/watchdog/iTCO_wdt.c+24−2
@@ -48,6 +48,7 @@ · 47 unmodified lines
4848
4949 /* Includes */
5050 #include <linux/acpi.h> /* For ACPI support */
51+#include <linux/bits.h> /* For BIT() */
5152 #include <linux/module.h> /* For module specific items */
5253 #include <linux/moduleparam.h> /* For new moduleparam's */
5354 #include <linux/types.h> /* For standard types (like size_t) */
@@ -215,6 +216,23 @@ static int update_no_reboot_bit_mem(void *priv, bool set) · 161 unmodified lines
215216 return 0;
216217 }
217218
219+static int update_no_reboot_bit_cnt(void *priv, bool set)
220+{
221+ struct iTCO_wdt_private *p = priv;
222+ u16 val, newval;
223+
224+ val = inw(TCO1_CNT(p));
225+ if (set)
226+ val |= BIT(0);
227+ else
228+ val &= ~BIT(0);
229+ outw(val, TCO1_CNT(p));
230+ newval = inw(TCO1_CNT(p));
231+
232+ /* make sure the update is successful */
233+ return val != newval ? -EIO : 0;
234+}
235+
218236 static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p,
219237 struct itco_wdt_platform_data *pdata)
220238 {
@@ -224,7 +242,9 @@ static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p, · 3 unmodified lines
224242 return;
225243 }
226244
227− if (p->iTCO_version >= 2)
245+ if (p->iTCO_version >= 6)
246+ p->update_no_reboot_bit = update_no_reboot_bit_cnt;
247+ else if (p->iTCO_version >= 2)
228248 p->update_no_reboot_bit = update_no_reboot_bit_mem;
229249 else if (p->iTCO_version == 1)
230250 p->update_no_reboot_bit = update_no_reboot_bit_pci;
@@ -452,7 +472,8 @@ static int iTCO_wdt_probe(struct platform_device *pdev) · 221 unmodified lines
452472 * Get the Memory-Mapped GCS or PMC register, we need it for the
453473 * NO_REBOOT flag (TCO v2 and v3).
454474 */
455− if (p->iTCO_version >= 2 && !pdata->update_no_reboot_bit) {
475+ if (p->iTCO_version >= 2 && p->iTCO_version < 6 &&
476+ !pdata->update_no_reboot_bit) {
456477 p->gcs_pmc_res = platform_get_resource(pdev,
457478 IORESOURCE_MEM,
458479 ICH_RES_MEM_GCS_PMC);
@@ -502,6 +523,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) · 43 unmodified lines
502523
503524 /* Clear out the (probably old) status */
504525 switch (p->iTCO_version) {
526+ case 6:
505527 case 5:
506528 case 4:
507529 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */
include/linux/i2c.h+1−1
@@ -473,7 +473,7 @@ extern struct i2c_client * · 472 unmodified lines
473473 devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address);
474474
475475 extern struct i2c_client *
476−i2c_new_secondary_device(struct i2c_client *client,
476+i2c_new_ancillary_device(struct i2c_client *client,
477477 const char *name,
478478 u16 default_addr);
479479

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t