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

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

Pull i2c updates from Wolfram Sang:
"Core got a new helper 'i2c_client_get_device_id()', designware got
some bigger updates, the rest is driver updates all over the place"

* tag 'i2c-for-6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (41 commits)
i2c: ismt: Fix an out-of-bounds bug in ismt_access()
i2c: mux: reg: check return value after calling platform_get_resource()
i2c: xiic: Make sure to disable clock on .remove()
i2c: hisi: Add support to get clock frequency from clock
i2c: pxa-pci: fix missing pci_disable_device() on error in ce4100_i2c_probe
i2c: slave-eeprom: Convert to i2c's .probe_new()
i2c: mux: pca954x: Convert to i2c's .probe_new()
drivers/i2c: use simple i2c probe
i2c: mux: pca9541: switch to using .probe_new
i2c: gpio: Fix potential unused warning for 'i2c_gpio_dt_ids'
i2c: qcom-geni: add support for I2C Master Hub variant
i2c: qcom-geni: add desc struct to prepare support for I2C Master Hub variant
soc: qcom: geni-se: add support for I2C Master Hub wrapper variant
soc: qcom: geni-se: add desc struct to specify clocks from device match data
dt-bindings: i2c: qcom-geni: document I2C Master Hub serial I2C engine
dt-bindings: qcom: geni-se: document I2C Master Hub wrapper variant
dt-bindings: i2c: renesas,riic: Document RZ/Five SoC
i2c: tegra: Set ACPI node as primary fwnode
i2c: smbus: add DDR support for SPD
i2c: /pasemi: PASemi I2C controller IRQ enablement
...

+618 -322
+73
Documentation/devicetree/bindings/i2c/hisilicon,ascend910-i2c.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/i2c/hisilicon,ascend910-i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: HiSilicon common I2C controller 8 + 9 + maintainers: 10 + - Yicong Yang <yangyicong@hisilicon.com> 11 + 12 + description: 13 + The HiSilicon common I2C controller can be used for many different 14 + types of SoC such as Huawei Ascend AI series chips. 15 + 16 + allOf: 17 + - $ref: /schemas/i2c/i2c-controller.yaml# 18 + 19 + properties: 20 + compatible: 21 + const: hisilicon,ascend910-i2c 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + interrupts: 27 + maxItems: 1 28 + 29 + clocks: 30 + maxItems: 1 31 + 32 + clock-frequency: 33 + default: 400000 34 + 35 + i2c-sda-falling-time-ns: 36 + default: 343 37 + 38 + i2c-scl-falling-time-ns: 39 + default: 203 40 + 41 + i2c-sda-hold-time-ns: 42 + default: 830 43 + 44 + i2c-scl-rising-time-ns: 45 + default: 365 46 + 47 + i2c-digital-filter-width-ns: 48 + default: 0 49 + 50 + required: 51 + - compatible 52 + - reg 53 + - interrupts 54 + 55 + unevaluatedProperties: false 56 + 57 + examples: 58 + - | 59 + #include <dt-bindings/interrupt-controller/arm-gic.h> 60 + 61 + i2c@38b0000 { 62 + compatible = "hisilicon,ascend910-i2c"; 63 + reg = <0x38b0000 0x10000>; 64 + interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>; 65 + i2c-sda-falling-time-ns = <56>; 66 + i2c-scl-falling-time-ns = <56>; 67 + i2c-sda-hold-time-ns = <56>; 68 + i2c-scl-rising-time-ns = <56>; 69 + i2c-digital-filter; 70 + i2c-digital-filter-width-ns = <0x0>; 71 + clocks = <&alg_clk>; 72 + clock-frequency = <400000>; 73 + };
+1
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,mt7986-i2c 26 27 - const: mediatek,mt8168-i2c 27 28 - const: mediatek,mt8173-i2c 28 29 - const: mediatek,mt8183-i2c
+1
Documentation/devicetree/bindings/i2c/marvell,mv64xxx-i2c.yaml
··· 19 19 - const: allwinner,sun6i-a31-i2c 20 20 - items: 21 21 - enum: 22 + - allwinner,suniv-f1c100s-i2c 22 23 - allwinner,sun8i-a23-i2c 23 24 - allwinner,sun8i-a83t-i2c 24 25 - allwinner,sun8i-v536-i2c
+54 -10
Documentation/devicetree/bindings/i2c/qcom,i2c-geni-qcom.yaml
··· 10 10 - Andy Gross <agross@kernel.org> 11 11 - Bjorn Andersson <bjorn.andersson@linaro.org> 12 12 13 - allOf: 14 - - $ref: /schemas/i2c/i2c-controller.yaml# 15 - 16 13 properties: 17 14 compatible: 18 - const: qcom,geni-i2c 15 + enum: 16 + - qcom,geni-i2c 17 + - qcom,geni-i2c-master-hub 19 18 20 19 clocks: 21 - maxItems: 1 20 + minItems: 1 21 + maxItems: 2 22 22 23 23 clock-names: 24 - const: se 24 + minItems: 1 25 + maxItems: 2 25 26 26 27 clock-frequency: 27 28 default: 100000 ··· 36 35 - const: rx 37 36 38 37 interconnects: 38 + minItems: 2 39 39 maxItems: 3 40 40 41 41 interconnect-names: 42 - items: 43 - - const: qup-core 44 - - const: qup-config 45 - - const: qup-memory 42 + minItems: 2 43 + maxItems: 3 46 44 47 45 interrupts: 48 46 maxItems: 1 ··· 70 70 - clocks 71 71 - clock-names 72 72 - reg 73 + 74 + allOf: 75 + - $ref: /schemas/i2c/i2c-controller.yaml# 76 + - if: 77 + properties: 78 + compatible: 79 + contains: 80 + const: qcom,geni-i2c-master-hub 81 + then: 82 + properties: 83 + clocks: 84 + minItems: 2 85 + 86 + clock-names: 87 + items: 88 + - const: se 89 + - const: core 90 + 91 + dmas: false 92 + dma-names: false 93 + 94 + interconnects: 95 + maxItems: 2 96 + 97 + interconnect-names: 98 + items: 99 + - const: qup-core 100 + - const: qup-config 101 + else: 102 + properties: 103 + clocks: 104 + maxItems: 1 105 + 106 + clock-names: 107 + const: se 108 + 109 + interconnects: 110 + minItems: 3 111 + 112 + interconnect-names: 113 + items: 114 + - const: qup-core 115 + - const: qup-config 116 + - const: qup-memory 73 117 74 118 unevaluatedProperties: false 75 119
+1 -1
Documentation/devicetree/bindings/i2c/renesas,riic.yaml
··· 19 19 - enum: 20 20 - renesas,riic-r7s72100 # RZ/A1H 21 21 - renesas,riic-r7s9210 # RZ/A2M 22 - - renesas,riic-r9a07g043 # RZ/G2UL 22 + - renesas,riic-r9a07g043 # RZ/G2UL and RZ/Five 23 23 - renesas,riic-r9a07g044 # RZ/G2{L,LC} 24 24 - renesas,riic-r9a07g054 # RZ/V2L 25 25 - const: renesas,riic-rz # RZ/A or RZ/G2L
+38 -6
Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml
··· 21 21 compatible: 22 22 enum: 23 23 - qcom,geni-se-qup 24 + - qcom,geni-se-i2c-master-hub 24 25 25 26 reg: 26 27 description: QUP wrapper common register address and length. 27 28 maxItems: 1 28 29 29 30 clock-names: 30 - items: 31 - - const: m-ahb 32 - - const: s-ahb 31 + minItems: 1 32 + maxItems: 2 33 33 34 34 clocks: 35 - items: 36 - - description: Master AHB Clock 37 - - description: Slave AHB Clock 35 + minItems: 1 36 + maxItems: 2 38 37 39 38 "#address-cells": 40 39 const: 2 ··· 79 80 type: object 80 81 description: GENI Serial Engine based UART Controller. 81 82 $ref: /schemas/serial/qcom,serial-geni-qcom.yaml# 83 + 84 + allOf: 85 + - if: 86 + properties: 87 + compatible: 88 + contains: 89 + const: qcom,geni-se-i2c-master-hub 90 + then: 91 + properties: 92 + clock-names: 93 + items: 94 + - const: s-ahb 95 + 96 + clocks: 97 + items: 98 + - description: Slave AHB Clock 99 + 100 + iommus: false 101 + 102 + patternProperties: 103 + "spi@[0-9a-f]+$": false 104 + "serial@[0-9a-f]+$": false 105 + else: 106 + properties: 107 + clock-names: 108 + items: 109 + - const: m-ahb 110 + - const: s-ahb 111 + 112 + clocks: 113 + items: 114 + - description: Master AHB Clock 115 + - description: Slave AHB Clock 82 116 83 117 additionalProperties: false 84 118
+1
MAINTAINERS
··· 9290 9290 L: linux-i2c@vger.kernel.org 9291 9291 S: Maintained 9292 9292 W: https://www.hisilicon.com 9293 + F: Documentation/devicetree/bindings/i2c/hisilicon,ascend910-i2c.yaml 9293 9294 F: drivers/i2c/busses/i2c-hisi.c 9294 9295 9295 9296 HISILICON LPC BUS DRIVER
+1 -1
drivers/i2c/busses/Kconfig
··· 673 673 674 674 config I2C_HISI 675 675 tristate "HiSilicon I2C controller" 676 - depends on (ARM64 && ACPI) || COMPILE_TEST 676 + depends on ARM64 || COMPILE_TEST 677 677 help 678 678 Say Y here if you want to have Hisilicon I2C controller support 679 679 available on the Kunpeng Server.
+21 -9
drivers/i2c/busses/i2c-amd-mp2-pci.c
··· 288 288 static int amd_mp2_pci_init(struct amd_mp2_dev *privdata, 289 289 struct pci_dev *pci_dev) 290 290 { 291 - int rc; 291 + int irq_flag = 0, rc; 292 292 293 293 pci_set_drvdata(pci_dev, privdata); 294 294 ··· 311 311 if (rc) 312 312 goto err_dma_mask; 313 313 314 - /* Set up intx irq */ 314 + /* request and enable interrupt */ 315 315 writel(0, privdata->mmio + AMD_P2C_MSG_INTEN); 316 - pci_intx(pci_dev, 1); 317 - rc = devm_request_irq(&pci_dev->dev, pci_dev->irq, amd_mp2_irq_isr, 318 - IRQF_SHARED, dev_name(&pci_dev->dev), privdata); 319 - if (rc) 320 - pci_err(pci_dev, "Failure requesting irq %i: %d\n", 321 - pci_dev->irq, rc); 316 + rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES); 317 + if (rc < 0) { 318 + dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc); 319 + goto err_dma_mask; 320 + } 321 + 322 + privdata->dev_irq = pci_irq_vector(pci_dev, 0); 323 + if (!pci_dev->msix_enabled && !pci_dev->msi_enabled) 324 + irq_flag = IRQF_SHARED; 325 + 326 + rc = devm_request_irq(&pci_dev->dev, privdata->dev_irq, 327 + amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata); 328 + if (rc) { 329 + pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc); 330 + goto free_irq_vectors; 331 + } 322 332 323 333 return rc; 324 334 335 + free_irq_vectors: 336 + free_irq(privdata->dev_irq, privdata); 325 337 err_dma_mask: 326 338 pci_clear_master(pci_dev); 327 339 err_pci_enable: ··· 376 364 pm_runtime_forbid(&pci_dev->dev); 377 365 pm_runtime_get_noresume(&pci_dev->dev); 378 366 379 - pci_intx(pci_dev, 0); 367 + free_irq(privdata->dev_irq, privdata); 380 368 pci_clear_master(pci_dev); 381 369 382 370 amd_mp2_clear_reg(privdata);
+1
drivers/i2c/busses/i2c-amd-mp2.h
··· 183 183 struct mutex c2p_lock; 184 184 u8 c2p_lock_busid; 185 185 unsigned int probed; 186 + int dev_irq; 186 187 }; 187 188 188 189 /* PCIe communication driver */
-5
drivers/i2c/busses/i2c-designware-common.c
··· 625 625 i2c_dw_release_lock(dev); 626 626 } 627 627 628 - void i2c_dw_disable_int(struct dw_i2c_dev *dev) 629 - { 630 - regmap_write(dev->map, DW_IC_INTR_MASK, 0); 631 - } 632 - 633 628 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core"); 634 629 MODULE_LICENSE("GPL");
+110 -113
drivers/i2c/busses/i2c-designware-core.h
··· 18 18 #include <linux/regmap.h> 19 19 #include <linux/types.h> 20 20 21 - #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C | \ 22 - I2C_FUNC_SMBUS_BYTE | \ 23 - I2C_FUNC_SMBUS_BYTE_DATA | \ 24 - I2C_FUNC_SMBUS_WORD_DATA | \ 25 - I2C_FUNC_SMBUS_BLOCK_DATA | \ 26 - I2C_FUNC_SMBUS_I2C_BLOCK) 21 + #define DW_IC_DEFAULT_FUNCTIONALITY (I2C_FUNC_I2C | \ 22 + I2C_FUNC_SMBUS_BYTE | \ 23 + I2C_FUNC_SMBUS_BYTE_DATA | \ 24 + I2C_FUNC_SMBUS_WORD_DATA | \ 25 + I2C_FUNC_SMBUS_BLOCK_DATA | \ 26 + I2C_FUNC_SMBUS_I2C_BLOCK) 27 27 28 28 #define DW_IC_CON_MASTER BIT(0) 29 29 #define DW_IC_CON_SPEED_STD (1 << 1) ··· 43 43 /* 44 44 * Registers offset 45 45 */ 46 - #define DW_IC_CON 0x00 47 - #define DW_IC_TAR 0x04 48 - #define DW_IC_SAR 0x08 49 - #define DW_IC_DATA_CMD 0x10 50 - #define DW_IC_SS_SCL_HCNT 0x14 51 - #define DW_IC_SS_SCL_LCNT 0x18 52 - #define DW_IC_FS_SCL_HCNT 0x1c 53 - #define DW_IC_FS_SCL_LCNT 0x20 54 - #define DW_IC_HS_SCL_HCNT 0x24 55 - #define DW_IC_HS_SCL_LCNT 0x28 56 - #define DW_IC_INTR_STAT 0x2c 57 - #define DW_IC_INTR_MASK 0x30 58 - #define DW_IC_RAW_INTR_STAT 0x34 59 - #define DW_IC_RX_TL 0x38 60 - #define DW_IC_TX_TL 0x3c 61 - #define DW_IC_CLR_INTR 0x40 62 - #define DW_IC_CLR_RX_UNDER 0x44 63 - #define DW_IC_CLR_RX_OVER 0x48 64 - #define DW_IC_CLR_TX_OVER 0x4c 65 - #define DW_IC_CLR_RD_REQ 0x50 66 - #define DW_IC_CLR_TX_ABRT 0x54 67 - #define DW_IC_CLR_RX_DONE 0x58 68 - #define DW_IC_CLR_ACTIVITY 0x5c 69 - #define DW_IC_CLR_STOP_DET 0x60 70 - #define DW_IC_CLR_START_DET 0x64 71 - #define DW_IC_CLR_GEN_CALL 0x68 72 - #define DW_IC_ENABLE 0x6c 73 - #define DW_IC_STATUS 0x70 74 - #define DW_IC_TXFLR 0x74 75 - #define DW_IC_RXFLR 0x78 76 - #define DW_IC_SDA_HOLD 0x7c 77 - #define DW_IC_TX_ABRT_SOURCE 0x80 78 - #define DW_IC_ENABLE_STATUS 0x9c 79 - #define DW_IC_CLR_RESTART_DET 0xa8 80 - #define DW_IC_COMP_PARAM_1 0xf4 81 - #define DW_IC_COMP_VERSION 0xf8 82 - #define DW_IC_SDA_HOLD_MIN_VERS 0x3131312A 83 - #define DW_IC_COMP_TYPE 0xfc 84 - #define DW_IC_COMP_TYPE_VALUE 0x44570140 46 + #define DW_IC_CON 0x00 47 + #define DW_IC_TAR 0x04 48 + #define DW_IC_SAR 0x08 49 + #define DW_IC_DATA_CMD 0x10 50 + #define DW_IC_SS_SCL_HCNT 0x14 51 + #define DW_IC_SS_SCL_LCNT 0x18 52 + #define DW_IC_FS_SCL_HCNT 0x1c 53 + #define DW_IC_FS_SCL_LCNT 0x20 54 + #define DW_IC_HS_SCL_HCNT 0x24 55 + #define DW_IC_HS_SCL_LCNT 0x28 56 + #define DW_IC_INTR_STAT 0x2c 57 + #define DW_IC_INTR_MASK 0x30 58 + #define DW_IC_RAW_INTR_STAT 0x34 59 + #define DW_IC_RX_TL 0x38 60 + #define DW_IC_TX_TL 0x3c 61 + #define DW_IC_CLR_INTR 0x40 62 + #define DW_IC_CLR_RX_UNDER 0x44 63 + #define DW_IC_CLR_RX_OVER 0x48 64 + #define DW_IC_CLR_TX_OVER 0x4c 65 + #define DW_IC_CLR_RD_REQ 0x50 66 + #define DW_IC_CLR_TX_ABRT 0x54 67 + #define DW_IC_CLR_RX_DONE 0x58 68 + #define DW_IC_CLR_ACTIVITY 0x5c 69 + #define DW_IC_CLR_STOP_DET 0x60 70 + #define DW_IC_CLR_START_DET 0x64 71 + #define DW_IC_CLR_GEN_CALL 0x68 72 + #define DW_IC_ENABLE 0x6c 73 + #define DW_IC_STATUS 0x70 74 + #define DW_IC_TXFLR 0x74 75 + #define DW_IC_RXFLR 0x78 76 + #define DW_IC_SDA_HOLD 0x7c 77 + #define DW_IC_TX_ABRT_SOURCE 0x80 78 + #define DW_IC_ENABLE_STATUS 0x9c 79 + #define DW_IC_CLR_RESTART_DET 0xa8 80 + #define DW_IC_COMP_PARAM_1 0xf4 81 + #define DW_IC_COMP_VERSION 0xf8 82 + #define DW_IC_SDA_HOLD_MIN_VERS 0x3131312A /* "111*" == v1.11* */ 83 + #define DW_IC_COMP_TYPE 0xfc 84 + #define DW_IC_COMP_TYPE_VALUE 0x44570140 /* "DW" + 0x0140 */ 85 85 86 - #define DW_IC_INTR_RX_UNDER BIT(0) 87 - #define DW_IC_INTR_RX_OVER BIT(1) 88 - #define DW_IC_INTR_RX_FULL BIT(2) 89 - #define DW_IC_INTR_TX_OVER BIT(3) 90 - #define DW_IC_INTR_TX_EMPTY BIT(4) 91 - #define DW_IC_INTR_RD_REQ BIT(5) 92 - #define DW_IC_INTR_TX_ABRT BIT(6) 93 - #define DW_IC_INTR_RX_DONE BIT(7) 94 - #define DW_IC_INTR_ACTIVITY BIT(8) 95 - #define DW_IC_INTR_STOP_DET BIT(9) 96 - #define DW_IC_INTR_START_DET BIT(10) 97 - #define DW_IC_INTR_GEN_CALL BIT(11) 98 - #define DW_IC_INTR_RESTART_DET BIT(12) 86 + #define DW_IC_INTR_RX_UNDER BIT(0) 87 + #define DW_IC_INTR_RX_OVER BIT(1) 88 + #define DW_IC_INTR_RX_FULL BIT(2) 89 + #define DW_IC_INTR_TX_OVER BIT(3) 90 + #define DW_IC_INTR_TX_EMPTY BIT(4) 91 + #define DW_IC_INTR_RD_REQ BIT(5) 92 + #define DW_IC_INTR_TX_ABRT BIT(6) 93 + #define DW_IC_INTR_RX_DONE BIT(7) 94 + #define DW_IC_INTR_ACTIVITY BIT(8) 95 + #define DW_IC_INTR_STOP_DET BIT(9) 96 + #define DW_IC_INTR_START_DET BIT(10) 97 + #define DW_IC_INTR_GEN_CALL BIT(11) 98 + #define DW_IC_INTR_RESTART_DET BIT(12) 99 99 100 - #define DW_IC_INTR_DEFAULT_MASK (DW_IC_INTR_RX_FULL | \ 101 - DW_IC_INTR_TX_ABRT | \ 102 - DW_IC_INTR_STOP_DET) 103 - #define DW_IC_INTR_MASTER_MASK (DW_IC_INTR_DEFAULT_MASK | \ 104 - DW_IC_INTR_TX_EMPTY) 105 - #define DW_IC_INTR_SLAVE_MASK (DW_IC_INTR_DEFAULT_MASK | \ 106 - DW_IC_INTR_RX_DONE | \ 107 - DW_IC_INTR_RX_UNDER | \ 108 - DW_IC_INTR_RD_REQ) 100 + #define DW_IC_INTR_DEFAULT_MASK (DW_IC_INTR_RX_FULL | \ 101 + DW_IC_INTR_TX_ABRT | \ 102 + DW_IC_INTR_STOP_DET) 103 + #define DW_IC_INTR_MASTER_MASK (DW_IC_INTR_DEFAULT_MASK | \ 104 + DW_IC_INTR_TX_EMPTY) 105 + #define DW_IC_INTR_SLAVE_MASK (DW_IC_INTR_DEFAULT_MASK | \ 106 + DW_IC_INTR_RX_UNDER | \ 107 + DW_IC_INTR_RD_REQ) 109 108 110 - #define DW_IC_STATUS_ACTIVITY BIT(0) 111 - #define DW_IC_STATUS_TFE BIT(2) 112 - #define DW_IC_STATUS_MASTER_ACTIVITY BIT(5) 113 - #define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6) 109 + #define DW_IC_STATUS_ACTIVITY BIT(0) 110 + #define DW_IC_STATUS_TFE BIT(2) 111 + #define DW_IC_STATUS_RFNE BIT(3) 112 + #define DW_IC_STATUS_MASTER_ACTIVITY BIT(5) 113 + #define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6) 114 114 115 - #define DW_IC_SDA_HOLD_RX_SHIFT 16 116 - #define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, 16) 115 + #define DW_IC_SDA_HOLD_RX_SHIFT 16 116 + #define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, 16) 117 117 118 - #define DW_IC_ERR_TX_ABRT 0x1 118 + #define DW_IC_ERR_TX_ABRT 0x1 119 119 120 - #define DW_IC_TAR_10BITADDR_MASTER BIT(12) 120 + #define DW_IC_TAR_10BITADDR_MASTER BIT(12) 121 121 122 122 #define DW_IC_COMP_PARAM_1_SPEED_MODE_HIGH (BIT(2) | BIT(3)) 123 123 #define DW_IC_COMP_PARAM_1_SPEED_MODE_MASK GENMASK(3, 2) 124 124 125 125 /* 126 - * status codes 126 + * Sofware status flags 127 127 */ 128 - #define STATUS_IDLE 0x0 129 - #define STATUS_ACTIVE 0x1 130 - #define STATUS_WRITE_IN_PROGRESS 0x2 131 - #define STATUS_READ_IN_PROGRESS 0x4 128 + #define STATUS_ACTIVE BIT(0) 129 + #define STATUS_WRITE_IN_PROGRESS BIT(1) 130 + #define STATUS_READ_IN_PROGRESS BIT(2) 131 + #define STATUS_MASK GENMASK(2, 0) 132 132 133 133 /* 134 134 * operation modes 135 135 */ 136 - #define DW_IC_MASTER 0 137 - #define DW_IC_SLAVE 1 136 + #define DW_IC_MASTER 0 137 + #define DW_IC_SLAVE 1 138 138 139 139 /* 140 140 * Hardware abort codes from the DW_IC_TX_ABRT_SOURCE register ··· 142 142 * Only expected abort codes are listed here 143 143 * refer to the datasheet for the full list 144 144 */ 145 - #define ABRT_7B_ADDR_NOACK 0 146 - #define ABRT_10ADDR1_NOACK 1 147 - #define ABRT_10ADDR2_NOACK 2 148 - #define ABRT_TXDATA_NOACK 3 149 - #define ABRT_GCALL_NOACK 4 150 - #define ABRT_GCALL_READ 5 151 - #define ABRT_SBYTE_ACKDET 7 152 - #define ABRT_SBYTE_NORSTRT 9 153 - #define ABRT_10B_RD_NORSTRT 10 154 - #define ABRT_MASTER_DIS 11 155 - #define ARB_LOST 12 156 - #define ABRT_SLAVE_FLUSH_TXFIFO 13 157 - #define ABRT_SLAVE_ARBLOST 14 158 - #define ABRT_SLAVE_RD_INTX 15 145 + #define ABRT_7B_ADDR_NOACK 0 146 + #define ABRT_10ADDR1_NOACK 1 147 + #define ABRT_10ADDR2_NOACK 2 148 + #define ABRT_TXDATA_NOACK 3 149 + #define ABRT_GCALL_NOACK 4 150 + #define ABRT_GCALL_READ 5 151 + #define ABRT_SBYTE_ACKDET 7 152 + #define ABRT_SBYTE_NORSTRT 9 153 + #define ABRT_10B_RD_NORSTRT 10 154 + #define ABRT_MASTER_DIS 11 155 + #define ARB_LOST 12 156 + #define ABRT_SLAVE_FLUSH_TXFIFO 13 157 + #define ABRT_SLAVE_ARBLOST 14 158 + #define ABRT_SLAVE_RD_INTX 15 159 159 160 160 #define DW_IC_TX_ABRT_7B_ADDR_NOACK BIT(ABRT_7B_ADDR_NOACK) 161 161 #define DW_IC_TX_ABRT_10ADDR1_NOACK BIT(ABRT_10ADDR1_NOACK) ··· 172 172 #define DW_IC_RX_ABRT_SLAVE_ARBLOST BIT(ABRT_SLAVE_ARBLOST) 173 173 #define DW_IC_RX_ABRT_SLAVE_FLUSH_TXFIFO BIT(ABRT_SLAVE_FLUSH_TXFIFO) 174 174 175 - #define DW_IC_TX_ABRT_NOACK (DW_IC_TX_ABRT_7B_ADDR_NOACK | \ 176 - DW_IC_TX_ABRT_10ADDR1_NOACK | \ 177 - DW_IC_TX_ABRT_10ADDR2_NOACK | \ 178 - DW_IC_TX_ABRT_TXDATA_NOACK | \ 179 - DW_IC_TX_ABRT_GCALL_NOACK) 175 + #define DW_IC_TX_ABRT_NOACK (DW_IC_TX_ABRT_7B_ADDR_NOACK | \ 176 + DW_IC_TX_ABRT_10ADDR1_NOACK | \ 177 + DW_IC_TX_ABRT_10ADDR2_NOACK | \ 178 + DW_IC_TX_ABRT_TXDATA_NOACK | \ 179 + DW_IC_TX_ABRT_GCALL_NOACK) 180 180 181 181 struct clk; 182 182 struct device; ··· 232 232 * -1 if there is no semaphore. 233 233 * @shared_with_punit: true if this bus is shared with the SoCs PUNIT 234 234 * @disable: function to disable the controller 235 - * @disable_int: function to disable all interrupts 236 235 * @init: function to initialize the I2C hardware 237 236 * @set_sda_hold_time: callback to retrieve IP specific SDA hold timing 238 237 * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE ··· 289 290 int semaphore_idx; 290 291 bool shared_with_punit; 291 292 void (*disable)(struct dw_i2c_dev *dev); 292 - void (*disable_int)(struct dw_i2c_dev *dev); 293 293 int (*init)(struct dw_i2c_dev *dev); 294 294 int (*set_sda_hold_time)(struct dw_i2c_dev *dev); 295 295 int mode; 296 296 struct i2c_bus_recovery_info rinfo; 297 297 }; 298 298 299 - #define ACCESS_INTR_MASK BIT(0) 300 - #define ACCESS_NO_IRQ_SUSPEND BIT(1) 301 - #define ARBITRATION_SEMAPHORE BIT(2) 299 + #define ACCESS_INTR_MASK BIT(0) 300 + #define ACCESS_NO_IRQ_SUSPEND BIT(1) 301 + #define ARBITRATION_SEMAPHORE BIT(2) 302 302 303 - #define MODEL_MSCC_OCELOT BIT(8) 304 - #define MODEL_BAIKAL_BT1 BIT(9) 305 - #define MODEL_AMD_NAVI_GPU BIT(10) 306 - #define MODEL_MASK GENMASK(11, 8) 303 + #define MODEL_MSCC_OCELOT BIT(8) 304 + #define MODEL_BAIKAL_BT1 BIT(9) 305 + #define MODEL_AMD_NAVI_GPU BIT(10) 306 + #define MODEL_MASK GENMASK(11, 8) 307 307 308 308 /* 309 309 * Enable UCSI interrupt by writing 0xd at register 310 310 * offset 0x474 specified in hardware specification. 311 311 */ 312 - #define AMD_UCSI_INTR_REG 0x474 313 - #define AMD_UCSI_INTR_EN 0xd 312 + #define AMD_UCSI_INTR_REG 0x474 313 + #define AMD_UCSI_INTR_EN 0xd 314 314 315 315 struct i2c_dw_semaphore_callbacks { 316 316 int (*probe)(struct dw_i2c_dev *dev); ··· 329 331 int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev); 330 332 u32 i2c_dw_func(struct i2c_adapter *adap); 331 333 void i2c_dw_disable(struct dw_i2c_dev *dev); 332 - void i2c_dw_disable_int(struct dw_i2c_dev *dev); 333 334 334 335 static inline void __i2c_dw_enable(struct dw_i2c_dev *dev) 335 336 {
+18 -26
drivers/i2c/busses/i2c-designware-master.c
··· 239 239 msgs[dev->msg_write_idx].addr | ic_tar); 240 240 241 241 /* Enforce disabled interrupts (due to HW issues) */ 242 - i2c_dw_disable_int(dev); 242 + regmap_write(dev->map, DW_IC_INTR_MASK, 0); 243 243 244 244 /* Enable the adapter */ 245 245 __i2c_dw_enable(dev); ··· 299 299 dev->msgs = msgs; 300 300 dev->msgs_num = num_msgs; 301 301 i2c_dw_xfer_init(dev); 302 - i2c_dw_disable_int(dev); 302 + regmap_write(dev->map, DW_IC_INTR_MASK, 0); 303 303 304 304 /* Initiate messages read/write transaction */ 305 305 for (msg_wrt_idx = 0; msg_wrt_idx < num_msgs; msg_wrt_idx++) { ··· 574 574 dev->msg_write_idx = 0; 575 575 dev->msg_read_idx = 0; 576 576 dev->msg_err = 0; 577 - dev->status = STATUS_IDLE; 577 + dev->status = 0; 578 578 dev->abort_source = 0; 579 579 dev->rx_outstanding = 0; 580 580 ··· 711 711 * Interrupt service routine. This gets called whenever an I2C master interrupt 712 712 * occurs. 713 713 */ 714 - static int i2c_dw_irq_handler_master(struct dw_i2c_dev *dev) 714 + static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) 715 715 { 716 - u32 stat; 716 + struct dw_i2c_dev *dev = dev_id; 717 + u32 stat, enabled; 718 + 719 + regmap_read(dev->map, DW_IC_ENABLE, &enabled); 720 + regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat); 721 + if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY)) 722 + return IRQ_NONE; 723 + if (pm_runtime_suspended(dev->dev) || stat == GENMASK(31, 0)) 724 + return IRQ_NONE; 725 + dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat); 717 726 718 727 stat = i2c_dw_read_clear_intrbits(dev); 719 728 ··· 735 726 * the HW active). 736 727 */ 737 728 regmap_write(dev->map, DW_IC_INTR_MASK, 0); 738 - return 0; 729 + return IRQ_HANDLED; 739 730 } 740 731 741 732 if (stat & DW_IC_INTR_TX_ABRT) { 742 733 dev->cmd_err |= DW_IC_ERR_TX_ABRT; 743 - dev->status = STATUS_IDLE; 734 + dev->status &= ~STATUS_MASK; 744 735 dev->rx_outstanding = 0; 745 736 746 737 /* ··· 770 761 else if (unlikely(dev->flags & ACCESS_INTR_MASK)) { 771 762 /* Workaround to trigger pending interrupt */ 772 763 regmap_read(dev->map, DW_IC_INTR_MASK, &stat); 773 - i2c_dw_disable_int(dev); 764 + regmap_write(dev->map, DW_IC_INTR_MASK, 0); 774 765 regmap_write(dev->map, DW_IC_INTR_MASK, stat); 775 766 } 776 - 777 - return 0; 778 - } 779 - 780 - static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id) 781 - { 782 - struct dw_i2c_dev *dev = dev_id; 783 - u32 stat, enabled; 784 - 785 - regmap_read(dev->map, DW_IC_ENABLE, &enabled); 786 - regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat); 787 - dev_dbg(dev->dev, "enabled=%#x stat=%#x\n", enabled, stat); 788 - if (!enabled || !(stat & ~DW_IC_INTR_ACTIVITY)) 789 - return IRQ_NONE; 790 - 791 - i2c_dw_irq_handler_master(dev); 792 767 793 768 return IRQ_HANDLED; 794 769 } ··· 871 878 872 879 dev->init = i2c_dw_init_master; 873 880 dev->disable = i2c_dw_disable; 874 - dev->disable_int = i2c_dw_disable_int; 875 881 876 882 ret = i2c_dw_init_regmap(dev); 877 883 if (ret) ··· 909 917 if (ret) 910 918 return ret; 911 919 912 - i2c_dw_disable_int(dev); 920 + regmap_write(dev->map, DW_IC_INTR_MASK, 0); 913 921 i2c_dw_release_lock(dev); 914 922 915 923 ret = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, irq_flags,
+29 -48
drivers/i2c/busses/i2c-designware-slave.c
··· 78 78 79 79 __i2c_dw_enable(dev); 80 80 81 - dev->cmd_err = 0; 82 - dev->msg_write_idx = 0; 83 - dev->msg_read_idx = 0; 84 - dev->msg_err = 0; 85 - dev->status = STATUS_IDLE; 86 - dev->abort_source = 0; 87 - dev->rx_outstanding = 0; 81 + dev->status = 0; 88 82 89 83 return 0; 90 84 } ··· 87 93 { 88 94 struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter); 89 95 90 - dev->disable_int(dev); 96 + regmap_write(dev->map, DW_IC_INTR_MASK, 0); 91 97 dev->disable(dev); 92 98 synchronize_irq(dev->irq); 93 99 dev->slave = NULL; ··· 147 153 * Interrupt service routine. This gets called whenever an I2C slave interrupt 148 154 * occurs. 149 155 */ 150 - 151 - static int i2c_dw_irq_handler_slave(struct dw_i2c_dev *dev) 156 + static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id) 152 157 { 158 + struct dw_i2c_dev *dev = dev_id; 153 159 u32 raw_stat, stat, enabled, tmp; 154 160 u8 val = 0, slave_activity; 155 161 ··· 159 165 slave_activity = ((tmp & DW_IC_STATUS_SLAVE_ACTIVITY) >> 6); 160 166 161 167 if (!enabled || !(raw_stat & ~DW_IC_INTR_ACTIVITY) || !dev->slave) 162 - return 0; 168 + return IRQ_NONE; 163 169 164 170 stat = i2c_dw_read_clear_intrbits_slave(dev); 165 171 dev_dbg(dev->dev, ··· 167 173 enabled, slave_activity, raw_stat, stat); 168 174 169 175 if (stat & DW_IC_INTR_RX_FULL) { 170 - if (dev->status != STATUS_WRITE_IN_PROGRESS) { 171 - dev->status = STATUS_WRITE_IN_PROGRESS; 176 + if (!(dev->status & STATUS_WRITE_IN_PROGRESS)) { 177 + dev->status |= STATUS_WRITE_IN_PROGRESS; 178 + dev->status &= ~STATUS_READ_IN_PROGRESS; 172 179 i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_REQUESTED, 173 180 &val); 174 181 } 175 182 176 - regmap_read(dev->map, DW_IC_DATA_CMD, &tmp); 177 - val = tmp; 178 - if (!i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED, 179 - &val)) 180 - dev_vdbg(dev->dev, "Byte %X acked!", val); 183 + do { 184 + regmap_read(dev->map, DW_IC_DATA_CMD, &tmp); 185 + val = tmp; 186 + i2c_slave_event(dev->slave, I2C_SLAVE_WRITE_RECEIVED, 187 + &val); 188 + regmap_read(dev->map, DW_IC_STATUS, &tmp); 189 + } while (tmp & DW_IC_STATUS_RFNE); 181 190 } 182 191 183 192 if (stat & DW_IC_INTR_RD_REQ) { 184 193 if (slave_activity) { 185 194 regmap_read(dev->map, DW_IC_CLR_RD_REQ, &tmp); 186 195 187 - dev->status = STATUS_READ_IN_PROGRESS; 188 - if (!i2c_slave_event(dev->slave, 189 - I2C_SLAVE_READ_REQUESTED, 190 - &val)) 191 - regmap_write(dev->map, DW_IC_DATA_CMD, val); 196 + if (!(dev->status & STATUS_READ_IN_PROGRESS)) { 197 + i2c_slave_event(dev->slave, 198 + I2C_SLAVE_READ_REQUESTED, 199 + &val); 200 + dev->status |= STATUS_READ_IN_PROGRESS; 201 + dev->status &= ~STATUS_WRITE_IN_PROGRESS; 202 + } else { 203 + i2c_slave_event(dev->slave, 204 + I2C_SLAVE_READ_PROCESSED, 205 + &val); 206 + } 207 + regmap_write(dev->map, DW_IC_DATA_CMD, val); 192 208 } 193 209 } 194 210 195 - if (stat & DW_IC_INTR_RX_DONE) { 196 - if (!i2c_slave_event(dev->slave, I2C_SLAVE_READ_PROCESSED, 197 - &val)) 198 - regmap_read(dev->map, DW_IC_CLR_RX_DONE, &tmp); 199 - } 200 - 201 - if (stat & DW_IC_INTR_STOP_DET) { 202 - dev->status = STATUS_IDLE; 211 + if (stat & DW_IC_INTR_STOP_DET) 203 212 i2c_slave_event(dev->slave, I2C_SLAVE_STOP, &val); 204 - } 205 213 206 - return 1; 207 - } 208 - 209 - static irqreturn_t i2c_dw_isr_slave(int this_irq, void *dev_id) 210 - { 211 - struct dw_i2c_dev *dev = dev_id; 212 - int ret; 213 - 214 - ret = i2c_dw_irq_handler_slave(dev); 215 - if (ret > 0) 216 - complete(&dev->cmd_complete); 217 - 218 - return IRQ_RETVAL(ret); 214 + return IRQ_HANDLED; 219 215 } 220 216 221 217 static const struct i2c_algorithm i2c_dw_algo = { ··· 230 246 struct i2c_adapter *adap = &dev->adapter; 231 247 int ret; 232 248 233 - init_completion(&dev->cmd_complete); 234 - 235 249 dev->init = i2c_dw_init_slave; 236 250 dev->disable = i2c_dw_disable; 237 - dev->disable_int = i2c_dw_disable_int; 238 251 239 252 ret = i2c_dw_init_regmap(dev); 240 253 if (ret)
+1 -3
drivers/i2c/busses/i2c-gpio.c
··· 482 482 return 0; 483 483 } 484 484 485 - #if defined(CONFIG_OF) 486 485 static const struct of_device_id i2c_gpio_dt_ids[] = { 487 486 { .compatible = "i2c-gpio", }, 488 487 { /* sentinel */ } 489 488 }; 490 489 491 490 MODULE_DEVICE_TABLE(of, i2c_gpio_dt_ids); 492 - #endif 493 491 494 492 static struct platform_driver i2c_gpio_driver = { 495 493 .driver = { 496 494 .name = "i2c-gpio", 497 - .of_match_table = of_match_ptr(i2c_gpio_dt_ids), 495 + .of_match_table = i2c_gpio_dt_ids, 498 496 }, 499 497 .probe = i2c_gpio_probe, 500 498 .remove = i2c_gpio_remove,
+18 -4
drivers/i2c/busses/i2c-hisi.c
··· 7 7 8 8 #include <linux/bits.h> 9 9 #include <linux/bitfield.h> 10 + #include <linux/clk.h> 10 11 #include <linux/completion.h> 11 12 #include <linux/i2c.h> 12 13 #include <linux/interrupt.h> ··· 89 88 struct i2c_adapter adapter; 90 89 void __iomem *iobase; 91 90 struct device *dev; 91 + struct clk *clk; 92 92 int irq; 93 93 94 94 /* Intermediates for recording the transfer process */ ··· 456 454 return ret; 457 455 } 458 456 459 - ret = device_property_read_u64(dev, "clk_rate", &clk_rate_hz); 460 - if (ret) { 461 - dev_err(dev, "failed to get clock frequency, ret = %d\n", ret); 462 - return ret; 457 + ctlr->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); 458 + if (IS_ERR_OR_NULL(ctlr->clk)) { 459 + ret = device_property_read_u64(dev, "clk_rate", &clk_rate_hz); 460 + if (ret) { 461 + dev_err(dev, "failed to get clock frequency, ret = %d\n", ret); 462 + return ret; 463 + } 464 + } else { 465 + clk_rate_hz = clk_get_rate(ctlr->clk); 463 466 } 464 467 465 468 ctlr->clk_rate_khz = DIV_ROUND_UP_ULL(clk_rate_hz, HZ_PER_KHZ); ··· 496 489 }; 497 490 MODULE_DEVICE_TABLE(acpi, hisi_i2c_acpi_ids); 498 491 492 + static const struct of_device_id hisi_i2c_dts_ids[] = { 493 + { .compatible = "hisilicon,ascend910-i2c", }, 494 + { } 495 + }; 496 + MODULE_DEVICE_TABLE(of, hisi_i2c_dts_ids); 497 + 499 498 static struct platform_driver hisi_i2c_driver = { 500 499 .probe = hisi_i2c_probe, 501 500 .driver = { 502 501 .name = "hisi-i2c", 503 502 .acpi_match_table = hisi_i2c_acpi_ids, 503 + .of_match_table = hisi_i2c_dts_ids, 504 504 }, 505 505 }; 506 506 module_platform_driver(hisi_i2c_driver);
+1 -2
drivers/i2c/busses/i2c-imx.c
··· 1451 1451 if (irq < 0) 1452 1452 return irq; 1453 1453 1454 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1455 - base = devm_ioremap_resource(&pdev->dev, res); 1454 + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1456 1455 if (IS_ERR(base)) 1457 1456 return PTR_ERR(base); 1458 1457
+3
drivers/i2c/busses/i2c-ismt.c
··· 509 509 if (read_write == I2C_SMBUS_WRITE) { 510 510 /* Block Write */ 511 511 dev_dbg(dev, "I2C_SMBUS_BLOCK_DATA: WRITE\n"); 512 + if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) 513 + return -EINVAL; 514 + 512 515 dma_size = data->block[0] + 1; 513 516 dma_direction = DMA_TO_DEVICE; 514 517 desc->wr_len_cmd = dma_size;
+14
drivers/i2c/busses/i2c-mt65xx.c
··· 431 431 .max_dma_support = 33, 432 432 }; 433 433 434 + static const struct mtk_i2c_compatible mt7986_compat = { 435 + .quirks = &mt7622_i2c_quirks, 436 + .regs = mt_i2c_regs_v1, 437 + .pmic_i2c = 0, 438 + .dcm = 1, 439 + .auto_restart = 1, 440 + .aux_len_reg = 1, 441 + .timing_adjust = 0, 442 + .dma_sync = 1, 443 + .ltiming_adjust = 0, 444 + .max_dma_support = 32, 445 + }; 446 + 434 447 static const struct mtk_i2c_compatible mt8173_compat = { 435 448 .regs = mt_i2c_regs_v1, 436 449 .pmic_i2c = 0, ··· 516 503 { .compatible = "mediatek,mt6577-i2c", .data = &mt6577_compat }, 517 504 { .compatible = "mediatek,mt6589-i2c", .data = &mt6589_compat }, 518 505 { .compatible = "mediatek,mt7622-i2c", .data = &mt7622_compat }, 506 + { .compatible = "mediatek,mt7986-i2c", .data = &mt7986_compat }, 519 507 { .compatible = "mediatek,mt8168-i2c", .data = &mt8168_compat }, 520 508 { .compatible = "mediatek,mt8173-i2c", .data = &mt8173_compat }, 521 509 { .compatible = "mediatek,mt8183-i2c", .data = &mt8183_compat },
+43 -44
drivers/i2c/busses/i2c-npcm7xx.c
··· 106 106 #define NPCM_I2CCST3 0x19 107 107 #define I2C_VER 0x1F 108 108 109 - /*BANK0 regs*/ 109 + /* BANK 0 regs */ 110 110 #define NPCM_I2CADDR3 0x10 111 111 #define NPCM_I2CADDR7 0x11 112 112 #define NPCM_I2CADDR4 0x12 ··· 115 115 #define NPCM_I2CADDR9 0x15 116 116 #define NPCM_I2CADDR6 0x16 117 117 #define NPCM_I2CADDR10 0x17 118 + #define NPCM_I2CCTL4 0x1A 119 + #define NPCM_I2CCTL5 0x1B 120 + #define NPCM_I2CSCLLT 0x1C /* SCL Low Time */ 121 + #define NPCM_I2CFIF_CTL 0x1D /* FIFO Control */ 122 + #define NPCM_I2CSCLHT 0x1E /* SCL High Time */ 123 + 124 + /* BANK 1 regs */ 125 + #define NPCM_I2CFIF_CTS 0x10 /* Both FIFOs Control and Status */ 126 + #define NPCM_I2CTXF_CTL 0x12 /* Tx-FIFO Control */ 127 + #define NPCM_I2CT_OUT 0x14 /* Bus T.O. */ 128 + #define NPCM_I2CPEC 0x16 /* PEC Data */ 129 + #define NPCM_I2CTXF_STS 0x1A /* Tx-FIFO Status */ 130 + #define NPCM_I2CRXF_STS 0x1C /* Rx-FIFO Status */ 131 + #define NPCM_I2CRXF_CTL 0x1E /* Rx-FIFO Control */ 118 132 119 133 #if IS_ENABLED(CONFIG_I2C_SLAVE) 120 134 /* ··· 145 131 }; 146 132 #endif 147 133 148 - #define NPCM_I2CCTL4 0x1A 149 - #define NPCM_I2CCTL5 0x1B 150 - #define NPCM_I2CSCLLT 0x1C /* SCL Low Time */ 151 - #define NPCM_I2CFIF_CTL 0x1D /* FIFO Control */ 152 - #define NPCM_I2CSCLHT 0x1E /* SCL High Time */ 153 - 154 - /* BANK 1 regs */ 155 - #define NPCM_I2CFIF_CTS 0x10 /* Both FIFOs Control and Status */ 156 - #define NPCM_I2CTXF_CTL 0x12 /* Tx-FIFO Control */ 157 - #define NPCM_I2CT_OUT 0x14 /* Bus T.O. */ 158 - #define NPCM_I2CPEC 0x16 /* PEC Data */ 159 - #define NPCM_I2CTXF_STS 0x1A /* Tx-FIFO Status */ 160 - #define NPCM_I2CRXF_STS 0x1C /* Rx-FIFO Status */ 161 - #define NPCM_I2CRXF_CTL 0x1E /* Rx-FIFO Control */ 162 - 163 134 /* NPCM_I2CST reg fields */ 164 - #define NPCM_I2CST_XMIT BIT(0) 165 - #define NPCM_I2CST_MASTER BIT(1) 166 - #define NPCM_I2CST_NMATCH BIT(2) 167 - #define NPCM_I2CST_STASTR BIT(3) 168 - #define NPCM_I2CST_NEGACK BIT(4) 169 - #define NPCM_I2CST_BER BIT(5) 170 - #define NPCM_I2CST_SDAST BIT(6) 171 - #define NPCM_I2CST_SLVSTP BIT(7) 135 + #define NPCM_I2CST_XMIT BIT(0) /* Transmit mode */ 136 + #define NPCM_I2CST_MASTER BIT(1) /* Master mode */ 137 + #define NPCM_I2CST_NMATCH BIT(2) /* New match */ 138 + #define NPCM_I2CST_STASTR BIT(3) /* Stall after start */ 139 + #define NPCM_I2CST_NEGACK BIT(4) /* Negative ACK */ 140 + #define NPCM_I2CST_BER BIT(5) /* Bus error */ 141 + #define NPCM_I2CST_SDAST BIT(6) /* SDA status */ 142 + #define NPCM_I2CST_SLVSTP BIT(7) /* Slave stop */ 172 143 173 144 /* NPCM_I2CCST reg fields */ 174 - #define NPCM_I2CCST_BUSY BIT(0) 175 - #define NPCM_I2CCST_BB BIT(1) 176 - #define NPCM_I2CCST_MATCH BIT(2) 177 - #define NPCM_I2CCST_GCMATCH BIT(3) 178 - #define NPCM_I2CCST_TSDA BIT(4) 179 - #define NPCM_I2CCST_TGSCL BIT(5) 180 - #define NPCM_I2CCST_MATCHAF BIT(6) 181 - #define NPCM_I2CCST_ARPMATCH BIT(7) 145 + #define NPCM_I2CCST_BUSY BIT(0) /* Busy */ 146 + #define NPCM_I2CCST_BB BIT(1) /* Bus busy */ 147 + #define NPCM_I2CCST_MATCH BIT(2) /* Address match */ 148 + #define NPCM_I2CCST_GCMATCH BIT(3) /* Global call match */ 149 + #define NPCM_I2CCST_TSDA BIT(4) /* Test SDA line */ 150 + #define NPCM_I2CCST_TGSCL BIT(5) /* Toggle SCL line */ 151 + #define NPCM_I2CCST_MATCHAF BIT(6) /* Match address field */ 152 + #define NPCM_I2CCST_ARPMATCH BIT(7) /* ARP address match */ 182 153 183 154 /* NPCM_I2CCTL1 reg fields */ 184 - #define NPCM_I2CCTL1_START BIT(0) 185 - #define NPCM_I2CCTL1_STOP BIT(1) 186 - #define NPCM_I2CCTL1_INTEN BIT(2) 155 + #define NPCM_I2CCTL1_START BIT(0) /* Generate start condition */ 156 + #define NPCM_I2CCTL1_STOP BIT(1) /* Generate stop condition */ 157 + #define NPCM_I2CCTL1_INTEN BIT(2) /* Interrupt enable */ 187 158 #define NPCM_I2CCTL1_EOBINTE BIT(3) 188 159 #define NPCM_I2CCTL1_ACK BIT(4) 189 - #define NPCM_I2CCTL1_GCMEN BIT(5) 190 - #define NPCM_I2CCTL1_NMINTE BIT(6) 191 - #define NPCM_I2CCTL1_STASTRE BIT(7) 160 + #define NPCM_I2CCTL1_GCMEN BIT(5) /* Global call match enable */ 161 + #define NPCM_I2CCTL1_NMINTE BIT(6) /* New match interrupt enable */ 162 + #define NPCM_I2CCTL1_STASTRE BIT(7) /* Stall after start enable */ 192 163 193 164 /* RW1S fields (inside a RW reg): */ 194 165 #define NPCM_I2CCTL1_RWS \ 195 166 (NPCM_I2CCTL1_START | NPCM_I2CCTL1_STOP | NPCM_I2CCTL1_ACK) 196 167 197 168 /* npcm_i2caddr reg fields */ 198 - #define NPCM_I2CADDR_A GENMASK(6, 0) 199 - #define NPCM_I2CADDR_SAEN BIT(7) 169 + #define NPCM_I2CADDR_A GENMASK(6, 0) /* Address */ 170 + #define NPCM_I2CADDR_SAEN BIT(7) /* Slave address enable */ 200 171 201 172 /* NPCM_I2CCTL2 reg fields */ 202 - #define I2CCTL2_ENABLE BIT(0) 203 - #define I2CCTL2_SCLFRQ6_0 GENMASK(7, 1) 173 + #define I2CCTL2_ENABLE BIT(0) /* Module enable */ 174 + #define I2CCTL2_SCLFRQ6_0 GENMASK(7, 1) /* Bits 0:6 of frequency divisor */ 204 175 205 176 /* NPCM_I2CCTL3 reg fields */ 206 - #define I2CCTL3_SCLFRQ8_7 GENMASK(1, 0) 207 - #define I2CCTL3_ARPMEN BIT(2) 177 + #define I2CCTL3_SCLFRQ8_7 GENMASK(1, 0) /* Bits 7:8 of frequency divisor */ 178 + #define I2CCTL3_ARPMEN BIT(2) /* ARP match enable */ 208 179 #define I2CCTL3_IDL_START BIT(3) 209 180 #define I2CCTL3_400K_MODE BIT(4) 210 181 #define I2CCTL3_BNK_SEL BIT(5)
+27 -5
drivers/i2c/busses/i2c-pasemi-core.c
··· 21 21 #define REG_MTXFIFO 0x00 22 22 #define REG_MRXFIFO 0x04 23 23 #define REG_SMSTA 0x14 24 + #define REG_IMASK 0x18 24 25 #define REG_CTL 0x1c 25 26 #define REG_REV 0x28 26 27 ··· 67 66 val |= CTL_EN; 68 67 69 68 reg_write(smbus, REG_CTL, val); 69 + reinit_completion(&smbus->irq_completion); 70 70 } 71 71 72 72 static void pasemi_smb_clear(struct pasemi_smbus *smbus) ··· 80 78 81 79 static int pasemi_smb_waitready(struct pasemi_smbus *smbus) 82 80 { 83 - int timeout = 10; 81 + int timeout = 100; 84 82 unsigned int status; 85 83 86 - status = reg_read(smbus, REG_SMSTA); 87 - 88 - while (!(status & SMSTA_XEN) && timeout--) { 89 - msleep(1); 84 + if (smbus->use_irq) { 85 + reinit_completion(&smbus->irq_completion); 86 + reg_write(smbus, REG_IMASK, SMSTA_XEN | SMSTA_MTN); 87 + wait_for_completion_timeout(&smbus->irq_completion, msecs_to_jiffies(100)); 88 + reg_write(smbus, REG_IMASK, 0); 90 89 status = reg_read(smbus, REG_SMSTA); 90 + } else { 91 + status = reg_read(smbus, REG_SMSTA); 92 + while (!(status & SMSTA_XEN) && timeout--) { 93 + msleep(1); 94 + status = reg_read(smbus, REG_SMSTA); 95 + } 91 96 } 92 97 93 98 /* Got NACK? */ ··· 353 344 354 345 /* set up the sysfs linkage to our parent device */ 355 346 smbus->adapter.dev.parent = smbus->dev; 347 + smbus->use_irq = 0; 348 + init_completion(&smbus->irq_completion); 356 349 357 350 if (smbus->hw_rev != PASEMI_HW_REV_PCI) 358 351 smbus->hw_rev = reg_read(smbus, REG_REV); 352 + 353 + reg_write(smbus, REG_IMASK, 0); 359 354 360 355 pasemi_reset(smbus); 361 356 ··· 368 355 return error; 369 356 370 357 return 0; 358 + } 359 + 360 + irqreturn_t pasemi_irq_handler(int irq, void *dev_id) 361 + { 362 + struct pasemi_smbus *smbus = dev_id; 363 + 364 + reg_write(smbus, REG_IMASK, 0); 365 + complete(&smbus->irq_completion); 366 + return IRQ_HANDLED; 371 367 }
+5
drivers/i2c/busses/i2c-pasemi-core.h
··· 7 7 #include <linux/i2c-smbus.h> 8 8 #include <linux/io.h> 9 9 #include <linux/kernel.h> 10 + #include <linux/completion.h> 10 11 11 12 #define PASEMI_HW_REV_PCI -1 12 13 ··· 17 16 void __iomem *ioaddr; 18 17 unsigned int clk_div; 19 18 int hw_rev; 19 + int use_irq; 20 + struct completion irq_completion; 20 21 }; 21 22 22 23 int pasemi_i2c_common_probe(struct pasemi_smbus *smbus); 24 + 25 + irqreturn_t pasemi_irq_handler(int irq, void *dev_id);
+6
drivers/i2c/busses/i2c-pasemi-platform.c
··· 49 49 struct pasemi_smbus *smbus; 50 50 u32 frequency; 51 51 int error; 52 + int irq_num; 52 53 53 54 data = devm_kzalloc(dev, sizeof(struct pasemi_platform_i2c_data), 54 55 GFP_KERNEL); ··· 83 82 if (error) 84 83 goto out_clk_disable; 85 84 85 + irq_num = platform_get_irq(pdev, 0); 86 + error = devm_request_irq(smbus->dev, irq_num, pasemi_irq_handler, 0, "pasemi_apple_i2c", (void *)smbus); 87 + 88 + if (!error) 89 + smbus->use_irq = 1; 86 90 platform_set_drvdata(pdev, data); 87 91 88 92 return 0;
+3 -7
drivers/i2c/busses/i2c-pxa-pci.c
··· 105 105 int i; 106 106 struct ce4100_devices *sds; 107 107 108 - ret = pci_enable_device_mem(dev); 108 + ret = pcim_enable_device(dev); 109 109 if (ret) 110 110 return ret; 111 111 ··· 114 114 return -EINVAL; 115 115 } 116 116 sds = kzalloc(sizeof(*sds), GFP_KERNEL); 117 - if (!sds) { 118 - ret = -ENOMEM; 119 - goto err_mem; 120 - } 117 + if (!sds) 118 + return -ENOMEM; 121 119 122 120 for (i = 0; i < ARRAY_SIZE(sds->pdev); i++) { 123 121 sds->pdev[i] = add_i2c_device(dev, i); ··· 131 133 132 134 err_dev_add: 133 135 kfree(sds); 134 - err_mem: 135 - pci_disable_device(dev); 136 136 return ret; 137 137 } 138 138
+55 -3
drivers/i2c/busses/i2c-qcom-geni.c
··· 88 88 int cur_wr; 89 89 int cur_rd; 90 90 spinlock_t lock; 91 + struct clk *core_clk; 91 92 u32 clk_freq_out; 92 93 const struct geni_i2c_clk_fld *clk_fld; 93 94 int suspended; ··· 99 98 struct dma_chan *rx_c; 100 99 bool gpi_mode; 101 100 bool abort_done; 101 + }; 102 + 103 + struct geni_i2c_desc { 104 + bool has_core_clk; 105 + char *icc_ddr; 106 + bool no_dma_support; 107 + unsigned int tx_fifo_depth; 102 108 }; 103 109 104 110 struct geni_i2c_err_log { ··· 771 763 u32 proto, tx_depth, fifo_disable; 772 764 int ret; 773 765 struct device *dev = &pdev->dev; 766 + const struct geni_i2c_desc *desc = NULL; 774 767 775 768 gi2c = devm_kzalloc(dev, sizeof(*gi2c), GFP_KERNEL); 776 769 if (!gi2c) ··· 783 774 gi2c->se.base = devm_ioremap_resource(dev, res); 784 775 if (IS_ERR(gi2c->se.base)) 785 776 return PTR_ERR(gi2c->se.base); 777 + 778 + desc = device_get_match_data(&pdev->dev); 779 + 780 + if (desc && desc->has_core_clk) { 781 + gi2c->core_clk = devm_clk_get(dev, "core"); 782 + if (IS_ERR(gi2c->core_clk)) 783 + return PTR_ERR(gi2c->core_clk); 784 + } 786 785 787 786 gi2c->se.clk = devm_clk_get(dev, "se"); 788 787 if (IS_ERR(gi2c->se.clk) && !has_acpi_companion(dev)) ··· 835 818 gi2c->adap.dev.of_node = dev->of_node; 836 819 strscpy(gi2c->adap.name, "Geni-I2C", sizeof(gi2c->adap.name)); 837 820 838 - ret = geni_icc_get(&gi2c->se, "qup-memory"); 821 + ret = geni_icc_get(&gi2c->se, desc ? desc->icc_ddr : "qup-memory"); 839 822 if (ret) 840 823 return ret; 841 824 /* ··· 845 828 */ 846 829 gi2c->se.icc_paths[GENI_TO_CORE].avg_bw = GENI_DEFAULT_BW; 847 830 gi2c->se.icc_paths[CPU_TO_GENI].avg_bw = GENI_DEFAULT_BW; 848 - gi2c->se.icc_paths[GENI_TO_DDR].avg_bw = Bps_to_icc(gi2c->clk_freq_out); 831 + if (!desc || desc->icc_ddr) 832 + gi2c->se.icc_paths[GENI_TO_DDR].avg_bw = Bps_to_icc(gi2c->clk_freq_out); 849 833 850 834 ret = geni_icc_set_bw(&gi2c->se); 835 + if (ret) 836 + return ret; 837 + 838 + ret = clk_prepare_enable(gi2c->core_clk); 851 839 if (ret) 852 840 return ret; 853 841 ··· 865 843 if (proto != GENI_SE_I2C) { 866 844 dev_err(dev, "Invalid proto %d\n", proto); 867 845 geni_se_resources_off(&gi2c->se); 846 + clk_disable_unprepare(gi2c->core_clk); 868 847 return -ENXIO; 869 848 } 870 849 871 - fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE; 850 + if (desc && desc->no_dma_support) 851 + fifo_disable = false; 852 + else 853 + fifo_disable = readl_relaxed(gi2c->se.base + GENI_IF_DISABLE_RO) & FIFO_IF_DISABLE; 854 + 872 855 if (fifo_disable) { 873 856 /* FIFO is disabled, so we can only use GPI DMA */ 874 857 gi2c->gpi_mode = true; ··· 885 858 } else { 886 859 gi2c->gpi_mode = false; 887 860 tx_depth = geni_se_get_tx_fifo_depth(&gi2c->se); 861 + 862 + /* I2C Master Hub Serial Elements doesn't have the HW_PARAM_0 register */ 863 + if (!tx_depth && desc) 864 + tx_depth = desc->tx_fifo_depth; 865 + 866 + if (!tx_depth) { 867 + dev_err(dev, "Invalid TX FIFO depth\n"); 868 + return -EINVAL; 869 + } 870 + 888 871 gi2c->tx_wm = tx_depth - 1; 889 872 geni_se_init(&gi2c->se, gi2c->tx_wm, tx_depth); 890 873 geni_se_config_packing(&gi2c->se, BITS_PER_BYTE, ··· 903 866 dev_dbg(dev, "i2c fifo/se-dma mode. fifo depth:%d\n", tx_depth); 904 867 } 905 868 869 + clk_disable_unprepare(gi2c->core_clk); 906 870 ret = geni_se_resources_off(&gi2c->se); 907 871 if (ret) { 908 872 dev_err(dev, "Error turning off resources %d\n", ret); ··· 969 931 gi2c->suspended = 1; 970 932 } 971 933 934 + clk_disable_unprepare(gi2c->core_clk); 935 + 972 936 return geni_icc_disable(&gi2c->se); 973 937 } 974 938 ··· 980 940 struct geni_i2c_dev *gi2c = dev_get_drvdata(dev); 981 941 982 942 ret = geni_icc_enable(&gi2c->se); 943 + if (ret) 944 + return ret; 945 + 946 + ret = clk_prepare_enable(gi2c->core_clk); 983 947 if (ret) 984 948 return ret; 985 949 ··· 1025 981 NULL) 1026 982 }; 1027 983 984 + const struct geni_i2c_desc i2c_master_hub = { 985 + .has_core_clk = true, 986 + .icc_ddr = NULL, 987 + .no_dma_support = true, 988 + .tx_fifo_depth = 16, 989 + }; 990 + 1028 991 static const struct of_device_id geni_i2c_dt_match[] = { 1029 992 { .compatible = "qcom,geni-i2c" }, 993 + { .compatible = "qcom,geni-i2c-master-hub", .data = &i2c_master_hub }, 1030 994 {} 1031 995 }; 1032 996 MODULE_DEVICE_TABLE(of, geni_i2c_dt_match);
+1
drivers/i2c/busses/i2c-tegra.c
··· 1830 1830 i2c_dev->adapter.class = I2C_CLASS_DEPRECATED; 1831 1831 i2c_dev->adapter.algo = &tegra_i2c_algo; 1832 1832 i2c_dev->adapter.nr = pdev->id; 1833 + ACPI_COMPANION_SET(&i2c_dev->adapter.dev, ACPI_COMPANION(&pdev->dev)); 1833 1834 1834 1835 if (i2c_dev->hw->supports_bus_clear) 1835 1836 i2c_dev->adapter.bus_recovery_info = &tegra_i2c_recovery_info;
+7 -4
drivers/i2c/busses/i2c-xiic.c
··· 858 858 /* remove adapter & data */ 859 859 i2c_del_adapter(&i2c->adap); 860 860 861 - ret = pm_runtime_resume_and_get(i2c->dev); 862 - if (ret < 0) 863 - return ret; 861 + ret = pm_runtime_get_sync(i2c->dev); 864 862 865 - xiic_deinit(i2c); 863 + if (ret < 0) 864 + dev_warn(&pdev->dev, "Failed to activate device for removal (%pe)\n", 865 + ERR_PTR(ret)); 866 + else 867 + xiic_deinit(i2c); 868 + 866 869 pm_runtime_put_sync(i2c->dev); 867 870 clk_disable_unprepare(i2c->clk); 868 871 pm_runtime_disable(&pdev->dev);
+2 -3
drivers/i2c/i2c-core-base.c
··· 1018 1018 { }, 1019 1019 }; 1020 1020 1021 - static int dummy_probe(struct i2c_client *client, 1022 - const struct i2c_device_id *id) 1021 + static int dummy_probe(struct i2c_client *client) 1023 1022 { 1024 1023 return 0; 1025 1024 } 1026 1025 1027 1026 static struct i2c_driver dummy_driver = { 1028 1027 .driver.name = "dummy", 1029 - .probe = dummy_probe, 1028 + .probe_new = dummy_probe, 1030 1029 .id_table = dummy_id, 1031 1030 }; 1032 1031
+3 -2
drivers/i2c/i2c-slave-eeprom.c
··· 140 140 return 0; 141 141 } 142 142 143 - static int i2c_slave_eeprom_probe(struct i2c_client *client, const struct i2c_device_id *id) 143 + static int i2c_slave_eeprom_probe(struct i2c_client *client) 144 144 { 145 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 145 146 struct eeprom_data *eeprom; 146 147 int ret; 147 148 unsigned int size = FIELD_GET(I2C_SLAVE_BYTELEN, id->driver_data) + 1; ··· 207 206 .driver = { 208 207 .name = "i2c-slave-eeprom", 209 208 }, 210 - .probe = i2c_slave_eeprom_probe, 209 + .probe_new = i2c_slave_eeprom_probe, 211 210 .remove = i2c_slave_eeprom_remove, 212 211 .id_table = i2c_slave_eeprom_id, 213 212 };
+8 -3
drivers/i2c/i2c-smbus.c
··· 112 112 } 113 113 114 114 /* Setup SMBALERT# infrastructure */ 115 - static int smbalert_probe(struct i2c_client *ara, 116 - const struct i2c_device_id *id) 115 + static int smbalert_probe(struct i2c_client *ara) 117 116 { 118 117 struct i2c_smbus_alert_setup *setup = dev_get_platdata(&ara->dev); 119 118 struct i2c_smbus_alert *alert; ··· 169 170 .driver = { 170 171 .name = "smbus_alert", 171 172 }, 172 - .probe = smbalert_probe, 173 + .probe_new = smbalert_probe, 173 174 .remove = smbalert_remove, 174 175 .id_table = smbalert_ids, 175 176 }; ··· 360 361 return; 361 362 } 362 363 364 + /* 365 + * Memory types could be found at section 7.18.2 (Memory Device — Type), table 78 366 + * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf 367 + */ 363 368 switch (common_mem_type) { 369 + case 0x12: /* DDR */ 364 370 case 0x13: /* DDR2 */ 365 371 case 0x18: /* DDR3 */ 372 + case 0x1B: /* LPDDR */ 366 373 case 0x1C: /* LPDDR2 */ 367 374 case 0x1D: /* LPDDR3 */ 368 375 name = "spd";
+2 -3
drivers/i2c/muxes/i2c-mux-pca9541.c
··· 283 283 /* 284 284 * I2C init/probing/exit functions 285 285 */ 286 - static int pca9541_probe(struct i2c_client *client, 287 - const struct i2c_device_id *id) 286 + static int pca9541_probe(struct i2c_client *client) 288 287 { 289 288 struct i2c_adapter *adap = client->adapter; 290 289 struct i2c_mux_core *muxc; ··· 336 337 .name = "pca9541", 337 338 .of_match_table = of_match_ptr(pca9541_of_match), 338 339 }, 339 - .probe = pca9541_probe, 340 + .probe_new = pca9541_probe, 340 341 .remove = pca9541_remove, 341 342 .id_table = pca9541_id, 342 343 };
+3 -3
drivers/i2c/muxes/i2c-mux-pca954x.c
··· 411 411 /* 412 412 * I2C init/probing/exit functions 413 413 */ 414 - static int pca954x_probe(struct i2c_client *client, 415 - const struct i2c_device_id *id) 414 + static int pca954x_probe(struct i2c_client *client) 416 415 { 416 + const struct i2c_device_id *id = i2c_client_get_device_id(client); 417 417 struct i2c_adapter *adap = client->adapter; 418 418 struct device *dev = &client->dev; 419 419 struct gpio_desc *gpio; ··· 554 554 .pm = &pca954x_pm, 555 555 .of_match_table = pca954x_of_match, 556 556 }, 557 - .probe = pca954x_probe, 557 + .probe_new = pca954x_probe, 558 558 .remove = pca954x_remove, 559 559 .id_table = pca954x_id, 560 560 };
+2 -3
drivers/i2c/muxes/i2c-mux-reg.c
··· 183 183 if (!mux->data.reg) { 184 184 dev_info(&pdev->dev, 185 185 "Register not set, using platform resource\n"); 186 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 187 - mux->data.reg_size = resource_size(res); 188 - mux->data.reg = devm_ioremap_resource(&pdev->dev, res); 186 + mux->data.reg = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 189 187 if (IS_ERR(mux->data.reg)) { 190 188 ret = PTR_ERR(mux->data.reg); 191 189 goto err_put_parent; 192 190 } 191 + mux->data.reg_size = resource_size(res); 193 192 } 194 193 195 194 if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
+65 -14
drivers/soc/qcom/qcom-geni-se.c
··· 81 81 */ 82 82 83 83 #define MAX_CLK_PERF_LEVEL 32 84 - #define NUM_AHB_CLKS 2 84 + #define MAX_CLKS 2 85 85 86 86 /** 87 87 * struct geni_wrapper - Data structure to represent the QUP Wrapper Core 88 88 * @dev: Device pointer of the QUP wrapper core 89 89 * @base: Base address of this instance of QUP wrapper core 90 - * @ahb_clks: Handle to the primary & secondary AHB clocks 90 + * @clks: Handle to the primary & optional secondary AHB clocks 91 + * @num_clks: Count of clocks 91 92 * @to_core: Core ICC path 92 93 */ 93 94 struct geni_wrapper { 94 95 struct device *dev; 95 96 void __iomem *base; 96 - struct clk_bulk_data ahb_clks[NUM_AHB_CLKS]; 97 + struct clk_bulk_data clks[MAX_CLKS]; 98 + unsigned int num_clks; 99 + }; 100 + 101 + /** 102 + * struct geni_se_desc - Data structure to represent the QUP Wrapper resources 103 + * @clks: Name of the primary & optional secondary AHB clocks 104 + * @num_clks: Count of clock names 105 + */ 106 + struct geni_se_desc { 107 + unsigned int num_clks; 108 + const char * const *clks; 97 109 }; 98 110 99 111 static const char * const icc_path_names[] = {"qup-core", "qup-config", ··· 508 496 struct geni_wrapper *wrapper = se->wrapper; 509 497 510 498 clk_disable_unprepare(se->clk); 511 - clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks), 512 - wrapper->ahb_clks); 499 + clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks); 513 500 } 514 501 515 502 /** ··· 539 528 int ret; 540 529 struct geni_wrapper *wrapper = se->wrapper; 541 530 542 - ret = clk_bulk_prepare_enable(ARRAY_SIZE(wrapper->ahb_clks), 543 - wrapper->ahb_clks); 531 + ret = clk_bulk_prepare_enable(wrapper->num_clks, wrapper->clks); 544 532 if (ret) 545 533 return ret; 546 534 547 535 ret = clk_prepare_enable(se->clk); 548 536 if (ret) 549 - clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks), 550 - wrapper->ahb_clks); 537 + clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks); 551 538 return ret; 552 539 } 553 540 ··· 896 887 return PTR_ERR(wrapper->base); 897 888 898 889 if (!has_acpi_companion(&pdev->dev)) { 899 - wrapper->ahb_clks[0].id = "m-ahb"; 900 - wrapper->ahb_clks[1].id = "s-ahb"; 901 - ret = devm_clk_bulk_get(dev, NUM_AHB_CLKS, wrapper->ahb_clks); 890 + const struct geni_se_desc *desc; 891 + int i; 892 + 893 + desc = device_get_match_data(&pdev->dev); 894 + if (!desc) 895 + return -EINVAL; 896 + 897 + wrapper->num_clks = min_t(unsigned int, desc->num_clks, MAX_CLKS); 898 + 899 + for (i = 0; i < wrapper->num_clks; ++i) 900 + wrapper->clks[i].id = desc->clks[i]; 901 + 902 + ret = of_count_phandle_with_args(dev->of_node, "clocks", "#clock-cells"); 903 + if (ret < 0) { 904 + dev_err(dev, "invalid clocks property at %pOF\n", dev->of_node); 905 + return ret; 906 + } 907 + 908 + if (ret < wrapper->num_clks) { 909 + dev_err(dev, "invalid clocks count at %pOF, expected %d entries\n", 910 + dev->of_node, wrapper->num_clks); 911 + return -EINVAL; 912 + } 913 + 914 + ret = devm_clk_bulk_get(dev, wrapper->num_clks, wrapper->clks); 902 915 if (ret) { 903 - dev_err(dev, "Err getting AHB clks %d\n", ret); 916 + dev_err(dev, "Err getting clks %d\n", ret); 904 917 return ret; 905 918 } 906 919 } ··· 932 901 return devm_of_platform_populate(dev); 933 902 } 934 903 904 + static const char * const qup_clks[] = { 905 + "m-ahb", 906 + "s-ahb", 907 + }; 908 + 909 + static const struct geni_se_desc qup_desc = { 910 + .clks = qup_clks, 911 + .num_clks = ARRAY_SIZE(qup_clks), 912 + }; 913 + 914 + static const char * const i2c_master_hub_clks[] = { 915 + "s-ahb", 916 + }; 917 + 918 + static const struct geni_se_desc i2c_master_hub_desc = { 919 + .clks = i2c_master_hub_clks, 920 + .num_clks = ARRAY_SIZE(i2c_master_hub_clks), 921 + }; 922 + 935 923 static const struct of_device_id geni_se_dt_match[] = { 936 - { .compatible = "qcom,geni-se-qup", }, 924 + { .compatible = "qcom,geni-se-qup", .data = &qup_desc }, 925 + { .compatible = "qcom,geni-se-i2c-master-hub", .data = &i2c_master_hub_desc }, 937 926 {} 938 927 }; 939 928 MODULE_DEVICE_TABLE(of, geni_se_dt_match);