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

Merge tag 'i2c-for-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
"Mostly fixes for DTs or DT handling this time. And a few driver
bugfixes"

* tag 'i2c-for-6.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (28 commits)
i2c: xiic: xiic_xfer(): Fix runtime PM leak on error path
i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
i2c: omap: Improve error reporting for problems during .remove()
i2c: cadence: Add reset controller support
dt-bindings: i2c: cadence: Document `resets` property
i2c: mediatek: add support for MT7981 SoC
dt-bindings: i2c: i2c-mt65xx: add MediaTek MT7981 SoC
dt-bindings: i2c: Drop unneeded quotes
i2c: brcmstb: use devm_platform_ioremap_resource_byname()
i2c: cadence: Detect maximum transfer size
i2c: cadence: Allow to specify the FIFO depth
dt-bindings: i2c: cadence: Document `fifo-depth` property
i2c: xiic: Use devm_platform_get_and_ioremap_resource()
i2c: mpc: Use i2c-scl-clk-low-timeout-us i2c property
i2c: mpc: Use of_property_read_u32 instead of of_get_property
dt-bindings: i2c: mpc: Mark "fsl,timeout" as deprecated
i2c: xiic: hide OF related data for COMPILE_TEST
i2c: synquacer: mark OF related data as maybe unused
dt-bindings: i2c: i2c-mt65xx: Add compatible for MT6795 Helio X10
i2c: imx: Simplify using devm_clk_get_enabled()
...

+182 -94
+2 -2
Documentation/devicetree/bindings/i2c/amlogic,meson6-i2c.yaml
··· 2 2 # Copyright 2019 BayLibre, SAS 3 3 %YAML 1.2 4 4 --- 5 - $id: "http://devicetree.org/schemas/i2c/amlogic,meson6-i2c.yaml#" 6 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 5 + $id: http://devicetree.org/schemas/i2c/amlogic,meson6-i2c.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 7 8 8 title: Amlogic Meson I2C Controller 9 9
+2 -2
Documentation/devicetree/bindings/i2c/apple,i2c.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/i2c/apple,i2c.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/i2c/apple,i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Apple/PASemi I2C controller 8 8
+1 -1
Documentation/devicetree/bindings/i2c/atmel,at91sam-i2c.yaml
··· 75 75 - clocks 76 76 77 77 allOf: 78 - - $ref: "i2c-controller.yaml" 78 + - $ref: i2c-controller.yaml 79 79 - if: 80 80 properties: 81 81 compatible:
+14 -2
Documentation/devicetree/bindings/i2c/cdns,i2c-r1p10.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/i2c/cdns,i2c-r1p10.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/i2c/cdns,i2c-r1p10.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Cadence I2C controller 8 8 ··· 24 24 clocks: 25 25 minItems: 1 26 26 27 + resets: 28 + maxItems: 1 29 + 27 30 interrupts: 28 31 maxItems: 1 29 32 ··· 40 37 const: pclk 41 38 description: | 42 39 Input clock name. 40 + 41 + fifo-depth: 42 + description: 43 + Size of the data FIFO in bytes. 44 + $ref: /schemas/types.yaml#/definitions/uint32 45 + default: 16 46 + enum: [2, 4, 8, 16, 32, 64, 128, 256] 43 47 44 48 required: 45 49 - compatible ··· 62 52 i2c@e0004000 { 63 53 compatible = "cdns,i2c-r1p10"; 64 54 clocks = <&clkc 38>; 55 + resets = <&rstc 288>; 65 56 interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; 66 57 reg = <0xe0004000 0x1000>; 67 58 clock-frequency = <400000>; 68 59 #address-cells = <1>; 69 60 #size-cells = <0>; 61 + fifo-depth = <8>; 70 62 };
+2 -1
Documentation/devicetree/bindings/i2c/i2c-mpc.yaml
··· 43 43 44 44 fsl,timeout: 45 45 $ref: /schemas/types.yaml#/definitions/uint32 46 + deprecated: true 46 47 description: | 47 48 I2C bus timeout in microseconds 48 49 ··· 96 95 interrupts = <43 2>; 97 96 interrupt-parent = <&mpic>; 98 97 clock-frequency = <400000>; 99 - fsl,timeout = <10000>; 98 + i2c-scl-clk-low-timeout-us = <10000>; 100 99 }; 101 100 ...
+5
Documentation/devicetree/bindings/i2c/i2c-mt65xx.yaml
··· 23 23 - const: mediatek,mt6577-i2c 24 24 - const: mediatek,mt6589-i2c 25 25 - const: mediatek,mt7622-i2c 26 + - const: mediatek,mt7981-i2c 26 27 - const: mediatek,mt7986-i2c 27 28 - const: mediatek,mt8168-i2c 28 29 - const: mediatek,mt8173-i2c ··· 46 45 - enum: 47 46 - mediatek,mt8365-i2c 48 47 - const: mediatek,mt8168-i2c 48 + - items: 49 + - enum: 50 + - mediatek,mt6795-i2c 51 + - const: mediatek,mt8173-i2c 49 52 - items: 50 53 - enum: 51 54 - mediatek,mt8195-i2c
+2 -2
Documentation/devicetree/bindings/i2c/i2c-mux-gpio.yaml
··· 45 45 46 46 i2c-parent: 47 47 description: phandle of the I2C bus that this multiplexer's master-side port is connected to 48 - $ref: "/schemas/types.yaml#/definitions/phandle" 48 + $ref: /schemas/types.yaml#/definitions/phandle 49 49 50 50 mux-gpios: 51 51 description: list of GPIOs used to control the muxer ··· 55 55 idle-state: 56 56 description: Value to set the muxer to when idle. When no value is given, it defaults to the 57 57 last value used. 58 - $ref: "/schemas/types.yaml#/definitions/uint32" 58 + $ref: /schemas/types.yaml#/definitions/uint32 59 59 60 60 allOf: 61 61 - $ref: i2c-mux.yaml
+2 -2
Documentation/devicetree/bindings/i2c/qcom,i2c-geni-qcom.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/i2c/qcom,i2c-geni-qcom.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/i2c/qcom,i2c-geni-qcom.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Qualcomm Geni based QUP I2C Controller 8 8
+1 -1
Documentation/devicetree/bindings/i2c/st,stm32-i2c.yaml
··· 90 90 st,syscfg-fmp: 91 91 description: Use to set Fast Mode Plus bit within SYSCFG when Fast Mode 92 92 Plus speed is selected by slave. 93 - $ref: "/schemas/types.yaml#/definitions/phandle-array" 93 + $ref: /schemas/types.yaml#/definitions/phandle-array 94 94 items: 95 95 - items: 96 96 - description: phandle to syscfg
+2 -2
Documentation/devicetree/bindings/i2c/xlnx,xps-iic-2.00.a.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: "http://devicetree.org/schemas/i2c/xlnx,xps-iic-2.00.a.yaml#" 5 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 4 + $id: http://devicetree.org/schemas/i2c/xlnx,xps-iic-2.00.a.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 6 7 7 title: Xilinx IIC controller 8 8
+1 -1
drivers/i2c/busses/Kconfig
··· 807 807 808 808 config I2C_MICROCHIP_CORE 809 809 tristate "Microchip FPGA I2C controller" 810 - depends on SOC_MICROCHIP_POLARFIRE || COMPILE_TEST 810 + depends on ARCH_MICROCHIP_POLARFIRE || COMPILE_TEST 811 811 depends on OF 812 812 help 813 813 If you say yes to this option, support will be included for the
+1 -3
drivers/i2c/busses/i2c-brcmstb.c
··· 575 575 static int bcm2711_release_bsc(struct brcmstb_i2c_dev *dev) 576 576 { 577 577 struct platform_device *pdev = to_platform_device(dev->device); 578 - struct resource *iomem; 579 578 void __iomem *autoi2c; 580 579 581 580 /* Map hardware registers */ 582 - iomem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "auto-i2c"); 583 - autoi2c = devm_ioremap_resource(&pdev->dev, iomem); 581 + autoi2c = devm_platform_ioremap_resource_byname(pdev, "auto-i2c"); 584 582 if (IS_ERR(autoi2c)) 585 583 return PTR_ERR(autoi2c); 586 584
+88 -29
drivers/i2c/busses/i2c-cadence.c
··· 16 16 #include <linux/of.h> 17 17 #include <linux/pm_runtime.h> 18 18 #include <linux/pinctrl/consumer.h> 19 + #include <linux/reset.h> 19 20 20 21 /* Register offsets for the I2C device. */ 21 22 #define CDNS_I2C_CR_OFFSET 0x00 /* Control Register, RW */ ··· 115 114 /* timeout for pm runtime autosuspend */ 116 115 #define CNDS_I2C_PM_TIMEOUT 1000 /* ms */ 117 116 118 - #define CDNS_I2C_FIFO_DEPTH 16 117 + #define CDNS_I2C_FIFO_DEPTH_DEFAULT 16 119 118 #define CDNS_I2C_MAX_TRANSFER_SIZE 255 120 119 /* Transfer size in multiples of data interrupt depth */ 121 - #define CDNS_I2C_TRANSFER_SIZE (CDNS_I2C_MAX_TRANSFER_SIZE - 3) 120 + #define CDNS_I2C_TRANSFER_SIZE(max) ((max) - 3) 122 121 123 122 #define DRIVER_NAME "cdns-i2c" 124 123 ··· 179 178 * @bus_hold_flag: Flag used in repeated start for clearing HOLD bit 180 179 * @clk: Pointer to struct clk 181 180 * @clk_rate_change_nb: Notifier block for clock rate changes 181 + * @reset: Reset control for the device 182 182 * @quirks: flag for broken hold bit usage in r1p10 183 183 * @ctrl_reg: Cached value of the control register. 184 184 * @ctrl_reg_diva_divb: value of fields DIV_A and DIV_B from CR register 185 185 * @slave: Registered slave instance. 186 186 * @dev_mode: I2C operating role(master/slave). 187 187 * @slave_state: I2C Slave state(idle/read/write). 188 + * @fifo_depth: The depth of the transfer FIFO 189 + * @transfer_size: The maximum number of bytes in one transfer 188 190 */ 189 191 struct cdns_i2c { 190 192 struct device *dev; ··· 206 202 unsigned int bus_hold_flag; 207 203 struct clk *clk; 208 204 struct notifier_block clk_rate_change_nb; 205 + struct reset_control *reset; 209 206 u32 quirks; 210 207 u32 ctrl_reg; 211 208 struct i2c_bus_recovery_info rinfo; ··· 216 211 enum cdns_i2c_mode dev_mode; 217 212 enum cdns_i2c_slave_state slave_state; 218 213 #endif 214 + u32 fifo_depth; 215 + unsigned int transfer_size; 219 216 }; 220 217 221 218 struct cdns_platform_data { ··· 243 236 static inline bool cdns_is_holdquirk(struct cdns_i2c *id, bool hold_wrkaround) 244 237 { 245 238 return (hold_wrkaround && 246 - (id->curr_recv_count == CDNS_I2C_FIFO_DEPTH + 1)); 239 + (id->curr_recv_count == id->fifo_depth + 1)); 247 240 } 248 241 249 242 #if IS_ENABLED(CONFIG_I2C_SLAVE) ··· 438 431 * if RX data left is less than or equal to 439 432 * FIFO DEPTH unless repeated start is selected 440 433 */ 441 - if (id->recv_count <= CDNS_I2C_FIFO_DEPTH && 434 + if (id->recv_count <= id->fifo_depth && 442 435 !id->bus_hold_flag) 443 436 cdns_i2c_clear_bus_hold(id); 444 437 ··· 463 456 if (cdns_is_holdquirk(id, updatetx)) { 464 457 /* wait while fifo is full */ 465 458 while (cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET) != 466 - (id->curr_recv_count - CDNS_I2C_FIFO_DEPTH)) 459 + (id->curr_recv_count - id->fifo_depth)) 467 460 ; 468 461 469 462 /* 470 463 * Check number of bytes to be received against maximum 471 464 * transfer size and update register accordingly. 472 465 */ 473 - if (((int)(id->recv_count) - CDNS_I2C_FIFO_DEPTH) > 474 - CDNS_I2C_TRANSFER_SIZE) { 475 - cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE, 466 + if (((int)(id->recv_count) - id->fifo_depth) > 467 + id->transfer_size) { 468 + cdns_i2c_writereg(id->transfer_size, 476 469 CDNS_I2C_XFER_SIZE_OFFSET); 477 - id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE + 478 - CDNS_I2C_FIFO_DEPTH; 470 + id->curr_recv_count = id->transfer_size + 471 + id->fifo_depth; 479 472 } else { 480 473 cdns_i2c_writereg(id->recv_count - 481 - CDNS_I2C_FIFO_DEPTH, 474 + id->fifo_depth, 482 475 CDNS_I2C_XFER_SIZE_OFFSET); 483 476 id->curr_recv_count = id->recv_count; 484 477 } ··· 501 494 * space available in FIFO and fill with that many bytes. 502 495 */ 503 496 if (id->send_count) { 504 - avail_bytes = CDNS_I2C_FIFO_DEPTH - 497 + avail_bytes = id->fifo_depth - 505 498 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET); 506 499 if (id->send_count > avail_bytes) 507 500 bytes_to_send = avail_bytes; ··· 595 588 * Check for the message size against FIFO depth and set the 596 589 * 'hold bus' bit if it is greater than FIFO depth. 597 590 */ 598 - if (id->recv_count > CDNS_I2C_FIFO_DEPTH) 591 + if (id->recv_count > id->fifo_depth) 599 592 ctrl_reg |= CDNS_I2C_CR_HOLD; 600 593 601 594 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); ··· 610 603 * receive if it is less than transfer size and transfer size if 611 604 * it is more. Enable the interrupts. 612 605 */ 613 - if (id->recv_count > CDNS_I2C_TRANSFER_SIZE) { 614 - cdns_i2c_writereg(CDNS_I2C_TRANSFER_SIZE, 606 + if (id->recv_count > id->transfer_size) { 607 + cdns_i2c_writereg(id->transfer_size, 615 608 CDNS_I2C_XFER_SIZE_OFFSET); 616 - id->curr_recv_count = CDNS_I2C_TRANSFER_SIZE; 609 + id->curr_recv_count = id->transfer_size; 617 610 } else { 618 611 cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET); 619 612 } 620 613 621 614 /* Determine hold_clear based on number of bytes to receive and hold flag */ 622 - if (!id->bus_hold_flag && id->recv_count <= CDNS_I2C_FIFO_DEPTH) { 623 - if (cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & CDNS_I2C_CR_HOLD) { 615 + if (!id->bus_hold_flag && id->recv_count <= id->fifo_depth) { 616 + if (ctrl_reg & CDNS_I2C_CR_HOLD) { 624 617 hold_clear = true; 625 618 if (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) 626 619 irq_save = true; ··· 631 624 addr &= CDNS_I2C_ADDR_MASK; 632 625 633 626 if (hold_clear) { 634 - ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & ~CDNS_I2C_CR_HOLD; 627 + ctrl_reg &= ~CDNS_I2C_CR_HOLD; 635 628 /* 636 629 * In case of Xilinx Zynq SOC, clear the HOLD bit before transfer size 637 630 * register reaches '0'. This is an IP bug which causes transfer size ··· 680 673 * Check for the message size against FIFO depth and set the 681 674 * 'hold bus' bit if it is greater than FIFO depth. 682 675 */ 683 - if (id->send_count > CDNS_I2C_FIFO_DEPTH) 676 + if (id->send_count > id->fifo_depth) 684 677 ctrl_reg |= CDNS_I2C_CR_HOLD; 685 678 cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); 686 679 ··· 693 686 * against the space available, and fill the FIFO accordingly. 694 687 * Enable the interrupts. 695 688 */ 696 - avail_bytes = CDNS_I2C_FIFO_DEPTH - 689 + avail_bytes = id->fifo_depth - 697 690 cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET); 698 691 699 692 if (id->send_count > avail_bytes) ··· 834 827 #if IS_ENABLED(CONFIG_I2C_SLAVE) 835 828 /* Check i2c operating mode and switch if possible */ 836 829 if (id->dev_mode == CDNS_I2C_MODE_SLAVE) { 837 - if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE) 838 - return -EAGAIN; 830 + if (id->slave_state != CDNS_I2C_SLAVE_STATE_IDLE) { 831 + ret = -EAGAIN; 832 + goto out; 833 + } 839 834 840 835 /* Set mode to master */ 841 836 cdns_i2c_set_mode(CDNS_I2C_MODE_MASTER, id); ··· 1039 1030 if (actual_fscl > fscl) 1040 1031 continue; 1041 1032 1042 - current_error = ((actual_fscl > fscl) ? (actual_fscl - fscl) : 1043 - (fscl - actual_fscl)); 1033 + current_error = fscl - actual_fscl; 1044 1034 1045 1035 if (last_error > current_error) { 1046 1036 calc_div_a = div_a; ··· 1235 1227 MODULE_DEVICE_TABLE(of, cdns_i2c_of_match); 1236 1228 1237 1229 /** 1230 + * cdns_i2c_detect_transfer_size - Detect the maximum transfer size supported 1231 + * @id: Device private data structure 1232 + * 1233 + * Detect the maximum transfer size that is supported by this instance of the 1234 + * Cadence I2C controller. 1235 + */ 1236 + static void cdns_i2c_detect_transfer_size(struct cdns_i2c *id) 1237 + { 1238 + u32 val; 1239 + 1240 + /* 1241 + * Writing to the transfer size register is only possible if these two bits 1242 + * are set in the control register. 1243 + */ 1244 + cdns_i2c_writereg(CDNS_I2C_CR_MS | CDNS_I2C_CR_RW, CDNS_I2C_CR_OFFSET); 1245 + 1246 + /* 1247 + * The number of writable bits of the transfer size register can be between 1248 + * 4 and 8. This is a controlled through a synthesis parameter of the IP 1249 + * core and can vary from instance to instance. The unused MSBs always read 1250 + * back as 0. Writing 0xff and then reading the value back will report the 1251 + * maximum supported transfer size. 1252 + */ 1253 + cdns_i2c_writereg(CDNS_I2C_MAX_TRANSFER_SIZE, CDNS_I2C_XFER_SIZE_OFFSET); 1254 + val = cdns_i2c_readreg(CDNS_I2C_XFER_SIZE_OFFSET); 1255 + id->transfer_size = CDNS_I2C_TRANSFER_SIZE(val); 1256 + cdns_i2c_writereg(0, CDNS_I2C_XFER_SIZE_OFFSET); 1257 + cdns_i2c_writereg(0, CDNS_I2C_CR_OFFSET); 1258 + } 1259 + 1260 + /** 1238 1261 * cdns_i2c_probe - Platform registration call 1239 1262 * @pdev: Handle to the platform device structure 1240 1263 * ··· 1330 1291 return dev_err_probe(&pdev->dev, PTR_ERR(id->clk), 1331 1292 "input clock not found.\n"); 1332 1293 1294 + id->reset = devm_reset_control_get_optional_shared(&pdev->dev, NULL); 1295 + if (IS_ERR(id->reset)) 1296 + return dev_err_probe(&pdev->dev, PTR_ERR(id->reset), 1297 + "Failed to request reset.\n"); 1298 + 1333 1299 ret = clk_prepare_enable(id->clk); 1334 1300 if (ret) 1335 1301 dev_err(&pdev->dev, "Unable to enable clock.\n"); 1302 + 1303 + ret = reset_control_deassert(id->reset); 1304 + if (ret) { 1305 + dev_err_probe(&pdev->dev, ret, 1306 + "Failed to de-assert reset.\n"); 1307 + goto err_clk_dis; 1308 + } 1336 1309 1337 1310 pm_runtime_set_autosuspend_delay(id->dev, CNDS_I2C_PM_TIMEOUT); 1338 1311 pm_runtime_use_autosuspend(id->dev); ··· 1368 1317 #endif 1369 1318 id->ctrl_reg = CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS; 1370 1319 1320 + id->fifo_depth = CDNS_I2C_FIFO_DEPTH_DEFAULT; 1321 + of_property_read_u32(pdev->dev.of_node, "fifo-depth", &id->fifo_depth); 1322 + 1323 + cdns_i2c_detect_transfer_size(id); 1324 + 1371 1325 ret = cdns_i2c_setclk(id->input_clk, id); 1372 1326 if (ret) { 1373 1327 dev_err(&pdev->dev, "invalid SCL clock: %u Hz\n", id->i2c_clk); 1374 1328 ret = -EINVAL; 1375 - goto err_clk_dis; 1329 + goto err_clk_notifier_unregister; 1376 1330 } 1377 1331 1378 1332 ret = devm_request_irq(&pdev->dev, irq, cdns_i2c_isr, 0, 1379 1333 DRIVER_NAME, id); 1380 1334 if (ret) { 1381 1335 dev_err(&pdev->dev, "cannot get irq %d\n", irq); 1382 - goto err_clk_dis; 1336 + goto err_clk_notifier_unregister; 1383 1337 } 1384 1338 cdns_i2c_init(id); 1385 1339 1386 1340 ret = i2c_add_adapter(&id->adap); 1387 1341 if (ret < 0) 1388 - goto err_clk_dis; 1342 + goto err_clk_notifier_unregister; 1389 1343 1390 1344 dev_info(&pdev->dev, "%u kHz mmio %08lx irq %d\n", 1391 1345 id->i2c_clk / 1000, (unsigned long)r_mem->start, irq); 1392 1346 1393 1347 return 0; 1394 1348 1395 - err_clk_dis: 1349 + err_clk_notifier_unregister: 1396 1350 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); 1351 + reset_control_assert(id->reset); 1352 + err_clk_dis: 1397 1353 clk_disable_unprepare(id->clk); 1398 1354 pm_runtime_disable(&pdev->dev); 1399 1355 pm_runtime_set_suspended(&pdev->dev); ··· 1425 1367 1426 1368 i2c_del_adapter(&id->adap); 1427 1369 clk_notifier_unregister(id->clk, &id->clk_rate_change_nb); 1370 + reset_control_assert(id->reset); 1428 1371 clk_disable_unprepare(id->clk); 1429 1372 1430 1373 return 0;
+2 -2
drivers/i2c/busses/i2c-cros-ec-tunnel.c
··· 292 292 return 0; 293 293 } 294 294 295 - static const struct of_device_id cros_ec_i2c_of_match[] = { 295 + static const struct of_device_id cros_ec_i2c_of_match[] __maybe_unused = { 296 296 { .compatible = "google,cros-ec-i2c-tunnel" }, 297 297 {}, 298 298 }; 299 299 MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match); 300 300 301 - static const struct acpi_device_id cros_ec_i2c_tunnel_acpi_id[] = { 301 + static const struct acpi_device_id cros_ec_i2c_tunnel_acpi_id[] __maybe_unused = { 302 302 { "GOOG0012", 0 }, 303 303 { } 304 304 };
+1 -4
drivers/i2c/busses/i2c-davinci.c
··· 764 764 int r, irq; 765 765 766 766 irq = platform_get_irq(pdev, 0); 767 - if (irq <= 0) { 768 - if (!irq) 769 - irq = -ENXIO; 767 + if (irq < 0) 770 768 return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n"); 771 - } 772 769 773 770 dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev), 774 771 GFP_KERNEL);
+1 -11
drivers/i2c/busses/i2c-imx.c
··· 1482 1482 ACPI_COMPANION_SET(&i2c_imx->adapter.dev, ACPI_COMPANION(&pdev->dev)); 1483 1483 1484 1484 /* Get I2C clock */ 1485 - i2c_imx->clk = devm_clk_get(&pdev->dev, NULL); 1485 + i2c_imx->clk = devm_clk_get_enabled(&pdev->dev, NULL); 1486 1486 if (IS_ERR(i2c_imx->clk)) 1487 1487 return dev_err_probe(&pdev->dev, PTR_ERR(i2c_imx->clk), 1488 1488 "can't get I2C clock\n"); 1489 - 1490 - ret = clk_prepare_enable(i2c_imx->clk); 1491 - if (ret) { 1492 - dev_err(&pdev->dev, "can't enable I2C clock, ret=%d\n", ret); 1493 - return ret; 1494 - } 1495 1489 1496 1490 /* Init queue */ 1497 1491 init_waitqueue_head(&i2c_imx->queue); ··· 1558 1564 pm_runtime_disable(&pdev->dev); 1559 1565 pm_runtime_set_suspended(&pdev->dev); 1560 1566 pm_runtime_dont_use_autosuspend(&pdev->dev); 1561 - clk_disable_unprepare(i2c_imx->clk); 1562 1567 return ret; 1563 1568 } 1564 1569 ··· 1583 1590 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_IFDR); 1584 1591 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2CR); 1585 1592 imx_i2c_write_reg(0, i2c_imx, IMX_I2C_I2SR); 1586 - clk_disable(i2c_imx->clk); 1587 1593 } 1588 1594 1589 1595 clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); 1590 1596 irq = platform_get_irq(pdev, 0); 1591 1597 if (irq >= 0) 1592 1598 free_irq(irq, i2c_imx); 1593 - 1594 - clk_unprepare(i2c_imx->clk); 1595 1599 1596 1600 pm_runtime_put_noidle(&pdev->dev); 1597 1601 pm_runtime_disable(&pdev->dev);
+24 -13
drivers/i2c/busses/i2c-mpc.c
··· 770 770 static struct i2c_adapter mpc_ops = { 771 771 .owner = THIS_MODULE, 772 772 .algo = &mpc_algo, 773 - .timeout = HZ, 774 773 }; 775 774 776 775 static struct i2c_bus_recovery_info fsl_i2c_recovery_info = { ··· 780 781 { 781 782 const struct mpc_i2c_data *data; 782 783 struct mpc_i2c *i2c; 783 - const u32 *prop; 784 - u32 clock = MPC_I2C_CLOCK_LEGACY; 785 - int result = 0; 786 - int plen; 787 784 struct clk *clk; 785 + int result; 786 + u32 clock; 788 787 int err; 789 788 790 789 i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL); ··· 828 831 if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) { 829 832 clock = MPC_I2C_CLOCK_PRESERVE; 830 833 } else { 831 - prop = of_get_property(op->dev.of_node, "clock-frequency", 832 - &plen); 833 - if (prop && plen == sizeof(u32)) 834 - clock = *prop; 834 + result = of_property_read_u32(op->dev.of_node, 835 + "clock-frequency", &clock); 836 + if (result) 837 + clock = MPC_I2C_CLOCK_LEGACY; 835 838 } 836 839 837 840 data = device_get_match_data(&op->dev); ··· 839 842 data->setup(op->dev.of_node, i2c, clock); 840 843 } else { 841 844 /* Backwards compatibility */ 842 - if (of_get_property(op->dev.of_node, "dfsrr", NULL)) 845 + if (of_property_read_bool(op->dev.of_node, "dfsrr")) 843 846 mpc_i2c_setup_8xxx(op->dev.of_node, i2c, clock); 844 847 } 845 848 846 - prop = of_get_property(op->dev.of_node, "fsl,timeout", &plen); 847 - if (prop && plen == sizeof(u32)) { 848 - mpc_ops.timeout = *prop * HZ / 1000000; 849 + /* 850 + * "fsl,timeout" has been marked as deprecated and, to maintain 851 + * backward compatibility, we will only look for it if 852 + * "i2c-scl-clk-low-timeout-us" is not present. 853 + */ 854 + result = of_property_read_u32(op->dev.of_node, 855 + "i2c-scl-clk-low-timeout-us", 856 + &mpc_ops.timeout); 857 + if (result == -EINVAL) 858 + result = of_property_read_u32(op->dev.of_node, 859 + "fsl,timeout", &mpc_ops.timeout); 860 + 861 + if (!result) { 862 + mpc_ops.timeout *= HZ / 1000000; 849 863 if (mpc_ops.timeout < 5) 850 864 mpc_ops.timeout = 5; 865 + } else { 866 + mpc_ops.timeout = HZ; 851 867 } 868 + 852 869 dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ); 853 870 854 871 if (of_property_read_bool(op->dev.of_node, "fsl,i2c-erratum-a004447"))
+14 -1
drivers/i2c/busses/i2c-mt65xx.c
··· 431 431 .max_dma_support = 33, 432 432 }; 433 433 434 + static const struct mtk_i2c_compatible mt7981_compat = { 435 + .regs = mt_i2c_regs_v3, 436 + .pmic_i2c = 0, 437 + .dcm = 0, 438 + .auto_restart = 1, 439 + .aux_len_reg = 1, 440 + .timing_adjust = 1, 441 + .dma_sync = 1, 442 + .ltiming_adjust = 1, 443 + .max_dma_support = 33 444 + }; 445 + 434 446 static const struct mtk_i2c_compatible mt7986_compat = { 435 447 .quirks = &mt7622_i2c_quirks, 436 448 .regs = mt_i2c_regs_v1, ··· 528 516 { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, 529 517 { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, 530 518 { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, 519 + { .compatible = "mediatek,mt7981-i2c", .data = &mt7981_compat }, 531 520 { .compatible = "mediatek,mt7986-i2c", .data = &mt7986_compat }, 532 521 { .compatible = "mediatek,mt8168-i2c", .data = &mt8168_compat }, 533 522 { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, ··· 1559 1546 .driver = { 1560 1547 .name = I2C_DRV_NAME, 1561 1548 .pm = &mtk_i2c_pm, 1562 - .of_match_table = of_match_ptr(mtk_i2c_of_match), 1549 + .of_match_table = mtk_i2c_of_match, 1563 1550 }, 1564 1551 }; 1565 1552
+7 -4
drivers/i2c/busses/i2c-omap.c
··· 1525 1525 int ret; 1526 1526 1527 1527 i2c_del_adapter(&omap->adapter); 1528 - ret = pm_runtime_resume_and_get(&pdev->dev); 1529 - if (ret < 0) 1530 - return ret; 1531 1528 1532 - omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 1529 + ret = pm_runtime_get_sync(&pdev->dev); 1530 + if (ret < 0) 1531 + dev_err(omap->dev, "Failed to resume hardware, skip disable\n"); 1532 + else 1533 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 1534 + 1533 1535 pm_runtime_dont_use_autosuspend(&pdev->dev); 1534 1536 pm_runtime_put_sync(&pdev->dev); 1535 1537 pm_runtime_disable(&pdev->dev); 1538 + 1536 1539 return 0; 1537 1540 } 1538 1541
+1 -1
drivers/i2c/busses/i2c-owl.c
··· 519 519 .probe = owl_i2c_probe, 520 520 .driver = { 521 521 .name = "owl-i2c", 522 - .of_match_table = of_match_ptr(owl_i2c_of_match), 522 + .of_match_table = owl_i2c_of_match, 523 523 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 524 524 }, 525 525 };
+2 -4
drivers/i2c/busses/i2c-pxa.c
··· 1261 1261 /* For device tree we always use the dynamic or alias-assigned ID */ 1262 1262 i2c->adap.nr = -1; 1263 1263 1264 - if (of_get_property(np, "mrvl,i2c-polling", NULL)) 1265 - i2c->use_pio = 1; 1266 - if (of_get_property(np, "mrvl,i2c-fast-mode", NULL)) 1267 - i2c->fast_mode = 1; 1264 + i2c->use_pio = of_property_read_bool(np, "mrvl,i2c-polling"); 1265 + i2c->fast_mode = of_property_read_bool(np, "mrvl,i2c-fast-mode"); 1268 1266 1269 1267 *i2c_types = (enum pxa_i2c_types)(of_id->data); 1270 1268
+1 -1
drivers/i2c/busses/i2c-synquacer.c
··· 629 629 return 0; 630 630 }; 631 631 632 - static const struct of_device_id synquacer_i2c_dt_ids[] = { 632 + static const struct of_device_id synquacer_i2c_dt_ids[] __maybe_unused = { 633 633 { .compatible = "socionext,synquacer-i2c" }, 634 634 { /* sentinel */ } 635 635 };
+5 -4
drivers/i2c/busses/i2c-xiic.c
··· 1164 1164 err = xiic_start_xfer(i2c, msgs, num); 1165 1165 if (err < 0) { 1166 1166 dev_err(adap->dev.parent, "Error xiic_start_xfer\n"); 1167 - return err; 1167 + goto out; 1168 1168 } 1169 1169 1170 1170 err = wait_for_completion_timeout(&i2c->completion, XIIC_XFER_TIMEOUT); ··· 1178 1178 err = (i2c->state == STATE_DONE) ? num : -EIO; 1179 1179 } 1180 1180 mutex_unlock(&i2c->lock); 1181 + 1182 + out: 1181 1183 pm_runtime_mark_last_busy(i2c->dev); 1182 1184 pm_runtime_put_autosuspend(i2c->dev); 1183 1185 return err; ··· 1201 1199 .algo = &xiic_algorithm, 1202 1200 }; 1203 1201 1202 + #if defined(CONFIG_OF) 1204 1203 static const struct xiic_version_data xiic_2_00 = { 1205 1204 .quirks = DYNAMIC_MODE_READ_BROKEN_BIT, 1206 1205 }; 1207 1206 1208 - #if defined(CONFIG_OF) 1209 1207 static const struct of_device_id xiic_of_match[] = { 1210 1208 { .compatible = "xlnx,xps-iic-2.00.a", .data = &xiic_2_00 }, 1211 1209 { .compatible = "xlnx,axi-iic-2.1", }, ··· 1235 1233 i2c->quirks = data->quirks; 1236 1234 } 1237 1235 1238 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1239 - i2c->base = devm_ioremap_resource(&pdev->dev, res); 1236 + i2c->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1240 1237 if (IS_ERR(i2c->base)) 1241 1238 return PTR_ERR(i2c->base); 1242 1239
+1 -1
drivers/i2c/i2c-core-of.c
··· 55 55 if (of_property_read_bool(node, "host-notify")) 56 56 info->flags |= I2C_CLIENT_HOST_NOTIFY; 57 57 58 - if (of_get_property(node, "wakeup-source", NULL)) 58 + if (of_property_read_bool(node, "wakeup-source")) 59 59 info->flags |= I2C_CLIENT_WAKE; 60 60 61 61 return 0;