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 ...
Unified · Split
| @@ -1,7 +1,9 @@ | ||
| 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. |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -7865,6 +7865,12 @@ S: Maintained · 7864 unmodified lines | ||
| 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 |
| @@ -13791,7 +13797,7 @@ F: drivers/clk/renesas/ · 5920 unmodified lines | ||
| 13791 | 13797 | RENESAS EMEV2 I2C DRIVER |
| 13792 | 13798 | M: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| 13793 | 13799 | S: Supported |
| 13794 | −F: Documentation/devicetree/bindings/i2c/i2c-emev2.txt | |
| 13800 | +F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt | |
| 13795 | 13801 | F: drivers/i2c/busses/i2c-emev2.c |
| 13796 | 13802 | |
| 13797 | 13803 | RENESAS ETHERNET DRIVERS |
| @@ -13813,15 +13819,15 @@ F: drivers/iio/adc/rcar-gyroadc.c · 15 unmodified lines | ||
| 13813 | 13819 | RENESAS R-CAR I2C DRIVERS |
| 13814 | 13820 | M: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| 13815 | 13821 | S: Supported |
| 13816 | −F: Documentation/devicetree/bindings/i2c/i2c-rcar.txt | |
| 13817 | −F: Documentation/devicetree/bindings/i2c/i2c-sh_mobile.txt | |
| 13822 | +F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt | |
| 13823 | +F: Documentation/devicetree/bindings/i2c/renesas,iic.txt | |
| 13818 | 13824 | F: drivers/i2c/busses/i2c-rcar.c |
| 13819 | 13825 | F: drivers/i2c/busses/i2c-sh_mobile.c |
| 13820 | 13826 | |
| 13821 | 13827 | RENESAS RIIC DRIVER |
| 13822 | 13828 | M: Chris Brandt <chris.brandt@renesas.com> |
| 13823 | 13829 | S: Supported |
| 13824 | −F: Documentation/devicetree/bindings/i2c/i2c-riic.txt | |
| 13830 | +F: Documentation/devicetree/bindings/i2c/renesas,riic.txt | |
| 13825 | 13831 | F: drivers/i2c/busses/i2c-riic.c |
| 13826 | 13832 | |
| 13827 | 13833 | RENESAS USB PHY DRIVER |
| @@ -160,11 +160,17 @@ static const struct apd_device_desc hip08_i2c_desc = { · 159 unmodified lines | ||
| 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, |
| 166 | 167 | }; |
| 167 | 168 | |
| 169 | +static const struct apd_device_desc nxp_i2c_desc = { | |
| 170 | + .setup = acpi_apd_setup, | |
| 171 | + .fixed_clk_rate = 350000000, | |
| 172 | +}; | |
| 173 | + | |
| 168 | 174 | static const struct apd_device_desc hip08_spi_desc = { |
| 169 | 175 | .setup = acpi_apd_setup, |
| 170 | 176 | .fixed_clk_rate = 250000000, |
| @@ -238,6 +244,7 @@ static const struct acpi_device_id acpi_apd_device_ids[] = { · 67 unmodified lines | ||
| 238 | 244 | { "HISI02A1", APD_ADDR(hip07_i2c_desc) }, |
| 239 | 245 | { "HISI02A2", APD_ADDR(hip08_i2c_desc) }, |
| 240 | 246 | { "HISI0173", APD_ADDR(hip08_spi_desc) }, |
| 247 | + { "NXP0001", APD_ADDR(nxp_i2c_desc) }, | |
| 241 | 248 | #endif |
| 242 | 249 | { } |
| 243 | 250 | }; |
| @@ -978,10 +978,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv) · 977 unmodified lines | ||
| 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,20 +1162,20 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) · 174 unmodified lines | ||
| 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 | |
| @@ -429,6 +429,7 @@ config I2C_AXXIA · 428 unmodified lines | ||
| 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 | |
| @@ -977,7 +978,7 @@ config I2C_SIRF · 542 unmodified lines | ||
| 977 | 978 | will be called i2c-sirf. |
| 978 | 979 | |
| 979 | 980 | config I2C_SPRD |
| 980 | − bool "Spreadtrum I2C interface" | |
| 981 | + tristate "Spreadtrum I2C interface" | |
| 981 | 982 | depends on I2C=y && ARCH_SPRD |
| 982 | 983 | help |
| 983 | 984 | If you say yes to this option, support will be included for the |
| @@ -1309,6 +1310,20 @@ config I2C_ELEKTOR · 325 unmodified lines | ||
| 1309 | 1310 | This support is also available as a module. If so, the module |
| 1310 | 1311 | will be called i2c-elektor. |
| 1311 | 1312 | |
| 1313 | +config I2C_ICY | |
| 1314 | + tristate "ICY Zorro card" | |
| 1315 | + depends on ZORRO | |
| 1316 | + select I2C_ALGOPCF | |
| 1317 | + help | |
| 1318 | + This supports the PCF8584 Zorro bus I2C adapter, known as ICY. | |
| 1319 | + Say Y if you own such an adapter. | |
| 1320 | + | |
| 1321 | + This support is also available as a module. If so, the module | |
| 1322 | + will be called i2c-icy. | |
| 1323 | + | |
| 1324 | + If you have a 2019 edition board with an LTC2990 sensor at address | |
| 1325 | + 0x4c, loading the module 'ltc2990' is sufficient to enable it. | |
| 1326 | + | |
| 1312 | 1327 | config I2C_MLXCPLD |
| 1313 | 1328 | tristate "Mellanox I2C driver" |
| 1314 | 1329 | depends on X86_64 |
| @@ -140,6 +140,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o · 139 unmodified lines | ||
| 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 |
| @@ -77,6 +77,40 @@ · 76 unmodified lines | ||
| 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 |
| @@ -111,6 +145,8 @@ struct axxia_i2c_dev { · 28 unmodified lines | ||
| 111 | 145 | struct clk *i2c_clk; |
| 112 | 146 | u32 bus_clk_rate; |
| 113 | 147 | bool last; |
| 148 | + struct i2c_client *slave; | |
| 149 | + int irq; | |
| 114 | 150 | }; |
| 115 | 151 | |
| 116 | 152 | static void i2c_int_disable(struct axxia_i2c_dev *idev, u32 mask) |
| @@ -276,13 +312,65 @@ static int axxia_i2c_fill_tx_fifo(struct axxia_i2c_dev *idev) · 159 unmodified lines | ||
| 276 | 312 | return ret; |
| 277 | 313 | } |
| 278 | 314 | |
| 315 | +static void axxia_i2c_slv_fifo_event(struct axxia_i2c_dev *idev) | |
| 316 | +{ | |
| 317 | + u32 fifo_status = readl(idev->base + SLV_RX_FIFO); | |
| 318 | + u8 val; | |
| 319 | + | |
| 320 | + dev_dbg(idev->dev, "slave irq fifo_status=0x%x\n", fifo_status); | |
| 321 | + | |
| 322 | + if (fifo_status & SLV_FIFO_DV1) { | |
| 323 | + if (fifo_status & SLV_FIFO_STRC) | |
| 324 | + i2c_slave_event(idev->slave, | |
| 325 | + I2C_SLAVE_WRITE_REQUESTED, &val); | |
| 326 | + | |
| 327 | + val = readl(idev->base + SLV_DATA); | |
| 328 | + i2c_slave_event(idev->slave, I2C_SLAVE_WRITE_RECEIVED, &val); | |
| 329 | + } | |
| 330 | + if (fifo_status & SLV_FIFO_STPC) { | |
| 331 | + readl(idev->base + SLV_DATA); /* dummy read */ | |
| 332 | + i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val); | |
| 333 | + } | |
| 334 | + if (fifo_status & SLV_FIFO_RSC) | |
| 335 | + readl(idev->base + SLV_DATA); /* dummy read */ | |
| 336 | +} | |
| 337 | + | |
| 338 | +static irqreturn_t axxia_i2c_slv_isr(struct axxia_i2c_dev *idev) | |
| 339 | +{ | |
| 340 | + u32 status = readl(idev->base + SLV_INT_STATUS); | |
| 341 | + u8 val; | |
| 342 | + | |
| 343 | + dev_dbg(idev->dev, "slave irq status=0x%x\n", status); | |
| 344 | + | |
| 345 | + if (status & SLV_STATUS_RFH) | |
| 346 | + axxia_i2c_slv_fifo_event(idev); | |
| 347 | + if (status & SLV_STATUS_SRS1) { | |
| 348 | + i2c_slave_event(idev->slave, I2C_SLAVE_READ_REQUESTED, &val); | |
| 349 | + writel(val, idev->base + SLV_DATA); | |
| 350 | + } | |
| 351 | + if (status & SLV_STATUS_SRND1) { | |
| 352 | + i2c_slave_event(idev->slave, I2C_SLAVE_READ_PROCESSED, &val); | |
| 353 | + writel(val, idev->base + SLV_DATA); | |
| 354 | + } | |
| 355 | + if (status & SLV_STATUS_SRC1) | |
| 356 | + i2c_slave_event(idev->slave, I2C_SLAVE_STOP, &val); | |
| 357 | + | |
| 358 | + writel(INT_SLV, idev->base + INTERRUPT_STATUS); | |
| 359 | + return IRQ_HANDLED; | |
| 360 | +} | |
| 361 | + | |
| 279 | 362 | static irqreturn_t axxia_i2c_isr(int irq, void *_dev) |
| 280 | 363 | { |
| 281 | 364 | struct axxia_i2c_dev *idev = _dev; |
| 365 | + irqreturn_t ret = IRQ_NONE; | |
| 282 | 366 | u32 status; |
| 283 | 367 | |
| 284 | − if (!(readl(idev->base + INTERRUPT_STATUS) & INT_MST)) | |
| 285 | − return IRQ_NONE; | |
| 368 | + status = readl(idev->base + INTERRUPT_STATUS); | |
| 369 | + | |
| 370 | + if (status & INT_SLV) | |
| 371 | + ret = axxia_i2c_slv_isr(idev); | |
| 372 | + if (!(status & INT_MST)) | |
| 373 | + return ret; | |
| 286 | 374 | |
| 287 | 375 | /* Read interrupt status bits */ |
| 288 | 376 | status = readl(idev->base + MST_INT_STATUS); |
| @@ -583,9 +671,58 @@ static u32 axxia_i2c_func(struct i2c_adapter *adap) · 294 unmodified lines | ||
| 583 | 671 | return caps; |
| 584 | 672 | } |
| 585 | 673 | |
| 674 | +static int axxia_i2c_reg_slave(struct i2c_client *slave) | |
| 675 | +{ | |
| 676 | + struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter); | |
| 677 | + u32 slv_int_mask = SLV_STATUS_RFH; | |
| 678 | + u32 dec_ctl; | |
| 679 | + | |
| 680 | + if (idev->slave) | |
| 681 | + return -EBUSY; | |
| 682 | + | |
| 683 | + idev->slave = slave; | |
| 684 | + | |
| 685 | + /* Enable slave mode as well */ | |
| 686 | + writel(GLOBAL_MST_EN | GLOBAL_SLV_EN, idev->base + GLOBAL_CONTROL); | |
| 687 | + writel(INT_MST | INT_SLV, idev->base + INTERRUPT_ENABLE); | |
| 688 | + | |
| 689 | + /* Set slave address */ | |
| 690 | + dec_ctl = SLV_ADDR_DEC_SA1E; | |
| 691 | + if (slave->flags & I2C_CLIENT_TEN) | |
| 692 | + dec_ctl |= SLV_ADDR_DEC_SA1M; | |
| 693 | + | |
| 694 | + writel(SLV_RX_ACSA1, idev->base + SLV_RX_CTL); | |
| 695 | + writel(dec_ctl, idev->base + SLV_ADDR_DEC_CTL); | |
| 696 | + writel(slave->addr, idev->base + SLV_ADDR_1); | |
| 697 | + | |
| 698 | + /* Enable interrupts */ | |
| 699 | + slv_int_mask |= SLV_STATUS_SRS1 | SLV_STATUS_SRRS1 | SLV_STATUS_SRND1; | |
| 700 | + slv_int_mask |= SLV_STATUS_SRC1; | |
| 701 | + writel(slv_int_mask, idev->base + SLV_INT_ENABLE); | |
| 702 | + | |
| 703 | + return 0; | |
| 704 | +} | |
| 705 | + | |
| 706 | +static int axxia_i2c_unreg_slave(struct i2c_client *slave) | |
| 707 | +{ | |
| 708 | + struct axxia_i2c_dev *idev = i2c_get_adapdata(slave->adapter); | |
| 709 | + | |
| 710 | + /* Disable slave mode */ | |
| 711 | + writel(GLOBAL_MST_EN, idev->base + GLOBAL_CONTROL); | |
| 712 | + writel(INT_MST, idev->base + INTERRUPT_ENABLE); | |
| 713 | + | |
| 714 | + synchronize_irq(idev->irq); | |
| 715 | + | |
| 716 | + idev->slave = NULL; | |
| 717 | + | |
| 718 | + return 0; | |
| 719 | +} | |
| 720 | + | |
| 586 | 721 | static const struct i2c_algorithm axxia_i2c_algo = { |
| 587 | 722 | .master_xfer = axxia_i2c_xfer, |
| 588 | 723 | .functionality = axxia_i2c_func, |
| 724 | + .reg_slave = axxia_i2c_reg_slave, | |
| 725 | + .unreg_slave = axxia_i2c_unreg_slave, | |
| 589 | 726 | }; |
| 590 | 727 | |
| 591 | 728 | static const struct i2c_adapter_quirks axxia_i2c_quirks = { |
| @@ -599,7 +736,6 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 599 | 736 | struct axxia_i2c_dev *idev = NULL; |
| 600 | 737 | struct resource *res; |
| 601 | 738 | void __iomem *base; |
| 602 | − int irq; | |
| 603 | 739 | int ret = 0; |
| 604 | 740 | |
| 605 | 741 | idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL); |
| @@ -611,10 +747,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 611 | 747 | if (IS_ERR(base)) |
| 612 | 748 | return PTR_ERR(base); |
| 613 | 749 | |
| 614 | − irq = platform_get_irq(pdev, 0); | |
| 615 | − if (irq < 0) { | |
| 750 | + idev->irq = platform_get_irq(pdev, 0); | |
| 751 | + if (idev->irq < 0) { | |
| 616 | 752 | dev_err(&pdev->dev, "missing interrupt resource\n"); |
| 617 | − return irq; | |
| 753 | + return idev->irq; | |
| 618 | 754 | } |
| 619 | 755 | |
| 620 | 756 | idev->i2c_clk = devm_clk_get(&pdev->dev, "i2c"); |
| @@ -643,10 +779,10 @@ static int axxia_i2c_probe(struct platform_device *pdev) · 22 unmodified lines | ||
| 643 | 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 | 783 | pdev->name, idev); |
| 648 | 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 | 786 | goto error_disable_clk; |
| 651 | 787 | } |
| 652 | 788 | |
| @@ -808,7 +808,7 @@ static struct i2c_algorithm bcm_iproc_algo = { · 807 unmodified lines | ||
| 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,7 +922,9 @@ static int bcm_iproc_i2c_probe(struct platform_device *pdev) · 107 unmodified lines | ||
| 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; |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 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 | |
| @@ -389,7 +390,7 @@ static const struct i2c_algorithm bcm2835_i2c_algo = { · 371 unmodified lines | ||
| 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 | 394 | * http://www.advamation.com/knowhow/raspberrypi/rpi-i2c-bug.html |
| 394 | 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) · 75 unmodified lines | ||
| 471 | 472 | i2c_set_adapdata(adap, i2c_dev); |
| 472 | 473 | adap->owner = THIS_MODULE; |
| 473 | 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 | 477 | adap->algo = &bcm2835_i2c_algo; |
| 476 | 478 | adap->dev.parent = &pdev->dev; |
| 477 | 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 | 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) · 19 unmodified lines | ||
| 501 | 503 | } |
| 502 | 504 | |
| 503 | 505 | static const struct of_device_id bcm2835_i2c_of_match[] = { |
| 504 | − { .compatible = "brcm,bcm2835-i2c" }, | |
| 506 | + { .compatible = "brcm,bcm2711-i2c" }, | |
| 507 | + { .compatible = "brcm,bcm2835-i2c", .data = &bcm2835_i2c_quirks }, | |
| 505 | 508 | {}, |
| 506 | 509 | }; |
| 507 | 510 | MODULE_DEVICE_TABLE(of, bcm2835_i2c_of_match); |
| @@ -178,6 +178,51 @@ static const struct i2c_algorithm cht_wc_i2c_adap_algo = { · 177 unmodified lines | ||
| 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 | { |
| @@ -286,6 +331,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) · 102 unmodified lines | ||
| 286 | 331 | adap->adapter.owner = THIS_MODULE; |
| 287 | 332 | adap->adapter.class = I2C_CLASS_HWMON; |
| 288 | 333 | adap->adapter.algo = &cht_wc_i2c_adap_algo; |
| 334 | + adap->adapter.lock_ops = &cht_wc_i2c_adap_lock_ops; | |
| 289 | 335 | strlcpy(adap->adapter.name, "PMIC I2C Adapter", |
| 290 | 336 | sizeof(adap->adapter.name)); |
| 291 | 337 | adap->adapter.dev.parent = &pdev->dev; |
| @@ -363,8 +409,7 @@ static int cht_wc_i2c_adap_i2c_remove(struct platform_device *pdev) · 71 unmodified lines | ||
| 363 | 409 | { |
| 364 | 410 | struct cht_wc_i2c_adap *adap = platform_get_drvdata(pdev); |
| 365 | 411 | |
| 366 | − if (adap->client) | |
| 367 | − i2c_unregister_device(adap->client); | |
| 412 | + i2c_unregister_device(adap->client); | |
| 368 | 413 | i2c_del_adapter(&adap->adapter); |
| 369 | 414 | irq_domain_remove(adap->irq_domain); |
| 370 | 415 | |
| @@ -655,15 +655,11 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev) · 654 unmodified lines | ||
| 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 | − | |
| 660 | − gpio = devm_gpiod_get(dev->dev, "scl", GPIOD_OUT_HIGH); | |
| 661 | − if (IS_ERR(gpio)) { | |
| 662 | − r = PTR_ERR(gpio); | |
| 663 | − if (r == -ENOENT || r == -ENOSYS) | |
| 664 | − return 0; | |
| 665 | − return r; | |
| 666 | − } | |
| 658 | + | |
| 659 | + gpio = devm_gpiod_get_optional(dev->dev, "scl", GPIOD_OUT_HIGH); | |
| 660 | + if (IS_ERR_OR_NULL(gpio)) | |
| 661 | + return PTR_ERR_OR_ZERO(gpio); | |
| 662 | + | |
| 667 | 663 | rinfo->scl_gpiod = gpio; |
| 668 | 664 | |
| 669 | 665 | gpio = devm_gpiod_get_optional(dev->dev, "sda", GPIOD_IN); |
| @@ -33,6 +33,7 @@ enum dw_pci_ctl_id_t { · 32 unmodified lines | ||
| 33 | 33 | baytrail, |
| 34 | 34 | cherrytrail, |
| 35 | 35 | haswell, |
| 36 | + elkhartlake, | |
| 36 | 37 | }; |
| 37 | 38 | |
| 38 | 39 | struct dw_scl_sda_cfg { |
| @@ -168,13 +169,20 @@ static struct dw_pci_controller dw_pci_controllers[] = { · 129 unmodified lines | ||
| 168 | 169 | .flags = MODEL_CHERRYTRAIL, |
| 169 | 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 | 182 | #ifdef CONFIG_PM |
| 174 | 183 | static int i2c_dw_pci_suspend(struct device *dev) |
| 175 | 184 | { |
| 176 | − struct pci_dev *pdev = to_pci_dev(dev); | |
| 177 | − struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev); | |
| 185 | + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); | |
| 178 | 186 | |
| 179 | 187 | i_dev->suspended = true; |
| 180 | 188 | i_dev->disable(i_dev); |
| @@ -184,8 +192,7 @@ static int i2c_dw_pci_suspend(struct device *dev) · 3 unmodified lines | ||
| 184 | 192 | |
| 185 | 193 | static int i2c_dw_pci_resume(struct device *dev) |
| 186 | 194 | { |
| 187 | − struct pci_dev *pdev = to_pci_dev(dev); | |
| 188 | − struct dw_i2c_dev *i_dev = pci_get_drvdata(pdev); | |
| 195 | + struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); | |
| 189 | 196 | int ret; |
| 190 | 197 | |
| 191 | 198 | ret = i_dev->init(i_dev); |
| @@ -227,6 +234,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, · 35 unmodified lines | ||
| 227 | 234 | return r; |
| 228 | 235 | } |
| 229 | 236 | |
| 237 | + pci_set_master(pdev); | |
| 238 | + | |
| 230 | 239 | r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); |
| 231 | 240 | if (r) { |
| 232 | 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, · 4 unmodified lines | ||
| 237 | 246 | if (!dev) |
| 238 | 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 | 253 | dev->clk = NULL; |
| 241 | 254 | dev->controller = controller; |
| 242 | 255 | dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; |
| 243 | 256 | dev->base = pcim_iomap_table(pdev)[0]; |
| 244 | 257 | dev->dev = &pdev->dev; |
| 245 | − dev->irq = pdev->irq; | |
| 258 | + dev->irq = pci_irq_vector(pdev, 0); | |
| 246 | 259 | dev->flags |= controller->flags; |
| 247 | 260 | |
| 248 | 261 | if (controller->setup) { |
| 249 | 262 | r = controller->setup(pdev, controller); |
| 250 | − if (r) | |
| 263 | + if (r) { | |
| 264 | + pci_free_irq_vectors(pdev); | |
| 251 | 265 | return r; |
| 266 | + } | |
| 252 | 267 | } |
| 253 | 268 | |
| 254 | 269 | dev->functionality = controller->functionality | |
| @@ -276,8 +291,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev, · 21 unmodified lines | ||
| 276 | 291 | adap->nr = controller->bus_num; |
| 277 | 292 | |
| 278 | 293 | r = i2c_dw_probe(dev); |
| 279 | − if (r) | |
| 294 | + if (r) { | |
| 295 | + pci_free_irq_vectors(pdev); | |
| 280 | 296 | return r; |
| 297 | + } | |
| 281 | 298 | |
| 282 | 299 | pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); |
| 283 | 300 | pm_runtime_use_autosuspend(&pdev->dev); |
| @@ -296,6 +313,7 @@ static void i2c_dw_pci_remove(struct pci_dev *pdev) · 12 unmodified lines | ||
| 296 | 313 | pm_runtime_get_noresume(&pdev->dev); |
| 297 | 314 | |
| 298 | 315 | i2c_del_adapter(&dev->adapter); |
| 316 | + pci_free_irq_vectors(pdev); | |
| 299 | 317 | } |
| 300 | 318 | |
| 301 | 319 | /* work with hotplug and coldplug */ |
| @@ -331,6 +349,15 @@ static const struct pci_device_id i2_designware_pci_ids[] = { · 29 unmodified lines | ||
| 331 | 349 | { PCI_VDEVICE(INTEL, 0x22C5), cherrytrail }, |
| 332 | 350 | { PCI_VDEVICE(INTEL, 0x22C6), cherrytrail }, |
| 333 | 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 | 361 | { 0,} |
| 335 | 362 | }; |
| 336 | 363 | MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids); |
| @@ -279,12 +279,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 278 unmodified lines | ||
| 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) |
| @@ -346,8 +344,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 55 unmodified lines | ||
| 346 | 344 | |
| 347 | 345 | /* Optional interface clock */ |
| 348 | 346 | dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); |
| 349 | − if (IS_ERR(dev->pclk)) | |
| 350 | − return PTR_ERR(dev->pclk); | |
| 347 | + if (IS_ERR(dev->pclk)) { | |
| 348 | + ret = PTR_ERR(dev->pclk); | |
| 349 | + goto exit_reset; | |
| 350 | + } | |
| 351 | 351 | |
| 352 | 352 | dev->clk = devm_clk_get(&pdev->dev, NULL); |
| 353 | 353 | if (!i2c_dw_prepare_clk(dev, true)) { |
| @@ -400,8 +400,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev) · 46 unmodified lines | ||
| 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 | |
| @@ -419,8 +418,7 @@ static int dw_i2c_plat_remove(struct platform_device *pdev) · 11 unmodified lines | ||
| 419 | 418 | pm_runtime_put_sync(&pdev->dev); |
| 420 | 419 | dw_i2c_plat_pm_cleanup(dev); |
| 421 | 420 | |
| 422 | − if (!IS_ERR_OR_NULL(dev->rst)) | |
| 423 | − reset_control_assert(dev->rst); | |
| 421 | + reset_control_assert(dev->rst); | |
| 424 | 422 | |
| 425 | 423 | return 0; |
| 426 | 424 | } |
| @@ -791,9 +791,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev) · 790 unmodified lines | ||
| 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; |
| @@ -707,8 +707,10 @@ static int fsi_i2c_probe(struct device *dev) · 706 unmodified lines | ||
| 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; |
| @@ -445,8 +445,7 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev) · 444 unmodified lines | ||
| 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; |
| @@ -292,7 +292,8 @@ struct i801_priv { · 291 unmodified lines | ||
| 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", |
| @@ -1500,57 +1501,23 @@ static inline unsigned int i801_get_adapter_class(struct i801_priv *priv) · 1201 unmodified lines | ||
| 1500 | 1501 | } |
| 1501 | 1502 | #endif |
| 1502 | 1503 | |
| 1503 | −static const struct itco_wdt_platform_data tco_platform_data = { | |
| 1504 | +static const struct itco_wdt_platform_data spt_tco_platform_data = { | |
| 1504 | 1505 | .name = "Intel PCH", |
| 1505 | 1506 | .version = 4, |
| 1506 | 1507 | }; |
| 1507 | 1508 | |
| 1508 | 1509 | static DEFINE_SPINLOCK(p2sb_spinlock); |
| 1509 | 1510 | |
| 1510 | −static void i801_add_tco(struct i801_priv *priv) | |
| 1511 | +static struct platform_device * | |
| 1512 | +i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, | |
| 1513 | + struct resource *tco_res) | |
| 1511 | 1514 | { |
| 1512 | − struct pci_dev *pci_dev = priv->pci_dev; | |
| 1513 | − struct resource tco_res[3], *res; | |
| 1514 | − struct platform_device *pdev; | |
| 1515 | + struct resource *res; | |
| 1515 | 1516 | unsigned int devfn; |
| 1516 | − u32 tco_base, tco_ctl; | |
| 1517 | − u32 base_addr, ctrl_val; | |
| 1518 | 1517 | u64 base64_addr; |
| 1518 | + u32 base_addr; | |
| 1519 | 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 | 1522 | * We must access the NO_REBOOT bit over the Primary to Sideband |
| 1556 | 1523 | * bridge (P2SB). The BIOS prevents the P2SB device from being |
| @@ -1586,15 +1553,76 @@ static void i801_add_tco(struct i801_priv *priv) · 29 unmodified lines | ||
| 1586 | 1553 | res->end = res->start + 3; |
| 1587 | 1554 | res->flags = IORESOURCE_MEM; |
| 1588 | 1555 | |
| 1589 | − pdev = platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, | |
| 1590 | − tco_res, 3, &tco_platform_data, | |
| 1591 | − sizeof(tco_platform_data)); | |
| 1592 | − if (IS_ERR(pdev)) { | |
| 1593 | − dev_warn(&pci_dev->dev, "failed to create iTCO device\n"); | |
| 1556 | + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, | |
| 1557 | + tco_res, 3, &spt_tco_platform_data, | |
| 1558 | + sizeof(spt_tco_platform_data)); | |
| 1559 | +} | |
| 1560 | + | |
| 1561 | +static const struct itco_wdt_platform_data cnl_tco_platform_data = { | |
| 1562 | + .name = "Intel PCH", | |
| 1563 | + .version = 6, | |
| 1564 | +}; | |
| 1565 | + | |
| 1566 | +static struct platform_device * | |
| 1567 | +i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev, | |
| 1568 | + struct resource *tco_res) | |
| 1569 | +{ | |
| 1570 | + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, | |
| 1571 | + tco_res, 2, &cnl_tco_platform_data, | |
| 1572 | + sizeof(cnl_tco_platform_data)); | |
| 1573 | +} | |
| 1574 | + | |
| 1575 | +static void i801_add_tco(struct i801_priv *priv) | |
| 1576 | +{ | |
| 1577 | + u32 base_addr, tco_base, tco_ctl, ctrl_val; | |
| 1578 | + struct pci_dev *pci_dev = priv->pci_dev; | |
| 1579 | + struct resource tco_res[3], *res; | |
| 1580 | + unsigned int devfn; | |
| 1581 | + | |
| 1582 | + /* If we have ACPI based watchdog use that instead */ | |
| 1583 | + if (acpi_has_watchdog()) | |
| 1594 | 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 | 1628 | #ifdef CONFIG_ACPI |
| @@ -1704,13 +1732,21 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 103 unmodified lines | ||
| 1704 | 1732 | switch (dev->device) { |
| 1705 | 1733 | case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS: |
| 1706 | 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 | 1735 | case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS: |
| 1710 | 1736 | case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS: |
| 1711 | − case PCI_DEVICE_ID_INTEL_CDF_SMBUS: | |
| 1712 | 1737 | case PCI_DEVICE_ID_INTEL_DNV_SMBUS: |
| 1713 | 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 | 1750 | case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: |
| 1715 | 1751 | case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: |
| 1716 | 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) · 3 unmodified lines | ||
| 1720 | 1756 | priv->features |= FEATURE_IRQ; |
| 1721 | 1757 | priv->features |= FEATURE_SMBUS_PEC; |
| 1722 | 1758 | priv->features |= FEATURE_BLOCK_BUFFER; |
| 1723 | − /* If we have ACPI based watchdog use that instead */ | |
| 1724 | − if (!acpi_has_watchdog()) | |
| 1725 | − priv->features |= FEATURE_TCO; | |
| 1759 | + priv->features |= FEATURE_TCO_CNL; | |
| 1726 | 1760 | priv->features |= FEATURE_HOST_NOTIFY; |
| 1727 | 1761 | break; |
| 1728 | 1762 | |
| @@ -1921,8 +1955,7 @@ static int i801_suspend(struct device *dev) · 192 unmodified lines | ||
| 1921 | 1955 | |
| 1922 | 1956 | static int i801_resume(struct device *dev) |
| 1923 | 1957 | { |
| 1924 | − struct pci_dev *pci_dev = to_pci_dev(dev); | |
| 1925 | − struct i801_priv *priv = pci_get_drvdata(pci_dev); | |
| 1958 | + struct i801_priv *priv = dev_get_drvdata(dev); | |
| 1926 | 1959 | |
| 1927 | 1960 | i801_enable_host_notify(&priv->adapter); |
| 1928 | 1961 | |
| @@ -0,0 +1,230 @@ | ||
| 1 | +// SPDX-License-Identifier: GPL-2.0 | |
| 2 | +/* | |
| 3 | + * I2C driver for stand-alone PCF8584 style adapters on Zorro cards | |
| 4 | + * | |
| 5 | + * Original ICY documentation can be found on Aminet: | |
| 6 | + * https://aminet.net/package/docs/hard/icy | |
| 7 | + * | |
| 8 | + * There has been a modern community re-print of this design in 2019: | |
| 9 | + * https://www.a1k.org/forum/index.php?threads/70106/ | |
| 10 | + * | |
| 11 | + * The card is basically a Philips PCF8584 connected straight to the | |
| 12 | + * beginning of the AutoConfig'd address space (register S1 on base+2), | |
| 13 | + * with /INT on /INT2 on the Zorro bus. | |
| 14 | + * | |
| 15 | + * Copyright (c) 2019 Max Staudt <max@enpas.org> | |
| 16 | + * | |
| 17 | + * This started as a fork of i2c-elektor.c and has evolved since. | |
| 18 | + * Thanks go to its authors for providing a base to grow on. | |
| 19 | + * | |
| 20 | + * | |
| 21 | + * IRQ support is currently not implemented. | |
| 22 | + * | |
| 23 | + * As it turns out, i2c-algo-pcf is really written with i2c-elektor's | |
| 24 | + * edge-triggered ISA interrupts in mind, while the Amiga's Zorro bus has | |
| 25 | + * level-triggered interrupts. This means that once an interrupt occurs, we | |
| 26 | + * have to tell the PCF8584 to shut up immediately, or it will keep the | |
| 27 | + * interrupt line busy and cause an IRQ storm. | |
| 28 | + | |
| 29 | + * However, because of the PCF8584's host-side protocol, there is no good | |
| 30 | + * way to just quieten it without side effects. Rather, we have to perform | |
| 31 | + * the next read/write operation straight away, which will reset the /INT | |
| 32 | + * pin. This entails re-designing the core of i2c-algo-pcf in the future. | |
| 33 | + * For now, we never request an IRQ from the PCF8584, and poll it instead. | |
| 34 | + */ | |
| 35 | + | |
| 36 | +#include <linux/delay.h> | |
| 37 | +#include <linux/init.h> | |
| 38 | +#include <linux/io.h> | |
| 39 | +#include <linux/ioport.h> | |
| 40 | +#include <linux/kernel.h> | |
| 41 | +#include <linux/module.h> | |
| 42 | + | |
| 43 | +#include <linux/i2c.h> | |
| 44 | +#include <linux/i2c-algo-pcf.h> | |
| 45 | + | |
| 46 | +#include <asm/amigaints.h> | |
| 47 | +#include <linux/zorro.h> | |
| 48 | + | |
| 49 | +#include "../algos/i2c-algo-pcf.h" | |
| 50 | + | |
| 51 | +struct icy_i2c { | |
| 52 | + struct i2c_adapter adapter; | |
| 53 | + | |
| 54 | + void __iomem *reg_s0; | |
| 55 | + void __iomem *reg_s1; | |
| 56 | + struct fwnode_handle *ltc2990_fwnode; | |
| 57 | + struct i2c_client *ltc2990_client; | |
| 58 | +}; | |
| 59 | + | |
| 60 | +/* | |
| 61 | + * Functions called by i2c-algo-pcf | |
| 62 | + */ | |
| 63 | +static void icy_pcf_setpcf(void *data, int ctl, int val) | |
| 64 | +{ | |
| 65 | + struct icy_i2c *i2c = (struct icy_i2c *)data; | |
| 66 | + | |
| 67 | + u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; | |
| 68 | + | |
| 69 | + z_writeb(val, address); | |
| 70 | +} | |
| 71 | + | |
| 72 | +static int icy_pcf_getpcf(void *data, int ctl) | |
| 73 | +{ | |
| 74 | + struct icy_i2c *i2c = (struct icy_i2c *)data; | |
| 75 | + | |
| 76 | + u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; | |
| 77 | + | |
| 78 | + return z_readb(address); | |
| 79 | +} | |
| 80 | + | |
| 81 | +static int icy_pcf_getown(void *data) | |
| 82 | +{ | |
| 83 | + return 0x55; | |
| 84 | +} | |
| 85 | + | |
| 86 | +static int icy_pcf_getclock(void *data) | |
| 87 | +{ | |
| 88 | + return 0x1c; | |
| 89 | +} | |
| 90 | + | |
| 91 | +static void icy_pcf_waitforpin(void *data) | |
| 92 | +{ | |
| 93 | + usleep_range(50, 150); | |
| 94 | +} | |
| 95 | + | |
| 96 | +/* | |
| 97 | + * Main i2c-icy part | |
| 98 | + */ | |
| 99 | +static unsigned short const icy_ltc2990_addresses[] = { | |
| 100 | + 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END | |
| 101 | +}; | |
| 102 | + | |
| 103 | +/* | |
| 104 | + * Additional sensors exposed once this property is applied: | |
| 105 | + * | |
| 106 | + * in1 will be the voltage of the 5V rail, divided by 2. | |
| 107 | + * in2 will be the voltage of the 12V rail, divided by 4. | |
| 108 | + * temp3 will be measured using a PCB loop next the chip. | |
| 109 | + */ | |
| 110 | +static const u32 icy_ltc2990_meas_mode[] = {0, 3}; | |
| 111 | + | |
| 112 | +static const struct property_entry icy_ltc2990_props[] = { | |
| 113 | + PROPERTY_ENTRY_U32_ARRAY("lltc,meas-mode", icy_ltc2990_meas_mode), | |
| 114 | + { } | |
| 115 | +}; | |
| 116 | + | |
| 117 | +static int icy_probe(struct zorro_dev *z, | |
| 118 | + const struct zorro_device_id *ent) | |
| 119 | +{ | |
| 120 | + struct icy_i2c *i2c; | |
| 121 | + struct i2c_algo_pcf_data *algo_data; | |
| 122 | + struct fwnode_handle *new_fwnode; | |
| 123 | + struct i2c_board_info ltc2990_info = { | |
| 124 | + .type = "ltc2990", | |
| 125 | + .addr = 0x4c, | |
| 126 | + }; | |
| 127 | + | |
| 128 | + i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL); | |
| 129 | + if (!i2c) | |
| 130 | + return -ENOMEM; | |
| 131 | + | |
| 132 | + algo_data = devm_kzalloc(&z->dev, sizeof(*algo_data), GFP_KERNEL); | |
| 133 | + if (!algo_data) | |
| 134 | + return -ENOMEM; | |
| 135 | + | |
| 136 | + dev_set_drvdata(&z->dev, i2c); | |
| 137 | + i2c->adapter.dev.parent = &z->dev; | |
| 138 | + i2c->adapter.owner = THIS_MODULE; | |
| 139 | + /* i2c->adapter.algo assigned by i2c_pcf_add_bus() */ | |
| 140 | + i2c->adapter.algo_data = algo_data; | |
| 141 | + strlcpy(i2c->adapter.name, "ICY I2C Zorro adapter", | |
| 142 | + sizeof(i2c->adapter.name)); | |
| 143 | + | |
| 144 | + if (!devm_request_mem_region(&z->dev, | |
| 145 | + z->resource.start, | |
| 146 | + 4, i2c->adapter.name)) | |
| 147 | + return -ENXIO; | |
| 148 | + | |
| 149 | + /* Driver private data */ | |
| 150 | + i2c->reg_s0 = ZTWO_VADDR(z->resource.start); | |
| 151 | + i2c->reg_s1 = ZTWO_VADDR(z->resource.start + 2); | |
| 152 | + | |
| 153 | + algo_data->data = i2c; | |
| 154 | + algo_data->setpcf = icy_pcf_setpcf; | |
| 155 | + algo_data->getpcf = icy_pcf_getpcf; | |
| 156 | + algo_data->getown = icy_pcf_getown; | |
| 157 | + algo_data->getclock = icy_pcf_getclock; | |
| 158 | + algo_data->waitforpin = icy_pcf_waitforpin; | |
| 159 | + | |
| 160 | + if (i2c_pcf_add_bus(&i2c->adapter)) { | |
| 161 | + dev_err(&z->dev, "i2c_pcf_add_bus() failed\n"); | |
| 162 | + return -ENXIO; | |
| 163 | + } | |
| 164 | + | |
| 165 | + dev_info(&z->dev, "ICY I2C controller at %pa, IRQ not implemented\n", | |
| 166 | + &z->resource.start); | |
| 167 | + | |
| 168 | + /* | |
| 169 | + * The 2019 a1k.org PCBs have an LTC2990 at 0x4c, so start | |
| 170 | + * it automatically once ltc2990 is modprobed. | |
| 171 | + * | |
| 172 | + * in0 is the voltage of the internal 5V power supply. | |
| 173 | + * temp1 is the temperature inside the chip. | |
| 174 | + * | |
| 175 | + * See property_entry above for in1, in2, temp3. | |
| 176 | + */ | |
| 177 | + new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL); | |
| 178 | + if (IS_ERR(new_fwnode)) { | |
| 179 | + dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n", | |
| 180 | + PTR_ERR(new_fwnode)); | |
| 181 | + } else { | |
| 182 | + /* | |
| 183 | + * Store the fwnode so we can destroy it on .remove(). | |
| 184 | + * Only store it on success, as fwnode_remove_software_node() | |
| 185 | + * is NULL safe, but not PTR_ERR safe. | |
| 186 | + */ | |
| 187 | + i2c->ltc2990_fwnode = new_fwnode; | |
| 188 | + ltc2990_info.fwnode = new_fwnode; | |
| 189 | + | |
| 190 | + i2c->ltc2990_client = | |
| 191 | + i2c_new_probed_device(&i2c->adapter, | |
| 192 | + <c2990_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"); | |
| @@ -545,7 +545,6 @@ MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); · 544 unmodified lines | ||
| 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 | |
| @@ -553,8 +552,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 553 | 552 | if (!lpi2c_imx) |
| 554 | 553 | return -ENOMEM; |
| 555 | 554 | |
| 556 | − res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 557 | − lpi2c_imx->base = devm_ioremap_resource(&pdev->dev, res); | |
| 555 | + lpi2c_imx->base = devm_platform_ioremap_resource(pdev, 0); | |
| 558 | 556 | if (IS_ERR(lpi2c_imx->base)) |
| 559 | 557 | return PTR_ERR(lpi2c_imx->base); |
| 560 | 558 | |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 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,6 +256,12 @@ static const struct of_device_id i2c_imx_dt_ids[] = { · 229 unmodified lines | ||
| 255 | 256 | }; |
| 256 | 257 | MODULE_DEVICE_TABLE(of, i2c_imx_dt_ids); |
| 257 | 258 | |
| 259 | +static const struct acpi_device_id i2c_imx_acpi_ids[] = { | |
| 260 | + {"NXP0001", .driver_data = (kernel_ulong_t)&vf610_i2c_hwdata}, | |
| 261 | + { } | |
| 262 | +}; | |
| 263 | +MODULE_DEVICE_TABLE(acpi, i2c_imx_acpi_ids); | |
| 264 | + | |
| 258 | 265 | static inline int is_imx1_i2c(struct imx_i2c_struct *i2c_imx) |
| 259 | 266 | { |
| 260 | 267 | return i2c_imx->hwdata->devtype == IMX1_I2C; |
| @@ -1048,14 +1055,13 @@ static const struct i2c_algorithm i2c_imx_algo = { · 787 unmodified lines | ||
| 1048 | 1055 | |
| 1049 | 1056 | static 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 | 1058 | struct imx_i2c_struct *i2c_imx; |
| 1054 | 1059 | struct resource *res; |
| 1055 | 1060 | struct imxi2c_platform_data *pdata = dev_get_platdata(&pdev->dev); |
| 1056 | 1061 | void __iomem *base; |
| 1057 | 1062 | int irq, ret; |
| 1058 | 1063 | dma_addr_t phy_addr; |
| 1064 | + const struct imx_i2c_hwdata *match; | |
| 1059 | 1065 | |
| 1060 | 1066 | dev_dbg(&pdev->dev, "<%s>\n", __func__); |
| 1061 | 1067 | |
| @@ -1075,8 +1081,9 @@ static int i2c_imx_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 1075 | 1081 | if (!i2c_imx) |
| 1076 | 1082 | return -ENOMEM; |
| 1077 | 1083 | |
| 1078 | − if (of_id) | |
| 1079 | − i2c_imx->hwdata = of_id->data; | |
| 1084 | + match = device_get_match_data(&pdev->dev); | |
| 1085 | + if (match) | |
| 1086 | + i2c_imx->hwdata = match; | |
| 1080 | 1087 | else |
| 1081 | 1088 | i2c_imx->hwdata = (struct imx_i2c_hwdata *) |
| 1082 | 1089 | platform_get_device_id(pdev)->driver_data; |
| @@ -1089,6 +1096,7 @@ static int i2c_imx_probe(struct platform_device *pdev) · 6 unmodified lines | ||
| 1089 | 1096 | i2c_imx->adapter.nr = pdev->id; |
| 1090 | 1097 | i2c_imx->adapter.dev.of_node = pdev->dev.of_node; |
| 1091 | 1098 | i2c_imx->base = base; |
| 1099 | + ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev)); | |
| 1092 | 1100 | |
| 1093 | 1101 | /* Get I2C clock */ |
| 1094 | 1102 | i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); |
| @@ -1247,6 +1255,7 @@ static struct platform_driver i2c_imx_driver = { · 152 unmodified lines | ||
| 1247 | 1255 | .name = DRIVER_NAME, |
| 1248 | 1256 | .pm = &i2c_imx_pm_ops, |
| 1249 | 1257 | .of_match_table = i2c_imx_dt_ids, |
| 1258 | + .acpi_match_table = i2c_imx_acpi_ids, | |
| 1250 | 1259 | }, |
| 1251 | 1260 | .id_table = imx_i2c_devtype, |
| 1252 | 1261 | }; |
| @@ -781,8 +781,6 @@ static int ismt_dev_init(struct ismt_priv *priv) · 780 unmodified lines | ||
| 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 | |
| @@ -802,7 +802,6 @@ static int mxs_i2c_probe(struct platform_device *pdev) · 801 unmodified lines | ||
| 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); |
| @@ -814,8 +813,7 @@ static int mxs_i2c_probe(struct platform_device *pdev) · 5 unmodified lines | ||
| 814 | 813 | i2c->dev_type = device_id->driver_data; |
| 815 | 814 | } |
| 816 | 815 | |
| 817 | − res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 818 | − i2c->regs = devm_ioremap_resource(&pdev->dev, res); | |
| 816 | + i2c->regs = devm_platform_ioremap_resource(pdev, 0); | |
| 819 | 817 | if (IS_ERR(i2c->regs)) |
| 820 | 818 | return PTR_ERR(i2c->regs); |
| 821 | 819 | |
| @@ -703,8 +703,9 @@ static int ocores_i2c_probe(struct platform_device *pdev) · 702 unmodified lines | ||
| 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; |
| @@ -72,7 +72,8 @@ · 71 unmodified lines | ||
| 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 |
| @@ -806,10 +807,12 @@ MODULE_DEVICE_TABLE (pci, piix4_ids); · 727 unmodified lines | ||
| 806 | 807 | |
| 807 | 808 | static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS]; |
| 808 | 809 | static struct i2c_adapter *piix4_aux_adapter; |
| 810 | +static int piix4_adapter_count; | |
| 809 | 811 | |
| 810 | 812 | static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, |
| 811 | 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 | 817 | struct i2c_adapter *adap; |
| 815 | 818 | struct i2c_piix4_adapdata *adapdata; |
| @@ -841,6 +844,12 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 25 unmodified lines | ||
| 841 | 844 | /* set up the sysfs linkage to our parent device */ |
| 842 | 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 | 853 | snprintf(adap->name, sizeof(adap->name), |
| 845 | 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, · 18 unmodified lines | ||
| 865 | 874 | int port; |
| 866 | 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 | 888 | retval = piix4_add_adapter(dev, smba, true, port, notify_imc, |
| 889 | + hw_port_nr, | |
| 870 | 890 | piix4_main_port_names_sb800[port], |
| 871 | 891 | &piix4_main_adapters[port]); |
| 872 | 892 | if (retval < 0) |
| @@ -937,8 +957,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 64 unmodified lines | ||
| 937 | 957 | return retval; |
| 938 | 958 | |
| 939 | 959 | /* Try to register main SMBus adapter, give up if we can't */ |
| 940 | − retval = piix4_add_adapter(dev, retval, false, 0, false, "", | |
| 941 | − &piix4_main_adapters[0]); | |
| 960 | + retval = piix4_add_adapter(dev, retval, false, 0, false, 0, | |
| 961 | + "", &piix4_main_adapters[0]); | |
| 942 | 962 | if (retval < 0) |
| 943 | 963 | return retval; |
| 944 | 964 | } |
| @@ -964,7 +984,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 19 unmodified lines | ||
| 964 | 984 | if (retval > 0) { |
| 965 | 985 | /* Try to add the aux adapter if it exists, |
| 966 | 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 | 988 | is_sb800 ? piix4_aux_port_name_sb800 : "", |
| 969 | 989 | &piix4_aux_adapter); |
| 970 | 990 | } |
| @@ -987,7 +1007,7 @@ static void piix4_adap_remove(struct i2c_adapter *adap) · 16 unmodified lines | ||
| 987 | 1007 | |
| 988 | 1008 | static void piix4_remove(struct pci_dev *dev) |
| 989 | 1009 | { |
| 990 | − int port = PIIX4_MAX_ADAPTERS; | |
| 1010 | + int port = piix4_adapter_count; | |
| 991 | 1011 | |
| 992 | 1012 | while (--port >= 0) { |
| 993 | 1013 | if (piix4_main_adapters[port]) { |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 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> |
| @@ -465,9 +466,9 @@ static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev) · 447 unmodified lines | ||
| 465 | 466 | |
| 466 | 467 | i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable"); |
| 467 | 468 | if (IS_ERR(i2c_dev->clk)) { |
| 468 | − dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n", | |
| 469 | − i2c_dev->adap.nr); | |
| 470 | − i2c_dev->clk = NULL; | |
| 469 | + dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n", | |
| 470 | + i2c_dev->adap.nr); | |
| 471 | + return PTR_ERR(i2c_dev->clk); | |
| 471 | 472 | } |
| 472 | 473 | |
| 473 | 474 | return 0; |
| @@ -477,7 +478,6 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 477 | 478 | { |
| 478 | 479 | struct device *dev = &pdev->dev; |
| 479 | 480 | struct sprd_i2c *i2c_dev; |
| 480 | − struct resource *res; | |
| 481 | 481 | u32 prop; |
| 482 | 482 | int ret; |
| 483 | 483 | |
| @@ -487,8 +487,7 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 3 unmodified lines | ||
| 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 | |
| @@ -520,7 +519,10 @@ static int sprd_i2c_probe(struct platform_device *pdev) · 25 unmodified lines | ||
| 520 | 519 | if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000) |
| 521 | 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 | 526 | platform_set_drvdata(pdev, i2c_dev); |
| 525 | 527 | |
| 526 | 528 | ret = clk_prepare_enable(i2c_dev->clk); |
| @@ -644,8 +646,7 @@ static struct platform_driver sprd_i2c_driver = { · 117 unmodified lines | ||
| 644 | 646 | }, |
| 645 | 647 | }; |
| 646 | 648 | |
| 647 | −static int sprd_i2c_init(void) | |
| 648 | −{ | |
| 649 | − return platform_driver_register(&sprd_i2c_driver); | |
| 650 | −} | |
| 651 | −arch_initcall_sync(sprd_i2c_init); | |
| 649 | +module_platform_driver(sprd_i2c_driver); | |
| 650 | + | |
| 651 | +MODULE_DESCRIPTION("Spreadtrum I2C master controller driver"); | |
| 652 | +MODULE_LICENSE("GPL v2"); | |
| @@ -1809,7 +1809,7 @@ static u32 stm32f7_i2c_func(struct i2c_adapter *adap) · 1808 unmodified lines | ||
| 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, |
| @@ -526,7 +526,7 @@ static const struct i2c_algorithm synquacer_i2c_algo = { · 525 unmodified lines | ||
| 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, |
| @@ -39,7 +39,7 @@ struct taos_data { · 38 unmodified lines | ||
| 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 | |
| @@ -636,7 +636,7 @@ static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev) · 635 unmodified lines | ||
| 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,7 +665,7 @@ static int tegra_i2c_runtime_resume(struct device *dev) · 22 unmodified lines | ||
| 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 | |
| @@ -713,12 +713,6 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit) · 41 unmodified lines | ||
| 713 | 713 | u32 tsu_thd; |
| 714 | 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 | 716 | reset_control_assert(i2c_dev->rst); |
| 723 | 717 | udelay(2); |
| 724 | 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) · 47 unmodified lines | ||
| 772 | 766 | if (err) { |
| 773 | 767 | dev_err(i2c_dev->dev, |
| 774 | 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) · 8 unmodified lines | ||
| 787 | 781 | |
| 788 | 782 | err = tegra_i2c_flush_fifos(i2c_dev); |
| 789 | 783 | if (err) |
| 790 | − goto err; | |
| 784 | + return err; | |
| 791 | 785 | |
| 792 | 786 | if (i2c_dev->is_multimaster_mode && i2c_dev->hw->has_slcg_override_reg) |
| 793 | 787 | i2c_writel(i2c_dev, I2C_MST_CORE_CLKEN_OVR, I2C_CLKEN_OVERRIDE); |
| 794 | 788 | |
| 795 | 789 | err = tegra_i2c_wait_for_config_load(i2c_dev); |
| 796 | 790 | if (err) |
| 797 | − goto err; | |
| 791 | + return err; | |
| 798 | 792 | |
| 799 | 793 | if (i2c_dev->irq_disabled) { |
| 800 | 794 | i2c_dev->irq_disabled = false; |
| 801 | 795 | enable_irq(i2c_dev->irq); |
| 802 | 796 | } |
| 803 | 797 | |
| 804 | −err: | |
| 805 | − pm_runtime_put(i2c_dev->dev); | |
| 806 | − return err; | |
| 798 | + return 0; | |
| 807 | 799 | } |
| 808 | 800 | |
| 809 | 801 | static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev) |
| @@ -1616,12 +1608,14 @@ static int tegra_i2c_probe(struct platform_device *pdev) · 806 unmodified lines | ||
| 1616 | 1608 | } |
| 1617 | 1609 | |
| 1618 | 1610 | pm_runtime_enable(&pdev->dev); |
| 1619 | − if (!pm_runtime_enabled(&pdev->dev)) { | |
| 1611 | + if (!pm_runtime_enabled(&pdev->dev)) | |
| 1620 | 1612 | ret = tegra_i2c_runtime_resume(&pdev->dev); |
| 1621 | − if (ret < 0) { | |
| 1622 | − dev_err(&pdev->dev, "runtime resume failed\n"); | |
| 1623 | − goto unprepare_div_clk; | |
| 1624 | − } | |
| 1613 | + else | |
| 1614 | + ret = pm_runtime_get_sync(i2c_dev->dev); | |
| 1615 | + | |
| 1616 | + if (ret < 0) { | |
| 1617 | + dev_err(&pdev->dev, "runtime resume failed\n"); | |
| 1618 | + goto unprepare_div_clk; | |
| 1625 | 1619 | } |
| 1626 | 1620 | |
| 1627 | 1621 | if (i2c_dev->is_multimaster_mode) { |
| @@ -1666,6 +1660,8 @@ static int tegra_i2c_probe(struct platform_device *pdev) · 38 unmodified lines | ||
| 1666 | 1660 | if (ret) |
| 1667 | 1661 | goto release_dma; |
| 1668 | 1662 | |
| 1663 | + pm_runtime_put(&pdev->dev); | |
| 1664 | + | |
| 1669 | 1665 | return 0; |
| 1670 | 1666 | |
| 1671 | 1667 | release_dma: |
| @@ -1711,8 +1707,7 @@ static int tegra_i2c_remove(struct platform_device *pdev) · 39 unmodified lines | ||
| 1711 | 1707 | return 0; |
| 1712 | 1708 | } |
| 1713 | 1709 | |
| 1714 | −#ifdef CONFIG_PM_SLEEP | |
| 1715 | −static int tegra_i2c_suspend(struct device *dev) | |
| 1710 | +static int __maybe_unused tegra_i2c_suspend(struct device *dev) | |
| 1716 | 1711 | { |
| 1717 | 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) · 2 unmodified lines | ||
| 1721 | 1716 | return 0; |
| 1722 | 1717 | } |
| 1723 | 1718 | |
| 1724 | −static int tegra_i2c_resume(struct device *dev) | |
| 1719 | +static int __maybe_unused tegra_i2c_resume(struct device *dev) | |
| 1725 | 1720 | { |
| 1726 | 1721 | struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev); |
| 1727 | 1722 | int err; |
| 1728 | 1723 | |
| 1724 | + err = tegra_i2c_runtime_resume(dev); | |
| 1725 | + if (err) | |
| 1726 | + return err; | |
| 1727 | + | |
| 1729 | 1728 | err = tegra_i2c_init(i2c_dev, false); |
| 1730 | 1729 | if (err) |
| 1731 | 1730 | return err; |
| 1732 | 1731 | |
| 1732 | + err = tegra_i2c_runtime_suspend(dev); | |
| 1733 | + if (err) | |
| 1734 | + return err; | |
| 1735 | + | |
| 1733 | 1736 | i2c_mark_adapter_resumed(&i2c_dev->adapter); |
| 1734 | 1737 | |
| 1735 | 1738 | return 0; |
| 1736 | 1739 | } |
| 1737 | 1740 | |
| 1738 | 1741 | static const struct dev_pm_ops tegra_i2c_pm = { |
| 1739 | − SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) | |
| 1742 | + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume) | |
| 1740 | 1743 | SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume, |
| 1741 | 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 | − | |
| 1749 | 1747 | static struct platform_driver tegra_i2c_driver = { |
| 1750 | 1748 | .probe = tegra_i2c_probe, |
| 1751 | 1749 | .remove = tegra_i2c_remove, |
| 1752 | 1750 | .driver = { |
| 1753 | 1751 | .name = "tegra-i2c", |
| 1754 | 1752 | .of_match_table = tegra_i2c_of_match, |
| 1755 | − .pm = TEGRA_I2C_PM, | |
| 1753 | + .pm = &tegra_i2c_pm, | |
| 1756 | 1754 | }, |
| 1757 | 1755 | }; |
| 1758 | 1756 | |
| @@ -108,7 +108,6 @@ static void uniphier_fi2c_fill_txfifo(struct uniphier_fi2c_priv *priv, · 107 unmodified lines | ||
| 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 | } |
| @@ -124,7 +123,6 @@ static void uniphier_fi2c_drain_rxfifo(struct uniphier_fi2c_priv *priv) · 9 unmodified lines | ||
| 124 | 123 | break; |
| 125 | 124 | |
| 126 | 125 | *priv->buf++ = readl(priv->membase + UNIPHIER_FI2C_DTRX); |
| 127 | − dev_dbg(&priv->adap.dev, "read data: %02x\n", priv->buf[-1]); | |
| 128 | 126 | priv->len--; |
| 129 | 127 | } |
| 130 | 128 | } |
| @@ -142,8 +140,6 @@ static void uniphier_fi2c_clear_irqs(struct uniphier_fi2c_priv *priv, · 11 unmodified lines | ||
| 142 | 140 | |
| 143 | 141 | static void uniphier_fi2c_stop(struct uniphier_fi2c_priv *priv) |
| 144 | 142 | { |
| 145 | − dev_dbg(&priv->adap.dev, "stop condition\n"); | |
| 146 | − | |
| 147 | 143 | priv->enabled_irqs |= UNIPHIER_FI2C_INT_STOP; |
| 148 | 144 | uniphier_fi2c_set_irqs(priv); |
| 149 | 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) · 10 unmodified lines | ||
| 160 | 156 | irq_status = readl(priv->membase + UNIPHIER_FI2C_INT); |
| 161 | 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 | 159 | if (irq_status & UNIPHIER_FI2C_INT_STOP) |
| 168 | 160 | goto complete; |
| 169 | 161 | |
| 170 | 162 | if (unlikely(irq_status & UNIPHIER_FI2C_INT_AL)) { |
| 171 | − dev_dbg(&priv->adap.dev, "arbitration lost\n"); | |
| 172 | 163 | priv->error = -EAGAIN; |
| 173 | 164 | goto complete; |
| 174 | 165 | } |
| 175 | 166 | |
| 176 | 167 | if (unlikely(irq_status & UNIPHIER_FI2C_INT_NA)) { |
| 177 | − dev_dbg(&priv->adap.dev, "could not get ACK\n"); | |
| 178 | 168 | priv->error = -ENXIO; |
| 179 | 169 | if (priv->flags & UNIPHIER_FI2C_RD) { |
| 180 | 170 | /* |
| @@ -215,18 +205,14 @@ static irqreturn_t uniphier_fi2c_interrupt(int irq, void *dev_id) · 34 unmodified lines | ||
| 215 | 205 | if (unlikely(priv->flags & UNIPHIER_FI2C_MANUAL_NACK)) { |
| 216 | 206 | if (priv->len <= UNIPHIER_FI2C_FIFO_SIZE && |
| 217 | 207 | !(priv->flags & UNIPHIER_FI2C_BYTE_WISE)) { |
| 218 | − dev_dbg(&priv->adap.dev, | |
| 219 | − "enable read byte count IRQ\n"); | |
| 220 | 208 | priv->enabled_irqs |= UNIPHIER_FI2C_INT_RB; |
| 221 | 209 | uniphier_fi2c_set_irqs(priv); |
| 222 | 210 | priv->flags |= UNIPHIER_FI2C_BYTE_WISE; |
| 223 | 211 | } |
| 224 | − if (priv->len <= 1) { | |
| 225 | − dev_dbg(&priv->adap.dev, "set NACK\n"); | |
| 212 | + if (priv->len <= 1) | |
| 226 | 213 | writel(UNIPHIER_FI2C_CR_MST | |
| 227 | 214 | UNIPHIER_FI2C_CR_NACK, |
| 228 | 215 | priv->membase + UNIPHIER_FI2C_CR); |
| 229 | − } | |
| 230 | 216 | } |
| 231 | 217 | |
| 232 | 218 | goto handled; |
| @@ -334,10 +320,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, · 101 unmodified lines | ||
| 334 | 320 | bool is_read = msg->flags & I2C_M_RD; |
| 335 | 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 | 323 | priv->len = msg->len; |
| 342 | 324 | priv->buf = msg->buf; |
| 343 | 325 | priv->enabled_irqs = UNIPHIER_FI2C_INT_FAULTS; |
| @@ -359,7 +341,6 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap, · 15 unmodified lines | ||
| 359 | 341 | else |
| 360 | 342 | uniphier_fi2c_tx_init(priv, msg->addr, repeat); |
| 361 | 343 | |
| 362 | − dev_dbg(&adap->dev, "start condition\n"); | |
| 363 | 344 | /* |
| 364 | 345 | * For a repeated START condition, writing a slave address to the FIFO |
| 365 | 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, · 17 unmodified lines | ||
| 383 | 364 | uniphier_fi2c_recover(priv); |
| 384 | 365 | return -ETIMEDOUT; |
| 385 | 366 | } |
| 386 | − dev_dbg(&adap->dev, "complete\n"); | |
| 387 | 367 | |
| 388 | 368 | if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) { |
| 389 | 369 | u32 status; |
| @@ -538,7 +518,6 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) · 148 unmodified lines | ||
| 538 | 518 | { |
| 539 | 519 | struct device *dev = &pdev->dev; |
| 540 | 520 | struct uniphier_fi2c_priv *priv; |
| 541 | − struct resource *regs; | |
| 542 | 521 | u32 bus_speed; |
| 543 | 522 | unsigned long clk_rate; |
| 544 | 523 | int irq, ret; |
| @@ -547,8 +526,7 @@ static int uniphier_fi2c_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 547 | 526 | if (!priv) |
| 548 | 527 | return -ENOMEM; |
| 549 | 528 | |
| 550 | − regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 551 | − priv->membase = devm_ioremap_resource(dev, regs); | |
| 529 | + priv->membase = devm_platform_ioremap_resource(pdev, 0); | |
| 552 | 530 | if (IS_ERR(priv->membase)) |
| 553 | 531 | return PTR_ERR(priv->membase); |
| 554 | 532 | |
| @@ -71,7 +71,6 @@ static int uniphier_i2c_xfer_byte(struct i2c_adapter *adap, u32 txdata, · 70 unmodified lines | ||
| 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); |
| @@ -81,8 +80,6 @@ static int uniphier_i2c_xfer_byte(struct i2c_adapter *adap, u32 txdata, · 3 unmodified lines | ||
| 81 | 80 | } |
| 82 | 81 | |
| 83 | 82 | rxdata = readl(priv->membase + UNIPHIER_I2C_DREC); |
| 84 | − dev_dbg(&adap->dev, "read data: 0x%04x\n", rxdata); | |
| 85 | − | |
| 86 | 83 | if (rxdatap) |
| 87 | 84 | *rxdatap = rxdata; |
| 88 | 85 | |
| @@ -98,14 +95,11 @@ static int uniphier_i2c_send_byte(struct i2c_adapter *adap, u32 txdata) · 9 unmodified lines | ||
| 98 | 95 | if (ret) |
| 99 | 96 | return ret; |
| 100 | 97 | |
| 101 | − if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) { | |
| 102 | − dev_dbg(&adap->dev, "arbitration lost\n"); | |
| 98 | + if (unlikely(rxdata & UNIPHIER_I2C_DREC_LAB)) | |
| 103 | 99 | return -EAGAIN; |
| 104 | − } | |
| 105 | − if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) { | |
| 106 | − dev_dbg(&adap->dev, "could not get ACK\n"); | |
| 100 | + | |
| 101 | + if (unlikely(rxdata & UNIPHIER_I2C_DREC_LRB)) | |
| 107 | 102 | return -ENXIO; |
| 108 | − } | |
| 109 | 103 | |
| 110 | 104 | return 0; |
| 111 | 105 | } |
| @@ -115,7 +109,6 @@ static int uniphier_i2c_tx(struct i2c_adapter *adap, u16 addr, u16 len, · 3 unmodified lines | ||
| 115 | 109 | { |
| 116 | 110 | int ret; |
| 117 | 111 | |
| 118 | − dev_dbg(&adap->dev, "start condition\n"); | |
| 119 | 112 | ret = uniphier_i2c_send_byte(adap, addr << 1 | |
| 120 | 113 | UNIPHIER_I2C_DTRM_STA | |
| 121 | 114 | UNIPHIER_I2C_DTRM_NACK); |
| @@ -137,7 +130,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len, · 15 unmodified lines | ||
| 137 | 130 | { |
| 138 | 131 | int ret; |
| 139 | 132 | |
| 140 | − dev_dbg(&adap->dev, "start condition\n"); | |
| 141 | 133 | ret = uniphier_i2c_send_byte(adap, addr << 1 | |
| 142 | 134 | UNIPHIER_I2C_DTRM_STA | |
| 143 | 135 | UNIPHIER_I2C_DTRM_NACK | |
| @@ -161,7 +153,6 @@ static int uniphier_i2c_rx(struct i2c_adapter *adap, u16 addr, u16 len, · 17 unmodified lines | ||
| 161 | 153 | |
| 162 | 154 | static int uniphier_i2c_stop(struct i2c_adapter *adap) |
| 163 | 155 | { |
| 164 | − dev_dbg(&adap->dev, "stop condition\n"); | |
| 165 | 156 | return uniphier_i2c_send_byte(adap, UNIPHIER_I2C_DTRM_STO | |
| 166 | 157 | UNIPHIER_I2C_DTRM_NACK); |
| 167 | 158 | } |
| @@ -173,9 +164,6 @@ static int uniphier_i2c_master_xfer_one(struct i2c_adapter *adap, · 5 unmodified lines | ||
| 173 | 164 | bool recovery = false; |
| 174 | 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 | 167 | if (is_read) |
| 180 | 168 | ret = uniphier_i2c_rx(adap, msg->addr, msg->len, msg->buf); |
| 181 | 169 | else |
| @@ -326,7 +314,6 @@ static int uniphier_i2c_probe(struct platform_device *pdev) · 144 unmodified lines | ||
| 326 | 314 | { |
| 327 | 315 | struct device *dev = &pdev->dev; |
| 328 | 316 | struct uniphier_i2c_priv *priv; |
| 329 | − struct resource *regs; | |
| 330 | 317 | u32 bus_speed; |
| 331 | 318 | unsigned long clk_rate; |
| 332 | 319 | int irq, ret; |
| @@ -335,8 +322,7 @@ static int uniphier_i2c_probe(struct platform_device *pdev) · 2 unmodified lines | ||
| 335 | 322 | if (!priv) |
| 336 | 323 | return -ENOMEM; |
| 337 | 324 | |
| 338 | − regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
| 339 | − priv->membase = devm_ioremap_resource(dev, regs); | |
| 325 | + priv->membase = devm_platform_ioremap_resource(pdev, 0); | |
| 340 | 326 | if (IS_ERR(priv->membase)) |
| 341 | 327 | return PTR_ERR(priv->membase); |
| 342 | 328 | |
| @@ -350,13 +350,11 @@ static int i2c_device_probe(struct device *dev) · 349 unmodified lines | ||
| 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 | |
| @@ -966,7 +964,7 @@ struct i2c_client *devm_i2c_new_dummy_device(struct device *dev, · 603 unmodified lines | ||
| 966 | 964 | EXPORT_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 | 968 | * and create the associated device |
| 971 | 969 | * @client: Handle to the primary client |
| 972 | 970 | * @name: Handle to specify which secondary address to get |
| @@ -985,9 +983,9 @@ EXPORT_SYMBOL_GPL(devm_i2c_new_dummy_device); · 12 unmodified lines | ||
| 985 | 983 | * cell whose "reg-names" value matches the slave name. |
| 986 | 984 | * |
| 987 | 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 | */ |
| 990 | −struct i2c_client *i2c_new_secondary_device(struct i2c_client *client, | |
| 988 | +struct i2c_client *i2c_new_ancillary_device(struct i2c_client *client, | |
| 991 | 989 | const char *name, |
| 992 | 990 | u16 default_addr) |
| 993 | 991 | { |
| @@ -1002,9 +1000,9 @@ struct i2c_client *i2c_new_secondary_device(struct i2c_client *client, · 8 unmodified lines | ||
| 1002 | 1000 | } |
| 1003 | 1001 | |
| 1004 | 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 | } |
| 1007 | −EXPORT_SYMBOL_GPL(i2c_new_secondary_device); | |
| 1005 | +EXPORT_SYMBOL_GPL(i2c_new_ancillary_device); | |
| 1008 | 1006 | |
| 1009 | 1007 | /* ------------------------------------------------------------------------- */ |
| 1010 | 1008 | |
| @@ -11,6 +11,13 @@ · 10 unmodified lines | ||
| 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> |
| @@ -21,12 +28,18 @@ · 4 unmodified lines | ||
| 21 | 28 | |
| 22 | 29 | struct eeprom_data { |
| 23 | 30 | struct bin_attribute bin; |
| 24 | − bool first_write; | |
| 25 | 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 | 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 | + | |
| 30 | 43 | static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, |
| 31 | 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, · 1 unmodified line | ||
| 34 | 47 | |
| 35 | 48 | switch (event) { |
| 36 | 49 | case I2C_SLAVE_WRITE_RECEIVED: |
| 37 | − if (eeprom->first_write) { | |
| 38 | − eeprom->buffer_idx = *val; | |
| 39 | − eeprom->first_write = false; | |
| 50 | + if (eeprom->idx_write_cnt < eeprom->num_address_bytes) { | |
| 51 | + if (eeprom->idx_write_cnt == 0) | |
| 52 | + eeprom->buffer_idx = 0; | |
| 53 | + eeprom->buffer_idx = *val | (eeprom->buffer_idx << 8); | |
| 54 | + eeprom->idx_write_cnt++; | |
| 40 | 55 | } else { |
| 41 | 56 | spin_lock(&eeprom->buffer_lock); |
| 42 | − eeprom->buffer[eeprom->buffer_idx++] = *val; | |
| 57 | + eeprom->buffer[eeprom->buffer_idx++ & eeprom->address_mask] = *val; | |
| 43 | 58 | spin_unlock(&eeprom->buffer_lock); |
| 44 | 59 | } |
| 45 | 60 | break; |
| @@ -50,7 +65,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, · 4 unmodified lines | ||
| 50 | 65 | /* fallthrough */ |
| 51 | 66 | case I2C_SLAVE_READ_REQUESTED: |
| 52 | 67 | spin_lock(&eeprom->buffer_lock); |
| 53 | − *val = eeprom->buffer[eeprom->buffer_idx]; | |
| 68 | + *val = eeprom->buffer[eeprom->buffer_idx & eeprom->address_mask]; | |
| 54 | 69 | spin_unlock(&eeprom->buffer_lock); |
| 55 | 70 | /* |
| 56 | 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, · 4 unmodified lines | ||
| 61 | 76 | |
| 62 | 77 | case I2C_SLAVE_STOP: |
| 63 | 78 | case I2C_SLAVE_WRITE_REQUESTED: |
| 64 | − eeprom->first_write = true; | |
| 79 | + eeprom->idx_write_cnt = 0; | |
| 65 | 80 | break; |
| 66 | 81 | |
| 67 | 82 | default: |
| @@ -105,13 +120,16 @@ static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_de · 37 unmodified lines | ||
| 105 | 120 | { |
| 106 | 121 | struct eeprom_data *eeprom; |
| 107 | 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 | 126 | eeprom = devm_kzalloc(&client->dev, sizeof(struct eeprom_data) + size, GFP_KERNEL); |
| 111 | 127 | if (!eeprom) |
| 112 | 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 | 133 | spin_lock_init(&eeprom->buffer_lock); |
| 116 | 134 | i2c_set_clientdata(client, eeprom); |
| 117 | 135 | |
| @@ -146,7 +164,9 @@ static int i2c_slave_eeprom_remove(struct i2c_client *client) · 28 unmodified lines | ||
| 146 | 164 | } |
| 147 | 165 | |
| 148 | 166 | static const struct i2c_device_id i2c_slave_eeprom_id[] = { |
| 149 | − { "slave-24c02", 2048 / 8 }, | |
| 167 | + { "slave-24c02", I2C_SLAVE_DEVICE_MAGIC(2048 / 8, 0) }, | |
| 168 | + { "slave-24c32", I2C_SLAVE_DEVICE_MAGIC(32768 / 8, I2C_SLAVE_FLAG_ADDR16) }, | |
| 169 | + { "slave-24c64", I2C_SLAVE_DEVICE_MAGIC(65536 / 8, I2C_SLAVE_FLAG_ADDR16) }, | |
| 150 | 170 | { } |
| 151 | 171 | }; |
| 152 | 172 | MODULE_DEVICE_TABLE(i2c, i2c_slave_eeprom_id); |
| @@ -183,14 +183,14 @@ static int adv748x_initialise_clients(struct adv748x_state *state) · 182 unmodified lines | ||
| 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); |
| @@ -2862,10 +2862,8 @@ static void adv76xx_unregister_clients(struct adv76xx_state *state) · 2861 unmodified lines | ||
| 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, |
| @@ -2878,14 +2876,14 @@ static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd, · 6 unmodified lines | ||
| 2878 | 2876 | struct i2c_client *new_client; |
| 2879 | 2877 | |
| 2880 | 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 | 2880 | pdata->i2c_addresses[page]); |
| 2883 | 2881 | else |
| 2884 | − new_client = i2c_new_secondary_device(client, | |
| 2882 | + new_client = i2c_new_ancillary_device(client, | |
| 2885 | 2883 | adv76xx_default_addresses[page].name, |
| 2886 | 2884 | adv76xx_default_addresses[page].default_addr); |
| 2887 | 2885 | |
| 2888 | − if (new_client) | |
| 2886 | + if (!IS_ERR(new_client)) | |
| 2889 | 2887 | io_write(sd, io_reg, new_client->addr << 1); |
| 2890 | 2888 | |
| 2891 | 2889 | return new_client; |
| @@ -3516,15 +3514,19 @@ static int adv76xx_probe(struct i2c_client *client, · 624 unmodified lines | ||
| 3516 | 3514 | } |
| 3517 | 3515 | |
| 3518 | 3516 | for (i = 1; i < ADV76XX_PAGE_MAX; ++i) { |
| 3517 | + struct i2c_client *dummy_client; | |
| 3518 | + | |
| 3519 | 3519 | if (!(BIT(i) & state->info->page_mask)) |
| 3520 | 3520 | continue; |
| 3521 | 3521 | |
| 3522 | − state->i2c_clients[i] = adv76xx_dummy_client(sd, i); | |
| 3523 | − if (!state->i2c_clients[i]) { | |
| 3524 | − err = -EINVAL; | |
| 3522 | + dummy_client = adv76xx_dummy_client(sd, i); | |
| 3523 | + if (IS_ERR(dummy_client)) { | |
| 3524 | + err = PTR_ERR(dummy_client); | |
| 3525 | 3525 | v4l2_err(sd, "failed to create i2c client %u\n", i); |
| 3526 | 3526 | goto err_i2c; |
| 3527 | 3527 | } |
| 3528 | + | |
| 3529 | + state->i2c_clients[i] = dummy_client; | |
| 3528 | 3530 | } |
| 3529 | 3531 | |
| 3530 | 3532 | INIT_DELAYED_WORK(&state->delayed_work_enable_hotplug, |
| @@ -14,7 +14,6 @@ · 13 unmodified lines | ||
| 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> |
| @@ -48,6 +48,7 @@ · 47 unmodified lines | ||
| 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) */ |
| @@ -215,6 +216,23 @@ static int update_no_reboot_bit_mem(void *priv, bool set) · 161 unmodified lines | ||
| 215 | 216 | return 0; |
| 216 | 217 | } |
| 217 | 218 | |
| 219 | +static int update_no_reboot_bit_cnt(void *priv, bool set) | |
| 220 | +{ | |
| 221 | + struct iTCO_wdt_private *p = priv; | |
| 222 | + u16 val, newval; | |
| 223 | + | |
| 224 | + val = inw(TCO1_CNT(p)); | |
| 225 | + if (set) | |
| 226 | + val |= BIT(0); | |
| 227 | + else | |
| 228 | + val &= ~BIT(0); | |
| 229 | + outw(val, TCO1_CNT(p)); | |
| 230 | + newval = inw(TCO1_CNT(p)); | |
| 231 | + | |
| 232 | + /* make sure the update is successful */ | |
| 233 | + return val != newval ? -EIO : 0; | |
| 234 | +} | |
| 235 | + | |
| 218 | 236 | static void iTCO_wdt_no_reboot_bit_setup(struct iTCO_wdt_private *p, |
| 219 | 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, · 3 unmodified lines | ||
| 224 | 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 | 248 | p->update_no_reboot_bit = update_no_reboot_bit_mem; |
| 229 | 249 | else if (p->iTCO_version == 1) |
| 230 | 250 | p->update_no_reboot_bit = update_no_reboot_bit_pci; |
| @@ -452,7 +472,8 @@ static int iTCO_wdt_probe(struct platform_device *pdev) · 221 unmodified lines | ||
| 452 | 472 | * Get the Memory-Mapped GCS or PMC register, we need it for the |
| 453 | 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 | 477 | p->gcs_pmc_res = platform_get_resource(pdev, |
| 457 | 478 | IORESOURCE_MEM, |
| 458 | 479 | ICH_RES_MEM_GCS_PMC); |
| @@ -502,6 +523,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) · 43 unmodified lines | ||
| 502 | 523 | |
| 503 | 524 | /* Clear out the (probably old) status */ |
| 504 | 525 | switch (p->iTCO_version) { |
| 526 | + case 6: | |
| 505 | 527 | case 5: |
| 506 | 528 | case 4: |
| 507 | 529 | outw(0x0008, TCO1_STS(p)); /* Clear the Time Out Status bit */ |
| @@ -473,7 +473,7 @@ extern struct i2c_client * · 472 unmodified lines | ||
| 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 | |