summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-24 19:48:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-24 19:48:02 -0400
commit351c8a09b00b5c51c8f58b016fffe51f87e2d820 (patch)
tree8bced5a9ff152bdcf2bb15a194c97b856c6358d5
parent3cf7487c5de713b706ca2e1f66ec5f9b27fe265a (diff)
parent8ebf15e9c869e764b3aab4928938ee68c0e2bd6d (diff)
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 ...
-rw-r--r--Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt4
-rw-r--r--Documentation/devicetree/bindings/i2c/renesas,i2c.txt (renamed from Documentation/devicetree/bindings/i2c/i2c-rcar.txt)0
-rw-r--r--Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt (renamed from Documentation/devicetree/bindings/i2c/i2c-emev2.txt)0
-rw-r--r--Documentation/devicetree/bindings/i2c/renesas,iic.txt (renamed from Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt)0
-rw-r--r--Documentation/devicetree/bindings/i2c/renesas,riic.txt (renamed from Documentation/devicetree/bindings/i2c/i2c-riic.txt)0
-rw-r--r--MAINTAINERS14
-rw-r--r--drivers/acpi/acpi_apd.c7
-rw-r--r--drivers/gpu/drm/bridge/adv7511/adv7511_drv.c18
-rw-r--r--drivers/i2c/busses/Kconfig17
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-axxia.c152
-rw-r--r--drivers/i2c/busses/i2c-bcm-iproc.c6
-rw-r--r--drivers/i2c/busses/i2c-bcm2835.c11
-rw-r--r--drivers/i2c/busses/i2c-cht-wc.c49
-rw-r--r--drivers/i2c/busses/i2c-designware-master.c14
-rw-r--r--drivers/i2c/busses/i2c-designware-pcidrv.c41
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c22
-rw-r--r--drivers/i2c/busses/i2c-exynos5.c4
-rw-r--r--drivers/i2c/busses/i2c-fsi.c4
-rw-r--r--drivers/i2c/busses/i2c-hix5hd2.c3
-rw-r--r--drivers/i2c/busses/i2c-i801.c145
-rw-r--r--drivers/i2c/busses/i2c-icy.c230
-rw-r--r--drivers/i2c/busses/i2c-imx-lpi2c.c4
-rw-r--r--drivers/i2c/busses/i2c-imx.c17
-rw-r--r--drivers/i2c/busses/i2c-ismt.c2
-rw-r--r--drivers/i2c/busses/i2c-mxs.c4
-rw-r--r--drivers/i2c/busses/i2c-ocores.c5
-rw-r--r--drivers/i2c/busses/i2c-piix4.c34
-rw-r--r--drivers/i2c/busses/i2c-sprd.c25
-rw-r--r--drivers/i2c/busses/i2c-stm32f7.c2
-rw-r--r--drivers/i2c/busses/i2c-synquacer.c2
-rw-r--r--drivers/i2c/busses/i2c-taos-evm.c2
-rw-r--r--drivers/i2c/busses/i2c-tegra.c56
-rw-r--r--drivers/i2c/busses/i2c-uniphier-f.c26
-rw-r--r--drivers/i2c/busses/i2c-uniphier.c22
-rw-r--r--drivers/i2c/i2c-core-base.c20
-rw-r--r--drivers/i2c/i2c-slave-eeprom.c42
-rw-r--r--drivers/media/i2c/adv748x/adv748x-core.c6
-rw-r--r--drivers/media/i2c/adv7604.c22
-rw-r--r--drivers/misc/eeprom/at24.c1
-rw-r--r--drivers/watchdog/iTCO_wdt.c26
-rw-r--r--include/linux/i2c.h2
42 files changed, 795 insertions, 267 deletions
diff --git a/Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt b/Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt
index e9de3756752b..c9a6587fe4bb 100644
--- a/Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt
@@ -1,7 +1,9 @@
1Broadcom BCM2835 I2C controller 1Broadcom BCM2835 I2C controller
2 2
3Required properties: 3Required properties:
4- compatible : Should be "brcm,bcm2835-i2c". 4- compatible : Should be one of:
5 "brcm,bcm2711-i2c"
6 "brcm,bcm2835-i2c"
5- reg: Should contain register location and length. 7- reg: Should contain register location and length.
6- interrupts: Should contain interrupt. 8- interrupts: Should contain interrupt.
7- clocks : The clock feeding the I2C controller. 9- clocks : The clock feeding the I2C controller.
diff --git a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt b/Documentation/devicetree/bindings/i2c/renesas,i2c.txt
index 3ee5e8f6ee01..3ee5e8f6ee01 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
+++ b/Documentation/devicetree/bindings/i2c/renesas,i2c.txt
diff --git a/Documentation/devicetree/bindings/i2c/i2c-emev2.txt b/Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
index 5ed1ea1c7e14..5ed1ea1c7e14 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-emev2.txt
+++ b/Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
diff --git a/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt b/Documentation/devicetree/bindings/i2c/renesas,iic.txt
index 202602e6e837..202602e6e837 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt
+++ b/Documentation/devicetree/bindings/i2c/renesas,iic.txt
diff --git a/Documentation/devicetree/bindings/i2c/i2c-riic.txt b/Documentation/devicetree/bindings/i2c/renesas,riic.txt
index e26fe3ad86a9..e26fe3ad86a9 100644
--- a/Documentation/devicetree/bindings/i2c/i2c-riic.txt
+++ b/Documentation/devicetree/bindings/i2c/renesas,riic.txt
diff --git a/MAINTAINERS b/MAINTAINERS
index 54f1286087e9..a8d193a74692 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7865,6 +7865,12 @@ S: Maintained
7865F: drivers/mfd/lpc_ich.c 7865F: drivers/mfd/lpc_ich.c
7866F: drivers/gpio/gpio-ich.c 7866F: drivers/gpio/gpio-ich.c
7867 7867
7868ICY I2C DRIVER
7869M: Max Staudt <max@enpas.org>
7870L: linux-i2c@vger.kernel.org
7871S: Maintained
7872F: drivers/i2c/busses/i2c-icy.c
7873
7868IDE SUBSYSTEM 7874IDE SUBSYSTEM
7869M: "David S. Miller" <davem@davemloft.net> 7875M: "David S. Miller" <davem@davemloft.net>
7870L: linux-ide@vger.kernel.org 7876L: linux-ide@vger.kernel.org
@@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/
13791RENESAS EMEV2 I2C DRIVER 13797RENESAS EMEV2 I2C DRIVER
13792M: Wolfram Sang <wsa+renesas@sang-engineering.com> 13798M: Wolfram Sang <wsa+renesas@sang-engineering.com>
13793S: Supported 13799S: Supported
13794F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt 13800F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
13795F: drivers/i2c/busses/i2c-emev2.c 13801F: drivers/i2c/busses/i2c-emev2.c
13796 13802
13797RENESAS ETHERNET DRIVERS 13803RENESAS ETHERNET DRIVERS
@@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c
13813RENESAS R-CAR I2C DRIVERS 13819RENESAS R-CAR I2C DRIVERS
13814M: Wolfram Sang <wsa+renesas@sang-engineering.com> 13820M: Wolfram Sang <wsa+renesas@sang-engineering.com>
13815S: Supported 13821S: Supported
13816F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt 13822F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt
13817F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt 13823F: Documentation/devicetree/bindings/i2c/renesas,iic.txt
13818F: drivers/i2c/busses/i2c-rcar.c 13824F: drivers/i2c/busses/i2c-rcar.c
13819F: drivers/i2c/busses/i2c-sh_mobile.c 13825F: drivers/i2c/busses/i2c-sh_mobile.c
13820 13826
13821RENESAS RIIC DRIVER 13827RENESAS RIIC DRIVER
13822M: Chris Brandt <chris.brandt@renesas.com> 13828M: Chris Brandt <chris.brandt@renesas.com>
13823S: Supported 13829S: Supported
13824F: Documentation/devicetree/bindings/i2c/i2c-riic.txt 13830F: Documentation/devicetree/bindings/i2c/renesas,riic.txt
13825F: drivers/i2c/busses/i2c-riic.c 13831F: drivers/i2c/busses/i2c-riic.c
13826 13832
13827RENESAS USB PHY DRIVER 13833RENESAS USB PHY DRIVER
diff --git a/drivers/acpi/acpi_apd.c b/drivers/acpi/acpi_apd.c
index 7cd0c9ac71ea..71511ae2dfcd 100644
--- a/drivers/acpi/acpi_apd.c
+++ b/drivers/acpi/acpi_apd.c
@@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = {
160 .setup = acpi_apd_setup, 160 .setup = acpi_apd_setup,
161 .fixed_clk_rate = 250000000, 161 .fixed_clk_rate = 250000000,
162}; 162};
163
163static const struct apd_device_desc thunderx2_i2c_desc = { 164static const struct apd_device_desc thunderx2_i2c_desc = {
164 .setup = acpi_apd_setup, 165 .setup = acpi_apd_setup,
165 .fixed_clk_rate = 125000000, 166 .fixed_clk_rate = 125000000,
166}; 167};
167 168
169static const struct apd_device_desc nxp_i2c_desc = {
170 .setup = acpi_apd_setup,
171 .fixed_clk_rate = 350000000,
172};
173
168static const struct apd_device_desc hip08_spi_desc = { 174static const struct apd_device_desc hip08_spi_desc = {
169 .setup = acpi_apd_setup, 175 .setup = acpi_apd_setup,
170 .fixed_clk_rate = 250000000, 176 .fixed_clk_rate = 250000000,
@@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = {
238 { "HISI02A1", APD_ADDR(hip07_i2c_desc) }, 244 { "HISI02A1", APD_ADDR(hip07_i2c_desc) },
239 { "HISI02A2", APD_ADDR(hip08_i2c_desc) }, 245 { "HISI02A2", APD_ADDR(hip08_i2c_desc) },
240 { "HISI0173", APD_ADDR(hip08_spi_desc) }, 246 { "HISI0173", APD_ADDR(hip08_spi_desc) },
247 { "NXP0001", APD_ADDR(nxp_i2c_desc) },
241#endif 248#endif
242 { } 249 { }
243}; 250};
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 98bccace8c1c..3d61c4fb4dec 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
978{ 978{
979 int ret; 979 int ret;
980 980
981 adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec", 981 adv->i2c_cec = i2c_new_ancillary_device(adv->i2c_main, "cec",
982 ADV7511_CEC_I2C_ADDR_DEFAULT); 982 ADV7511_CEC_I2C_ADDR_DEFAULT);
983 if (!adv->i2c_cec) 983 if (IS_ERR(adv->i2c_cec))
984 return -EINVAL; 984 return PTR_ERR(adv->i2c_cec);
985 i2c_set_clientdata(adv->i2c_cec, adv); 985 i2c_set_clientdata(adv->i2c_cec, adv);
986 986
987 adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec, 987 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)
1162 1162
1163 adv7511_packet_disable(adv7511, 0xffff); 1163 adv7511_packet_disable(adv7511, 0xffff);
1164 1164
1165 adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid", 1165 adv7511->i2c_edid = i2c_new_ancillary_device(i2c, "edid",
1166 ADV7511_EDID_I2C_ADDR_DEFAULT); 1166 ADV7511_EDID_I2C_ADDR_DEFAULT);
1167 if (!adv7511->i2c_edid) { 1167 if (IS_ERR(adv7511->i2c_edid)) {
1168 ret = -EINVAL; 1168 ret = PTR_ERR(adv7511->i2c_edid);
1169 goto uninit_regulators; 1169 goto uninit_regulators;
1170 } 1170 }
1171 1171
1172 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, 1172 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR,
1173 adv7511->i2c_edid->addr << 1); 1173 adv7511->i2c_edid->addr << 1);
1174 1174
1175 adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet", 1175 adv7511->i2c_packet = i2c_new_ancillary_device(i2c, "packet",
1176 ADV7511_PACKET_I2C_ADDR_DEFAULT); 1176 ADV7511_PACKET_I2C_ADDR_DEFAULT);
1177 if (!adv7511->i2c_packet) { 1177 if (IS_ERR(adv7511->i2c_packet)) {
1178 ret = -EINVAL; 1178 ret = PTR_ERR(adv7511->i2c_packet);
1179 goto err_i2c_unregister_edid; 1179 goto err_i2c_unregister_edid;
1180 } 1180 }
1181 1181
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 5587215b8ddb..146ce40d8e0a 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -429,6 +429,7 @@ config I2C_AXXIA
429 tristate "Axxia I2C controller" 429 tristate "Axxia I2C controller"
430 depends on ARCH_AXXIA || COMPILE_TEST 430 depends on ARCH_AXXIA || COMPILE_TEST
431 default ARCH_AXXIA 431 default ARCH_AXXIA
432 select I2C_SLAVE
432 help 433 help
433 Say yes if you want to support the I2C bus on Axxia platforms. 434 Say yes if you want to support the I2C bus on Axxia platforms.
434 435
@@ -977,7 +978,7 @@ config I2C_SIRF
977 will be called i2c-sirf. 978 will be called i2c-sirf.
978 979
979config I2C_SPRD 980config I2C_SPRD
980 bool "Spreadtrum I2C interface" 981 tristate "Spreadtrum I2C interface"
981 depends on I2C=y && ARCH_SPRD 982 depends on I2C=y && ARCH_SPRD
982 help 983 help
983 If you say yes to this option, support will be included for the 984 If you say yes to this option, support will be included for the
@@ -1309,6 +1310,20 @@ config I2C_ELEKTOR
1309 This support is also available as a module. If so, the module 1310 This support is also available as a module. If so, the module
1310 will be called i2c-elektor. 1311 will be called i2c-elektor.
1311 1312
1313config 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
1312config I2C_MLXCPLD 1327config I2C_MLXCPLD
1313 tristate "Mellanox I2C driver" 1328 tristate "Mellanox I2C driver"
1314 depends on X86_64 1329 depends on X86_64
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 80c23895eaaf..3ab8aebc39c9 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o
140obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o 140obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o
141obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o 141obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o
142obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 142obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
143obj-$(CONFIG_I2C_ICY) += i2c-icy.o
143obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o 144obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o
144obj-$(CONFIG_I2C_OPAL) += i2c-opal.o 145obj-$(CONFIG_I2C_OPAL) += i2c-opal.o
145obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 146obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
index ff3142b15cab..0214daa913ff 100644
--- a/drivers/i2c/busses/i2c-axxia.c
+++ b/drivers/i2c/busses/i2c-axxia.c
@@ -77,6 +77,40 @@
77 MST_STATUS_IP) 77 MST_STATUS_IP)
78#define MST_TX_BYTES_XFRD 0x50 78#define MST_TX_BYTES_XFRD 0x50
79#define MST_RX_BYTES_XFRD 0x54 79#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
80#define SCL_HIGH_PERIOD 0x80 114#define SCL_HIGH_PERIOD 0x80
81#define SCL_LOW_PERIOD 0x84 115#define SCL_LOW_PERIOD 0x84
82#define SPIKE_FLTR_LEN 0x88 116#define SPIKE_FLTR_LEN 0x88
@@ -111,6 +145,8 @@ struct axxia_i2c_dev {
111 struct clk *i2c_clk; 145 struct clk *i2c_clk;
112 u32 bus_clk_rate; 146 u32 bus_clk_rate;
113 bool last; 147 bool last;
148 struct i2c_client *slave;
149 int irq;
114}; 150};
115 151
116static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask) 152static 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)
276 return ret; 312 return ret;
277} 313}
278 314
315static 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
338static 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
279static irqreturn_t axxia_i2c_isr(int irq, void *_dev) 362static irqreturn_t axxia_i2c_isr(int irq, void *_dev)
280{ 363{
281 struct axxia_i2c_dev *idev = _dev; 364 struct axxia_i2c_dev *idev = _dev;
365 irqreturn_t ret = IRQ_NONE;
282 u32 status; 366 u32 status;
283 367
284 if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST)) 368 status = readl(idev->base + INTERRUPT_STATUS);
285 return IRQ_NONE; 369
370 if (status & INT_SLV)
371 ret = axxia_i2c_slv_isr(idev);
372 if (!(status & INT_MST))
373 return ret;
286 374
287 /* Read interrupt status bits */ 375 /* Read interrupt status bits */
288 status = readl(idev->base + MST_INT_STATUS); 376 status = readl(idev->base + MST_INT_STATUS);
@@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap)
583 return caps; 671 return caps;
584} 672}
585 673
674static 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
706static 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
586static const struct i2c_algorithm axxia_i2c_algo = { 721static const struct i2c_algorithm axxia_i2c_algo = {
587 .master_xfer = axxia_i2c_xfer, 722 .master_xfer = axxia_i2c_xfer,
588 .functionality = axxia_i2c_func, 723 .functionality = axxia_i2c_func,
724 .reg_slave = axxia_i2c_reg_slave,
725 .unreg_slave = axxia_i2c_unreg_slave,
589}; 726};
590 727
591static const struct i2c_adapter_quirks axxia_i2c_quirks = { 728static const struct i2c_adapter_quirks axxia_i2c_quirks = {
@@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev)
599 struct axxia_i2c_dev *idev = NULL; 736 struct axxia_i2c_dev *idev = NULL;
600 struct resource *res; 737 struct resource *res;
601 void __iomem *base; 738 void __iomem *base;
602 int irq;
603 int ret = 0; 739 int ret = 0;
604 740
605 idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL); 741 idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
@@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
611 if (IS_ERR(base)) 747 if (IS_ERR(base))
612 return PTR_ERR(base); 748 return PTR_ERR(base);
613 749
614 irq = platform_get_irq(pdev, 0); 750 idev->irq = platform_get_irq(pdev, 0);
615 if (irq < 0) { 751 if (idev->irq < 0) {
616 dev_err(&pdev->dev, "missing interrupt resource\n"); 752 dev_err(&pdev->dev, "missing interrupt resource\n");
617 return irq; 753 return idev->irq;
618 } 754 }
619 755
620 idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c"); 756 idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c");
@@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev)
643 goto error_disable_clk; 779 goto error_disable_clk;
644 } 780 }
645 781
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,
647 pdev->name, idev); 783 pdev->name, idev);
648 if (ret) { 784 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);
650 goto error_disable_clk; 786 goto error_disable_clk;
651 } 787 }
652 788
diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
index 19ef2b0c682a..9ffdffaf6141 100644
--- a/drivers/i2c/busses/i2c-bcm-iproc.c
+++ b/drivers/i2c/busses/i2c-bcm-iproc.c
@@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = {
808 .unreg_slave = bcm_iproc_i2c_unreg_slave, 808 .unreg_slave = bcm_iproc_i2c_unreg_slave,
809}; 809};
810 810
811static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = { 811static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = {
812 .max_read_len = M_RX_MAX_READ_LEN, 812 .max_read_len = M_RX_MAX_READ_LEN,
813}; 813};
814 814
@@ -922,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev)
922 922
923 adap = &iproc_i2c->adapter; 923 adap = &iproc_i2c->adapter;
924 i2c_set_adapdata(adap, iproc_i2c); 924 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));
926 adap->algo = &bcm_iproc_algo; 928 adap->algo = &bcm_iproc_algo;
927 adap->quirks = &bcm_iproc_i2c_quirks; 929 adap->quirks = &bcm_iproc_i2c_quirks;
928 adap->dev.parent = &pdev->dev; 930 adap->dev.parent = &pdev->dev;
diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
index 67752f7b0371..e01b2b57e724 100644
--- a/drivers/i2c/busses/i2c-bcm2835.c
+++ b/drivers/i2c/busses/i2c-bcm2835.c
@@ -12,6 +12,7 @@
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/of_device.h>
15#include <linux/platform_device.h> 16#include <linux/platform_device.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17 18
@@ -389,7 +390,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = {
389}; 390};
390 391
391/* 392/*
392 * This HW was reported to have problems with clock stretching: 393 * The BCM2835 was reported to have problems with clock stretching:
393 * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html 394 * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html
394 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272 395 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272
395 */ 396 */
@@ -471,11 +472,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
471 i2c_set_adapdata(adap, i2c_dev); 472 i2c_set_adapdata(adap, i2c_dev);
472 adap->owner = THIS_MODULE; 473 adap->owner = THIS_MODULE;
473 adap->class = I2C_CLASS_DEPRECATED; 474 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));
475 adap->algo = &bcm2835_i2c_algo; 477 adap->algo = &bcm2835_i2c_algo;
476 adap->dev.parent = &pdev->dev; 478 adap->dev.parent = &pdev->dev;
477 adap->dev.of_node = pdev->dev.of_node; 479 adap->dev.of_node = pdev->dev.of_node;
478 adap->quirks = &bcm2835_i2c_quirks; 480 adap->quirks = of_device_get_match_data(&pdev->dev);
479 481
480 bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); 482 bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
481 483
@@ -501,7 +503,8 @@ static int bcm2835_i2c_remove(struct platform_device *pdev)
501} 503}
502 504
503static const struct of_device_id bcm2835_i2c_of_match[] = { 505static 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 },
505 {}, 508 {},
506}; 509};
507MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match); 510MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
diff --git a/drivers/i2c/busses/i2c-cht-wc.c b/drivers/i2c/busses/i2c-cht-wc.c
index 66af44bfa67d..b8fde61bb5d8 100644
--- a/drivers/i2c/busses/i2c-cht-wc.c
+++ b/drivers/i2c/busses/i2c-cht-wc.c
@@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = {
178 .smbus_xfer = cht_wc_i2c_adap_smbus_xfer, 178 .smbus_xfer = cht_wc_i2c_adap_smbus_xfer,
179}; 179};
180 180
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 */
202static 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
208static 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
214static 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
220static 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
181/**** irqchip for the client connected to the extchgr i2c adapter ****/ 226/**** irqchip for the client connected to the extchgr i2c adapter ****/
182static void cht_wc_i2c_irq_lock(struct irq_data *data) 227static void cht_wc_i2c_irq_lock(struct irq_data *data)
183{ 228{
@@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev)
286 adap->adapter.owner = THIS_MODULE; 331 adap->adapter.owner = THIS_MODULE;
287 adap->adapter.class = I2C_CLASS_HWMON; 332 adap->adapter.class = I2C_CLASS_HWMON;
288 adap->adapter.algo = &cht_wc_i2c_adap_algo; 333 adap->adapter.algo = &cht_wc_i2c_adap_algo;
334 adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops;
289 strlcpy(adap->adapter.name, "PMIC I2C Adapter", 335 strlcpy(adap->adapter.name, "PMIC I2C Adapter",
290 sizeof(adap->adapter.name)); 336 sizeof(adap->adapter.name));
291 adap->adapter.dev.parent = &pdev->dev; 337 adap->adapter.dev.parent = &pdev->dev;
@@ -363,8 +409,7 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev)
363{ 409{
364 struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); 410 struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev);
365 411
366 if (adap->client) 412 i2c_unregister_device(adap->client);
367 i2c_unregister_device(adap->client);
368 i2c_del_adapter(&adap->adapter); 413 i2c_del_adapter(&adap->adapter);
369 irq_domain_remove(adap->irq_domain); 414 irq_domain_remove(adap->irq_domain);
370 415
diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index d464799e40a3..e8b328242256 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -655,15 +655,11 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
655 struct i2c_bus_recovery_info *rinfo = &dev->rinfo; 655 struct i2c_bus_recovery_info *rinfo = &dev->rinfo;
656 struct i2c_adapter *adap = &dev->adapter; 656 struct i2c_adapter *adap = &dev->adapter;
657 struct gpio_desc *gpio; 657 struct gpio_desc *gpio;
658 int r; 658
659 659 gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH);
660 gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); 660 if (IS_ERR_OR_NULL(gpio))
661 if (IS_ERR(gpio)) { 661 return PTR_ERR_OR_ZERO(gpio);
662 r = PTR_ERR(gpio); 662
663 if (r == -ENOENT || r == -ENOSYS)
664 return 0;
665 return r;
666 }
667 rinfo->scl_gpiod = gpio; 663 rinfo->scl_gpiod = gpio;
668 664
669 gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN); 665 gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN);
diff --git a/drivers/i2c/busses/i2c-designware-pcidrv.c b/drivers/i2c/busses/i2c-designware-pcidrv.c
index 76810deb2de6..050adda7c1bd 100644
--- a/drivers/i2c/busses/i2c-designware-pcidrv.c
+++ b/drivers/i2c/busses/i2c-designware-pcidrv.c
@@ -33,6 +33,7 @@ enum dw_pci_ctl_id_t {
33 baytrail, 33 baytrail,
34 cherrytrail, 34 cherrytrail,
35 haswell, 35 haswell,
36 elkhartlake,
36}; 37};
37 38
38struct dw_scl_sda_cfg { 39struct dw_scl_sda_cfg {
@@ -168,13 +169,20 @@ static struct dw_pci_controller dw_pci_controllers[] = {
168 .flags = MODEL_CHERRYTRAIL, 169 .flags = MODEL_CHERRYTRAIL,
169 .scl_sda_cfg = &byt_config, 170 .scl_sda_cfg = &byt_config,
170 }, 171 },
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 },
171}; 180};
172 181
173#ifdef CONFIG_PM 182#ifdef CONFIG_PM
174static int i2c_dw_pci_suspend(struct device *dev) 183static int i2c_dw_pci_suspend(struct device *dev)
175{ 184{
176 struct pci_dev *pdev = to_pci_dev(dev); 185 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
177 struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
178 186
179 i_dev->suspended = true; 187 i_dev->suspended = true;
180 i_dev->disable(i_dev); 188 i_dev->disable(i_dev);
@@ -184,8 +192,7 @@ static int i2c_dw_pci_suspend(struct device *dev)
184 192
185static int i2c_dw_pci_resume(struct device *dev) 193static int i2c_dw_pci_resume(struct device *dev)
186{ 194{
187 struct pci_dev *pdev = to_pci_dev(dev); 195 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev);
188 struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev);
189 int ret; 196 int ret;
190 197
191 ret = i_dev->init(i_dev); 198 ret = i_dev->init(i_dev);
@@ -227,6 +234,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
227 return r; 234 return r;
228 } 235 }
229 236
237 pci_set_master(pdev);
238
230 r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); 239 r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
231 if (r) { 240 if (r) {
232 dev_err(&pdev->dev, "I/O memory remapping failed\n"); 241 dev_err(&pdev->dev, "I/O memory remapping failed\n");
@@ -237,18 +246,24 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
237 if (!dev) 246 if (!dev)
238 return -ENOMEM; 247 return -ENOMEM;
239 248
249 r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES);
250 if (r < 0)
251 return r;
252
240 dev->clk = NULL; 253 dev->clk = NULL;
241 dev->controller = controller; 254 dev->controller = controller;
242 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; 255 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
243 dev->base = pcim_iomap_table(pdev)[0]; 256 dev->base = pcim_iomap_table(pdev)[0];
244 dev->dev = &pdev->dev; 257 dev->dev = &pdev->dev;
245 dev->irq = pdev->irq; 258 dev->irq = pci_irq_vector(pdev, 0);
246 dev->flags |= controller->flags; 259 dev->flags |= controller->flags;
247 260
248 if (controller->setup) { 261 if (controller->setup) {
249 r = controller->setup(pdev, controller); 262 r = controller->setup(pdev, controller);
250 if (r) 263 if (r) {
264 pci_free_irq_vectors(pdev);
251 return r; 265 return r;
266 }
252 } 267 }
253 268
254 dev->functionality = controller->functionality | 269 dev->functionality = controller->functionality |
@@ -276,8 +291,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
276 adap->nr = controller->bus_num; 291 adap->nr = controller->bus_num;
277 292
278 r = i2c_dw_probe(dev); 293 r = i2c_dw_probe(dev);
279 if (r) 294 if (r) {
295 pci_free_irq_vectors(pdev);
280 return r; 296 return r;
297 }
281 298
282 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); 299 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
283 pm_runtime_use_autosuspend(&pdev->dev); 300 pm_runtime_use_autosuspend(&pdev->dev);
@@ -296,6 +313,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev)
296 pm_runtime_get_noresume(&pdev->dev); 313 pm_runtime_get_noresume(&pdev->dev);
297 314
298 i2c_del_adapter(&dev->adapter); 315 i2c_del_adapter(&dev->adapter);
316 pci_free_irq_vectors(pdev);
299} 317}
300 318
301/* work with hotplug and coldplug */ 319/* work with hotplug and coldplug */
@@ -331,6 +349,15 @@ static const struct pci_device_id i2_designware_pci_ids[] = {
331 { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail }, 349 { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail },
332 { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail }, 350 { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail },
333 { PCI_VDEVICE(INTEL, 0x22C7), cherrytrail }, 351 { 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 },
334 { 0,} 361 { 0,}
335}; 362};
336MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids); 363MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index ddfb81872906..16dd338877d0 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -279,12 +279,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
279 platform_set_drvdata(pdev, dev); 279 platform_set_drvdata(pdev, dev);
280 280
281 dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); 281 dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
282 if (IS_ERR(dev->rst)) { 282 if (IS_ERR(dev->rst))
283 if (PTR_ERR(dev->rst) == -EPROBE_DEFER) 283 return PTR_ERR(dev->rst);
284 return -EPROBE_DEFER; 284
285 } else { 285 reset_control_deassert(dev->rst);
286 reset_control_deassert(dev->rst);
287 }
288 286
289 t = &dev->timings; 287 t = &dev->timings;
290 if (pdata) 288 if (pdata)
@@ -346,8 +344,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
346 344
347 /* Optional interface clock */ 345 /* Optional interface clock */
348 dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); 346 dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
349 if (IS_ERR(dev->pclk)) 347 if (IS_ERR(dev->pclk)) {
350 return PTR_ERR(dev->pclk); 348 ret = PTR_ERR(dev->pclk);
349 goto exit_reset;
350 }
351 351
352 dev->clk = devm_clk_get(&pdev->dev, NULL); 352 dev->clk = devm_clk_get(&pdev->dev, NULL);
353 if (!i2c_dw_prepare_clk(dev, true)) { 353 if (!i2c_dw_prepare_clk(dev, true)) {
@@ -400,8 +400,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
400exit_probe: 400exit_probe:
401 dw_i2c_plat_pm_cleanup(dev); 401 dw_i2c_plat_pm_cleanup(dev);
402exit_reset: 402exit_reset:
403 if (!IS_ERR_OR_NULL(dev->rst)) 403 reset_control_assert(dev->rst);
404 reset_control_assert(dev->rst);
405 return ret; 404 return ret;
406} 405}
407 406
@@ -419,8 +418,7 @@ static int dw_i2c_plat_remove(struct platform_device *pdev)
419 pm_runtime_put_sync(&pdev->dev); 418 pm_runtime_put_sync(&pdev->dev);
420 dw_i2c_plat_pm_cleanup(dev); 419 dw_i2c_plat_pm_cleanup(dev);
421 420
422 if (!IS_ERR_OR_NULL(dev->rst)) 421 reset_control_assert(dev->rst);
423 reset_control_assert(dev->rst);
424 422
425 return 0; 423 return 0;
426} 424}
diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index e4e7932f7800..e7514c16b756 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -791,9 +791,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
791 } 791 }
792 792
793 ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq, 793 ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq,
794 IRQF_NO_SUSPEND | IRQF_ONESHOT, 794 IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c);
795 dev_name(&pdev->dev), i2c);
796
797 if (ret != 0) { 795 if (ret != 0) {
798 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq); 796 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq);
799 goto err_clk; 797 goto err_clk;
diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index da5eb3960def..e0c256922d4f 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -707,8 +707,10 @@ static int fsi_i2c_probe(struct device *dev)
707 continue; 707 continue;
708 708
709 port = kzalloc(sizeof(*port), GFP_KERNEL); 709 port = kzalloc(sizeof(*port), GFP_KERNEL);
710 if (!port) 710 if (!port) {
711 of_node_put(np);
711 break; 712 break;
713 }
712 714
713 port->master = i2c; 715 port->master = i2c;
714 port->port = port_no; 716 port->port = port_no;
diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
index 4df1434b3597..8497c7a95dd4 100644
--- a/drivers/i2c/busses/i2c-hix5hd2.c
+++ b/drivers/i2c/busses/i2c-hix5hd2.c
@@ -445,8 +445,7 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
445 hix5hd2_i2c_init(priv); 445 hix5hd2_i2c_init(priv);
446 446
447 ret = devm_request_irq(&pdev->dev, irq, hix5hd2_i2c_irq, 447 ret = devm_request_irq(&pdev->dev, irq, hix5hd2_i2c_irq,
448 IRQF_NO_SUSPEND | IRQF_ONESHOT, 448 IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv);
449 dev_name(&pdev->dev), priv);
450 if (ret != 0) { 449 if (ret != 0) {
451 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq); 450 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq);
452 goto err_clk; 451 goto err_clk;
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 36e9559f880c..c09791fb4929 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -292,7 +292,8 @@ struct i801_priv {
292#define FEATURE_HOST_NOTIFY BIT(5) 292#define FEATURE_HOST_NOTIFY BIT(5)
293/* Not really a feature, but it's convenient to handle it as such */ 293/* Not really a feature, but it's convenient to handle it as such */
294#define FEATURE_IDF BIT(15) 294#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)
296 297
297static const char *i801_feature_names[] = { 298static const char *i801_feature_names[] = {
298 "SMBus PEC", 299 "SMBus PEC",
@@ -1500,57 +1501,23 @@ static inline unsigned int i801_get_adapter_class(struct i801_priv *priv)
1500} 1501}
1501#endif 1502#endif
1502 1503
1503static const struct itco_wdt_platform_data tco_platform_data = { 1504static const struct itco_wdt_platform_data spt_tco_platform_data = {
1504 .name = "Intel PCH", 1505 .name = "Intel PCH",
1505 .version = 4, 1506 .version = 4,
1506}; 1507};
1507 1508
1508static DEFINE_SPINLOCK(p2sb_spinlock); 1509static DEFINE_SPINLOCK(p2sb_spinlock);
1509 1510
1510static void i801_add_tco(struct i801_priv *priv) 1511static struct platform_device *
1512i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
1513 struct resource *tco_res)
1511{ 1514{
1512 struct pci_dev *pci_dev = priv->pci_dev; 1515 struct resource *res;
1513 struct resource tco_res[3], *res;
1514 struct platform_device *pdev;
1515 unsigned int devfn; 1516 unsigned int devfn;
1516 u32 tco_base, tco_ctl;
1517 u32 base_addr, ctrl_val;
1518 u64 base64_addr; 1517 u64 base64_addr;
1518 u32 base_addr;
1519 u8 hidden; 1519 u8 hidden;
1520 1520
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
1554 /* 1521 /*
1555 * We must access the NO_REBOOT bit over the Primary to Sideband 1522 * We must access the NO_REBOOT bit over the Primary to Sideband
1556 * bridge (P2SB). The BIOS prevents the P2SB device from being 1523 * bridge (P2SB). The BIOS prevents the P2SB device from being
@@ -1586,15 +1553,76 @@ static void i801_add_tco(struct i801_priv *priv)
1586 res->end = res->start + 3; 1553 res->end = res->start + 3;
1587 res->flags = IORESOURCE_MEM; 1554 res->flags = IORESOURCE_MEM;
1588 1555
1589 pdev = platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1556 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
1590 tco_res, 3, &tco_platform_data, 1557 tco_res, 3, &spt_tco_platform_data,
1591 sizeof(tco_platform_data)); 1558 sizeof(spt_tco_platform_data));
1592 if (IS_ERR(pdev)) { 1559}
1593 dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); 1560
1561static const struct itco_wdt_platform_data cnl_tco_platform_data = {
1562 .name = "Intel PCH",
1563 .version = 6,
1564};
1565
1566static struct platform_device *
1567i801_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
1575static 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())
1594 return; 1584 return;
1595 }
1596 1585
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");
1598} 1626}
1599 1627
1600#ifdef CONFIG_ACPI 1628#ifdef CONFIG_ACPI
@@ -1704,13 +1732,21 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
1704 switch (dev->device) { 1732 switch (dev->device) {
1705 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS: 1733 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS:
1706 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS: 1734 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:
1709 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS: 1735 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS:
1710 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS: 1736 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS:
1711 case PCI_DEVICE_ID_INTEL_CDF_SMBUS:
1712 case PCI_DEVICE_ID_INTEL_DNV_SMBUS: 1737 case PCI_DEVICE_ID_INTEL_DNV_SMBUS:
1713 case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: 1738 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:
1714 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: 1750 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS:
1715 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: 1751 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS:
1716 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: 1752 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)
1720 priv->features |= FEATURE_IRQ; 1756 priv->features |= FEATURE_IRQ;
1721 priv->features |= FEATURE_SMBUS_PEC; 1757 priv->features |= FEATURE_SMBUS_PEC;
1722 priv->features |= FEATURE_BLOCK_BUFFER; 1758 priv->features |= FEATURE_BLOCK_BUFFER;
1723 /* If we have ACPI based watchdog use that instead */ 1759 priv->features |= FEATURE_TCO_CNL;
1724 if (!acpi_has_watchdog())
1725 priv->features |= FEATURE_TCO;
1726 priv->features |= FEATURE_HOST_NOTIFY; 1760 priv->features |= FEATURE_HOST_NOTIFY;
1727 break; 1761 break;
1728 1762
@@ -1921,8 +1955,7 @@ static int i801_suspend(struct device *dev)
1921 1955
1922static int i801_resume(struct device *dev) 1956static int i801_resume(struct device *dev)
1923{ 1957{
1924 struct pci_dev *pci_dev = to_pci_dev(dev); 1958 struct i801_priv *priv = dev_get_drvdata(dev);
1925 struct i801_priv *priv = pci_get_drvdata(pci_dev);
1926 1959
1927 i801_enable_host_notify(&priv->adapter); 1960 i801_enable_host_notify(&priv->adapter);
1928 1961
diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c
new file mode 100644
index 000000000000..8382eb64b424
--- /dev/null
+++ b/drivers/i2c/busses/i2c-icy.c
@@ -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
51struct 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 */
63static 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
72static 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
81static int icy_pcf_getown(void *data)
82{
83 return 0x55;
84}
85
86static int icy_pcf_getclock(void *data)
87{
88 return 0x1c;
89}
90
91static void icy_pcf_waitforpin(void *data)
92{
93 usleep_range(50, 150);
94}
95
96/*
97 * Main i2c-icy part
98 */
99static 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 */
110static const u32 icy_ltc2990_meas_mode[] = {0, 3};
111
112static const struct property_entry icy_ltc2990_props[] = {
113 PROPERTY_ENTRY_U32_ARRAY("lltc,meas-mode", icy_ltc2990_meas_mode),
114 { }
115};
116
117static 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
200static 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
210static const struct zorro_device_id icy_zorro_tbl[] = {
211 { ZORRO_ID(VMC, 15, 0), },
212 { 0 }
213};
214
215MODULE_DEVICE_TABLE(zorro, icy_zorro_tbl);
216
217static 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
224module_driver(icy_driver,
225 zorro_register_driver,
226 zorro_unregister_driver);
227
228MODULE_AUTHOR("Max Staudt <max@enpas.org>");
229MODULE_DESCRIPTION("I2C bus via PCF8584 on ICY Zorro card");
230MODULE_LICENSE("GPL v2");
diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index dc00fabc919a..c92b56485fa6 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -545,7 +545,6 @@ MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match);
545static int lpi2c_imx_probe(struct platform_device *pdev) 545static int lpi2c_imx_probe(struct platform_device *pdev)
546{ 546{
547 struct lpi2c_imx_struct *lpi2c_imx; 547 struct lpi2c_imx_struct *lpi2c_imx;
548 struct resource *res;
549 unsigned int temp; 548 unsigned int temp;
550 int irq, ret; 549 int irq, ret;
551 550
@@ -553,8 +552,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
553 if (!lpi2c_imx) 552 if (!lpi2c_imx)
554 return -ENOMEM; 553 return -ENOMEM;
555 554
556 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 555 lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0);
557 lpi2c_imx->base = devm_ioremap_resource(&pdev->dev, res);
558 if (IS_ERR(lpi2c_imx->base)) 556 if (IS_ERR(lpi2c_imx->base))
559 return PTR_ERR(lpi2c_imx->base); 557 return PTR_ERR(lpi2c_imx->base);
560 558
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 15f6cde6452f..a3b61336fe55 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -20,6 +20,7 @@
20 * 20 *
21 */ 21 */
22 22
23#include <linux/acpi.h>
23#include <linux/clk.h> 24#include <linux/clk.h>
24#include <linux/completion.h> 25#include <linux/completion.h>
25#include <linux/delay.h> 26#include <linux/delay.h>
@@ -255,6 +256,12 @@ static const struct of_device_id i2c_imx_dt_ids[] = {
255}; 256};
256MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids); 257MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids);
257 258
259static const struct acpi_device_id i2c_imx_acpi_ids[] = {
260 {"NXP0001", .driver_data = (kernel_ulong_t)&vf610_i2c_hwdata},
261 { }
262};
263MODULE_DEVICE_TABLE(acpi, i2c_imx_acpi_ids);
264
258static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx) 265static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx)
259{ 266{
260 return i2c_imx->hwdata->devtype == IMX1_I2C; 267 return i2c_imx->hwdata->devtype == IMX1_I2C;
@@ -1048,14 +1055,13 @@ static const struct i2c_algorithm i2c_imx_algo = {
1048 1055
1049static int i2c_imx_probe(struct platform_device *pdev) 1056static int i2c_imx_probe(struct platform_device *pdev)
1050{ 1057{
1051 const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids,
1052 &pdev->dev);
1053 struct imx_i2c_struct *i2c_imx; 1058 struct imx_i2c_struct *i2c_imx;
1054 struct resource *res; 1059 struct resource *res;
1055 struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev); 1060 struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
1056 void __iomem *base; 1061 void __iomem *base;
1057 int irq, ret; 1062 int irq, ret;
1058 dma_addr_t phy_addr; 1063 dma_addr_t phy_addr;
1064 const struct imx_i2c_hwdata *match;
1059 1065
1060 dev_dbg(&pdev->dev, "<%s>\n", __func__); 1066 dev_dbg(&pdev->dev, "<%s>\n", __func__);
1061 1067
@@ -1075,8 +1081,9 @@ static int i2c_imx_probe(struct platform_device *pdev)
1075 if (!i2c_imx) 1081 if (!i2c_imx)
1076 return -ENOMEM; 1082 return -ENOMEM;
1077 1083
1078 if (of_id) 1084 match = device_get_match_data(&pdev->dev);
1079 i2c_imx->hwdata = of_id->data; 1085 if (match)
1086 i2c_imx->hwdata = match;
1080 else 1087 else
1081 i2c_imx->hwdata = (struct imx_i2c_hwdata *) 1088 i2c_imx->hwdata = (struct imx_i2c_hwdata *)
1082 platform_get_device_id(pdev)->driver_data; 1089 platform_get_device_id(pdev)->driver_data;
@@ -1089,6 +1096,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
1089 i2c_imx->adapter.nr = pdev->id; 1096 i2c_imx->adapter.nr = pdev->id;
1090 i2c_imx->adapter.dev.of_node = pdev->dev.of_node; 1097 i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
1091 i2c_imx->base = base; 1098 i2c_imx->base = base;
1099 ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev));
1092 1100
1093 /* Get I2C clock */ 1101 /* Get I2C clock */
1094 i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); 1102 i2c_imx->clk = devm_clk_get(&pdev->dev, NULL);
@@ -1247,6 +1255,7 @@ static struct platform_driver i2c_imx_driver = {
1247 .name = DRIVER_NAME, 1255 .name = DRIVER_NAME,
1248 .pm = &i2c_imx_pm_ops, 1256 .pm = &i2c_imx_pm_ops,
1249 .of_match_table = i2c_imx_dt_ids, 1257 .of_match_table = i2c_imx_dt_ids,
1258 .acpi_match_table = i2c_imx_acpi_ids,
1250 }, 1259 },
1251 .id_table = imx_i2c_devtype, 1260 .id_table = imx_i2c_devtype,
1252}; 1261};
diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c-ismt.c
index 02d23edb2fb1..2f95e25a10f7 100644
--- a/drivers/i2c/busses/i2c-ismt.c
+++ b/drivers/i2c/busses/i2c-ismt.c
@@ -781,8 +781,6 @@ static int ismt_dev_init(struct ismt_priv *priv)
781 if (!priv->hw) 781 if (!priv->hw)
782 return -ENOMEM; 782 return -ENOMEM;
783 783
784 memset(priv->hw, 0, (ISMT_DESC_ENTRIES * sizeof(struct ismt_desc)));
785
786 priv->head = 0; 784 priv->head = 0;
787 init_completion(&priv->cmp); 785 init_completion(&priv->cmp);
788 786
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 7d79317a1046..89224913f578 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -802,7 +802,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
802 struct device *dev = &pdev->dev; 802 struct device *dev = &pdev->dev;
803 struct mxs_i2c_dev *i2c; 803 struct mxs_i2c_dev *i2c;
804 struct i2c_adapter *adap; 804 struct i2c_adapter *adap;
805 struct resource *res;
806 int err, irq; 805 int err, irq;
807 806
808 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); 807 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
@@ -814,8 +813,7 @@ static int mxs_i2c_probe(struct platform_device *pdev)
814 i2c->dev_type = device_id->driver_data; 813 i2c->dev_type = device_id->driver_data;
815 } 814 }
816 815
817 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 816 i2c->regs = devm_platform_ioremap_resource(pdev, 0);
818 i2c->regs = devm_ioremap_resource(&pdev->dev, res);
819 if (IS_ERR(i2c->regs)) 817 if (IS_ERR(i2c->regs))
820 return PTR_ERR(i2c->regs); 818 return PTR_ERR(i2c->regs);
821 819
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 4117f1abc7c6..ca8b3ecfa93d 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -703,8 +703,9 @@ static int ocores_i2c_probe(struct platform_device *pdev)
703 } 703 }
704 704
705 if (ocores_algorithm.master_xfer != ocores_xfer_polling) { 705 if (ocores_algorithm.master_xfer != ocores_xfer_polling) {
706 ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, 706 ret = devm_request_any_context_irq(&pdev->dev, irq,
707 pdev->name, i2c); 707 ocores_isr, 0,
708 pdev->name, i2c);
708 if (ret) { 709 if (ret) {
709 dev_err(&pdev->dev, "Cannot claim IRQ\n"); 710 dev_err(&pdev->dev, "Cannot claim IRQ\n");
710 goto err_clk; 711 goto err_clk;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index cba325eb852f..30ded6422e7b 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -72,7 +72,8 @@
72#define PIIX4_BLOCK_DATA 0x14 72#define PIIX4_BLOCK_DATA 0x14
73 73
74/* Multi-port constants */ 74/* 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 */
76 77
77/* SB800 constants */ 78/* SB800 constants */
78#define SB800_PIIX4_SMB_IDX 0xcd6 79#define SB800_PIIX4_SMB_IDX 0xcd6
@@ -806,10 +807,12 @@ MODULE_DEVICE_TABLE (pci, piix4_ids);
806 807
807static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS]; 808static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS];
808static struct i2c_adapter *piix4_aux_adapter; 809static struct i2c_adapter *piix4_aux_adapter;
810static int piix4_adapter_count;
809 811
810static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, 812static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
811 bool sb800_main, u8 port, bool notify_imc, 813 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)
813{ 816{
814 struct i2c_adapter *adap; 817 struct i2c_adapter *adap;
815 struct i2c_piix4_adapdata *adapdata; 818 struct i2c_piix4_adapdata *adapdata;
@@ -841,6 +844,12 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
841 /* set up the sysfs linkage to our parent device */ 844 /* set up the sysfs linkage to our parent device */
842 adap->dev.parent = &dev->dev; 845 adap->dev.parent = &dev->dev;
843 846
847 if (has_acpi_companion(&dev->dev)) {
848 acpi_preset_companion(&adap->dev,
849 ACPI_COMPANION(&dev->dev),
850 hw_port_nr);
851 }
852
844 snprintf(adap->name, sizeof(adap->name), 853 snprintf(adap->name, sizeof(adap->name),
845 "SMBus PIIX4 adapter%s at %04x", name, smba); 854 "SMBus PIIX4 adapter%s at %04x", name, smba);
846 855
@@ -865,8 +874,19 @@ static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba,
865 int port; 874 int port;
866 int retval; 875 int retval;
867 876
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
869 retval = piix4_add_adapter(dev, smba, true, port, notify_imc, 888 retval = piix4_add_adapter(dev, smba, true, port, notify_imc,
889 hw_port_nr,
870 piix4_main_port_names_sb800[port], 890 piix4_main_port_names_sb800[port],
871 &piix4_main_adapters[port]); 891 &piix4_main_adapters[port]);
872 if (retval < 0) 892 if (retval < 0)
@@ -937,8 +957,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
937 return retval; 957 return retval;
938 958
939 /* Try to register main SMBus adapter, give up if we can't */ 959 /* Try to register main SMBus adapter, give up if we can't */
940 retval = piix4_add_adapter(dev, retval, false, 0, false, "", 960 retval = piix4_add_adapter(dev, retval, false, 0, false, 0,
941 &piix4_main_adapters[0]); 961 "", &piix4_main_adapters[0]);
942 if (retval < 0) 962 if (retval < 0)
943 return retval; 963 return retval;
944 } 964 }
@@ -964,7 +984,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
964 if (retval > 0) { 984 if (retval > 0) {
965 /* Try to add the aux adapter if it exists, 985 /* Try to add the aux adapter if it exists,
966 * piix4_add_adapter will clean up if this fails */ 986 * 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,
968 is_sb800 ? piix4_aux_port_name_sb800 : "", 988 is_sb800 ? piix4_aux_port_name_sb800 : "",
969 &piix4_aux_adapter); 989 &piix4_aux_adapter);
970 } 990 }
@@ -987,7 +1007,7 @@ static void piix4_adap_remove(struct i2c_adapter *adap)
987 1007
988static void piix4_remove(struct pci_dev *dev) 1008static void piix4_remove(struct pci_dev *dev)
989{ 1009{
990 int port = PIIX4_MAX_ADAPTERS; 1010 int port = piix4_adapter_count;
991 1011
992 while (--port >= 0) { 1012 while (--port >= 0) {
993 if (piix4_main_adapters[port]) { 1013 if (piix4_main_adapters[port]) {
diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 961123529678..b432e7580458 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/interrupt.h> 13#include <linux/interrupt.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h>
15#include <linux/of.h> 16#include <linux/of.h>
16#include <linux/of_device.h> 17#include <linux/of_device.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
@@ -465,9 +466,9 @@ static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev)
465 466
466 i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable"); 467 i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable");
467 if (IS_ERR(i2c_dev->clk)) { 468 if (IS_ERR(i2c_dev->clk)) {
468 dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n", 469 dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n",
469 i2c_dev->adap.nr); 470 i2c_dev->adap.nr);
470 i2c_dev->clk = NULL; 471 return PTR_ERR(i2c_dev->clk);
471 } 472 }
472 473
473 return 0; 474 return 0;
@@ -477,7 +478,6 @@ static int sprd_i2c_probe(struct platform_device *pdev)
477{ 478{
478 struct device *dev = &pdev->dev; 479 struct device *dev = &pdev->dev;
479 struct sprd_i2c *i2c_dev; 480 struct sprd_i2c *i2c_dev;
480 struct resource *res;
481 u32 prop; 481 u32 prop;
482 int ret; 482 int ret;
483 483
@@ -487,8 +487,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)
487 if (!i2c_dev) 487 if (!i2c_dev)
488 return -ENOMEM; 488 return -ENOMEM;
489 489
490 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 490 i2c_dev->base = devm_platform_ioremap_resource(pdev, 0);
491 i2c_dev->base = devm_ioremap_resource(dev, res);
492 if (IS_ERR(i2c_dev->base)) 491 if (IS_ERR(i2c_dev->base))
493 return PTR_ERR(i2c_dev->base); 492 return PTR_ERR(i2c_dev->base);
494 493
@@ -520,7 +519,10 @@ static int sprd_i2c_probe(struct platform_device *pdev)
520 if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000) 519 if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
521 return -EINVAL; 520 return -EINVAL;
522 521
523 sprd_i2c_clk_init(i2c_dev); 522 ret = sprd_i2c_clk_init(i2c_dev);
523 if (ret)
524 return ret;
525
524 platform_set_drvdata(pdev, i2c_dev); 526 platform_set_drvdata(pdev, i2c_dev);
525 527
526 ret = clk_prepare_enable(i2c_dev->clk); 528 ret = clk_prepare_enable(i2c_dev->clk);
@@ -644,8 +646,7 @@ static struct platform_driver sprd_i2c_driver = {
644 }, 646 },
645}; 647};
646 648
647static int sprd_i2c_init(void) 649module_platform_driver(sprd_i2c_driver);
648{ 650
649 return platform_driver_register(&sprd_i2c_driver); 651MODULE_DESCRIPTION("Spreadtrum I2C master controller driver");
650} 652MODULE_LICENSE("GPL v2");
651arch_initcall_sync(sprd_i2c_init);
diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c
index 266d1c269b83..d36cf08461f7 100644
--- a/drivers/i2c/busses/i2c-stm32f7.c
+++ b/drivers/i2c/busses/i2c-stm32f7.c
@@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap)
1809 I2C_FUNC_SMBUS_I2C_BLOCK; 1809 I2C_FUNC_SMBUS_I2C_BLOCK;
1810} 1810}
1811 1811
1812static struct i2c_algorithm stm32f7_i2c_algo = { 1812static const struct i2c_algorithm stm32f7_i2c_algo = {
1813 .master_xfer = stm32f7_i2c_xfer, 1813 .master_xfer = stm32f7_i2c_xfer,
1814 .smbus_xfer = stm32f7_i2c_smbus_xfer, 1814 .smbus_xfer = stm32f7_i2c_smbus_xfer,
1815 .functionality = stm32f7_i2c_func, 1815 .functionality = stm32f7_i2c_func,
diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index f724c8e6b360..39762f0611b1 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -526,7 +526,7 @@ static const struct i2c_algorithm synquacer_i2c_algo = {
526 .functionality = synquacer_i2c_functionality, 526 .functionality = synquacer_i2c_functionality,
527}; 527};
528 528
529static struct i2c_adapter synquacer_i2c_ops = { 529static const struct i2c_adapter synquacer_i2c_ops = {
530 .owner = THIS_MODULE, 530 .owner = THIS_MODULE,
531 .name = "synquacer_i2c-adapter", 531 .name = "synquacer_i2c-adapter",
532 .algo = &synquacer_i2c_algo, 532 .algo = &synquacer_i2c_algo,
diff --git a/drivers/i2c/busses/i2c-taos-evm.c b/drivers/i2c/busses/i2c-taos-evm.c
index 37347c93e8e0..0bff3f3a8779 100644
--- a/drivers/i2c/busses/i2c-taos-evm.c
+++ b/drivers/i2c/busses/i2c-taos-evm.c
@@ -39,7 +39,7 @@ struct taos_data {
39}; 39};
40 40
41/* TAOS TSL2550 EVM */ 41/* TAOS TSL2550 EVM */
42static struct i2c_board_info tsl2550_info = { 42static const struct i2c_board_info tsl2550_info = {
43 I2C_BOARD_INFO("tsl2550", 0x39), 43 I2C_BOARD_INFO("tsl2550", 0x39),
44}; 44};
45 45
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 9fcb13beeb8f..c1683f9338b4 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
636 dvc_writel(i2c_dev, val, DVC_CTRL_REG1); 636 dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
637} 637}
638 638
639static int tegra_i2c_runtime_resume(struct device *dev) 639static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev)
640{ 640{
641 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 641 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
642 int ret; 642 int ret;
@@ -665,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev)
665 return 0; 665 return 0;
666} 666}
667 667
668static int tegra_i2c_runtime_suspend(struct device *dev) 668static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev)
669{ 669{
670 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 670 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
671 671
@@ -713,12 +713,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit)
713 u32 tsu_thd; 713 u32 tsu_thd;
714 u8 tlow, thigh; 714 u8 tlow, thigh;
715 715
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
722 reset_control_assert(i2c_dev->rst); 716 reset_control_assert(i2c_dev->rst);
723 udelay(2); 717 udelay(2);
724 reset_control_deassert(i2c_dev->rst); 718 reset_control_deassert(i2c_dev->rst);
@@ -772,7 +766,7 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit)
772 if (err) { 766 if (err) {
773 dev_err(i2c_dev->dev, 767 dev_err(i2c_dev->dev,
774 "failed changing clock rate: %d\n", err); 768 "failed changing clock rate: %d\n", err);
775 goto err; 769 return err;
776 } 770 }
777 } 771 }
778 772
@@ -787,23 +781,21 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit)
787 781
788 err = tegra_i2c_flush_fifos(i2c_dev); 782 err = tegra_i2c_flush_fifos(i2c_dev);
789 if (err) 783 if (err)
790 goto err; 784 return err;
791 785
792 if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg) 786 if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg)
793 i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE); 787 i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE);
794 788
795 err = tegra_i2c_wait_for_config_load(i2c_dev); 789 err = tegra_i2c_wait_for_config_load(i2c_dev);
796 if (err) 790 if (err)
797 goto err; 791 return err;
798 792
799 if (i2c_dev->irq_disabled) { 793 if (i2c_dev->irq_disabled) {
800 i2c_dev->irq_disabled = false; 794 i2c_dev->irq_disabled = false;
801 enable_irq(i2c_dev->irq); 795 enable_irq(i2c_dev->irq);
802 } 796 }
803 797
804err: 798 return 0;
805 pm_runtime_put(i2c_dev->dev);
806 return err;
807} 799}
808 800
809static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev) 801static 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)
1616 } 1608 }
1617 1609
1618 pm_runtime_enable(&pdev->dev); 1610 pm_runtime_enable(&pdev->dev);
1619 if (!pm_runtime_enabled(&pdev->dev)) { 1611 if (!pm_runtime_enabled(&pdev->dev))
1620 ret = tegra_i2c_runtime_resume(&pdev->dev); 1612 ret = tegra_i2c_runtime_resume(&pdev->dev);
1621 if (ret < 0) { 1613 else
1622 dev_err(&pdev->dev, "runtime resume failed\n"); 1614 ret = pm_runtime_get_sync(i2c_dev->dev);
1623 goto unprepare_div_clk; 1615
1624 } 1616 if (ret < 0) {
1617 dev_err(&pdev->dev, "runtime resume failed\n");
1618 goto unprepare_div_clk;
1625 } 1619 }
1626 1620
1627 if (i2c_dev->is_multimaster_mode) { 1621 if (i2c_dev->is_multimaster_mode) {
@@ -1666,6 +1660,8 @@ static int tegra_i2c_probe(struct platform_device *pdev)
1666 if (ret) 1660 if (ret)
1667 goto release_dma; 1661 goto release_dma;
1668 1662
1663 pm_runtime_put(&pdev->dev);
1664
1669 return 0; 1665 return 0;
1670 1666
1671release_dma: 1667release_dma:
@@ -1711,8 +1707,7 @@ static int tegra_i2c_remove(struct platform_device *pdev)
1711 return 0; 1707 return 0;
1712} 1708}
1713 1709
1714#ifdef CONFIG_PM_SLEEP 1710static int __maybe_unused tegra_i2c_suspend(struct device *dev)
1715static int tegra_i2c_suspend(struct device *dev)
1716{ 1711{
1717 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 1712 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
1718 1713
@@ -1721,38 +1716,41 @@ static int tegra_i2c_suspend(struct device *dev)
1721 return 0; 1716 return 0;
1722} 1717}
1723 1718
1724static int tegra_i2c_resume(struct device *dev) 1719static int __maybe_unused tegra_i2c_resume(struct device *dev)
1725{ 1720{
1726 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 1721 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
1727 int err; 1722 int err;
1728 1723
1724 err = tegra_i2c_runtime_resume(dev);
1725 if (err)
1726 return err;
1727
1729 err = tegra_i2c_init(i2c_dev, false); 1728 err = tegra_i2c_init(i2c_dev, false);
1730 if (err) 1729 if (err)
1731 return err; 1730 return err;
1732 1731
1732 err = tegra_i2c_runtime_suspend(dev);
1733 if (err)
1734 return err;
1735
1733 i2c_mark_adapter_resumed(&i2c_dev->adapter); 1736 i2c_mark_adapter_resumed(&i2c_dev->adapter);
1734 1737
1735 return 0; 1738 return 0;
1736} 1739}
1737 1740
1738static const struct dev_pm_ops tegra_i2c_pm = { 1741static 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)
1740 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, 1743 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
1741 NULL) 1744 NULL)
1742}; 1745};
1743 1746
1744#define TEGRA_I2C_PM (&tegra_i2c_pm)
1745#else
1746#define TEGRA_I2C_PM NULL
1747#endif
1748
1749static struct platform_driver tegra_i2c_driver = { 1747static struct platform_driver tegra_i2c_driver = {
1750 .probe = tegra_i2c_probe, 1748 .probe = tegra_i2c_probe,
1751 .remove = tegra_i2c_remove, 1749 .remove = tegra_i2c_remove,
1752 .driver = { 1750 .driver = {
1753 .name = "tegra-i2c", 1751 .name = "tegra-i2c",
1754 .of_match_table = tegra_i2c_of_match, 1752 .of_match_table = tegra_i2c_of_match,
1755 .pm = TEGRA_I2C_PM, 1753 .pm = &tegra_i2c_pm,
1756 }, 1754 },
1757}; 1755};
1758 1756
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index 7acca2599f04..4241aac79e7e 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -108,7 +108,6 @@ static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv,
108 if (fifo_space-- <= 0) 108 if (fifo_space-- <= 0)
109 break; 109 break;
110 110
111 dev_dbg(&priv->adap.dev, "write data: %02x\n", *priv->buf);
112 writel(*priv->buf++, priv->membase + UNIPHIER_FI2C_DTTX); 111 writel(*priv->buf++, priv->membase + UNIPHIER_FI2C_DTTX);
113 priv->len--; 112 priv->len--;
114 } 113 }
@@ -124,7 +123,6 @@ static void uniphier_fi2c_drain_rxfifo(struct uniphier_fi2c_priv *priv)
124 break; 123 break;
125 124
126 *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX); 125 *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX);
127 dev_dbg(&priv->adap.dev, "read data: %02x\n", priv->buf[-1]);
128 priv->len--; 126 priv->len--;
129 } 127 }
130} 128}
@@ -142,8 +140,6 @@ static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv,
142 140
143static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv) 141static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv)
144{ 142{
145 dev_dbg(&priv->adap.dev, "stop condition\n");
146
147 priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP; 143 priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP;
148 uniphier_fi2c_set_irqs(priv); 144 uniphier_fi2c_set_irqs(priv);
149 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STO, 145 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STO,
@@ -160,21 +156,15 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id)
160 irq_status = readl(priv->membase + UNIPHIER_FI2C_INT); 156 irq_status = readl(priv->membase + UNIPHIER_FI2C_INT);
161 irq_status &= priv->enabled_irqs; 157 irq_status &= priv->enabled_irqs;
162 158
163 dev_dbg(&priv->adap.dev,
164 "interrupt: enabled_irqs=%04x, irq_status=%04x\n",
165 priv->enabled_irqs, irq_status);
166
167 if (irq_status & UNIPHIER_FI2C_INT_STOP) 159 if (irq_status & UNIPHIER_FI2C_INT_STOP)
168 goto complete; 160 goto complete;
169 161
170 if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) { 162 if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) {
171 dev_dbg(&priv->adap.dev, "arbitration lost\n");
172 priv->error = -EAGAIN; 163 priv->error = -EAGAIN;
173 goto complete; 164 goto complete;
174 } 165 }
175 166
176 if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) { 167 if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) {
177 dev_dbg(&priv->adap.dev, "could not get ACK\n");
178 priv->error = -ENXIO; 168 priv->error = -ENXIO;
179 if (priv->flags & UNIPHIER_FI2C_RD) { 169 if (priv->flags & UNIPHIER_FI2C_RD) {
180 /* 170 /*
@@ -215,18 +205,14 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id)
215 if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) { 205 if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) {
216 if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE && 206 if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE &&
217 !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) { 207 !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) {
218 dev_dbg(&priv->adap.dev,
219 "enable read byte count IRQ\n");
220 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB; 208 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB;
221 uniphier_fi2c_set_irqs(priv); 209 uniphier_fi2c_set_irqs(priv);
222 priv->flags |= UNIPHIER_FI2C_BYTE_WISE; 210 priv->flags |= UNIPHIER_FI2C_BYTE_WISE;
223 } 211 }
224 if (priv->len <= 1) { 212 if (priv->len <= 1)
225 dev_dbg(&priv->adap.dev, "set NACK\n");
226 writel(UNIPHIER_FI2C_CR_MST | 213 writel(UNIPHIER_FI2C_CR_MST |
227 UNIPHIER_FI2C_CR_NACK, 214 UNIPHIER_FI2C_CR_NACK,
228 priv->membase + UNIPHIER_FI2C_CR); 215 priv->membase + UNIPHIER_FI2C_CR);
229 }
230 } 216 }
231 217
232 goto handled; 218 goto handled;
@@ -334,10 +320,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap,
334 bool is_read = msg->flags & I2C_M_RD; 320 bool is_read = msg->flags & I2C_M_RD;
335 unsigned long time_left, flags; 321 unsigned long time_left, flags;
336 322
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
341 priv->len = msg->len; 323 priv->len = msg->len;
342 priv->buf = msg->buf; 324 priv->buf = msg->buf;
343 priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS; 325 priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS;
@@ -359,7 +341,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap,
359 else 341 else
360 uniphier_fi2c_tx_init(priv, msg->addr, repeat); 342 uniphier_fi2c_tx_init(priv, msg->addr, repeat);
361 343
362 dev_dbg(&adap->dev, "start condition\n");
363 /* 344 /*
364 * For a repeated START condition, writing a slave address to the FIFO 345 * For a repeated START condition, writing a slave address to the FIFO
365 * kicks the controller. So, the UNIPHIER_FI2C_CR register should be 346 * 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,
383 uniphier_fi2c_recover(priv); 364 uniphier_fi2c_recover(priv);
384 return -ETIMEDOUT; 365 return -ETIMEDOUT;
385 } 366 }
386 dev_dbg(&adap->dev, "complete\n");
387 367
388 if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) { 368 if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) {
389 u32 status; 369 u32 status;
@@ -538,7 +518,6 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
538{ 518{
539 struct device *dev = &pdev->dev; 519 struct device *dev = &pdev->dev;
540 struct uniphier_fi2c_priv *priv; 520 struct uniphier_fi2c_priv *priv;
541 struct resource *regs;
542 u32 bus_speed; 521 u32 bus_speed;
543 unsigned long clk_rate; 522 unsigned long clk_rate;
544 int irq, ret; 523 int irq, ret;
@@ -547,8 +526,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
547 if (!priv) 526 if (!priv)
548 return -ENOMEM; 527 return -ENOMEM;
549 528
550 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 529 priv->membase = devm_platform_ioremap_resource(pdev, 0);
551 priv->membase = devm_ioremap_resource(dev, regs);
552 if (IS_ERR(priv->membase)) 530 if (IS_ERR(priv->membase))
553 return PTR_ERR(priv->membase); 531 return PTR_ERR(priv->membase);
554 532
diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
index 0173840c32af..0270090c0360 100644
--- a/drivers/i2c/busses/i2c-uniphier.c
+++ b/drivers/i2c/busses/i2c-uniphier.c
@@ -71,7 +71,6 @@ static int uniphier_i2c_xfer_byte(struct i2c_adapter *adap, u32 txdata,
71 reinit_completion(&priv->comp); 71 reinit_completion(&priv->comp);
72 72
73 txdata |= UNIPHIER_I2C_DTRM_IRQEN; 73 txdata |= UNIPHIER_I2C_DTRM_IRQEN;
74 dev_dbg(&adap->dev, "write data: 0x%04x\n", txdata);
75 writel(txdata, priv->membase + UNIPHIER_I2C_DTRM); 74 writel(txdata, priv->membase + UNIPHIER_I2C_DTRM);
76 75
77 time_left = wait_for_completion_timeout(&priv->comp, adap->timeout); 76 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,
81 } 80 }
82 81
83 rxdata = readl(priv->membase + UNIPHIER_I2C_DREC); 82 rxdata = readl(priv->membase + UNIPHIER_I2C_DREC);
84 dev_dbg(&adap->dev, "read data: 0x%04x\n", rxdata);
85
86 if (rxdatap) 83 if (rxdatap)
87 *rxdatap = rxdata; 84 *rxdatap = rxdata;
88 85
@@ -98,14 +95,11 @@ static int uniphier_i2c_send_byte(struct i2c_adapter *adap, u32 txdata)
98 if (ret) 95 if (ret)
99 return ret; 96 return ret;
100 97
101 if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) { 98 if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB))
102 dev_dbg(&adap->dev, "arbitration lost\n");
103 return -EAGAIN; 99 return -EAGAIN;
104 } 100
105 if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) { 101 if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB))
106 dev_dbg(&adap->dev, "could not get ACK\n");
107 return -ENXIO; 102 return -ENXIO;
108 }
109 103
110 return 0; 104 return 0;
111} 105}
@@ -115,7 +109,6 @@ static int uniphier_i2c_tx(struct i2c_adapter *adap, u16 addr, u16 len,
115{ 109{
116 int ret; 110 int ret;
117 111
118 dev_dbg(&adap->dev, "start condition\n");
119 ret = uniphier_i2c_send_byte(adap, addr << 1 | 112 ret = uniphier_i2c_send_byte(adap, addr << 1 |
120 UNIPHIER_I2C_DTRM_STA | 113 UNIPHIER_I2C_DTRM_STA |
121 UNIPHIER_I2C_DTRM_NACK); 114 UNIPHIER_I2C_DTRM_NACK);
@@ -137,7 +130,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len,
137{ 130{
138 int ret; 131 int ret;
139 132
140 dev_dbg(&adap->dev, "start condition\n");
141 ret = uniphier_i2c_send_byte(adap, addr << 1 | 133 ret = uniphier_i2c_send_byte(adap, addr << 1 |
142 UNIPHIER_I2C_DTRM_STA | 134 UNIPHIER_I2C_DTRM_STA |
143 UNIPHIER_I2C_DTRM_NACK | 135 UNIPHIER_I2C_DTRM_NACK |
@@ -161,7 +153,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len,
161 153
162static int uniphier_i2c_stop(struct i2c_adapter *adap) 154static int uniphier_i2c_stop(struct i2c_adapter *adap)
163{ 155{
164 dev_dbg(&adap->dev, "stop condition\n");
165 return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO | 156 return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO |
166 UNIPHIER_I2C_DTRM_NACK); 157 UNIPHIER_I2C_DTRM_NACK);
167} 158}
@@ -173,9 +164,6 @@ static int uniphier_i2c_master_xfer_one(struct i2c_adapter *adap,
173 bool recovery = false; 164 bool recovery = false;
174 int ret; 165 int ret;
175 166
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
179 if (is_read) 167 if (is_read)
180 ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf); 168 ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf);
181 else 169 else
@@ -326,7 +314,6 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
326{ 314{
327 struct device *dev = &pdev->dev; 315 struct device *dev = &pdev->dev;
328 struct uniphier_i2c_priv *priv; 316 struct uniphier_i2c_priv *priv;
329 struct resource *regs;
330 u32 bus_speed; 317 u32 bus_speed;
331 unsigned long clk_rate; 318 unsigned long clk_rate;
332 int irq, ret; 319 int irq, ret;
@@ -335,8 +322,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
335 if (!priv) 322 if (!priv)
336 return -ENOMEM; 323 return -ENOMEM;
337 324
338 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 325 priv->membase = devm_platform_ioremap_resource(pdev, 0);
339 priv->membase = devm_ioremap_resource(dev, regs);
340 if (IS_ERR(priv->membase)) 326 if (IS_ERR(priv->membase))
341 return PTR_ERR(priv->membase); 327 return PTR_ERR(priv->membase);
342 328
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 72b300174cb8..5f6a4985f2bc 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -350,13 +350,11 @@ static int i2c_device_probe(struct device *dev)
350 return -ENODEV; 350 return -ENODEV;
351 351
352 if (client->flags & I2C_CLIENT_WAKE) { 352 if (client->flags & I2C_CLIENT_WAKE) {
353 int wakeirq = -ENOENT; 353 int wakeirq;
354 354
355 if (dev->of_node) { 355 wakeirq = of_irq_get_byname(dev->of_node, "wakeup");
356 wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); 356 if (wakeirq == -EPROBE_DEFER)
357 if (wakeirq == -EPROBE_DEFER) 357 return wakeirq;
358 return wakeirq;
359 }
360 358
361 device_init_wakeup(&client->dev, true); 359 device_init_wakeup(&client->dev, true);
362 360
@@ -966,7 +964,7 @@ struct i2c_client *devm_i2c_new_dummy_device(struct device *dev,
966EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device); 964EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device);
967 965
968/** 966/**
969 * i2c_new_secondary_device - Helper to get the instantiated secondary address 967 * i2c_new_ancillary_device - Helper to get the instantiated secondary address
970 * and create the associated device 968 * and create the associated device
971 * @client: Handle to the primary client 969 * @client: Handle to the primary client
972 * @name: Handle to specify which secondary address to get 970 * @name: Handle to specify which secondary address to get
@@ -985,9 +983,9 @@ EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device);
985 * cell whose "reg-names" value matches the slave name. 983 * cell whose "reg-names" value matches the slave name.
986 * 984 *
987 * This returns the new i2c client, which should be saved for later use with 985 * 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.
989 */ 987 */
990struct i2c_client *i2c_new_secondary_device(struct i2c_client *client, 988struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client,
991 const char *name, 989 const char *name,
992 u16 default_addr) 990 u16 default_addr)
993{ 991{
@@ -1002,9 +1000,9 @@ struct i2c_client *i2c_new_secondary_device(struct i2c_client *client,
1002 } 1000 }
1003 1001
1004 dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr); 1002 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);
1006} 1004}
1007EXPORT_SYMBOL_GPL(i2c_new_secondary_device); 1005EXPORT_SYMBOL_GPL(i2c_new_ancillary_device);
1008 1006
1009/* ------------------------------------------------------------------------- */ 1007/* ------------------------------------------------------------------------- */
1010 1008
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c
index be65d3842878..92ff9991bae8 100644
--- a/drivers/i2c/i2c-slave-eeprom.c
+++ b/drivers/i2c/i2c-slave-eeprom.c
@@ -11,6 +11,13 @@
11 * pointer, yet implementation is deferred until the need actually arises. 11 * pointer, yet implementation is deferred until the need actually arises.
12 */ 12 */
13 13
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>
14#include <linux/i2c.h> 21#include <linux/i2c.h>
15#include <linux/init.h> 22#include <linux/init.h>
16#include <linux/module.h> 23#include <linux/module.h>
@@ -21,12 +28,18 @@
21 28
22struct eeprom_data { 29struct eeprom_data {
23 struct bin_attribute bin; 30 struct bin_attribute bin;
24 bool first_write;
25 spinlock_t buffer_lock; 31 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;
27 u8 buffer[]; 36 u8 buffer[];
28}; 37};
29 38
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
30static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, 43static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
31 enum i2c_slave_event event, u8 *val) 44 enum i2c_slave_event event, u8 *val)
32{ 45{
@@ -34,12 +47,14 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
34 47
35 switch (event) { 48 switch (event) {
36 case I2C_SLAVE_WRITE_RECEIVED: 49 case I2C_SLAVE_WRITE_RECEIVED:
37 if (eeprom->first_write) { 50 if (eeprom->idx_write_cnt < eeprom->num_address_bytes) {
38 eeprom->buffer_idx = *val; 51 if (eeprom->idx_write_cnt == 0)
39 eeprom->first_write = false; 52 eeprom->buffer_idx = 0;
53 eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8);
54 eeprom->idx_write_cnt++;
40 } else { 55 } else {
41 spin_lock(&eeprom->buffer_lock); 56 spin_lock(&eeprom->buffer_lock);
42 eeprom->buffer[eeprom->buffer_idx++] = *val; 57 eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val;
43 spin_unlock(&eeprom->buffer_lock); 58 spin_unlock(&eeprom->buffer_lock);
44 } 59 }
45 break; 60 break;
@@ -50,7 +65,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client,
50 /* fallthrough */ 65 /* fallthrough */
51 case I2C_SLAVE_READ_REQUESTED: 66 case I2C_SLAVE_READ_REQUESTED:
52 spin_lock(&eeprom->buffer_lock); 67 spin_lock(&eeprom->buffer_lock);
53 *val = eeprom->buffer[eeprom->buffer_idx]; 68 *val = eeprom->buffer[eeprom->buffer_idx & eeprom->address_mask];
54 spin_unlock(&eeprom->buffer_lock); 69 spin_unlock(&eeprom->buffer_lock);
55 /* 70 /*
56 * Do not increment buffer_idx here, because we don't know if 71 * 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,
61 76
62 case I2C_SLAVE_STOP: 77 case I2C_SLAVE_STOP:
63 case I2C_SLAVE_WRITE_REQUESTED: 78 case I2C_SLAVE_WRITE_REQUESTED:
64 eeprom->first_write = true; 79 eeprom->idx_write_cnt = 0;
65 break; 80 break;
66 81
67 default: 82 default:
@@ -105,13 +120,16 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de
105{ 120{
106 struct eeprom_data *eeprom; 121 struct eeprom_data *eeprom;
107 int ret; 122 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);
109 125
110 eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); 126 eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL);
111 if (!eeprom) 127 if (!eeprom)
112 return -ENOMEM; 128 return -ENOMEM;
113 129
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;
115 spin_lock_init(&eeprom->buffer_lock); 133 spin_lock_init(&eeprom->buffer_lock);
116 i2c_set_clientdata(client, eeprom); 134 i2c_set_clientdata(client, eeprom);
117 135
@@ -146,7 +164,9 @@ static int i2c_slave_eeprom_remove(struct i2c_client *client)
146} 164}
147 165
148static const struct i2c_device_id i2c_slave_eeprom_id[] = { 166static 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) },
150 { } 170 { }
151}; 171};
152MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id); 172MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 0a47d474e97a..23e02ff27b17 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -183,14 +183,14 @@ static int adv748x_initialise_clients(struct adv748x_state *state)
183 int ret; 183 int ret;
184 184
185 for (i = ADV748X_PAGE_DPLL; i < ADV748X_PAGE_MAX; ++i) { 185 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(
187 state->client, 187 state->client,
188 adv748x_default_addresses[i].name, 188 adv748x_default_addresses[i].name,
189 adv748x_default_addresses[i].default_addr); 189 adv748x_default_addresses[i].default_addr);
190 190
191 if (state->i2c_clients[i] == NULL) { 191 if (IS_ERR(state->i2c_clients[i])) {
192 adv_err(state, "failed to create i2c client %u\n", i); 192 adv_err(state, "failed to create i2c client %u\n", i);
193 return -ENOMEM; 193 return PTR_ERR(state->i2c_clients[i]);
194 } 194 }
195 195
196 ret = adv748x_configure_regmap(state, i); 196 ret = adv748x_configure_regmap(state, i);
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index 28a84bf9f8a9..2dedd6ebb236 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -2862,10 +2862,8 @@ static void adv76xx_unregister_clients(struct adv76xx_state *state)
2862{ 2862{
2863 unsigned int i; 2863 unsigned int i;
2864 2864
2865 for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) { 2865 for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i)
2866 if (state->i2c_clients[i]) 2866 i2c_unregister_device(state->i2c_clients[i]);
2867 i2c_unregister_device(state->i2c_clients[i]);
2868 }
2869} 2867}
2870 2868
2871static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd, 2869static 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,
2878 struct i2c_client *new_client; 2876 struct i2c_client *new_client;
2879 2877
2880 if (pdata && pdata->i2c_addresses[page]) 2878 if (pdata && pdata->i2c_addresses[page])
2881 new_client = i2c_new_dummy(client->adapter, 2879 new_client = i2c_new_dummy_device(client->adapter,
2882 pdata->i2c_addresses[page]); 2880 pdata->i2c_addresses[page]);
2883 else 2881 else
2884 new_client = i2c_new_secondary_device(client, 2882 new_client = i2c_new_ancillary_device(client,
2885 adv76xx_default_addresses[page].name, 2883 adv76xx_default_addresses[page].name,
2886 adv76xx_default_addresses[page].default_addr); 2884 adv76xx_default_addresses[page].default_addr);
2887 2885
2888 if (new_client) 2886 if (!IS_ERR(new_client))
2889 io_write(sd, io_reg, new_client->addr << 1); 2887 io_write(sd, io_reg, new_client->addr << 1);
2890 2888
2891 return new_client; 2889 return new_client;
@@ -3516,15 +3514,19 @@ static int adv76xx_probe(struct i2c_client *client,
3516 } 3514 }
3517 3515
3518 for (i = 1; i < ADV76XX_PAGE_MAX; ++i) { 3516 for (i = 1; i < ADV76XX_PAGE_MAX; ++i) {
3517 struct i2c_client *dummy_client;
3518
3519 if (!(BIT(i) & state->info->page_mask)) 3519 if (!(BIT(i) & state->info->page_mask))
3520 continue; 3520 continue;
3521 3521
3522 state->i2c_clients[i] = adv76xx_dummy_client(sd, i); 3522 dummy_client = adv76xx_dummy_client(sd, i);
3523 if (!state->i2c_clients[i]) { 3523 if (IS_ERR(dummy_client)) {
3524 err = -EINVAL; 3524 err = PTR_ERR(dummy_client);
3525 v4l2_err(sd, "failed to create i2c client %u\n", i); 3525 v4l2_err(sd, "failed to create i2c client %u\n", i);
3526 goto err_i2c; 3526 goto err_i2c;
3527 } 3527 }
3528
3529 state->i2c_clients[i] = dummy_client;
3528 } 3530 }
3529 3531
3530 INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug, 3532 INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug,
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 518945b2f737..2cccd82a3106 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -14,7 +14,6 @@
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/mutex.h> 15#include <linux/mutex.h>
16#include <linux/mod_devicetable.h> 16#include <linux/mod_devicetable.h>
17#include <linux/log2.h>
18#include <linux/bitops.h> 17#include <linux/bitops.h>
19#include <linux/jiffies.h> 18#include <linux/jiffies.h>
20#include <linux/property.h> 19#include <linux/property.h>
diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c
index c559f706ae7e..156360e37714 100644
--- a/drivers/watchdog/iTCO_wdt.c
+++ b/drivers/watchdog/iTCO_wdt.c
@@ -48,6 +48,7 @@
48 48
49/* Includes */ 49/* Includes */
50#include <linux/acpi.h> /* For ACPI support */ 50#include <linux/acpi.h> /* For ACPI support */
51#include <linux/bits.h> /* For BIT() */
51#include <linux/module.h> /* For module specific items */ 52#include <linux/module.h> /* For module specific items */
52#include <linux/moduleparam.h> /* For new moduleparam's */ 53#include <linux/moduleparam.h> /* For new moduleparam's */
53#include <linux/types.h> /* For standard types (like size_t) */ 54#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)
215 return 0; 216 return 0;
216} 217}
217 218
219static 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
218static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p, 236static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p,
219 struct itco_wdt_platform_data *pdata) 237 struct itco_wdt_platform_data *pdata)
220{ 238{
@@ -224,7 +242,9 @@ static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p,
224 return; 242 return;
225 } 243 }
226 244
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)
228 p->update_no_reboot_bit = update_no_reboot_bit_mem; 248 p->update_no_reboot_bit = update_no_reboot_bit_mem;
229 else if (p->iTCO_version == 1) 249 else if (p->iTCO_version == 1)
230 p->update_no_reboot_bit = update_no_reboot_bit_pci; 250 p->update_no_reboot_bit = update_no_reboot_bit_pci;
@@ -452,7 +472,8 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
452 * Get the Memory-Mapped GCS or PMC register, we need it for the 472 * Get the Memory-Mapped GCS or PMC register, we need it for the
453 * NO_REBOOT flag (TCO v2 and v3). 473 * NO_REBOOT flag (TCO v2 and v3).
454 */ 474 */
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) {
456 p->gcs_pmc_res = platform_get_resource(pdev, 477 p->gcs_pmc_res = platform_get_resource(pdev,
457 IORESOURCE_MEM, 478 IORESOURCE_MEM,
458 ICH_RES_MEM_GCS_PMC); 479 ICH_RES_MEM_GCS_PMC);
@@ -502,6 +523,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev)
502 523
503 /* Clear out the (probably old) status */ 524 /* Clear out the (probably old) status */
504 switch (p->iTCO_version) { 525 switch (p->iTCO_version) {
526 case 6:
505 case 5: 527 case 5:
506 case 4: 528 case 4:
507 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */ 529 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index c0a78c069117..1361637c369d 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -473,7 +473,7 @@ extern struct i2c_client *
473devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address); 473devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address);
474 474
475extern struct i2c_client * 475extern struct i2c_client *
476i2c_new_secondary_device(struct i2c_client *client, 476i2c_new_ancillary_device(struct i2c_client *client,
477 const char *name, 477 const char *name,
478 u16 default_addr); 478 u16 default_addr);
479 479