Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+795 -267
+3 -1
Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt
··· 1 1 Broadcom BCM2835 I2C controller 2 2 3 3 Required properties: 4 - - compatible : Should be "brcm,bcm2835-i2c". 4 + - compatible : Should be one of: 5 + "brcm,bcm2711-i2c" 6 + "brcm,bcm2835-i2c" 5 7 - reg: Should contain register location and length. 6 8 - interrupts: Should contain interrupt. 7 9 - clocks : The clock feeding the I2C controller.
Documentation/devicetree/bindings/i2c/i2c-emev2.txt Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt
Documentation/devicetree/bindings/i2c/i2c-rcar.txt Documentation/devicetree/bindings/i2c/renesas,i2c.txt
Documentation/devicetree/bindings/i2c/i2c-riic.txt Documentation/devicetree/bindings/i2c/renesas,riic.txt
Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt Documentation/devicetree/bindings/i2c/renesas,iic.txt
+10 -4
MAINTAINERS
··· 7865 7865 F: drivers/mfd/lpc_ich.c 7866 7866 F: drivers/gpio/gpio-ich.c 7867 7867 7868 + ICY I2C DRIVER 7869 + M: Max Staudt <max@enpas.org> 7870 + L: linux-i2c@vger.kernel.org 7871 + S: Maintained 7872 + F: drivers/i2c/busses/i2c-icy.c 7873 + 7868 7874 IDE SUBSYSTEM 7869 7875 M: "David S. Miller" <davem@davemloft.net> 7870 7876 L: linux-ide@vger.kernel.org ··· 13797 13791 RENESAS EMEV2 I2C DRIVER 13798 13792 M: Wolfram Sang <wsa+renesas@sang-engineering.com> 13799 13793 S: Supported 13800 - F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt 13794 + F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt 13801 13795 F: drivers/i2c/busses/i2c-emev2.c 13802 13796 13803 13797 RENESAS ETHERNET DRIVERS ··· 13819 13813 RENESAS R-CAR I2C DRIVERS 13820 13814 M: Wolfram Sang <wsa+renesas@sang-engineering.com> 13821 13815 S: Supported 13822 - F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt 13823 - F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt 13816 + F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt 13817 + F: Documentation/devicetree/bindings/i2c/renesas,iic.txt 13824 13818 F: drivers/i2c/busses/i2c-rcar.c 13825 13819 F: drivers/i2c/busses/i2c-sh_mobile.c 13826 13820 13827 13821 RENESAS RIIC DRIVER 13828 13822 M: Chris Brandt <chris.brandt@renesas.com> 13829 13823 S: Supported 13830 - F: Documentation/devicetree/bindings/i2c/i2c-riic.txt 13824 + F: Documentation/devicetree/bindings/i2c/renesas,riic.txt 13831 13825 F: drivers/i2c/busses/i2c-riic.c 13832 13826 13833 13827 RENESAS USB PHY DRIVER
+7
drivers/acpi/acpi_apd.c
··· 160 160 .setup = acpi_apd_setup, 161 161 .fixed_clk_rate = 250000000, 162 162 }; 163 + 163 164 static const struct apd_device_desc thunderx2_i2c_desc = { 164 165 .setup = acpi_apd_setup, 165 166 .fixed_clk_rate = 125000000, 167 + }; 168 + 169 + static const struct apd_device_desc nxp_i2c_desc = { 170 + .setup = acpi_apd_setup, 171 + .fixed_clk_rate = 350000000, 166 172 }; 167 173 168 174 static const struct apd_device_desc hip08_spi_desc = { ··· 244 238 { "HISI02A1", APD_ADDR(hip07_i2c_desc) }, 245 239 { "HISI02A2", APD_ADDR(hip08_i2c_desc) }, 246 240 { "HISI0173", APD_ADDR(hip08_spi_desc) }, 241 + { "NXP0001", APD_ADDR(nxp_i2c_desc) }, 247 242 #endif 248 243 { } 249 244 };
+9 -9
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
··· 978 978 { 979 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 982 ADV7511_CEC_I2C_ADDR_DEFAULT); 983 - if (!adv->i2c_cec) 984 - return -EINVAL; 983 + if (IS_ERR(adv->i2c_cec)) 984 + return PTR_ERR(adv->i2c_cec); 985 985 i2c_set_clientdata(adv->i2c_cec, adv); 986 986 987 987 adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec, ··· 1162 1162 1163 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 1166 ADV7511_EDID_I2C_ADDR_DEFAULT); 1167 - if (!adv7511->i2c_edid) { 1168 - ret = -EINVAL; 1167 + if (IS_ERR(adv7511->i2c_edid)) { 1168 + ret = PTR_ERR(adv7511->i2c_edid); 1169 1169 goto uninit_regulators; 1170 1170 } 1171 1171 1172 1172 regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, 1173 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 1176 ADV7511_PACKET_I2C_ADDR_DEFAULT); 1177 - if (!adv7511->i2c_packet) { 1178 - ret = -EINVAL; 1177 + if (IS_ERR(adv7511->i2c_packet)) { 1178 + ret = PTR_ERR(adv7511->i2c_packet); 1179 1179 goto err_i2c_unregister_edid; 1180 1180 } 1181 1181
+16 -1
drivers/i2c/busses/Kconfig
··· 429 429 tristate "Axxia I2C controller" 430 430 depends on ARCH_AXXIA || COMPILE_TEST 431 431 default ARCH_AXXIA 432 + select I2C_SLAVE 432 433 help 433 434 Say yes if you want to support the I2C bus on Axxia platforms. 434 435 ··· 978 977 will be called i2c-sirf. 979 978 980 979 config I2C_SPRD 981 - bool "Spreadtrum I2C interface" 980 + tristate "Spreadtrum I2C interface" 982 981 depends on I2C=y && ARCH_SPRD 983 982 help 984 983 If you say yes to this option, support will be included for the ··· 1309 1308 1310 1309 This support is also available as a module. If so, the module 1311 1310 will be called i2c-elektor. 1311 + 1312 + config I2C_ICY 1313 + tristate "ICY Zorro card" 1314 + depends on ZORRO 1315 + select I2C_ALGOPCF 1316 + help 1317 + This supports the PCF8584 Zorro bus I2C adapter, known as ICY. 1318 + Say Y if you own such an adapter. 1319 + 1320 + This support is also available as a module. If so, the module 1321 + will be called i2c-icy. 1322 + 1323 + If you have a 2019 edition board with an LTC2990 sensor at address 1324 + 0x4c, loading the module 'ltc2990' is sufficient to enable it. 1312 1325 1313 1326 config I2C_MLXCPLD 1314 1327 tristate "Mellanox I2C driver"
+1
drivers/i2c/busses/Makefile
··· 140 140 obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o 141 141 obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o 142 142 obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 143 + obj-$(CONFIG_I2C_ICY) += i2c-icy.o 143 144 obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o 144 145 obj-$(CONFIG_I2C_OPAL) += i2c-opal.o 145 146 obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
+144 -8
drivers/i2c/busses/i2c-axxia.c
··· 77 77 MST_STATUS_IP) 78 78 #define MST_TX_BYTES_XFRD 0x50 79 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 114 #define SCL_HIGH_PERIOD 0x80 81 115 #define SCL_LOW_PERIOD 0x84 82 116 #define SPIKE_FLTR_LEN 0x88 ··· 145 111 struct clk *i2c_clk; 146 112 u32 bus_clk_rate; 147 113 bool last; 114 + struct i2c_client *slave; 115 + int irq; 148 116 }; 149 117 150 118 static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask) ··· 312 276 return ret; 313 277 } 314 278 279 + static void axxia_i2c_slv_fifo_event(struct axxia_i2c_dev *idev) 280 + { 281 + u32 fifo_status = readl(idev->base + SLV_RX_FIFO); 282 + u8 val; 283 + 284 + dev_dbg(idev->dev, "slave irq fifo_status=0x%x\n", fifo_status); 285 + 286 + if (fifo_status & SLV_FIFO_DV1) { 287 + if (fifo_status & SLV_FIFO_STRC) 288 + i2c_slave_event(idev->slave, 289 + I2C_SLAVE_WRITE_REQUESTED, &val); 290 + 291 + val = readl(idev->base + SLV_DATA); 292 + i2c_slave_event(idev->slave, I2C_SLAVE_WRITE_RECEIVED, &val); 293 + } 294 + if (fifo_status & SLV_FIFO_STPC) { 295 + readl(idev->base + SLV_DATA); /* dummy read */ 296 + i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val); 297 + } 298 + if (fifo_status & SLV_FIFO_RSC) 299 + readl(idev->base + SLV_DATA); /* dummy read */ 300 + } 301 + 302 + static irqreturn_t axxia_i2c_slv_isr(struct axxia_i2c_dev *idev) 303 + { 304 + u32 status = readl(idev->base + SLV_INT_STATUS); 305 + u8 val; 306 + 307 + dev_dbg(idev->dev, "slave irq status=0x%x\n", status); 308 + 309 + if (status & SLV_STATUS_RFH) 310 + axxia_i2c_slv_fifo_event(idev); 311 + if (status & SLV_STATUS_SRS1) { 312 + i2c_slave_event(idev->slave, I2C_SLAVE_READ_REQUESTED, &val); 313 + writel(val, idev->base + SLV_DATA); 314 + } 315 + if (status & SLV_STATUS_SRND1) { 316 + i2c_slave_event(idev->slave, I2C_SLAVE_READ_PROCESSED, &val); 317 + writel(val, idev->base + SLV_DATA); 318 + } 319 + if (status & SLV_STATUS_SRC1) 320 + i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val); 321 + 322 + writel(INT_SLV, idev->base + INTERRUPT_STATUS); 323 + return IRQ_HANDLED; 324 + } 325 + 315 326 static irqreturn_t axxia_i2c_isr(int irq, void *_dev) 316 327 { 317 328 struct axxia_i2c_dev *idev = _dev; 329 + irqreturn_t ret = IRQ_NONE; 318 330 u32 status; 319 331 320 - if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST)) 321 - return IRQ_NONE; 332 + status = readl(idev->base + INTERRUPT_STATUS); 333 + 334 + if (status & INT_SLV) 335 + ret = axxia_i2c_slv_isr(idev); 336 + if (!(status & INT_MST)) 337 + return ret; 322 338 323 339 /* Read interrupt status bits */ 324 340 status = readl(idev->base + MST_INT_STATUS); ··· 671 583 return caps; 672 584 } 673 585 586 + static int axxia_i2c_reg_slave(struct i2c_client *slave) 587 + { 588 + struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter); 589 + u32 slv_int_mask = SLV_STATUS_RFH; 590 + u32 dec_ctl; 591 + 592 + if (idev->slave) 593 + return -EBUSY; 594 + 595 + idev->slave = slave; 596 + 597 + /* Enable slave mode as well */ 598 + writel(GLOBAL_MST_EN | GLOBAL_SLV_EN, idev->base + GLOBAL_CONTROL); 599 + writel(INT_MST | INT_SLV, idev->base + INTERRUPT_ENABLE); 600 + 601 + /* Set slave address */ 602 + dec_ctl = SLV_ADDR_DEC_SA1E; 603 + if (slave->flags & I2C_CLIENT_TEN) 604 + dec_ctl |= SLV_ADDR_DEC_SA1M; 605 + 606 + writel(SLV_RX_ACSA1, idev->base + SLV_RX_CTL); 607 + writel(dec_ctl, idev->base + SLV_ADDR_DEC_CTL); 608 + writel(slave->addr, idev->base + SLV_ADDR_1); 609 + 610 + /* Enable interrupts */ 611 + slv_int_mask |= SLV_STATUS_SRS1 | SLV_STATUS_SRRS1 | SLV_STATUS_SRND1; 612 + slv_int_mask |= SLV_STATUS_SRC1; 613 + writel(slv_int_mask, idev->base + SLV_INT_ENABLE); 614 + 615 + return 0; 616 + } 617 + 618 + static int axxia_i2c_unreg_slave(struct i2c_client *slave) 619 + { 620 + struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter); 621 + 622 + /* Disable slave mode */ 623 + writel(GLOBAL_MST_EN, idev->base + GLOBAL_CONTROL); 624 + writel(INT_MST, idev->base + INTERRUPT_ENABLE); 625 + 626 + synchronize_irq(idev->irq); 627 + 628 + idev->slave = NULL; 629 + 630 + return 0; 631 + } 632 + 674 633 static const struct i2c_algorithm axxia_i2c_algo = { 675 634 .master_xfer = axxia_i2c_xfer, 676 635 .functionality = axxia_i2c_func, 636 + .reg_slave = axxia_i2c_reg_slave, 637 + .unreg_slave = axxia_i2c_unreg_slave, 677 638 }; 678 639 679 640 static const struct i2c_adapter_quirks axxia_i2c_quirks = { ··· 736 599 struct axxia_i2c_dev *idev = NULL; 737 600 struct resource *res; 738 601 void __iomem *base; 739 - int irq; 740 602 int ret = 0; 741 603 742 604 idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL); ··· 747 611 if (IS_ERR(base)) 748 612 return PTR_ERR(base); 749 613 750 - irq = platform_get_irq(pdev, 0); 751 - if (irq < 0) { 614 + idev->irq = platform_get_irq(pdev, 0); 615 + if (idev->irq < 0) { 752 616 dev_err(&pdev->dev, "missing interrupt resource\n"); 753 - return irq; 617 + return idev->irq; 754 618 } 755 619 756 620 idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c"); ··· 779 643 goto error_disable_clk; 780 644 } 781 645 782 - ret = devm_request_irq(&pdev->dev, irq, axxia_i2c_isr, 0, 646 + ret = devm_request_irq(&pdev->dev, idev->irq, axxia_i2c_isr, 0, 783 647 pdev->name, idev); 784 648 if (ret) { 785 - dev_err(&pdev->dev, "failed to claim IRQ%d\n", irq); 649 + dev_err(&pdev->dev, "failed to claim IRQ%d\n", idev->irq); 786 650 goto error_disable_clk; 787 651 } 788 652
+4 -2
drivers/i2c/busses/i2c-bcm-iproc.c
··· 808 808 .unreg_slave = bcm_iproc_i2c_unreg_slave, 809 809 }; 810 810 811 - static struct i2c_adapter_quirks bcm_iproc_i2c_quirks = { 811 + static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = { 812 812 .max_read_len = M_RX_MAX_READ_LEN, 813 813 }; 814 814 ··· 922 922 923 923 adap = &iproc_i2c->adapter; 924 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 928 adap->algo = &bcm_iproc_algo; 927 929 adap->quirks = &bcm_iproc_i2c_quirks; 928 930 adap->dev.parent = &pdev->dev;
+7 -4
drivers/i2c/busses/i2c-bcm2835.c
··· 12 12 #include <linux/interrupt.h> 13 13 #include <linux/io.h> 14 14 #include <linux/module.h> 15 + #include <linux/of_device.h> 15 16 #include <linux/platform_device.h> 16 17 #include <linux/slab.h> 17 18 ··· 390 389 }; 391 390 392 391 /* 393 - * This HW was reported to have problems with clock stretching: 392 + * The BCM2835 was reported to have problems with clock stretching: 394 393 * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html 395 394 * https://www.raspberrypi.org/forums/viewtopic.php?p=146272 396 395 */ ··· 472 471 i2c_set_adapdata(adap, i2c_dev); 473 472 adap->owner = THIS_MODULE; 474 473 adap->class = I2C_CLASS_DEPRECATED; 475 - strlcpy(adap->name, "bcm2835 I2C adapter", sizeof(adap->name)); 474 + snprintf(adap->name, sizeof(adap->name), "bcm2835 (%s)", 475 + of_node_full_name(pdev->dev.of_node)); 476 476 adap->algo = &bcm2835_i2c_algo; 477 477 adap->dev.parent = &pdev->dev; 478 478 adap->dev.of_node = pdev->dev.of_node; 479 - adap->quirks = &bcm2835_i2c_quirks; 479 + adap->quirks = of_device_get_match_data(&pdev->dev); 480 480 481 481 bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); 482 482 ··· 503 501 } 504 502 505 503 static const struct of_device_id bcm2835_i2c_of_match[] = { 506 - { .compatible = "brcm,bcm2835-i2c" }, 504 + { .compatible = "brcm,bcm2711-i2c" }, 505 + { .compatible = "brcm,bcm2835-i2c", .data = &bcm2835_i2c_quirks }, 507 506 {}, 508 507 }; 509 508 MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match);
+47 -2
drivers/i2c/busses/i2c-cht-wc.c
··· 178 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 + */ 202 + static void cht_wc_i2c_adap_lock_bus(struct i2c_adapter *adapter, 203 + unsigned int flags) 204 + { 205 + rt_mutex_lock_nested(&adapter->bus_lock, 1); 206 + } 207 + 208 + static int cht_wc_i2c_adap_trylock_bus(struct i2c_adapter *adapter, 209 + unsigned int flags) 210 + { 211 + return rt_mutex_trylock(&adapter->bus_lock); 212 + } 213 + 214 + static void cht_wc_i2c_adap_unlock_bus(struct i2c_adapter *adapter, 215 + unsigned int flags) 216 + { 217 + rt_mutex_unlock(&adapter->bus_lock); 218 + } 219 + 220 + static const struct i2c_lock_operations cht_wc_i2c_adap_lock_ops = { 221 + .lock_bus = cht_wc_i2c_adap_lock_bus, 222 + .trylock_bus = cht_wc_i2c_adap_trylock_bus, 223 + .unlock_bus = cht_wc_i2c_adap_unlock_bus, 224 + }; 225 + 181 226 /**** irqchip for the client connected to the extchgr i2c adapter ****/ 182 227 static void cht_wc_i2c_irq_lock(struct irq_data *data) 183 228 { ··· 331 286 adap->adapter.owner = THIS_MODULE; 332 287 adap->adapter.class = I2C_CLASS_HWMON; 333 288 adap->adapter.algo = &cht_wc_i2c_adap_algo; 289 + adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops; 334 290 strlcpy(adap->adapter.name, "PMIC I2C Adapter", 335 291 sizeof(adap->adapter.name)); 336 292 adap->adapter.dev.parent = &pdev->dev; ··· 409 363 { 410 364 struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); 411 365 412 - if (adap->client) 413 - i2c_unregister_device(adap->client); 366 + i2c_unregister_device(adap->client); 414 367 i2c_del_adapter(&adap->adapter); 415 368 irq_domain_remove(adap->irq_domain); 416 369
+4 -8
drivers/i2c/busses/i2c-designware-master.c
··· 655 655 struct i2c_bus_recovery_info *rinfo = &dev->rinfo; 656 656 struct i2c_adapter *adap = &dev->adapter; 657 657 struct gpio_desc *gpio; 658 - int r; 659 658 660 - gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); 661 - if (IS_ERR(gpio)) { 662 - r = PTR_ERR(gpio); 663 - if (r == -ENOENT || r == -ENOSYS) 664 - return 0; 665 - return r; 666 - } 659 + gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH); 660 + if (IS_ERR_OR_NULL(gpio)) 661 + return PTR_ERR_OR_ZERO(gpio); 662 + 667 663 rinfo->scl_gpiod = gpio; 668 664 669 665 gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN);
+34 -7
drivers/i2c/busses/i2c-designware-pcidrv.c
··· 33 33 baytrail, 34 34 cherrytrail, 35 35 haswell, 36 + elkhartlake, 36 37 }; 37 38 38 39 struct dw_scl_sda_cfg { ··· 169 168 .flags = MODEL_CHERRYTRAIL, 170 169 .scl_sda_cfg = &byt_config, 171 170 }, 171 + [elkhartlake] = { 172 + .bus_num = -1, 173 + .bus_cfg = INTEL_MID_STD_CFG | DW_IC_CON_SPEED_FAST, 174 + .tx_fifo_depth = 32, 175 + .rx_fifo_depth = 32, 176 + .functionality = I2C_FUNC_10BIT_ADDR, 177 + .clk_khz = 100000, 178 + }, 172 179 }; 173 180 174 181 #ifdef CONFIG_PM 175 182 static int i2c_dw_pci_suspend(struct device *dev) 176 183 { 177 - struct pci_dev *pdev = to_pci_dev(dev); 178 - struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev); 184 + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 179 185 180 186 i_dev->suspended = true; 181 187 i_dev->disable(i_dev); ··· 192 184 193 185 static int i2c_dw_pci_resume(struct device *dev) 194 186 { 195 - struct pci_dev *pdev = to_pci_dev(dev); 196 - struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev); 187 + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 197 188 int ret; 198 189 199 190 ret = i_dev->init(i_dev); ··· 234 227 return r; 235 228 } 236 229 230 + pci_set_master(pdev); 231 + 237 232 r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); 238 233 if (r) { 239 234 dev_err(&pdev->dev, "I/O memory remapping failed\n"); ··· 246 237 if (!dev) 247 238 return -ENOMEM; 248 239 240 + r = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_ALL_TYPES); 241 + if (r < 0) 242 + return r; 243 + 249 244 dev->clk = NULL; 250 245 dev->controller = controller; 251 246 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; 252 247 dev->base = pcim_iomap_table(pdev)[0]; 253 248 dev->dev = &pdev->dev; 254 - dev->irq = pdev->irq; 249 + dev->irq = pci_irq_vector(pdev, 0); 255 250 dev->flags |= controller->flags; 256 251 257 252 if (controller->setup) { 258 253 r = controller->setup(pdev, controller); 259 - if (r) 254 + if (r) { 255 + pci_free_irq_vectors(pdev); 260 256 return r; 257 + } 261 258 } 262 259 263 260 dev->functionality = controller->functionality | ··· 291 276 adap->nr = controller->bus_num; 292 277 293 278 r = i2c_dw_probe(dev); 294 - if (r) 279 + if (r) { 280 + pci_free_irq_vectors(pdev); 295 281 return r; 282 + } 296 283 297 284 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); 298 285 pm_runtime_use_autosuspend(&pdev->dev); ··· 313 296 pm_runtime_get_noresume(&pdev->dev); 314 297 315 298 i2c_del_adapter(&dev->adapter); 299 + pci_free_irq_vectors(pdev); 316 300 } 317 301 318 302 /* work with hotplug and coldplug */ ··· 349 331 { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail }, 350 332 { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail }, 351 333 { PCI_VDEVICE(INTEL, 0x22C7), cherrytrail }, 334 + /* Elkhart Lake (PSE I2C) */ 335 + { PCI_VDEVICE(INTEL, 0x4bb9), elkhartlake }, 336 + { PCI_VDEVICE(INTEL, 0x4bba), elkhartlake }, 337 + { PCI_VDEVICE(INTEL, 0x4bbb), elkhartlake }, 338 + { PCI_VDEVICE(INTEL, 0x4bbc), elkhartlake }, 339 + { PCI_VDEVICE(INTEL, 0x4bbd), elkhartlake }, 340 + { PCI_VDEVICE(INTEL, 0x4bbe), elkhartlake }, 341 + { PCI_VDEVICE(INTEL, 0x4bbf), elkhartlake }, 342 + { PCI_VDEVICE(INTEL, 0x4bc0), elkhartlake }, 352 343 { 0,} 353 344 }; 354 345 MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids);
+10 -12
drivers/i2c/busses/i2c-designware-platdrv.c
··· 279 279 platform_set_drvdata(pdev, dev); 280 280 281 281 dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); 282 - if (IS_ERR(dev->rst)) { 283 - if (PTR_ERR(dev->rst) == -EPROBE_DEFER) 284 - return -EPROBE_DEFER; 285 - } else { 286 - reset_control_deassert(dev->rst); 287 - } 282 + if (IS_ERR(dev->rst)) 283 + return PTR_ERR(dev->rst); 284 + 285 + reset_control_deassert(dev->rst); 288 286 289 287 t = &dev->timings; 290 288 if (pdata) ··· 344 346 345 347 /* Optional interface clock */ 346 348 dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); 347 - if (IS_ERR(dev->pclk)) 348 - return PTR_ERR(dev->pclk); 349 + if (IS_ERR(dev->pclk)) { 350 + ret = PTR_ERR(dev->pclk); 351 + goto exit_reset; 352 + } 349 353 350 354 dev->clk = devm_clk_get(&pdev->dev, NULL); 351 355 if (!i2c_dw_prepare_clk(dev, true)) { ··· 400 400 exit_probe: 401 401 dw_i2c_plat_pm_cleanup(dev); 402 402 exit_reset: 403 - if (!IS_ERR_OR_NULL(dev->rst)) 404 - reset_control_assert(dev->rst); 403 + reset_control_assert(dev->rst); 405 404 return ret; 406 405 } 407 406 ··· 418 419 pm_runtime_put_sync(&pdev->dev); 419 420 dw_i2c_plat_pm_cleanup(dev); 420 421 421 - if (!IS_ERR_OR_NULL(dev->rst)) 422 - reset_control_assert(dev->rst); 422 + reset_control_assert(dev->rst); 423 423 424 424 return 0; 425 425 }
+1 -3
drivers/i2c/busses/i2c-exynos5.c
··· 791 791 } 792 792 793 793 ret = devm_request_irq(&pdev->dev, i2c->irq, exynos5_i2c_irq, 794 - IRQF_NO_SUSPEND | IRQF_ONESHOT, 795 - dev_name(&pdev->dev), i2c); 796 - 794 + IRQF_NO_SUSPEND, dev_name(&pdev->dev), i2c); 797 795 if (ret != 0) { 798 796 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", i2c->irq); 799 797 goto err_clk;
+3 -1
drivers/i2c/busses/i2c-fsi.c
··· 707 707 continue; 708 708 709 709 port = kzalloc(sizeof(*port), GFP_KERNEL); 710 - if (!port) 710 + if (!port) { 711 + of_node_put(np); 711 712 break; 713 + } 712 714 713 715 port->master = i2c; 714 716 port->port = port_no;
+1 -2
drivers/i2c/busses/i2c-hix5hd2.c
··· 445 445 hix5hd2_i2c_init(priv); 446 446 447 447 ret = devm_request_irq(&pdev->dev, irq, hix5hd2_i2c_irq, 448 - IRQF_NO_SUSPEND | IRQF_ONESHOT, 449 - dev_name(&pdev->dev), priv); 448 + IRQF_NO_SUSPEND, dev_name(&pdev->dev), priv); 450 449 if (ret != 0) { 451 450 dev_err(&pdev->dev, "cannot request HS-I2C IRQ %d\n", irq); 452 451 goto err_clk;
+90 -57
drivers/i2c/busses/i2c-i801.c
··· 292 292 #define FEATURE_HOST_NOTIFY BIT(5) 293 293 /* Not really a feature, but it's convenient to handle it as such */ 294 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 297 298 static const char *i801_feature_names[] = { 298 299 "SMBus PEC", ··· 1501 1500 } 1502 1501 #endif 1503 1502 1504 - static const struct itco_wdt_platform_data tco_platform_data = { 1503 + static const struct itco_wdt_platform_data spt_tco_platform_data = { 1505 1504 .name = "Intel PCH", 1506 1505 .version = 4, 1507 1506 }; 1508 1507 1509 1508 static DEFINE_SPINLOCK(p2sb_spinlock); 1510 1509 1511 - static void i801_add_tco(struct i801_priv *priv) 1510 + static struct platform_device * 1511 + i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, 1512 + struct resource *tco_res) 1512 1513 { 1513 - struct pci_dev *pci_dev = priv->pci_dev; 1514 - struct resource tco_res[3], *res; 1515 - struct platform_device *pdev; 1514 + struct resource *res; 1516 1515 unsigned int devfn; 1517 - u32 tco_base, tco_ctl; 1518 - u32 base_addr, ctrl_val; 1519 1516 u64 base64_addr; 1517 + u32 base_addr; 1520 1518 u8 hidden; 1521 - 1522 - if (!(priv->features & FEATURE_TCO)) 1523 - return; 1524 - 1525 - pci_read_config_dword(pci_dev, TCOBASE, &tco_base); 1526 - pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl); 1527 - if (!(tco_ctl & TCOCTL_EN)) 1528 - return; 1529 - 1530 - memset(tco_res, 0, sizeof(tco_res)); 1531 - 1532 - res = &tco_res[ICH_RES_IO_TCO]; 1533 - res->start = tco_base & ~1; 1534 - res->end = res->start + 32 - 1; 1535 - res->flags = IORESOURCE_IO; 1536 - 1537 - /* 1538 - * Power Management registers. 1539 - */ 1540 - devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2); 1541 - pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr); 1542 - 1543 - res = &tco_res[ICH_RES_IO_SMI]; 1544 - res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF; 1545 - res->end = res->start + 3; 1546 - res->flags = IORESOURCE_IO; 1547 - 1548 - /* 1549 - * Enable the ACPI I/O space. 1550 - */ 1551 - pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val); 1552 - ctrl_val |= ACPICTRL_EN; 1553 - pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val); 1554 1519 1555 1520 /* 1556 1521 * We must access the NO_REBOOT bit over the Primary to Sideband ··· 1553 1586 res->end = res->start + 3; 1554 1587 res->flags = IORESOURCE_MEM; 1555 1588 1556 - pdev = platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1557 - tco_res, 3, &tco_platform_data, 1558 - sizeof(tco_platform_data)); 1559 - if (IS_ERR(pdev)) { 1560 - dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); 1561 - return; 1562 - } 1589 + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1590 + tco_res, 3, &spt_tco_platform_data, 1591 + sizeof(spt_tco_platform_data)); 1592 + } 1563 1593 1564 - priv->tco_pdev = pdev; 1594 + static const struct itco_wdt_platform_data cnl_tco_platform_data = { 1595 + .name = "Intel PCH", 1596 + .version = 6, 1597 + }; 1598 + 1599 + static struct platform_device * 1600 + i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev, 1601 + struct resource *tco_res) 1602 + { 1603 + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1604 + tco_res, 2, &cnl_tco_platform_data, 1605 + sizeof(cnl_tco_platform_data)); 1606 + } 1607 + 1608 + static void i801_add_tco(struct i801_priv *priv) 1609 + { 1610 + u32 base_addr, tco_base, tco_ctl, ctrl_val; 1611 + struct pci_dev *pci_dev = priv->pci_dev; 1612 + struct resource tco_res[3], *res; 1613 + unsigned int devfn; 1614 + 1615 + /* If we have ACPI based watchdog use that instead */ 1616 + if (acpi_has_watchdog()) 1617 + return; 1618 + 1619 + if (!(priv->features & (FEATURE_TCO_SPT | FEATURE_TCO_CNL))) 1620 + return; 1621 + 1622 + pci_read_config_dword(pci_dev, TCOBASE, &tco_base); 1623 + pci_read_config_dword(pci_dev, TCOCTL, &tco_ctl); 1624 + if (!(tco_ctl & TCOCTL_EN)) 1625 + return; 1626 + 1627 + memset(tco_res, 0, sizeof(tco_res)); 1628 + 1629 + res = &tco_res[ICH_RES_IO_TCO]; 1630 + res->start = tco_base & ~1; 1631 + res->end = res->start + 32 - 1; 1632 + res->flags = IORESOURCE_IO; 1633 + 1634 + /* 1635 + * Power Management registers. 1636 + */ 1637 + devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 2); 1638 + pci_bus_read_config_dword(pci_dev->bus, devfn, ACPIBASE, &base_addr); 1639 + 1640 + res = &tco_res[ICH_RES_IO_SMI]; 1641 + res->start = (base_addr & ~1) + ACPIBASE_SMI_OFF; 1642 + res->end = res->start + 3; 1643 + res->flags = IORESOURCE_IO; 1644 + 1645 + /* 1646 + * Enable the ACPI I/O space. 1647 + */ 1648 + pci_bus_read_config_dword(pci_dev->bus, devfn, ACPICTRL, &ctrl_val); 1649 + ctrl_val |= ACPICTRL_EN; 1650 + pci_bus_write_config_dword(pci_dev->bus, devfn, ACPICTRL, ctrl_val); 1651 + 1652 + if (priv->features & FEATURE_TCO_CNL) 1653 + priv->tco_pdev = i801_add_tco_cnl(priv, pci_dev, tco_res); 1654 + else 1655 + priv->tco_pdev = i801_add_tco_spt(priv, pci_dev, tco_res); 1656 + 1657 + if (IS_ERR(priv->tco_pdev)) 1658 + dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); 1565 1659 } 1566 1660 1567 1661 #ifdef CONFIG_ACPI ··· 1732 1704 switch (dev->device) { 1733 1705 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS: 1734 1706 case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS: 1735 - case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS: 1736 - case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS: 1737 1707 case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS: 1738 1708 case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS: 1739 - case PCI_DEVICE_ID_INTEL_CDF_SMBUS: 1740 1709 case PCI_DEVICE_ID_INTEL_DNV_SMBUS: 1741 1710 case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: 1711 + priv->features |= FEATURE_I2C_BLOCK_READ; 1712 + priv->features |= FEATURE_IRQ; 1713 + priv->features |= FEATURE_SMBUS_PEC; 1714 + priv->features |= FEATURE_BLOCK_BUFFER; 1715 + priv->features |= FEATURE_TCO_SPT; 1716 + priv->features |= FEATURE_HOST_NOTIFY; 1717 + break; 1718 + 1719 + case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS: 1720 + case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS: 1721 + case PCI_DEVICE_ID_INTEL_CDF_SMBUS: 1742 1722 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: 1743 1723 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: 1744 1724 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: ··· 1756 1720 priv->features |= FEATURE_IRQ; 1757 1721 priv->features |= FEATURE_SMBUS_PEC; 1758 1722 priv->features |= FEATURE_BLOCK_BUFFER; 1759 - /* If we have ACPI based watchdog use that instead */ 1760 - if (!acpi_has_watchdog()) 1761 - priv->features |= FEATURE_TCO; 1723 + priv->features |= FEATURE_TCO_CNL; 1762 1724 priv->features |= FEATURE_HOST_NOTIFY; 1763 1725 break; 1764 1726 ··· 1955 1921 1956 1922 static int i801_resume(struct device *dev) 1957 1923 { 1958 - struct pci_dev *pci_dev = to_pci_dev(dev); 1959 - struct i801_priv *priv = pci_get_drvdata(pci_dev); 1924 + struct i801_priv *priv = dev_get_drvdata(dev); 1960 1925 1961 1926 i801_enable_host_notify(&priv->adapter); 1962 1927
+230
drivers/i2c/busses/i2c-icy.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * I2C driver for stand-alone PCF8584 style adapters on Zorro cards 4 + * 5 + * Original ICY documentation can be found on Aminet: 6 + * https://aminet.net/package/docs/hard/icy 7 + * 8 + * There has been a modern community re-print of this design in 2019: 9 + * https://www.a1k.org/forum/index.php?threads/70106/ 10 + * 11 + * The card is basically a Philips PCF8584 connected straight to the 12 + * beginning of the AutoConfig'd address space (register S1 on base+2), 13 + * with /INT on /INT2 on the Zorro bus. 14 + * 15 + * Copyright (c) 2019 Max Staudt <max@enpas.org> 16 + * 17 + * This started as a fork of i2c-elektor.c and has evolved since. 18 + * Thanks go to its authors for providing a base to grow on. 19 + * 20 + * 21 + * IRQ support is currently not implemented. 22 + * 23 + * As it turns out, i2c-algo-pcf is really written with i2c-elektor's 24 + * edge-triggered ISA interrupts in mind, while the Amiga's Zorro bus has 25 + * level-triggered interrupts. This means that once an interrupt occurs, we 26 + * have to tell the PCF8584 to shut up immediately, or it will keep the 27 + * interrupt line busy and cause an IRQ storm. 28 + 29 + * However, because of the PCF8584's host-side protocol, there is no good 30 + * way to just quieten it without side effects. Rather, we have to perform 31 + * the next read/write operation straight away, which will reset the /INT 32 + * pin. This entails re-designing the core of i2c-algo-pcf in the future. 33 + * For now, we never request an IRQ from the PCF8584, and poll it instead. 34 + */ 35 + 36 + #include <linux/delay.h> 37 + #include <linux/init.h> 38 + #include <linux/io.h> 39 + #include <linux/ioport.h> 40 + #include <linux/kernel.h> 41 + #include <linux/module.h> 42 + 43 + #include <linux/i2c.h> 44 + #include <linux/i2c-algo-pcf.h> 45 + 46 + #include <asm/amigaints.h> 47 + #include <linux/zorro.h> 48 + 49 + #include "../algos/i2c-algo-pcf.h" 50 + 51 + struct icy_i2c { 52 + struct i2c_adapter adapter; 53 + 54 + void __iomem *reg_s0; 55 + void __iomem *reg_s1; 56 + struct fwnode_handle *ltc2990_fwnode; 57 + struct i2c_client *ltc2990_client; 58 + }; 59 + 60 + /* 61 + * Functions called by i2c-algo-pcf 62 + */ 63 + static void icy_pcf_setpcf(void *data, int ctl, int val) 64 + { 65 + struct icy_i2c *i2c = (struct icy_i2c *)data; 66 + 67 + u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; 68 + 69 + z_writeb(val, address); 70 + } 71 + 72 + static int icy_pcf_getpcf(void *data, int ctl) 73 + { 74 + struct icy_i2c *i2c = (struct icy_i2c *)data; 75 + 76 + u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; 77 + 78 + return z_readb(address); 79 + } 80 + 81 + static int icy_pcf_getown(void *data) 82 + { 83 + return 0x55; 84 + } 85 + 86 + static int icy_pcf_getclock(void *data) 87 + { 88 + return 0x1c; 89 + } 90 + 91 + static void icy_pcf_waitforpin(void *data) 92 + { 93 + usleep_range(50, 150); 94 + } 95 + 96 + /* 97 + * Main i2c-icy part 98 + */ 99 + static unsigned short const icy_ltc2990_addresses[] = { 100 + 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END 101 + }; 102 + 103 + /* 104 + * Additional sensors exposed once this property is applied: 105 + * 106 + * in1 will be the voltage of the 5V rail, divided by 2. 107 + * in2 will be the voltage of the 12V rail, divided by 4. 108 + * temp3 will be measured using a PCB loop next the chip. 109 + */ 110 + static const u32 icy_ltc2990_meas_mode[] = {0, 3}; 111 + 112 + static const struct property_entry icy_ltc2990_props[] = { 113 + PROPERTY_ENTRY_U32_ARRAY("lltc,meas-mode", icy_ltc2990_meas_mode), 114 + { } 115 + }; 116 + 117 + static int icy_probe(struct zorro_dev *z, 118 + const struct zorro_device_id *ent) 119 + { 120 + struct icy_i2c *i2c; 121 + struct i2c_algo_pcf_data *algo_data; 122 + struct fwnode_handle *new_fwnode; 123 + struct i2c_board_info ltc2990_info = { 124 + .type = "ltc2990", 125 + .addr = 0x4c, 126 + }; 127 + 128 + i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL); 129 + if (!i2c) 130 + return -ENOMEM; 131 + 132 + algo_data = devm_kzalloc(&z->dev, sizeof(*algo_data), GFP_KERNEL); 133 + if (!algo_data) 134 + return -ENOMEM; 135 + 136 + dev_set_drvdata(&z->dev, i2c); 137 + i2c->adapter.dev.parent = &z->dev; 138 + i2c->adapter.owner = THIS_MODULE; 139 + /* i2c->adapter.algo assigned by i2c_pcf_add_bus() */ 140 + i2c->adapter.algo_data = algo_data; 141 + strlcpy(i2c->adapter.name, "ICY I2C Zorro adapter", 142 + sizeof(i2c->adapter.name)); 143 + 144 + if (!devm_request_mem_region(&z->dev, 145 + z->resource.start, 146 + 4, i2c->adapter.name)) 147 + return -ENXIO; 148 + 149 + /* Driver private data */ 150 + i2c->reg_s0 = ZTWO_VADDR(z->resource.start); 151 + i2c->reg_s1 = ZTWO_VADDR(z->resource.start + 2); 152 + 153 + algo_data->data = i2c; 154 + algo_data->setpcf = icy_pcf_setpcf; 155 + algo_data->getpcf = icy_pcf_getpcf; 156 + algo_data->getown = icy_pcf_getown; 157 + algo_data->getclock = icy_pcf_getclock; 158 + algo_data->waitforpin = icy_pcf_waitforpin; 159 + 160 + if (i2c_pcf_add_bus(&i2c->adapter)) { 161 + dev_err(&z->dev, "i2c_pcf_add_bus() failed\n"); 162 + return -ENXIO; 163 + } 164 + 165 + dev_info(&z->dev, "ICY I2C controller at %pa, IRQ not implemented\n", 166 + &z->resource.start); 167 + 168 + /* 169 + * The 2019 a1k.org PCBs have an LTC2990 at 0x4c, so start 170 + * it automatically once ltc2990 is modprobed. 171 + * 172 + * in0 is the voltage of the internal 5V power supply. 173 + * temp1 is the temperature inside the chip. 174 + * 175 + * See property_entry above for in1, in2, temp3. 176 + */ 177 + new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL); 178 + if (IS_ERR(new_fwnode)) { 179 + dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n", 180 + PTR_ERR(new_fwnode)); 181 + } else { 182 + /* 183 + * Store the fwnode so we can destroy it on .remove(). 184 + * Only store it on success, as fwnode_remove_software_node() 185 + * is NULL safe, but not PTR_ERR safe. 186 + */ 187 + i2c->ltc2990_fwnode = new_fwnode; 188 + ltc2990_info.fwnode = new_fwnode; 189 + 190 + i2c->ltc2990_client = 191 + i2c_new_probed_device(&i2c->adapter, 192 + &ltc2990_info, 193 + icy_ltc2990_addresses, 194 + NULL); 195 + } 196 + 197 + return 0; 198 + } 199 + 200 + static void icy_remove(struct zorro_dev *z) 201 + { 202 + struct icy_i2c *i2c = dev_get_drvdata(&z->dev); 203 + 204 + i2c_unregister_device(i2c->ltc2990_client); 205 + fwnode_remove_software_node(i2c->ltc2990_fwnode); 206 + 207 + i2c_del_adapter(&i2c->adapter); 208 + } 209 + 210 + static const struct zorro_device_id icy_zorro_tbl[] = { 211 + { ZORRO_ID(VMC, 15, 0), }, 212 + { 0 } 213 + }; 214 + 215 + MODULE_DEVICE_TABLE(zorro, icy_zorro_tbl); 216 + 217 + static struct zorro_driver icy_driver = { 218 + .name = "i2c-icy", 219 + .id_table = icy_zorro_tbl, 220 + .probe = icy_probe, 221 + .remove = icy_remove, 222 + }; 223 + 224 + module_driver(icy_driver, 225 + zorro_register_driver, 226 + zorro_unregister_driver); 227 + 228 + MODULE_AUTHOR("Max Staudt <max@enpas.org>"); 229 + MODULE_DESCRIPTION("I2C bus via PCF8584 on ICY Zorro card"); 230 + MODULE_LICENSE("GPL v2");
+1 -3
drivers/i2c/busses/i2c-imx-lpi2c.c
··· 545 545 static int lpi2c_imx_probe(struct platform_device *pdev) 546 546 { 547 547 struct lpi2c_imx_struct *lpi2c_imx; 548 - struct resource *res; 549 548 unsigned int temp; 550 549 int irq, ret; 551 550 ··· 552 553 if (!lpi2c_imx) 553 554 return -ENOMEM; 554 555 555 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 556 - lpi2c_imx->base = devm_ioremap_resource(&pdev->dev, res); 556 + lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0); 557 557 if (IS_ERR(lpi2c_imx->base)) 558 558 return PTR_ERR(lpi2c_imx->base); 559 559
+13 -4
drivers/i2c/busses/i2c-imx.c
··· 20 20 * 21 21 */ 22 22 23 + #include <linux/acpi.h> 23 24 #include <linux/clk.h> 24 25 #include <linux/completion.h> 25 26 #include <linux/delay.h> ··· 255 254 { /* sentinel */ } 256 255 }; 257 256 MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids); 257 + 258 + static const struct acpi_device_id i2c_imx_acpi_ids[] = { 259 + {"NXP0001", .driver_data = (kernel_ulong_t)&vf610_i2c_hwdata}, 260 + { } 261 + }; 262 + MODULE_DEVICE_TABLE(acpi, i2c_imx_acpi_ids); 258 263 259 264 static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx) 260 265 { ··· 1055 1048 1056 1049 static int i2c_imx_probe(struct platform_device *pdev) 1057 1050 { 1058 - const struct of_device_id *of_id = of_match_device(i2c_imx_dt_ids, 1059 - &pdev->dev); 1060 1051 struct imx_i2c_struct *i2c_imx; 1061 1052 struct resource *res; 1062 1053 struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev); 1063 1054 void __iomem *base; 1064 1055 int irq, ret; 1065 1056 dma_addr_t phy_addr; 1057 + const struct imx_i2c_hwdata *match; 1066 1058 1067 1059 dev_dbg(&pdev->dev, "<%s>\n", __func__); 1068 1060 ··· 1081 1075 if (!i2c_imx) 1082 1076 return -ENOMEM; 1083 1077 1084 - if (of_id) 1085 - i2c_imx->hwdata = of_id->data; 1078 + match = device_get_match_data(&pdev->dev); 1079 + if (match) 1080 + i2c_imx->hwdata = match; 1086 1081 else 1087 1082 i2c_imx->hwdata = (struct imx_i2c_hwdata *) 1088 1083 platform_get_device_id(pdev)->driver_data; ··· 1096 1089 i2c_imx->adapter.nr = pdev->id; 1097 1090 i2c_imx->adapter.dev.of_node = pdev->dev.of_node; 1098 1091 i2c_imx->base = base; 1092 + ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev)); 1099 1093 1100 1094 /* Get I2C clock */ 1101 1095 i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); ··· 1255 1247 .name = DRIVER_NAME, 1256 1248 .pm = &i2c_imx_pm_ops, 1257 1249 .of_match_table = i2c_imx_dt_ids, 1250 + .acpi_match_table = i2c_imx_acpi_ids, 1258 1251 }, 1259 1252 .id_table = imx_i2c_devtype, 1260 1253 };
-2
drivers/i2c/busses/i2c-ismt.c
··· 781 781 if (!priv->hw) 782 782 return -ENOMEM; 783 783 784 - memset(priv->hw, 0, (ISMT_DESC_ENTRIES * sizeof(struct ismt_desc))); 785 - 786 784 priv->head = 0; 787 785 init_completion(&priv->cmp); 788 786
+1 -3
drivers/i2c/busses/i2c-mxs.c
··· 802 802 struct device *dev = &pdev->dev; 803 803 struct mxs_i2c_dev *i2c; 804 804 struct i2c_adapter *adap; 805 - struct resource *res; 806 805 int err, irq; 807 806 808 807 i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL); ··· 813 814 i2c->dev_type = device_id->driver_data; 814 815 } 815 816 816 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 817 - i2c->regs = devm_ioremap_resource(&pdev->dev, res); 817 + i2c->regs = devm_platform_ioremap_resource(pdev, 0); 818 818 if (IS_ERR(i2c->regs)) 819 819 return PTR_ERR(i2c->regs); 820 820
+3 -2
drivers/i2c/busses/i2c-ocores.c
··· 703 703 } 704 704 705 705 if (ocores_algorithm.master_xfer != ocores_xfer_polling) { 706 - ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, 707 - pdev->name, i2c); 706 + ret = devm_request_any_context_irq(&pdev->dev, irq, 707 + ocores_isr, 0, 708 + pdev->name, i2c); 708 709 if (ret) { 709 710 dev_err(&pdev->dev, "Cannot claim IRQ\n"); 710 711 goto err_clk;
+27 -7
drivers/i2c/busses/i2c-piix4.c
··· 72 72 #define PIIX4_BLOCK_DATA 0x14 73 73 74 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 78 /* SB800 constants */ 78 79 #define SB800_PIIX4_SMB_IDX 0xcd6 ··· 807 806 808 807 static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS]; 809 808 static struct i2c_adapter *piix4_aux_adapter; 809 + static int piix4_adapter_count; 810 810 811 811 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, 812 812 bool sb800_main, u8 port, bool notify_imc, 813 - const char *name, struct i2c_adapter **padap) 813 + u8 hw_port_nr, const char *name, 814 + struct i2c_adapter **padap) 814 815 { 815 816 struct i2c_adapter *adap; 816 817 struct i2c_piix4_adapdata *adapdata; ··· 844 841 /* set up the sysfs linkage to our parent device */ 845 842 adap->dev.parent = &dev->dev; 846 843 844 + if (has_acpi_companion(&dev->dev)) { 845 + acpi_preset_companion(&adap->dev, 846 + ACPI_COMPANION(&dev->dev), 847 + hw_port_nr); 848 + } 849 + 847 850 snprintf(adap->name, sizeof(adap->name), 848 851 "SMBus PIIX4 adapter%s at %04x", name, smba); 849 852 ··· 874 865 int port; 875 866 int retval; 876 867 877 - for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) { 868 + if (dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS || 869 + (dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS && 870 + dev->revision >= 0x1F)) { 871 + piix4_adapter_count = HUDSON2_MAIN_PORTS; 872 + } else { 873 + piix4_adapter_count = PIIX4_MAX_ADAPTERS; 874 + } 875 + 876 + for (port = 0; port < piix4_adapter_count; port++) { 877 + u8 hw_port_nr = port == 0 ? 0 : port + 1; 878 + 878 879 retval = piix4_add_adapter(dev, smba, true, port, notify_imc, 880 + hw_port_nr, 879 881 piix4_main_port_names_sb800[port], 880 882 &piix4_main_adapters[port]); 881 883 if (retval < 0) ··· 957 937 return retval; 958 938 959 939 /* Try to register main SMBus adapter, give up if we can't */ 960 - retval = piix4_add_adapter(dev, retval, false, 0, false, "", 961 - &piix4_main_adapters[0]); 940 + retval = piix4_add_adapter(dev, retval, false, 0, false, 0, 941 + "", &piix4_main_adapters[0]); 962 942 if (retval < 0) 963 943 return retval; 964 944 } ··· 984 964 if (retval > 0) { 985 965 /* Try to add the aux adapter if it exists, 986 966 * piix4_add_adapter will clean up if this fails */ 987 - piix4_add_adapter(dev, retval, false, 0, false, 967 + piix4_add_adapter(dev, retval, false, 0, false, 1, 988 968 is_sb800 ? piix4_aux_port_name_sb800 : "", 989 969 &piix4_aux_adapter); 990 970 } ··· 1007 987 1008 988 static void piix4_remove(struct pci_dev *dev) 1009 989 { 1010 - int port = PIIX4_MAX_ADAPTERS; 990 + int port = piix4_adapter_count; 1011 991 1012 992 while (--port >= 0) { 1013 993 if (piix4_main_adapters[port]) {
+13 -12
drivers/i2c/busses/i2c-sprd.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/kernel.h> 15 + #include <linux/module.h> 15 16 #include <linux/of.h> 16 17 #include <linux/of_device.h> 17 18 #include <linux/platform_device.h> ··· 466 465 467 466 i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable"); 468 467 if (IS_ERR(i2c_dev->clk)) { 469 - dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n", 470 - i2c_dev->adap.nr); 471 - i2c_dev->clk = NULL; 468 + dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n", 469 + i2c_dev->adap.nr); 470 + return PTR_ERR(i2c_dev->clk); 472 471 } 473 472 474 473 return 0; ··· 478 477 { 479 478 struct device *dev = &pdev->dev; 480 479 struct sprd_i2c *i2c_dev; 481 - struct resource *res; 482 480 u32 prop; 483 481 int ret; 484 482 ··· 487 487 if (!i2c_dev) 488 488 return -ENOMEM; 489 489 490 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 491 - i2c_dev->base = devm_ioremap_resource(dev, res); 490 + i2c_dev->base = devm_platform_ioremap_resource(pdev, 0); 492 491 if (IS_ERR(i2c_dev->base)) 493 492 return PTR_ERR(i2c_dev->base); 494 493 ··· 519 520 if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000) 520 521 return -EINVAL; 521 522 522 - sprd_i2c_clk_init(i2c_dev); 523 + ret = sprd_i2c_clk_init(i2c_dev); 524 + if (ret) 525 + return ret; 526 + 523 527 platform_set_drvdata(pdev, i2c_dev); 524 528 525 529 ret = clk_prepare_enable(i2c_dev->clk); ··· 646 644 }, 647 645 }; 648 646 649 - static int sprd_i2c_init(void) 650 - { 651 - return platform_driver_register(&sprd_i2c_driver); 652 - } 653 - arch_initcall_sync(sprd_i2c_init); 647 + module_platform_driver(sprd_i2c_driver); 648 + 649 + MODULE_DESCRIPTION("Spreadtrum I2C master controller driver"); 650 + MODULE_LICENSE("GPL v2");
+1 -1
drivers/i2c/busses/i2c-stm32f7.c
··· 1809 1809 I2C_FUNC_SMBUS_I2C_BLOCK; 1810 1810 } 1811 1811 1812 - static struct i2c_algorithm stm32f7_i2c_algo = { 1812 + static const struct i2c_algorithm stm32f7_i2c_algo = { 1813 1813 .master_xfer = stm32f7_i2c_xfer, 1814 1814 .smbus_xfer = stm32f7_i2c_smbus_xfer, 1815 1815 .functionality = stm32f7_i2c_func,
+1 -1
drivers/i2c/busses/i2c-synquacer.c
··· 526 526 .functionality = synquacer_i2c_functionality, 527 527 }; 528 528 529 - static struct i2c_adapter synquacer_i2c_ops = { 529 + static const struct i2c_adapter synquacer_i2c_ops = { 530 530 .owner = THIS_MODULE, 531 531 .name = "synquacer_i2c-adapter", 532 532 .algo = &synquacer_i2c_algo,
+1 -1
drivers/i2c/busses/i2c-taos-evm.c
··· 39 39 }; 40 40 41 41 /* TAOS TSL2550 EVM */ 42 - static struct i2c_board_info tsl2550_info = { 42 + static const struct i2c_board_info tsl2550_info = { 43 43 I2C_BOARD_INFO("tsl2550", 0x39), 44 44 }; 45 45
+27 -29
drivers/i2c/busses/i2c-tegra.c
··· 636 636 dvc_writel(i2c_dev, val, DVC_CTRL_REG1); 637 637 } 638 638 639 - static int tegra_i2c_runtime_resume(struct device *dev) 639 + static int __maybe_unused tegra_i2c_runtime_resume(struct device *dev) 640 640 { 641 641 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 642 642 int ret; ··· 665 665 return 0; 666 666 } 667 667 668 - static int tegra_i2c_runtime_suspend(struct device *dev) 668 + static int __maybe_unused tegra_i2c_runtime_suspend(struct device *dev) 669 669 { 670 670 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 671 671 ··· 712 712 u32 clk_divisor, clk_multiplier; 713 713 u32 tsu_thd; 714 714 u8 tlow, thigh; 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 715 722 716 reset_control_assert(i2c_dev->rst); 723 717 udelay(2); ··· 766 772 if (err) { 767 773 dev_err(i2c_dev->dev, 768 774 "failed changing clock rate: %d\n", err); 769 - goto err; 775 + return err; 770 776 } 771 777 } 772 778 ··· 781 787 782 788 err = tegra_i2c_flush_fifos(i2c_dev); 783 789 if (err) 784 - goto err; 790 + return err; 785 791 786 792 if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg) 787 793 i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE); 788 794 789 795 err = tegra_i2c_wait_for_config_load(i2c_dev); 790 796 if (err) 791 - goto err; 797 + return err; 792 798 793 799 if (i2c_dev->irq_disabled) { 794 800 i2c_dev->irq_disabled = false; 795 801 enable_irq(i2c_dev->irq); 796 802 } 797 803 798 - err: 799 - pm_runtime_put(i2c_dev->dev); 800 - return err; 804 + return 0; 801 805 } 802 806 803 807 static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev) ··· 1608 1616 } 1609 1617 1610 1618 pm_runtime_enable(&pdev->dev); 1611 - if (!pm_runtime_enabled(&pdev->dev)) { 1619 + if (!pm_runtime_enabled(&pdev->dev)) 1612 1620 ret = tegra_i2c_runtime_resume(&pdev->dev); 1613 - if (ret < 0) { 1614 - dev_err(&pdev->dev, "runtime resume failed\n"); 1615 - goto unprepare_div_clk; 1616 - } 1621 + else 1622 + ret = pm_runtime_get_sync(i2c_dev->dev); 1623 + 1624 + if (ret < 0) { 1625 + dev_err(&pdev->dev, "runtime resume failed\n"); 1626 + goto unprepare_div_clk; 1617 1627 } 1618 1628 1619 1629 if (i2c_dev->is_multimaster_mode) { ··· 1659 1665 ret = i2c_add_numbered_adapter(&i2c_dev->adapter); 1660 1666 if (ret) 1661 1667 goto release_dma; 1668 + 1669 + pm_runtime_put(&pdev->dev); 1662 1670 1663 1671 return 0; 1664 1672 ··· 1707 1711 return 0; 1708 1712 } 1709 1713 1710 - #ifdef CONFIG_PM_SLEEP 1711 - static int tegra_i2c_suspend(struct device *dev) 1714 + static int __maybe_unused tegra_i2c_suspend(struct device *dev) 1712 1715 { 1713 1716 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 1714 1717 ··· 1716 1721 return 0; 1717 1722 } 1718 1723 1719 - static int tegra_i2c_resume(struct device *dev) 1724 + static int __maybe_unused tegra_i2c_resume(struct device *dev) 1720 1725 { 1721 1726 struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); 1722 1727 int err; 1723 1728 1729 + err = tegra_i2c_runtime_resume(dev); 1730 + if (err) 1731 + return err; 1732 + 1724 1733 err = tegra_i2c_init(i2c_dev, false); 1734 + if (err) 1735 + return err; 1736 + 1737 + err = tegra_i2c_runtime_suspend(dev); 1725 1738 if (err) 1726 1739 return err; 1727 1740 ··· 1739 1736 } 1740 1737 1741 1738 static const struct dev_pm_ops tegra_i2c_pm = { 1742 - SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) 1739 + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) 1743 1740 SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, 1744 1741 NULL) 1745 1742 }; 1746 - 1747 - #define TEGRA_I2C_PM (&tegra_i2c_pm) 1748 - #else 1749 - #define TEGRA_I2C_PM NULL 1750 - #endif 1751 1743 1752 1744 static struct platform_driver tegra_i2c_driver = { 1753 1745 .probe = tegra_i2c_probe, ··· 1750 1752 .driver = { 1751 1753 .name = "tegra-i2c", 1752 1754 .of_match_table = tegra_i2c_of_match, 1753 - .pm = TEGRA_I2C_PM, 1755 + .pm = &tegra_i2c_pm, 1754 1756 }, 1755 1757 }; 1756 1758
+2 -24
drivers/i2c/busses/i2c-uniphier-f.c
··· 108 108 if (fifo_space-- <= 0) 109 109 break; 110 110 111 - dev_dbg(&priv->adap.dev, "write data: %02x\n", *priv->buf); 112 111 writel(*priv->buf++, priv->membase + UNIPHIER_FI2C_DTTX); 113 112 priv->len--; 114 113 } ··· 123 124 break; 124 125 125 126 *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX); 126 - dev_dbg(&priv->adap.dev, "read data: %02x\n", priv->buf[-1]); 127 127 priv->len--; 128 128 } 129 129 } ··· 140 142 141 143 static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv) 142 144 { 143 - dev_dbg(&priv->adap.dev, "stop condition\n"); 144 - 145 145 priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP; 146 146 uniphier_fi2c_set_irqs(priv); 147 147 writel(UNIPHIER_FI2C_CR_MST | UNIPHIER_FI2C_CR_STO, ··· 156 160 irq_status = readl(priv->membase + UNIPHIER_FI2C_INT); 157 161 irq_status &= priv->enabled_irqs; 158 162 159 - dev_dbg(&priv->adap.dev, 160 - "interrupt: enabled_irqs=%04x, irq_status=%04x\n", 161 - priv->enabled_irqs, irq_status); 162 - 163 163 if (irq_status & UNIPHIER_FI2C_INT_STOP) 164 164 goto complete; 165 165 166 166 if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) { 167 - dev_dbg(&priv->adap.dev, "arbitration lost\n"); 168 167 priv->error = -EAGAIN; 169 168 goto complete; 170 169 } 171 170 172 171 if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) { 173 - dev_dbg(&priv->adap.dev, "could not get ACK\n"); 174 172 priv->error = -ENXIO; 175 173 if (priv->flags & UNIPHIER_FI2C_RD) { 176 174 /* ··· 205 215 if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) { 206 216 if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE && 207 217 !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) { 208 - dev_dbg(&priv->adap.dev, 209 - "enable read byte count IRQ\n"); 210 218 priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB; 211 219 uniphier_fi2c_set_irqs(priv); 212 220 priv->flags |= UNIPHIER_FI2C_BYTE_WISE; 213 221 } 214 - if (priv->len <= 1) { 215 - dev_dbg(&priv->adap.dev, "set NACK\n"); 222 + if (priv->len <= 1) 216 223 writel(UNIPHIER_FI2C_CR_MST | 217 224 UNIPHIER_FI2C_CR_NACK, 218 225 priv->membase + UNIPHIER_FI2C_CR); 219 - } 220 226 } 221 227 222 228 goto handled; ··· 320 334 bool is_read = msg->flags & I2C_M_RD; 321 335 unsigned long time_left, flags; 322 336 323 - dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, repeat=%d, stop=%d\n", 324 - is_read ? "receive" : "transmit", msg->addr, msg->len, 325 - repeat, stop); 326 - 327 337 priv->len = msg->len; 328 338 priv->buf = msg->buf; 329 339 priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS; ··· 341 359 else 342 360 uniphier_fi2c_tx_init(priv, msg->addr, repeat); 343 361 344 - dev_dbg(&adap->dev, "start condition\n"); 345 362 /* 346 363 * For a repeated START condition, writing a slave address to the FIFO 347 364 * kicks the controller. So, the UNIPHIER_FI2C_CR register should be ··· 364 383 uniphier_fi2c_recover(priv); 365 384 return -ETIMEDOUT; 366 385 } 367 - dev_dbg(&adap->dev, "complete\n"); 368 386 369 387 if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) { 370 388 u32 status; ··· 518 538 { 519 539 struct device *dev = &pdev->dev; 520 540 struct uniphier_fi2c_priv *priv; 521 - struct resource *regs; 522 541 u32 bus_speed; 523 542 unsigned long clk_rate; 524 543 int irq, ret; ··· 526 547 if (!priv) 527 548 return -ENOMEM; 528 549 529 - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 530 - priv->membase = devm_ioremap_resource(dev, regs); 550 + priv->membase = devm_platform_ioremap_resource(pdev, 0); 531 551 if (IS_ERR(priv->membase)) 532 552 return PTR_ERR(priv->membase); 533 553
+4 -18
drivers/i2c/busses/i2c-uniphier.c
··· 71 71 reinit_completion(&priv->comp); 72 72 73 73 txdata |= UNIPHIER_I2C_DTRM_IRQEN; 74 - dev_dbg(&adap->dev, "write data: 0x%04x\n", txdata); 75 74 writel(txdata, priv->membase + UNIPHIER_I2C_DTRM); 76 75 77 76 time_left = wait_for_completion_timeout(&priv->comp, adap->timeout); ··· 80 81 } 81 82 82 83 rxdata = readl(priv->membase + UNIPHIER_I2C_DREC); 83 - dev_dbg(&adap->dev, "read data: 0x%04x\n", rxdata); 84 - 85 84 if (rxdatap) 86 85 *rxdatap = rxdata; 87 86 ··· 95 98 if (ret) 96 99 return ret; 97 100 98 - if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) { 99 - dev_dbg(&adap->dev, "arbitration lost\n"); 101 + if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) 100 102 return -EAGAIN; 101 - } 102 - if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) { 103 - dev_dbg(&adap->dev, "could not get ACK\n"); 103 + 104 + if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) 104 105 return -ENXIO; 105 - } 106 106 107 107 return 0; 108 108 } ··· 109 115 { 110 116 int ret; 111 117 112 - dev_dbg(&adap->dev, "start condition\n"); 113 118 ret = uniphier_i2c_send_byte(adap, addr << 1 | 114 119 UNIPHIER_I2C_DTRM_STA | 115 120 UNIPHIER_I2C_DTRM_NACK); ··· 130 137 { 131 138 int ret; 132 139 133 - dev_dbg(&adap->dev, "start condition\n"); 134 140 ret = uniphier_i2c_send_byte(adap, addr << 1 | 135 141 UNIPHIER_I2C_DTRM_STA | 136 142 UNIPHIER_I2C_DTRM_NACK | ··· 153 161 154 162 static int uniphier_i2c_stop(struct i2c_adapter *adap) 155 163 { 156 - dev_dbg(&adap->dev, "stop condition\n"); 157 164 return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO | 158 165 UNIPHIER_I2C_DTRM_NACK); 159 166 } ··· 163 172 bool is_read = msg->flags & I2C_M_RD; 164 173 bool recovery = false; 165 174 int ret; 166 - 167 - dev_dbg(&adap->dev, "%s: addr=0x%02x, len=%d, stop=%d\n", 168 - is_read ? "receive" : "transmit", msg->addr, msg->len, stop); 169 175 170 176 if (is_read) 171 177 ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf); ··· 314 326 { 315 327 struct device *dev = &pdev->dev; 316 328 struct uniphier_i2c_priv *priv; 317 - struct resource *regs; 318 329 u32 bus_speed; 319 330 unsigned long clk_rate; 320 331 int irq, ret; ··· 322 335 if (!priv) 323 336 return -ENOMEM; 324 337 325 - regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 326 - priv->membase = devm_ioremap_resource(dev, regs); 338 + priv->membase = devm_platform_ioremap_resource(pdev, 0); 327 339 if (IS_ERR(priv->membase)) 328 340 return PTR_ERR(priv->membase); 329 341
+9 -11
drivers/i2c/i2c-core-base.c
··· 350 350 return -ENODEV; 351 351 352 352 if (client->flags & I2C_CLIENT_WAKE) { 353 - int wakeirq = -ENOENT; 353 + int wakeirq; 354 354 355 - if (dev->of_node) { 356 - wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); 357 - if (wakeirq == -EPROBE_DEFER) 358 - return wakeirq; 359 - } 355 + wakeirq = of_irq_get_byname(dev->of_node, "wakeup"); 356 + if (wakeirq == -EPROBE_DEFER) 357 + return wakeirq; 360 358 361 359 device_init_wakeup(&client->dev, true); 362 360 ··· 964 966 EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device); 965 967 966 968 /** 967 - * i2c_new_secondary_device - Helper to get the instantiated secondary address 969 + * i2c_new_ancillary_device - Helper to get the instantiated secondary address 968 970 * and create the associated device 969 971 * @client: Handle to the primary client 970 972 * @name: Handle to specify which secondary address to get ··· 983 985 * cell whose "reg-names" value matches the slave name. 984 986 * 985 987 * This returns the new i2c client, which should be saved for later use with 986 - * i2c_unregister_device(); or NULL to indicate an error. 988 + * i2c_unregister_device(); or an ERR_PTR to describe the error. 987 989 */ 988 - struct i2c_client *i2c_new_secondary_device(struct i2c_client *client, 990 + struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, 989 991 const char *name, 990 992 u16 default_addr) 991 993 { ··· 1000 1002 } 1001 1003 1002 1004 dev_dbg(&client->adapter->dev, "Address for %s : 0x%x\n", name, addr); 1003 - return i2c_new_dummy(client->adapter, addr); 1005 + return i2c_new_dummy_device(client->adapter, addr); 1004 1006 } 1005 - EXPORT_SYMBOL_GPL(i2c_new_secondary_device); 1007 + EXPORT_SYMBOL_GPL(i2c_new_ancillary_device); 1006 1008 1007 1009 /* ------------------------------------------------------------------------- */ 1008 1010
+31 -11
drivers/i2c/i2c-slave-eeprom.c
··· 11 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 21 #include <linux/i2c.h> 15 22 #include <linux/init.h> 16 23 #include <linux/module.h> ··· 28 21 29 22 struct eeprom_data { 30 23 struct bin_attribute bin; 31 - bool first_write; 32 24 spinlock_t buffer_lock; 33 - u8 buffer_idx; 25 + u16 buffer_idx; 26 + u16 address_mask; 27 + u8 num_address_bytes; 28 + u8 idx_write_cnt; 34 29 u8 buffer[]; 35 30 }; 31 + 32 + #define I2C_SLAVE_BYTELEN GENMASK(15, 0) 33 + #define I2C_SLAVE_FLAG_ADDR16 BIT(16) 34 + #define I2C_SLAVE_DEVICE_MAGIC(_len, _flags) ((_flags) | (_len)) 36 35 37 36 static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, 38 37 enum i2c_slave_event event, u8 *val) ··· 47 34 48 35 switch (event) { 49 36 case I2C_SLAVE_WRITE_RECEIVED: 50 - if (eeprom->first_write) { 51 - eeprom->buffer_idx = *val; 52 - eeprom->first_write = false; 37 + if (eeprom->idx_write_cnt < eeprom->num_address_bytes) { 38 + if (eeprom->idx_write_cnt == 0) 39 + eeprom->buffer_idx = 0; 40 + eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8); 41 + eeprom->idx_write_cnt++; 53 42 } else { 54 43 spin_lock(&eeprom->buffer_lock); 55 - eeprom->buffer[eeprom->buffer_idx++] = *val; 44 + eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val; 56 45 spin_unlock(&eeprom->buffer_lock); 57 46 } 58 47 break; ··· 65 50 /* fallthrough */ 66 51 case I2C_SLAVE_READ_REQUESTED: 67 52 spin_lock(&eeprom->buffer_lock); 68 - *val = eeprom->buffer[eeprom->buffer_idx]; 53 + *val = eeprom->buffer[eeprom->buffer_idx & eeprom->address_mask]; 69 54 spin_unlock(&eeprom->buffer_lock); 70 55 /* 71 56 * Do not increment buffer_idx here, because we don't know if ··· 76 61 77 62 case I2C_SLAVE_STOP: 78 63 case I2C_SLAVE_WRITE_REQUESTED: 79 - eeprom->first_write = true; 64 + eeprom->idx_write_cnt = 0; 80 65 break; 81 66 82 67 default: ··· 120 105 { 121 106 struct eeprom_data *eeprom; 122 107 int ret; 123 - unsigned size = id->driver_data; 108 + unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data); 109 + unsigned int flag_addr16 = FIELD_GET(I2C_SLAVE_FLAG_ADDR16, id->driver_data); 124 110 125 111 eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); 126 112 if (!eeprom) 127 113 return -ENOMEM; 128 114 129 - eeprom->first_write = true; 115 + eeprom->idx_write_cnt = 0; 116 + eeprom->num_address_bytes = flag_addr16 ? 2 : 1; 117 + eeprom->address_mask = size - 1; 130 118 spin_lock_init(&eeprom->buffer_lock); 131 119 i2c_set_clientdata(client, eeprom); 132 120 ··· 164 146 } 165 147 166 148 static const struct i2c_device_id i2c_slave_eeprom_id[] = { 167 - { "slave-24c02", 2048 / 8 }, 149 + { "slave-24c02", I2C_SLAVE_DEVICE_MAGIC(2048 / 8, 0) }, 150 + { "slave-24c32", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) }, 151 + { "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) }, 168 152 { } 169 153 }; 170 154 MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id);
+3 -3
drivers/media/i2c/adv748x/adv748x-core.c
··· 183 183 int ret; 184 184 185 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 187 state->client, 188 188 adv748x_default_addresses[i].name, 189 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 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 196 ret = adv748x_configure_regmap(state, i);
+12 -10
drivers/media/i2c/adv7604.c
··· 2862 2862 { 2863 2863 unsigned int i; 2864 2864 2865 - for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) { 2866 - if (state->i2c_clients[i]) 2867 - i2c_unregister_device(state->i2c_clients[i]); 2868 - } 2865 + for (i = 1; i < ARRAY_SIZE(state->i2c_clients); ++i) 2866 + i2c_unregister_device(state->i2c_clients[i]); 2869 2867 } 2870 2868 2871 2869 static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd, ··· 2876 2878 struct i2c_client *new_client; 2877 2879 2878 2880 if (pdata && pdata->i2c_addresses[page]) 2879 - new_client = i2c_new_dummy(client->adapter, 2881 + new_client = i2c_new_dummy_device(client->adapter, 2880 2882 pdata->i2c_addresses[page]); 2881 2883 else 2882 - new_client = i2c_new_secondary_device(client, 2884 + new_client = i2c_new_ancillary_device(client, 2883 2885 adv76xx_default_addresses[page].name, 2884 2886 adv76xx_default_addresses[page].default_addr); 2885 2887 2886 - if (new_client) 2888 + if (!IS_ERR(new_client)) 2887 2889 io_write(sd, io_reg, new_client->addr << 1); 2888 2890 2889 2891 return new_client; ··· 3514 3516 } 3515 3517 3516 3518 for (i = 1; i < ADV76XX_PAGE_MAX; ++i) { 3519 + struct i2c_client *dummy_client; 3520 + 3517 3521 if (!(BIT(i) & state->info->page_mask)) 3518 3522 continue; 3519 3523 3520 - state->i2c_clients[i] = adv76xx_dummy_client(sd, i); 3521 - if (!state->i2c_clients[i]) { 3522 - err = -EINVAL; 3524 + dummy_client = adv76xx_dummy_client(sd, i); 3525 + if (IS_ERR(dummy_client)) { 3526 + err = PTR_ERR(dummy_client); 3523 3527 v4l2_err(sd, "failed to create i2c client %u\n", i); 3524 3528 goto err_i2c; 3525 3529 } 3530 + 3531 + state->i2c_clients[i] = dummy_client; 3526 3532 } 3527 3533 3528 3534 INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug,
-1
drivers/misc/eeprom/at24.c
··· 14 14 #include <linux/delay.h> 15 15 #include <linux/mutex.h> 16 16 #include <linux/mod_devicetable.h> 17 - #include <linux/log2.h> 18 17 #include <linux/bitops.h> 19 18 #include <linux/jiffies.h> 20 19 #include <linux/property.h>
+24 -2
drivers/watchdog/iTCO_wdt.c
··· 48 48 49 49 /* Includes */ 50 50 #include <linux/acpi.h> /* For ACPI support */ 51 + #include <linux/bits.h> /* For BIT() */ 51 52 #include <linux/module.h> /* For module specific items */ 52 53 #include <linux/moduleparam.h> /* For new moduleparam's */ 53 54 #include <linux/types.h> /* For standard types (like size_t) */ ··· 216 215 return 0; 217 216 } 218 217 218 + static int update_no_reboot_bit_cnt(void *priv, bool set) 219 + { 220 + struct iTCO_wdt_private *p = priv; 221 + u16 val, newval; 222 + 223 + val = inw(TCO1_CNT(p)); 224 + if (set) 225 + val |= BIT(0); 226 + else 227 + val &= ~BIT(0); 228 + outw(val, TCO1_CNT(p)); 229 + newval = inw(TCO1_CNT(p)); 230 + 231 + /* make sure the update is successful */ 232 + return val != newval ? -EIO : 0; 233 + } 234 + 219 235 static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p, 220 236 struct itco_wdt_platform_data *pdata) 221 237 { ··· 242 224 return; 243 225 } 244 226 245 - if (p->iTCO_version >= 2) 227 + if (p->iTCO_version >= 6) 228 + p->update_no_reboot_bit = update_no_reboot_bit_cnt; 229 + else if (p->iTCO_version >= 2) 246 230 p->update_no_reboot_bit = update_no_reboot_bit_mem; 247 231 else if (p->iTCO_version == 1) 248 232 p->update_no_reboot_bit = update_no_reboot_bit_pci; ··· 472 452 * Get the Memory-Mapped GCS or PMC register, we need it for the 473 453 * NO_REBOOT flag (TCO v2 and v3). 474 454 */ 475 - if (p->iTCO_version >= 2 && !pdata->update_no_reboot_bit) { 455 + if (p->iTCO_version >= 2 && p->iTCO_version < 6 && 456 + !pdata->update_no_reboot_bit) { 476 457 p->gcs_pmc_res = platform_get_resource(pdev, 477 458 IORESOURCE_MEM, 478 459 ICH_RES_MEM_GCS_PMC); ··· 523 502 524 503 /* Clear out the (probably old) status */ 525 504 switch (p->iTCO_version) { 505 + case 6: 526 506 case 5: 527 507 case 4: 528 508 outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */
+1 -1
include/linux/i2c.h
··· 473 473 devm_i2c_new_dummy_device(struct device *dev, struct i2c_adapter *adap, u16 address); 474 474 475 475 extern struct i2c_client * 476 - i2c_new_secondary_device(struct i2c_client *client, 476 + i2c_new_ancillary_device(struct i2c_client *client, 477 477 const char *name, 478 478 u16 default_addr); 479 479