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

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

Pull i2c updates from Wolfram Sang:
"I2C has mostly driver updates this time.

The few noteworthy changes are: the core has now support for analog
and digital filters with at91 being the first user, a core addition to
replace the NULL returning i2c_new_probed_device() with an ERR_PTR
variant, and the pxa driver has finally being moved to use the generic
I2C slave interface. We have quite a significant number of reviews per
patch this time, so thank you to all involved!"

* 'i2c/for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (37 commits)
video: fbdev: matrox: convert to i2c_new_scanned_device
i2c: icy: convert to i2c_new_scanned_device
i2c: replace i2c_new_probed_device with an ERR_PTR variant
i2c: Fix Kconfig indentation
i2c: smbus: Don't filter out duplicate alerts
i2c: i801: Correct Intel Jasper Lake SOC naming
i2c: i2c-stm32f7: fix 10-bits check in slave free id search loop
i2c: iproc: Add i2c repeated start capability
i2c: remove helpers for ref-counting clients
i2c: tegra: Use dma_request_chan() directly for channel request
i2c: sh_mobile: Use dma_request_chan() directly for channel request
i2c: qup: Use dma_request_chan() directly for channel request
i2c: at91: Use dma_request_chan() directly for channel request
i2c: rcar: Remove superfluous call to clk_get_rate()
i2c: pxa: remove unused i2c-slave APIs
i2c: pxa: migrate to new i2c_slave APIs
i2c: cros-ec-tunnel: Make the device acpi compatible
i2c: stm32f7: report dma error during probe
i2c: icy: no need to populate address for scanned device
i2c: xiic: Fix kerneldoc warnings
...

+430 -204
+53
Documentation/devicetree/bindings/i2c/amlogic,meson6-i2c.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + # Copyright 2019 BayLibre, SAS 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/i2c/amlogic,meson6-i2c.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Amlogic Meson I2C Controller 9 + 10 + maintainers: 11 + - Neil Armstrong <narmstrong@baylibre.com> 12 + - Beniamino Galvani <b.galvani@gmail.com> 13 + 14 + allOf: 15 + - $ref: /schemas/i2c/i2c-controller.yaml# 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - amlogic,meson6-i2c # Meson6, Meson8 and compatible SoCs 21 + - amlogic,meson-gxbb-i2c # GXBB and compatible SoCs 22 + - amlogic,meson-axg-i2c # AXG and compatible SoCs 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + clocks: 31 + minItems: 1 32 + 33 + required: 34 + - compatible 35 + - reg 36 + - interrupts 37 + - clocks 38 + 39 + examples: 40 + - | 41 + i2c@c8100500 { 42 + compatible = "amlogic,meson6-i2c"; 43 + reg = <0xc8100500 0x20>; 44 + interrupts = <92>; 45 + clocks = <&clk81>; 46 + #address-cells = <1>; 47 + #size-cells = <0>; 48 + 49 + eeprom@52 { 50 + compatible = "atmel,24c32"; 51 + reg = <0x52>; 52 + }; 53 + };
+2 -1
Documentation/devicetree/bindings/i2c/i2c-aspeed.txt
··· 1 - Device tree configuration for the I2C busses on the AST24XX and AST25XX SoCs. 1 + Device tree configuration for the I2C busses on the AST24XX, AST25XX, and AST26XX SoCs. 2 2 3 3 Required Properties: 4 4 - #address-cells : should be 1 ··· 6 6 - reg : address offset and range of bus 7 7 - compatible : should be "aspeed,ast2400-i2c-bus" 8 8 or "aspeed,ast2500-i2c-bus" 9 + or "aspeed,ast2600-i2c-bus" 9 10 - clocks : root clock of bus, should reference the APB 10 11 clock in the second cell 11 12 - resets : phandle to reset controller with the reset number in
+2 -1
Documentation/devicetree/bindings/i2c/i2c-at91.txt
··· 3 3 Required properties : 4 4 - compatible : Must be "atmel,at91rm9200-i2c", "atmel,at91sam9261-i2c", 5 5 "atmel,at91sam9260-i2c", "atmel,at91sam9g20-i2c", "atmel,at91sam9g10-i2c", 6 - "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c" or "atmel,sama5d2-i2c" 6 + "atmel,at91sam9x5-i2c", "atmel,sama5d4-i2c", "atmel,sama5d2-i2c" or 7 + "microchip,sam9x60-i2c" 7 8 - reg: physical base address of the controller and length of memory mapped 8 9 region. 9 10 - interrupts: interrupt number to the cpu.
-30
Documentation/devicetree/bindings/i2c/i2c-meson.txt
··· 1 - Amlogic Meson I2C controller 2 - 3 - Required properties: 4 - - compatible: must be: 5 - "amlogic,meson6-i2c" for Meson8 and compatible SoCs 6 - "amlogic,meson-gxbb-i2c" for GXBB and compatible SoCs 7 - "amlogic,meson-axg-i2c"for AXG and compatible SoCs 8 - 9 - - reg: physical address and length of the device registers 10 - - interrupts: a single interrupt specifier 11 - - clocks: clock for the device 12 - - #address-cells: should be <1> 13 - - #size-cells: should be <0> 14 - 15 - For details regarding the following core I2C bindings see also i2c.txt. 16 - 17 - Optional properties: 18 - - clock-frequency: the desired I2C bus clock frequency in Hz; in 19 - absence of this property the default value is used (100 kHz). 20 - 21 - Examples: 22 - 23 - i2c@c8100500 { 24 - compatible = "amlogic,meson6-i2c"; 25 - reg = <0xc8100500 0x20>; 26 - interrupts = <0 92 1>; 27 - clocks = <&clk81>; 28 - #address-cells = <1>; 29 - #size-cells = <0>; 30 - };
+18
Documentation/devicetree/bindings/i2c/i2c.txt
··· 55 55 Number of nanoseconds the SDA signal takes to fall; t(f) in the I2C 56 56 specification. 57 57 58 + - i2c-analog-filter 59 + Enable analog filter for i2c lines. 60 + 61 + - i2c-digital-filter 62 + Enable digital filter for i2c lines. 63 + 64 + - i2c-digital-filter-width-ns 65 + Width of spikes which can be filtered by digital filter 66 + (i2c-digital-filter). This width is specified in nanoseconds. 67 + 68 + - i2c-analog-filter-cutoff-frequency 69 + Frequency that the analog filter (i2c-analog-filter) uses to distinguish 70 + which signal to filter. Signal with higher frequency than specified will 71 + be filtered out. Only lower frequency will pass (this is applicable to 72 + a low-pass analog filter). Typical value should be above the normal 73 + i2c bus clock frequency (clock-frequency). 74 + Specified in Hz. 75 + 58 76 - interrupts 59 77 interrupts used by the device. 60 78
+1
Documentation/devicetree/bindings/i2c/renesas,i2c.txt
··· 7 7 "renesas,i2c-r8a7745" if the device is a part of a R8A7745 SoC. 8 8 "renesas,i2c-r8a77470" if the device is a part of a R8A77470 SoC. 9 9 "renesas,i2c-r8a774a1" if the device is a part of a R8A774A1 SoC. 10 + "renesas,i2c-r8a774b1" if the device is a part of a R8A774B1 SoC. 10 11 "renesas,i2c-r8a774c0" if the device is a part of a R8A774C0 SoC. 11 12 "renesas,i2c-r8a7778" if the device is a part of a R8A7778 SoC. 12 13 "renesas,i2c-r8a7779" if the device is a part of a R8A7779 SoC.
+1
Documentation/devicetree/bindings/i2c/renesas,iic.txt
··· 8 8 - "renesas,iic-r8a7744" (RZ/G1N) 9 9 - "renesas,iic-r8a7745" (RZ/G1E) 10 10 - "renesas,iic-r8a774a1" (RZ/G2M) 11 + - "renesas,iic-r8a774b1" (RZ/G2N) 11 12 - "renesas,iic-r8a774c0" (RZ/G2E) 12 13 - "renesas,iic-r8a7790" (R-Car H2) 13 14 - "renesas,iic-r8a7791" (R-Car M2-W)
+1
Documentation/i2c/busses/i2c-i801.rst
··· 42 42 * Intel Comet Lake (PCH) 43 43 * Intel Elkhart Lake (PCH) 44 44 * Intel Tiger Lake (PCH) 45 + * Intel Jasper Lake (SOC) 45 46 46 47 Datasheets: Publicly available at the Intel website 47 48
+5 -5
Documentation/i2c/instantiating-devices.rst
··· 123 123 on cheap variants of a board but you have no way to tell them apart), or 124 124 it may have different addresses from one board to the next (manufacturer 125 125 changing its design without notice). In this case, you can call 126 - i2c_new_probed_device() instead of i2c_new_device(). 126 + i2c_new_scanned_device() instead of i2c_new_device(). 127 127 128 128 Example (from the nxp OHCI driver):: 129 129 ··· 139 139 i2c_adap = i2c_get_adapter(2); 140 140 memset(&i2c_info, 0, sizeof(struct i2c_board_info)); 141 141 strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type)); 142 - isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, 143 - normal_i2c, NULL); 142 + isp1301_i2c_client = i2c_new_scanned_device(i2c_adap, &i2c_info, 143 + normal_i2c, NULL); 144 144 i2c_put_adapter(i2c_adap); 145 145 (...) 146 146 } ··· 153 153 The driver which instantiated the I2C device is responsible for destroying 154 154 it on cleanup. This is done by calling i2c_unregister_device() on the 155 155 pointer that was earlier returned by i2c_new_device() or 156 - i2c_new_probed_device(). 156 + i2c_new_scanned_device(). 157 157 158 158 159 159 Method 3: Probe an I2C bus for certain devices 160 160 ---------------------------------------------- 161 161 162 162 Sometimes you do not have enough information about an I2C device, not even 163 - to call i2c_new_probed_device(). The typical case is hardware monitoring 163 + to call i2c_new_scanned_device(). The typical case is hardware monitoring 164 164 chips on PC mainboards. There are several dozen models, which can live 165 165 at 25 different addresses. Given the huge number of mainboards out there, 166 166 it is next to impossible to build an exhaustive list of the hardware
+4 -4
Documentation/i2c/writing-clients.rst
··· 185 185 don't know the exact address it uses. This happens on TV adapters for 186 186 example, where the same driver supports dozens of slightly different 187 187 models, and I2C device addresses change from one model to the next. In 188 - that case, you can use the i2c_new_probed_device() variant, which is 188 + that case, you can use the i2c_new_scanned_device() variant, which is 189 189 similar to i2c_new_device(), except that it takes an additional list of 190 190 possible I2C addresses to probe. A device is created for the first 191 191 responsive address in the list. If you expect more than one device to be 192 - present in the address range, simply call i2c_new_probed_device() that 192 + present in the address range, simply call i2c_new_scanned_device() that 193 193 many times. 194 194 195 - The call to i2c_new_device() or i2c_new_probed_device() typically happens 195 + The call to i2c_new_device() or i2c_new_scanned_device() typically happens 196 196 in the I2C bus driver. You may want to save the returned i2c_client 197 197 reference for later use. 198 198 ··· 237 237 --------------- 238 238 239 239 Each I2C device which has been created using i2c_new_device() or 240 - i2c_new_probed_device() can be unregistered by calling 240 + i2c_new_scanned_device() can be unregistered by calling 241 241 i2c_unregister_device(). If you don't call it explicitly, it will be 242 242 called automatically before the underlying I2C bus itself is removed, as a 243 243 device can't survive its parent in the device driver model.
+13 -11
drivers/i2c/busses/Kconfig
··· 145 145 Comet Lake (PCH) 146 146 Elkhart Lake (PCH) 147 147 Tiger Lake (PCH) 148 + Jasper Lake (SOC) 148 149 149 150 This driver can also be built as a module. If so, the module 150 151 will be called i2c-i801. ··· 293 292 select I2C_ALGOBIT 294 293 help 295 294 If you say yes to this option, support will be included for the VIA 296 - 82C586B I2C interface 295 + 82C586B I2C interface 297 296 298 297 This driver can also be built as a module. If so, the module 299 298 will be called i2c-via. ··· 678 677 tristate "IMX Low Power I2C interface" 679 678 depends on ARCH_MXC || COMPILE_TEST 680 679 help 681 - Say Y here if you want to use the Low Power IIC bus controller 682 - on the Freescale i.MX processors. 680 + Say Y here if you want to use the Low Power IIC bus controller 681 + on the Freescale i.MX processors. 683 682 684 - This driver can also be built as a module. If so, the module 685 - will be called i2c-imx-lpi2c. 683 + This driver can also be built as a module. If so, the module 684 + will be called i2c-imx-lpi2c. 686 685 687 686 config I2C_IOP3XX 688 687 tristate "Intel IOPx3xx and IXP4xx on-chip I2C interface" ··· 875 874 config I2C_PXA_SLAVE 876 875 bool "Intel PXA2XX I2C Slave comms support" 877 876 depends on I2C_PXA && !X86_32 877 + select I2C_SLAVE 878 878 help 879 879 Support I2C slave mode communications on the PXA I2C bus. This 880 880 is necessary for systems where the PXA may be a target on the ··· 1184 1182 will be called i2c-diolan-u2c. 1185 1183 1186 1184 config I2C_DLN2 1187 - tristate "Diolan DLN-2 USB I2C adapter" 1188 - depends on MFD_DLN2 1189 - help 1185 + tristate "Diolan DLN-2 USB I2C adapter" 1186 + depends on MFD_DLN2 1187 + help 1190 1188 If you say yes to this option, support will be included for Diolan 1191 1189 DLN2, a USB to I2C interface. 1192 1190 ··· 1285 1283 help 1286 1284 Say yes here to access the I2C part of the Nano River 1287 1285 Technologies Viperboard as I2C master. 1288 - See viperboard API specification and Nano 1289 - River Tech's viperboard.h for detailed meaning 1290 - of the module parameters. 1286 + See viperboard API specification and Nano 1287 + River Tech's viperboard.h for detailed meaning 1288 + of the module parameters. 1291 1289 1292 1290 comment "Other I2C/SMBus bus drivers" 1293 1291
+4
drivers/i2c/busses/i2c-aspeed.c
··· 952 952 .compatible = "aspeed,ast2500-i2c-bus", 953 953 .data = aspeed_i2c_25xx_get_clk_reg_val, 954 954 }, 955 + { 956 + .compatible = "aspeed,ast2600-i2c-bus", 957 + .data = aspeed_i2c_25xx_get_clk_reg_val, 958 + }, 955 959 { }, 956 960 }; 957 961 MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table);
+38
drivers/i2c/busses/i2c-at91-core.c
··· 68 68 .has_unre_flag = true, 69 69 .has_alt_cmd = false, 70 70 .has_hold_field = false, 71 + .has_dig_filtr = false, 72 + .has_adv_dig_filtr = false, 73 + .has_ana_filtr = false, 71 74 }; 72 75 73 76 static struct at91_twi_pdata at91sam9261_config = { ··· 79 76 .has_unre_flag = false, 80 77 .has_alt_cmd = false, 81 78 .has_hold_field = false, 79 + .has_dig_filtr = false, 80 + .has_adv_dig_filtr = false, 81 + .has_ana_filtr = false, 82 82 }; 83 83 84 84 static struct at91_twi_pdata at91sam9260_config = { ··· 90 84 .has_unre_flag = false, 91 85 .has_alt_cmd = false, 92 86 .has_hold_field = false, 87 + .has_dig_filtr = false, 88 + .has_adv_dig_filtr = false, 89 + .has_ana_filtr = false, 93 90 }; 94 91 95 92 static struct at91_twi_pdata at91sam9g20_config = { ··· 101 92 .has_unre_flag = false, 102 93 .has_alt_cmd = false, 103 94 .has_hold_field = false, 95 + .has_dig_filtr = false, 96 + .has_adv_dig_filtr = false, 97 + .has_ana_filtr = false, 104 98 }; 105 99 106 100 static struct at91_twi_pdata at91sam9g10_config = { ··· 112 100 .has_unre_flag = false, 113 101 .has_alt_cmd = false, 114 102 .has_hold_field = false, 103 + .has_dig_filtr = false, 104 + .has_adv_dig_filtr = false, 105 + .has_ana_filtr = false, 115 106 }; 116 107 117 108 static const struct platform_device_id at91_twi_devtypes[] = { ··· 145 130 .has_unre_flag = false, 146 131 .has_alt_cmd = false, 147 132 .has_hold_field = false, 133 + .has_dig_filtr = false, 134 + .has_adv_dig_filtr = false, 135 + .has_ana_filtr = false, 148 136 }; 149 137 150 138 static struct at91_twi_pdata sama5d4_config = { ··· 156 138 .has_unre_flag = false, 157 139 .has_alt_cmd = false, 158 140 .has_hold_field = true, 141 + .has_dig_filtr = true, 142 + .has_adv_dig_filtr = false, 143 + .has_ana_filtr = false, 159 144 }; 160 145 161 146 static struct at91_twi_pdata sama5d2_config = { ··· 167 146 .has_unre_flag = true, 168 147 .has_alt_cmd = true, 169 148 .has_hold_field = true, 149 + .has_dig_filtr = true, 150 + .has_adv_dig_filtr = true, 151 + .has_ana_filtr = true, 152 + }; 153 + 154 + static struct at91_twi_pdata sam9x60_config = { 155 + .clk_max_div = 7, 156 + .clk_offset = 4, 157 + .has_unre_flag = true, 158 + .has_alt_cmd = true, 159 + .has_hold_field = true, 160 + .has_dig_filtr = true, 161 + .has_adv_dig_filtr = true, 162 + .has_ana_filtr = true, 170 163 }; 171 164 172 165 static const struct of_device_id atmel_twi_dt_ids[] = { ··· 208 173 }, { 209 174 .compatible = "atmel,sama5d2-i2c", 210 175 .data = &sama5d2_config, 176 + }, { 177 + .compatible = "microchip,sam9x60-i2c", 178 + .data = &sam9x60_config, 211 179 }, { 212 180 /* sentinel */ 213 181 }
+48 -5
drivers/i2c/busses/i2c-at91-master.c
··· 31 31 32 32 void at91_init_twi_bus_master(struct at91_twi_dev *dev) 33 33 { 34 + struct at91_twi_pdata *pdata = dev->pdata; 35 + u32 filtr = 0; 36 + 34 37 /* FIFO should be enabled immediately after the software reset */ 35 38 if (dev->fifo_size) 36 39 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_FIFOEN); 37 40 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_MSEN); 38 41 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_SVDIS); 39 42 at91_twi_write(dev, AT91_TWI_CWGR, dev->twi_cwgr_reg); 43 + 44 + /* enable digital filter */ 45 + if (pdata->has_dig_filtr && dev->enable_dig_filt) 46 + filtr |= AT91_TWI_FILTR_FILT; 47 + 48 + /* enable advanced digital filter */ 49 + if (pdata->has_adv_dig_filtr && dev->enable_dig_filt) 50 + filtr |= AT91_TWI_FILTR_FILT | 51 + (AT91_TWI_FILTR_THRES(dev->filter_width) & 52 + AT91_TWI_FILTR_THRES_MASK); 53 + 54 + /* enable analog filter */ 55 + if (pdata->has_ana_filtr && dev->enable_ana_filt) 56 + filtr |= AT91_TWI_FILTR_PADFEN; 57 + 58 + if (filtr) 59 + at91_twi_write(dev, AT91_TWI_FILTR, filtr); 40 60 } 41 61 42 62 /* ··· 65 45 */ 66 46 static void at91_calc_twi_clock(struct at91_twi_dev *dev) 67 47 { 68 - int ckdiv, cdiv, div, hold = 0; 48 + int ckdiv, cdiv, div, hold = 0, filter_width = 0; 69 49 struct at91_twi_pdata *pdata = dev->pdata; 70 50 int offset = pdata->clk_offset; 71 51 int max_ckdiv = pdata->clk_max_div; ··· 104 84 } 105 85 } 106 86 87 + if (pdata->has_adv_dig_filtr) { 88 + /* 89 + * filter width = 0 to AT91_TWI_FILTR_THRES_MAX 90 + * peripheral clocks 91 + */ 92 + filter_width = DIV_ROUND_UP(t->digital_filter_width_ns 93 + * (clk_get_rate(dev->clk) / 1000), 1000000); 94 + if (filter_width > AT91_TWI_FILTR_THRES_MAX) { 95 + dev_warn(dev->dev, 96 + "Filter threshold set to its maximum value (%d instead of %d)\n", 97 + AT91_TWI_FILTR_THRES_MAX, filter_width); 98 + filter_width = AT91_TWI_FILTR_THRES_MAX; 99 + } 100 + } 101 + 107 102 dev->twi_cwgr_reg = (ckdiv << 16) | (cdiv << 8) | cdiv 108 103 | AT91_TWI_CWGR_HOLD(hold); 109 104 110 - dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns)\n", 111 - cdiv, ckdiv, hold, t->sda_hold_ns); 105 + dev->filter_width = filter_width; 106 + 107 + dev_dbg(dev->dev, "cdiv %d ckdiv %d hold %d (%d ns), filter_width %d (%d ns)\n", 108 + cdiv, ckdiv, hold, t->sda_hold_ns, filter_width, 109 + t->digital_filter_width_ns); 112 110 } 113 111 114 112 static void at91_twi_dma_cleanup(struct at91_twi_dev *dev) ··· 758 720 slave_config.dst_maxburst = 1; 759 721 slave_config.device_fc = false; 760 722 761 - dma->chan_tx = dma_request_slave_channel_reason(dev->dev, "tx"); 723 + dma->chan_tx = dma_request_chan(dev->dev, "tx"); 762 724 if (IS_ERR(dma->chan_tx)) { 763 725 ret = PTR_ERR(dma->chan_tx); 764 726 dma->chan_tx = NULL; 765 727 goto error; 766 728 } 767 729 768 - dma->chan_rx = dma_request_slave_channel_reason(dev->dev, "rx"); 730 + dma->chan_rx = dma_request_chan(dev->dev, "rx"); 769 731 if (IS_ERR(dma->chan_rx)) { 770 732 ret = PTR_ERR(dma->chan_rx); 771 733 dma->chan_rx = NULL; ··· 831 793 dev_info(dev->dev, "Using FIFO (%u data)\n", dev->fifo_size); 832 794 } 833 795 796 + dev->enable_dig_filt = of_property_read_bool(pdev->dev.of_node, 797 + "i2c-digital-filter"); 798 + 799 + dev->enable_ana_filt = of_property_read_bool(pdev->dev.of_node, 800 + "i2c-analog-filter"); 834 801 at91_calc_twi_clock(dev); 835 802 836 803 dev->adapter.algo = &at91_twi_algorithm;
+13
drivers/i2c/busses/i2c-at91.h
··· 84 84 #define AT91_TWI_ACR_DATAL(len) ((len) & 0xff) 85 85 #define AT91_TWI_ACR_DIR BIT(8) 86 86 87 + #define AT91_TWI_FILTR 0x0044 88 + #define AT91_TWI_FILTR_FILT BIT(0) 89 + #define AT91_TWI_FILTR_PADFEN BIT(1) 90 + #define AT91_TWI_FILTR_THRES(v) ((v) << 8) 91 + #define AT91_TWI_FILTR_THRES_MAX 7 92 + #define AT91_TWI_FILTR_THRES_MASK GENMASK(10, 8) 93 + 87 94 #define AT91_TWI_FMR 0x0050 /* FIFO Mode Register */ 88 95 #define AT91_TWI_FMR_TXRDYM(mode) (((mode) & 0x3) << 0) 89 96 #define AT91_TWI_FMR_TXRDYM_MASK (0x3 << 0) ··· 115 108 bool has_unre_flag; 116 109 bool has_alt_cmd; 117 110 bool has_hold_field; 111 + bool has_dig_filtr; 112 + bool has_adv_dig_filtr; 113 + bool has_ana_filtr; 118 114 struct at_dma_slave dma_slave; 119 115 }; 120 116 ··· 155 145 unsigned smr; 156 146 struct i2c_client *slave; 157 147 #endif 148 + bool enable_dig_filt; 149 + bool enable_ana_filt; 150 + u32 filter_width; 158 151 }; 159 152 160 153 unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg);
+50 -13
drivers/i2c/busses/i2c-bcm-iproc.c
··· 81 81 #define M_CMD_PROTOCOL_MASK 0xf 82 82 #define M_CMD_PROTOCOL_BLK_WR 0x7 83 83 #define M_CMD_PROTOCOL_BLK_RD 0x8 84 + #define M_CMD_PROTOCOL_PROCESS 0xa 84 85 #define M_CMD_PEC_SHIFT 8 85 86 #define M_CMD_RD_CNT_SHIFT 0 86 87 #define M_CMD_RD_CNT_MASK 0xff ··· 676 675 return 0; 677 676 } 678 677 679 - static int bcm_iproc_i2c_xfer_single_msg(struct bcm_iproc_i2c_dev *iproc_i2c, 680 - struct i2c_msg *msg) 678 + /* 679 + * If 'process_call' is true, then this is a multi-msg transfer that requires 680 + * a repeated start between the messages. 681 + * More specifically, it must be a write (reg) followed by a read (data). 682 + * The i2c quirks are set to enforce this rule. 683 + */ 684 + static int bcm_iproc_i2c_xfer_internal(struct bcm_iproc_i2c_dev *iproc_i2c, 685 + struct i2c_msg *msgs, bool process_call) 681 686 { 682 687 int i; 683 688 u8 addr; 684 689 u32 val, tmp, val_intr_en; 685 690 unsigned int tx_bytes; 691 + struct i2c_msg *msg = &msgs[0]; 686 692 687 693 /* check if bus is busy */ 688 694 if (!!(iproc_i2c_rd_reg(iproc_i2c, ··· 715 707 val = msg->buf[i]; 716 708 717 709 /* mark the last byte */ 718 - if (i == msg->len - 1) 719 - val |= BIT(M_TX_WR_STATUS_SHIFT); 710 + if (!process_call && (i == msg->len - 1)) 711 + val |= 1 << M_TX_WR_STATUS_SHIFT; 720 712 721 713 iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val); 722 714 } 723 715 iproc_i2c->tx_bytes = tx_bytes; 716 + } 717 + 718 + /* Process the read message if this is process call */ 719 + if (process_call) { 720 + msg++; 721 + iproc_i2c->msg = msg; /* point to second msg */ 722 + 723 + /* 724 + * The last byte to be sent out should be a slave 725 + * address with read operation 726 + */ 727 + addr = i2c_8bit_addr_from_msg(msg); 728 + /* mark it the last byte out */ 729 + val = addr | (1 << M_TX_WR_STATUS_SHIFT); 730 + iproc_i2c_wr_reg(iproc_i2c, M_TX_OFFSET, val); 724 731 } 725 732 726 733 /* mark as incomplete before starting the transaction */ ··· 756 733 * underrun interrupt, which will be triggerred when the TX FIFO is 757 734 * empty. When that happens we can then pump more data into the FIFO 758 735 */ 759 - if (!(msg->flags & I2C_M_RD) && 736 + if (!process_call && !(msg->flags & I2C_M_RD) && 760 737 msg->len > iproc_i2c->tx_bytes) 761 738 val_intr_en |= BIT(IE_M_TX_UNDERRUN_SHIFT); 762 739 ··· 766 743 */ 767 744 val = BIT(M_CMD_START_BUSY_SHIFT); 768 745 if (msg->flags & I2C_M_RD) { 746 + u32 protocol; 747 + 769 748 iproc_i2c->rx_bytes = 0; 770 749 if (msg->len > M_RX_FIFO_MAX_THLD_VALUE) 771 750 iproc_i2c->thld_bytes = M_RX_FIFO_THLD_VALUE; ··· 783 758 /* enable the RX threshold interrupt */ 784 759 val_intr_en |= BIT(IE_M_RX_THLD_SHIFT); 785 760 786 - val |= (M_CMD_PROTOCOL_BLK_RD << M_CMD_PROTOCOL_SHIFT) | 761 + protocol = process_call ? 762 + M_CMD_PROTOCOL_PROCESS : M_CMD_PROTOCOL_BLK_RD; 763 + 764 + val |= (protocol << M_CMD_PROTOCOL_SHIFT) | 787 765 (msg->len << M_CMD_RD_CNT_SHIFT); 788 766 } else { 789 767 val |= (M_CMD_PROTOCOL_BLK_WR << M_CMD_PROTOCOL_SHIFT); ··· 802 774 struct i2c_msg msgs[], int num) 803 775 { 804 776 struct bcm_iproc_i2c_dev *iproc_i2c = i2c_get_adapdata(adapter); 805 - int ret, i; 777 + bool process_call = false; 778 + int ret; 806 779 807 - /* go through all messages */ 808 - for (i = 0; i < num; i++) { 809 - ret = bcm_iproc_i2c_xfer_single_msg(iproc_i2c, &msgs[i]); 810 - if (ret) { 811 - dev_dbg(iproc_i2c->device, "xfer failed\n"); 812 - return ret; 780 + if (num == 2) { 781 + /* Repeated start, use process call */ 782 + process_call = true; 783 + if (msgs[1].flags & I2C_M_NOSTART) { 784 + dev_err(iproc_i2c->device, "Invalid repeated start\n"); 785 + return -EOPNOTSUPP; 813 786 } 787 + } 788 + 789 + ret = bcm_iproc_i2c_xfer_internal(iproc_i2c, msgs, process_call); 790 + if (ret) { 791 + dev_dbg(iproc_i2c->device, "xfer failed\n"); 792 + return ret; 814 793 } 815 794 816 795 return num; ··· 844 809 }; 845 810 846 811 static const struct i2c_adapter_quirks bcm_iproc_i2c_quirks = { 812 + .flags = I2C_AQ_COMB_WRITE_THEN_READ, 813 + .max_comb_1st_msg_len = M_TX_RX_FIFO_SIZE, 847 814 .max_read_len = M_RX_MAX_READ_LEN, 848 815 }; 849 816
+10 -5
drivers/i2c/busses/i2c-cros-ec-tunnel.c
··· 3 3 // 4 4 // Copyright (C) 2013 Google, Inc. 5 5 6 + #include <linux/acpi.h> 6 7 #include <linux/module.h> 7 8 #include <linux/i2c.h> 8 9 #include <linux/platform_data/cros_ec_commands.h> ··· 241 240 242 241 static int ec_i2c_probe(struct platform_device *pdev) 243 242 { 244 - struct device_node *np = pdev->dev.of_node; 245 243 struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent); 246 244 struct device *dev = &pdev->dev; 247 245 struct ec_i2c_device *bus = NULL; ··· 256 256 if (bus == NULL) 257 257 return -ENOMEM; 258 258 259 - err = of_property_read_u32(np, "google,remote-bus", &remote_bus); 259 + err = device_property_read_u32(dev, "google,remote-bus", &remote_bus); 260 260 if (err) { 261 261 dev_err(dev, "Couldn't read remote-bus property\n"); 262 262 return err; ··· 271 271 bus->adap.algo = &ec_i2c_algorithm; 272 272 bus->adap.algo_data = bus; 273 273 bus->adap.dev.parent = &pdev->dev; 274 - bus->adap.dev.of_node = np; 274 + bus->adap.dev.of_node = pdev->dev.of_node; 275 275 bus->adap.retries = I2C_MAX_RETRIES; 276 276 277 277 err = i2c_add_adapter(&bus->adap); ··· 291 291 return 0; 292 292 } 293 293 294 - #ifdef CONFIG_OF 295 294 static const struct of_device_id cros_ec_i2c_of_match[] = { 296 295 { .compatible = "google,cros-ec-i2c-tunnel" }, 297 296 {}, 298 297 }; 299 298 MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match); 300 - #endif 299 + 300 + static const struct acpi_device_id cros_ec_i2c_tunnel_acpi_id[] = { 301 + { "GOOG001A", 0 }, 302 + { } 303 + }; 304 + MODULE_DEVICE_TABLE(acpi, cros_ec_i2c_tunnel_acpi_id); 301 305 302 306 static struct platform_driver ec_i2c_tunnel_driver = { 303 307 .probe = ec_i2c_probe, 304 308 .remove = ec_i2c_remove, 305 309 .driver = { 306 310 .name = "cros-ec-i2c-tunnel", 311 + .acpi_match_table = ACPI_PTR(cros_ec_i2c_tunnel_acpi_id), 307 312 .of_match_table = of_match_ptr(cros_ec_i2c_of_match), 308 313 }, 309 314 };
+8
drivers/i2c/busses/i2c-i801.c
··· 64 64 * Cedar Fork (PCH) 0x18df 32 hard yes yes yes 65 65 * Ice Lake-LP (PCH) 0x34a3 32 hard yes yes yes 66 66 * Comet Lake (PCH) 0x02a3 32 hard yes yes yes 67 + * Comet Lake-H (PCH) 0x06a3 32 hard yes yes yes 67 68 * Elkhart Lake (PCH) 0x4b23 32 hard yes yes yes 68 69 * Tiger Lake-LP (PCH) 0xa0a3 32 hard yes yes yes 70 + * Jasper Lake (SOC) 0x4da3 32 hard yes yes yes 69 71 * 70 72 * Features supported by this driver: 71 73 * Software PEC no ··· 207 205 208 206 /* Older devices have their ID defined in <linux/pci_ids.h> */ 209 207 #define PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS 0x02a3 208 + #define PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS 0x06a3 210 209 #define PCI_DEVICE_ID_INTEL_BAYTRAIL_SMBUS 0x0f12 211 210 #define PCI_DEVICE_ID_INTEL_CDF_SMBUS 0x18df 212 211 #define PCI_DEVICE_ID_INTEL_DNV_SMBUS 0x19df ··· 226 223 #define PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS 0x34a3 227 224 #define PCI_DEVICE_ID_INTEL_5_3400_SERIES_SMBUS 0x3b30 228 225 #define PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS 0x4b23 226 + #define PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS 0x4da3 229 227 #define PCI_DEVICE_ID_INTEL_BROXTON_SMBUS 0x5ad4 230 228 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 231 229 #define PCI_DEVICE_ID_INTEL_WILDCATPOINT_SMBUS 0x8ca2 ··· 1073 1069 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CANNONLAKE_LP_SMBUS) }, 1074 1070 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS) }, 1075 1071 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS) }, 1072 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS) }, 1076 1073 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS) }, 1077 1074 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS) }, 1075 + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS) }, 1078 1076 { 0, } 1079 1077 }; 1080 1078 ··· 1756 1750 case PCI_DEVICE_ID_INTEL_CDF_SMBUS: 1757 1751 case PCI_DEVICE_ID_INTEL_ICELAKE_LP_SMBUS: 1758 1752 case PCI_DEVICE_ID_INTEL_COMETLAKE_SMBUS: 1753 + case PCI_DEVICE_ID_INTEL_COMETLAKE_H_SMBUS: 1759 1754 case PCI_DEVICE_ID_INTEL_ELKHART_LAKE_SMBUS: 1760 1755 case PCI_DEVICE_ID_INTEL_TIGERLAKE_LP_SMBUS: 1756 + case PCI_DEVICE_ID_INTEL_JASPER_LAKE_SMBUS: 1761 1757 priv->features |= FEATURE_BLOCK_PROC; 1762 1758 priv->features |= FEATURE_I2C_BLOCK_READ; 1763 1759 priv->features |= FEATURE_IRQ;
+4 -5
drivers/i2c/busses/i2c-icy.c
··· 122 122 struct fwnode_handle *new_fwnode; 123 123 struct i2c_board_info ltc2990_info = { 124 124 .type = "ltc2990", 125 - .addr = 0x4c, 126 125 }; 127 126 128 127 i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL); ··· 187 188 ltc2990_info.fwnode = new_fwnode; 188 189 189 190 i2c->ltc2990_client = 190 - i2c_new_probed_device(&i2c->adapter, 191 - &ltc2990_info, 192 - icy_ltc2990_addresses, 193 - NULL); 191 + i2c_new_scanned_device(&i2c->adapter, 192 + &ltc2990_info, 193 + icy_ltc2990_addresses, 194 + NULL); 194 195 } 195 196 196 197 return 0;
+60 -15
drivers/i2c/busses/i2c-pxa.c
··· 25 25 #include <linux/delay.h> 26 26 #include <linux/errno.h> 27 27 #include <linux/interrupt.h> 28 - #include <linux/i2c-pxa.h> 29 28 #include <linux/of.h> 30 29 #include <linux/of_device.h> 31 30 #include <linux/platform_device.h> ··· 179 180 struct i2c_adapter adap; 180 181 struct clk *clk; 181 182 #ifdef CONFIG_I2C_PXA_SLAVE 182 - struct i2c_slave_client *slave; 183 + struct i2c_client *slave; 183 184 #endif 184 185 185 186 unsigned int irqlogidx; ··· 543 544 if (isr & ISR_BED) { 544 545 /* what should we do here? */ 545 546 } else { 546 - int ret = 0; 547 + u8 byte = 0; 547 548 548 549 if (i2c->slave != NULL) 549 - ret = i2c->slave->read(i2c->slave->data); 550 + i2c_slave_event(i2c->slave, I2C_SLAVE_READ_PROCESSED, 551 + &byte); 550 552 551 - writel(ret, _IDBR(i2c)); 553 + writel(byte, _IDBR(i2c)); 552 554 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); /* allow next byte */ 553 555 } 554 556 } 555 557 556 558 static void i2c_pxa_slave_rxfull(struct pxa_i2c *i2c, u32 isr) 557 559 { 558 - unsigned int byte = readl(_IDBR(i2c)); 560 + u8 byte = readl(_IDBR(i2c)); 559 561 560 562 if (i2c->slave != NULL) 561 - i2c->slave->write(i2c->slave->data, byte); 563 + i2c_slave_event(i2c->slave, I2C_SLAVE_WRITE_RECEIVED, &byte); 562 564 563 565 writel(readl(_ICR(i2c)) | ICR_TB, _ICR(i2c)); 564 566 } ··· 572 572 dev_dbg(&i2c->adap.dev, "SAD, mode is slave-%cx\n", 573 573 (isr & ISR_RWM) ? 'r' : 't'); 574 574 575 - if (i2c->slave != NULL) 576 - i2c->slave->event(i2c->slave->data, 577 - (isr & ISR_RWM) ? I2C_SLAVE_EVENT_START_READ : I2C_SLAVE_EVENT_START_WRITE); 575 + if (i2c->slave != NULL) { 576 + if (isr & ISR_RWM) { 577 + u8 byte = 0; 578 + 579 + i2c_slave_event(i2c->slave, I2C_SLAVE_READ_REQUESTED, 580 + &byte); 581 + writel(byte, _IDBR(i2c)); 582 + } else { 583 + i2c_slave_event(i2c->slave, I2C_SLAVE_WRITE_REQUESTED, 584 + NULL); 585 + } 586 + } 578 587 579 588 /* 580 589 * slave could interrupt in the middle of us generating a ··· 616 607 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop)\n"); 617 608 618 609 if (i2c->slave != NULL) 619 - i2c->slave->event(i2c->slave->data, I2C_SLAVE_EVENT_STOP); 610 + i2c_slave_event(i2c->slave, I2C_SLAVE_STOP, NULL); 620 611 621 612 if (i2c_debug > 2) 622 613 dev_dbg(&i2c->adap.dev, "ISR: SSD (Slave Stop) acked\n"); ··· 627 618 */ 628 619 if (i2c->msg) 629 620 i2c_pxa_master_complete(i2c, I2C_RETRY); 621 + } 622 + 623 + static int i2c_pxa_slave_reg(struct i2c_client *slave) 624 + { 625 + struct pxa_i2c *i2c = slave->adapter->algo_data; 626 + 627 + if (i2c->slave) 628 + return -EBUSY; 629 + 630 + if (!i2c->reg_isar) 631 + return -EAFNOSUPPORT; 632 + 633 + i2c->slave = slave; 634 + i2c->slave_addr = slave->addr; 635 + 636 + writel(i2c->slave_addr, _ISAR(i2c)); 637 + 638 + return 0; 639 + } 640 + 641 + static int i2c_pxa_slave_unreg(struct i2c_client *slave) 642 + { 643 + struct pxa_i2c *i2c = slave->adapter->algo_data; 644 + 645 + WARN_ON(!i2c->slave); 646 + 647 + i2c->slave_addr = I2C_PXA_SLAVE_ADDR; 648 + writel(i2c->slave_addr, _ISAR(i2c)); 649 + 650 + i2c->slave = NULL; 651 + 652 + return 0; 630 653 } 631 654 #else 632 655 static void i2c_pxa_slave_txempty(struct pxa_i2c *i2c, u32 isr) ··· 1182 1141 static const struct i2c_algorithm i2c_pxa_algorithm = { 1183 1142 .master_xfer = i2c_pxa_xfer, 1184 1143 .functionality = i2c_pxa_functionality, 1144 + #ifdef CONFIG_I2C_PXA_SLAVE 1145 + .reg_slave = i2c_pxa_slave_reg, 1146 + .unreg_slave = i2c_pxa_slave_unreg, 1147 + #endif 1185 1148 }; 1186 1149 1187 1150 static const struct i2c_algorithm i2c_pxa_pio_algorithm = { 1188 1151 .master_xfer = i2c_pxa_pio_xfer, 1189 1152 .functionality = i2c_pxa_functionality, 1153 + #ifdef CONFIG_I2C_PXA_SLAVE 1154 + .reg_slave = i2c_pxa_slave_reg, 1155 + .unreg_slave = i2c_pxa_slave_unreg, 1156 + #endif 1190 1157 }; 1191 1158 1192 1159 static const struct of_device_id i2c_pxa_dt_ids[] = { ··· 1319 1270 i2c->highmode_enter = false; 1320 1271 1321 1272 if (plat) { 1322 - #ifdef CONFIG_I2C_PXA_SLAVE 1323 - i2c->slave_addr = plat->slave_addr; 1324 - i2c->slave = plat->slave; 1325 - #endif 1326 1273 i2c->adap.class = plat->class; 1327 1274 } 1328 1275
+2 -2
drivers/i2c/busses/i2c-qup.c
··· 628 628 int err; 629 629 630 630 if (!qup->btx.dma) { 631 - qup->btx.dma = dma_request_slave_channel_reason(qup->dev, "tx"); 631 + qup->btx.dma = dma_request_chan(qup->dev, "tx"); 632 632 if (IS_ERR(qup->btx.dma)) { 633 633 err = PTR_ERR(qup->btx.dma); 634 634 qup->btx.dma = NULL; ··· 638 638 } 639 639 640 640 if (!qup->brx.dma) { 641 - qup->brx.dma = dma_request_slave_channel_reason(qup->dev, "rx"); 641 + qup->brx.dma = dma_request_chan(qup->dev, "rx"); 642 642 if (IS_ERR(qup->brx.dma)) { 643 643 dev_err(qup->dev, "\n rx channel not available"); 644 644 err = PTR_ERR(qup->brx.dma);
+1 -1
drivers/i2c/busses/i2c-rcar.c
··· 317 317 318 318 scgd_find: 319 319 dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n", 320 - scl, t->bus_freq_hz, clk_get_rate(priv->clk), round, cdf, scgd); 320 + scl, t->bus_freq_hz, rate, round, cdf, scgd); 321 321 322 322 /* keep icccr value */ 323 323 priv->icccr = scgd << cdf_width | cdf;
+1 -1
drivers/i2c/busses/i2c-sh_mobile.c
··· 486 486 char *chan_name = dir == DMA_MEM_TO_DEV ? "tx" : "rx"; 487 487 int ret; 488 488 489 - chan = dma_request_slave_channel_reason(dev, chan_name); 489 + chan = dma_request_chan(dev, chan_name); 490 490 if (IS_ERR(chan)) { 491 491 dev_dbg(dev, "request_channel failed for %s (%ld)\n", chan_name, 492 492 PTR_ERR(chan));
+8 -8
drivers/i2c/busses/i2c-stm32.c
··· 20 20 21 21 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); 22 22 if (!dma) 23 - return NULL; 23 + return ERR_PTR(-ENOMEM); 24 24 25 25 /* Request and configure I2C TX dma channel */ 26 - dma->chan_tx = dma_request_slave_channel(dev, "tx"); 27 - if (!dma->chan_tx) { 26 + dma->chan_tx = dma_request_chan(dev, "tx"); 27 + if (IS_ERR(dma->chan_tx)) { 28 28 dev_dbg(dev, "can't request DMA tx channel\n"); 29 - ret = -EINVAL; 29 + ret = PTR_ERR(dma->chan_tx); 30 30 goto fail_al; 31 31 } 32 32 ··· 42 42 } 43 43 44 44 /* Request and configure I2C RX dma channel */ 45 - dma->chan_rx = dma_request_slave_channel(dev, "rx"); 46 - if (!dma->chan_rx) { 45 + dma->chan_rx = dma_request_chan(dev, "rx"); 46 + if (IS_ERR(dma->chan_rx)) { 47 47 dev_err(dev, "can't request DMA rx channel\n"); 48 - ret = -EINVAL; 48 + ret = PTR_ERR(dma->chan_rx); 49 49 goto fail_tx; 50 50 } 51 51 ··· 75 75 devm_kfree(dev, dma); 76 76 dev_info(dev, "can't use DMA\n"); 77 77 78 - return NULL; 78 + return ERR_PTR(ret); 79 79 } 80 80 81 81 void stm32_i2c_dma_free(struct stm32_i2c_dma *dma)
+23 -9
drivers/i2c/busses/i2c-stm32f7.c
··· 1267 1267 * slave[0] supports 7-bit and 10-bit slave address 1268 1268 * slave[1] supports 7-bit slave address only 1269 1269 */ 1270 - for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) { 1271 - if (i == 1 && (slave->flags & I2C_CLIENT_PEC)) 1270 + for (i = STM32F7_I2C_MAX_SLAVE - 1; i >= 0; i--) { 1271 + if (i == 1 && (slave->flags & I2C_CLIENT_TEN)) 1272 1272 continue; 1273 1273 if (!i2c_dev->slave[i]) { 1274 1274 *id = i; ··· 1955 1955 i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr, 1956 1956 STM32F7_I2C_TXDR, 1957 1957 STM32F7_I2C_RXDR); 1958 + if (PTR_ERR(i2c_dev->dma) == -ENODEV) 1959 + i2c_dev->dma = NULL; 1960 + else if (IS_ERR(i2c_dev->dma)) { 1961 + ret = PTR_ERR(i2c_dev->dma); 1962 + if (ret != -EPROBE_DEFER) 1963 + dev_err(&pdev->dev, 1964 + "Failed to request dma error %i\n", ret); 1965 + goto clk_free; 1966 + } 1958 1967 1959 1968 platform_set_drvdata(pdev, i2c_dev); 1960 1969 ··· 1994 1985 pm_runtime_set_suspended(i2c_dev->dev); 1995 1986 pm_runtime_dont_use_autosuspend(i2c_dev->dev); 1996 1987 1988 + if (i2c_dev->dma) { 1989 + stm32_i2c_dma_free(i2c_dev->dma); 1990 + i2c_dev->dma = NULL; 1991 + } 1992 + 1997 1993 clk_free: 1998 1994 clk_disable_unprepare(i2c_dev->clk); 1999 1995 ··· 2009 1995 { 2010 1996 struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev); 2011 1997 2012 - if (i2c_dev->dma) { 2013 - stm32_i2c_dma_free(i2c_dev->dma); 2014 - i2c_dev->dma = NULL; 2015 - } 2016 - 2017 1998 i2c_del_adapter(&i2c_dev->adap); 2018 1999 pm_runtime_get_sync(i2c_dev->dev); 2019 - 2020 - clk_disable_unprepare(i2c_dev->clk); 2021 2000 2022 2001 pm_runtime_put_noidle(i2c_dev->dev); 2023 2002 pm_runtime_disable(i2c_dev->dev); 2024 2003 pm_runtime_set_suspended(i2c_dev->dev); 2025 2004 pm_runtime_dont_use_autosuspend(i2c_dev->dev); 2005 + 2006 + if (i2c_dev->dma) { 2007 + stm32_i2c_dma_free(i2c_dev->dma); 2008 + i2c_dev->dma = NULL; 2009 + } 2010 + 2011 + clk_disable_unprepare(i2c_dev->clk); 2026 2012 2027 2013 return 0; 2028 2014 }
+2 -2
drivers/i2c/busses/i2c-tegra.c
··· 413 413 return 0; 414 414 } 415 415 416 - chan = dma_request_slave_channel_reason(i2c_dev->dev, "rx"); 416 + chan = dma_request_chan(i2c_dev->dev, "rx"); 417 417 if (IS_ERR(chan)) { 418 418 err = PTR_ERR(chan); 419 419 goto err_out; ··· 421 421 422 422 i2c_dev->rx_dma_chan = chan; 423 423 424 - chan = dma_request_slave_channel_reason(i2c_dev->dev, "tx"); 424 + chan = dma_request_chan(i2c_dev->dev, "tx"); 425 425 if (IS_ERR(chan)) { 426 426 err = PTR_ERR(chan); 427 427 goto err_out;
+2
drivers/i2c/busses/i2c-xiic.c
··· 46 46 47 47 /** 48 48 * struct xiic_i2c - Internal representation of the XIIC I2C bus 49 + * @dev: Pointer to device structure 49 50 * @base: Memory base of the HW registers 50 51 * @wait: Wait queue for callers 51 52 * @adap: Kernel adapter representation ··· 58 57 * @rx_msg: Current RX message 59 58 * @rx_pos: Position within current RX message 60 59 * @endianness: big/little-endian byte order 60 + * @clk: Pointer to AXI4-lite input clock 61 61 */ 62 62 struct xiic_i2c { 63 63 struct device *dev;
+25 -38
drivers/i2c/i2c-core-base.c
··· 1656 1656 t->sda_fall_ns = t->scl_fall_ns; 1657 1657 1658 1658 device_property_read_u32(dev, "i2c-sda-hold-time-ns", &t->sda_hold_ns); 1659 + 1660 + device_property_read_u32(dev, "i2c-digital-filter-width-ns", 1661 + &t->digital_filter_width_ns); 1662 + 1663 + device_property_read_u32(dev, "i2c-analog-filter-cutoff-frequency", 1664 + &t->analog_filter_cutoff_freq_hz); 1659 1665 } 1660 1666 EXPORT_SYMBOL_GPL(i2c_parse_fw_timings); 1661 1667 ··· 1742 1736 EXPORT_SYMBOL(i2c_del_driver); 1743 1737 1744 1738 /* ------------------------------------------------------------------------- */ 1745 - 1746 - /** 1747 - * i2c_use_client - increments the reference count of the i2c client structure 1748 - * @client: the client being referenced 1749 - * 1750 - * Each live reference to a client should be refcounted. The driver model does 1751 - * that automatically as part of driver binding, so that most drivers don't 1752 - * need to do this explicitly: they hold a reference until they're unbound 1753 - * from the device. 1754 - * 1755 - * A pointer to the client with the incremented reference counter is returned. 1756 - */ 1757 - struct i2c_client *i2c_use_client(struct i2c_client *client) 1758 - { 1759 - if (client && get_device(&client->dev)) 1760 - return client; 1761 - return NULL; 1762 - } 1763 - EXPORT_SYMBOL(i2c_use_client); 1764 - 1765 - /** 1766 - * i2c_release_client - release a use of the i2c client structure 1767 - * @client: the client being no longer referenced 1768 - * 1769 - * Must be called when a user of a client is finished with it. 1770 - */ 1771 - void i2c_release_client(struct i2c_client *client) 1772 - { 1773 - if (client) 1774 - put_device(&client->dev); 1775 - } 1776 - EXPORT_SYMBOL(i2c_release_client); 1777 1739 1778 1740 struct i2c_cmd_arg { 1779 1741 unsigned cmd; ··· 2245 2271 EXPORT_SYMBOL_GPL(i2c_probe_func_quick_read); 2246 2272 2247 2273 struct i2c_client * 2248 - i2c_new_probed_device(struct i2c_adapter *adap, 2249 - struct i2c_board_info *info, 2250 - unsigned short const *addr_list, 2251 - int (*probe)(struct i2c_adapter *adap, unsigned short addr)) 2274 + i2c_new_scanned_device(struct i2c_adapter *adap, 2275 + struct i2c_board_info *info, 2276 + unsigned short const *addr_list, 2277 + int (*probe)(struct i2c_adapter *adap, unsigned short addr)) 2252 2278 { 2253 2279 int i; 2254 2280 ··· 2278 2304 2279 2305 if (addr_list[i] == I2C_CLIENT_END) { 2280 2306 dev_dbg(&adap->dev, "Probing failed, no device found\n"); 2281 - return NULL; 2307 + return ERR_PTR(-ENODEV); 2282 2308 } 2283 2309 2284 2310 info->addr = addr_list[i]; 2285 - return i2c_new_device(adap, info); 2311 + return i2c_new_client_device(adap, info); 2312 + } 2313 + EXPORT_SYMBOL_GPL(i2c_new_scanned_device); 2314 + 2315 + struct i2c_client * 2316 + i2c_new_probed_device(struct i2c_adapter *adap, 2317 + struct i2c_board_info *info, 2318 + unsigned short const *addr_list, 2319 + int (*probe)(struct i2c_adapter *adap, unsigned short addr)) 2320 + { 2321 + struct i2c_client *client; 2322 + 2323 + client = i2c_new_scanned_device(adap, info, addr_list, probe); 2324 + return IS_ERR(client) ? NULL : client; 2286 2325 } 2287 2326 EXPORT_SYMBOL_GPL(i2c_new_probed_device); 2288 2327
-7
drivers/i2c/i2c-smbus.c
··· 66 66 { 67 67 struct i2c_smbus_alert *alert = d; 68 68 struct i2c_client *ara; 69 - unsigned short prev_addr = 0; /* Not a valid address */ 70 69 71 70 ara = alert->ara; 72 71 ··· 89 90 data.addr = status >> 1; 90 91 data.type = I2C_PROTOCOL_SMBUS_ALERT; 91 92 92 - if (data.addr == prev_addr) { 93 - dev_warn(&ara->dev, "Duplicate SMBALERT# from dev " 94 - "0x%02x, skipping\n", data.addr); 95 - break; 96 - } 97 93 dev_dbg(&ara->dev, "SMBALERT# from dev 0x%02x, flag %d\n", 98 94 data.addr, data.data); 99 95 100 96 /* Notify driver for the device which issued the alert */ 101 97 device_for_each_child(&ara->adapter->dev, &data, 102 98 smbus_do_alert); 103 - prev_addr = data.addr; 104 99 } 105 100 106 101 return IRQ_HANDLED;
+8 -8
drivers/i2c/muxes/Kconfig
··· 109 109 want to change the I2C master at run-time depending on features. 110 110 111 111 config I2C_MUX_MLXCPLD 112 - tristate "Mellanox CPLD based I2C multiplexer" 113 - help 114 - If you say yes to this option, support will be included for a 115 - CPLD based I2C multiplexer. This driver provides access to 116 - I2C busses connected through a MUX, which is controlled 117 - by a CPLD register. 112 + tristate "Mellanox CPLD based I2C multiplexer" 113 + help 114 + If you say yes to this option, support will be included for a 115 + CPLD based I2C multiplexer. This driver provides access to 116 + I2C busses connected through a MUX, which is controlled 117 + by a CPLD register. 118 118 119 - This driver can also be built as a module. If so, the module 120 - will be called i2c-mux-mlxcpld. 119 + This driver can also be built as a module. If so, the module 120 + will be called i2c-mux-mlxcpld. 121 121 122 122 endmenu
+6 -3
drivers/misc/eeprom/at24.c
··· 716 716 return -ENODEV; 717 717 } 718 718 719 - dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n", 720 - byte_len, client->name, 721 - writable ? "writable" : "read-only", at24->write_max); 719 + if (writable) 720 + dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/write\n", 721 + byte_len, client->name, at24->write_max); 722 + else 723 + dev_info(dev, "%u byte %s EEPROM, read-only\n", 724 + byte_len, client->name); 722 725 723 726 return 0; 724 727 }
+2 -2
drivers/video/fbdev/matrox/i2c-matroxfb.c
··· 191 191 0x1b, I2C_CLIENT_END 192 192 }; 193 193 194 - i2c_new_probed_device(&m2info->maven.adapter, 195 - &maven_info, addr_list, NULL); 194 + i2c_new_scanned_device(&m2info->maven.adapter, 195 + &maven_info, addr_list, NULL); 196 196 } 197 197 } 198 198 return m2info;
-18
include/linux/i2c-pxa.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _LINUX_I2C_ALGO_PXA_H 3 - #define _LINUX_I2C_ALGO_PXA_H 4 - 5 - typedef enum i2c_slave_event_e { 6 - I2C_SLAVE_EVENT_START_READ, 7 - I2C_SLAVE_EVENT_START_WRITE, 8 - I2C_SLAVE_EVENT_STOP 9 - } i2c_slave_event_t; 10 - 11 - struct i2c_slave_client { 12 - void *data; 13 - void (*event)(void *ptr, i2c_slave_event_t event); 14 - int (*read) (void *ptr); 15 - void (*write)(void *ptr, unsigned int val); 16 - }; 17 - 18 - #endif /* _LINUX_I2C_ALGO_PXA_H */
+15 -6
include/linux/i2c.h
··· 452 452 * a default probing method is used. 453 453 */ 454 454 extern struct i2c_client * 455 + i2c_new_scanned_device(struct i2c_adapter *adap, 456 + struct i2c_board_info *info, 457 + unsigned short const *addr_list, 458 + int (*probe)(struct i2c_adapter *adap, unsigned short addr)); 459 + 460 + extern struct i2c_client * 455 461 i2c_new_probed_device(struct i2c_adapter *adap, 456 - struct i2c_board_info *info, 457 - unsigned short const *addr_list, 458 - int (*probe)(struct i2c_adapter *adap, unsigned short addr)); 462 + struct i2c_board_info *info, 463 + unsigned short const *addr_list, 464 + int (*probe)(struct i2c_adapter *adap, unsigned short addr)); 459 465 460 466 /* Common custom probe functions */ 461 467 extern int i2c_probe_func_quick_read(struct i2c_adapter *adap, unsigned short addr); ··· 581 575 * @scl_int_delay_ns: time IP core additionally needs to setup SCL in ns 582 576 * @sda_fall_ns: time SDA signal takes to fall in ns; t(f) in the I2C specification 583 577 * @sda_hold_ns: time IP core additionally needs to hold SDA in ns 578 + * @digital_filter_width_ns: width in ns of spikes on i2c lines that the IP core 579 + * digital filter can filter out 580 + * @analog_filter_cutoff_freq_hz: threshold frequency for the low pass IP core 581 + * analog filter 584 582 */ 585 583 struct i2c_timings { 586 584 u32 bus_freq_hz; ··· 593 583 u32 scl_int_delay_ns; 594 584 u32 sda_fall_ns; 595 585 u32 sda_hold_ns; 586 + u32 digital_filter_width_ns; 587 + u32 analog_filter_cutoff_freq_hz; 596 588 }; 597 589 598 590 /** ··· 855 843 /* use a define to avoid include chaining to get THIS_MODULE */ 856 844 #define i2c_add_driver(driver) \ 857 845 i2c_register_driver(THIS_MODULE, driver) 858 - 859 - extern struct i2c_client *i2c_use_client(struct i2c_client *client); 860 - extern void i2c_release_client(struct i2c_client *client); 861 846 862 847 /* call the i2c_client->command() of all attached clients with 863 848 * the given arguments */
-4
include/linux/platform_data/i2c-pxa.h
··· 55 55 */ 56 56 #define I2C_ISR_INIT 0x7FF /* status register init */ 57 57 58 - struct i2c_slave_client; 59 - 60 58 struct i2c_pxa_platform_data { 61 - unsigned int slave_addr; 62 - struct i2c_slave_client *slave; 63 59 unsigned int class; 64 60 unsigned int use_pio :1; 65 61 unsigned int fast_mode :1;