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

Merge branch 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c updates from Wolfram Sang:
"Mostly driver updates and refactorization.

The removal of the XLR driver and the i801 refactoring stand out a
little. In the core, we enabled async suspend/resume for I2C
controllers and their clients. No issues were reported during the test
phase in -next. We will see how this goes for mainline"

* 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (54 commits)
i2c: sh_mobile: remove unneeded semicolon
i2c: riic: Use platform_get_irq() to get the interrupt
i2c: sh_mobile: Use platform_get_irq_optional() to get the interrupt
i2c: bcm2835: Use platform_get_irq() to get the interrupt
i2c: aspeed: Remove unused includes
dt-bindings: i2c: aspeed: Drop stray '#interrupt-cells'
i2c: sh_mobile: update to new DMAENGINE API when terminating
i2c: rcar: update to new DMAENGINE API when terminating
i2c: exynos5: Fix getting the optional clock
i2c: designware-pci: Convert to use dev_err_probe()
i2c: designware-pci: use __maybe_unused for PM functions
i2c: designware-pci: Group MODULE_*() macros
i2c: designware-pci: Add a note about struct dw_scl_sda_cfg usage
i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters
i2c: designware: Do not complete i2c read without RX_FULL interrupt
eeprom: at24: Add support for 24c1025 EEPROM
dt-bindings: at24: add at24c1025
i2c: tegra: use i2c_timings for bus clock freq
dt-bindings: at24: Rework special case compatible handling
i2c: i801: Don't clear status flags twice in interrupt mode
...

+677 -1020
+15 -14
Documentation/devicetree/bindings/eeprom/at24.yaml
··· 87 87 - items: 88 88 pattern: cs1024$ 89 89 - items: 90 + pattern: c1025$ 91 + - items: 92 + pattern: cs1025$ 93 + - items: 90 94 pattern: c2048$ 91 95 - items: 92 96 pattern: cs2048$ ··· 99 95 # These are special cases that don't conform to the above pattern. 100 96 # Each requires a standard at24 model as fallback. 101 97 - items: 102 - - const: nxp,se97b 98 + - enum: 99 + - rohm,br24g01 100 + - rohm,br24t01 101 + - const: atmel,24c01 102 + - items: 103 + - enum: 104 + - nxp,se97b 105 + - renesas,r1ex24002 103 106 - const: atmel,24c02 104 107 - items: 105 - - const: onnn,cat24c04 108 + - enum: 109 + - onnn,cat24c04 110 + - onnn,cat24c05 106 111 - const: atmel,24c04 107 - - items: 108 - - const: onnn,cat24c05 109 - - const: atmel,24c04 110 - - items: 111 - - const: renesas,r1ex24002 112 - - const: atmel,24c02 113 112 - items: 114 113 - const: renesas,r1ex24016 115 114 - const: atmel,24c16 ··· 122 115 - items: 123 116 - const: renesas,r1ex24128 124 117 - const: atmel,24c128 125 - - items: 126 - - const: rohm,br24g01 127 - - const: atmel,24c01 128 - - items: 129 - - const: rohm,br24t01 130 - - const: atmel,24c01 131 118 132 119 label: 133 120 description: Descriptive name of the EEPROM.
-22
Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.txt
··· 1 - Broadcom BCM2835 I2C controller 2 - 3 - Required properties: 4 - - compatible : Should be one of: 5 - "brcm,bcm2711-i2c" 6 - "brcm,bcm2835-i2c" 7 - - reg: Should contain register location and length. 8 - - interrupts: Should contain interrupt. 9 - - clocks : The clock feeding the I2C controller. 10 - 11 - Recommended properties: 12 - - clock-frequency : desired I2C bus clock frequency in Hz. 13 - 14 - Example: 15 - 16 - i2c@7e205000 { 17 - compatible = "brcm,bcm2835-i2c"; 18 - reg = <0x7e205000 0x1000>; 19 - interrupts = <2 21>; 20 - clocks = <&clk_i2c>; 21 - clock-frequency = <100000>; 22 - };
+54
Documentation/devicetree/bindings/i2c/brcm,bcm2835-i2c.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/i2c/brcm,bcm2835-i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Broadcom BCM2835 I2C controller 8 + 9 + maintainers: 10 + - Stephen Warren <swarren@wwwdotorg.org> 11 + 12 + allOf: 13 + - $ref: /schemas/i2c/i2c-controller.yaml# 14 + 15 + properties: 16 + compatible: 17 + oneOf: 18 + - enum: 19 + - brcm,bcm2835-i2c 20 + - items: 21 + - const: brcm,bcm2711-i2c 22 + - const: brcm,bcm2835-i2c 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + clock-names: 31 + maxItems: 1 32 + 33 + clocks: 34 + maxItems: 1 35 + 36 + clock-frequency: true 37 + 38 + required: 39 + - compatible 40 + - reg 41 + - interrupts 42 + - clocks 43 + 44 + unevaluatedProperties: false 45 + 46 + examples: 47 + - | 48 + i2c@7e205000 { 49 + compatible = "brcm,bcm2835-i2c"; 50 + reg = <0x7e205000 0x1000>; 51 + interrupts = <2 21>; 52 + clocks = <&clk_i2c>; 53 + clock-frequency = <100000>; 54 + };
-53
Documentation/devicetree/bindings/i2c/i2c-exynos5.txt
··· 1 - * Samsung's High Speed I2C controller 2 - 3 - The Samsung's High Speed I2C controller is used to interface with I2C devices 4 - at various speeds ranging from 100khz to 3.4Mhz. 5 - 6 - Required properties: 7 - - compatible: value should be. 8 - -> "samsung,exynos5-hsi2c", (DEPRECATED) 9 - for i2c compatible with HSI2C available 10 - on Exynos5250 and Exynos5420 SoCs. 11 - -> "samsung,exynos5250-hsi2c", for i2c compatible with HSI2C available 12 - on Exynos5250 and Exynos5420 SoCs. 13 - -> "samsung,exynos5260-hsi2c", for i2c compatible with HSI2C available 14 - on Exynos5260 SoCs. 15 - -> "samsung,exynos7-hsi2c", for i2c compatible with HSI2C available 16 - on Exynos7 SoCs. 17 - 18 - - reg: physical base address of the controller and length of memory mapped 19 - region. 20 - - interrupts: interrupt number to the cpu. 21 - - #address-cells: always 1 (for i2c addresses) 22 - - #size-cells: always 0 23 - 24 - - Pinctrl: 25 - - pinctrl-0: Pin control group to be used for this controller. 26 - - pinctrl-names: Should contain only one value - "default". 27 - 28 - Optional properties: 29 - - clock-frequency: Desired operating frequency in Hz of the bus. 30 - -> If not specified, the bus operates in fast-speed mode at 31 - at 100khz. 32 - -> If specified, the bus operates in high-speed mode only if the 33 - clock-frequency is >= 1Mhz. 34 - 35 - Example: 36 - 37 - hsi2c@12ca0000 { 38 - compatible = "samsung,exynos5250-hsi2c"; 39 - reg = <0x12ca0000 0x100>; 40 - interrupts = <56>; 41 - clock-frequency = <100000>; 42 - 43 - pinctrl-0 = <&i2c4_bus>; 44 - pinctrl-names = "default"; 45 - 46 - #address-cells = <1>; 47 - #size-cells = <0>; 48 - 49 - s2mps11_pmic@66 { 50 - compatible = "samsung,s2mps11-pmic"; 51 - reg = <0x66>; 52 - }; 53 - };
+133
Documentation/devicetree/bindings/i2c/i2c-exynos5.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/i2c/i2c-exynos5.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Samsung's High Speed I2C controller 8 + 9 + maintainers: 10 + - Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> 11 + 12 + description: | 13 + The Samsung's High Speed I2C controller is used to interface with I2C devices 14 + at various speeds ranging from 100kHz to 3.4MHz. 15 + 16 + In case the HSI2C controller is encapsulated within USI block (it's the case 17 + e.g. for Exynos850 and Exynos Auto V9 SoCs), it might be also necessary to 18 + define USI node in device tree file, choosing "i2c" configuration. Please see 19 + Documentation/devicetree/bindings/soc/samsung/exynos-usi.yaml for details. 20 + 21 + properties: 22 + compatible: 23 + oneOf: 24 + - enum: 25 + - samsung,exynos5250-hsi2c # Exynos5250 and Exynos5420 26 + - samsung,exynos5260-hsi2c # Exynos5260 27 + - samsung,exynos7-hsi2c # Exynos7 28 + - samsung,exynosautov9-hsi2c # ExynosAutoV9 and Exynos850 29 + - const: samsung,exynos5-hsi2c # Exynos5250 and Exynos5420 30 + deprecated: true 31 + 32 + reg: 33 + maxItems: 1 34 + 35 + interrupts: 36 + maxItems: 1 37 + 38 + clock-frequency: 39 + default: 100000 40 + description: 41 + Desired operating frequency in Hz of the bus. 42 + 43 + If not specified, the bus operates in fast-speed mode at 100kHz. 44 + 45 + If specified, the bus operates in high-speed mode only if the 46 + clock-frequency is >= 1MHz. 47 + 48 + clocks: 49 + minItems: 1 50 + items: 51 + - description: I2C operating clock 52 + - description: Bus clock (APB) 53 + 54 + clock-names: 55 + minItems: 1 56 + items: 57 + - const: hsi2c 58 + - const: hsi2c_pclk 59 + 60 + required: 61 + - compatible 62 + - reg 63 + - interrupts 64 + - clocks 65 + 66 + allOf: 67 + - $ref: /schemas/i2c/i2c-controller.yaml# 68 + - if: 69 + properties: 70 + compatible: 71 + contains: 72 + enum: 73 + - samsung,exynosautov9-hsi2c 74 + 75 + then: 76 + properties: 77 + clocks: 78 + minItems: 2 79 + 80 + clock-names: 81 + minItems: 2 82 + 83 + required: 84 + - clock-names 85 + 86 + else: 87 + properties: 88 + clocks: 89 + maxItems: 1 90 + 91 + unevaluatedProperties: false 92 + 93 + examples: 94 + - | 95 + #include <dt-bindings/clock/exynos5420.h> 96 + #include <dt-bindings/interrupt-controller/arm-gic.h> 97 + #include <dt-bindings/interrupt-controller/irq.h> 98 + 99 + hsi2c_8: i2c@12e00000 { 100 + compatible = "samsung,exynos5250-hsi2c"; 101 + reg = <0x12e00000 0x1000>; 102 + interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>; 103 + #address-cells = <1>; 104 + #size-cells = <0>; 105 + clock-frequency = <100000>; 106 + clocks = <&clock CLK_USI4>; 107 + clock-names = "hsi2c"; 108 + 109 + pmic@66 { 110 + /* compatible = "samsung,s2mps11-pmic"; */ 111 + reg = <0x66>; 112 + }; 113 + }; 114 + 115 + - | 116 + #include <dt-bindings/clock/exynos850.h> 117 + #include <dt-bindings/interrupt-controller/arm-gic.h> 118 + 119 + hsi2c_2: i2c@138c0000 { 120 + compatible = "samsung,exynosautov9-hsi2c"; 121 + reg = <0x138c0000 0xc0>; 122 + interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>; 123 + #address-cells = <1>; 124 + #size-cells = <0>; 125 + clocks = <&cmu_peri CLK_GOUT_HSI2C2_IPCLK>, 126 + <&cmu_peri CLK_GOUT_HSI2C2_PCLK>; 127 + clock-names = "hsi2c", "hsi2c_pclk"; 128 + 129 + pmic@66 { 130 + /* compatible = "samsung,s2mps11-pmic"; */ 131 + reg = <0x66>; 132 + }; 133 + };
+2
Documentation/devicetree/bindings/i2c/i2c-imx-lpi2c.yaml
··· 20 20 - items: 21 21 - enum: 22 22 - fsl,imx8qxp-lpi2c 23 + - fsl,imx8dxl-lpi2c 23 24 - fsl,imx8qm-lpi2c 25 + - fsl,imx8ulp-lpi2c 24 26 - const: fsl,imx7ulp-lpi2c 25 27 26 28 reg:
+4 -14
drivers/i2c/busses/Kconfig
··· 617 617 help 618 618 High-speed I2C controller on Samsung Exynos5 and newer Samsung SoCs: 619 619 Exynos5250, Exynos5260, Exynos5410, Exynos542x, Exynos5800, 620 - Exynos5433 and Exynos7. 620 + Exynos5433, Exynos7, Exynos850 and ExynosAutoV9. 621 621 Choose Y here only if you build for such Samsung SoC. 622 622 623 623 config I2C_GPIO ··· 1153 1153 This driver can also be built as a module. If so, the module 1154 1154 will be called xilinx_i2c. 1155 1155 1156 - config I2C_XLR 1157 - tristate "Netlogic XLR I2C support" 1158 - depends on CPU_XLR || COMPILE_TEST 1159 - help 1160 - This driver enables support for the on-chip I2C interface of 1161 - the Netlogic XLR/XLS MIPS processors and Sigma Designs SOCs. 1162 - 1163 - This driver can also be built as a module. If so, the module 1164 - will be called i2c-xlr. 1165 - 1166 1156 config I2C_XLP9XX 1167 - tristate "XLP9XX I2C support" 1168 - depends on CPU_XLP || ARCH_THUNDER2 || COMPILE_TEST 1157 + tristate "Cavium ThunderX2 I2C support" 1158 + depends on ARCH_THUNDER2 || COMPILE_TEST 1169 1159 help 1170 1160 This driver enables support for the on-chip I2C interface of 1171 - the Broadcom XLP9xx/XLP5xx MIPS and Vulcan ARM64 processors. 1161 + the Cavium ThunderX2 processors. (Originally on Netlogic XLP SoCs.) 1172 1162 1173 1163 This driver can also be built as a module. If so, the module will 1174 1164 be called i2c-xlp9xx.
-1
drivers/i2c/busses/Makefile
··· 119 119 i2c-thunderx-objs := i2c-octeon-core.o i2c-thunderx-pcidrv.o 120 120 obj-$(CONFIG_I2C_THUNDERX) += i2c-thunderx.o 121 121 obj-$(CONFIG_I2C_XILINX) += i2c-xiic.o 122 - obj-$(CONFIG_I2C_XLR) += i2c-xlr.o 123 122 obj-$(CONFIG_I2C_XLP9XX) += i2c-xlp9xx.o 124 123 obj-$(CONFIG_I2C_RCAR) += i2c-rcar.o 125 124
-2
drivers/i2c/busses/i2c-aspeed.c
··· 16 16 #include <linux/interrupt.h> 17 17 #include <linux/io.h> 18 18 #include <linux/irq.h> 19 - #include <linux/irqchip/chained_irq.h> 20 - #include <linux/irqdomain.h> 21 19 #include <linux/kernel.h> 22 20 #include <linux/module.h> 23 21 #include <linux/of_address.h>
+4 -7
drivers/i2c/busses/i2c-bcm2835.c
··· 402 402 static int bcm2835_i2c_probe(struct platform_device *pdev) 403 403 { 404 404 struct bcm2835_i2c_dev *i2c_dev; 405 - struct resource *mem, *irq; 405 + struct resource *mem; 406 406 int ret; 407 407 struct i2c_adapter *adap; 408 408 struct clk *mclk; ··· 452 452 return ret; 453 453 } 454 454 455 - irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 456 - if (!irq) { 457 - dev_err(&pdev->dev, "No IRQ resource\n"); 458 - return -ENODEV; 459 - } 460 - i2c_dev->irq = irq->start; 455 + i2c_dev->irq = platform_get_irq(pdev, 0); 456 + if (i2c_dev->irq < 0) 457 + return i2c_dev->irq; 461 458 462 459 ret = request_irq(i2c_dev->irq, bcm2835_i2c_isr, IRQF_SHARED, 463 460 dev_name(&pdev->dev), i2c_dev);
+9 -4
drivers/i2c/busses/i2c-designware-core.h
··· 191 191 * @cmd_complete: tx completion indicator 192 192 * @clk: input reference clock 193 193 * @pclk: clock required to access the registers 194 + * @rst: optional reset for the controller 194 195 * @slave: represent an I2C slave device 196 + * @get_clk_rate_khz: callback to retrieve IP specific bus speed 195 197 * @cmd_err: run time hadware error code 196 198 * @msgs: points to an array of messages currently being transferred 197 199 * @msgs_num: the number of elements in msgs 198 - * @msg_write_idx: the element index of the current tx message in the msgs 199 - * array 200 + * @msg_write_idx: the element index of the current tx message in the msgs array 200 201 * @tx_buf_len: the length of the current tx buffer 201 202 * @tx_buf: the current tx buffer 202 - * @msg_read_idx: the element index of the current rx message in the msgs 203 - * array 203 + * @msg_read_idx: the element index of the current rx message in the msgs array 204 204 * @rx_buf_len: the length of the current rx buffer 205 205 * @rx_buf: the current rx buffer 206 206 * @msg_err: error status of the current transfer 207 207 * @status: i2c master status, one of STATUS_* 208 208 * @abort_source: copy of the TX_ABRT_SOURCE register 209 209 * @irq: interrupt number for the i2c master 210 + * @flags: platform specific flags like type of IO accessors or model 210 211 * @adapter: i2c subsystem adapter node 212 + * @functionality: I2C_FUNC_* ORed bits to reflect what controller does support 213 + * @master_cfg: configuration for the master device 211 214 * @slave_cfg: configuration for the slave device 212 215 * @tx_fifo_depth: depth of the hardware tx fifo 213 216 * @rx_fifo_depth: depth of the hardware rx fifo ··· 231 228 * @disable: function to disable the controller 232 229 * @disable_int: function to disable all interrupts 233 230 * @init: function to initialize the I2C hardware 231 + * @set_sda_hold_time: callback to retrieve IP specific SDA hold timing 234 232 * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE 233 + * @rinfo: I²C GPIO recovery information 235 234 * @suspended: set to true if the controller is suspended 236 235 * 237 236 * HCNT and LCNT parameters can be used if the platform knows more accurate
+5 -2
drivers/i2c/busses/i2c-designware-master.c
··· 701 701 regmap_read(dev->map, DW_IC_CLR_RX_DONE, &dummy); 702 702 if (stat & DW_IC_INTR_ACTIVITY) 703 703 regmap_read(dev->map, DW_IC_CLR_ACTIVITY, &dummy); 704 - if (stat & DW_IC_INTR_STOP_DET) 704 + if ((stat & DW_IC_INTR_STOP_DET) && 705 + ((dev->rx_outstanding == 0) || (stat & DW_IC_INTR_RX_FULL))) 705 706 regmap_read(dev->map, DW_IC_CLR_STOP_DET, &dummy); 706 707 if (stat & DW_IC_INTR_START_DET) 707 708 regmap_read(dev->map, DW_IC_CLR_START_DET, &dummy); ··· 724 723 if (stat & DW_IC_INTR_TX_ABRT) { 725 724 dev->cmd_err |= DW_IC_ERR_TX_ABRT; 726 725 dev->status = STATUS_IDLE; 726 + dev->rx_outstanding = 0; 727 727 728 728 /* 729 729 * Anytime TX_ABRT is set, the contents of the tx/rx ··· 747 745 */ 748 746 749 747 tx_aborted: 750 - if ((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err) 748 + if (((stat & (DW_IC_INTR_TX_ABRT | DW_IC_INTR_STOP_DET)) || dev->msg_err) && 749 + (dev->rx_outstanding == 0)) 751 750 complete(&dev->cmd_complete); 752 751 else if (unlikely(dev->flags & ACCESS_INTR_MASK)) { 753 752 /* Workaround to trigger pending interrupt */
+25 -26
drivers/i2c/busses/i2c-designware-pcidrv.c
··· 38 38 navi_amd, 39 39 }; 40 40 41 + /* 42 + * This is a legacy structure to describe the hardware counters 43 + * to configure signal timings on the bus. For Device Tree platforms 44 + * one should use the respective properties and for ACPI there is 45 + * a set of ACPI methods that provide these counters. No new 46 + * platform should use this structure. 47 + */ 41 48 struct dw_scl_sda_cfg { 42 - u32 ss_hcnt; 43 - u32 fs_hcnt; 44 - u32 ss_lcnt; 45 - u32 fs_lcnt; 49 + u16 ss_hcnt; 50 + u16 fs_hcnt; 51 + u16 ss_lcnt; 52 + u16 fs_lcnt; 46 53 u32 sda_hold; 47 54 }; 48 55 ··· 213 206 }, 214 207 }; 215 208 216 - #ifdef CONFIG_PM 217 - static int i2c_dw_pci_suspend(struct device *dev) 209 + static int __maybe_unused i2c_dw_pci_suspend(struct device *dev) 218 210 { 219 211 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 220 212 ··· 223 217 return 0; 224 218 } 225 219 226 - static int i2c_dw_pci_resume(struct device *dev) 220 + static int __maybe_unused i2c_dw_pci_resume(struct device *dev) 227 221 { 228 222 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 229 223 int ret; ··· 233 227 234 228 return ret; 235 229 } 236 - #endif 237 230 238 231 static UNIVERSAL_DEV_PM_OPS(i2c_dw_pm_ops, i2c_dw_pci_suspend, 239 232 i2c_dw_pci_resume, NULL); ··· 246 241 struct dw_pci_controller *controller; 247 242 struct dw_scl_sda_cfg *cfg; 248 243 249 - if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) { 250 - dev_err(&pdev->dev, "%s: invalid driver data %ld\n", __func__, 251 - id->driver_data); 252 - return -EINVAL; 253 - } 244 + if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) 245 + return dev_err_probe(&pdev->dev, -EINVAL, 246 + "Invalid driver data %ld\n", 247 + id->driver_data); 254 248 255 249 controller = &dw_pci_controllers[id->driver_data]; 256 250 257 251 r = pcim_enable_device(pdev); 258 - if (r) { 259 - dev_err(&pdev->dev, "Failed to enable I2C PCI device (%d)\n", 260 - r); 261 - return r; 262 - } 252 + if (r) 253 + return dev_err_probe(&pdev->dev, r, 254 + "Failed to enable I2C PCI device\n"); 263 255 264 256 pci_set_master(pdev); 265 257 266 258 r = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); 267 - if (r) { 268 - dev_err(&pdev->dev, "I/O memory remapping failed\n"); 269 - return r; 270 - } 259 + if (r) 260 + return dev_err_probe(&pdev->dev, r, 261 + "I/O memory remapping failed\n"); 271 262 272 263 dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL); 273 264 if (!dev) ··· 353 352 pci_free_irq_vectors(pdev); 354 353 } 355 354 356 - /* work with hotplug and coldplug */ 357 - MODULE_ALIAS("i2c_designware-pci"); 358 - 359 355 static const struct pci_device_id i2_designware_pci_ids[] = { 360 356 /* Medfield */ 361 357 { PCI_VDEVICE(INTEL, 0x0817), medfield }, ··· 409 411 .pm = &i2c_dw_pm_ops, 410 412 }, 411 413 }; 412 - 413 414 module_pci_driver(dw_i2c_driver); 414 415 416 + /* Work with hotplug and coldplug */ 417 + MODULE_ALIAS("i2c_designware-pci"); 415 418 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 416 419 MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); 417 420 MODULE_LICENSE("GPL");
+2
drivers/i2c/busses/i2c-designware-platdrv.c
··· 293 293 DPM_FLAG_MAY_SKIP_RESUME); 294 294 } 295 295 296 + device_enable_async_suspend(&pdev->dev); 297 + 296 298 /* The code below assumes runtime PM to be disabled. */ 297 299 WARN_ON(pm_runtime_enabled(&pdev->dev)); 298 300
+93 -17
drivers/i2c/busses/i2c-exynos5.c
··· 169 169 enum i2c_type_exynos { 170 170 I2C_TYPE_EXYNOS5, 171 171 I2C_TYPE_EXYNOS7, 172 + I2C_TYPE_EXYNOSAUTOV9, 172 173 }; 173 174 174 175 struct exynos5_i2c { ··· 182 181 unsigned int irq; 183 182 184 183 void __iomem *regs; 185 - struct clk *clk; 184 + struct clk *clk; /* operating clock */ 185 + struct clk *pclk; /* bus clock */ 186 186 struct device *dev; 187 187 int state; 188 188 ··· 232 230 .hw = I2C_TYPE_EXYNOS7, 233 231 }; 234 232 233 + static const struct exynos_hsi2c_variant exynosautov9_hsi2c_data = { 234 + .fifo_depth = 64, 235 + .hw = I2C_TYPE_EXYNOSAUTOV9, 236 + }; 237 + 235 238 static const struct of_device_id exynos5_i2c_match[] = { 236 239 { 237 240 .compatible = "samsung,exynos5-hsi2c", ··· 250 243 }, { 251 244 .compatible = "samsung,exynos7-hsi2c", 252 245 .data = &exynos7_hsi2c_data 246 + }, { 247 + .compatible = "samsung,exynosautov9-hsi2c", 248 + .data = &exynosautov9_hsi2c_data 253 249 }, {}, 254 250 }; 255 251 MODULE_DEVICE_TABLE(of, exynos5_i2c_match); ··· 290 280 (i2c->op_clock >= I2C_MAX_FAST_MODE_PLUS_FREQ) ? I2C_MAX_STANDARD_MODE_FREQ : 291 281 i2c->op_clock; 292 282 int div, clk_cycle, temp; 283 + 284 + /* 285 + * In case of HSI2C controllers in ExynosAutoV9: 286 + * 287 + * FSCL = IPCLK / ((CLK_DIV + 1) * 16) 288 + * T_SCL_LOW = IPCLK * (CLK_DIV + 1) * (N + M) 289 + * [N : number of 0's in the TSCL_H_HS] 290 + * [M : number of 0's in the TSCL_L_HS] 291 + * T_SCL_HIGH = IPCLK * (CLK_DIV + 1) * (N + M) 292 + * [N : number of 1's in the TSCL_H_HS] 293 + * [M : number of 1's in the TSCL_L_HS] 294 + * 295 + * Result of (N + M) is always 8. 296 + * In general case, we don't need to control timing_s1 and timing_s2. 297 + */ 298 + if (i2c->variant->hw == I2C_TYPE_EXYNOSAUTOV9) { 299 + div = ((clkin / (16 * i2c->op_clock)) - 1); 300 + i2c_timing_s3 = div << 16; 301 + if (hs_timings) 302 + writel(i2c_timing_s3, i2c->regs + HSI2C_TIMING_HS3); 303 + else 304 + writel(i2c_timing_s3, i2c->regs + HSI2C_TIMING_FS3); 305 + 306 + return 0; 307 + } 293 308 294 309 /* 295 310 * In case of HSI2C controller in Exynos5 series ··· 457 422 writel(int_status, i2c->regs + HSI2C_INT_STATUS); 458 423 459 424 /* handle interrupt related to the transfer status */ 460 - if (i2c->variant->hw == I2C_TYPE_EXYNOS7) { 425 + switch (i2c->variant->hw) { 426 + case I2C_TYPE_EXYNOSAUTOV9: 427 + fallthrough; 428 + case I2C_TYPE_EXYNOS7: 461 429 if (int_status & HSI2C_INT_TRANS_DONE) { 462 430 i2c->trans_done = 1; 463 431 i2c->state = 0; ··· 481 443 i2c->state = -ETIMEDOUT; 482 444 goto stop; 483 445 } 484 - } else if (int_status & HSI2C_INT_I2C) { 446 + 447 + break; 448 + case I2C_TYPE_EXYNOS5: 449 + if (!(int_status & HSI2C_INT_I2C)) 450 + break; 451 + 485 452 trans_status = readl(i2c->regs + HSI2C_TRANS_STATUS); 486 453 if (trans_status & HSI2C_NO_DEV_ACK) { 487 454 dev_dbg(i2c->dev, "No ACK from device\n"); ··· 508 465 i2c->trans_done = 1; 509 466 i2c->state = 0; 510 467 } 468 + 469 + break; 511 470 } 512 471 513 472 if ((i2c->msg->flags & I2C_M_RD) && (int_status & ··· 614 569 { 615 570 unsigned long timeout; 616 571 617 - if (i2c->variant->hw != I2C_TYPE_EXYNOS7) 572 + if (i2c->variant->hw == I2C_TYPE_EXYNOS5) 618 573 return; 619 574 620 575 /* 621 - * HSI2C_MASTER_ST_LOSE state in EXYNOS7 variant before transaction 622 - * indicates that bus is stuck (SDA is low). In such case bus recovery 623 - * can be performed. 576 + * HSI2C_MASTER_ST_LOSE state (in Exynos7 and ExynosAutoV9 variants) 577 + * before transaction indicates that bus is stuck (SDA is low). 578 + * In such case bus recovery can be performed. 624 579 */ 625 580 timeout = jiffies + msecs_to_jiffies(100); 626 581 for (;;) { ··· 656 611 unsigned long flags; 657 612 unsigned short trig_lvl; 658 613 659 - if (i2c->variant->hw == I2C_TYPE_EXYNOS7) 660 - int_en |= HSI2C_INT_I2C_TRANS; 661 - else 614 + if (i2c->variant->hw == I2C_TYPE_EXYNOS5) 662 615 int_en |= HSI2C_INT_I2C; 616 + else 617 + int_en |= HSI2C_INT_I2C_TRANS; 663 618 664 619 i2c_ctl = readl(i2c->regs + HSI2C_CTL); 665 620 i2c_ctl &= ~(HSI2C_TXCHON | HSI2C_RXCHON); ··· 758 713 struct exynos5_i2c *i2c = adap->algo_data; 759 714 int i, ret; 760 715 761 - ret = clk_enable(i2c->clk); 716 + ret = clk_enable(i2c->pclk); 762 717 if (ret) 763 718 return ret; 719 + 720 + ret = clk_enable(i2c->clk); 721 + if (ret) 722 + goto err_pclk; 764 723 765 724 for (i = 0; i < num; ++i) { 766 725 ret = exynos5_i2c_xfer_msg(i2c, msgs + i, i + 1 == num); ··· 773 724 } 774 725 775 726 clk_disable(i2c->clk); 727 + err_pclk: 728 + clk_disable(i2c->pclk); 776 729 777 730 return ret ?: num; 778 731 } ··· 814 763 return -ENOENT; 815 764 } 816 765 817 - ret = clk_prepare_enable(i2c->clk); 766 + i2c->pclk = devm_clk_get_optional(&pdev->dev, "hsi2c_pclk"); 767 + if (IS_ERR(i2c->pclk)) { 768 + return dev_err_probe(&pdev->dev, PTR_ERR(i2c->pclk), 769 + "cannot get pclk"); 770 + } 771 + 772 + ret = clk_prepare_enable(i2c->pclk); 818 773 if (ret) 819 774 return ret; 775 + 776 + ret = clk_prepare_enable(i2c->clk); 777 + if (ret) 778 + goto err_pclk; 820 779 821 780 i2c->regs = devm_platform_ioremap_resource(pdev, 0); 822 781 if (IS_ERR(i2c->regs)) { ··· 870 809 platform_set_drvdata(pdev, i2c); 871 810 872 811 clk_disable(i2c->clk); 812 + clk_disable(i2c->pclk); 873 813 874 814 return 0; 875 815 876 816 err_clk: 877 817 clk_disable_unprepare(i2c->clk); 818 + 819 + err_pclk: 820 + clk_disable_unprepare(i2c->pclk); 878 821 return ret; 879 822 } 880 823 ··· 889 824 i2c_del_adapter(&i2c->adap); 890 825 891 826 clk_unprepare(i2c->clk); 827 + clk_unprepare(i2c->pclk); 892 828 893 829 return 0; 894 830 } ··· 901 835 902 836 i2c_mark_adapter_suspended(&i2c->adap); 903 837 clk_unprepare(i2c->clk); 838 + clk_unprepare(i2c->pclk); 904 839 905 840 return 0; 906 841 } ··· 911 844 struct exynos5_i2c *i2c = dev_get_drvdata(dev); 912 845 int ret = 0; 913 846 914 - ret = clk_prepare_enable(i2c->clk); 847 + ret = clk_prepare_enable(i2c->pclk); 915 848 if (ret) 916 849 return ret; 917 850 851 + ret = clk_prepare_enable(i2c->clk); 852 + if (ret) 853 + goto err_pclk; 854 + 918 855 ret = exynos5_hsi2c_clock_setup(i2c); 919 - if (ret) { 920 - clk_disable_unprepare(i2c->clk); 921 - return ret; 922 - } 856 + if (ret) 857 + goto err_clk; 923 858 924 859 exynos5_i2c_init(i2c); 925 860 clk_disable(i2c->clk); 861 + clk_disable(i2c->pclk); 926 862 i2c_mark_adapter_resumed(&i2c->adap); 927 863 928 864 return 0; 865 + 866 + err_clk: 867 + clk_disable_unprepare(i2c->clk); 868 + err_pclk: 869 + clk_disable_unprepare(i2c->pclk); 870 + return ret; 929 871 } 930 872 #endif 931 873
+96 -192
drivers/i2c/busses/i2c-i801.c
··· 328 328 329 329 status = inb_p(SMBHSTSTS(priv)); 330 330 if (status & SMBHSTSTS_HOST_BUSY) { 331 - dev_err(&priv->pci_dev->dev, "SMBus is busy, can't use it!\n"); 331 + pci_err(priv->pci_dev, "SMBus is busy, can't use it!\n"); 332 332 return -EBUSY; 333 333 } 334 334 335 335 status &= STATUS_FLAGS; 336 336 if (status) { 337 - dev_dbg(&priv->pci_dev->dev, "Clearing status flags (%02x)\n", 338 - status); 337 + pci_dbg(priv->pci_dev, "Clearing status flags (%02x)\n", status); 339 338 outb_p(status, SMBHSTSTS(priv)); 340 - status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; 341 - if (status) { 342 - dev_err(&priv->pci_dev->dev, 343 - "Failed clearing status flags (%02x)\n", 344 - status); 345 - return -EBUSY; 346 - } 347 339 } 348 340 349 341 /* ··· 348 356 if (priv->features & FEATURE_SMBUS_PEC) { 349 357 status = inb_p(SMBAUXSTS(priv)) & SMBAUXSTS_CRCE; 350 358 if (status) { 351 - dev_dbg(&priv->pci_dev->dev, 352 - "Clearing aux status flags (%02x)\n", status); 359 + pci_dbg(priv->pci_dev, "Clearing aux status flags (%02x)\n", status); 353 360 outb_p(status, SMBAUXSTS(priv)); 354 - status = inb_p(SMBAUXSTS(priv)) & SMBAUXSTS_CRCE; 355 - if (status) { 356 - dev_err(&priv->pci_dev->dev, 357 - "Failed clearing aux status flags (%02x)\n", 358 - status); 359 - return -EBUSY; 360 - } 361 361 } 362 362 } 363 363 364 364 return 0; 365 365 } 366 366 367 - /* 368 - * Convert the status register to an error code, and clear it. 369 - * Note that status only contains the bits we want to clear, not the 370 - * actual register value. 371 - */ 372 367 static int i801_check_post(struct i801_priv *priv, int status) 373 368 { 374 369 int result = 0; ··· 380 401 !(status & SMBHSTSTS_FAILED)) 381 402 dev_err(&priv->pci_dev->dev, 382 403 "Failed terminating the transaction\n"); 383 - outb_p(STATUS_FLAGS, SMBHSTSTS(priv)); 384 404 return -ETIMEDOUT; 385 405 } 386 406 ··· 417 439 result = -EAGAIN; 418 440 dev_dbg(&priv->pci_dev->dev, "Lost arbitration\n"); 419 441 } 420 - 421 - /* Clear status flags except BYTE_DONE, to be cleared by caller */ 422 - outb_p(status, SMBHSTSTS(priv)); 423 442 424 443 return result; 425 444 } ··· 498 523 return -EOPNOTSUPP; 499 524 } 500 525 526 + /* Set block buffer mode */ 527 + outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); 528 + 501 529 inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ 502 530 503 - /* Use 32-byte buffer to process this transaction */ 504 531 if (read_write == I2C_SMBUS_WRITE) { 505 532 len = data->block[0]; 506 533 outb_p(len, SMBHSTDAT0(priv)); ··· 737 760 return i801_check_post(priv, status); 738 761 } 739 762 740 - static int i801_set_block_buffer_mode(struct i801_priv *priv) 741 - { 742 - outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); 743 - if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) 744 - return -EIO; 745 - return 0; 746 - } 747 - 748 763 /* Block transaction function */ 749 764 static int i801_block_transaction(struct i801_priv *priv, union i2c_smbus_data *data, 750 765 char read_write, int command) 751 766 { 752 767 int result = 0; 753 768 unsigned char hostc; 769 + 770 + if (read_write == I2C_SMBUS_READ && command == I2C_SMBUS_BLOCK_DATA) 771 + data->block[0] = I2C_SMBUS_BLOCK_MAX; 772 + else if (data->block[0] < 1 || data->block[0] > I2C_SMBUS_BLOCK_MAX) 773 + return -EPROTO; 754 774 755 775 if (command == I2C_SMBUS_I2C_BLOCK_DATA) { 756 776 if (read_write == I2C_SMBUS_WRITE) { ··· 762 788 } 763 789 } 764 790 765 - if (read_write == I2C_SMBUS_WRITE 766 - || command == I2C_SMBUS_I2C_BLOCK_DATA) { 767 - if (data->block[0] < 1) 768 - data->block[0] = 1; 769 - if (data->block[0] > I2C_SMBUS_BLOCK_MAX) 770 - data->block[0] = I2C_SMBUS_BLOCK_MAX; 771 - } else { 772 - data->block[0] = 32; /* max for SMBus block reads */ 773 - } 774 - 775 791 /* Experience has shown that the block buffer can only be used for 776 792 SMBus (not I2C) block transactions, even though the datasheet 777 793 doesn't mention this limitation. */ 778 - if ((priv->features & FEATURE_BLOCK_BUFFER) 779 - && command != I2C_SMBUS_I2C_BLOCK_DATA 780 - && i801_set_block_buffer_mode(priv) == 0) 794 + if ((priv->features & FEATURE_BLOCK_BUFFER) && 795 + command != I2C_SMBUS_I2C_BLOCK_DATA) 781 796 result = i801_block_transaction_by_block(priv, data, 782 797 read_write, 783 798 command); ··· 914 951 } 915 952 916 953 out: 917 - /* Unlock the SMBus device for use by BIOS/ACPI */ 918 - outb_p(SMBHSTSTS_INUSE_STS, SMBHSTSTS(priv)); 954 + /* 955 + * Unlock the SMBus device for use by BIOS/ACPI, 956 + * and clear status flags if not done already. 957 + */ 958 + outb_p(SMBHSTSTS_INUSE_STS | STATUS_FLAGS, SMBHSTSTS(priv)); 919 959 920 960 pm_runtime_mark_last_busy(&priv->pci_dev->dev); 921 961 pm_runtime_put_autosuspend(&priv->pci_dev->dev); ··· 975 1009 .functionality = i801_func, 976 1010 }; 977 1011 1012 + #define FEATURES_ICH5 (FEATURE_BLOCK_PROC | FEATURE_I2C_BLOCK_READ | \ 1013 + FEATURE_IRQ | FEATURE_SMBUS_PEC | \ 1014 + FEATURE_BLOCK_BUFFER | FEATURE_HOST_NOTIFY) 1015 + #define FEATURES_ICH4 (FEATURE_SMBUS_PEC | FEATURE_BLOCK_BUFFER | \ 1016 + FEATURE_HOST_NOTIFY) 1017 + 978 1018 static const struct pci_device_id i801_ids[] = { 979 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_3) }, 980 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_3) }, 981 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_2) }, 982 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_3) }, 983 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_3) }, 984 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_3) }, 985 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_4) }, 986 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_16) }, 987 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_17) }, 988 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_17) }, 989 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_5) }, 990 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_6) }, 991 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EP80579_1) }, 992 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_4) }, 993 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_5) }, 994 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS) }, 995 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COUGARPOINT_SMBUS) }, 996 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS) }, 997 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0) }, 998 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1) }, 999 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2) }, 1000 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DH89XXCC_SMBUS) }, 1001 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PANTHERPOINT_SMBUS) }, 1002 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS) }, 1003 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS) }, 1004 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_AVOTON_SMBUS) }, 1005 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS) }, 1006 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS0) }, 1007 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS1) }, 1008 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2) }, 1009 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COLETOCREEK_SMBUS) }, 1010 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GEMINILAKE_SMBUS) }, 1011 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS) }, 1012 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_WILDCATPOINT_LP_SMBUS) }, 1013 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS) }, 1014 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BRASWELL_SMBUS) }, 1015 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS) }, 1016 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS) }, 1017 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CDF_SMBUS) }, 1018 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_DNV_SMBUS) }, 1019 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EBG_SMBUS) }, 1020 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BROXTON_SMBUS) }, 1021 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS) }, 1022 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS) }, 1023 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS) }, 1024 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS) }, 1025 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS) }, 1026 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS) }, 1027 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICELAKE_N_SMBUS) }, 1028 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS) }, 1029 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS) }, 1030 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_V_SMBUS) }, 1031 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS) }, 1032 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS) }, 1033 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_H_SMBUS) }, 1034 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS) }, 1035 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ALDER_LAKE_S_SMBUS) }, 1036 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ALDER_LAKE_P_SMBUS) }, 1037 - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ALDER_LAKE_M_SMBUS) }, 1019 + { PCI_DEVICE_DATA(INTEL, 82801AA_3, 0) }, 1020 + { PCI_DEVICE_DATA(INTEL, 82801AB_3, 0) }, 1021 + { PCI_DEVICE_DATA(INTEL, 82801BA_2, 0) }, 1022 + { PCI_DEVICE_DATA(INTEL, 82801CA_3, FEATURE_HOST_NOTIFY) }, 1023 + { PCI_DEVICE_DATA(INTEL, 82801DB_3, FEATURES_ICH4) }, 1024 + { PCI_DEVICE_DATA(INTEL, 82801EB_3, FEATURES_ICH5) }, 1025 + { PCI_DEVICE_DATA(INTEL, ESB_4, FEATURES_ICH5) }, 1026 + { PCI_DEVICE_DATA(INTEL, ICH6_16, FEATURES_ICH5) }, 1027 + { PCI_DEVICE_DATA(INTEL, ICH7_17, FEATURES_ICH5) }, 1028 + { PCI_DEVICE_DATA(INTEL, ESB2_17, FEATURES_ICH5) }, 1029 + { PCI_DEVICE_DATA(INTEL, ICH8_5, FEATURES_ICH5) }, 1030 + { PCI_DEVICE_DATA(INTEL, ICH9_6, FEATURES_ICH5) }, 1031 + { PCI_DEVICE_DATA(INTEL, EP80579_1, FEATURES_ICH5) }, 1032 + { PCI_DEVICE_DATA(INTEL, ICH10_4, FEATURES_ICH5) }, 1033 + { PCI_DEVICE_DATA(INTEL, ICH10_5, FEATURES_ICH5) }, 1034 + { PCI_DEVICE_DATA(INTEL, 5_3400_SERIES_SMBUS, FEATURES_ICH5) }, 1035 + { PCI_DEVICE_DATA(INTEL, COUGARPOINT_SMBUS, FEATURES_ICH5) }, 1036 + { PCI_DEVICE_DATA(INTEL, PATSBURG_SMBUS, FEATURES_ICH5) }, 1037 + { PCI_DEVICE_DATA(INTEL, PATSBURG_SMBUS_IDF0, FEATURES_ICH5 | FEATURE_IDF) }, 1038 + { PCI_DEVICE_DATA(INTEL, PATSBURG_SMBUS_IDF1, FEATURES_ICH5 | FEATURE_IDF) }, 1039 + { PCI_DEVICE_DATA(INTEL, PATSBURG_SMBUS_IDF2, FEATURES_ICH5 | FEATURE_IDF) }, 1040 + { PCI_DEVICE_DATA(INTEL, DH89XXCC_SMBUS, FEATURES_ICH5) }, 1041 + { PCI_DEVICE_DATA(INTEL, PANTHERPOINT_SMBUS, FEATURES_ICH5) }, 1042 + { PCI_DEVICE_DATA(INTEL, LYNXPOINT_SMBUS, FEATURES_ICH5) }, 1043 + { PCI_DEVICE_DATA(INTEL, LYNXPOINT_LP_SMBUS, FEATURES_ICH5) }, 1044 + { PCI_DEVICE_DATA(INTEL, AVOTON_SMBUS, FEATURES_ICH5) }, 1045 + { PCI_DEVICE_DATA(INTEL, WELLSBURG_SMBUS, FEATURES_ICH5) }, 1046 + { PCI_DEVICE_DATA(INTEL, WELLSBURG_SMBUS_MS0, FEATURES_ICH5 | FEATURE_IDF) }, 1047 + { PCI_DEVICE_DATA(INTEL, WELLSBURG_SMBUS_MS1, FEATURES_ICH5 | FEATURE_IDF) }, 1048 + { PCI_DEVICE_DATA(INTEL, WELLSBURG_SMBUS_MS2, FEATURES_ICH5 | FEATURE_IDF) }, 1049 + { PCI_DEVICE_DATA(INTEL, COLETOCREEK_SMBUS, FEATURES_ICH5) }, 1050 + { PCI_DEVICE_DATA(INTEL, GEMINILAKE_SMBUS, FEATURES_ICH5) }, 1051 + { PCI_DEVICE_DATA(INTEL, WILDCATPOINT_SMBUS, FEATURES_ICH5) }, 1052 + { PCI_DEVICE_DATA(INTEL, WILDCATPOINT_LP_SMBUS, FEATURES_ICH5) }, 1053 + { PCI_DEVICE_DATA(INTEL, BAYTRAIL_SMBUS, FEATURES_ICH5) }, 1054 + { PCI_DEVICE_DATA(INTEL, BRASWELL_SMBUS, FEATURES_ICH5) }, 1055 + { PCI_DEVICE_DATA(INTEL, SUNRISEPOINT_H_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1056 + { PCI_DEVICE_DATA(INTEL, SUNRISEPOINT_LP_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1057 + { PCI_DEVICE_DATA(INTEL, CDF_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1058 + { PCI_DEVICE_DATA(INTEL, DNV_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1059 + { PCI_DEVICE_DATA(INTEL, EBG_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1060 + { PCI_DEVICE_DATA(INTEL, BROXTON_SMBUS, FEATURES_ICH5) }, 1061 + { PCI_DEVICE_DATA(INTEL, LEWISBURG_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1062 + { PCI_DEVICE_DATA(INTEL, LEWISBURG_SSKU_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1063 + { PCI_DEVICE_DATA(INTEL, KABYLAKE_PCH_H_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1064 + { PCI_DEVICE_DATA(INTEL, CANNONLAKE_H_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1065 + { PCI_DEVICE_DATA(INTEL, CANNONLAKE_LP_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1066 + { PCI_DEVICE_DATA(INTEL, ICELAKE_LP_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1067 + { PCI_DEVICE_DATA(INTEL, ICELAKE_N_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1068 + { PCI_DEVICE_DATA(INTEL, COMETLAKE_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1069 + { PCI_DEVICE_DATA(INTEL, COMETLAKE_H_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1070 + { PCI_DEVICE_DATA(INTEL, COMETLAKE_V_SMBUS, FEATURES_ICH5 | FEATURE_TCO_SPT) }, 1071 + { PCI_DEVICE_DATA(INTEL, ELKHART_LAKE_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1072 + { PCI_DEVICE_DATA(INTEL, TIGERLAKE_LP_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1073 + { PCI_DEVICE_DATA(INTEL, TIGERLAKE_H_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1074 + { PCI_DEVICE_DATA(INTEL, JASPER_LAKE_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1075 + { PCI_DEVICE_DATA(INTEL, ALDER_LAKE_S_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1076 + { PCI_DEVICE_DATA(INTEL, ALDER_LAKE_P_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1077 + { PCI_DEVICE_DATA(INTEL, ALDER_LAKE_M_SMBUS, FEATURES_ICH5 | FEATURE_TCO_CNL) }, 1038 1078 { 0, } 1039 1079 }; 1040 1080 ··· 1465 1493 } 1466 1494 #endif 1467 1495 1468 - static const struct itco_wdt_platform_data spt_tco_platform_data = { 1469 - .name = "Intel PCH", 1470 - .version = 4, 1471 - }; 1472 - 1473 1496 static struct platform_device * 1474 1497 i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev, 1475 1498 struct resource *tco_res) 1476 1499 { 1500 + static const struct itco_wdt_platform_data pldata = { 1501 + .name = "Intel PCH", 1502 + .version = 4, 1503 + }; 1477 1504 struct resource *res; 1478 1505 unsigned int devfn; 1479 1506 u64 base64_addr; ··· 1515 1544 res->flags = IORESOURCE_MEM; 1516 1545 1517 1546 return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1518 - tco_res, 2, &spt_tco_platform_data, 1519 - sizeof(spt_tco_platform_data)); 1547 + tco_res, 2, &pldata, sizeof(pldata)); 1520 1548 } 1521 - 1522 - static const struct itco_wdt_platform_data cnl_tco_platform_data = { 1523 - .name = "Intel PCH", 1524 - .version = 6, 1525 - }; 1526 1549 1527 1550 static struct platform_device * 1528 1551 i801_add_tco_cnl(struct i801_priv *priv, struct pci_dev *pci_dev, 1529 1552 struct resource *tco_res) 1530 1553 { 1531 - return platform_device_register_resndata(&pci_dev->dev, 1532 - "iTCO_wdt", -1, tco_res, 1, &cnl_tco_platform_data, 1533 - sizeof(cnl_tco_platform_data)); 1554 + static const struct itco_wdt_platform_data pldata = { 1555 + .name = "Intel PCH", 1556 + .version = 6, 1557 + }; 1558 + 1559 + return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1, 1560 + tco_res, 1, &pldata, sizeof(pldata)); 1534 1561 } 1535 1562 1536 1563 static void i801_add_tco(struct i801_priv *priv) ··· 1666 1697 mutex_init(&priv->acpi_lock); 1667 1698 1668 1699 priv->pci_dev = dev; 1669 - switch (dev->device) { 1670 - case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_H_SMBUS: 1671 - case PCI_DEVICE_ID_INTEL_SUNRISEPOINT_LP_SMBUS: 1672 - case PCI_DEVICE_ID_INTEL_LEWISBURG_SMBUS: 1673 - case PCI_DEVICE_ID_INTEL_LEWISBURG_SSKU_SMBUS: 1674 - case PCI_DEVICE_ID_INTEL_DNV_SMBUS: 1675 - case PCI_DEVICE_ID_INTEL_KABYLAKE_PCH_H_SMBUS: 1676 - case PCI_DEVICE_ID_INTEL_COMETLAKE_V_SMBUS: 1677 - priv->features |= FEATURE_BLOCK_PROC; 1678 - priv->features |= FEATURE_I2C_BLOCK_READ; 1679 - priv->features |= FEATURE_IRQ; 1680 - priv->features |= FEATURE_SMBUS_PEC; 1681 - priv->features |= FEATURE_BLOCK_BUFFER; 1682 - priv->features |= FEATURE_TCO_SPT; 1683 - priv->features |= FEATURE_HOST_NOTIFY; 1684 - break; 1685 - 1686 - case PCI_DEVICE_ID_INTEL_CANNONLAKE_H_SMBUS: 1687 - case PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS: 1688 - case PCI_DEVICE_ID_INTEL_CDF_SMBUS: 1689 - case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: 1690 - case PCI_DEVICE_ID_INTEL_ICELAKE_N_SMBUS: 1691 - case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: 1692 - case PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS: 1693 - case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: 1694 - case PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS: 1695 - case PCI_DEVICE_ID_INTEL_TIGERLAKE_H_SMBUS: 1696 - case PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS: 1697 - case PCI_DEVICE_ID_INTEL_EBG_SMBUS: 1698 - case PCI_DEVICE_ID_INTEL_ALDER_LAKE_S_SMBUS: 1699 - case PCI_DEVICE_ID_INTEL_ALDER_LAKE_P_SMBUS: 1700 - case PCI_DEVICE_ID_INTEL_ALDER_LAKE_M_SMBUS: 1701 - priv->features |= FEATURE_BLOCK_PROC; 1702 - priv->features |= FEATURE_I2C_BLOCK_READ; 1703 - priv->features |= FEATURE_IRQ; 1704 - priv->features |= FEATURE_SMBUS_PEC; 1705 - priv->features |= FEATURE_BLOCK_BUFFER; 1706 - priv->features |= FEATURE_TCO_CNL; 1707 - priv->features |= FEATURE_HOST_NOTIFY; 1708 - break; 1709 - 1710 - case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF0: 1711 - case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF1: 1712 - case PCI_DEVICE_ID_INTEL_PATSBURG_SMBUS_IDF2: 1713 - case PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS0: 1714 - case PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS1: 1715 - case PCI_DEVICE_ID_INTEL_WELLSBURG_SMBUS_MS2: 1716 - priv->features |= FEATURE_IDF; 1717 - fallthrough; 1718 - default: 1719 - priv->features |= FEATURE_BLOCK_PROC; 1720 - priv->features |= FEATURE_I2C_BLOCK_READ; 1721 - priv->features |= FEATURE_IRQ; 1722 - fallthrough; 1723 - case PCI_DEVICE_ID_INTEL_82801DB_3: 1724 - priv->features |= FEATURE_SMBUS_PEC; 1725 - priv->features |= FEATURE_BLOCK_BUFFER; 1726 - fallthrough; 1727 - case PCI_DEVICE_ID_INTEL_82801CA_3: 1728 - priv->features |= FEATURE_HOST_NOTIFY; 1729 - fallthrough; 1730 - case PCI_DEVICE_ID_INTEL_82801BA_2: 1731 - case PCI_DEVICE_ID_INTEL_82801AB_3: 1732 - case PCI_DEVICE_ID_INTEL_82801AA_3: 1733 - break; 1734 - } 1700 + priv->features = id->driver_data; 1735 1701 1736 1702 /* Disable features on user request */ 1737 1703 for (i = 0; i < ARRAY_SIZE(i801_feature_names); i++) {
+73 -19
drivers/i2c/busses/i2c-imx.c
··· 37 37 #include <linux/io.h> 38 38 #include <linux/iopoll.h> 39 39 #include <linux/kernel.h> 40 + #include <linux/spinlock.h> 41 + #include <linux/hrtimer.h> 40 42 #include <linux/module.h> 41 43 #include <linux/of.h> 42 44 #include <linux/of_device.h> ··· 52 50 53 51 /* This will be the driver name the kernel reports */ 54 52 #define DRIVER_NAME "imx-i2c" 53 + 54 + #define I2C_IMX_CHECK_DELAY 30000 /* Time to check for bus idle, in NS */ 55 55 56 56 /* 57 57 * Enable DMA if transfer byte size is bigger than this threshold. ··· 214 210 struct imx_i2c_dma *dma; 215 211 struct i2c_client *slave; 216 212 enum i2c_slave_event last_slave_event; 213 + 214 + /* For checking slave events. */ 215 + spinlock_t slave_lock; 216 + struct hrtimer slave_timer; 217 217 }; 218 218 219 219 static const struct imx_i2c_hwdata imx1_i2c_hwdata = { ··· 688 680 689 681 static void i2c_imx_slave_finish_op(struct imx_i2c_struct *i2c_imx) 690 682 { 691 - u8 val; 683 + u8 val = 0; 692 684 693 685 while (i2c_imx->last_slave_event != I2C_SLAVE_STOP) { 694 686 switch (i2c_imx->last_slave_event) { ··· 709 701 } 710 702 } 711 703 712 - static irqreturn_t i2c_imx_slave_isr(struct imx_i2c_struct *i2c_imx, 713 - unsigned int status, unsigned int ctl) 704 + /* Returns true if the timer should be restarted, false if not. */ 705 + static irqreturn_t i2c_imx_slave_handle(struct imx_i2c_struct *i2c_imx, 706 + unsigned int status, unsigned int ctl) 714 707 { 715 - u8 value; 708 + u8 value = 0; 716 709 717 710 if (status & I2SR_IAL) { /* Arbitration lost */ 718 711 i2c_imx_clear_irq(i2c_imx, I2SR_IAL); 719 712 if (!(status & I2SR_IAAS)) 720 713 return IRQ_HANDLED; 721 714 } 715 + 716 + if (!(status & I2SR_IBB)) { 717 + /* No master on the bus, that could mean a stop condition. */ 718 + i2c_imx_slave_finish_op(i2c_imx); 719 + return IRQ_HANDLED; 720 + } 721 + 722 + if (!(status & I2SR_ICF)) 723 + /* Data transfer still in progress, ignore this. */ 724 + goto out; 722 725 723 726 if (status & I2SR_IAAS) { /* Addressed as a slave */ 724 727 i2c_imx_slave_finish_op(i2c_imx); ··· 756 737 imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); 757 738 } 758 739 } else if (!(ctl & I2CR_MTX)) { /* Receive mode */ 759 - if (status & I2SR_IBB) { /* No STOP signal detected */ 760 - value = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); 761 - i2c_imx_slave_event(i2c_imx, 762 - I2C_SLAVE_WRITE_RECEIVED, &value); 763 - } else { /* STOP signal is detected */ 764 - dev_dbg(&i2c_imx->adapter.dev, 765 - "STOP signal detected"); 766 - i2c_imx_slave_event(i2c_imx, 767 - I2C_SLAVE_STOP, &value); 768 - } 740 + value = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); 741 + i2c_imx_slave_event(i2c_imx, 742 + I2C_SLAVE_WRITE_RECEIVED, &value); 769 743 } else if (!(status & I2SR_RXAK)) { /* Transmit mode received ACK */ 770 744 ctl |= I2CR_MTX; 771 745 imx_i2c_write_reg(ctl, i2c_imx, IMX_I2C_I2CR); ··· 767 755 I2C_SLAVE_READ_PROCESSED, &value); 768 756 769 757 imx_i2c_write_reg(value, i2c_imx, IMX_I2C_I2DR); 770 - } else { /* Transmit mode received NAK */ 758 + } else { /* Transmit mode received NAK, operation is done */ 771 759 ctl &= ~I2CR_MTX; 772 760 imx_i2c_write_reg(ctl, i2c_imx, IMX_I2C_I2CR); 773 761 imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR); 762 + i2c_imx_slave_finish_op(i2c_imx); 763 + return IRQ_HANDLED; 774 764 } 775 765 766 + out: 767 + /* 768 + * No need to check the return value here. If it returns 0 or 769 + * 1, then everything is fine. If it returns -1, then the 770 + * timer is running in the handler. This will still work, 771 + * though it may be redone (or already have been done) by the 772 + * timer function. 773 + */ 774 + hrtimer_try_to_cancel(&i2c_imx->slave_timer); 775 + hrtimer_forward_now(&i2c_imx->slave_timer, I2C_IMX_CHECK_DELAY); 776 + hrtimer_restart(&i2c_imx->slave_timer); 776 777 return IRQ_HANDLED; 778 + } 779 + 780 + static enum hrtimer_restart i2c_imx_slave_timeout(struct hrtimer *t) 781 + { 782 + struct imx_i2c_struct *i2c_imx = container_of(t, struct imx_i2c_struct, 783 + slave_timer); 784 + unsigned int ctl, status; 785 + unsigned long flags; 786 + 787 + spin_lock_irqsave(&i2c_imx->slave_lock, flags); 788 + status = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); 789 + ctl = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 790 + i2c_imx_slave_handle(i2c_imx, status, ctl); 791 + spin_unlock_irqrestore(&i2c_imx->slave_lock, flags); 792 + return HRTIMER_NORESTART; 777 793 } 778 794 779 795 static void i2c_imx_slave_init(struct imx_i2c_struct *i2c_imx) ··· 883 843 { 884 844 struct imx_i2c_struct *i2c_imx = dev_id; 885 845 unsigned int ctl, status; 846 + unsigned long flags; 886 847 848 + spin_lock_irqsave(&i2c_imx->slave_lock, flags); 887 849 status = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); 888 850 ctl = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 889 851 ··· 893 851 i2c_imx_clear_irq(i2c_imx, I2SR_IIF); 894 852 if (i2c_imx->slave) { 895 853 if (!(ctl & I2CR_MSTA)) { 896 - return i2c_imx_slave_isr(i2c_imx, status, ctl); 897 - } else if (i2c_imx->last_slave_event != 898 - I2C_SLAVE_STOP) { 899 - i2c_imx_slave_finish_op(i2c_imx); 854 + irqreturn_t ret; 855 + 856 + ret = i2c_imx_slave_handle(i2c_imx, 857 + status, ctl); 858 + spin_unlock_irqrestore(&i2c_imx->slave_lock, 859 + flags); 860 + return ret; 900 861 } 862 + i2c_imx_slave_finish_op(i2c_imx); 901 863 } 864 + spin_unlock_irqrestore(&i2c_imx->slave_lock, flags); 902 865 return i2c_imx_master_isr(i2c_imx, status); 903 866 } 867 + spin_unlock_irqrestore(&i2c_imx->slave_lock, flags); 904 868 905 869 return IRQ_NONE; 906 870 } ··· 1426 1378 if (!i2c_imx) 1427 1379 return -ENOMEM; 1428 1380 1381 + spin_lock_init(&i2c_imx->slave_lock); 1382 + hrtimer_init(&i2c_imx->slave_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 1383 + i2c_imx->slave_timer.function = i2c_imx_slave_timeout; 1384 + 1429 1385 match = device_get_match_data(&pdev->dev); 1430 1386 if (match) 1431 1387 i2c_imx->hwdata = match; ··· 1542 1490 ret = pm_runtime_resume_and_get(&pdev->dev); 1543 1491 if (ret < 0) 1544 1492 return ret; 1493 + 1494 + hrtimer_cancel(&i2c_imx->slave_timer); 1545 1495 1546 1496 /* remove adapter */ 1547 1497 dev_dbg(&i2c_imx->adapter.dev, "adapter removed\n");
+15 -8
drivers/i2c/busses/i2c-mpc.c
··· 119 119 /* Sometimes 9th clock pulse isn't generated, and slave doesn't release 120 120 * the bus, because it wants to send ACK. 121 121 * Following sequence of enabling/disabling and sending start/stop generates 122 - * the 9 pulses, so it's all OK. 122 + * the 9 pulses, each with a START then ending with STOP, so it's all OK. 123 123 */ 124 124 static void mpc_i2c_fixup(struct mpc_i2c *i2c) 125 125 { 126 126 int k; 127 - u32 delay_val = 1000000 / i2c->real_clk + 1; 128 - 129 - if (delay_val < 2) 130 - delay_val = 2; 127 + unsigned long flags; 131 128 132 129 for (k = 9; k; k--) { 133 130 writeccr(i2c, 0); 134 - writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN); 131 + writeb(0, i2c->base + MPC_I2C_SR); /* clear any status bits */ 132 + writeccr(i2c, CCR_MEN | CCR_MSTA); /* START */ 133 + readb(i2c->base + MPC_I2C_DR); /* init xfer */ 134 + udelay(15); /* let it hit the bus */ 135 + local_irq_save(flags); /* should not be delayed further */ 136 + writeccr(i2c, CCR_MEN | CCR_MSTA | CCR_RSTA); /* delay SDA */ 135 137 readb(i2c->base + MPC_I2C_DR); 136 - writeccr(i2c, CCR_MEN); 137 - udelay(delay_val << 1); 138 + if (k != 1) 139 + udelay(5); 140 + local_irq_restore(flags); 138 141 } 142 + writeccr(i2c, CCR_MEN); /* Initiate STOP */ 143 + readb(i2c->base + MPC_I2C_DR); 144 + udelay(15); /* Let STOP propagate */ 145 + writeccr(i2c, 0); 139 146 } 140 147 141 148 static int i2c_mpc_wait_sr(struct mpc_i2c *i2c, int mask)
+9 -17
drivers/i2c/busses/i2c-rcar.c
··· 367 367 rcar_i2c_prepare_msg(priv); 368 368 } 369 369 370 - static void rcar_i2c_dma_unmap(struct rcar_i2c_priv *priv) 370 + static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv, bool terminate) 371 371 { 372 372 struct dma_chan *chan = priv->dma_direction == DMA_FROM_DEVICE 373 373 ? priv->dma_rx : priv->dma_tx; 374 + 375 + /* only allowed from thread context! */ 376 + if (terminate) 377 + dmaengine_terminate_sync(chan); 374 378 375 379 dma_unmap_single(chan->device->dev, sg_dma_address(&priv->sg), 376 380 sg_dma_len(&priv->sg), priv->dma_direction); ··· 390 386 rcar_i2c_write(priv, ICDMAER, 0); 391 387 } 392 388 393 - static void rcar_i2c_cleanup_dma(struct rcar_i2c_priv *priv) 394 - { 395 - if (priv->dma_direction == DMA_NONE) 396 - return; 397 - else if (priv->dma_direction == DMA_FROM_DEVICE) 398 - dmaengine_terminate_all(priv->dma_rx); 399 - else if (priv->dma_direction == DMA_TO_DEVICE) 400 - dmaengine_terminate_all(priv->dma_tx); 401 - 402 - rcar_i2c_dma_unmap(priv); 403 - } 404 - 405 389 static void rcar_i2c_dma_callback(void *data) 406 390 { 407 391 struct rcar_i2c_priv *priv = data; 408 392 409 393 priv->pos += sg_dma_len(&priv->sg); 410 394 411 - rcar_i2c_dma_unmap(priv); 395 + rcar_i2c_cleanup_dma(priv, false); 412 396 } 413 397 414 398 static bool rcar_i2c_dma(struct rcar_i2c_priv *priv) ··· 448 456 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 449 457 if (!txdesc) { 450 458 dev_dbg(dev, "dma prep slave sg failed, using PIO\n"); 451 - rcar_i2c_cleanup_dma(priv); 459 + rcar_i2c_cleanup_dma(priv, false); 452 460 return false; 453 461 } 454 462 ··· 458 466 cookie = dmaengine_submit(txdesc); 459 467 if (dma_submit_error(cookie)) { 460 468 dev_dbg(dev, "submitting dma failed, using PIO\n"); 461 - rcar_i2c_cleanup_dma(priv); 469 + rcar_i2c_cleanup_dma(priv, false); 462 470 return false; 463 471 } 464 472 ··· 838 846 839 847 /* cleanup DMA if it couldn't complete properly due to an error */ 840 848 if (priv->dma_direction != DMA_NONE) 841 - rcar_i2c_cleanup_dma(priv); 849 + rcar_i2c_cleanup_dma(priv, true); 842 850 843 851 if (!time_left) { 844 852 rcar_i2c_init(priv);
+5 -5
drivers/i2c/busses/i2c-riic.c
··· 433 433 } 434 434 435 435 for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { 436 - res = platform_get_resource(pdev, IORESOURCE_IRQ, riic_irqs[i].res_num); 437 - if (!res) 438 - return -ENODEV; 436 + ret = platform_get_irq(pdev, riic_irqs[i].res_num); 437 + if (ret < 0) 438 + return ret; 439 439 440 - ret = devm_request_irq(&pdev->dev, res->start, riic_irqs[i].isr, 441 - 0, riic_irqs[i].name, riic); 440 + ret = devm_request_irq(&pdev->dev, ret, riic_irqs[i].isr, 441 + 0, riic_irqs[i].name, riic); 442 442 if (ret) { 443 443 dev_err(&pdev->dev, "failed to request irq %s\n", riic_irqs[i].name); 444 444 return ret;
+7
drivers/i2c/busses/i2c-rk3x.c
··· 1338 1338 goto err_pclk; 1339 1339 } 1340 1340 1341 + ret = clk_enable(i2c->clk); 1342 + if (ret < 0) { 1343 + dev_err(&pdev->dev, "Can't enable bus clk: %d\n", ret); 1344 + goto err_clk_notifier; 1345 + } 1346 + 1341 1347 clk_rate = clk_get_rate(i2c->clk); 1342 1348 rk3x_i2c_adapt_div(i2c, clk_rate); 1349 + clk_disable(i2c->clk); 1343 1350 1344 1351 ret = i2c_add_adapter(&i2c->adap); 1345 1352 if (ret < 0)
+35 -25
drivers/i2c/busses/i2c-sh_mobile.c
··· 442 442 return IRQ_HANDLED; 443 443 } 444 444 445 - static void sh_mobile_i2c_dma_unmap(struct sh_mobile_i2c_data *pd) 445 + static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd, bool terminate) 446 446 { 447 447 struct dma_chan *chan = pd->dma_direction == DMA_FROM_DEVICE 448 448 ? pd->dma_rx : pd->dma_tx; 449 + 450 + /* only allowed from thread context! */ 451 + if (terminate) 452 + dmaengine_terminate_sync(chan); 449 453 450 454 dma_unmap_single(chan->device->dev, sg_dma_address(&pd->sg), 451 455 pd->msg->len, pd->dma_direction); ··· 457 453 pd->dma_direction = DMA_NONE; 458 454 } 459 455 460 - static void sh_mobile_i2c_cleanup_dma(struct sh_mobile_i2c_data *pd) 461 - { 462 - if (pd->dma_direction == DMA_NONE) 463 - return; 464 - else if (pd->dma_direction == DMA_FROM_DEVICE) 465 - dmaengine_terminate_sync(pd->dma_rx); 466 - else if (pd->dma_direction == DMA_TO_DEVICE) 467 - dmaengine_terminate_sync(pd->dma_tx); 468 - 469 - sh_mobile_i2c_dma_unmap(pd); 470 - } 471 - 472 456 static void sh_mobile_i2c_dma_callback(void *data) 473 457 { 474 458 struct sh_mobile_i2c_data *pd = data; 475 459 476 - sh_mobile_i2c_dma_unmap(pd); 460 + sh_mobile_i2c_cleanup_dma(pd, false); 477 461 pd->pos = pd->msg->len; 478 462 pd->stop_after_dma = true; 479 463 ··· 541 549 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 542 550 if (!txdesc) { 543 551 dev_dbg(pd->dev, "dma prep slave sg failed, using PIO\n"); 544 - sh_mobile_i2c_cleanup_dma(pd); 552 + sh_mobile_i2c_cleanup_dma(pd, false); 545 553 return; 546 554 } 547 555 ··· 551 559 cookie = dmaengine_submit(txdesc); 552 560 if (dma_submit_error(cookie)) { 553 561 dev_dbg(pd->dev, "submitting dma failed, using PIO\n"); 554 - sh_mobile_i2c_cleanup_dma(pd); 562 + sh_mobile_i2c_cleanup_dma(pd, false); 555 563 return; 556 564 } 557 565 ··· 690 698 if (!time_left) { 691 699 dev_err(pd->dev, "Transfer request timed out\n"); 692 700 if (pd->dma_direction != DMA_NONE) 693 - sh_mobile_i2c_cleanup_dma(pd); 701 + sh_mobile_i2c_cleanup_dma(pd, true); 694 702 695 703 err = -ETIMEDOUT; 696 704 break; ··· 830 838 831 839 static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, struct sh_mobile_i2c_data *pd) 832 840 { 833 - struct resource *res; 834 - resource_size_t n; 841 + struct device_node *np = dev_of_node(&dev->dev); 835 842 int k = 0, ret; 836 843 837 - while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { 838 - for (n = res->start; n <= res->end; n++) { 839 - ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, 840 - 0, dev_name(&dev->dev), pd); 844 + if (np) { 845 + int irq; 846 + 847 + while ((irq = platform_get_irq_optional(dev, k)) != -ENXIO) { 848 + if (irq < 0) 849 + return irq; 850 + ret = devm_request_irq(&dev->dev, irq, sh_mobile_i2c_isr, 851 + 0, dev_name(&dev->dev), pd); 841 852 if (ret) { 842 - dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); 853 + dev_err(&dev->dev, "cannot request IRQ %d\n", irq); 843 854 return ret; 844 855 } 856 + k++; 845 857 } 846 - k++; 858 + } else { 859 + struct resource *res; 860 + resource_size_t n; 861 + 862 + while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { 863 + for (n = res->start; n <= res->end; n++) { 864 + ret = devm_request_irq(&dev->dev, n, sh_mobile_i2c_isr, 865 + 0, dev_name(&dev->dev), pd); 866 + if (ret) { 867 + dev_err(&dev->dev, "cannot request IRQ %pa\n", &n); 868 + return ret; 869 + } 870 + } 871 + k++; 872 + } 847 873 } 848 874 849 875 return k > 0 ? 0 : -ENOENT;
+2 -12
drivers/i2c/busses/i2c-stm32f7.c
··· 828 828 writel_relaxed(cr2, i2c_dev->base + STM32F7_I2C_CR2); 829 829 } 830 830 831 - static int stm32f7_i2c_release_bus(struct i2c_adapter *i2c_adap) 831 + static void stm32f7_i2c_release_bus(struct i2c_adapter *i2c_adap) 832 832 { 833 833 struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap); 834 - 835 - dev_info(i2c_dev->dev, "Trying to recover bus\n"); 836 834 837 835 stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, 838 836 STM32F7_I2C_CR1_PE); 839 837 840 838 stm32f7_i2c_hw_config(i2c_dev); 841 - 842 - return 0; 843 839 } 844 840 845 841 static int stm32f7_i2c_wait_free_bus(struct stm32f7_i2c_dev *i2c_dev) ··· 850 854 if (!ret) 851 855 return 0; 852 856 853 - dev_info(i2c_dev->dev, "bus busy\n"); 854 - 855 - ret = stm32f7_i2c_release_bus(&i2c_dev->adap); 856 - if (ret) { 857 - dev_err(i2c_dev->dev, "Failed to recover the bus (%d)\n", ret); 858 - return ret; 859 - } 857 + stm32f7_i2c_release_bus(&i2c_dev->adap); 860 858 861 859 return -EBUSY; 862 860 }
+47 -22
drivers/i2c/busses/i2c-tegra.c
··· 6 6 * Author: Colin Cross <ccross@android.com> 7 7 */ 8 8 9 + #include <linux/acpi.h> 9 10 #include <linux/bitfield.h> 10 11 #include <linux/clk.h> 11 12 #include <linux/delay.h> ··· 246 245 * @msg_buf: pointer to current message data 247 246 * @msg_buf_remaining: size of unsent data in the message buffer 248 247 * @msg_read: indicates that the transfer is a read access 249 - * @bus_clk_rate: current I2C bus clock rate 248 + * @timings: i2c timings information like bus frequency 250 249 * @multimaster_mode: indicates that I2C controller is in multi-master mode 251 250 * @tx_dma_chan: DMA transmit channel 252 251 * @rx_dma_chan: DMA receive channel ··· 273 272 unsigned int nclocks; 274 273 275 274 struct clk *div_clk; 276 - u32 bus_clk_rate; 275 + struct i2c_timings timings; 277 276 278 277 struct completion msg_complete; 279 278 size_t msg_buf_remaining; ··· 609 608 static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev) 610 609 { 611 610 u32 val, clk_divisor, clk_multiplier, tsu_thd, tlow, thigh, non_hs_mode; 611 + acpi_handle handle = ACPI_HANDLE(i2c_dev->dev); 612 + struct i2c_timings *t = &i2c_dev->timings; 612 613 int err; 613 614 614 615 /* ··· 621 618 * emit a noisy warning on error, which won't stay unnoticed and 622 619 * won't hose machine entirely. 623 620 */ 624 - err = reset_control_reset(i2c_dev->rst); 621 + if (handle) 622 + err = acpi_evaluate_object(handle, "_RST", NULL, NULL); 623 + else 624 + err = reset_control_reset(i2c_dev->rst); 625 + 625 626 WARN_ON_ONCE(err); 626 627 627 628 if (i2c_dev->is_dvc) ··· 643 636 if (i2c_dev->is_vi) 644 637 tegra_i2c_vi_init(i2c_dev); 645 638 646 - switch (i2c_dev->bus_clk_rate) { 639 + switch (t->bus_freq_hz) { 647 640 case I2C_MAX_STANDARD_MODE_FREQ + 1 ... I2C_MAX_FAST_MODE_PLUS_FREQ: 648 641 default: 649 642 tlow = i2c_dev->hw->tlow_fast_fastplus_mode; 650 643 thigh = i2c_dev->hw->thigh_fast_fastplus_mode; 651 644 tsu_thd = i2c_dev->hw->setup_hold_time_fast_fast_plus_mode; 652 645 653 - if (i2c_dev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ) 646 + if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) 654 647 non_hs_mode = i2c_dev->hw->clk_divisor_fast_plus_mode; 655 648 else 656 649 non_hs_mode = i2c_dev->hw->clk_divisor_fast_mode; ··· 686 679 clk_multiplier = (tlow + thigh + 2) * (non_hs_mode + 1); 687 680 688 681 err = clk_set_rate(i2c_dev->div_clk, 689 - i2c_dev->bus_clk_rate * clk_multiplier); 682 + t->bus_freq_hz * clk_multiplier); 690 683 if (err) { 691 684 dev_err(i2c_dev->dev, "failed to set div-clk rate: %d\n", err); 692 685 return err; ··· 725 718 * before disabling the controller so that the STOP condition has 726 719 * been delivered properly. 727 720 */ 728 - udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate)); 721 + udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->timings.bus_freq_hz)); 729 722 730 723 cnfg = i2c_readl(i2c_dev, I2C_CNFG); 731 724 if (cnfg & I2C_CNFG_PACKET_MODE_EN) ··· 1255 1248 * Total bits = 9 bits per byte (including ACK bit) + Start & stop bits 1256 1249 */ 1257 1250 xfer_time += DIV_ROUND_CLOSEST(((xfer_size * 9) + 2) * MSEC_PER_SEC, 1258 - i2c_dev->bus_clk_rate); 1251 + i2c_dev->timings.bus_freq_hz); 1259 1252 1260 1253 int_mask = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST; 1261 1254 tegra_i2c_unmask_irq(i2c_dev, int_mask); ··· 1632 1625 { 1633 1626 struct device_node *np = i2c_dev->dev->of_node; 1634 1627 bool multi_mode; 1635 - int err; 1636 1628 1637 - err = of_property_read_u32(np, "clock-frequency", 1638 - &i2c_dev->bus_clk_rate); 1639 - if (err) 1640 - i2c_dev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; 1629 + i2c_parse_fw_timings(i2c_dev->dev, &i2c_dev->timings, true); 1641 1630 1642 - multi_mode = of_property_read_bool(np, "multi-master"); 1631 + multi_mode = device_property_read_bool(i2c_dev->dev, "multi-master"); 1643 1632 i2c_dev->multimaster_mode = multi_mode; 1644 1633 1645 1634 if (of_device_is_compatible(np, "nvidia,tegra20-i2c-dvc")) ··· 1645 1642 i2c_dev->is_vi = true; 1646 1643 } 1647 1644 1645 + static int tegra_i2c_init_reset(struct tegra_i2c_dev *i2c_dev) 1646 + { 1647 + if (ACPI_HANDLE(i2c_dev->dev)) 1648 + return 0; 1649 + 1650 + i2c_dev->rst = devm_reset_control_get_exclusive(i2c_dev->dev, "i2c"); 1651 + if (IS_ERR(i2c_dev->rst)) 1652 + return dev_err_probe(i2c_dev->dev, PTR_ERR(i2c_dev->rst), 1653 + "failed to get reset control\n"); 1654 + 1655 + return 0; 1656 + } 1657 + 1648 1658 static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev) 1649 1659 { 1650 1660 int err; 1661 + 1662 + if (ACPI_HANDLE(i2c_dev->dev)) 1663 + return 0; 1651 1664 1652 1665 i2c_dev->clocks[i2c_dev->nclocks++].id = "div-clk"; 1653 1666 ··· 1739 1720 init_completion(&i2c_dev->msg_complete); 1740 1721 init_completion(&i2c_dev->dma_complete); 1741 1722 1742 - i2c_dev->hw = of_device_get_match_data(&pdev->dev); 1723 + i2c_dev->hw = device_get_match_data(&pdev->dev); 1743 1724 i2c_dev->cont_id = pdev->id; 1744 1725 i2c_dev->dev = &pdev->dev; 1745 1726 ··· 1765 1746 if (err) 1766 1747 return err; 1767 1748 1768 - i2c_dev->rst = devm_reset_control_get_exclusive(i2c_dev->dev, "i2c"); 1769 - if (IS_ERR(i2c_dev->rst)) { 1770 - dev_err_probe(i2c_dev->dev, PTR_ERR(i2c_dev->rst), 1771 - "failed to get reset control\n"); 1772 - return PTR_ERR(i2c_dev->rst); 1773 - } 1774 - 1775 1749 tegra_i2c_parse_dt(i2c_dev); 1750 + 1751 + err = tegra_i2c_init_reset(i2c_dev); 1752 + if (err) 1753 + return err; 1776 1754 1777 1755 err = tegra_i2c_init_clocks(i2c_dev); 1778 1756 if (err) ··· 1939 1923 NULL) 1940 1924 }; 1941 1925 1926 + static const struct acpi_device_id tegra_i2c_acpi_match[] = { 1927 + {.id = "NVDA0101", .driver_data = (kernel_ulong_t)&tegra210_i2c_hw}, 1928 + {.id = "NVDA0201", .driver_data = (kernel_ulong_t)&tegra186_i2c_hw}, 1929 + {.id = "NVDA0301", .driver_data = (kernel_ulong_t)&tegra194_i2c_hw}, 1930 + { } 1931 + }; 1932 + MODULE_DEVICE_TABLE(acpi, tegra_i2c_acpi_match); 1933 + 1942 1934 static struct platform_driver tegra_i2c_driver = { 1943 1935 .probe = tegra_i2c_probe, 1944 1936 .remove = tegra_i2c_remove, 1945 1937 .driver = { 1946 1938 .name = "tegra-i2c", 1947 1939 .of_match_table = tegra_i2c_of_match, 1940 + .acpi_match_table = tegra_i2c_acpi_match, 1948 1941 .pm = &tegra_i2c_pm, 1949 1942 }, 1950 1943 };
-7
drivers/i2c/busses/i2c-xlp9xx.c
··· 572 572 return 0; 573 573 } 574 574 575 - static const struct of_device_id xlp9xx_i2c_of_match[] = { 576 - { .compatible = "netlogic,xlp980-i2c", }, 577 - { /* sentinel */ }, 578 - }; 579 - MODULE_DEVICE_TABLE(of, xlp9xx_i2c_of_match); 580 - 581 575 #ifdef CONFIG_ACPI 582 576 static const struct acpi_device_id xlp9xx_i2c_acpi_ids[] = { 583 577 {"BRCM9007", 0}, ··· 586 592 .remove = xlp9xx_i2c_remove, 587 593 .driver = { 588 594 .name = "xlp9xx-i2c", 589 - .of_match_table = xlp9xx_i2c_of_match, 590 595 .acpi_match_table = ACPI_PTR(xlp9xx_i2c_acpi_ids), 591 596 }, 592 597 };
-470
drivers/i2c/busses/i2c-xlr.c
··· 1 - /* 2 - * Copyright 2011, Netlogic Microsystems Inc. 3 - * Copyright 2004, Matt Porter <mporter@kernel.crashing.org> 4 - * 5 - * This file is licensed under the terms of the GNU General Public 6 - * License version 2. This program is licensed "as is" without any 7 - * warranty of any kind, whether express or implied. 8 - */ 9 - 10 - #include <linux/err.h> 11 - #include <linux/kernel.h> 12 - #include <linux/module.h> 13 - #include <linux/slab.h> 14 - #include <linux/ioport.h> 15 - #include <linux/delay.h> 16 - #include <linux/errno.h> 17 - #include <linux/i2c.h> 18 - #include <linux/io.h> 19 - #include <linux/platform_device.h> 20 - #include <linux/of_device.h> 21 - #include <linux/clk.h> 22 - #include <linux/interrupt.h> 23 - #include <linux/wait.h> 24 - 25 - /* XLR I2C REGISTERS */ 26 - #define XLR_I2C_CFG 0x00 27 - #define XLR_I2C_CLKDIV 0x01 28 - #define XLR_I2C_DEVADDR 0x02 29 - #define XLR_I2C_ADDR 0x03 30 - #define XLR_I2C_DATAOUT 0x04 31 - #define XLR_I2C_DATAIN 0x05 32 - #define XLR_I2C_STATUS 0x06 33 - #define XLR_I2C_STARTXFR 0x07 34 - #define XLR_I2C_BYTECNT 0x08 35 - #define XLR_I2C_HDSTATIM 0x09 36 - 37 - /* Sigma Designs additional registers */ 38 - #define XLR_I2C_INT_EN 0x09 39 - #define XLR_I2C_INT_STAT 0x0a 40 - 41 - /* XLR I2C REGISTERS FLAGS */ 42 - #define XLR_I2C_BUS_BUSY 0x01 43 - #define XLR_I2C_SDOEMPTY 0x02 44 - #define XLR_I2C_RXRDY 0x04 45 - #define XLR_I2C_ACK_ERR 0x08 46 - #define XLR_I2C_ARB_STARTERR 0x30 47 - 48 - /* Register Values */ 49 - #define XLR_I2C_CFG_ADDR 0xF8 50 - #define XLR_I2C_CFG_NOADDR 0xFA 51 - #define XLR_I2C_STARTXFR_ND 0x02 /* No Data */ 52 - #define XLR_I2C_STARTXFR_RD 0x01 /* Read */ 53 - #define XLR_I2C_STARTXFR_WR 0x00 /* Write */ 54 - 55 - #define XLR_I2C_TIMEOUT 10 /* timeout per byte in msec */ 56 - 57 - /* 58 - * On XLR/XLS, we need to use __raw_ IO to read the I2C registers 59 - * because they are in the big-endian MMIO area on the SoC. 60 - * 61 - * The readl/writel implementation on XLR/XLS byteswaps, because 62 - * those are for its little-endian PCI space (see arch/mips/Kconfig). 63 - */ 64 - static inline void xlr_i2c_wreg(u32 __iomem *base, unsigned int reg, u32 val) 65 - { 66 - __raw_writel(val, base + reg); 67 - } 68 - 69 - static inline u32 xlr_i2c_rdreg(u32 __iomem *base, unsigned int reg) 70 - { 71 - return __raw_readl(base + reg); 72 - } 73 - 74 - #define XLR_I2C_FLAG_IRQ 1 75 - 76 - struct xlr_i2c_config { 77 - u32 flags; /* optional feature support */ 78 - u32 status_busy; /* value of STATUS[0] when busy */ 79 - u32 cfg_extra; /* extra CFG bits to set */ 80 - }; 81 - 82 - struct xlr_i2c_private { 83 - struct i2c_adapter adap; 84 - u32 __iomem *iobase; 85 - int irq; 86 - int pos; 87 - struct i2c_msg *msg; 88 - const struct xlr_i2c_config *cfg; 89 - wait_queue_head_t wait; 90 - struct clk *clk; 91 - }; 92 - 93 - static int xlr_i2c_busy(struct xlr_i2c_private *priv, u32 status) 94 - { 95 - return (status & XLR_I2C_BUS_BUSY) == priv->cfg->status_busy; 96 - } 97 - 98 - static int xlr_i2c_idle(struct xlr_i2c_private *priv) 99 - { 100 - return !xlr_i2c_busy(priv, xlr_i2c_rdreg(priv->iobase, XLR_I2C_STATUS)); 101 - } 102 - 103 - static int xlr_i2c_wait(struct xlr_i2c_private *priv, unsigned long timeout) 104 - { 105 - int status; 106 - int t; 107 - 108 - t = wait_event_timeout(priv->wait, xlr_i2c_idle(priv), 109 - msecs_to_jiffies(timeout)); 110 - if (!t) 111 - return -ETIMEDOUT; 112 - 113 - status = xlr_i2c_rdreg(priv->iobase, XLR_I2C_STATUS); 114 - 115 - return status & XLR_I2C_ACK_ERR ? -EIO : 0; 116 - } 117 - 118 - static void xlr_i2c_tx_irq(struct xlr_i2c_private *priv, u32 status) 119 - { 120 - struct i2c_msg *msg = priv->msg; 121 - 122 - if (status & XLR_I2C_SDOEMPTY) 123 - xlr_i2c_wreg(priv->iobase, XLR_I2C_DATAOUT, 124 - msg->buf[priv->pos++]); 125 - } 126 - 127 - static void xlr_i2c_rx_irq(struct xlr_i2c_private *priv, u32 status) 128 - { 129 - struct i2c_msg *msg = priv->msg; 130 - 131 - if (status & XLR_I2C_RXRDY) 132 - msg->buf[priv->pos++] = 133 - xlr_i2c_rdreg(priv->iobase, XLR_I2C_DATAIN); 134 - } 135 - 136 - static irqreturn_t xlr_i2c_irq(int irq, void *dev_id) 137 - { 138 - struct xlr_i2c_private *priv = dev_id; 139 - struct i2c_msg *msg = priv->msg; 140 - u32 int_stat, status; 141 - 142 - int_stat = xlr_i2c_rdreg(priv->iobase, XLR_I2C_INT_STAT); 143 - if (!int_stat) 144 - return IRQ_NONE; 145 - 146 - xlr_i2c_wreg(priv->iobase, XLR_I2C_INT_STAT, int_stat); 147 - 148 - if (!msg) 149 - return IRQ_HANDLED; 150 - 151 - status = xlr_i2c_rdreg(priv->iobase, XLR_I2C_STATUS); 152 - 153 - if (priv->pos < msg->len) { 154 - if (msg->flags & I2C_M_RD) 155 - xlr_i2c_rx_irq(priv, status); 156 - else 157 - xlr_i2c_tx_irq(priv, status); 158 - } 159 - 160 - if (!xlr_i2c_busy(priv, status)) 161 - wake_up(&priv->wait); 162 - 163 - return IRQ_HANDLED; 164 - } 165 - 166 - static int xlr_i2c_tx(struct xlr_i2c_private *priv, u16 len, 167 - u8 *buf, u16 addr) 168 - { 169 - struct i2c_adapter *adap = &priv->adap; 170 - unsigned long timeout, stoptime, checktime; 171 - u32 i2c_status; 172 - int pos, timedout; 173 - u8 offset; 174 - u32 xfer; 175 - 176 - offset = buf[0]; 177 - xlr_i2c_wreg(priv->iobase, XLR_I2C_ADDR, offset); 178 - xlr_i2c_wreg(priv->iobase, XLR_I2C_DEVADDR, addr); 179 - xlr_i2c_wreg(priv->iobase, XLR_I2C_CFG, 180 - XLR_I2C_CFG_ADDR | priv->cfg->cfg_extra); 181 - 182 - timeout = msecs_to_jiffies(XLR_I2C_TIMEOUT); 183 - stoptime = jiffies + timeout; 184 - timedout = 0; 185 - 186 - if (len == 1) { 187 - xlr_i2c_wreg(priv->iobase, XLR_I2C_BYTECNT, len - 1); 188 - xfer = XLR_I2C_STARTXFR_ND; 189 - pos = 1; 190 - } else { 191 - xlr_i2c_wreg(priv->iobase, XLR_I2C_BYTECNT, len - 2); 192 - xlr_i2c_wreg(priv->iobase, XLR_I2C_DATAOUT, buf[1]); 193 - xfer = XLR_I2C_STARTXFR_WR; 194 - pos = 2; 195 - } 196 - 197 - priv->pos = pos; 198 - 199 - retry: 200 - /* retry can only happen on the first byte */ 201 - xlr_i2c_wreg(priv->iobase, XLR_I2C_STARTXFR, xfer); 202 - 203 - if (priv->irq > 0) 204 - return xlr_i2c_wait(priv, XLR_I2C_TIMEOUT * len); 205 - 206 - while (!timedout) { 207 - checktime = jiffies; 208 - i2c_status = xlr_i2c_rdreg(priv->iobase, XLR_I2C_STATUS); 209 - 210 - if ((i2c_status & XLR_I2C_SDOEMPTY) && pos < len) { 211 - xlr_i2c_wreg(priv->iobase, XLR_I2C_DATAOUT, buf[pos++]); 212 - 213 - /* reset timeout on successful xmit */ 214 - stoptime = jiffies + timeout; 215 - } 216 - timedout = time_after(checktime, stoptime); 217 - 218 - if (i2c_status & XLR_I2C_ARB_STARTERR) { 219 - if (timedout) 220 - break; 221 - goto retry; 222 - } 223 - 224 - if (i2c_status & XLR_I2C_ACK_ERR) 225 - return -EIO; 226 - 227 - if (!xlr_i2c_busy(priv, i2c_status) && pos >= len) 228 - return 0; 229 - } 230 - dev_err(&adap->dev, "I2C transmit timeout\n"); 231 - return -ETIMEDOUT; 232 - } 233 - 234 - static int xlr_i2c_rx(struct xlr_i2c_private *priv, u16 len, u8 *buf, u16 addr) 235 - { 236 - struct i2c_adapter *adap = &priv->adap; 237 - u32 i2c_status; 238 - unsigned long timeout, stoptime, checktime; 239 - int nbytes, timedout; 240 - 241 - xlr_i2c_wreg(priv->iobase, XLR_I2C_CFG, 242 - XLR_I2C_CFG_NOADDR | priv->cfg->cfg_extra); 243 - xlr_i2c_wreg(priv->iobase, XLR_I2C_BYTECNT, len - 1); 244 - xlr_i2c_wreg(priv->iobase, XLR_I2C_DEVADDR, addr); 245 - 246 - priv->pos = 0; 247 - 248 - timeout = msecs_to_jiffies(XLR_I2C_TIMEOUT); 249 - stoptime = jiffies + timeout; 250 - timedout = 0; 251 - nbytes = 0; 252 - retry: 253 - xlr_i2c_wreg(priv->iobase, XLR_I2C_STARTXFR, XLR_I2C_STARTXFR_RD); 254 - 255 - if (priv->irq > 0) 256 - return xlr_i2c_wait(priv, XLR_I2C_TIMEOUT * len); 257 - 258 - while (!timedout) { 259 - checktime = jiffies; 260 - i2c_status = xlr_i2c_rdreg(priv->iobase, XLR_I2C_STATUS); 261 - if (i2c_status & XLR_I2C_RXRDY) { 262 - if (nbytes >= len) 263 - return -EIO; /* should not happen */ 264 - 265 - buf[nbytes++] = 266 - xlr_i2c_rdreg(priv->iobase, XLR_I2C_DATAIN); 267 - 268 - /* reset timeout on successful read */ 269 - stoptime = jiffies + timeout; 270 - } 271 - 272 - timedout = time_after(checktime, stoptime); 273 - if (i2c_status & XLR_I2C_ARB_STARTERR) { 274 - if (timedout) 275 - break; 276 - goto retry; 277 - } 278 - 279 - if (i2c_status & XLR_I2C_ACK_ERR) 280 - return -EIO; 281 - 282 - if (!xlr_i2c_busy(priv, i2c_status)) 283 - return 0; 284 - } 285 - 286 - dev_err(&adap->dev, "I2C receive timeout\n"); 287 - return -ETIMEDOUT; 288 - } 289 - 290 - static int xlr_i2c_xfer(struct i2c_adapter *adap, 291 - struct i2c_msg *msgs, int num) 292 - { 293 - struct i2c_msg *msg; 294 - int i; 295 - int ret = 0; 296 - struct xlr_i2c_private *priv = i2c_get_adapdata(adap); 297 - 298 - ret = clk_enable(priv->clk); 299 - if (ret) 300 - return ret; 301 - 302 - if (priv->irq) 303 - xlr_i2c_wreg(priv->iobase, XLR_I2C_INT_EN, 0xf); 304 - 305 - 306 - for (i = 0; ret == 0 && i < num; i++) { 307 - msg = &msgs[i]; 308 - priv->msg = msg; 309 - if (msg->flags & I2C_M_RD) 310 - ret = xlr_i2c_rx(priv, msg->len, &msg->buf[0], 311 - msg->addr); 312 - else 313 - ret = xlr_i2c_tx(priv, msg->len, &msg->buf[0], 314 - msg->addr); 315 - } 316 - 317 - if (priv->irq) 318 - xlr_i2c_wreg(priv->iobase, XLR_I2C_INT_EN, 0); 319 - 320 - clk_disable(priv->clk); 321 - priv->msg = NULL; 322 - 323 - return (ret != 0) ? ret : num; 324 - } 325 - 326 - static u32 xlr_func(struct i2c_adapter *adap) 327 - { 328 - /* Emulate SMBUS over I2C */ 329 - return (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK) | I2C_FUNC_I2C; 330 - } 331 - 332 - static const struct i2c_algorithm xlr_i2c_algo = { 333 - .master_xfer = xlr_i2c_xfer, 334 - .functionality = xlr_func, 335 - }; 336 - 337 - static const struct i2c_adapter_quirks xlr_i2c_quirks = { 338 - .flags = I2C_AQ_NO_ZERO_LEN, 339 - }; 340 - 341 - static const struct xlr_i2c_config xlr_i2c_config_default = { 342 - .status_busy = XLR_I2C_BUS_BUSY, 343 - .cfg_extra = 0, 344 - }; 345 - 346 - static const struct xlr_i2c_config xlr_i2c_config_tangox = { 347 - .flags = XLR_I2C_FLAG_IRQ, 348 - .status_busy = 0, 349 - .cfg_extra = 1 << 8, 350 - }; 351 - 352 - static const struct of_device_id xlr_i2c_dt_ids[] = { 353 - { 354 - .compatible = "sigma,smp8642-i2c", 355 - .data = &xlr_i2c_config_tangox, 356 - }, 357 - { } 358 - }; 359 - MODULE_DEVICE_TABLE(of, xlr_i2c_dt_ids); 360 - 361 - static int xlr_i2c_probe(struct platform_device *pdev) 362 - { 363 - const struct of_device_id *match; 364 - struct xlr_i2c_private *priv; 365 - struct clk *clk; 366 - unsigned long clk_rate; 367 - unsigned long clk_div; 368 - u32 busfreq; 369 - int irq; 370 - int ret; 371 - 372 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 373 - if (!priv) 374 - return -ENOMEM; 375 - 376 - match = of_match_device(xlr_i2c_dt_ids, &pdev->dev); 377 - if (match) 378 - priv->cfg = match->data; 379 - else 380 - priv->cfg = &xlr_i2c_config_default; 381 - 382 - priv->iobase = devm_platform_ioremap_resource(pdev, 0); 383 - if (IS_ERR(priv->iobase)) 384 - return PTR_ERR(priv->iobase); 385 - 386 - irq = platform_get_irq(pdev, 0); 387 - 388 - if (irq > 0 && (priv->cfg->flags & XLR_I2C_FLAG_IRQ)) { 389 - priv->irq = irq; 390 - 391 - xlr_i2c_wreg(priv->iobase, XLR_I2C_INT_EN, 0); 392 - xlr_i2c_wreg(priv->iobase, XLR_I2C_INT_STAT, 0xf); 393 - 394 - ret = devm_request_irq(&pdev->dev, priv->irq, xlr_i2c_irq, 395 - IRQF_SHARED, dev_name(&pdev->dev), 396 - priv); 397 - if (ret) 398 - return ret; 399 - 400 - init_waitqueue_head(&priv->wait); 401 - } 402 - 403 - if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", 404 - &busfreq)) 405 - busfreq = I2C_MAX_STANDARD_MODE_FREQ; 406 - 407 - clk = devm_clk_get(&pdev->dev, NULL); 408 - if (!IS_ERR(clk)) { 409 - ret = clk_prepare_enable(clk); 410 - if (ret) 411 - return ret; 412 - 413 - clk_rate = clk_get_rate(clk); 414 - clk_div = DIV_ROUND_UP(clk_rate, 2 * busfreq); 415 - xlr_i2c_wreg(priv->iobase, XLR_I2C_CLKDIV, clk_div); 416 - 417 - clk_disable(clk); 418 - priv->clk = clk; 419 - } 420 - 421 - priv->adap.dev.parent = &pdev->dev; 422 - priv->adap.dev.of_node = pdev->dev.of_node; 423 - priv->adap.owner = THIS_MODULE; 424 - priv->adap.algo_data = priv; 425 - priv->adap.algo = &xlr_i2c_algo; 426 - priv->adap.quirks = &xlr_i2c_quirks; 427 - priv->adap.nr = pdev->id; 428 - priv->adap.class = I2C_CLASS_HWMON; 429 - snprintf(priv->adap.name, sizeof(priv->adap.name), "xlr-i2c"); 430 - 431 - i2c_set_adapdata(&priv->adap, priv); 432 - ret = i2c_add_numbered_adapter(&priv->adap); 433 - if (ret < 0) 434 - goto err_unprepare_clk; 435 - 436 - platform_set_drvdata(pdev, priv); 437 - dev_info(&priv->adap.dev, "Added I2C Bus.\n"); 438 - return 0; 439 - 440 - err_unprepare_clk: 441 - clk_unprepare(clk); 442 - return ret; 443 - } 444 - 445 - static int xlr_i2c_remove(struct platform_device *pdev) 446 - { 447 - struct xlr_i2c_private *priv; 448 - 449 - priv = platform_get_drvdata(pdev); 450 - i2c_del_adapter(&priv->adap); 451 - clk_unprepare(priv->clk); 452 - 453 - return 0; 454 - } 455 - 456 - static struct platform_driver xlr_i2c_driver = { 457 - .probe = xlr_i2c_probe, 458 - .remove = xlr_i2c_remove, 459 - .driver = { 460 - .name = "xlr-i2cbus", 461 - .of_match_table = xlr_i2c_dt_ids, 462 - }, 463 - }; 464 - 465 - module_platform_driver(xlr_i2c_driver); 466 - 467 - MODULE_AUTHOR("Ganesan Ramalingam <ganesanr@netlogicmicro.com>"); 468 - MODULE_DESCRIPTION("XLR/XLS SoC I2C Controller driver"); 469 - MODULE_LICENSE("GPL v2"); 470 - MODULE_ALIAS("platform:xlr-i2cbus");
+2
drivers/i2c/i2c-core-base.c
··· 953 953 client->dev.of_node = of_node_get(info->of_node); 954 954 client->dev.fwnode = info->fwnode; 955 955 956 + device_enable_async_suspend(&client->dev); 956 957 i2c_dev_set_name(adap, client, info); 957 958 958 959 if (info->swnode) { ··· 1483 1482 if (res) 1484 1483 goto out_reg; 1485 1484 1485 + device_enable_async_suspend(&adap->dev); 1486 1486 pm_runtime_no_callbacks(&adap->dev); 1487 1487 pm_suspend_ignore_children(&adap->dev, true); 1488 1488 pm_runtime_enable(&adap->dev);
+8 -45
drivers/i2c/muxes/i2c-mux-gpio.c
··· 7 7 8 8 #include <linux/i2c.h> 9 9 #include <linux/i2c-mux.h> 10 + #include <linux/overflow.h> 10 11 #include <linux/platform_data/i2c-mux-gpio.h> 11 12 #include <linux/platform_device.h> 12 13 #include <linux/module.h> ··· 50 49 return 0; 51 50 } 52 51 53 - #ifdef CONFIG_ACPI 54 - 55 - static int i2c_mux_gpio_get_acpi_adr(struct device *dev, 56 - struct fwnode_handle *fwdev, 57 - unsigned int *adr) 58 - 59 - { 60 - unsigned long long adr64; 61 - acpi_status status; 62 - 63 - status = acpi_evaluate_integer(ACPI_HANDLE_FWNODE(fwdev), 64 - METHOD_NAME__ADR, 65 - NULL, &adr64); 66 - 67 - if (!ACPI_SUCCESS(status)) { 68 - dev_err(dev, "Cannot get address\n"); 69 - return -EINVAL; 70 - } 71 - 72 - *adr = adr64; 73 - if (*adr != adr64) { 74 - dev_err(dev, "Address out of range\n"); 75 - return -ERANGE; 76 - } 77 - 78 - return 0; 79 - } 80 - 81 - #else 82 - 83 - static int i2c_mux_gpio_get_acpi_adr(struct device *dev, 84 - struct fwnode_handle *fwdev, 85 - unsigned int *adr) 86 - { 87 - return -EINVAL; 88 - } 89 - 90 - #endif 91 - 92 52 static int i2c_mux_gpio_probe_fw(struct gpiomux *mux, 93 53 struct platform_device *pdev) 94 54 { 95 55 struct device *dev = &pdev->dev; 56 + struct fwnode_handle *fwnode = dev_fwnode(dev); 96 57 struct device_node *np = dev->of_node; 97 58 struct device_node *adapter_np; 98 59 struct i2c_adapter *adapter = NULL; ··· 62 99 unsigned *values; 63 100 int rc, i = 0; 64 101 65 - if (is_of_node(dev->fwnode)) { 102 + if (is_of_node(fwnode)) { 66 103 if (!np) 67 104 return -ENODEV; 68 105 ··· 74 111 adapter = of_find_i2c_adapter_by_node(adapter_np); 75 112 of_node_put(adapter_np); 76 113 77 - } else if (is_acpi_node(dev->fwnode)) { 114 + } else if (is_acpi_node(fwnode)) { 78 115 /* 79 116 * In ACPI land the mux should be a direct child of the i2c 80 117 * bus it muxes. ··· 104 141 fwnode_property_read_u32(child, "reg", values + i); 105 142 106 143 } else if (is_acpi_node(child)) { 107 - rc = i2c_mux_gpio_get_acpi_adr(dev, child, values + i); 144 + rc = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), values + i); 108 145 if (rc) 109 - return rc; 146 + return dev_err_probe(dev, rc, "Cannot get address\n"); 110 147 } 111 148 112 149 i++; 113 150 } 114 151 mux->data.values = values; 115 152 116 - if (fwnode_property_read_u32(dev->fwnode, "idle-state", &mux->data.idle)) 153 + if (device_property_read_u32(dev, "idle-state", &mux->data.idle)) 117 154 mux->data.idle = I2C_MUX_GPIO_NO_IDLE; 118 155 119 156 return 0; ··· 153 190 return -EPROBE_DEFER; 154 191 155 192 muxc = i2c_mux_alloc(parent, &pdev->dev, mux->data.n_values, 156 - ngpios * sizeof(*mux->gpios), 0, 193 + array_size(ngpios, sizeof(*mux->gpios)), 0, 157 194 i2c_mux_gpio_select, NULL); 158 195 if (!muxc) { 159 196 ret = -ENOMEM;
+32 -36
drivers/misc/eeprom/at24.c
··· 68 68 * which won't work on pure SMBus systems. 69 69 */ 70 70 71 - struct at24_client { 72 - struct i2c_client *client; 73 - struct regmap *regmap; 74 - }; 75 - 76 71 struct at24_data { 77 72 /* 78 73 * Lock protects against activities from other Linux tasks, ··· 89 94 90 95 /* 91 96 * Some chips tie up multiple I2C addresses; dummy devices reserve 92 - * them for us, and we'll use them with SMBus calls. 97 + * them for us. 93 98 */ 94 - struct at24_client client[]; 99 + u8 bank_addr_shift; 100 + struct regmap *client_regmaps[]; 95 101 }; 96 102 97 103 /* ··· 119 123 struct at24_chip_data { 120 124 u32 byte_len; 121 125 u8 flags; 126 + u8 bank_addr_shift; 122 127 void (*read_post)(unsigned int off, char *buf, size_t count); 123 128 }; 124 129 ··· 132 135 static const struct at24_chip_data _name = { \ 133 136 .byte_len = _len, .flags = _flags, \ 134 137 .read_post = _read_post, \ 138 + } 139 + 140 + #define AT24_CHIP_DATA_BS(_name, _len, _flags, _bank_addr_shift) \ 141 + static const struct at24_chip_data _name = { \ 142 + .byte_len = _len, .flags = _flags, \ 143 + .bank_addr_shift = _bank_addr_shift \ 135 144 } 136 145 137 146 static void at24_read_post_vaio(unsigned int off, char *buf, size_t count) ··· 200 197 AT24_CHIP_DATA(at24_data_24c256, 262144 / 8, AT24_FLAG_ADDR16); 201 198 AT24_CHIP_DATA(at24_data_24c512, 524288 / 8, AT24_FLAG_ADDR16); 202 199 AT24_CHIP_DATA(at24_data_24c1024, 1048576 / 8, AT24_FLAG_ADDR16); 200 + AT24_CHIP_DATA_BS(at24_data_24c1025, 1048576 / 8, AT24_FLAG_ADDR16, 2); 203 201 AT24_CHIP_DATA(at24_data_24c2048, 2097152 / 8, AT24_FLAG_ADDR16); 204 202 /* identical to 24c08 ? */ 205 203 AT24_CHIP_DATA(at24_data_INT3499, 8192 / 8, 0); ··· 229 225 { "24c256", (kernel_ulong_t)&at24_data_24c256 }, 230 226 { "24c512", (kernel_ulong_t)&at24_data_24c512 }, 231 227 { "24c1024", (kernel_ulong_t)&at24_data_24c1024 }, 228 + { "24c1025", (kernel_ulong_t)&at24_data_24c1025 }, 232 229 { "24c2048", (kernel_ulong_t)&at24_data_24c2048 }, 233 230 { "at24", 0 }, 234 231 { /* END OF LIST */ } ··· 259 254 { .compatible = "atmel,24c256", .data = &at24_data_24c256 }, 260 255 { .compatible = "atmel,24c512", .data = &at24_data_24c512 }, 261 256 { .compatible = "atmel,24c1024", .data = &at24_data_24c1024 }, 257 + { .compatible = "atmel,24c1025", .data = &at24_data_24c1025 }, 262 258 { .compatible = "atmel,24c2048", .data = &at24_data_24c2048 }, 263 259 { /* END OF LIST */ }, 264 260 }; ··· 281 275 * set the byte address; on a multi-master board, another master 282 276 * may have changed the chip's "current" address pointer. 283 277 */ 284 - static struct at24_client *at24_translate_offset(struct at24_data *at24, 285 - unsigned int *offset) 278 + static struct regmap *at24_translate_offset(struct at24_data *at24, 279 + unsigned int *offset) 286 280 { 287 281 unsigned int i; 288 282 ··· 294 288 *offset &= 0xff; 295 289 } 296 290 297 - return &at24->client[i]; 291 + return at24->client_regmaps[i]; 298 292 } 299 293 300 294 static struct device *at24_base_client_dev(struct at24_data *at24) 301 295 { 302 - return &at24->client[0].client->dev; 296 + return regmap_get_device(at24->client_regmaps[0]); 303 297 } 304 298 305 299 static size_t at24_adjust_read_count(struct at24_data *at24, ··· 330 324 unsigned int offset, size_t count) 331 325 { 332 326 unsigned long timeout, read_time; 333 - struct at24_client *at24_client; 334 - struct i2c_client *client; 335 327 struct regmap *regmap; 336 328 int ret; 337 329 338 - at24_client = at24_translate_offset(at24, &offset); 339 - regmap = at24_client->regmap; 340 - client = at24_client->client; 330 + regmap = at24_translate_offset(at24, &offset); 341 331 count = at24_adjust_read_count(at24, offset, count); 342 332 343 333 /* adjust offset for mac and serial read ops */ ··· 348 346 read_time = jiffies; 349 347 350 348 ret = regmap_bulk_read(regmap, offset, buf, count); 351 - dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", 349 + dev_dbg(regmap_get_device(regmap), "read %zu@%d --> %d (%ld)\n", 352 350 count, offset, ret, jiffies); 353 351 if (!ret) 354 352 return count; ··· 389 387 unsigned int offset, size_t count) 390 388 { 391 389 unsigned long timeout, write_time; 392 - struct at24_client *at24_client; 393 - struct i2c_client *client; 394 390 struct regmap *regmap; 395 391 int ret; 396 392 397 - at24_client = at24_translate_offset(at24, &offset); 398 - regmap = at24_client->regmap; 399 - client = at24_client->client; 393 + regmap = at24_translate_offset(at24, &offset); 400 394 count = at24_adjust_write_count(at24, offset, count); 401 395 timeout = jiffies + msecs_to_jiffies(at24_write_timeout); 402 396 ··· 404 406 write_time = jiffies; 405 407 406 408 ret = regmap_bulk_write(regmap, offset, buf, count); 407 - dev_dbg(&client->dev, "write %zu@%d --> %d (%ld)\n", 409 + dev_dbg(regmap_get_device(regmap), "write %zu@%d --> %d (%ld)\n", 408 410 count, offset, ret, jiffies); 409 411 if (!ret) 410 412 return count; ··· 536 538 } 537 539 538 540 static int at24_make_dummy_client(struct at24_data *at24, unsigned int index, 541 + struct i2c_client *base_client, 539 542 struct regmap_config *regmap_config) 540 543 { 541 - struct i2c_client *base_client, *dummy_client; 544 + struct i2c_client *dummy_client; 542 545 struct regmap *regmap; 543 - struct device *dev; 544 546 545 - base_client = at24->client[0].client; 546 - dev = &base_client->dev; 547 - 548 - dummy_client = devm_i2c_new_dummy_device(dev, base_client->adapter, 549 - base_client->addr + index); 547 + dummy_client = devm_i2c_new_dummy_device(&base_client->dev, 548 + base_client->adapter, 549 + base_client->addr + 550 + (index << at24->bank_addr_shift)); 550 551 if (IS_ERR(dummy_client)) 551 552 return PTR_ERR(dummy_client); 552 553 ··· 553 556 if (IS_ERR(regmap)) 554 557 return PTR_ERR(regmap); 555 558 556 - at24->client[index].client = dummy_client; 557 - at24->client[index].regmap = regmap; 559 + at24->client_regmaps[index] = regmap; 558 560 559 561 return 0; 560 562 } ··· 676 680 if (IS_ERR(regmap)) 677 681 return PTR_ERR(regmap); 678 682 679 - at24 = devm_kzalloc(dev, struct_size(at24, client, num_addresses), 683 + at24 = devm_kzalloc(dev, struct_size(at24, client_regmaps, num_addresses), 680 684 GFP_KERNEL); 681 685 if (!at24) 682 686 return -ENOMEM; ··· 686 690 at24->page_size = page_size; 687 691 at24->flags = flags; 688 692 at24->read_post = cdata->read_post; 693 + at24->bank_addr_shift = cdata->bank_addr_shift; 689 694 at24->num_addresses = num_addresses; 690 695 at24->offset_adj = at24_get_offset_adj(flags, byte_len); 691 - at24->client[0].client = client; 692 - at24->client[0].regmap = regmap; 696 + at24->client_regmaps[0] = regmap; 693 697 694 698 at24->vcc_reg = devm_regulator_get(dev, "vcc"); 695 699 if (IS_ERR(at24->vcc_reg)) ··· 705 709 706 710 /* use dummy devices for multiple-address chips */ 707 711 for (i = 1; i < num_addresses; i++) { 708 - err = at24_make_dummy_client(at24, i, &regmap_config); 712 + err = at24_make_dummy_client(at24, i, client, &regmap_config); 709 713 if (err) 710 714 return err; 711 715 }