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

Pull i2c updates from Wolfram Sang:
"I2C core:

- finally remove the I2C_COMPAT symbol after 15 years of deprecation

- lock client addresses during initialization to prevent race
conditions between different kinds of instantiation

- use scoped foreach OF child loops

- testunit cleanups and documentation improvements, as well as two
new tests, one for repeated start and one for triggering SMBusAlert
interrupts

I2C host drivers:

- DesignWare and Renesas I2C driver updates.

The first has has undergone through a series of cleanups that have
been sent to the mailing list a year ago for the first time and
finally get merged in this pull request. They are many, from typos
(e.g. i2/i2c), to cosmetics, to refactoring (e.g. move inline
functions to librarieas) and many others.

- all the DesignWare Kconfig options have been grouped under the
I2C_DESIGNWARE_CORE and this required some adaptation in many of
the kernel configuration files for different arm and mips boards

Cleanups:

- improve the exit path in the runtime resume function for the
Qualcomm Geni platform

- get rid of the unused "target_addr" parameter in the Intel LJCA
driver

- intialize the restart_flag in the MediaTek controller in one single
place

- constify a few global data structures in the virtio driver

- simplify the bus speed handling in the Renesas driver init function
making it more readable

- improved probe function of the Renesas R-Car driver

- switch the iMX/MXC driver to use RUNTIME_PM_OPS() instead of
SET_RUNTIME_PM_OPS()

- iMX/MXC driver cleanups

- use devm_clk_get_enabled() to simplify the Renesas EMEV2, Ingenic
and MPC drivers

Refactoring:

- Fix a potential out of boundary array access in the Nuvoton driver.

This is not a bug fix because the issue could never occur due to
hardware not having the properties listed in the array. The change
makes the driver more future proof and, at the same time, silences
code analyzers.

Improvements:

- several patches improving the runtime power management handling of
the Renesas I2C (riic) driver

- use a more descriptive adapter name in the Intel i801 driver to
show the presence of the IDF feature

- kill pending transactions when irq's can't complete their handling
in the Intel Denverton (ismt) driver, triggering a timeout

New Feature:

- support fast mode plus in the Renesas I2C (riic) driver

New support:

- Added support for:
- Renesas R9A08G045
- Rockchip RK3576
- KEBA I2C
- Theobroma Systems Mule Multiplexer.

- new i2c-keba.c driver

- new driver for The Mule i2c multiplexer

Core I2C framework:

- move runtime PM functions in order to allow them to be accessed
during device add

Devicetree:

- nVidia and Qualcomm binding improvements

- get rid of redundant "multi-master" property in the aspeed binding

- convert i2c-sprd binding to YAML

AT24 updates:

- document a new model from giantec in DT bindings"

* tag 'i2c-for-6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (69 commits)
i2c: designware: Use pci_get_drvdata()
i2c: designware: Propagate firmware node
i2c: designware: Uninline i2c_dw_probe()
i2c: ljca: Remove unused "target_addr" parameter
i2c: keba: Add KEBA I2C controller support
i2c: i801: Use a different adapter-name for IDF adapters
i2c: core: Setup i2c_adapter runtime-pm before calling device_add()
dt-bindings: i2c: i2c-sprd: convert to YAML
i2c: ismt: kill transaction in hardware on timeout
i2c: designware: Group all DesignWare drivers under a single option
net: txgbe: Fix I2C Kconfig dependencies
RISC-V: configs: enable I2C_DESIGNWARE_CORE with I2C_DESIGNWARE_PLATFORM
mips: configs: enable I2C_DESIGNWARE_CORE with I2C_DESIGNWARE_PLATFORM
arm64: defconfig: enable I2C_DESIGNWARE_CORE with I2C_DESIGNWARE_PLATFORM
ARM: configs: enable I2C_DESIGNWARE_CORE with I2C_DESIGNWARE_PLATFORM
ARC: configs: enable I2C_DESIGNWARE_CORE with I2C_DESIGNWARE_PLATFORM
i2c: virtio: Constify struct i2c_algorithm and struct virtio_device_id
i2c: rcar: tidyup priv->devtype handling on rcar_i2c_probe()
i2c: imx: Convert comma to semicolon
i2c: jz4780: Use devm_clk_get_enabled() helpers
...

+1748 -606
+1
Documentation/devicetree/bindings/eeprom/at24.yaml
··· 116 - const: atmel,24c02 117 - items: 118 - enum: 119 - onnn,cat24c04 120 - onnn,cat24c05 121 - rohm,br24g04
··· 116 - const: atmel,24c02 117 - items: 118 - enum: 119 + - giantec,gt24c04a 120 - onnn,cat24c04 121 - onnn,cat24c05 122 - rohm,br24g04
-5
Documentation/devicetree/bindings/i2c/aspeed,i2c.yaml
··· 44 description: frequency of the bus clock in Hz defaults to 100 kHz when not 45 specified 46 47 - multi-master: 48 - type: boolean 49 - description: 50 - states that there is another master active on this bus 51 - 52 required: 53 - reg 54 - compatible
··· 44 description: frequency of the bus clock in Hz defaults to 100 kHz when not 45 specified 46 47 required: 48 - reg 49 - compatible
+1
Documentation/devicetree/bindings/i2c/i2c-rk3x.yaml
··· 38 - rockchip,rk3308-i2c 39 - rockchip,rk3328-i2c 40 - rockchip,rk3568-i2c 41 - rockchip,rk3588-i2c 42 - rockchip,rv1126-i2c 43 - const: rockchip,rk3399-i2c
··· 38 - rockchip,rk3308-i2c 39 - rockchip,rk3328-i2c 40 - rockchip,rk3568-i2c 41 + - rockchip,rk3576-i2c 42 - rockchip,rk3588-i2c 43 - rockchip,rv1126-i2c 44 - const: rockchip,rk3399-i2c
-31
Documentation/devicetree/bindings/i2c/i2c-sprd.txt
··· 1 - I2C for Spreadtrum platforms 2 - 3 - Required properties: 4 - - compatible: Should be "sprd,sc9860-i2c". 5 - - reg: Specify the physical base address of the controller and length 6 - of memory mapped region. 7 - - interrupts: Should contain I2C interrupt. 8 - - clock-names: Should contain following entries: 9 - "i2c" for I2C clock, 10 - "source" for I2C source (parent) clock, 11 - "enable" for I2C module enable clock. 12 - - clocks: Should contain a clock specifier for each entry in clock-names. 13 - - clock-frequency: Contains desired I2C bus clock frequency in Hz. 14 - - #address-cells: Should be 1 to describe address cells for I2C device address. 15 - - #size-cells: Should be 0 means no size cell for I2C device address. 16 - 17 - Optional properties: 18 - - Child nodes conforming to I2C bus binding 19 - 20 - Examples: 21 - i2c0: i2c@70500000 { 22 - compatible = "sprd,sc9860-i2c"; 23 - reg = <0 0x70500000 0 0x1000>; 24 - interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>; 25 - clock-names = "i2c", "source", "enable"; 26 - clocks = <&clk_i2c3>, <&ext_26m>, <&clk_ap_apb_gates 11>; 27 - clock-frequency = <400000>; 28 - #address-cells = <1>; 29 - #size-cells = <0>; 30 - }; 31 -
···
+15 -12
Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.yaml
··· 103 items: 104 - const: i2c 105 106 dmas: 107 items: 108 - description: DMA channel for the reception FIFO ··· 127 - nvidia,tegra30-i2c 128 then: 129 properties: 130 clock-names: 131 items: 132 - const: div-clk ··· 138 properties: 139 compatible: 140 contains: 141 - const: nvidia,tegra114-i2c 142 then: 143 properties: 144 - clock-names: 145 - items: 146 - - const: div-clk 147 - 148 - - if: 149 - properties: 150 - compatible: 151 - contains: 152 - const: nvidia,tegra210-i2c 153 - then: 154 - properties: 155 clock-names: 156 items: 157 - const: div-clk ··· 156 const: nvidia,tegra210-i2c-vi 157 then: 158 properties: 159 clock-names: 160 items: 161 - const: div-clk ··· 165 power-domains: 166 items: 167 - description: phandle to the VENC power domain 168 169 unevaluatedProperties: false 170
··· 103 items: 104 - const: i2c 105 106 + power-domains: 107 + maxItems: 1 108 + 109 dmas: 110 items: 111 - description: DMA channel for the reception FIFO ··· 124 - nvidia,tegra30-i2c 125 then: 126 properties: 127 + clocks: 128 + minItems: 2 129 clock-names: 130 items: 131 - const: div-clk ··· 133 properties: 134 compatible: 135 contains: 136 + enum: 137 + - nvidia,tegra114-i2c 138 + - nvidia,tegra210-i2c 139 then: 140 properties: 141 + clocks: 142 + maxItems: 1 143 clock-names: 144 items: 145 - const: div-clk ··· 158 const: nvidia,tegra210-i2c-vi 159 then: 160 properties: 161 + clocks: 162 + minItems: 2 163 clock-names: 164 items: 165 - const: div-clk ··· 165 power-domains: 166 items: 167 - description: phandle to the VENC power domain 168 + else: 169 + properties: 170 + power-domains: false 171 172 unevaluatedProperties: false 173
+1
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml
··· 130 then: 131 properties: 132 clocks: 133 maxItems: 4 134 clock-names: 135 items:
··· 130 then: 131 properties: 132 clocks: 133 + minItems: 4 134 maxItems: 4 135 clock-names: 136 items:
+4
Documentation/devicetree/bindings/i2c/renesas,riic.yaml
··· 25 - renesas,riic-r9a07g054 # RZ/V2L 26 - const: renesas,riic-rz # RZ/A or RZ/G2L 27 28 - const: renesas,riic-r9a09g057 # RZ/V2H(P) 29 30 reg:
··· 25 - renesas,riic-r9a07g054 # RZ/V2L 26 - const: renesas,riic-rz # RZ/A or RZ/G2L 27 28 + - items: 29 + - const: renesas,riic-r9a08g045 # RZ/G3S 30 + - const: renesas,riic-r9a09g057 # RZ/V2H(P) 31 + 32 - const: renesas,riic-r9a09g057 # RZ/V2H(P) 33 34 reg:
+65
Documentation/devicetree/bindings/i2c/sprd,sc9860-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/sprd,sc9860-i2c.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Spreadtrum SC9860 I2C controller 8 + 9 + maintainers: 10 + - Orson Zhai <orsonzhai@gmail.com> 11 + - Baolin Wang <baolin.wang7@gmail.com> 12 + - Chunyan Zhang <zhang.lyra@gmail.com> 13 + 14 + allOf: 15 + - $ref: /schemas/i2c/i2c-controller.yaml# 16 + 17 + properties: 18 + compatible: 19 + const: sprd,sc9860-i2c 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + clocks: 28 + items: 29 + - description: I2C clock 30 + - description: I2C source (parent) clock 31 + - description: I2C module enable clock 32 + 33 + clock-names: 34 + items: 35 + - const: i2c 36 + - const: source 37 + - const: enable 38 + 39 + clock-frequency: true 40 + 41 + required: 42 + - compatible 43 + - reg 44 + - interrupts 45 + - clocks 46 + - clock-names 47 + - clock-frequency 48 + 49 + unevaluatedProperties: false 50 + 51 + examples: 52 + - | 53 + #include <dt-bindings/interrupt-controller/arm-gic.h> 54 + #include <dt-bindings/interrupt-controller/irq.h> 55 + 56 + i2c@70500000 { 57 + compatible = "sprd,sc9860-i2c"; 58 + reg = <0x70500000 0x1000>; 59 + interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>; 60 + clocks = <&clk_i2c3>, <&ext_26m>, <&clk_ap_apb_gates 11>; 61 + clock-names = "i2c", "source", "enable"; 62 + clock-frequency = <400000>; 63 + #address-cells = <1>; 64 + #size-cells = <0>; 65 + };
+69
Documentation/devicetree/bindings/i2c/tsd,mule-i2c-mux.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/tsd,mule-i2c-mux.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Theobroma Systems Mule I2C multiplexer 8 + 9 + maintainers: 10 + - Farouk Bouabid <farouk.bouabid@cherry.de> 11 + - Quentin Schulz <quentin.schulz@cherry.de> 12 + 13 + description: | 14 + Theobroma Systems Mule is an MCU that emulates a set of I2C devices, among 15 + which devices that are reachable through an I2C-mux. The devices on the mux 16 + can be selected by writing the appropriate device number to an I2C config 17 + register. 18 + 19 + 20 + +--------------------------------------------------+ 21 + | Mule | 22 + 0x18| +---------------+ | 23 + -------->|Config register|----+ | 24 + | +---------------+ | | 25 + | V_ | 26 + | | \ +--------+ | 27 + | | \-------->| dev #0 | | 28 + | | | +--------+ | 29 + 0x6f| | M |-------->| dev #1 | | 30 + ---------------------------->| U | +--------+ | 31 + | | X |-------->| dev #2 | | 32 + | | | +--------+ | 33 + | | /-------->| dev #3 | | 34 + | |__/ +--------+ | 35 + +--------------------------------------------------+ 36 + 37 + 38 + allOf: 39 + - $ref: /schemas/i2c/i2c-mux.yaml# 40 + 41 + properties: 42 + compatible: 43 + const: tsd,mule-i2c-mux 44 + 45 + required: 46 + - compatible 47 + 48 + unevaluatedProperties: false 49 + 50 + examples: 51 + - | 52 + i2c-mux { 53 + compatible = "tsd,mule-i2c-mux"; 54 + #address-cells = <1>; 55 + #size-cells = <0>; 56 + 57 + i2c@0 { 58 + reg = <0x0>; 59 + #address-cells = <1>; 60 + #size-cells = <0>; 61 + 62 + rtc@6f { 63 + compatible = "isil,isl1208"; 64 + reg = <0x6f>; 65 + }; 66 + }; 67 + }; 68 + ... 69 +
+110 -10
Documentation/i2c/slave-testunit-backend.rst
··· 20 21 # echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device 22 23 - After that, you will have a write-only device listening. Reads will just return 24 - an 8-bit version number of the testunit. When writing, the device consists of 4 25 - 8-bit registers and, except for some "partial" commands, all registers must be 26 - written to start a testcase, i.e. you usually write 4 bytes to the device. The 27 - registers are: 28 29 .. csv-table:: 30 :header: "Offset", "Name", "Description" ··· 89 access the bus at the same time, the bus will be busy. Example to read 128 90 bytes from device 0x50 after 50ms of delay:: 91 92 - # i2cset -y 0 0x30 0x01 0x50 0x80 0x05 i 93 94 0x02 SMBUS_HOST_NOTIFY 95 ~~~~~~~~~~~~~~~~~~~~~~ ··· 109 110 Also needs master mode. This test will send an SMBUS_HOST_NOTIFY message to the 111 host. Note that the status word is currently ignored in the Linux Kernel. 112 - Example to send a notification after 10ms:: 113 114 - # i2cset -y 0 0x30 0x02 0x42 0x64 0x01 i 115 116 If the host controller supports HostNotify, this message with debug level 117 should appear (Linux 6.11 and later):: ··· 130 - DELAY 131 132 * - 0x03 133 - - must be '1', i.e. one further byte will be written 134 - number of bytes to be sent back 135 - leave out, partial command! 136 ··· 145 i2c_smbus_block_process_call() using i2ctransfer (you need i2c-tools v4.2 or 146 later):: 147 148 - # i2ctransfer -y 0 w3@0x30 0x03 0x01 0x10 r? 149 0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00
··· 20 21 # echo "slave-testunit 0x1030" > /sys/bus/i2c/devices/i2c-0/new_device 22 23 + Or using firmware nodes. Here is a devicetree example (note this is only a 24 + debug device, so there are no official DT bindings):: 25 + 26 + &i2c0 { 27 + ... 28 + 29 + testunit@30 { 30 + compatible = "slave-testunit"; 31 + reg = <(0x30 | I2C_OWN_SLAVE_ADDRESS)>; 32 + }; 33 + }; 34 + 35 + After that, you will have the device listening. Reading will return a single 36 + byte. Its value is 0 if the testunit is idle, otherwise the command number of 37 + the currently running command. 38 + 39 + When writing, the device consists of 4 8-bit registers and, except for some 40 + "partial" commands, all registers must be written to start a testcase, i.e. you 41 + usually write 4 bytes to the device. The registers are: 42 43 .. csv-table:: 44 :header: "Offset", "Name", "Description" ··· 75 access the bus at the same time, the bus will be busy. Example to read 128 76 bytes from device 0x50 after 50ms of delay:: 77 78 + # i2cset -y 0 0x30 1 0x50 0x80 5 i 79 80 0x02 SMBUS_HOST_NOTIFY 81 ~~~~~~~~~~~~~~~~~~~~~~ ··· 95 96 Also needs master mode. This test will send an SMBUS_HOST_NOTIFY message to the 97 host. Note that the status word is currently ignored in the Linux Kernel. 98 + Example to send a notification with status word 0x6442 after 10ms:: 99 100 + # i2cset -y 0 0x30 2 0x42 0x64 1 i 101 102 If the host controller supports HostNotify, this message with debug level 103 should appear (Linux 6.11 and later):: ··· 116 - DELAY 117 118 * - 0x03 119 + - 0x01 (i.e. one further byte will be written) 120 - number of bytes to be sent back 121 - leave out, partial command! 122 ··· 131 i2c_smbus_block_process_call() using i2ctransfer (you need i2c-tools v4.2 or 132 later):: 133 134 + # i2ctransfer -y 0 w3@0x30 3 1 0x10 r? 135 0x10 0x0f 0x0e 0x0d 0x0c 0x0b 0x0a 0x09 0x08 0x07 0x06 0x05 0x04 0x03 0x02 0x01 0x00 136 + 137 + 0x04 GET_VERSION_WITH_REP_START 138 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 139 + 140 + .. list-table:: 141 + :header-rows: 1 142 + 143 + * - CMD 144 + - DATAL 145 + - DATAH 146 + - DELAY 147 + 148 + * - 0x04 149 + - currently unused 150 + - currently unused 151 + - leave out, partial command! 152 + 153 + Partial command. After sending this command, the testunit will reply to a read 154 + message with a NUL terminated version string based on UTS_RELEASE. The first 155 + character is always a 'v' and the length of the version string is at maximum 156 + 128 bytes. However, it will only respond if the read message is connected to 157 + the write message via repeated start. If your controller driver handles 158 + repeated start correctly, this will work:: 159 + 160 + # i2ctransfer -y 0 w3@0x30 4 0 0 r128 161 + 0x76 0x36 0x2e 0x31 0x31 0x2e 0x30 0x2d 0x72 0x63 0x31 0x2d 0x30 0x30 0x30 0x30 ... 162 + 163 + If you have i2c-tools 4.4 or later, you can print out the data right away:: 164 + 165 + # i2ctransfer -y -b 0 w3@0x30 4 0 0 r128 166 + v6.11.0-rc1-00009-gd37a1b4d3fd0 167 + 168 + STOP/START combinations between the two messages will *not* work because they 169 + are not equivalent to a REPEATED START. As an example, this returns just the 170 + default response:: 171 + 172 + # i2cset -y 0 0x30 4 0 0 i; i2cget -y 0 0x30 173 + 0x00 174 + 175 + 0x05 SMBUS_ALERT_REQUEST 176 + ~~~~~~~~~~~~~~~~~~~~~~~~ 177 + 178 + .. list-table:: 179 + :header-rows: 1 180 + 181 + * - CMD 182 + - DATAL 183 + - DATAH 184 + - DELAY 185 + 186 + * - 0x05 187 + - response value (7 MSBs interpreted as I2C address) 188 + - currently unused 189 + - n * 10ms 190 + 191 + This test raises an interrupt via the SMBAlert pin which the host controller 192 + must handle. The pin must be connected to the testunit as a GPIO. GPIO access 193 + is not allowed to sleep. Currently, this can only be described using firmware 194 + nodes. So, for devicetree, you would add something like this to the testunit 195 + node:: 196 + 197 + gpios = <&gpio1 24 GPIO_ACTIVE_LOW>; 198 + 199 + The following command will trigger the alert with a response of 0xc9 after 1 200 + second of delay:: 201 + 202 + # i2cset -y 0 0x30 5 0xc9 0x00 100 i 203 + 204 + If the host controller supports SMBusAlert, this message with debug level 205 + should appear:: 206 + 207 + smbus_alert 0-000c: SMBALERT# from dev 0x64, flag 1 208 + 209 + This message may appear more than once because the testunit is software not 210 + hardware and, thus, may not be able to react to the response of the host fast 211 + enough. The interrupt count should increase only by one, though:: 212 + 213 + # cat /proc/interrupts | grep smbus_alert 214 + 93: 1 gpio-rcar 26 Edge smbus_alert 215 + 216 + If the host does not respond to the alert within 1 second, the test will be 217 + aborted and the testunit will report an error. 218 + 219 + For this test, the testunit will shortly drop its assigned address and listen 220 + on the SMBus Alert Response Address (0x0c). It will reassign its original 221 + address afterwards.
+1
arch/arc/configs/axs101_defconfig
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 CONFIG_I2C_DESIGNWARE_PLATFORM=y 70 # CONFIG_HWMON is not set 71 CONFIG_DRM=m
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 + CONFIG_I2C_DESIGNWARE_CORE=y 70 CONFIG_I2C_DESIGNWARE_PLATFORM=y 71 # CONFIG_HWMON is not set 72 CONFIG_DRM=m
+1
arch/arc/configs/axs103_defconfig
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 CONFIG_I2C_DESIGNWARE_PLATFORM=y 70 # CONFIG_HWMON is not set 71 CONFIG_FB=y
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 + CONFIG_I2C_DESIGNWARE_CORE=y 70 CONFIG_I2C_DESIGNWARE_PLATFORM=y 71 # CONFIG_HWMON is not set 72 CONFIG_FB=y
+1
arch/arc/configs/axs103_smp_defconfig
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 CONFIG_I2C_DESIGNWARE_PLATFORM=y 70 # CONFIG_HWMON is not set 71 CONFIG_DRM=m
··· 66 # CONFIG_HW_RANDOM is not set 67 CONFIG_I2C=y 68 CONFIG_I2C_CHARDEV=y 69 + CONFIG_I2C_DESIGNWARE_CORE=y 70 CONFIG_I2C_DESIGNWARE_PLATFORM=y 71 # CONFIG_HWMON is not set 72 CONFIG_DRM=m
+1
arch/arc/configs/tb10x_defconfig
··· 60 # CONFIG_HW_RANDOM is not set 61 CONFIG_I2C=y 62 # CONFIG_I2C_COMPAT is not set 63 CONFIG_I2C_DESIGNWARE_PLATFORM=y 64 CONFIG_GPIO_SYSFS=y 65 # CONFIG_HWMON is not set
··· 60 # CONFIG_HW_RANDOM is not set 61 CONFIG_I2C=y 62 # CONFIG_I2C_COMPAT is not set 63 + CONFIG_I2C_DESIGNWARE_CORE=y 64 CONFIG_I2C_DESIGNWARE_PLATFORM=y 65 CONFIG_GPIO_SYSFS=y 66 # CONFIG_HWMON is not set
+1
arch/arm/configs/hisi_defconfig
··· 43 CONFIG_SERIAL_OF_PLATFORM=y 44 CONFIG_SERIAL_AMBA_PL011=y 45 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 46 CONFIG_I2C_DESIGNWARE_PLATFORM=y 47 CONFIG_SPI=y 48 CONFIG_SPI_PL022=y
··· 43 CONFIG_SERIAL_OF_PLATFORM=y 44 CONFIG_SERIAL_AMBA_PL011=y 45 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 46 + CONFIG_I2C_DESIGNWARE_CORE=y 47 CONFIG_I2C_DESIGNWARE_PLATFORM=y 48 CONFIG_SPI=y 49 CONFIG_SPI_PL022=y
+1
arch/arm/configs/multi_v7_defconfig
··· 413 CONFIG_I2C_BCM2835=y 414 CONFIG_I2C_CADENCE=y 415 CONFIG_I2C_DAVINCI=y 416 CONFIG_I2C_DESIGNWARE_PLATFORM=y 417 CONFIG_I2C_DIGICOLOR=m 418 CONFIG_I2C_EMEV2=m
··· 413 CONFIG_I2C_BCM2835=y 414 CONFIG_I2C_CADENCE=y 415 CONFIG_I2C_DAVINCI=y 416 + CONFIG_I2C_DESIGNWARE_CORE=y 417 CONFIG_I2C_DESIGNWARE_PLATFORM=y 418 CONFIG_I2C_DIGICOLOR=m 419 CONFIG_I2C_EMEV2=m
+1
arch/arm/configs/pxa_defconfig
··· 277 CONFIG_I2C_CHARDEV=m 278 CONFIG_I2C_MUX_PCA954x=m 279 CONFIG_I2C_MUX_PINCTRL=m 280 CONFIG_I2C_DESIGNWARE_PLATFORM=m 281 CONFIG_I2C_GPIO=y 282 CONFIG_I2C_PXA_SLAVE=y
··· 277 CONFIG_I2C_CHARDEV=m 278 CONFIG_I2C_MUX_PCA954x=m 279 CONFIG_I2C_MUX_PINCTRL=m 280 + CONFIG_I2C_DESIGNWARE_CORE=m 281 CONFIG_I2C_DESIGNWARE_PLATFORM=m 282 CONFIG_I2C_GPIO=y 283 CONFIG_I2C_PXA_SLAVE=y
+1
arch/arm/configs/socfpga_defconfig
··· 83 CONFIG_SERIAL_8250_DW=y 84 CONFIG_I2C=y 85 CONFIG_I2C_CHARDEV=y 86 CONFIG_I2C_DESIGNWARE_PLATFORM=y 87 CONFIG_SPI=y 88 CONFIG_SPI_CADENCE_QUADSPI=y
··· 83 CONFIG_SERIAL_8250_DW=y 84 CONFIG_I2C=y 85 CONFIG_I2C_CHARDEV=y 86 + CONFIG_I2C_DESIGNWARE_CORE=y 87 CONFIG_I2C_DESIGNWARE_PLATFORM=y 88 CONFIG_SPI=y 89 CONFIG_SPI_CADENCE_QUADSPI=y
+1
arch/arm/configs/spear13xx_defconfig
··· 62 # CONFIG_HW_RANDOM is not set 63 CONFIG_RAW_DRIVER=y 64 CONFIG_I2C=y 65 CONFIG_I2C_DESIGNWARE_PLATFORM=y 66 CONFIG_SPI=y 67 CONFIG_SPI_PL022=y
··· 62 # CONFIG_HW_RANDOM is not set 63 CONFIG_RAW_DRIVER=y 64 CONFIG_I2C=y 65 + CONFIG_I2C_DESIGNWARE_CORE=y 66 CONFIG_I2C_DESIGNWARE_PLATFORM=y 67 CONFIG_SPI=y 68 CONFIG_SPI_PL022=y
+1
arch/arm/configs/spear3xx_defconfig
··· 42 # CONFIG_HW_RANDOM is not set 43 CONFIG_RAW_DRIVER=y 44 CONFIG_I2C=y 45 CONFIG_I2C_DESIGNWARE_PLATFORM=y 46 CONFIG_SPI=y 47 CONFIG_SPI_PL022=y
··· 42 # CONFIG_HW_RANDOM is not set 43 CONFIG_RAW_DRIVER=y 44 CONFIG_I2C=y 45 + CONFIG_I2C_DESIGNWARE_CORE=y 46 CONFIG_I2C_DESIGNWARE_PLATFORM=y 47 CONFIG_SPI=y 48 CONFIG_SPI_PL022=y
+1
arch/arm/configs/spear6xx_defconfig
··· 33 CONFIG_SERIAL_AMBA_PL011=y 34 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 35 CONFIG_I2C=y 36 CONFIG_I2C_DESIGNWARE_PLATFORM=y 37 CONFIG_SPI=y 38 CONFIG_SPI_PL022=y
··· 33 CONFIG_SERIAL_AMBA_PL011=y 34 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 35 CONFIG_I2C=y 36 + CONFIG_I2C_DESIGNWARE_CORE=y 37 CONFIG_I2C_DESIGNWARE_PLATFORM=y 38 CONFIG_SPI=y 39 CONFIG_SPI_PL022=y
+1
arch/arm64/configs/defconfig
··· 518 CONFIG_I2C_MUX_PCA954x=y 519 CONFIG_I2C_BCM2835=m 520 CONFIG_I2C_CADENCE=m 521 CONFIG_I2C_DESIGNWARE_PLATFORM=y 522 CONFIG_I2C_GPIO=m 523 CONFIG_I2C_IMX=y
··· 518 CONFIG_I2C_MUX_PCA954x=y 519 CONFIG_I2C_BCM2835=m 520 CONFIG_I2C_CADENCE=m 521 + CONFIG_I2C_DESIGNWARE_CORE=y 522 CONFIG_I2C_DESIGNWARE_PLATFORM=y 523 CONFIG_I2C_GPIO=m 524 CONFIG_I2C_IMX=y
+1
arch/mips/configs/generic/board-ocelot.config
··· 31 CONFIG_I2C=y 32 CONFIG_I2C_CHARDEV=y 33 CONFIG_I2C_MUX=y 34 CONFIG_I2C_DESIGNWARE_PLATFORM=y 35 36 CONFIG_SPI=y
··· 31 CONFIG_I2C=y 32 CONFIG_I2C_CHARDEV=y 33 CONFIG_I2C_MUX=y 34 + CONFIG_I2C_DESIGNWARE_CORE=y 35 CONFIG_I2C_DESIGNWARE_PLATFORM=y 36 37 CONFIG_SPI=y
+1
arch/riscv/configs/defconfig
··· 157 CONFIG_HW_RANDOM_JH7110=m 158 CONFIG_I2C=y 159 CONFIG_I2C_CHARDEV=m 160 CONFIG_I2C_DESIGNWARE_PLATFORM=y 161 CONFIG_I2C_MV64XXX=m 162 CONFIG_I2C_RIIC=y
··· 157 CONFIG_HW_RANDOM_JH7110=m 158 CONFIG_I2C=y 159 CONFIG_I2C_CHARDEV=m 160 + CONFIG_I2C_DESIGNWARE_CORE=y 161 CONFIG_I2C_DESIGNWARE_PLATFORM=y 162 CONFIG_I2C_MV64XXX=m 163 CONFIG_I2C_RIIC=y
+1
arch/riscv/configs/nommu_k210_defconfig
··· 58 # CONFIG_I2C_COMPAT is not set 59 CONFIG_I2C_CHARDEV=y 60 # CONFIG_I2C_HELPER_AUTO is not set 61 CONFIG_I2C_DESIGNWARE_PLATFORM=y 62 CONFIG_SPI=y 63 # CONFIG_SPI_MEM is not set
··· 58 # CONFIG_I2C_COMPAT is not set 59 CONFIG_I2C_CHARDEV=y 60 # CONFIG_I2C_HELPER_AUTO is not set 61 + CONFIG_I2C_DESIGNWARE_CORE=y 62 CONFIG_I2C_DESIGNWARE_PLATFORM=y 63 CONFIG_SPI=y 64 # CONFIG_SPI_MEM is not set
+1
arch/riscv/configs/nommu_k210_sdcard_defconfig
··· 50 CONFIG_I2C=y 51 CONFIG_I2C_CHARDEV=y 52 # CONFIG_I2C_HELPER_AUTO is not set 53 CONFIG_I2C_DESIGNWARE_PLATFORM=y 54 CONFIG_SPI=y 55 # CONFIG_SPI_MEM is not set
··· 50 CONFIG_I2C=y 51 CONFIG_I2C_CHARDEV=y 52 # CONFIG_I2C_HELPER_AUTO is not set 53 + CONFIG_I2C_DESIGNWARE_CORE=y 54 CONFIG_I2C_DESIGNWARE_PLATFORM=y 55 CONFIG_SPI=y 56 # CONFIG_SPI_MEM is not set
-8
drivers/i2c/Kconfig
··· 40 bool 41 default y 42 43 - config I2C_COMPAT 44 - bool "Enable compatibility bits for old user-space" 45 - default y 46 - help 47 - Say Y here if you intend to run lm-sensors 3.1.1 or older, or any 48 - other user-space package which expects i2c adapters to be class 49 - devices. If you don't know, say Y. 50 - 51 config I2C_CHARDEV 52 tristate "I2C device interface" 53 help
··· 40 bool 41 default y 42 43 config I2C_CHARDEV 44 tristate "I2C device interface" 45 help
+29 -11
drivers/i2c/busses/Kconfig
··· 559 For details please see http://www.ti.com/davinci 560 561 config I2C_DESIGNWARE_CORE 562 - tristate 563 select REGMAP 564 565 config I2C_DESIGNWARE_SLAVE 566 bool "Synopsys DesignWare Slave" 567 - depends on I2C_DESIGNWARE_CORE 568 select I2C_SLAVE 569 help 570 If you say yes to this option, support will be included for the 571 Synopsys DesignWare I2C slave adapter. 572 573 - This is not a standalone module, this module compiles together with 574 - i2c-designware-core. 575 - 576 config I2C_DESIGNWARE_PLATFORM 577 - tristate "Synopsys DesignWare Platform" 578 depends on (ACPI && COMMON_CLK) || !ACPI 579 - select I2C_DESIGNWARE_CORE 580 select MFD_SYSCON if MIPS_BAIKAL_T1 581 help 582 If you say yes to this option, support will be included for the 583 - Synopsys DesignWare I2C adapter. 584 585 This driver can also be built as a module. If so, the module 586 will be called i2c-designware-platform. ··· 618 a BayTrail system using the AXP288. 619 620 config I2C_DESIGNWARE_PCI 621 - tristate "Synopsys DesignWare PCI" 622 depends on PCI 623 - select I2C_DESIGNWARE_CORE 624 select I2C_CCGX_UCSI 625 help 626 If you say yes to this option, support will be included for the 627 - Synopsys DesignWare I2C adapter. Only master mode is supported. 628 629 This driver can also be built as a module. If so, the module 630 will be called i2c-designware-pci. 631 632 config I2C_DIGICOLOR 633 tristate "Conexant Digicolor I2C driver" ··· 778 Ingenic JZ4780 I2C controller. 779 780 If you don't know what to do here, say N. 781 782 config I2C_KEMPLD 783 tristate "Kontron COM I2C Controller"
··· 559 For details please see http://www.ti.com/davinci 560 561 config I2C_DESIGNWARE_CORE 562 + tristate "Synopsys DesignWare I2C adapter" 563 select REGMAP 564 + help 565 + This option enables support for the Synopsys DesignWare I2C adapter. 566 + This driver includes support for the I2C host on the Synopsys 567 + Designware I2C adapter. 568 + 569 + To compile the driver as a module, choose M here: the module will be 570 + called i2c-designware-core. 571 + 572 + if I2C_DESIGNWARE_CORE 573 574 config I2C_DESIGNWARE_SLAVE 575 bool "Synopsys DesignWare Slave" 576 select I2C_SLAVE 577 help 578 If you say yes to this option, support will be included for the 579 Synopsys DesignWare I2C slave adapter. 580 581 config I2C_DESIGNWARE_PLATFORM 582 + tristate "Synopsys DesignWare Platform driver" 583 depends on (ACPI && COMMON_CLK) || !ACPI 584 select MFD_SYSCON if MIPS_BAIKAL_T1 585 + default I2C_DESIGNWARE_CORE 586 help 587 If you say yes to this option, support will be included for the 588 + Synopsys DesignWare I2C adapters on the platform bus. 589 590 This driver can also be built as a module. If so, the module 591 will be called i2c-designware-platform. ··· 613 a BayTrail system using the AXP288. 614 615 config I2C_DESIGNWARE_PCI 616 + tristate "Synopsys DesignWare PCI driver" 617 depends on PCI 618 select I2C_CCGX_UCSI 619 help 620 If you say yes to this option, support will be included for the 621 + Synopsys DesignWare I2C adapters on the PCI bus. Only master mode is 622 + supported. 623 624 This driver can also be built as a module. If so, the module 625 will be called i2c-designware-pci. 626 + 627 + endif 628 629 config I2C_DIGICOLOR 630 tristate "Conexant Digicolor I2C driver" ··· 771 Ingenic JZ4780 I2C controller. 772 773 If you don't know what to do here, say N. 774 + 775 + config I2C_KEBA 776 + tristate "KEBA I2C controller support" 777 + depends on HAS_IOMEM 778 + select AUXILIARY_BUS 779 + help 780 + This driver supports the I2C controller found in KEBA system FPGA 781 + devices. 782 + 783 + This driver can also be built as a module. If so, the module 784 + will be called i2c-keba. 785 786 config I2C_KEMPLD 787 tristate "Kontron COM I2C Controller"
+1
drivers/i2c/busses/Makefile
··· 76 obj-$(CONFIG_I2C_IMX_LPI2C) += i2c-imx-lpi2c.o 77 obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 78 obj-$(CONFIG_I2C_JZ4780) += i2c-jz4780.o 79 obj-$(CONFIG_I2C_KEMPLD) += i2c-kempld.o 80 obj-$(CONFIG_I2C_LPC2K) += i2c-lpc2k.o 81 obj-$(CONFIG_I2C_LS2X) += i2c-ls2x.o
··· 76 obj-$(CONFIG_I2C_IMX_LPI2C) += i2c-imx-lpi2c.o 77 obj-$(CONFIG_I2C_IOP3XX) += i2c-iop3xx.o 78 obj-$(CONFIG_I2C_JZ4780) += i2c-jz4780.o 79 + obj-$(CONFIG_I2C_KEBA) += i2c-keba.o 80 obj-$(CONFIG_I2C_KEMPLD) += i2c-kempld.o 81 obj-$(CONFIG_I2C_LPC2K) += i2c-lpc2k.o 82 obj-$(CONFIG_I2C_LS2X) += i2c-ls2x.o
+1 -2
drivers/i2c/busses/i2c-ali1535.c
··· 479 480 static const struct pci_device_id ali1535_ids[] = { 481 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, 482 - { }, 483 }; 484 - 485 MODULE_DEVICE_TABLE(pci, ali1535_ids); 486 487 static int ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
··· 479 480 static const struct pci_device_id ali1535_ids[] = { 481 { PCI_DEVICE(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101) }, 482 + { } 483 }; 484 MODULE_DEVICE_TABLE(pci, ali1535_ids); 485 486 static int ali1535_probe(struct pci_dev *dev, const struct pci_device_id *id)
+1 -1
drivers/i2c/busses/i2c-amd-mp2-plat.c
··· 340 341 static const struct acpi_device_id i2c_amd_acpi_match[] = { 342 { "AMDI0011" }, 343 - { }, 344 }; 345 MODULE_DEVICE_TABLE(acpi, i2c_amd_acpi_match); 346
··· 340 341 static const struct acpi_device_id i2c_amd_acpi_match[] = { 342 { "AMDI0011" }, 343 + { } 344 }; 345 MODULE_DEVICE_TABLE(acpi, i2c_amd_acpi_match); 346
+1 -1
drivers/i2c/busses/i2c-aspeed.c
··· 991 .compatible = "aspeed,ast2600-i2c-bus", 992 .data = aspeed_i2c_25xx_get_clk_reg_val, 993 }, 994 - { }, 995 }; 996 MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table); 997
··· 991 .compatible = "aspeed,ast2600-i2c-bus", 992 .data = aspeed_i2c_25xx_get_clk_reg_val, 993 }, 994 + { } 995 }; 996 MODULE_DEVICE_TABLE(of, aspeed_i2c_bus_of_table); 997
+170 -10
drivers/i2c/busses/i2c-designware-common.c
··· 20 #include <linux/io.h> 21 #include <linux/kernel.h> 22 #include <linux/module.h> 23 #include <linux/pm_runtime.h> 24 #include <linux/regmap.h> 25 #include <linux/swab.h> 26 #include <linux/types.h> 27 #include <linux/units.h> 28 29 #include "i2c-designware-core.h" 30 ··· 193 I2C_MAX_STANDARD_MODE_FREQ, 194 }; 195 196 - int i2c_dw_validate_speed(struct dw_i2c_dev *dev) 197 { 198 struct i2c_timings *t = &dev->timings; 199 unsigned int i; ··· 213 214 return -EINVAL; 215 } 216 - EXPORT_SYMBOL_GPL(i2c_dw_validate_speed); 217 218 #ifdef CONFIG_ACPI 219 ··· 297 kfree(buf.pointer); 298 } 299 300 - int i2c_dw_acpi_configure(struct device *device) 301 { 302 struct dw_i2c_dev *dev = dev_get_drvdata(device); 303 struct i2c_timings *t = &dev->timings; ··· 327 dev->sda_hold_time = fs_ht; 328 break; 329 } 330 - 331 - return 0; 332 } 333 - EXPORT_SYMBOL_GPL(i2c_dw_acpi_configure); 334 335 static u32 i2c_dw_acpi_round_bus_speed(struct device *device) 336 { ··· 349 350 #else /* CONFIG_ACPI */ 351 352 static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; } 353 354 #endif /* CONFIG_ACPI */ 355 356 - void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev) 357 { 358 u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev); 359 struct i2c_timings *t = &dev->timings; ··· 371 else 372 t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ; 373 } 374 - EXPORT_SYMBOL_GPL(i2c_dw_adjust_bus_speed); 375 376 - u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset) 377 { 378 /* 379 * DesignWare I2C core doesn't seem to have solid strategy to meet 380 * the tHD;STA timing spec. Configuring _HCNT based on tHIGH spec ··· 450 3 + offset; 451 } 452 453 - u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset) 454 { 455 /* 456 * Conditional expression: 457 * ··· 735 736 i2c_dw_release_lock(dev); 737 } 738 739 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core"); 740 MODULE_LICENSE("GPL");
··· 20 #include <linux/io.h> 21 #include <linux/kernel.h> 22 #include <linux/module.h> 23 + #include <linux/of.h> 24 + #include <linux/pm.h> 25 #include <linux/pm_runtime.h> 26 + #include <linux/property.h> 27 #include <linux/regmap.h> 28 #include <linux/swab.h> 29 #include <linux/types.h> 30 #include <linux/units.h> 31 + 32 + #define DEFAULT_SYMBOL_NAMESPACE I2C_DW_COMMON 33 34 #include "i2c-designware-core.h" 35 ··· 188 I2C_MAX_STANDARD_MODE_FREQ, 189 }; 190 191 + static int i2c_dw_validate_speed(struct dw_i2c_dev *dev) 192 { 193 struct i2c_timings *t = &dev->timings; 194 unsigned int i; ··· 208 209 return -EINVAL; 210 } 211 + 212 + #ifdef CONFIG_OF 213 + 214 + #include <linux/platform_device.h> 215 + 216 + #define MSCC_ICPU_CFG_TWI_DELAY 0x0 217 + #define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0) 218 + #define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4 219 + 220 + static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev) 221 + { 222 + writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE, 223 + dev->ext + MSCC_ICPU_CFG_TWI_DELAY); 224 + 225 + return 0; 226 + } 227 + 228 + static void i2c_dw_of_configure(struct device *device) 229 + { 230 + struct platform_device *pdev = to_platform_device(device); 231 + struct dw_i2c_dev *dev = dev_get_drvdata(device); 232 + 233 + switch (dev->flags & MODEL_MASK) { 234 + case MODEL_MSCC_OCELOT: 235 + dev->ext = devm_platform_ioremap_resource(pdev, 1); 236 + if (!IS_ERR(dev->ext)) 237 + dev->set_sda_hold_time = mscc_twi_set_sda_hold_time; 238 + break; 239 + default: 240 + break; 241 + } 242 + } 243 + 244 + #else /* CONFIG_OF */ 245 + 246 + static inline void i2c_dw_of_configure(struct device *device) { } 247 + 248 + #endif /* CONFIG_OF */ 249 250 #ifdef CONFIG_ACPI 251 ··· 255 kfree(buf.pointer); 256 } 257 258 + static void i2c_dw_acpi_configure(struct device *device) 259 { 260 struct dw_i2c_dev *dev = dev_get_drvdata(device); 261 struct i2c_timings *t = &dev->timings; ··· 285 dev->sda_hold_time = fs_ht; 286 break; 287 } 288 } 289 290 static u32 i2c_dw_acpi_round_bus_speed(struct device *device) 291 { ··· 310 311 #else /* CONFIG_ACPI */ 312 313 + static inline void i2c_dw_acpi_configure(struct device *device) { } 314 + 315 static inline u32 i2c_dw_acpi_round_bus_speed(struct device *device) { return 0; } 316 317 #endif /* CONFIG_ACPI */ 318 319 + static void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev) 320 { 321 u32 acpi_speed = i2c_dw_acpi_round_bus_speed(dev->dev); 322 struct i2c_timings *t = &dev->timings; ··· 330 else 331 t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ; 332 } 333 334 + int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev) 335 { 336 + struct i2c_timings *t = &dev->timings; 337 + struct device *device = dev->dev; 338 + struct fwnode_handle *fwnode = dev_fwnode(device); 339 + 340 + i2c_parse_fw_timings(device, t, false); 341 + 342 + i2c_dw_adjust_bus_speed(dev); 343 + 344 + if (is_of_node(fwnode)) 345 + i2c_dw_of_configure(device); 346 + else if (is_acpi_node(fwnode)) 347 + i2c_dw_acpi_configure(device); 348 + 349 + return i2c_dw_validate_speed(dev); 350 + } 351 + EXPORT_SYMBOL_GPL(i2c_dw_fw_parse_and_configure); 352 + 353 + static u32 i2c_dw_read_scl_reg(struct dw_i2c_dev *dev, u32 reg) 354 + { 355 + u32 val; 356 + int ret; 357 + 358 + ret = i2c_dw_acquire_lock(dev); 359 + if (ret) 360 + return 0; 361 + 362 + ret = regmap_read(dev->map, reg, &val); 363 + i2c_dw_release_lock(dev); 364 + 365 + return ret ? 0 : val; 366 + } 367 + 368 + u32 i2c_dw_scl_hcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk, 369 + u32 tSYMBOL, u32 tf, int cond, int offset) 370 + { 371 + if (!ic_clk) 372 + return i2c_dw_read_scl_reg(dev, reg); 373 + 374 /* 375 * DesignWare I2C core doesn't seem to have solid strategy to meet 376 * the tHD;STA timing spec. Configuring _HCNT based on tHIGH spec ··· 372 3 + offset; 373 } 374 375 + u32 i2c_dw_scl_lcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk, 376 + u32 tLOW, u32 tf, int offset) 377 { 378 + if (!ic_clk) 379 + return i2c_dw_read_scl_reg(dev, reg); 380 + 381 /* 382 * Conditional expression: 383 * ··· 653 654 i2c_dw_release_lock(dev); 655 } 656 + EXPORT_SYMBOL_GPL(i2c_dw_disable); 657 + 658 + int i2c_dw_probe(struct dw_i2c_dev *dev) 659 + { 660 + device_set_node(&dev->adapter.dev, dev_fwnode(dev->dev)); 661 + 662 + switch (dev->mode) { 663 + case DW_IC_SLAVE: 664 + return i2c_dw_probe_slave(dev); 665 + case DW_IC_MASTER: 666 + return i2c_dw_probe_master(dev); 667 + default: 668 + dev_err(dev->dev, "Wrong operation mode: %d\n", dev->mode); 669 + return -EINVAL; 670 + } 671 + } 672 + EXPORT_SYMBOL_GPL(i2c_dw_probe); 673 + 674 + static int i2c_dw_prepare(struct device *device) 675 + { 676 + /* 677 + * If the ACPI companion device object is present for this device, 678 + * it may be accessed during suspend and resume of other devices via 679 + * I2C operation regions, so tell the PM core and middle layers to 680 + * avoid skipping system suspend/resume callbacks for it in that case. 681 + */ 682 + return !has_acpi_companion(device); 683 + } 684 + 685 + static int i2c_dw_runtime_suspend(struct device *device) 686 + { 687 + struct dw_i2c_dev *dev = dev_get_drvdata(device); 688 + 689 + if (dev->shared_with_punit) 690 + return 0; 691 + 692 + i2c_dw_disable(dev); 693 + i2c_dw_prepare_clk(dev, false); 694 + 695 + return 0; 696 + } 697 + 698 + static int i2c_dw_suspend(struct device *device) 699 + { 700 + struct dw_i2c_dev *dev = dev_get_drvdata(device); 701 + 702 + i2c_mark_adapter_suspended(&dev->adapter); 703 + 704 + return i2c_dw_runtime_suspend(device); 705 + } 706 + 707 + static int i2c_dw_runtime_resume(struct device *device) 708 + { 709 + struct dw_i2c_dev *dev = dev_get_drvdata(device); 710 + 711 + if (!dev->shared_with_punit) 712 + i2c_dw_prepare_clk(dev, true); 713 + 714 + dev->init(dev); 715 + 716 + return 0; 717 + } 718 + 719 + static int i2c_dw_resume(struct device *device) 720 + { 721 + struct dw_i2c_dev *dev = dev_get_drvdata(device); 722 + 723 + i2c_dw_runtime_resume(device); 724 + i2c_mark_adapter_resumed(&dev->adapter); 725 + 726 + return 0; 727 + } 728 + 729 + EXPORT_GPL_DEV_PM_OPS(i2c_dw_dev_pm_ops) = { 730 + .prepare = pm_sleep_ptr(i2c_dw_prepare), 731 + LATE_SYSTEM_SLEEP_PM_OPS(i2c_dw_suspend, i2c_dw_resume) 732 + RUNTIME_PM_OPS(i2c_dw_runtime_suspend, i2c_dw_runtime_resume, NULL) 733 + }; 734 735 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core"); 736 MODULE_LICENSE("GPL");
+11 -28
drivers/i2c/busses/i2c-designware-core.h
··· 10 */ 11 12 #include <linux/bits.h> 13 - #include <linux/compiler_types.h> 14 #include <linux/completion.h> 15 - #include <linux/dev_printk.h> 16 #include <linux/errno.h> 17 #include <linux/i2c.h> 18 #include <linux/regmap.h> 19 #include <linux/types.h> 20 ··· 236 * @semaphore_idx: Index of table with semaphore type attached to the bus. It's 237 * -1 if there is no semaphore. 238 * @shared_with_punit: true if this bus is shared with the SoCs PUNIT 239 - * @disable: function to disable the controller 240 * @init: function to initialize the I2C hardware 241 * @set_sda_hold_time: callback to retrieve IP specific SDA hold timing 242 * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE ··· 293 void (*release_lock)(void); 294 int semaphore_idx; 295 bool shared_with_punit; 296 - void (*disable)(struct dw_i2c_dev *dev); 297 int (*init)(struct dw_i2c_dev *dev); 298 int (*set_sda_hold_time)(struct dw_i2c_dev *dev); 299 int mode; ··· 326 }; 327 328 int i2c_dw_init_regmap(struct dw_i2c_dev *dev); 329 - u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset); 330 - u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset); 331 int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev); 332 u32 i2c_dw_clk_rate(struct dw_i2c_dev *dev); 333 int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare); ··· 339 int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev); 340 int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev); 341 u32 i2c_dw_func(struct i2c_adapter *adap); 342 - void i2c_dw_disable(struct dw_i2c_dev *dev); 343 344 static inline void __i2c_dw_enable(struct dw_i2c_dev *dev) 345 { ··· 373 } 374 375 void __i2c_dw_disable(struct dw_i2c_dev *dev); 376 377 extern void i2c_dw_configure_master(struct dw_i2c_dev *dev); 378 extern int i2c_dw_probe_master(struct dw_i2c_dev *dev); ··· 386 static inline int i2c_dw_probe_slave(struct dw_i2c_dev *dev) { return -EINVAL; } 387 #endif 388 389 - static inline int i2c_dw_probe(struct dw_i2c_dev *dev) 390 - { 391 - switch (dev->mode) { 392 - case DW_IC_SLAVE: 393 - return i2c_dw_probe_slave(dev); 394 - case DW_IC_MASTER: 395 - return i2c_dw_probe_master(dev); 396 - default: 397 - dev_err(dev->dev, "Wrong operation mode: %d\n", dev->mode); 398 - return -EINVAL; 399 - } 400 - } 401 - 402 static inline void i2c_dw_configure(struct dw_i2c_dev *dev) 403 { 404 if (i2c_detect_slave_mode(dev->dev)) ··· 393 else 394 i2c_dw_configure_master(dev); 395 } 396 397 #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_BAYTRAIL) 398 int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev); ··· 404 int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev); 405 #endif 406 407 - int i2c_dw_validate_speed(struct dw_i2c_dev *dev); 408 - void i2c_dw_adjust_bus_speed(struct dw_i2c_dev *dev); 409 - 410 - #if IS_ENABLED(CONFIG_ACPI) 411 - int i2c_dw_acpi_configure(struct device *device); 412 - #else 413 - static inline int i2c_dw_acpi_configure(struct device *device) { return -ENODEV; } 414 - #endif
··· 10 */ 11 12 #include <linux/bits.h> 13 #include <linux/completion.h> 14 #include <linux/errno.h> 15 #include <linux/i2c.h> 16 + #include <linux/pm.h> 17 #include <linux/regmap.h> 18 #include <linux/types.h> 19 ··· 237 * @semaphore_idx: Index of table with semaphore type attached to the bus. It's 238 * -1 if there is no semaphore. 239 * @shared_with_punit: true if this bus is shared with the SoCs PUNIT 240 * @init: function to initialize the I2C hardware 241 * @set_sda_hold_time: callback to retrieve IP specific SDA hold timing 242 * @mode: operation mode - DW_IC_MASTER or DW_IC_SLAVE ··· 295 void (*release_lock)(void); 296 int semaphore_idx; 297 bool shared_with_punit; 298 int (*init)(struct dw_i2c_dev *dev); 299 int (*set_sda_hold_time)(struct dw_i2c_dev *dev); 300 int mode; ··· 329 }; 330 331 int i2c_dw_init_regmap(struct dw_i2c_dev *dev); 332 + u32 i2c_dw_scl_hcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk, 333 + u32 tSYMBOL, u32 tf, int cond, int offset); 334 + u32 i2c_dw_scl_lcnt(struct dw_i2c_dev *dev, unsigned int reg, u32 ic_clk, 335 + u32 tLOW, u32 tf, int offset); 336 int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev); 337 u32 i2c_dw_clk_rate(struct dw_i2c_dev *dev); 338 int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare); ··· 340 int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev); 341 int i2c_dw_set_fifo_size(struct dw_i2c_dev *dev); 342 u32 i2c_dw_func(struct i2c_adapter *adap); 343 + 344 + extern const struct dev_pm_ops i2c_dw_dev_pm_ops; 345 346 static inline void __i2c_dw_enable(struct dw_i2c_dev *dev) 347 { ··· 373 } 374 375 void __i2c_dw_disable(struct dw_i2c_dev *dev); 376 + void i2c_dw_disable(struct dw_i2c_dev *dev); 377 378 extern void i2c_dw_configure_master(struct dw_i2c_dev *dev); 379 extern int i2c_dw_probe_master(struct dw_i2c_dev *dev); ··· 385 static inline int i2c_dw_probe_slave(struct dw_i2c_dev *dev) { return -EINVAL; } 386 #endif 387 388 static inline void i2c_dw_configure(struct dw_i2c_dev *dev) 389 { 390 if (i2c_detect_slave_mode(dev->dev)) ··· 405 else 406 i2c_dw_configure_master(dev); 407 } 408 + 409 + int i2c_dw_probe(struct dw_i2c_dev *dev); 410 411 #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_BAYTRAIL) 412 int i2c_dw_baytrail_probe_lock_support(struct dw_i2c_dev *dev); ··· 414 int i2c_dw_amdpsp_probe_lock_support(struct dw_i2c_dev *dev); 415 #endif 416 417 + int i2c_dw_fw_parse_and_configure(struct dw_i2c_dev *dev);
+27 -9
drivers/i2c/busses/i2c-designware-master.c
··· 22 #include <linux/regmap.h> 23 #include <linux/reset.h> 24 25 #include "i2c-designware-core.h" 26 27 #define AMD_TIMEOUT_MIN_US 25 ··· 66 if (!dev->ss_hcnt || !dev->ss_lcnt) { 67 ic_clk = i2c_dw_clk_rate(dev); 68 dev->ss_hcnt = 69 - i2c_dw_scl_hcnt(ic_clk, 70 4000, /* tHD;STA = tHIGH = 4.0 us */ 71 sda_falling_time, 72 0, /* 0: DW default, 1: Ideal */ 73 0); /* No offset */ 74 dev->ss_lcnt = 75 - i2c_dw_scl_lcnt(ic_clk, 76 4700, /* tLOW = 4.7 us */ 77 scl_falling_time, 78 0); /* No offset */ ··· 100 } else { 101 ic_clk = i2c_dw_clk_rate(dev); 102 dev->fs_hcnt = 103 - i2c_dw_scl_hcnt(ic_clk, 104 260, /* tHIGH = 260 ns */ 105 sda_falling_time, 106 0, /* DW default */ 107 0); /* No offset */ 108 dev->fs_lcnt = 109 - i2c_dw_scl_lcnt(ic_clk, 110 500, /* tLOW = 500 ns */ 111 scl_falling_time, 112 0); /* No offset */ ··· 124 if (!dev->fs_hcnt || !dev->fs_lcnt) { 125 ic_clk = i2c_dw_clk_rate(dev); 126 dev->fs_hcnt = 127 - i2c_dw_scl_hcnt(ic_clk, 128 600, /* tHD;STA = tHIGH = 0.6 us */ 129 sda_falling_time, 130 0, /* 0: DW default, 1: Ideal */ 131 0); /* No offset */ 132 dev->fs_lcnt = 133 - i2c_dw_scl_lcnt(ic_clk, 134 1300, /* tLOW = 1.3 us */ 135 scl_falling_time, 136 0); /* No offset */ ··· 156 } else if (!dev->hs_hcnt || !dev->hs_lcnt) { 157 ic_clk = i2c_dw_clk_rate(dev); 158 dev->hs_hcnt = 159 - i2c_dw_scl_hcnt(ic_clk, 160 160, /* tHIGH = 160 ns */ 161 sda_falling_time, 162 0, /* DW default */ 163 0); /* No offset */ 164 dev->hs_lcnt = 165 - i2c_dw_scl_lcnt(ic_clk, 166 320, /* tLOW = 320 ns */ 167 scl_falling_time, 168 0); /* No offset */ ··· 949 init_completion(&dev->cmd_complete); 950 951 dev->init = i2c_dw_init_master; 952 - dev->disable = i2c_dw_disable; 953 954 ret = i2c_dw_init_regmap(dev); 955 if (ret) ··· 1038 1039 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus master adapter"); 1040 MODULE_LICENSE("GPL");
··· 22 #include <linux/regmap.h> 23 #include <linux/reset.h> 24 25 + #define DEFAULT_SYMBOL_NAMESPACE I2C_DW 26 + 27 #include "i2c-designware-core.h" 28 29 #define AMD_TIMEOUT_MIN_US 25 ··· 64 if (!dev->ss_hcnt || !dev->ss_lcnt) { 65 ic_clk = i2c_dw_clk_rate(dev); 66 dev->ss_hcnt = 67 + i2c_dw_scl_hcnt(dev, 68 + DW_IC_SS_SCL_HCNT, 69 + ic_clk, 70 4000, /* tHD;STA = tHIGH = 4.0 us */ 71 sda_falling_time, 72 0, /* 0: DW default, 1: Ideal */ 73 0); /* No offset */ 74 dev->ss_lcnt = 75 + i2c_dw_scl_lcnt(dev, 76 + DW_IC_SS_SCL_LCNT, 77 + ic_clk, 78 4700, /* tLOW = 4.7 us */ 79 scl_falling_time, 80 0); /* No offset */ ··· 94 } else { 95 ic_clk = i2c_dw_clk_rate(dev); 96 dev->fs_hcnt = 97 + i2c_dw_scl_hcnt(dev, 98 + DW_IC_FS_SCL_HCNT, 99 + ic_clk, 100 260, /* tHIGH = 260 ns */ 101 sda_falling_time, 102 0, /* DW default */ 103 0); /* No offset */ 104 dev->fs_lcnt = 105 + i2c_dw_scl_lcnt(dev, 106 + DW_IC_FS_SCL_LCNT, 107 + ic_clk, 108 500, /* tLOW = 500 ns */ 109 scl_falling_time, 110 0); /* No offset */ ··· 114 if (!dev->fs_hcnt || !dev->fs_lcnt) { 115 ic_clk = i2c_dw_clk_rate(dev); 116 dev->fs_hcnt = 117 + i2c_dw_scl_hcnt(dev, 118 + DW_IC_FS_SCL_HCNT, 119 + ic_clk, 120 600, /* tHD;STA = tHIGH = 0.6 us */ 121 sda_falling_time, 122 0, /* 0: DW default, 1: Ideal */ 123 0); /* No offset */ 124 dev->fs_lcnt = 125 + i2c_dw_scl_lcnt(dev, 126 + DW_IC_FS_SCL_LCNT, 127 + ic_clk, 128 1300, /* tLOW = 1.3 us */ 129 scl_falling_time, 130 0); /* No offset */ ··· 142 } else if (!dev->hs_hcnt || !dev->hs_lcnt) { 143 ic_clk = i2c_dw_clk_rate(dev); 144 dev->hs_hcnt = 145 + i2c_dw_scl_hcnt(dev, 146 + DW_IC_HS_SCL_HCNT, 147 + ic_clk, 148 160, /* tHIGH = 160 ns */ 149 sda_falling_time, 150 0, /* DW default */ 151 0); /* No offset */ 152 dev->hs_lcnt = 153 + i2c_dw_scl_lcnt(dev, 154 + DW_IC_HS_SCL_LCNT, 155 + ic_clk, 156 320, /* tLOW = 320 ns */ 157 scl_falling_time, 158 0); /* No offset */ ··· 931 init_completion(&dev->cmd_complete); 932 933 dev->init = i2c_dw_init_master; 934 935 ret = i2c_dw_init_regmap(dev); 936 if (ret) ··· 1021 1022 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus master adapter"); 1023 MODULE_LICENSE("GPL"); 1024 + MODULE_IMPORT_NS(I2C_DW_COMMON);
+16 -72
drivers/i2c/busses/i2c-designware-pcidrv.c
··· 9 * Copyright (C) 2009 Provigent Ltd. 10 * Copyright (C) 2011, 2015, 2016 Intel Corporation. 11 */ 12 - #include <linux/acpi.h> 13 #include <linux/delay.h> 14 #include <linux/err.h> 15 #include <linux/errno.h> ··· 18 #include <linux/kernel.h> 19 #include <linux/module.h> 20 #include <linux/pci.h> 21 #include <linux/pm_runtime.h> 22 #include <linux/power_supply.h> 23 #include <linux/sched.h> ··· 102 103 static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) 104 { 105 - struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev); 106 107 switch (pdev->device) { 108 case 0x0817: ··· 152 153 static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c) 154 { 155 - struct dw_i2c_dev *dev = dev_get_drvdata(&pdev->dev); 156 157 dev->flags |= MODEL_AMD_NAVI_GPU | ACCESS_POLLING; 158 dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; ··· 194 }, 195 }; 196 197 - static int __maybe_unused i2c_dw_pci_runtime_suspend(struct device *dev) 198 - { 199 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 200 - 201 - i_dev->disable(i_dev); 202 - return 0; 203 - } 204 - 205 - static int __maybe_unused i2c_dw_pci_suspend(struct device *dev) 206 - { 207 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 208 - 209 - i2c_mark_adapter_suspended(&i_dev->adapter); 210 - 211 - return i2c_dw_pci_runtime_suspend(dev); 212 - } 213 - 214 - static int __maybe_unused i2c_dw_pci_runtime_resume(struct device *dev) 215 - { 216 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 217 - 218 - return i_dev->init(i_dev); 219 - } 220 - 221 - static int __maybe_unused i2c_dw_pci_resume(struct device *dev) 222 - { 223 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 224 - int ret; 225 - 226 - ret = i2c_dw_pci_runtime_resume(dev); 227 - 228 - i2c_mark_adapter_resumed(&i_dev->adapter); 229 - 230 - return ret; 231 - } 232 - 233 - static const struct dev_pm_ops i2c_dw_pm_ops = { 234 - SET_SYSTEM_SLEEP_PM_OPS(i2c_dw_pci_suspend, i2c_dw_pci_resume) 235 - SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL) 236 - }; 237 - 238 static const struct property_entry dgpu_properties[] = { 239 /* USB-C doesn't power the system */ 240 PROPERTY_ENTRY_U8("scope", POWER_SUPPLY_SCOPE_DEVICE), ··· 212 int r; 213 struct dw_pci_controller *controller; 214 struct dw_scl_sda_cfg *cfg; 215 - struct i2c_timings *t; 216 217 if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) 218 return dev_err_probe(&pdev->dev, -EINVAL, ··· 246 dev->irq = pci_irq_vector(pdev, 0); 247 dev->flags |= controller->flags; 248 249 - t = &dev->timings; 250 - i2c_parse_fw_timings(&pdev->dev, t, false); 251 - 252 pci_set_drvdata(pdev, dev); 253 254 if (controller->setup) { 255 r = controller->setup(pdev, controller); 256 - if (r) { 257 - pci_free_irq_vectors(pdev); 258 return r; 259 - } 260 } 261 262 - i2c_dw_adjust_bus_speed(dev); 263 - 264 - if (has_acpi_companion(&pdev->dev)) 265 - i2c_dw_acpi_configure(&pdev->dev); 266 - 267 - r = i2c_dw_validate_speed(dev); 268 - if (r) { 269 - pci_free_irq_vectors(pdev); 270 return r; 271 - } 272 273 i2c_dw_configure(dev); 274 ··· 272 adap = &dev->adapter; 273 adap->owner = THIS_MODULE; 274 adap->class = 0; 275 - ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); 276 adap->nr = controller->bus_num; 277 278 r = i2c_dw_probe(dev); 279 - if (r) { 280 - pci_free_irq_vectors(pdev); 281 return r; 282 - } 283 284 if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { 285 dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node); ··· 297 { 298 struct dw_i2c_dev *dev = pci_get_drvdata(pdev); 299 300 - dev->disable(dev); 301 pm_runtime_forbid(&pdev->dev); 302 pm_runtime_get_noresume(&pdev->dev); 303 304 i2c_del_adapter(&dev->adapter); 305 - devm_free_irq(&pdev->dev, dev->irq, dev); 306 - pci_free_irq_vectors(pdev); 307 } 308 309 - static const struct pci_device_id i2_designware_pci_ids[] = { 310 /* Medfield */ 311 { PCI_VDEVICE(INTEL, 0x0817), medfield }, 312 { PCI_VDEVICE(INTEL, 0x0818), medfield }, ··· 351 { PCI_VDEVICE(ATI, 0x73c4), navi_amd }, 352 { PCI_VDEVICE(ATI, 0x7444), navi_amd }, 353 { PCI_VDEVICE(ATI, 0x7464), navi_amd }, 354 - { 0,} 355 }; 356 - MODULE_DEVICE_TABLE(pci, i2_designware_pci_ids); 357 358 static struct pci_driver dw_i2c_driver = { 359 .name = DRIVER_NAME, 360 - .id_table = i2_designware_pci_ids, 361 .probe = i2c_dw_pci_probe, 362 .remove = i2c_dw_pci_remove, 363 .driver = { 364 - .pm = &i2c_dw_pm_ops, 365 }, 366 }; 367 module_pci_driver(dw_i2c_driver); 368 369 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 370 MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); 371 MODULE_LICENSE("GPL");
··· 9 * Copyright (C) 2009 Provigent Ltd. 10 * Copyright (C) 2011, 2015, 2016 Intel Corporation. 11 */ 12 #include <linux/delay.h> 13 #include <linux/err.h> 14 #include <linux/errno.h> ··· 19 #include <linux/kernel.h> 20 #include <linux/module.h> 21 #include <linux/pci.h> 22 + #include <linux/pm.h> 23 #include <linux/pm_runtime.h> 24 #include <linux/power_supply.h> 25 #include <linux/sched.h> ··· 102 103 static int mfld_setup(struct pci_dev *pdev, struct dw_pci_controller *c) 104 { 105 + struct dw_i2c_dev *dev = pci_get_drvdata(pdev); 106 107 switch (pdev->device) { 108 case 0x0817: ··· 152 153 static int navi_amd_setup(struct pci_dev *pdev, struct dw_pci_controller *c) 154 { 155 + struct dw_i2c_dev *dev = pci_get_drvdata(pdev); 156 157 dev->flags |= MODEL_AMD_NAVI_GPU | ACCESS_POLLING; 158 dev->timings.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ; ··· 194 }, 195 }; 196 197 static const struct property_entry dgpu_properties[] = { 198 /* USB-C doesn't power the system */ 199 PROPERTY_ENTRY_U8("scope", POWER_SUPPLY_SCOPE_DEVICE), ··· 253 int r; 254 struct dw_pci_controller *controller; 255 struct dw_scl_sda_cfg *cfg; 256 257 if (id->driver_data >= ARRAY_SIZE(dw_pci_controllers)) 258 return dev_err_probe(&pdev->dev, -EINVAL, ··· 288 dev->irq = pci_irq_vector(pdev, 0); 289 dev->flags |= controller->flags; 290 291 pci_set_drvdata(pdev, dev); 292 293 if (controller->setup) { 294 r = controller->setup(pdev, controller); 295 + if (r) 296 return r; 297 } 298 299 + r = i2c_dw_fw_parse_and_configure(dev); 300 + if (r) 301 return r; 302 303 i2c_dw_configure(dev); 304 ··· 326 adap = &dev->adapter; 327 adap->owner = THIS_MODULE; 328 adap->class = 0; 329 adap->nr = controller->bus_num; 330 331 r = i2c_dw_probe(dev); 332 + if (r) 333 return r; 334 335 if ((dev->flags & MODEL_MASK) == MODEL_AMD_NAVI_GPU) { 336 dev->slave = i2c_new_ccgx_ucsi(&dev->adapter, dev->irq, &dgpu_node); ··· 354 { 355 struct dw_i2c_dev *dev = pci_get_drvdata(pdev); 356 357 + i2c_dw_disable(dev); 358 + 359 pm_runtime_forbid(&pdev->dev); 360 pm_runtime_get_noresume(&pdev->dev); 361 362 i2c_del_adapter(&dev->adapter); 363 } 364 365 + static const struct pci_device_id i2c_designware_pci_ids[] = { 366 /* Medfield */ 367 { PCI_VDEVICE(INTEL, 0x0817), medfield }, 368 { PCI_VDEVICE(INTEL, 0x0818), medfield }, ··· 409 { PCI_VDEVICE(ATI, 0x73c4), navi_amd }, 410 { PCI_VDEVICE(ATI, 0x7444), navi_amd }, 411 { PCI_VDEVICE(ATI, 0x7464), navi_amd }, 412 + {} 413 }; 414 + MODULE_DEVICE_TABLE(pci, i2c_designware_pci_ids); 415 416 static struct pci_driver dw_i2c_driver = { 417 .name = DRIVER_NAME, 418 .probe = i2c_dw_pci_probe, 419 .remove = i2c_dw_pci_remove, 420 .driver = { 421 + .pm = pm_ptr(&i2c_dw_dev_pm_ops), 422 }, 423 + .id_table = i2c_designware_pci_ids, 424 }; 425 module_pci_driver(dw_i2c_driver); 426 427 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 428 MODULE_DESCRIPTION("Synopsys DesignWare PCI I2C bus adapter"); 429 MODULE_LICENSE("GPL"); 430 + MODULE_IMPORT_NS(I2C_DW); 431 + MODULE_IMPORT_NS(I2C_DW_COMMON);
+36 -150
drivers/i2c/busses/i2c-designware-platdrv.c
··· 8 * Copyright (C) 2007 MontaVista Software Inc. 9 * Copyright (C) 2009 Provigent Ltd. 10 */ 11 - #include <linux/acpi.h> 12 #include <linux/clk-provider.h> 13 #include <linux/clk.h> 14 #include <linux/delay.h> ··· 20 #include <linux/kernel.h> 21 #include <linux/mfd/syscon.h> 22 #include <linux/module.h> 23 - #include <linux/of.h> 24 #include <linux/platform_device.h> 25 #include <linux/pm.h> 26 #include <linux/pm_runtime.h> ··· 28 #include <linux/reset.h> 29 #include <linux/sched.h> 30 #include <linux/slab.h> 31 - #include <linux/suspend.h> 32 #include <linux/units.h> 33 34 #include "i2c-designware-core.h" ··· 36 { 37 return clk_get_rate(dev->clk) / KILO; 38 } 39 - 40 - #ifdef CONFIG_ACPI 41 - static const struct acpi_device_id dw_i2c_acpi_match[] = { 42 - { "INT33C2", 0 }, 43 - { "INT33C3", 0 }, 44 - { "INT3432", 0 }, 45 - { "INT3433", 0 }, 46 - { "INTC10EF", 0 }, 47 - { "80860F41", ACCESS_NO_IRQ_SUSPEND }, 48 - { "808622C1", ACCESS_NO_IRQ_SUSPEND }, 49 - { "AMD0010", ACCESS_INTR_MASK }, 50 - { "AMDI0010", ACCESS_INTR_MASK }, 51 - { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE }, 52 - { "AMDI0510", 0 }, 53 - { "APMC0D0F", 0 }, 54 - { "HISI02A1", 0 }, 55 - { "HISI02A2", 0 }, 56 - { "HISI02A3", 0 }, 57 - { "HYGO0010", ACCESS_INTR_MASK }, 58 - { } 59 - }; 60 - MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); 61 - #endif 62 63 #ifdef CONFIG_OF 64 #define BT1_I2C_CTL 0x100 ··· 94 dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg); 95 return PTR_ERR_OR_ZERO(dev->map); 96 } 97 - 98 - #define MSCC_ICPU_CFG_TWI_DELAY 0x0 99 - #define MSCC_ICPU_CFG_TWI_DELAY_ENABLE BIT(0) 100 - #define MSCC_ICPU_CFG_TWI_SPIKE_FILTER 0x4 101 - 102 - static int mscc_twi_set_sda_hold_time(struct dw_i2c_dev *dev) 103 - { 104 - writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE, 105 - dev->ext + MSCC_ICPU_CFG_TWI_DELAY); 106 - 107 - return 0; 108 - } 109 - 110 - static int dw_i2c_of_configure(struct platform_device *pdev) 111 - { 112 - struct dw_i2c_dev *dev = platform_get_drvdata(pdev); 113 - 114 - switch (dev->flags & MODEL_MASK) { 115 - case MODEL_MSCC_OCELOT: 116 - dev->ext = devm_platform_ioremap_resource(pdev, 1); 117 - if (!IS_ERR(dev->ext)) 118 - dev->set_sda_hold_time = mscc_twi_set_sda_hold_time; 119 - break; 120 - default: 121 - break; 122 - } 123 - 124 - return 0; 125 - } 126 - 127 - static const struct of_device_id dw_i2c_of_match[] = { 128 - { .compatible = "snps,designware-i2c", }, 129 - { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT }, 130 - { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 }, 131 - {}, 132 - }; 133 - MODULE_DEVICE_TABLE(of, dw_i2c_of_match); 134 #else 135 static int bt1_i2c_request_regs(struct dw_i2c_dev *dev) 136 - { 137 - return -ENODEV; 138 - } 139 - 140 - static inline int dw_i2c_of_configure(struct platform_device *pdev) 141 { 142 return -ENODEV; 143 } ··· 170 int i = 0; 171 int ret; 172 173 - ptr = i2c_dw_semaphore_cb_table; 174 - 175 dev->semaphore_idx = -1; 176 177 - while (ptr->probe) { 178 ret = ptr->probe(dev); 179 if (ret) { 180 /* ··· 184 return ret; 185 186 i++; 187 - ptr++; 188 continue; 189 } 190 ··· 207 { 208 struct i2c_adapter *adap; 209 struct dw_i2c_dev *dev; 210 - struct i2c_timings *t; 211 int irq, ret; 212 213 irq = platform_get_irq(pdev, 0); ··· 235 236 reset_control_deassert(dev->rst); 237 238 - t = &dev->timings; 239 - i2c_parse_fw_timings(&pdev->dev, t, false); 240 - 241 - i2c_dw_adjust_bus_speed(dev); 242 - 243 - if (pdev->dev.of_node) 244 - dw_i2c_of_configure(pdev); 245 - 246 - if (has_acpi_companion(&pdev->dev)) 247 - i2c_dw_acpi_configure(&pdev->dev); 248 - 249 - ret = i2c_dw_validate_speed(dev); 250 if (ret) 251 goto exit_reset; 252 ··· 263 goto exit_reset; 264 265 if (dev->clk) { 266 u64 clk_khz; 267 268 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; ··· 278 adap->owner = THIS_MODULE; 279 adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ? 280 I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED; 281 - ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); 282 - adap->dev.of_node = pdev->dev.of_node; 283 adap->nr = -1; 284 285 if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { ··· 324 325 i2c_del_adapter(&dev->adapter); 326 327 - dev->disable(dev); 328 329 pm_runtime_dont_use_autosuspend(&pdev->dev); 330 pm_runtime_put_sync(&pdev->dev); ··· 335 reset_control_assert(dev->rst); 336 } 337 338 - static int dw_i2c_plat_prepare(struct device *dev) 339 - { 340 - /* 341 - * If the ACPI companion device object is present for this device, it 342 - * may be accessed during suspend and resume of other devices via I2C 343 - * operation regions, so tell the PM core and middle layers to avoid 344 - * skipping system suspend/resume callbacks for it in that case. 345 - */ 346 - return !has_acpi_companion(dev); 347 - } 348 - 349 - static int dw_i2c_plat_runtime_suspend(struct device *dev) 350 - { 351 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 352 - 353 - if (i_dev->shared_with_punit) 354 - return 0; 355 - 356 - i_dev->disable(i_dev); 357 - i2c_dw_prepare_clk(i_dev, false); 358 - 359 - return 0; 360 - } 361 - 362 - static int dw_i2c_plat_suspend(struct device *dev) 363 - { 364 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 365 - 366 - i2c_mark_adapter_suspended(&i_dev->adapter); 367 - 368 - return dw_i2c_plat_runtime_suspend(dev); 369 - } 370 - 371 - static int dw_i2c_plat_runtime_resume(struct device *dev) 372 - { 373 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 374 - 375 - if (!i_dev->shared_with_punit) 376 - i2c_dw_prepare_clk(i_dev, true); 377 - 378 - i_dev->init(i_dev); 379 - 380 - return 0; 381 - } 382 - 383 - static int dw_i2c_plat_resume(struct device *dev) 384 - { 385 - struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 386 - 387 - dw_i2c_plat_runtime_resume(dev); 388 - i2c_mark_adapter_resumed(&i_dev->adapter); 389 - 390 - return 0; 391 - } 392 - 393 - static const struct dev_pm_ops dw_i2c_dev_pm_ops = { 394 - .prepare = pm_sleep_ptr(dw_i2c_plat_prepare), 395 - LATE_SYSTEM_SLEEP_PM_OPS(dw_i2c_plat_suspend, dw_i2c_plat_resume) 396 - RUNTIME_PM_OPS(dw_i2c_plat_runtime_suspend, dw_i2c_plat_runtime_resume, NULL) 397 }; 398 399 static const struct platform_device_id dw_i2c_platform_ids[] = { 400 { "i2c_designware" }, ··· 375 .remove_new = dw_i2c_plat_remove, 376 .driver = { 377 .name = "i2c_designware", 378 - .of_match_table = of_match_ptr(dw_i2c_of_match), 379 - .acpi_match_table = ACPI_PTR(dw_i2c_acpi_match), 380 - .pm = pm_ptr(&dw_i2c_dev_pm_ops), 381 }, 382 .id_table = dw_i2c_platform_ids, 383 }; ··· 397 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 398 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter"); 399 MODULE_LICENSE("GPL");
··· 8 * Copyright (C) 2007 MontaVista Software Inc. 9 * Copyright (C) 2009 Provigent Ltd. 10 */ 11 #include <linux/clk-provider.h> 12 #include <linux/clk.h> 13 #include <linux/delay.h> ··· 21 #include <linux/kernel.h> 22 #include <linux/mfd/syscon.h> 23 #include <linux/module.h> 24 #include <linux/platform_device.h> 25 #include <linux/pm.h> 26 #include <linux/pm_runtime.h> ··· 30 #include <linux/reset.h> 31 #include <linux/sched.h> 32 #include <linux/slab.h> 33 #include <linux/units.h> 34 35 #include "i2c-designware-core.h" ··· 39 { 40 return clk_get_rate(dev->clk) / KILO; 41 } 42 43 #ifdef CONFIG_OF 44 #define BT1_I2C_CTL 0x100 ··· 120 dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg); 121 return PTR_ERR_OR_ZERO(dev->map); 122 } 123 #else 124 static int bt1_i2c_request_regs(struct dw_i2c_dev *dev) 125 { 126 return -ENODEV; 127 } ··· 238 int i = 0; 239 int ret; 240 241 dev->semaphore_idx = -1; 242 243 + for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) { 244 ret = ptr->probe(dev); 245 if (ret) { 246 /* ··· 254 return ret; 255 256 i++; 257 continue; 258 } 259 ··· 278 { 279 struct i2c_adapter *adap; 280 struct dw_i2c_dev *dev; 281 int irq, ret; 282 283 irq = platform_get_irq(pdev, 0); ··· 307 308 reset_control_deassert(dev->rst); 309 310 + ret = i2c_dw_fw_parse_and_configure(dev); 311 if (ret) 312 goto exit_reset; 313 ··· 346 goto exit_reset; 347 348 if (dev->clk) { 349 + struct i2c_timings *t = &dev->timings; 350 u64 clk_khz; 351 352 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; ··· 360 adap->owner = THIS_MODULE; 361 adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ? 362 I2C_CLASS_HWMON : I2C_CLASS_DEPRECATED; 363 adap->nr = -1; 364 365 if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { ··· 408 409 i2c_del_adapter(&dev->adapter); 410 411 + i2c_dw_disable(dev); 412 413 pm_runtime_dont_use_autosuspend(&pdev->dev); 414 pm_runtime_put_sync(&pdev->dev); ··· 419 reset_control_assert(dev->rst); 420 } 421 422 + static const struct of_device_id dw_i2c_of_match[] = { 423 + { .compatible = "snps,designware-i2c", }, 424 + { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT }, 425 + { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 }, 426 + {} 427 }; 428 + MODULE_DEVICE_TABLE(of, dw_i2c_of_match); 429 + 430 + static const struct acpi_device_id dw_i2c_acpi_match[] = { 431 + { "80860F41", ACCESS_NO_IRQ_SUSPEND }, 432 + { "808622C1", ACCESS_NO_IRQ_SUSPEND }, 433 + { "AMD0010", ACCESS_INTR_MASK }, 434 + { "AMDI0010", ACCESS_INTR_MASK }, 435 + { "AMDI0019", ACCESS_INTR_MASK | ARBITRATION_SEMAPHORE }, 436 + { "AMDI0510", 0 }, 437 + { "APMC0D0F", 0 }, 438 + { "HISI02A1", 0 }, 439 + { "HISI02A2", 0 }, 440 + { "HISI02A3", 0 }, 441 + { "HYGO0010", ACCESS_INTR_MASK }, 442 + { "INT33C2", 0 }, 443 + { "INT33C3", 0 }, 444 + { "INT3432", 0 }, 445 + { "INT3433", 0 }, 446 + { "INTC10EF", 0 }, 447 + {} 448 + }; 449 + MODULE_DEVICE_TABLE(acpi, dw_i2c_acpi_match); 450 451 static const struct platform_device_id dw_i2c_platform_ids[] = { 452 { "i2c_designware" }, ··· 491 .remove_new = dw_i2c_plat_remove, 492 .driver = { 493 .name = "i2c_designware", 494 + .of_match_table = dw_i2c_of_match, 495 + .acpi_match_table = dw_i2c_acpi_match, 496 + .pm = pm_ptr(&i2c_dw_dev_pm_ops), 497 }, 498 .id_table = dw_i2c_platform_ids, 499 }; ··· 513 MODULE_AUTHOR("Baruch Siach <baruch@tkos.co.il>"); 514 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter"); 515 MODULE_LICENSE("GPL"); 516 + MODULE_IMPORT_NS(I2C_DW); 517 + MODULE_IMPORT_NS(I2C_DW_COMMON);
+4 -2
drivers/i2c/busses/i2c-designware-slave.c
··· 16 #include <linux/pm_runtime.h> 17 #include <linux/regmap.h> 18 19 #include "i2c-designware-core.h" 20 21 static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev) ··· 90 struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter); 91 92 regmap_write(dev->map, DW_IC_INTR_MASK, 0); 93 - dev->disable(dev); 94 synchronize_irq(dev->irq); 95 dev->slave = NULL; 96 pm_runtime_put(dev->dev); ··· 237 int ret; 238 239 dev->init = i2c_dw_init_slave; 240 - dev->disable = i2c_dw_disable; 241 242 ret = i2c_dw_init_regmap(dev); 243 if (ret) ··· 280 MODULE_AUTHOR("Luis Oliveira <lolivei@synopsys.com>"); 281 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus slave adapter"); 282 MODULE_LICENSE("GPL v2");
··· 16 #include <linux/pm_runtime.h> 17 #include <linux/regmap.h> 18 19 + #define DEFAULT_SYMBOL_NAMESPACE I2C_DW 20 + 21 #include "i2c-designware-core.h" 22 23 static void i2c_dw_configure_fifo_slave(struct dw_i2c_dev *dev) ··· 88 struct dw_i2c_dev *dev = i2c_get_adapdata(slave->adapter); 89 90 regmap_write(dev->map, DW_IC_INTR_MASK, 0); 91 + i2c_dw_disable(dev); 92 synchronize_irq(dev->irq); 93 dev->slave = NULL; 94 pm_runtime_put(dev->dev); ··· 235 int ret; 236 237 dev->init = i2c_dw_init_slave; 238 239 ret = i2c_dw_init_regmap(dev); 240 if (ret) ··· 279 MODULE_AUTHOR("Luis Oliveira <lolivei@synopsys.com>"); 280 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus slave adapter"); 281 MODULE_LICENSE("GPL v2"); 282 + MODULE_IMPORT_NS(I2C_DW_COMMON);
+1 -1
drivers/i2c/busses/i2c-digicolor.c
··· 357 358 static const struct of_device_id dc_i2c_match[] = { 359 { .compatible = "cnxt,cx92755-i2c" }, 360 - { }, 361 }; 362 MODULE_DEVICE_TABLE(of, dc_i2c_match); 363
··· 357 358 static const struct of_device_id dc_i2c_match[] = { 359 { .compatible = "cnxt,cx92755-i2c" }, 360 + { } 361 }; 362 MODULE_DEVICE_TABLE(of, dc_i2c_match); 363
+8 -17
drivers/i2c/busses/i2c-emev2.c
··· 67 void __iomem *base; 68 struct i2c_adapter adap; 69 struct completion msg_done; 70 - struct clk *sclk; 71 struct i2c_client *slave; 72 int irq; 73 }; ··· 360 static int em_i2c_probe(struct platform_device *pdev) 361 { 362 struct em_i2c_device *priv; 363 int ret; 364 365 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ··· 373 374 strscpy(priv->adap.name, "EMEV2 I2C", sizeof(priv->adap.name)); 375 376 - priv->sclk = devm_clk_get(&pdev->dev, "sclk"); 377 - if (IS_ERR(priv->sclk)) 378 - return PTR_ERR(priv->sclk); 379 - 380 - ret = clk_prepare_enable(priv->sclk); 381 - if (ret) 382 - return ret; 383 384 priv->adap.timeout = msecs_to_jiffies(100); 385 priv->adap.retries = 5; ··· 393 394 ret = platform_get_irq(pdev, 0); 395 if (ret < 0) 396 - goto err_clk; 397 priv->irq = ret; 398 ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0, 399 "em_i2c", priv); 400 if (ret) 401 - goto err_clk; 402 403 ret = i2c_add_adapter(&priv->adap); 404 - 405 if (ret) 406 - goto err_clk; 407 408 dev_info(&pdev->dev, "Added i2c controller %d, irq %d\n", priv->adap.nr, 409 priv->irq); 410 411 return 0; 412 - 413 - err_clk: 414 - clk_disable_unprepare(priv->sclk); 415 - return ret; 416 } 417 418 static void em_i2c_remove(struct platform_device *dev) ··· 416 struct em_i2c_device *priv = platform_get_drvdata(dev); 417 418 i2c_del_adapter(&priv->adap); 419 - clk_disable_unprepare(priv->sclk); 420 } 421 422 static const struct of_device_id em_i2c_ids[] = {
··· 67 void __iomem *base; 68 struct i2c_adapter adap; 69 struct completion msg_done; 70 struct i2c_client *slave; 71 int irq; 72 }; ··· 361 static int em_i2c_probe(struct platform_device *pdev) 362 { 363 struct em_i2c_device *priv; 364 + struct clk *sclk; 365 int ret; 366 367 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); ··· 373 374 strscpy(priv->adap.name, "EMEV2 I2C", sizeof(priv->adap.name)); 375 376 + sclk = devm_clk_get_enabled(&pdev->dev, "sclk"); 377 + if (IS_ERR(sclk)) 378 + return PTR_ERR(sclk); 379 380 priv->adap.timeout = msecs_to_jiffies(100); 381 priv->adap.retries = 5; ··· 397 398 ret = platform_get_irq(pdev, 0); 399 if (ret < 0) 400 + return ret; 401 priv->irq = ret; 402 + 403 ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0, 404 "em_i2c", priv); 405 if (ret) 406 + return ret; 407 408 ret = i2c_add_adapter(&priv->adap); 409 if (ret) 410 + return ret; 411 412 dev_info(&pdev->dev, "Added i2c controller %d, irq %d\n", priv->adap.nr, 413 priv->irq); 414 415 return 0; 416 } 417 418 static void em_i2c_remove(struct platform_device *dev) ··· 424 struct em_i2c_device *priv = platform_get_drvdata(dev); 425 426 i2c_del_adapter(&priv->adap); 427 } 428 429 static const struct of_device_id em_i2c_ids[] = {
+8 -1
drivers/i2c/busses/i2c-i801.c
··· 1763 1764 i801_add_tco(priv); 1765 1766 snprintf(priv->adapter.name, sizeof(priv->adapter.name), 1767 - "SMBus I801 adapter at %04lx", priv->smba); 1768 err = i2c_add_adapter(&priv->adapter); 1769 if (err) { 1770 platform_device_unregister(priv->tco_pdev);
··· 1763 1764 i801_add_tco(priv); 1765 1766 + /* 1767 + * adapter.name is used by platform code to find the main I801 adapter 1768 + * to instantiante i2c_clients, do not change. 1769 + */ 1770 snprintf(priv->adapter.name, sizeof(priv->adapter.name), 1771 + "SMBus %s adapter at %04lx", 1772 + (priv->features & FEATURE_IDF) ? "I801 IDF" : "I801", 1773 + priv->smba); 1774 + 1775 err = i2c_add_adapter(&priv->adapter); 1776 if (err) { 1777 platform_device_unregister(priv->tco_pdev);
+1 -1
drivers/i2c/busses/i2c-imx-lpi2c.c
··· 559 560 static const struct of_device_id lpi2c_imx_of_match[] = { 561 { .compatible = "fsl,imx7ulp-lpi2c" }, 562 - { }, 563 }; 564 MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); 565
··· 559 560 static const struct of_device_id lpi2c_imx_of_match[] = { 561 { .compatible = "fsl,imx7ulp-lpi2c" }, 562 + { } 563 }; 564 MODULE_DEVICE_TABLE(of, lpi2c_imx_of_match); 565
+5 -6
drivers/i2c/busses/i2c-imx.c
··· 687 i2c_imx_bus_busy(i2c_imx, 0, atomic); 688 689 /* Disable I2C controller */ 690 - temp = i2c_imx->hwdata->i2cr_ien_opcode ^ I2CR_IEN, 691 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); 692 } 693 ··· 1549 pm_runtime_disable(&pdev->dev); 1550 } 1551 1552 - static int __maybe_unused i2c_imx_runtime_suspend(struct device *dev) 1553 { 1554 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); 1555 ··· 1558 return 0; 1559 } 1560 1561 - static int __maybe_unused i2c_imx_runtime_resume(struct device *dev) 1562 { 1563 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); 1564 int ret; ··· 1571 } 1572 1573 static const struct dev_pm_ops i2c_imx_pm_ops = { 1574 - SET_RUNTIME_PM_OPS(i2c_imx_runtime_suspend, 1575 - i2c_imx_runtime_resume, NULL) 1576 }; 1577 1578 static struct platform_driver i2c_imx_driver = { ··· 1579 .remove_new = i2c_imx_remove, 1580 .driver = { 1581 .name = DRIVER_NAME, 1582 - .pm = &i2c_imx_pm_ops, 1583 .of_match_table = i2c_imx_dt_ids, 1584 .acpi_match_table = i2c_imx_acpi_ids, 1585 },
··· 687 i2c_imx_bus_busy(i2c_imx, 0, atomic); 688 689 /* Disable I2C controller */ 690 + temp = i2c_imx->hwdata->i2cr_ien_opcode ^ I2CR_IEN; 691 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR); 692 } 693 ··· 1549 pm_runtime_disable(&pdev->dev); 1550 } 1551 1552 + static int i2c_imx_runtime_suspend(struct device *dev) 1553 { 1554 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); 1555 ··· 1558 return 0; 1559 } 1560 1561 + static int i2c_imx_runtime_resume(struct device *dev) 1562 { 1563 struct imx_i2c_struct *i2c_imx = dev_get_drvdata(dev); 1564 int ret; ··· 1571 } 1572 1573 static const struct dev_pm_ops i2c_imx_pm_ops = { 1574 + RUNTIME_PM_OPS(i2c_imx_runtime_suspend, i2c_imx_runtime_resume, NULL) 1575 }; 1576 1577 static struct platform_driver i2c_imx_driver = { ··· 1580 .remove_new = i2c_imx_remove, 1581 .driver = { 1582 .name = DRIVER_NAME, 1583 + .pm = pm_ptr(&i2c_imx_pm_ops), 1584 .of_match_table = i2c_imx_dt_ids, 1585 .acpi_match_table = i2c_imx_acpi_ids, 1586 },
+10
drivers/i2c/busses/i2c-ismt.c
··· 382 } 383 384 /** 385 * ismt_access() - process an SMBus command 386 * @adap: the i2c host adapter 387 * @addr: address of the i2c/SMBus target ··· 632 dma_unmap_single(dev, dma_addr, dma_size, dma_direction); 633 634 if (unlikely(!time_left)) { 635 ret = -ETIMEDOUT; 636 goto out; 637 }
··· 382 } 383 384 /** 385 + * ismt_kill_transaction() - kill current transaction 386 + * @priv: iSMT private data 387 + */ 388 + static void ismt_kill_transaction(struct ismt_priv *priv) 389 + { 390 + writel(ISMT_GCTRL_KILL, priv->smba + ISMT_GR_GCTRL); 391 + } 392 + 393 + /** 394 * ismt_access() - process an SMBus command 395 * @adap: the i2c host adapter 396 * @addr: address of the i2c/SMBus target ··· 623 dma_unmap_single(dev, dma_addr, dma_size, dma_direction); 624 625 if (unlikely(!time_left)) { 626 + ismt_kill_transaction(priv); 627 ret = -ETIMEDOUT; 628 goto out; 629 }
+7 -15
drivers/i2c/busses/i2c-jz4780.c
··· 792 793 platform_set_drvdata(pdev, i2c); 794 795 - i2c->clk = devm_clk_get(&pdev->dev, NULL); 796 if (IS_ERR(i2c->clk)) 797 return PTR_ERR(i2c->clk); 798 - 799 - ret = clk_prepare_enable(i2c->clk); 800 - if (ret) 801 - return ret; 802 803 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 804 &clk_freq); 805 if (ret) { 806 dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); 807 - goto err; 808 } 809 810 i2c->speed = clk_freq / 1000; 811 if (i2c->speed == 0) { 812 ret = -EINVAL; 813 dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); 814 - goto err; 815 } 816 jz4780_i2c_set_speed(i2c); 817 ··· 823 824 ret = platform_get_irq(pdev, 0); 825 if (ret < 0) 826 - goto err; 827 i2c->irq = ret; 828 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, 829 dev_name(&pdev->dev), i2c); 830 if (ret) 831 - goto err; 832 833 ret = i2c_add_adapter(&i2c->adap); 834 if (ret < 0) 835 - goto err; 836 837 return 0; 838 - 839 - err: 840 - clk_disable_unprepare(i2c->clk); 841 - return ret; 842 } 843 844 static void jz4780_i2c_remove(struct platform_device *pdev) 845 { 846 struct jz4780_i2c *i2c = platform_get_drvdata(pdev); 847 848 - clk_disable_unprepare(i2c->clk); 849 i2c_del_adapter(&i2c->adap); 850 } 851
··· 792 793 platform_set_drvdata(pdev, i2c); 794 795 + i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL); 796 if (IS_ERR(i2c->clk)) 797 return PTR_ERR(i2c->clk); 798 799 ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency", 800 &clk_freq); 801 if (ret) { 802 dev_err(&pdev->dev, "clock-frequency not specified in DT\n"); 803 + return ret; 804 } 805 806 i2c->speed = clk_freq / 1000; 807 if (i2c->speed == 0) { 808 ret = -EINVAL; 809 dev_err(&pdev->dev, "clock-frequency minimum is 1000\n"); 810 + return ret; 811 } 812 jz4780_i2c_set_speed(i2c); 813 ··· 827 828 ret = platform_get_irq(pdev, 0); 829 if (ret < 0) 830 + return ret; 831 i2c->irq = ret; 832 + 833 ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0, 834 dev_name(&pdev->dev), i2c); 835 if (ret) 836 + return ret; 837 838 ret = i2c_add_adapter(&i2c->adap); 839 if (ret < 0) 840 + return ret; 841 842 return 0; 843 } 844 845 static void jz4780_i2c_remove(struct platform_device *pdev) 846 { 847 struct jz4780_i2c *i2c = platform_get_drvdata(pdev); 848 849 i2c_del_adapter(&i2c->adap); 850 } 851
+598
drivers/i2c/busses/i2c-keba.c
···
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) KEBA Industrial Automation Gmbh 2024 4 + * 5 + * Driver for KEBA I2C controller FPGA IP core 6 + */ 7 + 8 + #include <linux/i2c.h> 9 + #include <linux/io.h> 10 + #include <linux/iopoll.h> 11 + #include <linux/module.h> 12 + #include <linux/misc/keba.h> 13 + 14 + #define KI2C "i2c-keba" 15 + 16 + #define KI2C_CAPABILITY_REG 0x02 17 + #define KI2C_CAPABILITY_CRYPTO 0x01 18 + #define KI2C_CAPABILITY_DC 0x02 19 + 20 + #define KI2C_CONTROL_REG 0x04 21 + #define KI2C_CONTROL_MEN 0x01 22 + #define KI2C_CONTROL_MSTA 0x02 23 + #define KI2C_CONTROL_RSTA 0x04 24 + #define KI2C_CONTROL_MTX 0x08 25 + #define KI2C_CONTROL_TXAK 0x10 26 + #define KI2C_CONTROL_DISABLE 0x00 27 + 28 + #define KI2C_CONTROL_DC_REG 0x05 29 + #define KI2C_CONTROL_DC_SDA 0x01 30 + #define KI2C_CONTROL_DC_SCL 0x02 31 + 32 + #define KI2C_STATUS_REG 0x08 33 + #define KI2C_STATUS_IN_USE 0x01 34 + #define KI2C_STATUS_ACK_CYC 0x02 35 + #define KI2C_STATUS_RXAK 0x04 36 + #define KI2C_STATUS_MCF 0x08 37 + 38 + #define KI2C_STATUS_DC_REG 0x09 39 + #define KI2C_STATUS_DC_SDA 0x01 40 + #define KI2C_STATUS_DC_SCL 0x02 41 + 42 + #define KI2C_DATA_REG 0x0c 43 + 44 + #define KI2C_INUSE_SLEEP_US (2 * USEC_PER_MSEC) 45 + #define KI2C_INUSE_TIMEOUT_US (10 * USEC_PER_SEC) 46 + 47 + #define KI2C_POLL_DELAY_US 5 48 + 49 + struct ki2c { 50 + struct keba_i2c_auxdev *auxdev; 51 + void __iomem *base; 52 + struct i2c_adapter adapter; 53 + 54 + struct i2c_client **client; 55 + int client_size; 56 + }; 57 + 58 + static int ki2c_inuse_lock(struct ki2c *ki2c) 59 + { 60 + u8 sts; 61 + int ret; 62 + 63 + /* 64 + * The I2C controller has an IN_USE bit for locking access to the 65 + * controller. This enables the use of I2C controller by other none 66 + * Linux processors. 67 + * 68 + * If the I2C controller is free, then the first read returns 69 + * IN_USE == 0. After that the I2C controller is locked and further 70 + * reads of IN_USE return 1. 71 + * 72 + * The I2C controller is unlocked by writing 1 into IN_USE. 73 + * 74 + * The IN_USE bit acts as a hardware semaphore for the I2C controller. 75 + * Poll for semaphore, but sleep while polling to free the CPU. 76 + */ 77 + ret = readb_poll_timeout(ki2c->base + KI2C_STATUS_REG, 78 + sts, (sts & KI2C_STATUS_IN_USE) == 0, 79 + KI2C_INUSE_SLEEP_US, KI2C_INUSE_TIMEOUT_US); 80 + if (ret) 81 + dev_err(&ki2c->auxdev->auxdev.dev, "%s err!\n", __func__); 82 + 83 + return ret; 84 + } 85 + 86 + static void ki2c_inuse_unlock(struct ki2c *ki2c) 87 + { 88 + /* unlock the controller by writing 1 into IN_USE */ 89 + iowrite8(KI2C_STATUS_IN_USE, ki2c->base + KI2C_STATUS_REG); 90 + } 91 + 92 + static int ki2c_wait_for_bit(void __iomem *addr, u8 mask, unsigned long timeout) 93 + { 94 + u8 val; 95 + 96 + return readb_poll_timeout(addr, val, (val & mask), KI2C_POLL_DELAY_US, 97 + jiffies_to_usecs(timeout)); 98 + } 99 + 100 + static int ki2c_wait_for_mcf(struct ki2c *ki2c) 101 + { 102 + return ki2c_wait_for_bit(ki2c->base + KI2C_STATUS_REG, KI2C_STATUS_MCF, 103 + ki2c->adapter.timeout); 104 + } 105 + 106 + static int ki2c_wait_for_data(struct ki2c *ki2c) 107 + { 108 + int ret; 109 + 110 + ret = ki2c_wait_for_mcf(ki2c); 111 + if (ret < 0) 112 + return ret; 113 + 114 + return ki2c_wait_for_bit(ki2c->base + KI2C_STATUS_REG, 115 + KI2C_STATUS_ACK_CYC, 116 + ki2c->adapter.timeout); 117 + } 118 + 119 + static int ki2c_wait_for_data_ack(struct ki2c *ki2c) 120 + { 121 + unsigned int reg; 122 + int ret; 123 + 124 + ret = ki2c_wait_for_data(ki2c); 125 + if (ret < 0) 126 + return ret; 127 + 128 + /* RXAK == 0 means ACK reveived */ 129 + reg = ioread8(ki2c->base + KI2C_STATUS_REG); 130 + if (reg & KI2C_STATUS_RXAK) 131 + return -EIO; 132 + 133 + return 0; 134 + } 135 + 136 + static int ki2c_has_capability(struct ki2c *ki2c, unsigned int cap) 137 + { 138 + unsigned int reg = ioread8(ki2c->base + KI2C_CAPABILITY_REG); 139 + 140 + return (reg & cap) != 0; 141 + } 142 + 143 + static int ki2c_get_scl(struct ki2c *ki2c) 144 + { 145 + unsigned int reg = ioread8(ki2c->base + KI2C_STATUS_DC_REG); 146 + 147 + /* capability KI2C_CAPABILITY_DC required */ 148 + return (reg & KI2C_STATUS_DC_SCL) != 0; 149 + } 150 + 151 + static int ki2c_get_sda(struct ki2c *ki2c) 152 + { 153 + unsigned int reg = ioread8(ki2c->base + KI2C_STATUS_DC_REG); 154 + 155 + /* capability KI2C_CAPABILITY_DC required */ 156 + return (reg & KI2C_STATUS_DC_SDA) != 0; 157 + } 158 + 159 + static void ki2c_set_scl(struct ki2c *ki2c, int val) 160 + { 161 + u8 control_dc; 162 + 163 + /* capability KI2C_CAPABILITY_DC and KI2C_CONTROL_MEN = 0 reqired */ 164 + control_dc = ioread8(ki2c->base + KI2C_CONTROL_DC_REG); 165 + if (val) 166 + control_dc |= KI2C_CONTROL_DC_SCL; 167 + else 168 + control_dc &= ~KI2C_CONTROL_DC_SCL; 169 + iowrite8(control_dc, ki2c->base + KI2C_CONTROL_DC_REG); 170 + } 171 + 172 + /* 173 + * Resetting bus bitwise is done by checking SDA and applying clock cycles as 174 + * long as SDA is low. 9 clock cycles are applied at most. 175 + * 176 + * Clock cycles are generated and udelay() determines the duration of clock 177 + * cycles. Generated clock rate is 100 KHz and so duration of both clock levels 178 + * is: delay in ns = (10^6 / 100) / 2 179 + */ 180 + #define KI2C_RECOVERY_CLK_CNT (9 * 2) 181 + #define KI2C_RECOVERY_UDELAY 5 182 + static int ki2c_reset_bus_bitwise(struct ki2c *ki2c) 183 + { 184 + int val = 1; 185 + int ret = 0; 186 + int i; 187 + 188 + /* disable I2C controller (MEN = 0) to get direct access to SCL/SDA */ 189 + iowrite8(0, ki2c->base + KI2C_CONTROL_REG); 190 + 191 + /* generate clock cycles */ 192 + ki2c_set_scl(ki2c, val); 193 + udelay(KI2C_RECOVERY_UDELAY); 194 + for (i = 0; i < KI2C_RECOVERY_CLK_CNT; i++) { 195 + if (val) { 196 + /* SCL shouldn't be low here */ 197 + if (!ki2c_get_scl(ki2c)) { 198 + dev_err(&ki2c->auxdev->auxdev.dev, 199 + "SCL is stuck low!\n"); 200 + ret = -EBUSY; 201 + break; 202 + } 203 + 204 + /* break if SDA is high */ 205 + if (ki2c_get_sda(ki2c)) 206 + break; 207 + } 208 + 209 + val = !val; 210 + ki2c_set_scl(ki2c, val); 211 + udelay(KI2C_RECOVERY_UDELAY); 212 + } 213 + 214 + if (!ki2c_get_sda(ki2c)) { 215 + dev_err(&ki2c->auxdev->auxdev.dev, "SDA is still low!\n"); 216 + ret = -EBUSY; 217 + } 218 + 219 + /* reenable controller */ 220 + iowrite8(KI2C_CONTROL_MEN, ki2c->base + KI2C_CONTROL_REG); 221 + 222 + return ret; 223 + } 224 + 225 + /* 226 + * Resetting bus bytewise is done by writing start bit, 9 data bits and stop 227 + * bit. 228 + * 229 + * This is not 100% safe. If target is an EEPROM and a write access was 230 + * interrupted during the ACK cycle, this approach might not be able to recover 231 + * the bus. The reason is, that after the 9 clock cycles the EEPROM will be in 232 + * ACK cycle again and will hold SDA low like it did before the start of the 233 + * routine. Furthermore the EEPROM might get written one additional byte with 234 + * 0xff into it. Thus, use bitwise approach whenever possible, especially when 235 + * EEPROMs are on the bus. 236 + */ 237 + static int ki2c_reset_bus_bytewise(struct ki2c *ki2c) 238 + { 239 + int ret; 240 + 241 + /* hold data line high for 9 clock cycles */ 242 + iowrite8(0xFF, ki2c->base + KI2C_DATA_REG); 243 + 244 + /* create start condition */ 245 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MTX | KI2C_CONTROL_MSTA | KI2C_CONTROL_TXAK, 246 + ki2c->base + KI2C_CONTROL_REG); 247 + ret = ki2c_wait_for_mcf(ki2c); 248 + if (ret < 0) { 249 + dev_err(&ki2c->auxdev->auxdev.dev, "Start condition failed\n"); 250 + 251 + return ret; 252 + } 253 + 254 + /* create stop condition */ 255 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MTX | KI2C_CONTROL_TXAK, 256 + ki2c->base + KI2C_CONTROL_REG); 257 + ret = ki2c_wait_for_mcf(ki2c); 258 + if (ret < 0) 259 + dev_err(&ki2c->auxdev->auxdev.dev, "Stop condition failed\n"); 260 + 261 + return ret; 262 + } 263 + 264 + static int ki2c_reset_bus(struct ki2c *ki2c) 265 + { 266 + int ret; 267 + 268 + ret = ki2c_inuse_lock(ki2c); 269 + if (ret < 0) 270 + return ret; 271 + 272 + /* 273 + * If the I2C controller is capable of direct control of SCL/SDA, then a 274 + * bitwise reset is used. Otherwise fall back to bytewise reset. 275 + */ 276 + if (ki2c_has_capability(ki2c, KI2C_CAPABILITY_DC)) 277 + ret = ki2c_reset_bus_bitwise(ki2c); 278 + else 279 + ret = ki2c_reset_bus_bytewise(ki2c); 280 + 281 + ki2c_inuse_unlock(ki2c); 282 + 283 + return ret; 284 + } 285 + 286 + static void ki2c_write_target_addr(struct ki2c *ki2c, struct i2c_msg *m) 287 + { 288 + u8 addr; 289 + 290 + addr = m->addr << 1; 291 + /* Bit 0 signals RD/WR */ 292 + if (m->flags & I2C_M_RD) 293 + addr |= 0x01; 294 + 295 + iowrite8(addr, ki2c->base + KI2C_DATA_REG); 296 + } 297 + 298 + static int ki2c_start_addr(struct ki2c *ki2c, struct i2c_msg *m) 299 + { 300 + int ret; 301 + 302 + /* 303 + * Store target address byte in the controller. This has to be done 304 + * before sending START condition. 305 + */ 306 + ki2c_write_target_addr(ki2c, m); 307 + 308 + /* enable controller for TX */ 309 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MTX, 310 + ki2c->base + KI2C_CONTROL_REG); 311 + 312 + /* send START condition and target address byte */ 313 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MTX | KI2C_CONTROL_MSTA, 314 + ki2c->base + KI2C_CONTROL_REG); 315 + 316 + ret = ki2c_wait_for_data_ack(ki2c); 317 + if (ret < 0) 318 + /* 319 + * For EEPROMs this is normal behavior during internal write 320 + * operation. 321 + */ 322 + dev_dbg(&ki2c->auxdev->auxdev.dev, 323 + "%s wait for ACK err at 0x%02x!\n", __func__, m->addr); 324 + 325 + return ret; 326 + } 327 + 328 + static int ki2c_repstart_addr(struct ki2c *ki2c, struct i2c_msg *m) 329 + { 330 + int ret; 331 + 332 + /* repeated start and write is not supported */ 333 + if ((m->flags & I2C_M_RD) == 0) { 334 + dev_err(&ki2c->auxdev->auxdev.dev, 335 + "Repeated start not supported for writes\n"); 336 + return -EINVAL; 337 + } 338 + 339 + /* send repeated start */ 340 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MSTA | KI2C_CONTROL_RSTA, 341 + ki2c->base + KI2C_CONTROL_REG); 342 + 343 + ret = ki2c_wait_for_mcf(ki2c); 344 + if (ret < 0) { 345 + dev_err(&ki2c->auxdev->auxdev.dev, 346 + "%s wait for MCF err at 0x%02x!\n", __func__, m->addr); 347 + return ret; 348 + } 349 + 350 + /* write target-address byte */ 351 + ki2c_write_target_addr(ki2c, m); 352 + 353 + ret = ki2c_wait_for_data_ack(ki2c); 354 + if (ret < 0) 355 + dev_err(&ki2c->auxdev->auxdev.dev, 356 + "%s wait for ACK err at 0x%02x!\n", __func__, m->addr); 357 + 358 + return ret; 359 + } 360 + 361 + static void ki2c_stop(struct ki2c *ki2c) 362 + { 363 + iowrite8(KI2C_CONTROL_MEN, ki2c->base + KI2C_CONTROL_REG); 364 + ki2c_wait_for_mcf(ki2c); 365 + } 366 + 367 + static int ki2c_write(struct ki2c *ki2c, const u8 *data, int len) 368 + { 369 + int ret; 370 + int i; 371 + 372 + for (i = 0; i < len; i++) { 373 + /* write data byte */ 374 + iowrite8(data[i], ki2c->base + KI2C_DATA_REG); 375 + 376 + ret = ki2c_wait_for_data_ack(ki2c); 377 + if (ret < 0) 378 + return ret; 379 + } 380 + 381 + return 0; 382 + } 383 + 384 + static int ki2c_read(struct ki2c *ki2c, u8 *data, int len) 385 + { 386 + u8 control; 387 + int ret; 388 + int i; 389 + 390 + if (len == 0) 391 + return 0; /* nothing to do */ 392 + 393 + control = KI2C_CONTROL_MEN | KI2C_CONTROL_MSTA; 394 + 395 + /* if just one byte => send tx-nack after transfer */ 396 + if (len == 1) 397 + control |= KI2C_CONTROL_TXAK; 398 + 399 + iowrite8(control, ki2c->base + KI2C_CONTROL_REG); 400 + 401 + /* dummy read to start transfer on bus */ 402 + ioread8(ki2c->base + KI2C_DATA_REG); 403 + 404 + for (i = 0; i < len; i++) { 405 + ret = ki2c_wait_for_data(ki2c); 406 + if (ret < 0) 407 + return ret; 408 + 409 + if (i == len - 2) 410 + /* send tx-nack after transfer of last byte */ 411 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MSTA | KI2C_CONTROL_TXAK, 412 + ki2c->base + KI2C_CONTROL_REG); 413 + else if (i == len - 1) 414 + /* 415 + * switch to TX on last byte, so that reading DATA 416 + * register does not trigger another read transfer 417 + */ 418 + iowrite8(KI2C_CONTROL_MEN | KI2C_CONTROL_MSTA | KI2C_CONTROL_MTX, 419 + ki2c->base + KI2C_CONTROL_REG); 420 + 421 + /* read byte and start next transfer (if not last byte) */ 422 + data[i] = ioread8(ki2c->base + KI2C_DATA_REG); 423 + } 424 + 425 + return len; 426 + } 427 + 428 + static int ki2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 429 + { 430 + struct ki2c *ki2c = i2c_get_adapdata(adap); 431 + int ret; 432 + int i; 433 + 434 + ret = ki2c_inuse_lock(ki2c); 435 + if (ret < 0) 436 + return ret; 437 + 438 + for (i = 0; i < num; i++) { 439 + struct i2c_msg *m = &msgs[i]; 440 + 441 + if (i == 0) 442 + ret = ki2c_start_addr(ki2c, m); 443 + else 444 + ret = ki2c_repstart_addr(ki2c, m); 445 + if (ret < 0) 446 + break; 447 + 448 + if (m->flags & I2C_M_RD) 449 + ret = ki2c_read(ki2c, m->buf, m->len); 450 + else 451 + ret = ki2c_write(ki2c, m->buf, m->len); 452 + if (ret < 0) 453 + break; 454 + } 455 + 456 + ki2c_stop(ki2c); 457 + 458 + ki2c_inuse_unlock(ki2c); 459 + 460 + return ret < 0 ? ret : num; 461 + } 462 + 463 + static void ki2c_unregister_devices(struct ki2c *ki2c) 464 + { 465 + int i; 466 + 467 + for (i = 0; i < ki2c->client_size; i++) { 468 + struct i2c_client *client = ki2c->client[i]; 469 + 470 + if (client) 471 + i2c_unregister_device(client); 472 + } 473 + } 474 + 475 + static int ki2c_register_devices(struct ki2c *ki2c) 476 + { 477 + struct i2c_board_info *info = ki2c->auxdev->info; 478 + int i; 479 + 480 + /* register all known I2C devices */ 481 + for (i = 0; i < ki2c->client_size; i++) { 482 + struct i2c_client *client; 483 + unsigned short const addr_list[2] = { info[i].addr, 484 + I2C_CLIENT_END }; 485 + 486 + client = i2c_new_scanned_device(&ki2c->adapter, &info[i], 487 + addr_list, NULL); 488 + if (!IS_ERR(client)) { 489 + ki2c->client[i] = client; 490 + } else if (PTR_ERR(client) != -ENODEV) { 491 + ki2c->client_size = i; 492 + ki2c_unregister_devices(ki2c); 493 + 494 + return PTR_ERR(client); 495 + } 496 + } 497 + 498 + return 0; 499 + } 500 + 501 + static u32 ki2c_func(struct i2c_adapter *adap) 502 + { 503 + return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 504 + } 505 + 506 + static const struct i2c_algorithm ki2c_algo = { 507 + .master_xfer = ki2c_xfer, 508 + .functionality = ki2c_func, 509 + }; 510 + 511 + static int ki2c_probe(struct auxiliary_device *auxdev, 512 + const struct auxiliary_device_id *id) 513 + { 514 + struct device *dev = &auxdev->dev; 515 + struct i2c_adapter *adap; 516 + struct ki2c *ki2c; 517 + int ret; 518 + 519 + ki2c = devm_kzalloc(dev, sizeof(*ki2c), GFP_KERNEL); 520 + if (!ki2c) 521 + return -ENOMEM; 522 + ki2c->auxdev = container_of(auxdev, struct keba_i2c_auxdev, auxdev); 523 + ki2c->client = devm_kcalloc(dev, ki2c->auxdev->info_size, 524 + sizeof(*ki2c->client), GFP_KERNEL); 525 + if (!ki2c->client) 526 + return -ENOMEM; 527 + ki2c->client_size = ki2c->auxdev->info_size; 528 + auxiliary_set_drvdata(auxdev, ki2c); 529 + 530 + ki2c->base = devm_ioremap_resource(dev, &ki2c->auxdev->io); 531 + if (IS_ERR(ki2c->base)) 532 + return PTR_ERR(ki2c->base); 533 + 534 + adap = &ki2c->adapter; 535 + strscpy(adap->name, "KEBA I2C adapter", sizeof(adap->name)); 536 + adap->owner = THIS_MODULE; 537 + adap->class = I2C_CLASS_HWMON; 538 + adap->algo = &ki2c_algo; 539 + adap->dev.parent = dev; 540 + 541 + i2c_set_adapdata(adap, ki2c); 542 + 543 + /* enable controller */ 544 + iowrite8(KI2C_CONTROL_MEN, ki2c->base + KI2C_CONTROL_REG); 545 + 546 + /* reset bus before probing I2C devices */ 547 + ret = ki2c_reset_bus(ki2c); 548 + if (ret) 549 + goto out; 550 + 551 + ret = devm_i2c_add_adapter(dev, adap); 552 + if (ret) { 553 + dev_err(dev, "Failed to add adapter (%d)!\n", ret); 554 + goto out; 555 + } 556 + 557 + ret = ki2c_register_devices(ki2c); 558 + if (ret) { 559 + dev_err(dev, "Failed to register devices (%d)!\n", ret); 560 + goto out; 561 + } 562 + 563 + return 0; 564 + 565 + out: 566 + iowrite8(KI2C_CONTROL_DISABLE, ki2c->base + KI2C_CONTROL_REG); 567 + return ret; 568 + } 569 + 570 + static void ki2c_remove(struct auxiliary_device *auxdev) 571 + { 572 + struct ki2c *ki2c = auxiliary_get_drvdata(auxdev); 573 + 574 + ki2c_unregister_devices(ki2c); 575 + 576 + /* disable controller */ 577 + iowrite8(KI2C_CONTROL_DISABLE, ki2c->base + KI2C_CONTROL_REG); 578 + 579 + auxiliary_set_drvdata(auxdev, NULL); 580 + } 581 + 582 + static const struct auxiliary_device_id ki2c_devtype_aux[] = { 583 + { .name = "keba.i2c" }, 584 + { } 585 + }; 586 + MODULE_DEVICE_TABLE(auxiliary, ki2c_devtype_aux); 587 + 588 + static struct auxiliary_driver ki2c_driver_aux = { 589 + .name = KI2C, 590 + .id_table = ki2c_devtype_aux, 591 + .probe = ki2c_probe, 592 + .remove = ki2c_remove, 593 + }; 594 + module_auxiliary_driver(ki2c_driver_aux); 595 + 596 + MODULE_AUTHOR("Gerhard Engleder <eg@keba.com>"); 597 + MODULE_DESCRIPTION("KEBA I2C bus controller driver"); 598 + MODULE_LICENSE("GPL");
+3 -3
drivers/i2c/busses/i2c-ljca.c
··· 107 return 0; 108 } 109 110 - static void ljca_i2c_stop(struct ljca_i2c_dev *ljca_i2c, u8 target_addr) 111 { 112 struct ljca_i2c_rw_packet *w_packet = 113 (struct ljca_i2c_rw_packet *)ljca_i2c->obuf; ··· 178 if (!ret) 179 ret = ljca_i2c_pure_read(ljca_i2c, data, len); 180 181 - ljca_i2c_stop(ljca_i2c, target_addr); 182 183 return ret; 184 } ··· 222 if (!ret) 223 ret = ljca_i2c_pure_write(ljca_i2c, data, len); 224 225 - ljca_i2c_stop(ljca_i2c, target_addr); 226 227 return ret; 228 }
··· 107 return 0; 108 } 109 110 + static void ljca_i2c_stop(struct ljca_i2c_dev *ljca_i2c) 111 { 112 struct ljca_i2c_rw_packet *w_packet = 113 (struct ljca_i2c_rw_packet *)ljca_i2c->obuf; ··· 178 if (!ret) 179 ret = ljca_i2c_pure_read(ljca_i2c, data, len); 180 181 + ljca_i2c_stop(ljca_i2c); 182 183 return ret; 184 } ··· 222 if (!ret) 223 ret = ljca_i2c_pure_write(ljca_i2c, data, len); 224 225 + ljca_i2c_stop(ljca_i2c); 226 227 return ret; 228 }
+4 -19
drivers/i2c/busses/i2c-mpc.c
··· 88 int irq; 89 u32 real_clk; 90 u8 fdr, dfsrr; 91 - struct clk *clk_per; 92 u32 cntl_bits; 93 enum mpc_i2c_action action; 94 struct i2c_msg *msgs; ··· 778 struct clk *clk; 779 int result; 780 u32 clock; 781 - int err; 782 783 i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL); 784 if (!i2c) ··· 807 * enable clock for the I2C peripheral (non fatal), 808 * keep a reference upon successful allocation 809 */ 810 - clk = devm_clk_get_optional(&op->dev, NULL); 811 - if (IS_ERR(clk)) 812 - return PTR_ERR(clk); 813 - 814 - err = clk_prepare_enable(clk); 815 - if (err) { 816 dev_err(&op->dev, "failed to enable clock\n"); 817 - return err; 818 } 819 - 820 - i2c->clk_per = clk; 821 822 if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) { 823 clock = MPC_I2C_CLOCK_PRESERVE; ··· 868 869 result = i2c_add_numbered_adapter(&i2c->adap); 870 if (result) 871 - goto fail_add; 872 873 return 0; 874 - 875 - fail_add: 876 - clk_disable_unprepare(i2c->clk_per); 877 - 878 - return result; 879 }; 880 881 static void fsl_i2c_remove(struct platform_device *op) ··· 878 struct mpc_i2c *i2c = platform_get_drvdata(op); 879 880 i2c_del_adapter(&i2c->adap); 881 - 882 - clk_disable_unprepare(i2c->clk_per); 883 }; 884 885 static int __maybe_unused mpc_i2c_suspend(struct device *dev)
··· 88 int irq; 89 u32 real_clk; 90 u8 fdr, dfsrr; 91 u32 cntl_bits; 92 enum mpc_i2c_action action; 93 struct i2c_msg *msgs; ··· 779 struct clk *clk; 780 int result; 781 u32 clock; 782 783 i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL); 784 if (!i2c) ··· 809 * enable clock for the I2C peripheral (non fatal), 810 * keep a reference upon successful allocation 811 */ 812 + clk = devm_clk_get_optional_enabled(&op->dev, NULL); 813 + if (IS_ERR(clk)) { 814 dev_err(&op->dev, "failed to enable clock\n"); 815 + return PTR_ERR(clk); 816 } 817 818 if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) { 819 clock = MPC_I2C_CLOCK_PRESERVE; ··· 876 877 result = i2c_add_numbered_adapter(&i2c->adap); 878 if (result) 879 + return result; 880 881 return 0; 882 }; 883 884 static void fsl_i2c_remove(struct platform_device *op) ··· 891 struct mpc_i2c *i2c = platform_get_drvdata(op); 892 893 i2c_del_adapter(&i2c->adap); 894 }; 895 896 static int __maybe_unused mpc_i2c_suspend(struct device *dev)
+1 -4
drivers/i2c/busses/i2c-mt65xx.c
··· 1306 static irqreturn_t mtk_i2c_irq(int irqno, void *dev_id) 1307 { 1308 struct mtk_i2c *i2c = dev_id; 1309 - u16 restart_flag = 0; 1310 u16 intr_stat; 1311 - 1312 - if (i2c->auto_restart) 1313 - restart_flag = I2C_RS_TRANSFER; 1314 1315 intr_stat = mtk_i2c_readw(i2c, OFFSET_INTR_STAT); 1316 mtk_i2c_writew(i2c, intr_stat, OFFSET_INTR_STAT);
··· 1306 static irqreturn_t mtk_i2c_irq(int irqno, void *dev_id) 1307 { 1308 struct mtk_i2c *i2c = dev_id; 1309 + u16 restart_flag = i2c->auto_restart ? I2C_RS_TRANSFER : 0; 1310 u16 intr_stat; 1311 1312 intr_stat = mtk_i2c_readw(i2c, OFFSET_INTR_STAT); 1313 mtk_i2c_writew(i2c, intr_stat, OFFSET_INTR_STAT);
+4 -2
drivers/i2c/busses/i2c-npcm7xx.c
··· 136 * Since the addr regs are sprinkled all over the address space, 137 * use this array to get the address or each register. 138 */ 139 - #define I2C_NUM_OWN_ADDR 2 140 #define I2C_NUM_OWN_ADDR_SUPPORTED 2 141 142 static const int npcm_i2caddr[I2C_NUM_OWN_ADDR] = { 143 - NPCM_I2CADDR1, NPCM_I2CADDR2, 144 }; 145 #endif 146
··· 136 * Since the addr regs are sprinkled all over the address space, 137 * use this array to get the address or each register. 138 */ 139 + #define I2C_NUM_OWN_ADDR 10 140 #define I2C_NUM_OWN_ADDR_SUPPORTED 2 141 142 static const int npcm_i2caddr[I2C_NUM_OWN_ADDR] = { 143 + NPCM_I2CADDR1, NPCM_I2CADDR2, NPCM_I2CADDR3, NPCM_I2CADDR4, 144 + NPCM_I2CADDR5, NPCM_I2CADDR6, NPCM_I2CADDR7, NPCM_I2CADDR8, 145 + NPCM_I2CADDR9, NPCM_I2CADDR10, 146 }; 147 #endif 148
+1 -1
drivers/i2c/busses/i2c-omap.c
··· 1261 .compatible = "ti,omap2420-i2c", 1262 .data = &omap2420_pdata, 1263 }, 1264 - { }, 1265 }; 1266 MODULE_DEVICE_TABLE(of, omap_i2c_of_match); 1267 #endif
··· 1261 .compatible = "ti,omap2420-i2c", 1262 .data = &omap2420_pdata, 1263 }, 1264 + { } 1265 }; 1266 MODULE_DEVICE_TABLE(of, omap_i2c_of_match); 1267 #endif
+1 -1
drivers/i2c/busses/i2c-piix4.c
··· 146 .ident = "IBM", 147 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), }, 148 }, 149 - { }, 150 }; 151 152 /*
··· 146 .ident = "IBM", 147 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), }, 148 }, 149 + { } 150 }; 151 152 /*
+1 -1
drivers/i2c/busses/i2c-pnx.c
··· 721 #ifdef CONFIG_OF 722 static const struct of_device_id i2c_pnx_of_match[] = { 723 { .compatible = "nxp,pnx-i2c" }, 724 - { }, 725 }; 726 MODULE_DEVICE_TABLE(of, i2c_pnx_of_match); 727 #endif
··· 721 #ifdef CONFIG_OF 722 static const struct of_device_id i2c_pnx_of_match[] = { 723 { .compatible = "nxp,pnx-i2c" }, 724 + { } 725 }; 726 MODULE_DEVICE_TABLE(of, i2c_pnx_of_match); 727 #endif
+1 -1
drivers/i2c/busses/i2c-pxa-pci.c
··· 135 136 static const struct pci_device_id ce4100_i2c_devices[] = { 137 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)}, 138 - { }, 139 }; 140 141 static struct pci_driver ce4100_i2c_driver = {
··· 135 136 static const struct pci_device_id ce4100_i2c_devices[] = { 137 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2e68)}, 138 + { } 139 }; 140 141 static struct pci_driver ce4100_i2c_driver = {
+1 -1
drivers/i2c/busses/i2c-pxa.c
··· 218 { "ce4100-i2c", REGS_CE4100 }, 219 { "pxa910-i2c", REGS_PXA910 }, 220 { "armada-3700-i2c", REGS_A3700 }, 221 - { }, 222 }; 223 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); 224
··· 218 { "ce4100-i2c", REGS_CE4100 }, 219 { "pxa910-i2c", REGS_PXA910 }, 220 { "armada-3700-i2c", REGS_A3700 }, 221 + { } 222 }; 223 MODULE_DEVICE_TABLE(platform, i2c_pxa_id_table); 224
+13 -10
drivers/i2c/busses/i2c-qcom-geni.c
··· 721 static const struct acpi_device_id geni_i2c_acpi_match[] = { 722 { "QCOM0220"}, 723 { "QCOM0411" }, 724 - { }, 725 }; 726 MODULE_DEVICE_TABLE(acpi, geni_i2c_acpi_match); 727 #endif ··· 984 return ret; 985 986 ret = clk_prepare_enable(gi2c->core_clk); 987 - if (ret) { 988 - geni_icc_disable(&gi2c->se); 989 - return ret; 990 - } 991 992 ret = geni_se_resources_on(&gi2c->se); 993 - if (ret) { 994 - clk_disable_unprepare(gi2c->core_clk); 995 - geni_icc_disable(&gi2c->se); 996 - return ret; 997 - } 998 999 enable_irq(gi2c->irq); 1000 gi2c->suspended = 0; 1001 return 0; 1002 } 1003 1004 static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev)
··· 721 static const struct acpi_device_id geni_i2c_acpi_match[] = { 722 { "QCOM0220"}, 723 { "QCOM0411" }, 724 + { } 725 }; 726 MODULE_DEVICE_TABLE(acpi, geni_i2c_acpi_match); 727 #endif ··· 984 return ret; 985 986 ret = clk_prepare_enable(gi2c->core_clk); 987 + if (ret) 988 + goto out_icc_disable; 989 990 ret = geni_se_resources_on(&gi2c->se); 991 + if (ret) 992 + goto out_clk_disable; 993 994 enable_irq(gi2c->irq); 995 gi2c->suspended = 0; 996 + 997 return 0; 998 + 999 + out_clk_disable: 1000 + clk_disable_unprepare(gi2c->core_clk); 1001 + out_icc_disable: 1002 + geni_icc_disable(&gi2c->se); 1003 + 1004 + return ret; 1005 } 1006 1007 static int __maybe_unused geni_i2c_suspend_noirq(struct device *dev)
+1 -1
drivers/i2c/busses/i2c-qup.c
··· 1648 1649 static const struct acpi_device_id qup_i2c_acpi_match[] = { 1650 { "QCOM8010"}, 1651 - { }, 1652 }; 1653 MODULE_DEVICE_TABLE(acpi, qup_i2c_acpi_match); 1654
··· 1648 1649 static const struct acpi_device_id qup_i2c_acpi_match[] = { 1650 { "QCOM8010"}, 1651 + { } 1652 }; 1653 MODULE_DEVICE_TABLE(acpi, qup_i2c_acpi_match); 1654
+5 -7
drivers/i2c/busses/i2c-rcar.c
··· 1164 rcar_i2c_init(priv); 1165 rcar_i2c_reset_slave(priv); 1166 1167 - if (priv->devtype < I2C_RCAR_GEN3) { 1168 - irqflags |= IRQF_NO_THREAD; 1169 - irqhandler = rcar_i2c_gen2_irq; 1170 - } 1171 - 1172 /* Stay always active when multi-master to keep arbitration working */ 1173 if (of_property_read_bool(dev->of_node, "multi-master")) 1174 priv->flags |= ID_P_PM_BLOCKED; ··· 1173 if (of_property_read_bool(dev->of_node, "smbus")) 1174 priv->flags |= ID_P_HOST_NOTIFY; 1175 1176 - /* R-Car Gen3+ needs a reset before every transfer */ 1177 - if (priv->devtype >= I2C_RCAR_GEN3) { 1178 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); 1179 if (IS_ERR(priv->rstc)) { 1180 ret = PTR_ERR(priv->rstc);
··· 1164 rcar_i2c_init(priv); 1165 rcar_i2c_reset_slave(priv); 1166 1167 /* Stay always active when multi-master to keep arbitration working */ 1168 if (of_property_read_bool(dev->of_node, "multi-master")) 1169 priv->flags |= ID_P_PM_BLOCKED; ··· 1178 if (of_property_read_bool(dev->of_node, "smbus")) 1179 priv->flags |= ID_P_HOST_NOTIFY; 1180 1181 + if (priv->devtype < I2C_RCAR_GEN3) { 1182 + irqflags |= IRQF_NO_THREAD; 1183 + irqhandler = rcar_i2c_gen2_irq; 1184 + } else { 1185 + /* R-Car Gen3+ needs a reset before every transfer */ 1186 priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); 1187 if (IS_ERR(priv->rstc)) { 1188 ret = PTR_ERR(priv->rstc);
+157 -71
drivers/i2c/busses/i2c-riic.c
··· 63 #define ICMR3_ACKWP 0x10 64 #define ICMR3_ACKBT 0x08 65 66 #define ICIER_TIE 0x80 67 #define ICIER_TEIE 0x40 68 #define ICIER_RIE 0x20 ··· 82 RIIC_ICCR2, 83 RIIC_ICMR1, 84 RIIC_ICMR3, 85 RIIC_ICSER, 86 RIIC_ICIER, 87 RIIC_ICSR2, ··· 94 }; 95 96 struct riic_of_data { 97 - u8 regs[RIIC_REG_END]; 98 }; 99 100 struct riic_dev { ··· 109 struct completion msg_done; 110 struct i2c_adapter adapter; 111 struct clk *clk; 112 }; 113 114 struct riic_irq_desc { ··· 137 static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 138 { 139 struct riic_dev *riic = i2c_get_adapdata(adap); 140 unsigned long time_left; 141 - int i; 142 u8 start_bit; 143 144 - pm_runtime_get_sync(adap->dev.parent); 145 146 if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) { 147 riic->err = -EBUSY; ··· 177 } 178 179 out: 180 - pm_runtime_put(adap->dev.parent); 181 182 return riic->err ?: num; 183 } ··· 308 .functionality = riic_func, 309 }; 310 311 - static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t) 312 { 313 - int ret = 0; 314 unsigned long rate; 315 int total_ticks, cks, brl, brh; 316 317 - pm_runtime_get_sync(riic->adapter.dev.parent); 318 - 319 - if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) { 320 - dev_err(&riic->adapter.dev, 321 - "unsupported bus speed (%dHz). %d max\n", 322 - t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ); 323 - ret = -EINVAL; 324 - goto out; 325 - } 326 327 rate = clk_get_rate(riic->clk); 328 ··· 359 if (brl > (0x1F + 3)) { 360 dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n", 361 (unsigned long)t->bus_freq_hz); 362 - ret = -EINVAL; 363 - goto out; 364 } 365 366 brh = total_ticks - brl; ··· 391 t->scl_fall_ns / (1000000000 / rate), 392 t->scl_rise_ns / (1000000000 / rate), cks, brl, brh); 393 394 /* Changing the order of accessing IICRST and ICE may break things! */ 395 riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1); 396 riic_clear_set_bit(riic, 0, ICCR1_ICE, RIIC_ICCR1); ··· 406 riic_writeb(riic, 0, RIIC_ICSER); 407 riic_writeb(riic, ICMR3_ACKWP | ICMR3_RDRFS, RIIC_ICMR3); 408 409 riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); 410 411 - out: 412 - pm_runtime_put(riic->adapter.dev.parent); 413 - return ret; 414 } 415 416 static struct riic_irq_desc riic_irqs[] = { ··· 431 432 static int riic_i2c_probe(struct platform_device *pdev) 433 { 434 struct riic_dev *riic; 435 struct i2c_adapter *adap; 436 - struct i2c_timings i2c_t; 437 - struct reset_control *rstc; 438 int i, ret; 439 440 - riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL); 441 if (!riic) 442 return -ENOMEM; 443 ··· 444 if (IS_ERR(riic->base)) 445 return PTR_ERR(riic->base); 446 447 - riic->clk = devm_clk_get(&pdev->dev, NULL); 448 if (IS_ERR(riic->clk)) { 449 - dev_err(&pdev->dev, "missing controller clock"); 450 return PTR_ERR(riic->clk); 451 } 452 453 - rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); 454 - if (IS_ERR(rstc)) 455 - return dev_err_probe(&pdev->dev, PTR_ERR(rstc), 456 "Error: missing reset ctrl\n"); 457 458 - ret = reset_control_deassert(rstc); 459 if (ret) 460 return ret; 461 462 - ret = devm_add_action_or_reset(&pdev->dev, riic_reset_control_assert, rstc); 463 if (ret) 464 return ret; 465 ··· 468 if (ret < 0) 469 return ret; 470 471 - ret = devm_request_irq(&pdev->dev, ret, riic_irqs[i].isr, 472 0, riic_irqs[i].name, riic); 473 if (ret) { 474 - dev_err(&pdev->dev, "failed to request irq %s\n", riic_irqs[i].name); 475 return ret; 476 } 477 } 478 479 - riic->info = of_device_get_match_data(&pdev->dev); 480 481 adap = &riic->adapter; 482 i2c_set_adapdata(adap, riic); 483 strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); 484 adap->owner = THIS_MODULE; 485 adap->algo = &riic_algo; 486 - adap->dev.parent = &pdev->dev; 487 - adap->dev.of_node = pdev->dev.of_node; 488 489 init_completion(&riic->msg_done); 490 491 - i2c_parse_fw_timings(&pdev->dev, &i2c_t, true); 492 493 - pm_runtime_enable(&pdev->dev); 494 495 - ret = riic_init_hw(riic, &i2c_t); 496 if (ret) 497 goto out; 498 ··· 505 506 platform_set_drvdata(pdev, riic); 507 508 - dev_info(&pdev->dev, "registered with %dHz bus speed\n", 509 - i2c_t.bus_freq_hz); 510 return 0; 511 512 out: 513 - pm_runtime_disable(&pdev->dev); 514 return ret; 515 } 516 517 static void riic_i2c_remove(struct platform_device *pdev) 518 { 519 struct riic_dev *riic = platform_get_drvdata(pdev); 520 521 - pm_runtime_get_sync(&pdev->dev); 522 - riic_writeb(riic, 0, RIIC_ICIER); 523 - pm_runtime_put(&pdev->dev); 524 i2c_del_adapter(&riic->adapter); 525 - pm_runtime_disable(&pdev->dev); 526 } 527 528 static const struct riic_of_data riic_rz_a_info = { 529 - .regs = { 530 - [RIIC_ICCR1] = 0x00, 531 - [RIIC_ICCR2] = 0x04, 532 - [RIIC_ICMR1] = 0x08, 533 - [RIIC_ICMR3] = 0x10, 534 - [RIIC_ICSER] = 0x18, 535 - [RIIC_ICIER] = 0x1c, 536 - [RIIC_ICSR2] = 0x24, 537 - [RIIC_ICBRL] = 0x34, 538 - [RIIC_ICBRH] = 0x38, 539 - [RIIC_ICDRT] = 0x3c, 540 - [RIIC_ICDRR] = 0x40, 541 - }, 542 }; 543 544 static const struct riic_of_data riic_rz_v2h_info = { 545 - .regs = { 546 - [RIIC_ICCR1] = 0x00, 547 - [RIIC_ICCR2] = 0x01, 548 - [RIIC_ICMR1] = 0x02, 549 - [RIIC_ICMR3] = 0x04, 550 - [RIIC_ICSER] = 0x06, 551 - [RIIC_ICIER] = 0x07, 552 - [RIIC_ICSR2] = 0x09, 553 - [RIIC_ICBRL] = 0x10, 554 - [RIIC_ICBRH] = 0x11, 555 - [RIIC_ICDRT] = 0x12, 556 - [RIIC_ICDRR] = 0x13, 557 - }, 558 }; 559 560 static const struct of_device_id riic_i2c_dt_ids[] = { 561 { .compatible = "renesas,riic-rz", .data = &riic_rz_a_info }, 562 { .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info }, 563 { /* Sentinel */ }, 564 }; ··· 636 .driver = { 637 .name = "i2c-riic", 638 .of_match_table = riic_i2c_dt_ids, 639 }, 640 }; 641
··· 63 #define ICMR3_ACKWP 0x10 64 #define ICMR3_ACKBT 0x08 65 66 + #define ICFER_FMPE 0x80 67 + 68 #define ICIER_TIE 0x80 69 #define ICIER_TEIE 0x40 70 #define ICIER_RIE 0x20 ··· 80 RIIC_ICCR2, 81 RIIC_ICMR1, 82 RIIC_ICMR3, 83 + RIIC_ICFER, 84 RIIC_ICSER, 85 RIIC_ICIER, 86 RIIC_ICSR2, ··· 91 }; 92 93 struct riic_of_data { 94 + const u8 *regs; 95 + bool fast_mode_plus; 96 }; 97 98 struct riic_dev { ··· 105 struct completion msg_done; 106 struct i2c_adapter adapter; 107 struct clk *clk; 108 + struct reset_control *rstc; 109 + struct i2c_timings i2c_t; 110 }; 111 112 struct riic_irq_desc { ··· 131 static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 132 { 133 struct riic_dev *riic = i2c_get_adapdata(adap); 134 + struct device *dev = adap->dev.parent; 135 unsigned long time_left; 136 + int i, ret; 137 u8 start_bit; 138 139 + ret = pm_runtime_resume_and_get(dev); 140 + if (ret) 141 + return ret; 142 143 if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) { 144 riic->err = -EBUSY; ··· 168 } 169 170 out: 171 + pm_runtime_mark_last_busy(dev); 172 + pm_runtime_put_autosuspend(dev); 173 174 return riic->err ?: num; 175 } ··· 298 .functionality = riic_func, 299 }; 300 301 + static int riic_init_hw(struct riic_dev *riic) 302 { 303 + int ret; 304 unsigned long rate; 305 int total_ticks, cks, brl, brh; 306 + struct i2c_timings *t = &riic->i2c_t; 307 + struct device *dev = riic->adapter.dev.parent; 308 + bool fast_mode_plus = riic->info->fast_mode_plus; 309 + u32 max_freq = fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ 310 + : I2C_MAX_FAST_MODE_FREQ; 311 312 + if (t->bus_freq_hz > max_freq) 313 + return dev_err_probe(&riic->adapter.dev, -EINVAL, 314 + "unsupported bus speed %uHz (%u max)\n", 315 + t->bus_freq_hz, max_freq); 316 317 rate = clk_get_rate(riic->clk); 318 ··· 349 if (brl > (0x1F + 3)) { 350 dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n", 351 (unsigned long)t->bus_freq_hz); 352 + return -EINVAL; 353 } 354 355 brh = total_ticks - brl; ··· 382 t->scl_fall_ns / (1000000000 / rate), 383 t->scl_rise_ns / (1000000000 / rate), cks, brl, brh); 384 385 + ret = pm_runtime_resume_and_get(dev); 386 + if (ret) 387 + return ret; 388 + 389 /* Changing the order of accessing IICRST and ICE may break things! */ 390 riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1); 391 riic_clear_set_bit(riic, 0, ICCR1_ICE, RIIC_ICCR1); ··· 393 riic_writeb(riic, 0, RIIC_ICSER); 394 riic_writeb(riic, ICMR3_ACKWP | ICMR3_RDRFS, RIIC_ICMR3); 395 396 + if (fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) 397 + riic_clear_set_bit(riic, 0, ICFER_FMPE, RIIC_ICFER); 398 + 399 riic_clear_set_bit(riic, ICCR1_IICRST, 0, RIIC_ICCR1); 400 401 + pm_runtime_mark_last_busy(dev); 402 + pm_runtime_put_autosuspend(dev); 403 + return 0; 404 } 405 406 static struct riic_irq_desc riic_irqs[] = { ··· 415 416 static int riic_i2c_probe(struct platform_device *pdev) 417 { 418 + struct device *dev = &pdev->dev; 419 struct riic_dev *riic; 420 struct i2c_adapter *adap; 421 int i, ret; 422 423 + riic = devm_kzalloc(dev, sizeof(*riic), GFP_KERNEL); 424 if (!riic) 425 return -ENOMEM; 426 ··· 429 if (IS_ERR(riic->base)) 430 return PTR_ERR(riic->base); 431 432 + riic->clk = devm_clk_get(dev, NULL); 433 if (IS_ERR(riic->clk)) { 434 + dev_err(dev, "missing controller clock"); 435 return PTR_ERR(riic->clk); 436 } 437 438 + riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL); 439 + if (IS_ERR(riic->rstc)) 440 + return dev_err_probe(dev, PTR_ERR(riic->rstc), 441 "Error: missing reset ctrl\n"); 442 443 + ret = reset_control_deassert(riic->rstc); 444 if (ret) 445 return ret; 446 447 + ret = devm_add_action_or_reset(dev, riic_reset_control_assert, riic->rstc); 448 if (ret) 449 return ret; 450 ··· 453 if (ret < 0) 454 return ret; 455 456 + ret = devm_request_irq(dev, ret, riic_irqs[i].isr, 457 0, riic_irqs[i].name, riic); 458 if (ret) { 459 + dev_err(dev, "failed to request irq %s\n", riic_irqs[i].name); 460 return ret; 461 } 462 } 463 464 + riic->info = of_device_get_match_data(dev); 465 466 adap = &riic->adapter; 467 i2c_set_adapdata(adap, riic); 468 strscpy(adap->name, "Renesas RIIC adapter", sizeof(adap->name)); 469 adap->owner = THIS_MODULE; 470 adap->algo = &riic_algo; 471 + adap->dev.parent = dev; 472 + adap->dev.of_node = dev->of_node; 473 474 init_completion(&riic->msg_done); 475 476 + i2c_parse_fw_timings(dev, &riic->i2c_t, true); 477 478 + /* Default 0 to save power. Can be overridden via sysfs for lower latency. */ 479 + pm_runtime_set_autosuspend_delay(dev, 0); 480 + pm_runtime_use_autosuspend(dev); 481 + pm_runtime_enable(dev); 482 483 + ret = riic_init_hw(riic); 484 if (ret) 485 goto out; 486 ··· 487 488 platform_set_drvdata(pdev, riic); 489 490 + dev_info(dev, "registered with %dHz bus speed\n", riic->i2c_t.bus_freq_hz); 491 return 0; 492 493 out: 494 + pm_runtime_disable(dev); 495 + pm_runtime_dont_use_autosuspend(dev); 496 return ret; 497 } 498 499 static void riic_i2c_remove(struct platform_device *pdev) 500 { 501 struct riic_dev *riic = platform_get_drvdata(pdev); 502 + struct device *dev = &pdev->dev; 503 + int ret; 504 505 + ret = pm_runtime_resume_and_get(dev); 506 + if (!ret) { 507 + riic_writeb(riic, 0, RIIC_ICIER); 508 + pm_runtime_put(dev); 509 + } 510 i2c_del_adapter(&riic->adapter); 511 + pm_runtime_disable(dev); 512 + pm_runtime_dont_use_autosuspend(dev); 513 } 514 515 + static const u8 riic_rz_a_regs[RIIC_REG_END] = { 516 + [RIIC_ICCR1] = 0x00, 517 + [RIIC_ICCR2] = 0x04, 518 + [RIIC_ICMR1] = 0x08, 519 + [RIIC_ICMR3] = 0x10, 520 + [RIIC_ICFER] = 0x14, 521 + [RIIC_ICSER] = 0x18, 522 + [RIIC_ICIER] = 0x1c, 523 + [RIIC_ICSR2] = 0x24, 524 + [RIIC_ICBRL] = 0x34, 525 + [RIIC_ICBRH] = 0x38, 526 + [RIIC_ICDRT] = 0x3c, 527 + [RIIC_ICDRR] = 0x40, 528 + }; 529 + 530 static const struct riic_of_data riic_rz_a_info = { 531 + .regs = riic_rz_a_regs, 532 + .fast_mode_plus = true, 533 + }; 534 + 535 + static const struct riic_of_data riic_rz_a1h_info = { 536 + .regs = riic_rz_a_regs, 537 + }; 538 + 539 + static const u8 riic_rz_v2h_regs[RIIC_REG_END] = { 540 + [RIIC_ICCR1] = 0x00, 541 + [RIIC_ICCR2] = 0x01, 542 + [RIIC_ICMR1] = 0x02, 543 + [RIIC_ICMR3] = 0x04, 544 + [RIIC_ICFER] = 0x05, 545 + [RIIC_ICSER] = 0x06, 546 + [RIIC_ICIER] = 0x07, 547 + [RIIC_ICSR2] = 0x09, 548 + [RIIC_ICBRL] = 0x10, 549 + [RIIC_ICBRH] = 0x11, 550 + [RIIC_ICDRT] = 0x12, 551 + [RIIC_ICDRR] = 0x13, 552 }; 553 554 static const struct riic_of_data riic_rz_v2h_info = { 555 + .regs = riic_rz_v2h_regs, 556 + .fast_mode_plus = true, 557 + }; 558 + 559 + static int riic_i2c_suspend(struct device *dev) 560 + { 561 + struct riic_dev *riic = dev_get_drvdata(dev); 562 + int ret; 563 + 564 + ret = pm_runtime_resume_and_get(dev); 565 + if (ret) 566 + return ret; 567 + 568 + i2c_mark_adapter_suspended(&riic->adapter); 569 + 570 + /* Disable output on SDA, SCL pins. */ 571 + riic_clear_set_bit(riic, ICCR1_ICE, 0, RIIC_ICCR1); 572 + 573 + pm_runtime_mark_last_busy(dev); 574 + pm_runtime_put_sync(dev); 575 + 576 + return reset_control_assert(riic->rstc); 577 + } 578 + 579 + static int riic_i2c_resume(struct device *dev) 580 + { 581 + struct riic_dev *riic = dev_get_drvdata(dev); 582 + int ret; 583 + 584 + ret = reset_control_deassert(riic->rstc); 585 + if (ret) 586 + return ret; 587 + 588 + ret = riic_init_hw(riic); 589 + if (ret) { 590 + /* 591 + * In case this happens there is no way to recover from this 592 + * state. The driver will remain loaded. We want to avoid 593 + * keeping the reset line de-asserted for no reason. 594 + */ 595 + reset_control_assert(riic->rstc); 596 + return ret; 597 + } 598 + 599 + i2c_mark_adapter_resumed(&riic->adapter); 600 + 601 + return 0; 602 + } 603 + 604 + static const struct dev_pm_ops riic_i2c_pm_ops = { 605 + SYSTEM_SLEEP_PM_OPS(riic_i2c_suspend, riic_i2c_resume) 606 }; 607 608 static const struct of_device_id riic_i2c_dt_ids[] = { 609 { .compatible = "renesas,riic-rz", .data = &riic_rz_a_info }, 610 + { .compatible = "renesas,riic-r7s72100", .data = &riic_rz_a1h_info, }, 611 { .compatible = "renesas,riic-r9a09g057", .data = &riic_rz_v2h_info }, 612 { /* Sentinel */ }, 613 }; ··· 551 .driver = { 552 .name = "i2c-riic", 553 .of_match_table = riic_i2c_dt_ids, 554 + .pm = pm_ptr(&riic_i2c_pm_ops), 555 }, 556 }; 557
+1 -1
drivers/i2c/busses/i2c-s3c2410.c
··· 130 }, { 131 .name = "s3c2440-hdmiphy-i2c", 132 .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO, 133 - }, { }, 134 }; 135 MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); 136
··· 130 }, { 131 .name = "s3c2440-hdmiphy-i2c", 132 .driver_data = QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO, 133 + }, { } 134 }; 135 MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids); 136
+2 -2
drivers/i2c/busses/i2c-virtio.c
··· 182 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 183 } 184 185 - static struct i2c_algorithm virtio_algorithm = { 186 .xfer = virtio_i2c_xfer, 187 .functionality = virtio_i2c_func, 188 }; ··· 237 virtio_i2c_del_vqs(vdev); 238 } 239 240 - static struct virtio_device_id id_table[] = { 241 { VIRTIO_ID_I2C_ADAPTER, VIRTIO_DEV_ANY_ID }, 242 {} 243 };
··· 182 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 183 } 184 185 + static const struct i2c_algorithm virtio_algorithm = { 186 .xfer = virtio_i2c_xfer, 187 .functionality = virtio_i2c_func, 188 }; ··· 237 virtio_i2c_del_vqs(vdev); 238 } 239 240 + static const struct virtio_device_id id_table[] = { 241 { VIRTIO_ID_I2C_ADAPTER, VIRTIO_DEV_ANY_ID }, 242 {} 243 };
+41 -38
drivers/i2c/i2c-core-base.c
··· 915 return 0; 916 } 917 918 /** 919 * i2c_new_client_device - instantiate an i2c device 920 * @adap: the adapter managing the device ··· 983 goto out_err_silent; 984 } 985 986 /* Check for address business */ 987 status = i2c_check_addr_busy(adap, i2c_encode_flags_to_addr(client)); 988 if (status) ··· 1018 dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", 1019 client->name, dev_name(&client->dev)); 1020 1021 return client; 1022 1023 out_remove_swnode: ··· 1031 dev_err(&adap->dev, 1032 "Failed to register i2c client %s at 0x%02x (%d)\n", 1033 client->name, client->addr, status); 1034 out_err_silent: 1035 if (need_put) 1036 put_device(&client->dev); ··· 1096 static const struct i2c_device_id dummy_id[] = { 1097 { "dummy", }, 1098 { "smbus_host_notify", }, 1099 - { }, 1100 }; 1101 1102 static int dummy_probe(struct i2c_client *client) ··· 1395 } 1396 EXPORT_SYMBOL(i2c_verify_adapter); 1397 1398 - #ifdef CONFIG_I2C_COMPAT 1399 - static struct class_compat *i2c_adapter_compat_class; 1400 - #endif 1401 - 1402 static void i2c_scan_static_board_info(struct i2c_adapter *adapter) 1403 { 1404 struct i2c_devinfo *devinfo; ··· 1548 dev_set_name(&adap->dev, "i2c-%d", adap->nr); 1549 adap->dev.bus = &i2c_bus_type; 1550 adap->dev.type = &i2c_adapter_type; 1551 - res = device_register(&adap->dev); 1552 if (res) { 1553 pr_err("adapter '%s': can't register device (%d)\n", adap->name, res); 1554 goto out_list; ··· 1571 if (res) 1572 goto out_reg; 1573 1574 - device_enable_async_suspend(&adap->dev); 1575 - pm_runtime_no_callbacks(&adap->dev); 1576 - pm_suspend_ignore_children(&adap->dev, true); 1577 - pm_runtime_enable(&adap->dev); 1578 - 1579 res = i2c_init_recovery(adap); 1580 if (res == -EPROBE_DEFER) 1581 goto out_reg; 1582 1583 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 1584 - 1585 - #ifdef CONFIG_I2C_COMPAT 1586 - res = class_compat_create_link(i2c_adapter_compat_class, &adap->dev, 1587 - adap->dev.parent); 1588 - if (res) 1589 - dev_warn(&adap->dev, 1590 - "Failed to create compatibility class link\n"); 1591 - #endif 1592 1593 /* create pre-declared device nodes */ 1594 of_i2c_register_devices(adap); ··· 1782 * them up properly, so we give them a chance to do that first. */ 1783 device_for_each_child(&adap->dev, NULL, __unregister_client); 1784 device_for_each_child(&adap->dev, NULL, __unregister_dummy); 1785 - 1786 - #ifdef CONFIG_I2C_COMPAT 1787 - class_compat_remove_link(i2c_adapter_compat_class, &adap->dev, 1788 - adap->dev.parent); 1789 - #endif 1790 1791 /* device name is gone after device_unregister */ 1792 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); ··· 2091 2092 i2c_debugfs_root = debugfs_create_dir("i2c", NULL); 2093 2094 - #ifdef CONFIG_I2C_COMPAT 2095 - i2c_adapter_compat_class = class_compat_register("i2c-adapter"); 2096 - if (!i2c_adapter_compat_class) { 2097 - retval = -ENOMEM; 2098 - goto bus_err; 2099 - } 2100 - #endif 2101 retval = i2c_add_driver(&dummy_driver); 2102 if (retval) 2103 goto class_err; ··· 2103 return 0; 2104 2105 class_err: 2106 - #ifdef CONFIG_I2C_COMPAT 2107 - class_compat_unregister(i2c_adapter_compat_class); 2108 - bus_err: 2109 - #endif 2110 is_registered = false; 2111 bus_unregister(&i2c_bus_type); 2112 return retval; ··· 2115 if (IS_ENABLED(CONFIG_OF_DYNAMIC)) 2116 WARN_ON(of_reconfig_notifier_unregister(&i2c_of_notifier)); 2117 i2c_del_driver(&dummy_driver); 2118 - #ifdef CONFIG_I2C_COMPAT 2119 - class_compat_unregister(i2c_adapter_compat_class); 2120 - #endif 2121 debugfs_remove_recursive(i2c_debugfs_root); 2122 bus_unregister(&i2c_bus_type); 2123 tracepoint_synchronize_unregister();
··· 915 return 0; 916 } 917 918 + /* 919 + * Serialize device instantiation in case it can be instantiated explicitly 920 + * and by auto-detection 921 + */ 922 + static int i2c_lock_addr(struct i2c_adapter *adap, unsigned short addr, 923 + unsigned short flags) 924 + { 925 + if (!(flags & I2C_CLIENT_TEN) && 926 + test_and_set_bit(addr, adap->addrs_in_instantiation)) 927 + return -EBUSY; 928 + 929 + return 0; 930 + } 931 + 932 + static void i2c_unlock_addr(struct i2c_adapter *adap, unsigned short addr, 933 + unsigned short flags) 934 + { 935 + if (!(flags & I2C_CLIENT_TEN)) 936 + clear_bit(addr, adap->addrs_in_instantiation); 937 + } 938 + 939 /** 940 * i2c_new_client_device - instantiate an i2c device 941 * @adap: the adapter managing the device ··· 962 goto out_err_silent; 963 } 964 965 + status = i2c_lock_addr(adap, client->addr, client->flags); 966 + if (status) 967 + goto out_err_silent; 968 + 969 /* Check for address business */ 970 status = i2c_check_addr_busy(adap, i2c_encode_flags_to_addr(client)); 971 if (status) ··· 993 dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n", 994 client->name, dev_name(&client->dev)); 995 996 + i2c_unlock_addr(adap, client->addr, client->flags); 997 + 998 return client; 999 1000 out_remove_swnode: ··· 1004 dev_err(&adap->dev, 1005 "Failed to register i2c client %s at 0x%02x (%d)\n", 1006 client->name, client->addr, status); 1007 + i2c_unlock_addr(adap, client->addr, client->flags); 1008 out_err_silent: 1009 if (need_put) 1010 put_device(&client->dev); ··· 1068 static const struct i2c_device_id dummy_id[] = { 1069 { "dummy", }, 1070 { "smbus_host_notify", }, 1071 + { } 1072 }; 1073 1074 static int dummy_probe(struct i2c_client *client) ··· 1367 } 1368 EXPORT_SYMBOL(i2c_verify_adapter); 1369 1370 static void i2c_scan_static_board_info(struct i2c_adapter *adapter) 1371 { 1372 struct i2c_devinfo *devinfo; ··· 1524 dev_set_name(&adap->dev, "i2c-%d", adap->nr); 1525 adap->dev.bus = &i2c_bus_type; 1526 adap->dev.type = &i2c_adapter_type; 1527 + device_initialize(&adap->dev); 1528 + 1529 + /* 1530 + * This adapter can be used as a parent immediately after device_add(), 1531 + * setup runtime-pm (especially ignore-children) before hand. 1532 + */ 1533 + device_enable_async_suspend(&adap->dev); 1534 + pm_runtime_no_callbacks(&adap->dev); 1535 + pm_suspend_ignore_children(&adap->dev, true); 1536 + pm_runtime_enable(&adap->dev); 1537 + 1538 + res = device_add(&adap->dev); 1539 if (res) { 1540 pr_err("adapter '%s': can't register device (%d)\n", adap->name, res); 1541 goto out_list; ··· 1536 if (res) 1537 goto out_reg; 1538 1539 res = i2c_init_recovery(adap); 1540 if (res == -EPROBE_DEFER) 1541 goto out_reg; 1542 1543 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 1544 1545 /* create pre-declared device nodes */ 1546 of_i2c_register_devices(adap); ··· 1760 * them up properly, so we give them a chance to do that first. */ 1761 device_for_each_child(&adap->dev, NULL, __unregister_client); 1762 device_for_each_child(&adap->dev, NULL, __unregister_dummy); 1763 1764 /* device name is gone after device_unregister */ 1765 dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); ··· 2074 2075 i2c_debugfs_root = debugfs_create_dir("i2c", NULL); 2076 2077 retval = i2c_add_driver(&dummy_driver); 2078 if (retval) 2079 goto class_err; ··· 2093 return 0; 2094 2095 class_err: 2096 is_registered = false; 2097 bus_unregister(&i2c_bus_type); 2098 return retval; ··· 2109 if (IS_ENABLED(CONFIG_OF_DYNAMIC)) 2110 WARN_ON(of_reconfig_notifier_unregister(&i2c_of_notifier)); 2111 i2c_del_driver(&dummy_driver); 2112 debugfs_remove_recursive(i2c_debugfs_root); 2113 bus_unregister(&i2c_bus_type); 2114 tracepoint_synchronize_unregister();
+2 -5
drivers/i2c/i2c-core-slave.c
··· 109 bool i2c_detect_slave_mode(struct device *dev) 110 { 111 if (IS_BUILTIN(CONFIG_OF) && dev->of_node) { 112 - struct device_node *child; 113 u32 reg; 114 115 - for_each_child_of_node(dev->of_node, child) { 116 of_property_read_u32(child, "reg", &reg); 117 - if (reg & I2C_OWN_SLAVE_ADDRESS) { 118 - of_node_put(child); 119 return true; 120 - } 121 } 122 } else if (IS_BUILTIN(CONFIG_ACPI) && ACPI_HANDLE(dev)) { 123 dev_dbg(dev, "ACPI slave is not supported yet\n");
··· 109 bool i2c_detect_slave_mode(struct device *dev) 110 { 111 if (IS_BUILTIN(CONFIG_OF) && dev->of_node) { 112 u32 reg; 113 114 + for_each_child_of_node_scoped(dev->of_node, child) { 115 of_property_read_u32(child, "reg", &reg); 116 + if (reg & I2C_OWN_SLAVE_ADDRESS) 117 return true; 118 } 119 } else if (IS_BUILTIN(CONFIG_ACPI) && ACPI_HANDLE(dev)) { 120 dev_dbg(dev, "ACPI slave is not supported yet\n");
+123 -43
drivers/i2c/i2c-slave-testunit.c
··· 6 * Copyright (C) 2020 by Renesas Electronics Corporation 7 */ 8 9 #include <linux/bitops.h> 10 #include <linux/i2c.h> 11 #include <linux/init.h> 12 #include <linux/module.h> ··· 17 #include <linux/slab.h> 18 #include <linux/workqueue.h> /* FIXME: is system_long_wq the best choice? */ 19 20 - #define TU_CUR_VERSION 0x01 21 22 enum testunit_cmds { 23 TU_CMD_READ_BYTES = 1, /* save 0 for ABORT, RESET or similar */ 24 TU_CMD_SMBUS_HOST_NOTIFY, 25 TU_CMD_SMBUS_BLOCK_PROC_CALL, 26 TU_NUM_CMDS 27 }; 28 ··· 44 unsigned long flags; 45 u8 regs[TU_NUM_REGS]; 46 u8 reg_idx; 47 struct i2c_client *client; 48 struct delayed_work worker; 49 }; 50 51 - static void i2c_slave_testunit_work(struct work_struct *work) 52 { 53 - struct testunit_data *tu = container_of(work, struct testunit_data, worker.work); 54 - struct i2c_msg msg; 55 - u8 msgbuf[256]; 56 - int ret = 0; 57 58 - msg.addr = I2C_CLIENT_END; 59 - msg.buf = msgbuf; 60 - 61 - switch (tu->regs[TU_REG_CMD]) { 62 - case TU_CMD_READ_BYTES: 63 - msg.addr = tu->regs[TU_REG_DATAL]; 64 - msg.flags = I2C_M_RD; 65 - msg.len = tu->regs[TU_REG_DATAH]; 66 break; 67 68 - case TU_CMD_SMBUS_HOST_NOTIFY: 69 - msg.addr = 0x08; 70 - msg.flags = 0; 71 - msg.len = 3; 72 - msgbuf[0] = tu->client->addr; 73 - msgbuf[1] = tu->regs[TU_REG_DATAL]; 74 - msgbuf[2] = tu->regs[TU_REG_DATAH]; 75 break; 76 77 - default: 78 - break; 79 } 80 81 - if (msg.addr != I2C_CLIENT_END) { 82 - ret = i2c_transfer(tu->client->adapter, &msg, 1); 83 - /* convert '0 msgs transferred' to errno */ 84 - ret = (ret == 0) ? -EIO : ret; 85 - } 86 - 87 - if (ret < 0) 88 - dev_err(&tu->client->dev, "CMD%02X failed (%d)\n", tu->regs[TU_REG_CMD], ret); 89 - 90 - clear_bit(TU_FLAG_IN_PROCESS, &tu->flags); 91 } 92 93 static int i2c_slave_testunit_slave_cb(struct i2c_client *client, ··· 84 struct testunit_data *tu = i2c_get_clientdata(client); 85 bool is_proc_call = tu->reg_idx == 3 && tu->regs[TU_REG_DATAL] == 1 && 86 tu->regs[TU_REG_CMD] == TU_CMD_SMBUS_BLOCK_PROC_CALL; 87 int ret = 0; 88 89 switch (event) { 90 case I2C_SLAVE_WRITE_RECEIVED: 91 if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags)) 92 return -EBUSY; ··· 131 tu->reg_idx = 0; 132 break; 133 134 - case I2C_SLAVE_WRITE_REQUESTED: 135 - if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags)) 136 - return -EBUSY; 137 - 138 - memset(tu->regs, 0, TU_NUM_REGS); 139 - tu->reg_idx = 0; 140 - break; 141 - 142 case I2C_SLAVE_READ_PROCESSED: 143 - if (is_proc_call && tu->regs[TU_REG_DATAH]) 144 tu->regs[TU_REG_DATAH]--; 145 fallthrough; 146 147 case I2C_SLAVE_READ_REQUESTED: 148 - *val = is_proc_call ? tu->regs[TU_REG_DATAH] : TU_CUR_VERSION; 149 break; 150 } 151 152 return ret; 153 } 154 155 static int i2c_slave_testunit_probe(struct i2c_client *client) ··· 228 229 tu->client = client; 230 i2c_set_clientdata(client, tu); 231 INIT_DELAYED_WORK(&tu->worker, i2c_slave_testunit_work); 232 233 return i2c_slave_register(client, i2c_slave_testunit_slave_cb); 234 };
··· 6 * Copyright (C) 2020 by Renesas Electronics Corporation 7 */ 8 9 + #include <generated/utsrelease.h> 10 #include <linux/bitops.h> 11 + #include <linux/completion.h> 12 + #include <linux/gpio/consumer.h> 13 #include <linux/i2c.h> 14 #include <linux/init.h> 15 #include <linux/module.h> ··· 14 #include <linux/slab.h> 15 #include <linux/workqueue.h> /* FIXME: is system_long_wq the best choice? */ 16 17 + #define TU_VERSION_MAX_LENGTH 128 18 19 enum testunit_cmds { 20 TU_CMD_READ_BYTES = 1, /* save 0 for ABORT, RESET or similar */ 21 TU_CMD_SMBUS_HOST_NOTIFY, 22 TU_CMD_SMBUS_BLOCK_PROC_CALL, 23 + TU_CMD_GET_VERSION_WITH_REP_START, 24 + TU_CMD_SMBUS_ALERT_REQUEST, 25 TU_NUM_CMDS 26 }; 27 ··· 39 unsigned long flags; 40 u8 regs[TU_NUM_REGS]; 41 u8 reg_idx; 42 + u8 read_idx; 43 struct i2c_client *client; 44 struct delayed_work worker; 45 + struct gpio_desc *gpio; 46 + struct completion alert_done; 47 }; 48 49 + static char tu_version_info[] = "v" UTS_RELEASE "\n\0"; 50 + 51 + static int i2c_slave_testunit_smbalert_cb(struct i2c_client *client, 52 + enum i2c_slave_event event, u8 *val) 53 { 54 + struct testunit_data *tu = i2c_get_clientdata(client); 55 56 + switch (event) { 57 + case I2C_SLAVE_READ_PROCESSED: 58 + gpiod_set_value(tu->gpio, 0); 59 + fallthrough; 60 + case I2C_SLAVE_READ_REQUESTED: 61 + *val = tu->regs[TU_REG_DATAL]; 62 break; 63 64 + case I2C_SLAVE_STOP: 65 + complete(&tu->alert_done); 66 break; 67 68 + case I2C_SLAVE_WRITE_REQUESTED: 69 + case I2C_SLAVE_WRITE_RECEIVED: 70 + return -EOPNOTSUPP; 71 } 72 73 + return 0; 74 } 75 76 static int i2c_slave_testunit_slave_cb(struct i2c_client *client, ··· 91 struct testunit_data *tu = i2c_get_clientdata(client); 92 bool is_proc_call = tu->reg_idx == 3 && tu->regs[TU_REG_DATAL] == 1 && 93 tu->regs[TU_REG_CMD] == TU_CMD_SMBUS_BLOCK_PROC_CALL; 94 + bool is_get_version = tu->reg_idx == 3 && 95 + tu->regs[TU_REG_CMD] == TU_CMD_GET_VERSION_WITH_REP_START; 96 int ret = 0; 97 98 switch (event) { 99 + case I2C_SLAVE_WRITE_REQUESTED: 100 + if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags)) 101 + return -EBUSY; 102 + 103 + memset(tu->regs, 0, TU_NUM_REGS); 104 + tu->reg_idx = 0; 105 + tu->read_idx = 0; 106 + break; 107 + 108 case I2C_SLAVE_WRITE_RECEIVED: 109 if (test_bit(TU_FLAG_IN_PROCESS, &tu->flags)) 110 return -EBUSY; ··· 127 tu->reg_idx = 0; 128 break; 129 130 case I2C_SLAVE_READ_PROCESSED: 131 + /* Advance until we reach the NUL character */ 132 + if (is_get_version && tu_version_info[tu->read_idx] != 0) 133 + tu->read_idx++; 134 + else if (is_proc_call && tu->regs[TU_REG_DATAH]) 135 tu->regs[TU_REG_DATAH]--; 136 + 137 fallthrough; 138 139 case I2C_SLAVE_READ_REQUESTED: 140 + if (is_get_version) 141 + *val = tu_version_info[tu->read_idx]; 142 + else if (is_proc_call) 143 + *val = tu->regs[TU_REG_DATAH]; 144 + else 145 + *val = test_bit(TU_FLAG_IN_PROCESS, &tu->flags) ? 146 + tu->regs[TU_REG_CMD] : 0; 147 break; 148 } 149 150 return ret; 151 + } 152 + 153 + static void i2c_slave_testunit_work(struct work_struct *work) 154 + { 155 + struct testunit_data *tu = container_of(work, struct testunit_data, worker.work); 156 + unsigned long time_left; 157 + struct i2c_msg msg; 158 + u8 msgbuf[256]; 159 + u16 orig_addr; 160 + int ret = 0; 161 + 162 + msg.addr = I2C_CLIENT_END; 163 + msg.buf = msgbuf; 164 + 165 + switch (tu->regs[TU_REG_CMD]) { 166 + case TU_CMD_READ_BYTES: 167 + msg.addr = tu->regs[TU_REG_DATAL]; 168 + msg.flags = I2C_M_RD; 169 + msg.len = tu->regs[TU_REG_DATAH]; 170 + break; 171 + 172 + case TU_CMD_SMBUS_HOST_NOTIFY: 173 + msg.addr = 0x08; 174 + msg.flags = 0; 175 + msg.len = 3; 176 + msgbuf[0] = tu->client->addr; 177 + msgbuf[1] = tu->regs[TU_REG_DATAL]; 178 + msgbuf[2] = tu->regs[TU_REG_DATAH]; 179 + break; 180 + 181 + case TU_CMD_SMBUS_ALERT_REQUEST: 182 + i2c_slave_unregister(tu->client); 183 + orig_addr = tu->client->addr; 184 + tu->client->addr = 0x0c; 185 + ret = i2c_slave_register(tu->client, i2c_slave_testunit_smbalert_cb); 186 + if (ret) 187 + goto out_smbalert; 188 + 189 + reinit_completion(&tu->alert_done); 190 + gpiod_set_value(tu->gpio, 1); 191 + time_left = wait_for_completion_timeout(&tu->alert_done, HZ); 192 + if (!time_left) 193 + ret = -ETIMEDOUT; 194 + 195 + i2c_slave_unregister(tu->client); 196 + out_smbalert: 197 + tu->client->addr = orig_addr; 198 + i2c_slave_register(tu->client, i2c_slave_testunit_slave_cb); 199 + break; 200 + 201 + default: 202 + break; 203 + } 204 + 205 + if (msg.addr != I2C_CLIENT_END) { 206 + ret = i2c_transfer(tu->client->adapter, &msg, 1); 207 + /* convert '0 msgs transferred' to errno */ 208 + ret = (ret == 0) ? -EIO : ret; 209 + } 210 + 211 + if (ret < 0) 212 + dev_err(&tu->client->dev, "CMD%02X failed (%d)\n", tu->regs[TU_REG_CMD], ret); 213 + 214 + clear_bit(TU_FLAG_IN_PROCESS, &tu->flags); 215 } 216 217 static int i2c_slave_testunit_probe(struct i2c_client *client) ··· 158 159 tu->client = client; 160 i2c_set_clientdata(client, tu); 161 + init_completion(&tu->alert_done); 162 INIT_DELAYED_WORK(&tu->worker, i2c_slave_testunit_work); 163 + 164 + tu->gpio = devm_gpiod_get_index_optional(&client->dev, NULL, 0, GPIOD_OUT_LOW); 165 + if (gpiod_cansleep(tu->gpio)) { 166 + dev_err(&client->dev, "GPIO access which may sleep is not allowed\n"); 167 + return -EDEADLK; 168 + } 169 + 170 + if (sizeof(tu_version_info) > TU_VERSION_MAX_LENGTH) 171 + tu_version_info[TU_VERSION_MAX_LENGTH - 1] = 0; 172 173 return i2c_slave_register(client, i2c_slave_testunit_slave_cb); 174 };
+16
drivers/i2c/muxes/Kconfig
··· 119 This driver can also be built as a module. If so, the module 120 will be called i2c-mux-mlxcpld. 121 122 endmenu
··· 119 This driver can also be built as a module. If so, the module 120 will be called i2c-mux-mlxcpld. 121 122 + config I2C_MUX_MULE 123 + tristate "Theobroma Systems Mule I2C device multiplexer" 124 + depends on OF && SENSORS_AMC6821 125 + help 126 + Mule is an MCU that emulates a set of I2C devices, among which 127 + devices that are reachable through an I2C-mux. The devices on the mux 128 + can be selected by writing the appropriate device number to an I2C 129 + configuration register. 130 + 131 + If you say yes to this option, support will be included for a 132 + Theobroma Systems Mule I2C multiplexer. This driver provides access to 133 + I2C devices connected on this mux. 134 + 135 + This driver can also be built as a module. If so, the module 136 + will be called i2c-mux-mule. 137 + 138 endmenu
+1
drivers/i2c/muxes/Makefile
··· 10 obj-$(CONFIG_I2C_MUX_GPMUX) += i2c-mux-gpmux.o 11 obj-$(CONFIG_I2C_MUX_LTC4306) += i2c-mux-ltc4306.o 12 obj-$(CONFIG_I2C_MUX_MLXCPLD) += i2c-mux-mlxcpld.o 13 obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o 14 obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o 15 obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o
··· 10 obj-$(CONFIG_I2C_MUX_GPMUX) += i2c-mux-gpmux.o 11 obj-$(CONFIG_I2C_MUX_LTC4306) += i2c-mux-ltc4306.o 12 obj-$(CONFIG_I2C_MUX_MLXCPLD) += i2c-mux-mlxcpld.o 13 + obj-$(CONFIG_I2C_MUX_MULE) += i2c-mux-mule.o 14 obj-$(CONFIG_I2C_MUX_PCA9541) += i2c-mux-pca9541.o 15 obj-$(CONFIG_I2C_MUX_PCA954x) += i2c-mux-pca954x.o 16 obj-$(CONFIG_I2C_MUX_PINCTRL) += i2c-mux-pinctrl.o
+148
drivers/i2c/muxes/i2c-mux-mule.c
···
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Theobroma Systems Mule I2C device multiplexer 4 + * 5 + * Copyright (C) 2024 Theobroma Systems Design und Consulting GmbH 6 + */ 7 + 8 + #include <linux/i2c-mux.h> 9 + #include <linux/i2c.h> 10 + #include <linux/module.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/property.h> 14 + #include <linux/regmap.h> 15 + 16 + #define MULE_I2C_MUX_CONFIG_REG 0xff 17 + #define MULE_I2C_MUX_DEFAULT_DEV 0x0 18 + 19 + struct mule_i2c_reg_mux { 20 + struct regmap *regmap; 21 + }; 22 + 23 + static int mule_i2c_mux_select(struct i2c_mux_core *muxc, u32 dev) 24 + { 25 + struct mule_i2c_reg_mux *mux = muxc->priv; 26 + 27 + return regmap_write(mux->regmap, MULE_I2C_MUX_CONFIG_REG, dev); 28 + } 29 + 30 + static int mule_i2c_mux_deselect(struct i2c_mux_core *muxc, u32 dev) 31 + { 32 + return mule_i2c_mux_select(muxc, MULE_I2C_MUX_DEFAULT_DEV); 33 + } 34 + 35 + static void mule_i2c_mux_remove(void *data) 36 + { 37 + struct i2c_mux_core *muxc = data; 38 + 39 + i2c_mux_del_adapters(muxc); 40 + 41 + mule_i2c_mux_deselect(muxc, MULE_I2C_MUX_DEFAULT_DEV); 42 + } 43 + 44 + static int mule_i2c_mux_probe(struct platform_device *pdev) 45 + { 46 + struct device *mux_dev = &pdev->dev; 47 + struct mule_i2c_reg_mux *priv; 48 + struct i2c_client *client; 49 + struct i2c_mux_core *muxc; 50 + struct device_node *dev; 51 + unsigned int readback; 52 + int ndev, ret; 53 + bool old_fw; 54 + 55 + /* Count devices on the mux */ 56 + ndev = of_get_child_count(mux_dev->of_node); 57 + dev_dbg(mux_dev, "%d devices on the mux\n", ndev); 58 + 59 + client = to_i2c_client(mux_dev->parent); 60 + 61 + muxc = i2c_mux_alloc(client->adapter, mux_dev, ndev, sizeof(*priv), 62 + I2C_MUX_LOCKED, mule_i2c_mux_select, mule_i2c_mux_deselect); 63 + if (!muxc) 64 + return -ENOMEM; 65 + 66 + priv = i2c_mux_priv(muxc); 67 + 68 + priv->regmap = dev_get_regmap(mux_dev->parent, NULL); 69 + if (IS_ERR(priv->regmap)) 70 + return dev_err_probe(mux_dev, PTR_ERR(priv->regmap), 71 + "No parent i2c register map\n"); 72 + 73 + platform_set_drvdata(pdev, muxc); 74 + 75 + /* 76 + * MULE_I2C_MUX_DEFAULT_DEV is guaranteed to exist on all old and new 77 + * mule fw. Mule fw without mux support will accept write ops to the 78 + * config register, but readback returns 0xff (register not updated). 79 + */ 80 + ret = mule_i2c_mux_select(muxc, MULE_I2C_MUX_DEFAULT_DEV); 81 + if (ret) 82 + return dev_err_probe(mux_dev, ret, 83 + "Failed to write config register\n"); 84 + 85 + ret = regmap_read(priv->regmap, MULE_I2C_MUX_CONFIG_REG, &readback); 86 + if (ret) 87 + return dev_err_probe(mux_dev, ret, 88 + "Failed to read config register\n"); 89 + 90 + old_fw = (readback != MULE_I2C_MUX_DEFAULT_DEV); 91 + 92 + ret = devm_add_action_or_reset(mux_dev, mule_i2c_mux_remove, muxc); 93 + if (ret) 94 + return dev_err_probe(mux_dev, ret, 95 + "Failed to register mux remove\n"); 96 + 97 + /* Create device adapters */ 98 + for_each_child_of_node(mux_dev->of_node, dev) { 99 + u32 reg; 100 + 101 + ret = of_property_read_u32(dev, "reg", &reg); 102 + if (ret) 103 + return dev_err_probe(mux_dev, ret, 104 + "No reg property found for %s\n", 105 + of_node_full_name(dev)); 106 + 107 + if (old_fw && reg != 0) { 108 + dev_warn(mux_dev, 109 + "Mux is not supported, please update Mule FW\n"); 110 + continue; 111 + } 112 + 113 + ret = mule_i2c_mux_select(muxc, reg); 114 + if (ret) { 115 + dev_warn(mux_dev, 116 + "Device %d not supported, please update Mule FW\n", reg); 117 + continue; 118 + } 119 + 120 + ret = i2c_mux_add_adapter(muxc, 0, reg); 121 + if (ret) 122 + return ret; 123 + } 124 + 125 + mule_i2c_mux_deselect(muxc, MULE_I2C_MUX_DEFAULT_DEV); 126 + 127 + return 0; 128 + } 129 + 130 + static const struct of_device_id mule_i2c_mux_of_match[] = { 131 + { .compatible = "tsd,mule-i2c-mux", }, 132 + {}, 133 + }; 134 + MODULE_DEVICE_TABLE(of, mule_i2c_mux_of_match); 135 + 136 + static struct platform_driver mule_i2c_mux_driver = { 137 + .driver = { 138 + .name = "mule-i2c-mux", 139 + .of_match_table = mule_i2c_mux_of_match, 140 + }, 141 + .probe = mule_i2c_mux_probe, 142 + }; 143 + 144 + module_platform_driver(mule_i2c_mux_driver); 145 + 146 + MODULE_AUTHOR("Farouk Bouabid <farouk.bouabid@cherry.de>"); 147 + MODULE_DESCRIPTION("I2C mux driver for Theobroma Systems Mule"); 148 + MODULE_LICENSE("GPL");
+1 -2
drivers/net/ethernet/wangxun/Kconfig
··· 41 tristate "Wangxun(R) 10GbE PCI Express adapters support" 42 depends on PCI 43 depends on COMMON_CLK 44 select MARVELL_10G_PHY 45 select REGMAP 46 - select I2C 47 - select I2C_DESIGNWARE_PLATFORM 48 select PHYLINK 49 select HWMON if TXGBE=y 50 select SFP
··· 41 tristate "Wangxun(R) 10GbE PCI Express adapters support" 42 depends on PCI 43 depends on COMMON_CLK 44 + depends on I2C_DESIGNWARE_PLATFORM 45 select MARVELL_10G_PHY 46 select REGMAP 47 select PHYLINK 48 select HWMON if TXGBE=y 49 select SFP
+3
include/linux/i2c.h
··· 761 struct regulator *bus_regulator; 762 763 struct dentry *debugfs; 764 }; 765 #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 766
··· 761 struct regulator *bus_regulator; 762 763 struct dentry *debugfs; 764 + 765 + /* 7bit address space */ 766 + DECLARE_BITMAP(addrs_in_instantiation, 1 << 7); 767 }; 768 #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 769