Pull i2c updates from Wolfram Sang: - core supports now bus regulators controlling power for SCL/SDA - quite some DT binding conversions to YAML - added a seperate DT binding for the optional SMBus Alert feature - documentation with examples how to deal with I2C sysfs files - some bigger rework for the i801 driver - and a few usual driver updates * 'i2c/for-mergewindow' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (42 commits) i2c: ali1535: mention that the device should not be disabled i2c: mpc: Restore reread of I2C status register i2c: core-smbus: Expose PEC calculate function for generic use Documentation: i2c: Add doc for I2C sysfs i2c: core: Disable client irq on reboot/shutdown dt-bindings: i2c: update bindings for MT8195 SoC i2c: imx: Fix some checkpatch warnings i2c: davinci: Simplify with dev_err_probe() i2c: cadence: Simplify with dev_err_probe() i2c: xiic: Simplify with dev_err_probe() i2c: cadence: Clear HOLD bit before xfer_size register rolls over dt-bindings: i2c: ce4100: Replace "ti,pcf8575" by "nxp,pcf8575" i2c: i801: Improve i801_setup_hstcfg i2c: i801: Use driver name constant instead of function dev_driver_string i2c: i801: Simplify initialization of i2c_board_info in i801_probe_optional_slaves i2c: i801: Improve status polling i2c: cht-wc: Replace of_node by NULL i2c: riic: Add RZ/G2L support dt-bindings: i2c: renesas,riic: Document RZ/G2L I2C controller dt-bindings: i2c: renesas,iic: Convert to json-schema ...
Unified · Split
| @@ -15,6 +15,7 @@ Required properties: · 14 unmodified lines | ||
| 15 | 15 | "mediatek,mt8173-i2c": for MediaTek MT8173 |
| 16 | 16 | "mediatek,mt8183-i2c": for MediaTek MT8183 |
| 17 | 17 | "mediatek,mt8192-i2c": for MediaTek MT8192 |
| 18 | + "mediatek,mt8195-i2c", "mediatek,mt8192-i2c": for MediaTek MT8195 | |
| 18 | 19 | "mediatek,mt8516-i2c", "mediatek,mt2712-i2c": for MediaTek MT8516 |
| 19 | 20 | - reg: physical base address of the controller and dma base, length of memory |
| 20 | 21 | mapped region. |
| @@ -32,6 +33,7 @@ Optional properties: · 11 unmodified lines | ||
| 32 | 33 | - mediatek,have-pmic: platform can control i2c form special pmic side. |
| 33 | 34 | Only mt6589 and mt8135 support this feature. |
| 34 | 35 | - mediatek,use-push-pull: IO config use push-pull mode. |
| 36 | + - vbus-supply: phandle to the regulator that provides power to SCL/SDA. | |
| 35 | 37 | |
| 36 | 38 | Example: |
| 37 | 39 | |
| @@ -62,7 +62,6 @@ Example: · 61 unmodified lines | ||
| 62 | 62 | reg = <0x3c>; |
| 63 | 63 | pwms = <&pwm 4 3000>; |
| 64 | 64 | reset-gpios = <&gpio2 7 1>; |
| 65 | − reset-active-low; | |
| 66 | 65 | }; |
| 67 | 66 | }; |
| 68 | 67 | |
| @@ -1,37 +0,0 @@ | ||
| 1 | −I2C for OMAP platforms | |
| 2 | − | |
| 3 | −Required properties : | |
| 4 | −- compatible : Must be | |
| 5 | − "ti,omap2420-i2c" for OMAP2420 SoCs | |
| 6 | − "ti,omap2430-i2c" for OMAP2430 SoCs | |
| 7 | − "ti,omap3-i2c" for OMAP3 SoCs | |
| 8 | − "ti,omap4-i2c" for OMAP4+ SoCs | |
| 9 | − "ti,am654-i2c", "ti,omap4-i2c" for AM654 SoCs | |
| 10 | − "ti,j721e-i2c", "ti,omap4-i2c" for J721E SoCs | |
| 11 | − "ti,am64-i2c", "ti,omap4-i2c" for AM64 SoCs | |
| 12 | −- ti,hwmods : Must be "i2c<n>", n being the instance number (1-based) | |
| 13 | −- #address-cells = <1>; | |
| 14 | −- #size-cells = <0>; | |
| 15 | − | |
| 16 | −Recommended properties : | |
| 17 | −- clock-frequency : Desired I2C bus clock frequency in Hz. Otherwise | |
| 18 | − the default 100 kHz frequency will be used. | |
| 19 | − | |
| 20 | −Optional properties: | |
| 21 | −- Child nodes conforming to i2c bus binding | |
| 22 | − | |
| 23 | −Note: Current implementation will fetch base address, irq and dma | |
| 24 | −from omap hwmod data base during device registration. | |
| 25 | −Future plan is to migrate hwmod data base contents into device tree | |
| 26 | −blob so that, all the required data will be used from device tree dts | |
| 27 | −file. | |
| 28 | − | |
| 29 | −Examples : | |
| 30 | − | |
| 31 | −i2c1: i2c@0 { | |
| 32 | − compatible = "ti,omap3-i2c"; | |
| 33 | − #address-cells = <1>; | |
| 34 | − #size-cells = <0>; | |
| 35 | − ti,hwmods = "i2c1"; | |
| 36 | − clock-frequency = <400000>; | |
| 37 | −}; | |
| @@ -71,7 +71,7 @@ This is an example which is used on FalconFalls: · 70 unmodified lines | ||
| 71 | 71 | /* This I2C controller has one gpio controller */ |
| 72 | 72 | gpio@26 { |
| 73 | 73 | #gpio-cells = <2>; |
| 74 | − compatible = "ti,pcf8575"; | |
| 74 | + compatible = "nxp,pcf8575"; | |
| 75 | 75 | reg = <0x26>; |
| 76 | 76 | gpio-controller; |
| 77 | 77 | }; |
| @@ -85,7 +85,7 @@ This is an example which is used on FalconFalls: · 7 unmodified lines | ||
| 85 | 85 | |
| 86 | 86 | gpio@26 { |
| 87 | 87 | #gpio-cells = <2>; |
| 88 | − compatible = "ti,pcf8575"; | |
| 88 | + compatible = "nxp,pcf8575"; | |
| 89 | 89 | reg = <0x26>; |
| 90 | 90 | gpio-controller; |
| 91 | 91 | }; |
| @@ -9,6 +9,7 @@ PROPERTIES: · 8 unmodified lines | ||
| 9 | 9 | "qcom,msm8916-cci" |
| 10 | 10 | "qcom,msm8996-cci" |
| 11 | 11 | "qcom,sdm845-cci" |
| 12 | + "qcom,sm8250-cci" | |
| 12 | 13 | |
| 13 | 14 | - reg |
| 14 | 15 | Usage: required |
| @@ -41,8 +42,8 @@ PROPERTIES: · 26 unmodified lines | ||
| 41 | 42 | |
| 42 | 43 | SUBNODES: |
| 43 | 44 | |
| 44 | −The CCI provides I2C masters for one (msm8916) or two i2c busses (msm8996 and | |
| 45 | −sdm845), described as subdevices named "i2c-bus@0" and "i2c-bus@1". | |
| 45 | +The CCI provides I2C masters for one (msm8916) or two i2c busses (msm8996, | |
| 46 | +sdm845 and sm8250), described as subdevices named "i2c-bus@0" and "i2c-bus@1". | |
| 46 | 47 | |
| 47 | 48 | PROPERTIES: |
| 48 | 49 | |
| @@ -36,6 +36,7 @@ properties: · 35 unmodified lines | ||
| 36 | 36 | - rockchip,px30-i2c |
| 37 | 37 | - rockchip,rk3308-i2c |
| 38 | 38 | - rockchip,rk3328-i2c |
| 39 | + - rockchip,rk3568-i2c | |
| 39 | 40 | - const: rockchip,rk3399-i2c |
| 40 | 41 | |
| 41 | 42 | reg: |
| @@ -89,8 +89,11 @@ wants to support one of the below features, it should adapt these bindings. · 88 unmodified lines | ||
| 89 | 89 | |
| 90 | 90 | - smbus |
| 91 | 91 | states that additional SMBus restrictions and features apply to this bus. |
| 92 | − Examples of features are SMBusHostNotify and SMBusAlert. Examples of | |
| 93 | − restrictions are more reserved addresses and timeout definitions. | |
| 92 | + An example of feature is SMBusHostNotify. Examples of restrictions are | |
| 93 | + more reserved addresses and timeout definitions. | |
| 94 | + | |
| 95 | +- smbus-alert | |
| 96 | + states that the optional SMBus-Alert feature apply to this bus. | |
| 94 | 97 | |
| 95 | 98 | Required properties (per child device) |
| 96 | 99 | -------------------------------------- |
| @@ -1,67 +0,0 @@ | ||
| 1 | −I2C for R-Car platforms | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible: | |
| 5 | − "renesas,i2c-r8a7742" if the device is a part of a R8A7742 SoC. | |
| 6 | − "renesas,i2c-r8a7743" if the device is a part of a R8A7743 SoC. | |
| 7 | − "renesas,i2c-r8a7744" if the device is a part of a R8A7744 SoC. | |
| 8 | − "renesas,i2c-r8a7745" if the device is a part of a R8A7745 SoC. | |
| 9 | − "renesas,i2c-r8a77470" if the device is a part of a R8A77470 SoC. | |
| 10 | − "renesas,i2c-r8a774a1" if the device is a part of a R8A774A1 SoC. | |
| 11 | − "renesas,i2c-r8a774b1" if the device is a part of a R8A774B1 SoC. | |
| 12 | − "renesas,i2c-r8a774c0" if the device is a part of a R8A774C0 SoC. | |
| 13 | − "renesas,i2c-r8a774e1" if the device is a part of a R8A774E1 SoC. | |
| 14 | − "renesas,i2c-r8a7778" if the device is a part of a R8A7778 SoC. | |
| 15 | − "renesas,i2c-r8a7779" if the device is a part of a R8A7779 SoC. | |
| 16 | − "renesas,i2c-r8a7790" if the device is a part of a R8A7790 SoC. | |
| 17 | − "renesas,i2c-r8a7791" if the device is a part of a R8A7791 SoC. | |
| 18 | − "renesas,i2c-r8a7792" if the device is a part of a R8A7792 SoC. | |
| 19 | − "renesas,i2c-r8a7793" if the device is a part of a R8A7793 SoC. | |
| 20 | − "renesas,i2c-r8a7794" if the device is a part of a R8A7794 SoC. | |
| 21 | − "renesas,i2c-r8a7795" if the device is a part of a R8A7795 SoC. | |
| 22 | − "renesas,i2c-r8a7796" if the device is a part of a R8A77960 SoC. | |
| 23 | − "renesas,i2c-r8a77961" if the device is a part of a R8A77961 SoC. | |
| 24 | − "renesas,i2c-r8a77965" if the device is a part of a R8A77965 SoC. | |
| 25 | − "renesas,i2c-r8a77970" if the device is a part of a R8A77970 SoC. | |
| 26 | − "renesas,i2c-r8a77980" if the device is a part of a R8A77980 SoC. | |
| 27 | − "renesas,i2c-r8a77990" if the device is a part of a R8A77990 SoC. | |
| 28 | − "renesas,i2c-r8a77995" if the device is a part of a R8A77995 SoC. | |
| 29 | − "renesas,i2c-r8a779a0" if the device is a part of a R8A779A0 SoC. | |
| 30 | − "renesas,rcar-gen1-i2c" for a generic R-Car Gen1 compatible device. | |
| 31 | − "renesas,rcar-gen2-i2c" for a generic R-Car Gen2 or RZ/G1 compatible | |
| 32 | − device. | |
| 33 | − "renesas,rcar-gen3-i2c" for a generic R-Car Gen3 or RZ/G2 compatible | |
| 34 | − device. | |
| 35 | − "renesas,i2c-rcar" (deprecated) | |
| 36 | − | |
| 37 | − When compatible with the generic version, nodes must list the | |
| 38 | − SoC-specific version corresponding to the platform first followed | |
| 39 | − by the generic version. | |
| 40 | − | |
| 41 | −- reg: physical base address of the controller and length of memory mapped | |
| 42 | − region. | |
| 43 | −- interrupts: interrupt specifier. | |
| 44 | − | |
| 45 | −Optional properties: | |
| 46 | −- clock-frequency: desired I2C bus clock frequency in Hz. The absence of this | |
| 47 | − property indicates the default frequency 100 kHz. | |
| 48 | −- clocks: clock specifier. | |
| 49 | −- dmas: Must contain a list of two references to DMA specifiers, one for | |
| 50 | − transmission, and one for reception. | |
| 51 | −- dma-names: Must contain a list of two DMA names, "tx" and "rx". | |
| 52 | − | |
| 53 | −- i2c-scl-falling-time-ns: see i2c.txt | |
| 54 | −- i2c-scl-internal-delay-ns: see i2c.txt | |
| 55 | −- i2c-scl-rising-time-ns: see i2c.txt | |
| 56 | − | |
| 57 | −Examples : | |
| 58 | − | |
| 59 | −i2c0: i2c@e6508000 { | |
| 60 | − #address-cells = <1>; | |
| 61 | − #size-cells = <0>; | |
| 62 | − compatible = "renesas,i2c-r8a7791", "renesas,rcar-gen2-i2c"; | |
| 63 | − reg = <0 0xe6508000 0 0x40>; | |
| 64 | − interrupts = <0 287 IRQ_TYPE_LEVEL_HIGH>; | |
| 65 | − clocks = <&mstp9_clks R8A7791_CLK_I2C0>; | |
| 66 | − clock-frequency = <400000>; | |
| 67 | −}; | |
| @@ -1,22 +0,0 @@ | ||
| 1 | −Device tree configuration for Renesas EMEV2 IIC controller | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : "renesas,iic-emev2" | |
| 5 | −- reg : address start and address range size of device | |
| 6 | −- interrupts : specifier for the IIC controller interrupt | |
| 7 | −- clocks : phandle to the IP core SCLK | |
| 8 | −- clock-names : must be "sclk" | |
| 9 | −- #address-cells : should be <1> | |
| 10 | −- #size-cells : should be <0> | |
| 11 | − | |
| 12 | −Example: | |
| 13 | − | |
| 14 | − iic0: i2c@e0070000 { | |
| 15 | − #address-cells = <1>; | |
| 16 | − #size-cells = <0>; | |
| 17 | − compatible = "renesas,iic-emev2"; | |
| 18 | − reg = <0xe0070000 0x28>; | |
| 19 | − interrupts = <0 32 IRQ_TYPE_EDGE_RISING>; | |
| 20 | − clocks = <&iic0_sclk>; | |
| 21 | − clock-names = "sclk"; | |
| 22 | − }; | |
| @@ -0,0 +1,54 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/i2c/renesas,iic-emev2.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Renesas EMMA Mobile EV2 IIC Interface | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Wolfram Sang <wsa+renesas@sang-engineering.com> | |
| 11 | + | |
| 12 | +allOf: | |
| 13 | + - $ref: /schemas/i2c/i2c-controller.yaml# | |
| 14 | + | |
| 15 | +properties: | |
| 16 | + compatible: | |
| 17 | + const: renesas,iic-emev2 | |
| 18 | + | |
| 19 | + reg: | |
| 20 | + maxItems: 1 | |
| 21 | + | |
| 22 | + interrupts: | |
| 23 | + maxItems: 1 | |
| 24 | + | |
| 25 | + clocks: | |
| 26 | + maxItems: 1 | |
| 27 | + | |
| 28 | + clock-names: | |
| 29 | + const: sclk | |
| 30 | + | |
| 31 | +required: | |
| 32 | + - compatible | |
| 33 | + - reg | |
| 34 | + - interrupts | |
| 35 | + - clocks | |
| 36 | + - clock-names | |
| 37 | + - '#address-cells' | |
| 38 | + - '#size-cells' | |
| 39 | + | |
| 40 | +unevaluatedProperties: false | |
| 41 | + | |
| 42 | +examples: | |
| 43 | + - | | |
| 44 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 45 | + | |
| 46 | + iic0: i2c@e0070000 { | |
| 47 | + #address-cells = <1>; | |
| 48 | + #size-cells = <0>; | |
| 49 | + compatible = "renesas,iic-emev2"; | |
| 50 | + reg = <0xe0070000 0x28>; | |
| 51 | + interrupts = <GIC_SPI 32 IRQ_TYPE_EDGE_RISING>; | |
| 52 | + clocks = <&iic0_sclk>; | |
| 53 | + clock-names = "sclk"; | |
| 54 | + }; | |
| @@ -1,72 +0,0 @@ | ||
| 1 | −Device tree configuration for Renesas IIC (sh_mobile) driver | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : | |
| 5 | − - "renesas,iic-r8a73a4" (R-Mobile APE6) | |
| 6 | − - "renesas,iic-r8a7740" (R-Mobile A1) | |
| 7 | − - "renesas,iic-r8a7742" (RZ/G1H) | |
| 8 | − - "renesas,iic-r8a7743" (RZ/G1M) | |
| 9 | − - "renesas,iic-r8a7744" (RZ/G1N) | |
| 10 | − - "renesas,iic-r8a7745" (RZ/G1E) | |
| 11 | − - "renesas,iic-r8a774a1" (RZ/G2M) | |
| 12 | − - "renesas,iic-r8a774b1" (RZ/G2N) | |
| 13 | − - "renesas,iic-r8a774c0" (RZ/G2E) | |
| 14 | − - "renesas,iic-r8a774e1" (RZ/G2H) | |
| 15 | − - "renesas,iic-r8a7790" (R-Car H2) | |
| 16 | − - "renesas,iic-r8a7791" (R-Car M2-W) | |
| 17 | − - "renesas,iic-r8a7792" (R-Car V2H) | |
| 18 | − - "renesas,iic-r8a7793" (R-Car M2-N) | |
| 19 | − - "renesas,iic-r8a7794" (R-Car E2) | |
| 20 | − - "renesas,iic-r8a7795" (R-Car H3) | |
| 21 | − - "renesas,iic-r8a7796" (R-Car M3-W) | |
| 22 | − - "renesas,iic-r8a77961" (R-Car M3-W+) | |
| 23 | − - "renesas,iic-r8a77965" (R-Car M3-N) | |
| 24 | − - "renesas,iic-r8a77990" (R-Car E3) | |
| 25 | − - "renesas,iic-sh73a0" (SH-Mobile AG5) | |
| 26 | − - "renesas,rcar-gen2-iic" (generic R-Car Gen2 or RZ/G1 | |
| 27 | − compatible device) | |
| 28 | − - "renesas,rcar-gen3-iic" (generic R-Car Gen3 or RZ/G2 | |
| 29 | − compatible device) | |
| 30 | − - "renesas,rmobile-iic" (generic device) | |
| 31 | − | |
| 32 | − When compatible with a generic R-Car version, nodes | |
| 33 | − must list the SoC-specific version corresponding to | |
| 34 | − the platform first followed by the generic R-Car | |
| 35 | − version. | |
| 36 | − | |
| 37 | − When compatible with "renesas,rmobile-iic" it should | |
| 38 | − be the last compatibility string listed. | |
| 39 | − | |
| 40 | − The r8a77990 (R-Car E3) and r8a774c0 (RZ/G2E) | |
| 41 | − controllers are not considered compatible with | |
| 42 | − "renesas,rcar-gen3-iic" or "renesas,rmobile-iic" | |
| 43 | − due to the absence of automatic transmission registers. | |
| 44 | − | |
| 45 | −- reg : address start and address range size of device | |
| 46 | −- interrupts : interrupt of device | |
| 47 | −- clocks : clock for device | |
| 48 | −- #address-cells : should be <1> | |
| 49 | −- #size-cells : should be <0> | |
| 50 | − | |
| 51 | −Optional properties: | |
| 52 | −- clock-frequency : frequency of bus clock in Hz. Default 100kHz if unset. | |
| 53 | −- dmas : Must contain a list of two references to DMA | |
| 54 | − specifiers, one for transmission, and one for | |
| 55 | − reception. | |
| 56 | −- dma-names : Must contain a list of two DMA names, "tx" and "rx". | |
| 57 | − | |
| 58 | − | |
| 59 | −Pinctrl properties might be needed, too. See there. | |
| 60 | − | |
| 61 | −Example: | |
| 62 | − | |
| 63 | − iic0: i2c@e6500000 { | |
| 64 | − compatible = "renesas,iic-r8a7790", "renesas,rcar-gen2-iic", | |
| 65 | − "renesas,rmobile-iic"; | |
| 66 | − reg = <0 0xe6500000 0 0x425>; | |
| 67 | − interrupts = <0 174 IRQ_TYPE_LEVEL_HIGH>; | |
| 68 | − clocks = <&mstp3_clks R8A7790_CLK_IIC0>; | |
| 69 | − clock-frequency = <400000>; | |
| 70 | − #address-cells = <1>; | |
| 71 | − #size-cells = <0>; | |
| 72 | − }; | |
| @@ -0,0 +1,158 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/i2c/renesas,rcar-i2c.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Renesas R-Car I2C Controller | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Wolfram Sang <wsa+renesas@sang-engineering.com> | |
| 11 | + | |
| 12 | +properties: | |
| 13 | + compatible: | |
| 14 | + oneOf: | |
| 15 | + - items: | |
| 16 | + - enum: | |
| 17 | + - renesas,i2c-r8a7778 # R-Car M1A | |
| 18 | + - renesas,i2c-r8a7779 # R-Car H1 | |
| 19 | + - const: renesas,rcar-gen1-i2c # R-Car Gen1 | |
| 20 | + | |
| 21 | + - items: | |
| 22 | + - enum: | |
| 23 | + - renesas,i2c-r8a7742 # RZ/G1H | |
| 24 | + - renesas,i2c-r8a7743 # RZ/G1M | |
| 25 | + - renesas,i2c-r8a7744 # RZ/G1N | |
| 26 | + - renesas,i2c-r8a7745 # RZ/G1E | |
| 27 | + - renesas,i2c-r8a77470 # RZ/G1C | |
| 28 | + - renesas,i2c-r8a7790 # R-Car H2 | |
| 29 | + - renesas,i2c-r8a7791 # R-Car M2-W | |
| 30 | + - renesas,i2c-r8a7792 # R-Car V2H | |
| 31 | + - renesas,i2c-r8a7793 # R-Car M2-N | |
| 32 | + - renesas,i2c-r8a7794 # R-Car E2 | |
| 33 | + - const: renesas,rcar-gen2-i2c # R-Car Gen2 and RZ/G1 | |
| 34 | + | |
| 35 | + - items: | |
| 36 | + - enum: | |
| 37 | + - renesas,i2c-r8a774a1 # RZ/G2M | |
| 38 | + - renesas,i2c-r8a774b1 # RZ/G2N | |
| 39 | + - renesas,i2c-r8a774c0 # RZ/G2E | |
| 40 | + - renesas,i2c-r8a774e1 # RZ/G2H | |
| 41 | + - renesas,i2c-r8a7795 # R-Car H3 | |
| 42 | + - renesas,i2c-r8a7796 # R-Car M3-W | |
| 43 | + - renesas,i2c-r8a77961 # R-Car M3-W+ | |
| 44 | + - renesas,i2c-r8a77965 # R-Car M3-N | |
| 45 | + - renesas,i2c-r8a77970 # R-Car V3M | |
| 46 | + - renesas,i2c-r8a77980 # R-Car V3H | |
| 47 | + - renesas,i2c-r8a77990 # R-Car E3 | |
| 48 | + - renesas,i2c-r8a77995 # R-Car D3 | |
| 49 | + - renesas,i2c-r8a779a0 # R-Car V3U | |
| 50 | + - const: renesas,rcar-gen3-i2c # R-Car Gen3 and RZ/G2 | |
| 51 | + | |
| 52 | + reg: | |
| 53 | + maxItems: 1 | |
| 54 | + | |
| 55 | + interrupts: | |
| 56 | + maxItems: 1 | |
| 57 | + | |
| 58 | + clock-frequency: | |
| 59 | + description: | |
| 60 | + Desired I2C bus clock frequency in Hz. The absence of this property | |
| 61 | + indicates the default frequency 100 kHz. | |
| 62 | + | |
| 63 | + clocks: | |
| 64 | + maxItems: 1 | |
| 65 | + | |
| 66 | + power-domains: | |
| 67 | + maxItems: 1 | |
| 68 | + | |
| 69 | + resets: | |
| 70 | + maxItems: 1 | |
| 71 | + | |
| 72 | + dmas: | |
| 73 | + minItems: 2 | |
| 74 | + maxItems: 4 | |
| 75 | + description: | |
| 76 | + Must contain a list of pairs of references to DMA specifiers, one for | |
| 77 | + transmission, and one for reception. | |
| 78 | + | |
| 79 | + dma-names: | |
| 80 | + minItems: 2 | |
| 81 | + maxItems: 4 | |
| 82 | + items: | |
| 83 | + enum: | |
| 84 | + - tx | |
| 85 | + - rx | |
| 86 | + | |
| 87 | + i2c-scl-falling-time-ns: | |
| 88 | + default: 35 | |
| 89 | + description: | |
| 90 | + Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C | |
| 91 | + specification. | |
| 92 | + | |
| 93 | + i2c-scl-internal-delay-ns: | |
| 94 | + default: 50 | |
| 95 | + description: | |
| 96 | + Number of nanoseconds the IP core additionally needs to setup SCL. | |
| 97 | + | |
| 98 | + i2c-scl-rising-time-ns: | |
| 99 | + default: 200 | |
| 100 | + description: | |
| 101 | + Number of nanoseconds the SCL signal takes to rise; t(r) in the I2C | |
| 102 | + specification. | |
| 103 | + | |
| 104 | +required: | |
| 105 | + - compatible | |
| 106 | + - reg | |
| 107 | + - interrupts | |
| 108 | + - clocks | |
| 109 | + - power-domains | |
| 110 | + - '#address-cells' | |
| 111 | + - '#size-cells' | |
| 112 | + | |
| 113 | +allOf: | |
| 114 | + - $ref: /schemas/i2c/i2c-controller.yaml# | |
| 115 | + | |
| 116 | + - if: | |
| 117 | + properties: | |
| 118 | + compatible: | |
| 119 | + contains: | |
| 120 | + enum: | |
| 121 | + - renesas,rcar-gen1-i2c | |
| 122 | + - renesas,rcar-gen2-i2c | |
| 123 | + then: | |
| 124 | + properties: | |
| 125 | + dmas: false | |
| 126 | + dma-names: false | |
| 127 | + | |
| 128 | + - if: | |
| 129 | + properties: | |
| 130 | + compatible: | |
| 131 | + contains: | |
| 132 | + enum: | |
| 133 | + - renesas,rcar-gen2-i2c | |
| 134 | + - renesas,rcar-gen3-i2c | |
| 135 | + then: | |
| 136 | + required: | |
| 137 | + - resets | |
| 138 | + | |
| 139 | +unevaluatedProperties: false | |
| 140 | + | |
| 141 | +examples: | |
| 142 | + - | | |
| 143 | + #include <dt-bindings/clock/r8a7791-cpg-mssr.h> | |
| 144 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 145 | + #include <dt-bindings/power/r8a7791-sysc.h> | |
| 146 | + | |
| 147 | + i2c0: i2c@e6508000 { | |
| 148 | + #address-cells = <1>; | |
| 149 | + #size-cells = <0>; | |
| 150 | + compatible = "renesas,i2c-r8a7791", "renesas,rcar-gen2-i2c"; | |
| 151 | + reg = <0xe6508000 0x40>; | |
| 152 | + interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>; | |
| 153 | + clock-frequency = <400000>; | |
| 154 | + clocks = <&cpg CPG_MOD 931>; | |
| 155 | + power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; | |
| 156 | + resets = <&cpg 931>; | |
| 157 | + i2c-scl-internal-delay-ns = <6>; | |
| 158 | + }; | |
| @@ -1,32 +0,0 @@ | ||
| 1 | −Device tree configuration for Renesas RIIC driver | |
| 2 | − | |
| 3 | −Required properties: | |
| 4 | −- compatible : | |
| 5 | − "renesas,riic-r7s72100" if the device is a part of a R7S72100 SoC. | |
| 6 | − "renesas,riic-r7s9210" if the device is a part of a R7S9210 SoC. | |
| 7 | − "renesas,riic-rz" for a generic RZ/A compatible device. | |
| 8 | −- reg : address start and address range size of device | |
| 9 | −- interrupts : 8 interrupts (TEI, RI, TI, SPI, STI, NAKI, ALI, TMOI) | |
| 10 | −- clock-frequency : frequency of bus clock in Hz | |
| 11 | −- #address-cells : should be <1> | |
| 12 | −- #size-cells : should be <0> | |
| 13 | − | |
| 14 | −Pinctrl properties might be needed, too. See there. | |
| 15 | − | |
| 16 | −Example: | |
| 17 | − | |
| 18 | − i2c0: i2c@fcfee000 { | |
| 19 | − compatible = "renesas,riic-r7s72100", "renesas,riic-rz"; | |
| 20 | − reg = <0xfcfee000 0x44>; | |
| 21 | − interrupts = <0 157 IRQ_TYPE_LEVEL_HIGH>, | |
| 22 | − <0 158 IRQ_TYPE_EDGE_RISING>, | |
| 23 | − <0 159 IRQ_TYPE_EDGE_RISING>, | |
| 24 | − <0 160 IRQ_TYPE_LEVEL_HIGH>, | |
| 25 | − <0 161 IRQ_TYPE_LEVEL_HIGH>, | |
| 26 | − <0 162 IRQ_TYPE_LEVEL_HIGH>, | |
| 27 | − <0 163 IRQ_TYPE_LEVEL_HIGH>, | |
| 28 | − <0 164 IRQ_TYPE_LEVEL_HIGH>; | |
| 29 | − clock-frequency = <100000>; | |
| 30 | − #address-cells = <1>; | |
| 31 | − #size-cells = <0>; | |
| 32 | − }; | |
| @@ -0,0 +1,93 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/i2c/renesas,riic.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Renesas RZ/A and RZ/G2L I2C Bus Interface (RIIC) | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Chris Brandt <chris.brandt@renesas.com> | |
| 11 | + - Wolfram Sang <wsa+renesas@sang-engineering.com> | |
| 12 | + | |
| 13 | +allOf: | |
| 14 | + - $ref: /schemas/i2c/i2c-controller.yaml# | |
| 15 | + | |
| 16 | +properties: | |
| 17 | + compatible: | |
| 18 | + items: | |
| 19 | + - enum: | |
| 20 | + - renesas,riic-r7s72100 # RZ/A1H | |
| 21 | + - renesas,riic-r7s9210 # RZ/A2M | |
| 22 | + - renesas,riic-r9a07g044 # RZ/G2{L,LC} | |
| 23 | + - const: renesas,riic-rz # RZ/A or RZ/G2L | |
| 24 | + | |
| 25 | + reg: | |
| 26 | + maxItems: 1 | |
| 27 | + | |
| 28 | + interrupts: | |
| 29 | + items: | |
| 30 | + - description: Transmit End Interrupt (TEI) | |
| 31 | + - description: Receive Data Full Interrupt (RI) | |
| 32 | + - description: Transmit Data Empty Interrupt (TI) | |
| 33 | + - description: Stop Condition Detection Interrupt (SPI) | |
| 34 | + - description: Start Condition Detection Interrupt (STI) | |
| 35 | + - description: NACK Reception Interrupt (NAKI) | |
| 36 | + - description: Arbitration-Lost Interrupt (ALI) | |
| 37 | + - description: Timeout Interrupt (TMOI) | |
| 38 | + | |
| 39 | + clock-frequency: | |
| 40 | + description: | |
| 41 | + Desired I2C bus clock frequency in Hz. The absence of this property | |
| 42 | + indicates the default frequency 100 kHz. | |
| 43 | + | |
| 44 | + clocks: | |
| 45 | + maxItems: 1 | |
| 46 | + | |
| 47 | + power-domains: | |
| 48 | + maxItems: 1 | |
| 49 | + | |
| 50 | +required: | |
| 51 | + - compatible | |
| 52 | + - reg | |
| 53 | + - interrupts | |
| 54 | + - clocks | |
| 55 | + - clock-frequency | |
| 56 | + - power-domains | |
| 57 | + - '#address-cells' | |
| 58 | + - '#size-cells' | |
| 59 | + | |
| 60 | +if: | |
| 61 | + properties: | |
| 62 | + compatible: | |
| 63 | + contains: | |
| 64 | + enum: | |
| 65 | + - renesas,riic-r9a07g044 | |
| 66 | +then: | |
| 67 | + required: | |
| 68 | + - resets | |
| 69 | + | |
| 70 | +unevaluatedProperties: false | |
| 71 | + | |
| 72 | +examples: | |
| 73 | + - | | |
| 74 | + #include <dt-bindings/clock/r7s72100-clock.h> | |
| 75 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 76 | + | |
| 77 | + i2c0: i2c@fcfee000 { | |
| 78 | + compatible = "renesas,riic-r7s72100", "renesas,riic-rz"; | |
| 79 | + reg = <0xfcfee000 0x44>; | |
| 80 | + interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>, | |
| 81 | + <GIC_SPI 158 IRQ_TYPE_EDGE_RISING>, | |
| 82 | + <GIC_SPI 159 IRQ_TYPE_EDGE_RISING>, | |
| 83 | + <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>, | |
| 84 | + <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>, | |
| 85 | + <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>, | |
| 86 | + <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>, | |
| 87 | + <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>; | |
| 88 | + clocks = <&mstp9_clks R7S72100_CLK_I2C0>; | |
| 89 | + clock-frequency = <100000>; | |
| 90 | + power-domains = <&cpg_clocks>; | |
| 91 | + #address-cells = <1>; | |
| 92 | + #size-cells = <0>; | |
| 93 | + }; | |
| @@ -0,0 +1,149 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/i2c/renesas,rmobile-iic.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Renesas R-Mobile I2C Bus Interface (IIC) | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Wolfram Sang <wsa+renesas@sang-engineering.com> | |
| 11 | + | |
| 12 | +properties: | |
| 13 | + compatible: | |
| 14 | + oneOf: | |
| 15 | + - items: | |
| 16 | + - enum: | |
| 17 | + - renesas,iic-r8a73a4 # R-Mobile APE6 | |
| 18 | + - renesas,iic-r8a7740 # R-Mobile A1 | |
| 19 | + - renesas,iic-sh73a0 # SH-Mobile AG5 | |
| 20 | + - const: renesas,rmobile-iic # Generic | |
| 21 | + | |
| 22 | + - items: | |
| 23 | + - enum: | |
| 24 | + - renesas,iic-r8a7742 # RZ/G1H | |
| 25 | + - renesas,iic-r8a7743 # RZ/G1M | |
| 26 | + - renesas,iic-r8a7744 # RZ/G1N | |
| 27 | + - renesas,iic-r8a7745 # RZ/G1E | |
| 28 | + - renesas,iic-r8a7790 # R-Car H2 | |
| 29 | + - renesas,iic-r8a7791 # R-Car M2-W | |
| 30 | + - renesas,iic-r8a7792 # R-Car V2H | |
| 31 | + - renesas,iic-r8a7793 # R-Car M2-N | |
| 32 | + - renesas,iic-r8a7794 # R-Car E2 | |
| 33 | + - const: renesas,rcar-gen2-iic # R-Car Gen2 and RZ/G1 | |
| 34 | + - const: renesas,rmobile-iic # Generic | |
| 35 | + | |
| 36 | + - items: | |
| 37 | + - enum: | |
| 38 | + - renesas,iic-r8a774a1 # RZ/G2M | |
| 39 | + - renesas,iic-r8a774b1 # RZ/G2N | |
| 40 | + - renesas,iic-r8a774c0 # RZ/G2E | |
| 41 | + - renesas,iic-r8a774e1 # RZ/G2H | |
| 42 | + - renesas,iic-r8a7795 # R-Car H3 | |
| 43 | + - renesas,iic-r8a7796 # R-Car M3-W | |
| 44 | + - renesas,iic-r8a77961 # R-Car M3-W+ | |
| 45 | + - renesas,iic-r8a77965 # R-Car M3-N | |
| 46 | + - renesas,iic-r8a77990 # R-Car E3 | |
| 47 | + - const: renesas,rcar-gen3-iic # R-Car Gen3 and RZ/G2 | |
| 48 | + - const: renesas,rmobile-iic # Generic | |
| 49 | + | |
| 50 | + reg: | |
| 51 | + maxItems: 1 | |
| 52 | + | |
| 53 | + interrupts: true | |
| 54 | + | |
| 55 | + clock-frequency: | |
| 56 | + description: | |
| 57 | + Desired I2C bus clock frequency in Hz. The absence of this property | |
| 58 | + indicates the default frequency 100 kHz. | |
| 59 | + | |
| 60 | + clocks: | |
| 61 | + maxItems: 1 | |
| 62 | + | |
| 63 | + power-domains: | |
| 64 | + maxItems: 1 | |
| 65 | + | |
| 66 | + resets: | |
| 67 | + maxItems: 1 | |
| 68 | + | |
| 69 | + dmas: | |
| 70 | + minItems: 2 | |
| 71 | + maxItems: 4 | |
| 72 | + description: | |
| 73 | + Must contain a list of pairs of references to DMA specifiers, one for | |
| 74 | + transmission, and one for reception. | |
| 75 | + | |
| 76 | + dma-names: | |
| 77 | + minItems: 2 | |
| 78 | + maxItems: 4 | |
| 79 | + items: | |
| 80 | + enum: | |
| 81 | + - tx | |
| 82 | + - rx | |
| 83 | + | |
| 84 | +required: | |
| 85 | + - compatible | |
| 86 | + - reg | |
| 87 | + - interrupts | |
| 88 | + - clocks | |
| 89 | + - power-domains | |
| 90 | + - '#address-cells' | |
| 91 | + - '#size-cells' | |
| 92 | + | |
| 93 | +allOf: | |
| 94 | + - $ref: /schemas/i2c/i2c-controller.yaml# | |
| 95 | + | |
| 96 | + - if: | |
| 97 | + properties: | |
| 98 | + compatible: | |
| 99 | + contains: | |
| 100 | + enum: | |
| 101 | + - renesas,iic-r8a7740 | |
| 102 | + - renesas,iic-sh73a0 | |
| 103 | + then: | |
| 104 | + properties: | |
| 105 | + interrupts: | |
| 106 | + items: | |
| 107 | + - description: Arbitration Lost Interrupt (ALI) | |
| 108 | + - description: Non-acknowledge Detection Interrupt (TACKI) | |
| 109 | + - description: Wait Interrupt (WAITI) | |
| 110 | + - description: Data Transmit Enable interrupt (DTEI) | |
| 111 | + else: | |
| 112 | + properties: | |
| 113 | + interrupts: | |
| 114 | + items: | |
| 115 | + - description: Single combined interrupt | |
| 116 | + | |
| 117 | + - if: | |
| 118 | + properties: | |
| 119 | + compatible: | |
| 120 | + contains: | |
| 121 | + enum: | |
| 122 | + - renesas,rcar-gen2-iic | |
| 123 | + - renesas,rcar-gen3-iic | |
| 124 | + then: | |
| 125 | + required: | |
| 126 | + - resets | |
| 127 | + | |
| 128 | +unevaluatedProperties: false | |
| 129 | + | |
| 130 | +examples: | |
| 131 | + - | | |
| 132 | + #include <dt-bindings/clock/r8a7790-cpg-mssr.h> | |
| 133 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 134 | + #include <dt-bindings/power/r8a7790-sysc.h> | |
| 135 | + | |
| 136 | + iic0: i2c@e6500000 { | |
| 137 | + compatible = "renesas,iic-r8a7790", "renesas,rcar-gen2-iic", | |
| 138 | + "renesas,rmobile-iic"; | |
| 139 | + reg = <0xe6500000 0x425>; | |
| 140 | + interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>; | |
| 141 | + clocks = <&cpg CPG_MOD 318>; | |
| 142 | + clock-frequency = <400000>; | |
| 143 | + dmas = <&dmac0 0x61>, <&dmac0 0x62>, <&dmac1 0x61>, <&dmac1 0x62>; | |
| 144 | + dma-names = "tx", "rx", "tx", "rx"; | |
| 145 | + power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; | |
| 146 | + resets = <&cpg 318>; | |
| 147 | + #address-cells = <1>; | |
| 148 | + #size-cells = <0>; | |
| 149 | + }; | |
| @@ -0,0 +1,102 @@ | ||
| 1 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | |
| 2 | +%YAML 1.2 | |
| 3 | +--- | |
| 4 | +$id: http://devicetree.org/schemas/i2c/ti,omap4-i2c.yaml# | |
| 5 | +$schema: http://devicetree.org/meta-schemas/core.yaml# | |
| 6 | + | |
| 7 | +title: Bindings for I2C controllers on TI's OMAP and K3 SoCs | |
| 8 | + | |
| 9 | +maintainers: | |
| 10 | + - Vignesh Raghavendra <vigneshr@ti.com> | |
| 11 | + | |
| 12 | +properties: | |
| 13 | + compatible: | |
| 14 | + oneOf: | |
| 15 | + - enum: | |
| 16 | + - ti,omap2420-i2c | |
| 17 | + - ti,omap2430-i2c | |
| 18 | + - ti,omap3-i2c | |
| 19 | + - ti,omap4-i2c | |
| 20 | + - items: | |
| 21 | + - enum: | |
| 22 | + - ti,am4372-i2c | |
| 23 | + - ti,am64-i2c | |
| 24 | + - ti,am654-i2c | |
| 25 | + - ti,j721e-i2c | |
| 26 | + - const: ti,omap4-i2c | |
| 27 | + | |
| 28 | + reg: | |
| 29 | + maxItems: 1 | |
| 30 | + | |
| 31 | + interrupts: | |
| 32 | + maxItems: 1 | |
| 33 | + | |
| 34 | + clocks: | |
| 35 | + maxItems: 1 | |
| 36 | + | |
| 37 | + clock-names: | |
| 38 | + const: fck | |
| 39 | + | |
| 40 | + clock-frequency: true | |
| 41 | + | |
| 42 | + power-domains: true | |
| 43 | + | |
| 44 | + "#address-cells": | |
| 45 | + const: 1 | |
| 46 | + | |
| 47 | + "#size-cells": | |
| 48 | + const: 0 | |
| 49 | + | |
| 50 | + ti,hwmods: | |
| 51 | + description: | |
| 52 | + Must be "i2c<n>", n being the instance number (1-based). | |
| 53 | + This property is applicable only on legacy platforms mainly omap2/3 | |
| 54 | + and ti81xx and should not be used on other platforms. | |
| 55 | + $ref: /schemas/types.yaml#/definitions/string | |
| 56 | + deprecated: true | |
| 57 | + | |
| 58 | +# subnode's properties | |
| 59 | +patternProperties: | |
| 60 | + "@[0-9a-f]+$": | |
| 61 | + type: object | |
| 62 | + description: | |
| 63 | + Flash device uses the below defined properties in the subnode. | |
| 64 | + | |
| 65 | +required: | |
| 66 | + - compatible | |
| 67 | + - reg | |
| 68 | + - interrupts | |
| 69 | + | |
| 70 | +additionalProperties: false | |
| 71 | + | |
| 72 | +if: | |
| 73 | + properties: | |
| 74 | + compatible: | |
| 75 | + oneOf: | |
| 76 | + - const: ti,omap2420-i2c | |
| 77 | + - const: ti,omap2430-i2c | |
| 78 | + - const: ti,omap3-i2c | |
| 79 | + - const: ti,omap4-i2c | |
| 80 | + | |
| 81 | +then: | |
| 82 | + properties: | |
| 83 | + ti,hwmods: | |
| 84 | + items: | |
| 85 | + - pattern: "^i2c([1-9])$" | |
| 86 | + | |
| 87 | +else: | |
| 88 | + properties: | |
| 89 | + ti,hwmods: false | |
| 90 | + | |
| 91 | +examples: | |
| 92 | + - | | |
| 93 | + #include <dt-bindings/interrupt-controller/irq.h> | |
| 94 | + #include <dt-bindings/interrupt-controller/arm-gic.h> | |
| 95 | + | |
| 96 | + main_i2c0: i2c@2000000 { | |
| 97 | + compatible = "ti,j721e-i2c", "ti,omap4-i2c"; | |
| 98 | + reg = <0x2000000 0x100>; | |
| 99 | + interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH>; | |
| 100 | + #address-cells = <1>; | |
| 101 | + #size-cells = <0>; | |
| 102 | + }; | |
| @@ -0,0 +1,395 @@ | ||
| 1 | +.. SPDX-License-Identifier: GPL-2.0 | |
| 2 | + | |
| 3 | +=============== | |
| 4 | +Linux I2C Sysfs | |
| 5 | +=============== | |
| 6 | + | |
| 7 | +Overview | |
| 8 | +======== | |
| 9 | + | |
| 10 | +I2C topology can be complex because of the existence of I2C MUX | |
| 11 | +(I2C Multiplexer). The Linux | |
| 12 | +kernel abstracts the MUX channels into logical I2C bus numbers. However, there | |
| 13 | +is a gap of knowledge to map from the I2C bus physical number and MUX topology | |
| 14 | +to logical I2C bus number. This doc is aimed to fill in this gap, so the | |
| 15 | +audience (hardware engineers and new software developers for example) can learn | |
| 16 | +the concept of logical I2C buses in the kernel, by knowing the physical I2C | |
| 17 | +topology and navigating through the I2C sysfs in Linux shell. This knowledge is | |
| 18 | +useful and essential to use ``i2c-tools`` for the purpose of development and | |
| 19 | +debugging. | |
| 20 | + | |
| 21 | +Target audience | |
| 22 | +--------------- | |
| 23 | + | |
| 24 | +People who need to use Linux shell to interact with I2C subsystem on a system | |
| 25 | +which the Linux is running on. | |
| 26 | + | |
| 27 | +Prerequisites | |
| 28 | +------------- | |
| 29 | + | |
| 30 | +1. Knowledge of general Linux shell file system commands and operations. | |
| 31 | + | |
| 32 | +2. General knowledge of I2C, I2C MUX and I2C topology. | |
| 33 | + | |
| 34 | +Location of I2C Sysfs | |
| 35 | +===================== | |
| 36 | + | |
| 37 | +Typically, the Linux Sysfs filesystem is mounted at the ``/sys`` directory, | |
| 38 | +so you can find the I2C Sysfs under ``/sys/bus/i2c/devices`` | |
| 39 | +where you can directly ``cd`` to it. | |
| 40 | +There is a list of symbolic links under that directory. The links that | |
| 41 | +start with ``i2c-`` are I2C buses, which may be either physical or logical. The | |
| 42 | +other links that begin with numbers and end with numbers are I2C devices, where | |
| 43 | +the first number is I2C bus number, and the second number is I2C address. | |
| 44 | + | |
| 45 | +Google Pixel 3 phone for example:: | |
| 46 | + | |
| 47 | + blueline:/sys/bus/i2c/devices $ ls | |
| 48 | + 0-0008 0-0061 1-0028 3-0043 4-0036 4-0041 i2c-1 i2c-3 | |
| 49 | + 0-000c 0-0066 2-0049 4-000b 4-0040 i2c-0 i2c-2 i2c-4 | |
| 50 | + | |
| 51 | +``i2c-2`` is an I2C bus whose number is 2, and ``2-0049`` is an I2C device | |
| 52 | +on bus 2 address 0x49 bound with a kernel driver. | |
| 53 | + | |
| 54 | +Terminologies | |
| 55 | +============= | |
| 56 | + | |
| 57 | +First, let us define a couple of terminologies to avoid confusions in the later | |
| 58 | +sections. | |
| 59 | + | |
| 60 | +(Physical) I2C Bus Controller | |
| 61 | +----------------------------- | |
| 62 | + | |
| 63 | +The hardware system that the Linux kernel is running on may have multiple | |
| 64 | +physical I2C bus controllers. The controllers are hardware and physical, and the | |
| 65 | +system may define multiple registers in the memory space to manipulate the | |
| 66 | +controllers. Linux kernel has I2C bus drivers under source directory | |
| 67 | +``drivers/i2c/busses`` to translate kernel I2C API into register | |
| 68 | +operations for different systems. This terminology is not limited to Linux | |
| 69 | +kernel only. | |
| 70 | + | |
| 71 | +I2C Bus Physical Number | |
| 72 | +----------------------- | |
| 73 | + | |
| 74 | +For each physical I2C bus controller, the system vendor may assign a physical | |
| 75 | +number to each controller. For example, the first I2C bus controller which has | |
| 76 | +the lowest register addresses may be called ``I2C-0``. | |
| 77 | + | |
| 78 | +Logical I2C Bus | |
| 79 | +--------------- | |
| 80 | + | |
| 81 | +Every I2C bus number you see in Linux I2C Sysfs is a logical I2C bus with a | |
| 82 | +number assigned. This is similar to the fact that software code is usually | |
| 83 | +written upon virtual memory space, instead of physical memory space. | |
| 84 | + | |
| 85 | +Each logical I2C bus may be an abstraction of a physical I2C bus controller, or | |
| 86 | +an abstraction of a channel behind an I2C MUX. In case it is an abstraction of a | |
| 87 | +MUX channel, whenever we access an I2C device via a such logical bus, the kernel | |
| 88 | +will switch the I2C MUX for you to the proper channel as part of the | |
| 89 | +abstraction. | |
| 90 | + | |
| 91 | +Physical I2C Bus | |
| 92 | +---------------- | |
| 93 | + | |
| 94 | +If the logical I2C bus is a direct abstraction of a physical I2C bus controller, | |
| 95 | +let us call it a physical I2C bus. | |
| 96 | + | |
| 97 | +Caveat | |
| 98 | +------ | |
| 99 | + | |
| 100 | +This may be a confusing part for people who only know about the physical I2C | |
| 101 | +design of a board. It is actually possible to rename the I2C bus physical number | |
| 102 | +to a different number in logical I2C bus level in Device Tree Source (DTS) under | |
| 103 | +section ``aliases``. See | |
| 104 | +`arch/arm/boot/dts/nuvoton-npcm730-gsj.dts | |
| 105 | +<../../arch/arm/boot/dts/nuvoton-npcm730-gsj.dts>`_ | |
| 106 | +for an example of DTS file. | |
| 107 | + | |
| 108 | +Best Practice: **(To kernel software developers)** It is better to keep the I2C | |
| 109 | +bus physical number the same as their corresponding logical I2C bus number, | |
| 110 | +instead of renaming or mapping them, so that it may be less confusing to other | |
| 111 | +users. These physical I2C buses can be served as good starting points for I2C | |
| 112 | +MUX fanouts. For the following examples, we will assume that the physical I2C | |
| 113 | +bus has a number same as their I2C bus physical number. | |
| 114 | + | |
| 115 | +Walk through Logical I2C Bus | |
| 116 | +============================ | |
| 117 | + | |
| 118 | +For the following content, we will use a more complex I2C topology as an | |
| 119 | +example. Here is a brief graph for the I2C topology. If you do not understand | |
| 120 | +this graph at the first glance, do not be afraid to continue reading this doc | |
| 121 | +and review it when you finish reading. | |
| 122 | + | |
| 123 | +:: | |
| 124 | + | |
| 125 | + i2c-7 (physical I2C bus controller 7) | |
| 126 | + `-- 7-0071 (4-channel I2C MUX at 0x71) | |
| 127 | + |-- i2c-60 (channel-0) | |
| 128 | + |-- i2c-73 (channel-1) | |
| 129 | + | |-- 73-0040 (I2C sensor device with hwmon directory) | |
| 130 | + | |-- 73-0070 (I2C MUX at 0x70, exists in DTS, but failed to probe) | |
| 131 | + | `-- 73-0072 (8-channel I2C MUX at 0x72) | |
| 132 | + | |-- i2c-78 (channel-0) | |
| 133 | + | |-- ... (channel-1...6, i2c-79...i2c-84) | |
| 134 | + | `-- i2c-85 (channel-7) | |
| 135 | + |-- i2c-86 (channel-2) | |
| 136 | + `-- i2c-203 (channel-3) | |
| 137 | + | |
| 138 | +Distinguish Physical and Logical I2C Bus | |
| 139 | +---------------------------------------- | |
| 140 | + | |
| 141 | +One simple way to distinguish between a physical I2C bus and a logical I2C bus, | |
| 142 | +is to read the symbolic link ``device`` under the I2C bus directory by using | |
| 143 | +command ``ls -l`` or ``readlink``. | |
| 144 | + | |
| 145 | +An alternative symbolic link to check is ``mux_device``. This link only exists | |
| 146 | +in logical I2C bus directory which is fanned out from another I2C bus. | |
| 147 | +Reading this link will also tell you which I2C MUX device created | |
| 148 | +this logical I2C bus. | |
| 149 | + | |
| 150 | +If the symbolic link points to a directory ending with ``.i2c``, it should be a | |
| 151 | +physical I2C bus, directly abstracting a physical I2C bus controller. For | |
| 152 | +example:: | |
| 153 | + | |
| 154 | + $ readlink /sys/bus/i2c/devices/i2c-7/device | |
| 155 | + ../../f0087000.i2c | |
| 156 | + $ ls /sys/bus/i2c/devices/i2c-7/mux_device | |
| 157 | + ls: /sys/bus/i2c/devices/i2c-7/mux_device: No such file or directory | |
| 158 | + | |
| 159 | +In this case, ``i2c-7`` is a physical I2C bus, so it does not have the symbolic | |
| 160 | +link ``mux_device`` under its directory. And if the kernel software developer | |
| 161 | +follows the common practice by not renaming physical I2C buses, this should also | |
| 162 | +mean the physical I2C bus controller 7 of the system. | |
| 163 | + | |
| 164 | +On the other hand, if the symbolic link points to another I2C bus, the I2C bus | |
| 165 | +presented by the current directory has to be a logical bus. The I2C bus pointed | |
| 166 | +by the link is the parent bus which may be either a physical I2C bus or a | |
| 167 | +logical one. In this case, the I2C bus presented by the current directory | |
| 168 | +abstracts an I2C MUX channel under the parent bus. | |
| 169 | + | |
| 170 | +For example:: | |
| 171 | + | |
| 172 | + $ readlink /sys/bus/i2c/devices/i2c-73/device | |
| 173 | + ../../i2c-7 | |
| 174 | + $ readlink /sys/bus/i2c/devices/i2c-73/mux_device | |
| 175 | + ../7-0071 | |
| 176 | + | |
| 177 | +``i2c-73`` is a logical bus fanout by an I2C MUX under ``i2c-7`` | |
| 178 | +whose I2C address is 0x71. | |
| 179 | +Whenever we access an I2C device with bus 73, the kernel will always | |
| 180 | +switch the I2C MUX addressed 0x71 to the proper channel for you as part of the | |
| 181 | +abstraction. | |
| 182 | + | |
| 183 | +Finding out Logical I2C Bus Number | |
| 184 | +---------------------------------- | |
| 185 | + | |
| 186 | +In this section, we will describe how to find out the logical I2C bus number | |
| 187 | +representing certain I2C MUX channels based on the knowledge of physical | |
| 188 | +hardware I2C topology. | |
| 189 | + | |
| 190 | +In this example, we have a system which has a physical I2C bus 7 and not renamed | |
| 191 | +in DTS. There is a 4-channel MUX at address 0x71 on that bus. There is another | |
| 192 | +8-channel MUX at address 0x72 behind the channel 1 of the 0x71 MUX. Let us | |
| 193 | +navigate through Sysfs and find out the logical I2C bus number of the channel 3 | |
| 194 | +of the 0x72 MUX. | |
| 195 | + | |
| 196 | +First of all, let us go to the directory of ``i2c-7``:: | |
| 197 | + | |
| 198 | + ~$ cd /sys/bus/i2c/devices/i2c-7 | |
| 199 | + /sys/bus/i2c/devices/i2c-7$ ls | |
| 200 | + 7-0071 i2c-60 name subsystem | |
| 201 | + delete_device i2c-73 new_device uevent | |
| 202 | + device i2c-86 of_node | |
| 203 | + i2c-203 i2c-dev power | |
| 204 | + | |
| 205 | +There, we see the 0x71 MUX as ``7-0071``. Go inside it:: | |
| 206 | + | |
| 207 | + /sys/bus/i2c/devices/i2c-7$ cd 7-0071/ | |
| 208 | + /sys/bus/i2c/devices/i2c-7/7-0071$ ls -l | |
| 209 | + channel-0 channel-3 modalias power | |
| 210 | + channel-1 driver name subsystem | |
| 211 | + channel-2 idle_state of_node uevent | |
| 212 | + | |
| 213 | +Read the link ``channel-1`` using ``readlink`` or ``ls -l``:: | |
| 214 | + | |
| 215 | + /sys/bus/i2c/devices/i2c-7/7-0071$ readlink channel-1 | |
| 216 | + ../i2c-73 | |
| 217 | + | |
| 218 | +We find out that the channel 1 of 0x71 MUX on ``i2c-7`` is assigned | |
| 219 | +with a logical I2C bus number of 73. | |
| 220 | +Let us continue the journey to directory ``i2c-73`` in either ways:: | |
| 221 | + | |
| 222 | + # cd to i2c-73 under I2C Sysfs root | |
| 223 | + /sys/bus/i2c/devices/i2c-7/7-0071$ cd /sys/bus/i2c/devices/i2c-73 | |
| 224 | + /sys/bus/i2c/devices/i2c-73$ | |
| 225 | + | |
| 226 | + # cd the channel symbolic link | |
| 227 | + /sys/bus/i2c/devices/i2c-7/7-0071$ cd channel-1 | |
| 228 | + /sys/bus/i2c/devices/i2c-7/7-0071/channel-1$ | |
| 229 | + | |
| 230 | + # cd the link content | |
| 231 | + /sys/bus/i2c/devices/i2c-7/7-0071$ cd ../i2c-73 | |
| 232 | + /sys/bus/i2c/devices/i2c-7/i2c-73$ | |
| 233 | + | |
| 234 | +Either ways, you will end up in the directory of ``i2c-73``. Similar to above, | |
| 235 | +we can now find the 0x72 MUX and what logical I2C bus numbers | |
| 236 | +that its channels are assigned:: | |
| 237 | + | |
| 238 | + /sys/bus/i2c/devices/i2c-73$ ls | |
| 239 | + 73-0040 device i2c-83 new_device | |
| 240 | + 73-004e i2c-78 i2c-84 of_node | |
| 241 | + 73-0050 i2c-79 i2c-85 power | |
| 242 | + 73-0070 i2c-80 i2c-dev subsystem | |
| 243 | + 73-0072 i2c-81 mux_device uevent | |
| 244 | + delete_device i2c-82 name | |
| 245 | + /sys/bus/i2c/devices/i2c-73$ cd 73-0072 | |
| 246 | + /sys/bus/i2c/devices/i2c-73/73-0072$ ls | |
| 247 | + channel-0 channel-4 driver of_node | |
| 248 | + channel-1 channel-5 idle_state power | |
| 249 | + channel-2 channel-6 modalias subsystem | |
| 250 | + channel-3 channel-7 name uevent | |
| 251 | + /sys/bus/i2c/devices/i2c-73/73-0072$ readlink channel-3 | |
| 252 | + ../i2c-81 | |
| 253 | + | |
| 254 | +There, we find out the logical I2C bus number of the channel 3 of the 0x72 MUX | |
| 255 | +is 81. We can later use this number to switch to its own I2C Sysfs directory or | |
| 256 | +issue ``i2c-tools`` commands. | |
| 257 | + | |
| 258 | +Tip: Once you understand the I2C topology with MUX, command | |
| 259 | +`i2cdetect -l | |
| 260 | +<https://manpages.debian.org/unstable/i2c-tools/i2cdetect.8.en.html>`_ | |
| 261 | +in | |
| 262 | +`I2C Tools | |
| 263 | +<https://i2c.wiki.kernel.org/index.php/I2C_Tools>`_ | |
| 264 | +can give you | |
| 265 | +an overview of the I2C topology easily, if it is available on your system. For | |
| 266 | +example:: | |
| 267 | + | |
| 268 | + $ i2cdetect -l | grep -e '\-73' -e _7 | sort -V | |
| 269 | + i2c-7 i2c npcm_i2c_7 I2C adapter | |
| 270 | + i2c-73 i2c i2c-7-mux (chan_id 1) I2C adapter | |
| 271 | + i2c-78 i2c i2c-73-mux (chan_id 0) I2C adapter | |
| 272 | + i2c-79 i2c i2c-73-mux (chan_id 1) I2C adapter | |
| 273 | + i2c-80 i2c i2c-73-mux (chan_id 2) I2C adapter | |
| 274 | + i2c-81 i2c i2c-73-mux (chan_id 3) I2C adapter | |
| 275 | + i2c-82 i2c i2c-73-mux (chan_id 4) I2C adapter | |
| 276 | + i2c-83 i2c i2c-73-mux (chan_id 5) I2C adapter | |
| 277 | + i2c-84 i2c i2c-73-mux (chan_id 6) I2C adapter | |
| 278 | + i2c-85 i2c i2c-73-mux (chan_id 7) I2C adapter | |
| 279 | + | |
| 280 | +Pinned Logical I2C Bus Number | |
| 281 | +----------------------------- | |
| 282 | + | |
| 283 | +If not specified in DTS, when an I2C MUX driver is applied and the MUX device is | |
| 284 | +successfully probed, the kernel will assign the MUX channels with a logical bus | |
| 285 | +number based on the current biggest logical bus number incrementally. For | |
| 286 | +example, if the system has ``i2c-15`` as the highest logical bus number, and a | |
| 287 | +4-channel MUX is applied successfully, we will have ``i2c-16`` for the | |
| 288 | +MUX channel 0, and all the way to ``i2c-19`` for the MUX channel 3. | |
| 289 | + | |
| 290 | +The kernel software developer is able to pin the fanout MUX channels to a static | |
| 291 | +logical I2C bus number in the DTS. This doc will not go through the details on | |
| 292 | +how to implement this in DTS, but we can see an example in: | |
| 293 | +`arch/arm/boot/dts/aspeed-bmc-facebook-wedge400.dts | |
| 294 | +<../../arch/arm/boot/dts/aspeed-bmc-facebook-wedge400.dts>`_ | |
| 295 | + | |
| 296 | +In the above example, there is an 8-channel I2C MUX at address 0x70 on physical | |
| 297 | +I2C bus 2. The channel 2 of the MUX is defined as ``imux18`` in DTS, | |
| 298 | +and pinned to logical I2C bus number 18 with the line of ``i2c18 = &imux18;`` | |
| 299 | +in section ``aliases``. | |
| 300 | + | |
| 301 | +Take it further, it is possible to design a logical I2C bus number schema that | |
| 302 | +can be easily remembered by humans or calculated arithmetically. For example, we | |
| 303 | +can pin the fanout channels of a MUX on bus 3 to start at 30. So 30 will be the | |
| 304 | +logical bus number of the channel 0 of the MUX on bus 3, and 37 will be the | |
| 305 | +logical bus number of the channel 7 of the MUX on bus 3. | |
| 306 | + | |
| 307 | +I2C Devices | |
| 308 | +=========== | |
| 309 | + | |
| 310 | +In previous sections, we mostly covered the I2C bus. In this section, let us see | |
| 311 | +what we can learn from the I2C device directory whose link name is in the format | |
| 312 | +of ``${bus}-${addr}``. The ``${bus}`` part in the name is a logical I2C bus | |
| 313 | +decimal number, while the ``${addr}`` part is a hex number of the I2C address | |
| 314 | +of each device. | |
| 315 | + | |
| 316 | +I2C Device Directory Content | |
| 317 | +---------------------------- | |
| 318 | + | |
| 319 | +Inside each I2C device directory, there is a file named ``name``. | |
| 320 | +This file tells what device name it was used for the kernel driver to | |
| 321 | +probe this device. Use command ``cat`` to read its content. For example:: | |
| 322 | + | |
| 323 | + /sys/bus/i2c/devices/i2c-73$ cat 73-0040/name | |
| 324 | + ina230 | |
| 325 | + /sys/bus/i2c/devices/i2c-73$ cat 73-0070/name | |
| 326 | + pca9546 | |
| 327 | + /sys/bus/i2c/devices/i2c-73$ cat 73-0072/name | |
| 328 | + pca9547 | |
| 329 | + | |
| 330 | +There is a symbolic link named ``driver`` to tell what Linux kernel driver was | |
| 331 | +used to probe this device:: | |
| 332 | + | |
| 333 | + /sys/bus/i2c/devices/i2c-73$ readlink -f 73-0040/driver | |
| 334 | + /sys/bus/i2c/drivers/ina2xx | |
| 335 | + /sys/bus/i2c/devices/i2c-73$ readlink -f 73-0072/driver | |
| 336 | + /sys/bus/i2c/drivers/pca954x | |
| 337 | + | |
| 338 | +But if the link ``driver`` does not exist at the first place, | |
| 339 | +it may mean that the kernel driver failed to probe this device due to | |
| 340 | +some errors. The error may be found in ``dmesg``:: | |
| 341 | + | |
| 342 | + /sys/bus/i2c/devices/i2c-73$ ls 73-0070/driver | |
| 343 | + ls: 73-0070/driver: No such file or directory | |
| 344 | + /sys/bus/i2c/devices/i2c-73$ dmesg | grep 73-0070 | |
| 345 | + pca954x 73-0070: probe failed | |
| 346 | + pca954x 73-0070: probe failed | |
| 347 | + | |
| 348 | +Depending on what the I2C device is and what kernel driver was used to probe the | |
| 349 | +device, we may have different content in the device directory. | |
| 350 | + | |
| 351 | +I2C MUX Device | |
| 352 | +-------------- | |
| 353 | + | |
| 354 | +While you may be already aware of this in previous sections, an I2C MUX device | |
| 355 | +will have symbolic link ``channel-*`` inside its device directory. | |
| 356 | +These symbolic links point to their logical I2C bus directories:: | |
| 357 | + | |
| 358 | + /sys/bus/i2c/devices/i2c-73$ ls -l 73-0072/channel-* | |
| 359 | + lrwxrwxrwx ... 73-0072/channel-0 -> ../i2c-78 | |
| 360 | + lrwxrwxrwx ... 73-0072/channel-1 -> ../i2c-79 | |
| 361 | + lrwxrwxrwx ... 73-0072/channel-2 -> ../i2c-80 | |
| 362 | + lrwxrwxrwx ... 73-0072/channel-3 -> ../i2c-81 | |
| 363 | + lrwxrwxrwx ... 73-0072/channel-4 -> ../i2c-82 | |
| 364 | + lrwxrwxrwx ... 73-0072/channel-5 -> ../i2c-83 | |
| 365 | + lrwxrwxrwx ... 73-0072/channel-6 -> ../i2c-84 | |
| 366 | + lrwxrwxrwx ... 73-0072/channel-7 -> ../i2c-85 | |
| 367 | + | |
| 368 | +I2C Sensor Device / Hwmon | |
| 369 | +------------------------- | |
| 370 | + | |
| 371 | +I2C sensor device is also common to see. If they are bound by a kernel hwmon | |
| 372 | +(Hardware Monitoring) driver successfully, you will see a ``hwmon`` directory | |
| 373 | +inside the I2C device directory. Keep digging into it, you will find the Hwmon | |
| 374 | +Sysfs for the I2C sensor device:: | |
| 375 | + | |
| 376 | + /sys/bus/i2c/devices/i2c-73/73-0040/hwmon/hwmon17$ ls | |
| 377 | + curr1_input in0_lcrit_alarm name subsystem | |
| 378 | + device in1_crit power uevent | |
| 379 | + in0_crit in1_crit_alarm power1_crit update_interval | |
| 380 | + in0_crit_alarm in1_input power1_crit_alarm | |
| 381 | + in0_input in1_lcrit power1_input | |
| 382 | + in0_lcrit in1_lcrit_alarm shunt_resistor | |
| 383 | + | |
| 384 | +For more info on the Hwmon Sysfs, refer to the doc: | |
| 385 | + | |
| 386 | +`Naming and data format standards for sysfs files | |
| 387 | +<../hwmon/sysfs-interface.rst>`_ | |
| 388 | + | |
| 389 | +Instantiate I2C Devices in I2C Sysfs | |
| 390 | +------------------------------------ | |
| 391 | + | |
| 392 | +Refer to the doc: | |
| 393 | + | |
| 394 | +`How to instantiate I2C devices, Method 4: Instantiate from user-space | |
| 395 | +<instantiating-devices.rst#method-4-instantiate-from-user-space>`_ | |
| @@ -13494,7 +13494,7 @@ M: Vignesh R <vigneshr@ti.com> · 13493 unmodified lines | ||
| 13494 | 13494 | L: linux-omap@vger.kernel.org |
| 13495 | 13495 | L: linux-i2c@vger.kernel.org |
| 13496 | 13496 | S: Maintained |
| 13497 | −F: Documentation/devicetree/bindings/i2c/i2c-omap.txt | |
| 13497 | +F: Documentation/devicetree/bindings/i2c/ti,omap4-i2c.yaml | |
| 13498 | 13498 | F: drivers/i2c/busses/i2c-omap.c |
| 13499 | 13499 | |
| 13500 | 13500 | OMAP IMAGING SUBSYSTEM (OMAP3 ISP and OMAP4 ISS) |
| @@ -15722,8 +15722,9 @@ F: drivers/clk/renesas/ · 2221 unmodified lines | ||
| 15722 | 15722 | |
| 15723 | 15723 | RENESAS EMEV2 I2C DRIVER |
| 15724 | 15724 | M: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| 15725 | +L: linux-renesas-soc@vger.kernel.org | |
| 15725 | 15726 | S: Supported |
| 15726 | −F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.txt | |
| 15727 | +F: Documentation/devicetree/bindings/i2c/renesas,iic-emev2.yaml | |
| 15727 | 15728 | F: drivers/i2c/busses/i2c-emev2.c |
| 15728 | 15729 | |
| 15729 | 15730 | RENESAS ETHERNET DRIVERS |
| @@ -15743,9 +15744,10 @@ F: drivers/iio/adc/rcar-gyroadc.c · 13 unmodified lines | ||
| 15743 | 15744 | |
| 15744 | 15745 | RENESAS R-CAR I2C DRIVERS |
| 15745 | 15746 | M: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| 15747 | +L: linux-renesas-soc@vger.kernel.org | |
| 15746 | 15748 | S: Supported |
| 15747 | −F: Documentation/devicetree/bindings/i2c/renesas,i2c.txt | |
| 15748 | −F: Documentation/devicetree/bindings/i2c/renesas,iic.txt | |
| 15749 | +F: Documentation/devicetree/bindings/i2c/renesas,rcar-i2c.yaml | |
| 15750 | +F: Documentation/devicetree/bindings/i2c/renesas,rmobile-iic.yaml | |
| 15749 | 15751 | F: drivers/i2c/busses/i2c-rcar.c |
| 15750 | 15752 | F: drivers/i2c/busses/i2c-sh_mobile.c |
| 15751 | 15753 | |
| @@ -15760,8 +15762,9 @@ F: drivers/thermal/rcar_thermal.c · 8 unmodified lines | ||
| 15760 | 15762 | |
| 15761 | 15763 | RENESAS RIIC DRIVER |
| 15762 | 15764 | M: Chris Brandt <chris.brandt@renesas.com> |
| 15765 | +L: linux-renesas-soc@vger.kernel.org | |
| 15763 | 15766 | S: Supported |
| 15764 | −F: Documentation/devicetree/bindings/i2c/renesas,riic.txt | |
| 15767 | +F: Documentation/devicetree/bindings/i2c/renesas,riic.yaml | |
| 15765 | 15768 | F: drivers/i2c/busses/i2c-riic.c |
| 15766 | 15769 | |
| 15767 | 15770 | RENESAS USB PHY DRIVER |
| @@ -508,6 +508,11 @@ static void ali1535_remove(struct pci_dev *dev) · 507 unmodified lines | ||
| 508 | 508 | { |
| 509 | 509 | i2c_del_adapter(&ali1535_adapter); |
| 510 | 510 | release_region(ali1535_smba, ALI1535_SMB_IOSIZE); |
| 511 | + | |
| 512 | + /* | |
| 513 | + * do not call pci_disable_device(dev) since it can cause hard hangs on | |
| 514 | + * some systems during power-off | |
| 515 | + */ | |
| 511 | 516 | } |
| 512 | 517 | |
| 513 | 518 | static struct pci_driver ali1535_driver = { |
| @@ -727,10 +727,14 @@ static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bus *bus, u16 slave_addr) · 726 unmodified lines | ||
| 727 | 727 | { |
| 728 | 728 | u32 addr_reg_val, func_ctrl_reg_val; |
| 729 | 729 | |
| 730 | − /* Set slave addr. */ | |
| 731 | − addr_reg_val = readl(bus->base + ASPEED_I2C_DEV_ADDR_REG); | |
| 732 | − addr_reg_val &= ~ASPEED_I2CD_DEV_ADDR_MASK; | |
| 733 | − addr_reg_val |= slave_addr & ASPEED_I2CD_DEV_ADDR_MASK; | |
| 730 | + /* | |
| 731 | + * Set slave addr. Reserved bits can all safely be written with zeros | |
| 732 | + * on all of ast2[456]00, so zero everything else to ensure we only | |
| 733 | + * enable a single slave address (ast2500 has two, ast2600 has three, | |
| 734 | + * the enable bits for which are also in this register) so that we don't | |
| 735 | + * end up with additional phantom devices responding on the bus. | |
| 736 | + */ | |
| 737 | + addr_reg_val = slave_addr & ASPEED_I2CD_DEV_ADDR_MASK; | |
| 734 | 738 | writel(addr_reg_val, bus->base + ASPEED_I2C_DEV_ADDR_REG); |
| 735 | 739 | |
| 736 | 740 | /* Turn on slave mode. */ |
| @@ -578,6 +578,11 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) · 577 unmodified lines | ||
| 578 | 578 | { |
| 579 | 579 | unsigned int ctrl_reg; |
| 580 | 580 | unsigned int isr_status; |
| 581 | + unsigned long flags; | |
| 582 | + bool hold_clear = false; | |
| 583 | + bool irq_save = false; | |
| 584 | + | |
| 585 | + u32 addr; | |
| 581 | 586 | |
| 582 | 587 | id->p_recv_buf = id->p_msg->buf; |
| 583 | 588 | id->recv_count = id->p_msg->len; |
| @@ -618,14 +623,43 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id) · 34 unmodified lines | ||
| 618 | 623 | cdns_i2c_writereg(id->recv_count, CDNS_I2C_XFER_SIZE_OFFSET); |
| 619 | 624 | } |
| 620 | 625 | |
| 621 | − /* Set the slave address in address register - triggers operation */ | |
| 622 | − cdns_i2c_writereg(id->p_msg->addr & CDNS_I2C_ADDR_MASK, | |
| 623 | − CDNS_I2C_ADDR_OFFSET); | |
| 624 | − /* Clear the bus hold flag if bytes to receive is less than FIFO size */ | |
| 626 | + /* Determine hold_clear based on number of bytes to receive and hold flag */ | |
| 625 | 627 | if (!id->bus_hold_flag && |
| 626 | − ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) && | |
| 627 | − (id->recv_count <= CDNS_I2C_FIFO_DEPTH)) | |
| 628 | − cdns_i2c_clear_bus_hold(id); | |
| 628 | + ((id->p_msg->flags & I2C_M_RECV_LEN) != I2C_M_RECV_LEN) && | |
| 629 | + (id->recv_count <= CDNS_I2C_FIFO_DEPTH)) { | |
| 630 | + if (cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & CDNS_I2C_CR_HOLD) { | |
| 631 | + hold_clear = true; | |
| 632 | + if (id->quirks & CDNS_I2C_BROKEN_HOLD_BIT) | |
| 633 | + irq_save = true; | |
| 634 | + } | |
| 635 | + } | |
| 636 | + | |
| 637 | + addr = id->p_msg->addr; | |
| 638 | + addr &= CDNS_I2C_ADDR_MASK; | |
| 639 | + | |
| 640 | + if (hold_clear) { | |
| 641 | + ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET) & ~CDNS_I2C_CR_HOLD; | |
| 642 | + /* | |
| 643 | + * In case of Xilinx Zynq SOC, clear the HOLD bit before transfer size | |
| 644 | + * register reaches '0'. This is an IP bug which causes transfer size | |
| 645 | + * register overflow to 0xFF. To satisfy this timing requirement, | |
| 646 | + * disable the interrupts on current processor core between register | |
| 647 | + * writes to slave address register and control register. | |
| 648 | + */ | |
| 649 | + if (irq_save) | |
| 650 | + local_irq_save(flags); | |
| 651 | + | |
| 652 | + cdns_i2c_writereg(addr, CDNS_I2C_ADDR_OFFSET); | |
| 653 | + cdns_i2c_writereg(ctrl_reg, CDNS_I2C_CR_OFFSET); | |
| 654 | + /* Read it back to avoid bufferring and make sure write happens */ | |
| 655 | + cdns_i2c_readreg(CDNS_I2C_CR_OFFSET); | |
| 656 | + | |
| 657 | + if (irq_save) | |
| 658 | + local_irq_restore(flags); | |
| 659 | + } else { | |
| 660 | + cdns_i2c_writereg(addr, CDNS_I2C_ADDR_OFFSET); | |
| 661 | + } | |
| 662 | + | |
| 629 | 663 | cdns_i2c_writereg(CDNS_I2C_ENABLED_INTR_MASK, CDNS_I2C_IER_OFFSET); |
| 630 | 664 | } |
| 631 | 665 | |
| @@ -1217,11 +1251,10 @@ static int cdns_i2c_probe(struct platform_device *pdev) · 585 unmodified lines | ||
| 1217 | 1251 | "Cadence I2C at %08lx", (unsigned long)r_mem->start); |
| 1218 | 1252 | |
| 1219 | 1253 | id->clk = devm_clk_get(&pdev->dev, NULL); |
| 1220 | − if (IS_ERR(id->clk)) { | |
| 1221 | − if (PTR_ERR(id->clk) != -EPROBE_DEFER) | |
| 1222 | − dev_err(&pdev->dev, "input clock not found.\n"); | |
| 1223 | − return PTR_ERR(id->clk); | |
| 1224 | − } | |
| 1254 | + if (IS_ERR(id->clk)) | |
| 1255 | + return dev_err_probe(&pdev->dev, PTR_ERR(id->clk), | |
| 1256 | + "input clock not found.\n"); | |
| 1257 | + | |
| 1225 | 1258 | ret = clk_prepare_enable(id->clk); |
| 1226 | 1259 | if (ret) |
| 1227 | 1260 | dev_err(&pdev->dev, "Unable to enable clock.\n"); |
| @@ -354,8 +354,7 @@ static int cht_wc_i2c_adap_i2c_probe(struct platform_device *pdev) · 353 unmodified lines | ||
| 354 | 354 | return ret; |
| 355 | 355 | |
| 356 | 356 | /* Alloc and register client IRQ */ |
| 357 | − adap->irq_domain = irq_domain_add_linear(pdev->dev.of_node, 1, | |
| 358 | − &irq_domain_simple_ops, NULL); | |
| 357 | + adap->irq_domain = irq_domain_add_linear(NULL, 1, &irq_domain_simple_ops, NULL); | |
| 359 | 358 | if (!adap->irq_domain) |
| 360 | 359 | return -ENOMEM; |
| 361 | 360 | |
| @@ -768,10 +768,7 @@ static int davinci_i2c_probe(struct platform_device *pdev) · 767 unmodified lines | ||
| 768 | 768 | if (irq <= 0) { |
| 769 | 769 | if (!irq) |
| 770 | 770 | irq = -ENXIO; |
| 771 | − if (irq != -EPROBE_DEFER) | |
| 772 | − dev_err(&pdev->dev, | |
| 773 | − "can't get irq resource ret=%d\n", irq); | |
| 774 | − return irq; | |
| 771 | + return dev_err_probe(&pdev->dev, irq, "can't get irq resource\n"); | |
| 775 | 772 | } |
| 776 | 773 | |
| 777 | 774 | dev = devm_kzalloc(&pdev->dev, sizeof(struct davinci_i2c_dev), |
| @@ -88,6 +88,8 @@ · 87 unmodified lines | ||
| 88 | 88 | * See the file Documentation/i2c/busses/i2c-i801.rst for details. |
| 89 | 89 | */ |
| 90 | 90 | |
| 91 | +#define DRV_NAME "i801_smbus" | |
| 92 | + | |
| 91 | 93 | #include <linux/interrupt.h> |
| 92 | 94 | #include <linux/module.h> |
| 93 | 95 | #include <linux/pci.h> |
| @@ -103,7 +105,7 @@ · 9 unmodified lines | ||
| 103 | 105 | #include <linux/dmi.h> |
| 104 | 106 | #include <linux/slab.h> |
| 105 | 107 | #include <linux/string.h> |
| 106 | −#include <linux/wait.h> | |
| 108 | +#include <linux/completion.h> | |
| 107 | 109 | #include <linux/err.h> |
| 108 | 110 | #include <linux/platform_device.h> |
| 109 | 111 | #include <linux/platform_data/itco_wdt.h> |
| @@ -131,8 +133,6 @@ · 21 unmodified lines | ||
| 131 | 133 | |
| 132 | 134 | /* PCI Address Constants */ |
| 133 | 135 | #define SMBBAR 4 |
| 134 | −#define SMBPCICTL 0x004 | |
| 135 | −#define SMBPCISTS 0x006 | |
| 136 | 136 | #define SMBHSTCFG 0x040 |
| 137 | 137 | #define TCOBASE 0x050 |
| 138 | 138 | #define TCOCTL 0x054 |
| @@ -141,12 +141,6 @@ · 2 unmodified lines | ||
| 141 | 141 | #define SBREG_SMBCTRL 0xc6000c |
| 142 | 142 | #define SBREG_SMBCTRL_DNV 0xcf000c |
| 143 | 143 | |
| 144 | −/* Host status bits for SMBPCISTS */ | |
| 145 | −#define SMBPCISTS_INTS BIT(3) | |
| 146 | − | |
| 147 | −/* Control bits for SMBPCICTL */ | |
| 148 | −#define SMBPCICTL_INTDIS BIT(10) | |
| 149 | − | |
| 150 | 144 | /* Host configuration bits for SMBHSTCFG */ |
| 151 | 145 | #define SMBHSTCFG_HST_EN BIT(0) |
| 152 | 146 | #define SMBHSTCFG_SMB_SMI_EN BIT(1) |
| @@ -164,9 +158,6 @@ · 11 unmodified lines | ||
| 164 | 158 | #define SMBAUXCTL_CRC BIT(0) |
| 165 | 159 | #define SMBAUXCTL_E32B BIT(1) |
| 166 | 160 | |
| 167 | −/* Other settings */ | |
| 168 | −#define MAX_RETRIES 400 | |
| 169 | − | |
| 170 | 161 | /* I801 command constants */ |
| 171 | 162 | #define I801_QUICK 0x00 |
| 172 | 163 | #define I801_BYTE 0x04 |
| @@ -270,7 +261,7 @@ struct i801_priv { · 97 unmodified lines | ||
| 270 | 261 | unsigned int features; |
| 271 | 262 | |
| 272 | 263 | /* isr processing */ |
| 273 | − wait_queue_head_t waitq; | |
| 264 | + struct completion done; | |
| 274 | 265 | u8 status; |
| 275 | 266 | |
| 276 | 267 | /* Command state used by isr for byte-by-byte block transactions */ |
| @@ -453,67 +444,53 @@ static int i801_check_post(struct i801_priv *priv, int status) · 176 unmodified lines | ||
| 453 | 444 | /* Wait for BUSY being cleared and either INTR or an error flag being set */ |
| 454 | 445 | static int i801_wait_intr(struct i801_priv *priv) |
| 455 | 446 | { |
| 456 | − int timeout = 0; | |
| 457 | − int status; | |
| 447 | + unsigned long timeout = jiffies + priv->adapter.timeout; | |
| 448 | + int status, busy; | |
| 458 | 449 | |
| 459 | − /* We will always wait for a fraction of a second! */ | |
| 460 | 450 | do { |
| 461 | 451 | usleep_range(250, 500); |
| 462 | 452 | status = inb_p(SMBHSTSTS(priv)); |
| 463 | − } while (((status & SMBHSTSTS_HOST_BUSY) || | |
| 464 | − !(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_INTR))) && | |
| 465 | − (timeout++ < MAX_RETRIES)); | |
| 453 | + busy = status & SMBHSTSTS_HOST_BUSY; | |
| 454 | + status &= STATUS_ERROR_FLAGS | SMBHSTSTS_INTR; | |
| 455 | + if (!busy && status) | |
| 456 | + return status; | |
| 457 | + } while (time_is_after_eq_jiffies(timeout)); | |
| 466 | 458 | |
| 467 | − if (timeout > MAX_RETRIES) { | |
| 468 | − dev_dbg(&priv->pci_dev->dev, "INTR Timeout!\n"); | |
| 469 | − return -ETIMEDOUT; | |
| 470 | − } | |
| 471 | − return status & (STATUS_ERROR_FLAGS | SMBHSTSTS_INTR); | |
| 459 | + return -ETIMEDOUT; | |
| 472 | 460 | } |
| 473 | 461 | |
| 474 | 462 | /* Wait for either BYTE_DONE or an error flag being set */ |
| 475 | 463 | static int i801_wait_byte_done(struct i801_priv *priv) |
| 476 | 464 | { |
| 477 | − int timeout = 0; | |
| 465 | + unsigned long timeout = jiffies + priv->adapter.timeout; | |
| 478 | 466 | int status; |
| 479 | 467 | |
| 480 | − /* We will always wait for a fraction of a second! */ | |
| 481 | 468 | do { |
| 482 | 469 | usleep_range(250, 500); |
| 483 | 470 | status = inb_p(SMBHSTSTS(priv)); |
| 484 | − } while (!(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_BYTE_DONE)) && | |
| 485 | − (timeout++ < MAX_RETRIES)); | |
| 471 | + if (status & (STATUS_ERROR_FLAGS | SMBHSTSTS_BYTE_DONE)) | |
| 472 | + return status & STATUS_ERROR_FLAGS; | |
| 473 | + } while (time_is_after_eq_jiffies(timeout)); | |
| 486 | 474 | |
| 487 | − if (timeout > MAX_RETRIES) { | |
| 488 | − dev_dbg(&priv->pci_dev->dev, "BYTE_DONE Timeout!\n"); | |
| 489 | − return -ETIMEDOUT; | |
| 490 | − } | |
| 491 | − return status & STATUS_ERROR_FLAGS; | |
| 475 | + return -ETIMEDOUT; | |
| 492 | 476 | } |
| 493 | 477 | |
| 494 | 478 | static int i801_transaction(struct i801_priv *priv, int xact) |
| 495 | 479 | { |
| 496 | 480 | int status; |
| 497 | − int result; | |
| 481 | + unsigned long result; | |
| 498 | 482 | const struct i2c_adapter *adap = &priv->adapter; |
| 499 | 483 | |
| 500 | − result = i801_check_pre(priv); | |
| 501 | − if (result < 0) | |
| 502 | − return result; | |
| 484 | + status = i801_check_pre(priv); | |
| 485 | + if (status < 0) | |
| 486 | + return status; | |
| 503 | 487 | |
| 504 | 488 | if (priv->features & FEATURE_IRQ) { |
| 489 | + reinit_completion(&priv->done); | |
| 505 | 490 | outb_p(xact | SMBHSTCNT_INTREN | SMBHSTCNT_START, |
| 506 | 491 | SMBHSTCNT(priv)); |
| 507 | − result = wait_event_timeout(priv->waitq, | |
| 508 | − (status = priv->status), | |
| 509 | − adap->timeout); | |
| 510 | − if (!result) { | |
| 511 | − status = -ETIMEDOUT; | |
| 512 | − dev_warn(&priv->pci_dev->dev, | |
| 513 | − "Timeout waiting for interrupt!\n"); | |
| 514 | − } | |
| 515 | − priv->status = 0; | |
| 516 | − return i801_check_post(priv, status); | |
| 492 | + result = wait_for_completion_timeout(&priv->done, adap->timeout); | |
| 493 | + return i801_check_post(priv, result ? priv->status : -ETIMEDOUT); | |
| 517 | 494 | } |
| 518 | 495 | |
| 519 | 496 | /* the current contents of SMBHSTCNT can be overwritten, since PEC, |
| @@ -638,7 +615,7 @@ static irqreturn_t i801_host_notify_isr(struct i801_priv *priv) · 118 unmodified lines | ||
| 638 | 615 | * DEV_ERR - Invalid command, NAK or communication timeout |
| 639 | 616 | * BUS_ERR - SMI# transaction collision |
| 640 | 617 | * FAILED - transaction was canceled due to a KILL request |
| 641 | − * When any of these occur, update ->status and wake up the waitq. | |
| 618 | + * When any of these occur, update ->status and signal completion. | |
| 642 | 619 | * ->status must be cleared before kicking off the next transaction. |
| 643 | 620 | * |
| 644 | 621 | * 2) For byte-by-byte (I2C read/write) transactions, one BYTE_DONE interrupt |
| @@ -653,8 +630,8 @@ static irqreturn_t i801_isr(int irq, void *dev_id) · 8 unmodified lines | ||
| 653 | 630 | u8 status; |
| 654 | 631 | |
| 655 | 632 | /* Confirm this is our interrupt */ |
| 656 | − pci_read_config_word(priv->pci_dev, SMBPCISTS, &pcists); | |
| 657 | − if (!(pcists & SMBPCISTS_INTS)) | |
| 633 | + pci_read_config_word(priv->pci_dev, PCI_STATUS, &pcists); | |
| 634 | + if (!(pcists & PCI_STATUS_INTERRUPT)) | |
| 658 | 635 | return IRQ_NONE; |
| 659 | 636 | |
| 660 | 637 | if (priv->features & FEATURE_HOST_NOTIFY) { |
| @@ -675,7 +652,7 @@ static irqreturn_t i801_isr(int irq, void *dev_id) · 14 unmodified lines | ||
| 675 | 652 | if (status) { |
| 676 | 653 | outb_p(status, SMBHSTSTS(priv)); |
| 677 | 654 | priv->status = status; |
| 678 | − wake_up(&priv->waitq); | |
| 655 | + complete(&priv->done); | |
| 679 | 656 | } |
| 680 | 657 | |
| 681 | 658 | return IRQ_HANDLED; |
| @@ -694,15 +671,15 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, · 12 unmodified lines | ||
| 694 | 671 | int i, len; |
| 695 | 672 | int smbcmd; |
| 696 | 673 | int status; |
| 697 | − int result; | |
| 674 | + unsigned long result; | |
| 698 | 675 | const struct i2c_adapter *adap = &priv->adapter; |
| 699 | 676 | |
| 700 | 677 | if (command == I2C_SMBUS_BLOCK_PROC_CALL) |
| 701 | 678 | return -EOPNOTSUPP; |
| 702 | 679 | |
| 703 | − result = i801_check_pre(priv); | |
| 704 | − if (result < 0) | |
| 705 | − return result; | |
| 680 | + status = i801_check_pre(priv); | |
| 681 | + if (status < 0) | |
| 682 | + return status; | |
| 706 | 683 | |
| 707 | 684 | len = data->block[0]; |
| 708 | 685 | |
| @@ -726,17 +703,10 @@ static int i801_block_transaction_byte_by_byte(struct i801_priv *priv, · 17 unmodified lines | ||
| 726 | 703 | priv->count = 0; |
| 727 | 704 | priv->data = &data->block[1]; |
| 728 | 705 | |
| 706 | + reinit_completion(&priv->done); | |
| 729 | 707 | outb_p(priv->cmd | SMBHSTCNT_START, SMBHSTCNT(priv)); |
| 730 | − result = wait_event_timeout(priv->waitq, | |
| 731 | − (status = priv->status), | |
| 732 | − adap->timeout); | |
| 733 | − if (!result) { | |
| 734 | − status = -ETIMEDOUT; | |
| 735 | − dev_warn(&priv->pci_dev->dev, | |
| 736 | − "Timeout waiting for interrupt!\n"); | |
| 737 | − } | |
| 738 | − priv->status = 0; | |
| 739 | − return i801_check_post(priv, status); | |
| 708 | + result = wait_for_completion_timeout(&priv->done, adap->timeout); | |
| 709 | + return i801_check_post(priv, result ? priv->status : -ETIMEDOUT); | |
| 740 | 710 | } |
| 741 | 711 | |
| 742 | 712 | for (i = 1; i <= len; i++) { |
| @@ -1322,11 +1292,11 @@ static void i801_probe_optional_slaves(struct i801_priv *priv) · 579 unmodified lines | ||
| 1322 | 1292 | return; |
| 1323 | 1293 | |
| 1324 | 1294 | if (apanel_addr) { |
| 1325 | − struct i2c_board_info info; | |
| 1295 | + struct i2c_board_info info = { | |
| 1296 | + .addr = apanel_addr, | |
| 1297 | + .type = "fujitsu_apanel", | |
| 1298 | + }; | |
| 1326 | 1299 | |
| 1327 | − memset(&info, 0, sizeof(struct i2c_board_info)); | |
| 1328 | − info.addr = apanel_addr; | |
| 1329 | − strlcpy(info.type, "fujitsu_apanel", I2C_NAME_SIZE); | |
| 1330 | 1300 | i2c_new_client_device(&priv->adapter, &info); |
| 1331 | 1301 | } |
| 1332 | 1302 | |
| @@ -1715,19 +1685,17 @@ static inline int i801_acpi_probe(struct i801_priv *priv) { return 0; } · 382 unmodified lines | ||
| 1715 | 1685 | static inline void i801_acpi_remove(struct i801_priv *priv) { } |
| 1716 | 1686 | #endif |
| 1717 | 1687 | |
| 1718 | −static unsigned char i801_setup_hstcfg(struct i801_priv *priv) | |
| 1688 | +static void i801_setup_hstcfg(struct i801_priv *priv) | |
| 1719 | 1689 | { |
| 1720 | 1690 | unsigned char hstcfg = priv->original_hstcfg; |
| 1721 | 1691 | |
| 1722 | 1692 | hstcfg &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ |
| 1723 | 1693 | hstcfg |= SMBHSTCFG_HST_EN; |
| 1724 | 1694 | pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hstcfg); |
| 1725 | − return hstcfg; | |
| 1726 | 1695 | } |
| 1727 | 1696 | |
| 1728 | 1697 | static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) |
| 1729 | 1698 | { |
| 1730 | − unsigned char temp; | |
| 1731 | 1699 | int err, i; |
| 1732 | 1700 | struct i801_priv *priv; |
| 1733 | 1701 | |
| @@ -1838,8 +1806,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 104 unmodified lines | ||
| 1838 | 1806 | if (i801_acpi_probe(priv)) |
| 1839 | 1807 | return -ENODEV; |
| 1840 | 1808 | |
| 1841 | − err = pcim_iomap_regions(dev, 1 << SMBBAR, | |
| 1842 | − dev_driver_string(&dev->dev)); | |
| 1809 | + err = pcim_iomap_regions(dev, 1 << SMBBAR, DRV_NAME); | |
| 1843 | 1810 | if (err) { |
| 1844 | 1811 | dev_err(&dev->dev, |
| 1845 | 1812 | "Failed to request SMBus region 0x%lx-0x%Lx\n", |
| @@ -1850,16 +1817,16 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 4 unmodified lines | ||
| 1850 | 1817 | } |
| 1851 | 1818 | |
| 1852 | 1819 | pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &priv->original_hstcfg); |
| 1853 | − temp = i801_setup_hstcfg(priv); | |
| 1820 | + i801_setup_hstcfg(priv); | |
| 1854 | 1821 | if (!(priv->original_hstcfg & SMBHSTCFG_HST_EN)) |
| 1855 | 1822 | dev_info(&dev->dev, "Enabling SMBus device\n"); |
| 1856 | 1823 | |
| 1857 | − if (temp & SMBHSTCFG_SMB_SMI_EN) { | |
| 1824 | + if (priv->original_hstcfg & SMBHSTCFG_SMB_SMI_EN) { | |
| 1858 | 1825 | dev_dbg(&dev->dev, "SMBus using interrupt SMI#\n"); |
| 1859 | 1826 | /* Disable SMBus interrupt feature if SMBus using SMI# */ |
| 1860 | 1827 | priv->features &= ~FEATURE_IRQ; |
| 1861 | 1828 | } |
| 1862 | − if (temp & SMBHSTCFG_SPD_WD) | |
| 1829 | + if (priv->original_hstcfg & SMBHSTCFG_SPD_WD) | |
| 1863 | 1830 | dev_info(&dev->dev, "SPD Write Disable is set\n"); |
| 1864 | 1831 | |
| 1865 | 1832 | /* Clear special mode bits */ |
| @@ -1881,24 +1848,23 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id) · 15 unmodified lines | ||
| 1881 | 1848 | u16 pcictl, pcists; |
| 1882 | 1849 | |
| 1883 | 1850 | /* Complain if an interrupt is already pending */ |
| 1884 | − pci_read_config_word(priv->pci_dev, SMBPCISTS, &pcists); | |
| 1885 | − if (pcists & SMBPCISTS_INTS) | |
| 1851 | + pci_read_config_word(priv->pci_dev, PCI_STATUS, &pcists); | |
| 1852 | + if (pcists & PCI_STATUS_INTERRUPT) | |
| 1886 | 1853 | dev_warn(&dev->dev, "An interrupt is pending!\n"); |
| 1887 | 1854 | |
| 1888 | 1855 | /* Check if interrupts have been disabled */ |
| 1889 | − pci_read_config_word(priv->pci_dev, SMBPCICTL, &pcictl); | |
| 1890 | − if (pcictl & SMBPCICTL_INTDIS) { | |
| 1856 | + pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pcictl); | |
| 1857 | + if (pcictl & PCI_COMMAND_INTX_DISABLE) { | |
| 1891 | 1858 | dev_info(&dev->dev, "Interrupts are disabled\n"); |
| 1892 | 1859 | priv->features &= ~FEATURE_IRQ; |
| 1893 | 1860 | } |
| 1894 | 1861 | } |
| 1895 | 1862 | |
| 1896 | 1863 | if (priv->features & FEATURE_IRQ) { |
| 1897 | − init_waitqueue_head(&priv->waitq); | |
| 1864 | + init_completion(&priv->done); | |
| 1898 | 1865 | |
| 1899 | 1866 | err = devm_request_irq(&dev->dev, dev->irq, i801_isr, |
| 1900 | − IRQF_SHARED, | |
| 1901 | − dev_driver_string(&dev->dev), priv); | |
| 1867 | + IRQF_SHARED, DRV_NAME, priv); | |
| 1902 | 1868 | if (err) { |
| 1903 | 1869 | dev_err(&dev->dev, "Failed to allocate irq %d: %d\n", |
| 1904 | 1870 | dev->irq, err); |
| @@ -1988,7 +1954,7 @@ static int i801_resume(struct device *dev) · 83 unmodified lines | ||
| 1988 | 1954 | static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume); |
| 1989 | 1955 | |
| 1990 | 1956 | static struct pci_driver i801_driver = { |
| 1991 | − .name = "i801_smbus", | |
| 1957 | + .name = DRV_NAME, | |
| 1992 | 1958 | .id_table = i801_ids, |
| 1993 | 1959 | .probe = i801_probe, |
| 1994 | 1960 | .remove = i801_remove, |
| @@ -170,11 +170,11 @@ enum imx_i2c_type { · 169 unmodified lines | ||
| 170 | 170 | |
| 171 | 171 | struct imx_i2c_hwdata { |
| 172 | 172 | enum imx_i2c_type devtype; |
| 173 | − unsigned regshift; | |
| 173 | + unsigned int regshift; | |
| 174 | 174 | struct imx_i2c_clk_pair *clk_div; |
| 175 | − unsigned ndivs; | |
| 176 | − unsigned i2sr_clr_opcode; | |
| 177 | − unsigned i2cr_ien_opcode; | |
| 175 | + unsigned int ndivs; | |
| 176 | + unsigned int i2sr_clr_opcode; | |
| 177 | + unsigned int i2cr_ien_opcode; | |
| 178 | 178 | }; |
| 179 | 179 | |
| 180 | 180 | struct imx_i2c_dma { |
| @@ -452,8 +452,6 @@ static int i2c_imx_bus_busy(struct imx_i2c_struct *i2c_imx, int for_busy, bool a · 271 unmodified lines | ||
| 452 | 452 | unsigned long orig_jiffies = jiffies; |
| 453 | 453 | unsigned int temp; |
| 454 | 454 | |
| 455 | − dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); | |
| 456 | − | |
| 457 | 455 | while (1) { |
| 458 | 456 | temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); |
| 459 | 457 | |
| @@ -599,8 +597,6 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx, bool atomic) · 139 unmodified lines | ||
| 599 | 597 | unsigned int temp = 0; |
| 600 | 598 | int result; |
| 601 | 599 | |
| 602 | − dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); | |
| 603 | − | |
| 604 | 600 | imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR); |
| 605 | 601 | /* Enable I2C controller */ |
| 606 | 602 | imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR); |
| @@ -635,7 +631,6 @@ static void i2c_imx_stop(struct imx_i2c_struct *i2c_imx, bool atomic) · 28 unmodified lines | ||
| 635 | 631 | |
| 636 | 632 | if (!i2c_imx->stopped) { |
| 637 | 633 | /* Stop I2C transaction */ |
| 638 | − dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); | |
| 639 | 634 | temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); |
| 640 | 635 | if (!(temp & I2CR_MSTA)) |
| 641 | 636 | i2c_imx->stopped = 1; |
| @@ -1167,8 +1162,6 @@ static int i2c_imx_xfer_common(struct i2c_adapter *adapter, · 525 unmodified lines | ||
| 1167 | 1162 | bool is_lastmsg = false; |
| 1168 | 1163 | struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(adapter); |
| 1169 | 1164 | |
| 1170 | − dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); | |
| 1171 | − | |
| 1172 | 1165 | /* Start I2C transfer */ |
| 1173 | 1166 | result = i2c_imx_start(i2c_imx, atomic); |
| 1174 | 1167 | if (result) { |
| @@ -1371,8 +1364,6 @@ static int i2c_imx_probe(struct platform_device *pdev) · 196 unmodified lines | ||
| 1371 | 1364 | dma_addr_t phy_addr; |
| 1372 | 1365 | const struct imx_i2c_hwdata *match; |
| 1373 | 1366 | |
| 1374 | − dev_dbg(&pdev->dev, "<%s>\n", __func__); | |
| 1375 | − | |
| 1376 | 1367 | irq = platform_get_irq(pdev, 0); |
| 1377 | 1368 | if (irq < 0) |
| 1378 | 1369 | return irq; |
| @@ -1395,7 +1386,7 @@ static int i2c_imx_probe(struct platform_device *pdev) · 16 unmodified lines | ||
| 1395 | 1386 | platform_get_device_id(pdev)->driver_data; |
| 1396 | 1387 | |
| 1397 | 1388 | /* Setup i2c_imx driver structure */ |
| 1398 | − strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); | |
| 1389 | + strscpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx->adapter.name)); | |
| 1399 | 1390 | i2c_imx->adapter.owner = THIS_MODULE; |
| 1400 | 1391 | i2c_imx->adapter.algo = &i2c_imx_algo; |
| 1401 | 1392 | i2c_imx->adapter.dev.parent = &pdev->dev; |
| @@ -635,6 +635,8 @@ static irqreturn_t mpc_i2c_isr(int irq, void *dev_id) · 634 unmodified lines | ||
| 635 | 635 | |
| 636 | 636 | status = readb(i2c->base + MPC_I2C_SR); |
| 637 | 637 | if (status & CSR_MIF) { |
| 638 | + /* Read again to allow register to stabilise */ | |
| 639 | + status = readb(i2c->base + MPC_I2C_SR); | |
| 638 | 640 | writeb(0, i2c->base + MPC_I2C_SR); |
| 639 | 641 | mpc_i2c_do_intr(i2c, status); |
| 640 | 642 | return IRQ_HANDLED; |
| @@ -1225,6 +1225,13 @@ static int mtk_i2c_probe(struct platform_device *pdev) · 1224 unmodified lines | ||
| 1225 | 1225 | i2c->adap.quirks = i2c->dev_comp->quirks; |
| 1226 | 1226 | i2c->adap.timeout = 2 * HZ; |
| 1227 | 1227 | i2c->adap.retries = 1; |
| 1228 | + i2c->adap.bus_regulator = devm_regulator_get_optional(&pdev->dev, "vbus"); | |
| 1229 | + if (IS_ERR(i2c->adap.bus_regulator)) { | |
| 1230 | + if (PTR_ERR(i2c->adap.bus_regulator) == -ENODEV) | |
| 1231 | + i2c->adap.bus_regulator = NULL; | |
| 1232 | + else | |
| 1233 | + return PTR_ERR(i2c->adap.bus_regulator); | |
| 1234 | + } | |
| 1228 | 1235 | |
| 1229 | 1236 | ret = mtk_i2c_parse_dt(pdev->dev.of_node, i2c); |
| 1230 | 1237 | if (ret) |
| @@ -1286,7 +1293,7 @@ static int mtk_i2c_probe(struct platform_device *pdev) · 55 unmodified lines | ||
| 1286 | 1293 | |
| 1287 | 1294 | ret = devm_request_irq(&pdev->dev, irq, mtk_i2c_irq, |
| 1288 | 1295 | IRQF_NO_SUSPEND | IRQF_TRIGGER_NONE, |
| 1289 | − I2C_DRV_NAME, i2c); | |
| 1296 | + dev_name(&pdev->dev), i2c); | |
| 1290 | 1297 | if (ret < 0) { |
| 1291 | 1298 | dev_err(&pdev->dev, |
| 1292 | 1299 | "Request I2C IRQ %d fail\n", irq); |
| @@ -769,6 +769,7 @@ static const struct of_device_id cci_dt_match[] = { · 768 unmodified lines | ||
| 769 | 769 | { .compatible = "qcom,msm8916-cci", .data = &cci_v1_data}, |
| 770 | 770 | { .compatible = "qcom,msm8996-cci", .data = &cci_v2_data}, |
| 771 | 771 | { .compatible = "qcom,sdm845-cci", .data = &cci_v2_data}, |
| 772 | + { .compatible = "qcom,sm8250-cci", .data = &cci_v2_data}, | |
| 772 | 773 | {} |
| 773 | 774 | }; |
| 774 | 775 | MODULE_DEVICE_TABLE(of, cci_dt_match); |
| @@ -1013,7 +1013,6 @@ static const struct of_device_id rcar_i2c_dt_ids[] = { · 1012 unmodified lines | ||
| 1013 | 1013 | { .compatible = "renesas,i2c-r8a7794", .data = (void *)I2C_RCAR_GEN2 }, |
| 1014 | 1014 | { .compatible = "renesas,i2c-r8a7795", .data = (void *)I2C_RCAR_GEN3 }, |
| 1015 | 1015 | { .compatible = "renesas,i2c-r8a7796", .data = (void *)I2C_RCAR_GEN3 }, |
| 1016 | − { .compatible = "renesas,i2c-rcar", .data = (void *)I2C_RCAR_GEN1 }, /* Deprecated */ | |
| 1017 | 1016 | { .compatible = "renesas,rcar-gen1-i2c", .data = (void *)I2C_RCAR_GEN1 }, |
| 1018 | 1017 | { .compatible = "renesas,rcar-gen2-i2c", .data = (void *)I2C_RCAR_GEN2 }, |
| 1019 | 1018 | { .compatible = "renesas,rcar-gen3-i2c", .data = (void *)I2C_RCAR_GEN3 }, |
| @@ -42,8 +42,10 @@ · 41 unmodified lines | ||
| 42 | 42 | #include <linux/io.h> |
| 43 | 43 | #include <linux/module.h> |
| 44 | 44 | #include <linux/of.h> |
| 45 | +#include <linux/of_device.h> | |
| 45 | 46 | #include <linux/platform_device.h> |
| 46 | 47 | #include <linux/pm_runtime.h> |
| 48 | +#include <linux/reset.h> | |
| 47 | 49 | |
| 48 | 50 | #define RIIC_ICCR1 0x00 |
| 49 | 51 | #define RIIC_ICCR2 0x04 |
| @@ -86,6 +88,11 @@ · 36 unmodified lines | ||
| 86 | 88 | |
| 87 | 89 | #define RIIC_INIT_MSG -1 |
| 88 | 90 | |
| 91 | +enum riic_type { | |
| 92 | + RIIC_RZ_A, | |
| 93 | + RIIC_RZ_G2L, | |
| 94 | +}; | |
| 95 | + | |
| 89 | 96 | struct riic_dev { |
| 90 | 97 | void __iomem *base; |
| 91 | 98 | u8 *buf; |
| @@ -395,7 +402,9 @@ static int riic_i2c_probe(struct platform_device *pdev) · 303 unmodified lines | ||
| 395 | 402 | struct i2c_adapter *adap; |
| 396 | 403 | struct resource *res; |
| 397 | 404 | struct i2c_timings i2c_t; |
| 405 | + struct reset_control *rstc; | |
| 398 | 406 | int i, ret; |
| 407 | + enum riic_type type; | |
| 399 | 408 | |
| 400 | 409 | riic = devm_kzalloc(&pdev->dev, sizeof(*riic), GFP_KERNEL); |
| 401 | 410 | if (!riic) |
| @@ -412,6 +421,17 @@ static int riic_i2c_probe(struct platform_device *pdev) · 10 unmodified lines | ||
| 412 | 421 | return PTR_ERR(riic->clk); |
| 413 | 422 | } |
| 414 | 423 | |
| 424 | + type = (enum riic_type)of_device_get_match_data(&pdev->dev); | |
| 425 | + if (type == RIIC_RZ_G2L) { | |
| 426 | + rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); | |
| 427 | + if (IS_ERR(rstc)) { | |
| 428 | + dev_err(&pdev->dev, "Error: missing reset ctrl\n"); | |
| 429 | + return PTR_ERR(rstc); | |
| 430 | + } | |
| 431 | + | |
| 432 | + reset_control_deassert(rstc); | |
| 433 | + } | |
| 434 | + | |
| 415 | 435 | for (i = 0; i < ARRAY_SIZE(riic_irqs); i++) { |
| 416 | 436 | res = platform_get_resource(pdev, IORESOURCE_IRQ, riic_irqs[i].res_num); |
| 417 | 437 | if (!res) |
| @@ -472,7 +492,8 @@ static int riic_i2c_remove(struct platform_device *pdev) · 54 unmodified lines | ||
| 472 | 492 | } |
| 473 | 493 | |
| 474 | 494 | static const struct of_device_id riic_i2c_dt_ids[] = { |
| 475 | − { .compatible = "renesas,riic-rz" }, | |
| 495 | + { .compatible = "renesas,riic-r9a07g044", .data = (void *)RIIC_RZ_G2L }, | |
| 496 | + { .compatible = "renesas,riic-rz", .data = (void *)RIIC_RZ_A }, | |
| 476 | 497 | { /* Sentinel */ }, |
| 477 | 498 | }; |
| 478 | 499 | |
| @@ -51,6 +51,7 @@ · 50 unmodified lines | ||
| 51 | 51 | |
| 52 | 52 | /* STM32F7 I2C control 1 */ |
| 53 | 53 | #define STM32F7_I2C_CR1_PECEN BIT(23) |
| 54 | +#define STM32F7_I2C_CR1_ALERTEN BIT(22) | |
| 54 | 55 | #define STM32F7_I2C_CR1_SMBHEN BIT(20) |
| 55 | 56 | #define STM32F7_I2C_CR1_WUPEN BIT(18) |
| 56 | 57 | #define STM32F7_I2C_CR1_SBC BIT(16) |
| @@ -125,6 +126,7 @@ · 68 unmodified lines | ||
| 125 | 126 | (((n) & STM32F7_I2C_ISR_ADDCODE_MASK) >> 17) |
| 126 | 127 | #define STM32F7_I2C_ISR_DIR BIT(16) |
| 127 | 128 | #define STM32F7_I2C_ISR_BUSY BIT(15) |
| 129 | +#define STM32F7_I2C_ISR_ALERT BIT(13) | |
| 128 | 130 | #define STM32F7_I2C_ISR_PECERR BIT(11) |
| 129 | 131 | #define STM32F7_I2C_ISR_ARLO BIT(9) |
| 130 | 132 | #define STM32F7_I2C_ISR_BERR BIT(8) |
| @@ -138,6 +140,7 @@ · 7 unmodified lines | ||
| 138 | 140 | #define STM32F7_I2C_ISR_TXE BIT(0) |
| 139 | 141 | |
| 140 | 142 | /* STM32F7 I2C Interrupt Clear */ |
| 143 | +#define STM32F7_I2C_ICR_ALERTCF BIT(13) | |
| 141 | 144 | #define STM32F7_I2C_ICR_PECCF BIT(11) |
| 142 | 145 | #define STM32F7_I2C_ICR_ARLOCF BIT(9) |
| 143 | 146 | #define STM32F7_I2C_ICR_BERRCF BIT(8) |
| @@ -278,6 +281,17 @@ struct stm32f7_i2c_msg { · 134 unmodified lines | ||
| 278 | 281 | u8 smbus_buf[I2C_SMBUS_BLOCK_MAX + 3] __aligned(4); |
| 279 | 282 | }; |
| 280 | 283 | |
| 284 | +/** | |
| 285 | + * struct stm32f7_i2c_alert - SMBus alert specific data | |
| 286 | + * @setup: platform data for the smbus_alert i2c client | |
| 287 | + * @ara: I2C slave device used to respond to the SMBus Alert with Alert | |
| 288 | + * Response Address | |
| 289 | + */ | |
| 290 | +struct stm32f7_i2c_alert { | |
| 291 | + struct i2c_smbus_alert_setup setup; | |
| 292 | + struct i2c_client *ara; | |
| 293 | +}; | |
| 294 | + | |
| 281 | 295 | /** |
| 282 | 296 | * struct stm32f7_i2c_dev - private data of the controller |
| 283 | 297 | * @adap: I2C adapter for this controller |
| @@ -310,6 +324,7 @@ struct stm32f7_i2c_msg { · 26 unmodified lines | ||
| 310 | 324 | * @analog_filter: boolean to indicate enabling of the analog filter |
| 311 | 325 | * @dnf_dt: value of digital filter requested via dt |
| 312 | 326 | * @dnf: value of digital filter to apply |
| 327 | + * @alert: SMBus alert specific data | |
| 313 | 328 | */ |
| 314 | 329 | struct stm32f7_i2c_dev { |
| 315 | 330 | struct i2c_adapter adap; |
| @@ -341,6 +356,7 @@ struct stm32f7_i2c_dev { · 25 unmodified lines | ||
| 341 | 356 | bool analog_filter; |
| 342 | 357 | u32 dnf_dt; |
| 343 | 358 | u32 dnf; |
| 359 | + struct stm32f7_i2c_alert *alert; | |
| 344 | 360 | }; |
| 345 | 361 | |
| 346 | 362 | /* |
| @@ -1624,6 +1640,13 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data) · 1277 unmodified lines | ||
| 1624 | 1640 | f7_msg->result = -EINVAL; |
| 1625 | 1641 | } |
| 1626 | 1642 | |
| 1643 | + if (status & STM32F7_I2C_ISR_ALERT) { | |
| 1644 | + dev_dbg(dev, "<%s>: SMBus alert received\n", __func__); | |
| 1645 | + writel_relaxed(STM32F7_I2C_ICR_ALERTCF, base + STM32F7_I2C_ICR); | |
| 1646 | + i2c_handle_smbus_alert(i2c_dev->alert->ara); | |
| 1647 | + return IRQ_HANDLED; | |
| 1648 | + } | |
| 1649 | + | |
| 1627 | 1650 | if (!i2c_dev->slave_running) { |
| 1628 | 1651 | u32 mask; |
| 1629 | 1652 | /* Disable interrupts */ |
| @@ -1990,6 +2013,42 @@ static void stm32f7_i2c_disable_smbus_host(struct stm32f7_i2c_dev *i2c_dev) · 360 unmodified lines | ||
| 1990 | 2013 | } |
| 1991 | 2014 | } |
| 1992 | 2015 | |
| 2016 | +static int stm32f7_i2c_enable_smbus_alert(struct stm32f7_i2c_dev *i2c_dev) | |
| 2017 | +{ | |
| 2018 | + struct stm32f7_i2c_alert *alert; | |
| 2019 | + struct i2c_adapter *adap = &i2c_dev->adap; | |
| 2020 | + struct device *dev = i2c_dev->dev; | |
| 2021 | + void __iomem *base = i2c_dev->base; | |
| 2022 | + | |
| 2023 | + alert = devm_kzalloc(dev, sizeof(*alert), GFP_KERNEL); | |
| 2024 | + if (!alert) | |
| 2025 | + return -ENOMEM; | |
| 2026 | + | |
| 2027 | + alert->ara = i2c_new_smbus_alert_device(adap, &alert->setup); | |
| 2028 | + if (IS_ERR(alert->ara)) | |
| 2029 | + return PTR_ERR(alert->ara); | |
| 2030 | + | |
| 2031 | + i2c_dev->alert = alert; | |
| 2032 | + | |
| 2033 | + /* Enable SMBus Alert */ | |
| 2034 | + stm32f7_i2c_set_bits(base + STM32F7_I2C_CR1, STM32F7_I2C_CR1_ALERTEN); | |
| 2035 | + | |
| 2036 | + return 0; | |
| 2037 | +} | |
| 2038 | + | |
| 2039 | +static void stm32f7_i2c_disable_smbus_alert(struct stm32f7_i2c_dev *i2c_dev) | |
| 2040 | +{ | |
| 2041 | + struct stm32f7_i2c_alert *alert = i2c_dev->alert; | |
| 2042 | + void __iomem *base = i2c_dev->base; | |
| 2043 | + | |
| 2044 | + if (alert) { | |
| 2045 | + /* Disable SMBus Alert */ | |
| 2046 | + stm32f7_i2c_clr_bits(base + STM32F7_I2C_CR1, | |
| 2047 | + STM32F7_I2C_CR1_ALERTEN); | |
| 2048 | + i2c_unregister_device(alert->ara); | |
| 2049 | + } | |
| 2050 | +} | |
| 2051 | + | |
| 1993 | 2052 | static u32 stm32f7_i2c_func(struct i2c_adapter *adap) |
| 1994 | 2053 | { |
| 1995 | 2054 | struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(adap); |
| @@ -2173,6 +2232,16 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) · 177 unmodified lines | ||
| 2173 | 2232 | } |
| 2174 | 2233 | } |
| 2175 | 2234 | |
| 2235 | + if (of_property_read_bool(pdev->dev.of_node, "smbus-alert")) { | |
| 2236 | + ret = stm32f7_i2c_enable_smbus_alert(i2c_dev); | |
| 2237 | + if (ret) { | |
| 2238 | + dev_err(i2c_dev->dev, | |
| 2239 | + "failed to enable SMBus alert protocol (%d)\n", | |
| 2240 | + ret); | |
| 2241 | + goto i2c_disable_smbus_host; | |
| 2242 | + } | |
| 2243 | + } | |
| 2244 | + | |
| 2176 | 2245 | dev_info(i2c_dev->dev, "STM32F7 I2C-%d bus adapter\n", adap->nr); |
| 2177 | 2246 | |
| 2178 | 2247 | pm_runtime_mark_last_busy(i2c_dev->dev); |
| @@ -2180,6 +2249,9 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) · 1 unmodified line | ||
| 2180 | 2249 | |
| 2181 | 2250 | return 0; |
| 2182 | 2251 | |
| 2252 | +i2c_disable_smbus_host: | |
| 2253 | + stm32f7_i2c_disable_smbus_host(i2c_dev); | |
| 2254 | + | |
| 2183 | 2255 | i2c_adapter_remove: |
| 2184 | 2256 | i2c_del_adapter(adap); |
| 2185 | 2257 | |
| @@ -2214,6 +2286,7 @@ static int stm32f7_i2c_remove(struct platform_device *pdev) · 28 unmodified lines | ||
| 2214 | 2286 | { |
| 2215 | 2287 | struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev); |
| 2216 | 2288 | |
| 2289 | + stm32f7_i2c_disable_smbus_alert(i2c_dev); | |
| 2217 | 2290 | stm32f7_i2c_disable_smbus_host(i2c_dev); |
| 2218 | 2291 | |
| 2219 | 2292 | i2c_del_adapter(&i2c_dev->adap); |
| @@ -798,11 +798,10 @@ static int xiic_i2c_probe(struct platform_device *pdev) · 797 unmodified lines | ||
| 798 | 798 | init_waitqueue_head(&i2c->wait); |
| 799 | 799 | |
| 800 | 800 | i2c->clk = devm_clk_get(&pdev->dev, NULL); |
| 801 | − if (IS_ERR(i2c->clk)) { | |
| 802 | − if (PTR_ERR(i2c->clk) != -EPROBE_DEFER) | |
| 803 | − dev_err(&pdev->dev, "input clock not found.\n"); | |
| 804 | − return PTR_ERR(i2c->clk); | |
| 805 | − } | |
| 801 | + if (IS_ERR(i2c->clk)) | |
| 802 | + return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk), | |
| 803 | + "input clock not found.\n"); | |
| 804 | + | |
| 806 | 805 | ret = clk_prepare_enable(i2c->clk); |
| 807 | 806 | if (ret) { |
| 808 | 807 | dev_err(&pdev->dev, "Unable to enable clock.\n"); |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include <linux/i2c-smbus.h> |
| 25 | 25 | #include <linux/idr.h> |
| 26 | 26 | #include <linux/init.h> |
| 27 | +#include <linux/interrupt.h> | |
| 27 | 28 | #include <linux/irqflags.h> |
| 28 | 29 | #include <linux/jump_label.h> |
| 29 | 30 | #include <linux/kernel.h> |
| @@ -399,7 +400,8 @@ static int i2c_gpio_init_recovery(struct i2c_adapter *adap) · 369 unmodified lines | ||
| 399 | 400 | static int i2c_init_recovery(struct i2c_adapter *adap) |
| 400 | 401 | { |
| 401 | 402 | struct i2c_bus_recovery_info *bri = adap->bus_recovery_info; |
| 402 | − char *err_str, *err_level = KERN_ERR; | |
| 403 | + bool is_error_level = true; | |
| 404 | + char *err_str; | |
| 403 | 405 | |
| 404 | 406 | if (!bri) |
| 405 | 407 | return 0; |
| @@ -409,7 +411,7 @@ static int i2c_init_recovery(struct i2c_adapter *adap) · 3 unmodified lines | ||
| 409 | 411 | |
| 410 | 412 | if (!bri->recover_bus) { |
| 411 | 413 | err_str = "no suitable method provided"; |
| 412 | − err_level = KERN_DEBUG; | |
| 414 | + is_error_level = false; | |
| 413 | 415 | goto err; |
| 414 | 416 | } |
| 415 | 417 | |
| @@ -436,7 +438,10 @@ static int i2c_init_recovery(struct i2c_adapter *adap) · 20 unmodified lines | ||
| 436 | 438 | |
| 437 | 439 | return 0; |
| 438 | 440 | err: |
| 439 | − dev_printk(err_level, &adap->dev, "Not using recovery: %s\n", err_str); | |
| 441 | + if (is_error_level) | |
| 442 | + dev_err(&adap->dev, "Not using recovery: %s\n", err_str); | |
| 443 | + else | |
| 444 | + dev_dbg(&adap->dev, "Not using recovery: %s\n", err_str); | |
| 440 | 445 | adap->bus_recovery_info = NULL; |
| 441 | 446 | |
| 442 | 447 | return -EINVAL; |
| @@ -461,12 +466,14 @@ static int i2c_smbus_host_notify_to_irq(const struct i2c_client *client) · 18 unmodified lines | ||
| 461 | 466 | static int i2c_device_probe(struct device *dev) |
| 462 | 467 | { |
| 463 | 468 | struct i2c_client *client = i2c_verify_client(dev); |
| 469 | + struct i2c_adapter *adap; | |
| 464 | 470 | struct i2c_driver *driver; |
| 465 | 471 | int status; |
| 466 | 472 | |
| 467 | 473 | if (!client) |
| 468 | 474 | return 0; |
| 469 | 475 | |
| 476 | + adap = client->adapter; | |
| 470 | 477 | client->irq = client->init_irq; |
| 471 | 478 | |
| 472 | 479 | if (!client->irq) { |
| @@ -532,6 +539,14 @@ static int i2c_device_probe(struct device *dev) · 59 unmodified lines | ||
| 532 | 539 | |
| 533 | 540 | dev_dbg(dev, "probe\n"); |
| 534 | 541 | |
| 542 | + if (adap->bus_regulator) { | |
| 543 | + status = regulator_enable(adap->bus_regulator); | |
| 544 | + if (status < 0) { | |
| 545 | + dev_err(&adap->dev, "Failed to enable bus regulator\n"); | |
| 546 | + goto err_clear_wakeup_irq; | |
| 547 | + } | |
| 548 | + } | |
| 549 | + | |
| 535 | 550 | status = of_clk_set_defaults(dev->of_node, false); |
| 536 | 551 | if (status < 0) |
| 537 | 552 | goto err_clear_wakeup_irq; |
| @@ -589,8 +604,10 @@ put_sync_adapter: · 51 unmodified lines | ||
| 589 | 604 | static int i2c_device_remove(struct device *dev) |
| 590 | 605 | { |
| 591 | 606 | struct i2c_client *client = to_i2c_client(dev); |
| 607 | + struct i2c_adapter *adap; | |
| 592 | 608 | struct i2c_driver *driver; |
| 593 | 609 | |
| 610 | + adap = client->adapter; | |
| 594 | 611 | driver = to_i2c_driver(dev->driver); |
| 595 | 612 | if (driver->remove) { |
| 596 | 613 | int status; |
| @@ -605,6 +622,8 @@ static int i2c_device_remove(struct device *dev) · 8 unmodified lines | ||
| 605 | 622 | devres_release_group(&client->dev, client->devres_group_id); |
| 606 | 623 | |
| 607 | 624 | dev_pm_domain_detach(&client->dev, true); |
| 625 | + if (!pm_runtime_status_suspended(&client->dev) && adap->bus_regulator) | |
| 626 | + regulator_disable(adap->bus_regulator); | |
| 608 | 627 | |
| 609 | 628 | dev_pm_clear_wake_irq(&client->dev); |
| 610 | 629 | device_init_wakeup(&client->dev, false); |
| @@ -617,6 +636,86 @@ static int i2c_device_remove(struct device *dev) · 6 unmodified lines | ||
| 617 | 636 | return 0; |
| 618 | 637 | } |
| 619 | 638 | |
| 639 | +#ifdef CONFIG_PM_SLEEP | |
| 640 | +static int i2c_resume_early(struct device *dev) | |
| 641 | +{ | |
| 642 | + struct i2c_client *client = i2c_verify_client(dev); | |
| 643 | + int err; | |
| 644 | + | |
| 645 | + if (!client) | |
| 646 | + return 0; | |
| 647 | + | |
| 648 | + if (pm_runtime_status_suspended(&client->dev) && | |
| 649 | + client->adapter->bus_regulator) { | |
| 650 | + err = regulator_enable(client->adapter->bus_regulator); | |
| 651 | + if (err) | |
| 652 | + return err; | |
| 653 | + } | |
| 654 | + | |
| 655 | + return pm_generic_resume_early(&client->dev); | |
| 656 | +} | |
| 657 | + | |
| 658 | +static int i2c_suspend_late(struct device *dev) | |
| 659 | +{ | |
| 660 | + struct i2c_client *client = i2c_verify_client(dev); | |
| 661 | + int err; | |
| 662 | + | |
| 663 | + if (!client) | |
| 664 | + return 0; | |
| 665 | + | |
| 666 | + err = pm_generic_suspend_late(&client->dev); | |
| 667 | + if (err) | |
| 668 | + return err; | |
| 669 | + | |
| 670 | + if (!pm_runtime_status_suspended(&client->dev) && | |
| 671 | + client->adapter->bus_regulator) | |
| 672 | + return regulator_disable(client->adapter->bus_regulator); | |
| 673 | + | |
| 674 | + return 0; | |
| 675 | +} | |
| 676 | +#endif | |
| 677 | + | |
| 678 | +#ifdef CONFIG_PM | |
| 679 | +static int i2c_runtime_resume(struct device *dev) | |
| 680 | +{ | |
| 681 | + struct i2c_client *client = i2c_verify_client(dev); | |
| 682 | + int err; | |
| 683 | + | |
| 684 | + if (!client) | |
| 685 | + return 0; | |
| 686 | + | |
| 687 | + if (client->adapter->bus_regulator) { | |
| 688 | + err = regulator_enable(client->adapter->bus_regulator); | |
| 689 | + if (err) | |
| 690 | + return err; | |
| 691 | + } | |
| 692 | + | |
| 693 | + return pm_generic_runtime_resume(&client->dev); | |
| 694 | +} | |
| 695 | + | |
| 696 | +static int i2c_runtime_suspend(struct device *dev) | |
| 697 | +{ | |
| 698 | + struct i2c_client *client = i2c_verify_client(dev); | |
| 699 | + int err; | |
| 700 | + | |
| 701 | + if (!client) | |
| 702 | + return 0; | |
| 703 | + | |
| 704 | + err = pm_generic_runtime_suspend(&client->dev); | |
| 705 | + if (err) | |
| 706 | + return err; | |
| 707 | + | |
| 708 | + if (client->adapter->bus_regulator) | |
| 709 | + return regulator_disable(client->adapter->bus_regulator); | |
| 710 | + return 0; | |
| 711 | +} | |
| 712 | +#endif | |
| 713 | + | |
| 714 | +static const struct dev_pm_ops i2c_device_pm = { | |
| 715 | + SET_LATE_SYSTEM_SLEEP_PM_OPS(i2c_suspend_late, i2c_resume_early) | |
| 716 | + SET_RUNTIME_PM_OPS(i2c_runtime_suspend, i2c_runtime_resume, NULL) | |
| 717 | +}; | |
| 718 | + | |
| 620 | 719 | static void i2c_device_shutdown(struct device *dev) |
| 621 | 720 | { |
| 622 | 721 | struct i2c_client *client = i2c_verify_client(dev); |
| @@ -627,6 +726,8 @@ static void i2c_device_shutdown(struct device *dev) · 4 unmodified lines | ||
| 627 | 726 | driver = to_i2c_driver(dev->driver); |
| 628 | 727 | if (driver->shutdown) |
| 629 | 728 | driver->shutdown(client); |
| 729 | + else if (client->irq > 0) | |
| 730 | + disable_irq(client->irq); | |
| 630 | 731 | } |
| 631 | 732 | |
| 632 | 733 | static void i2c_client_dev_release(struct device *dev) |
| @@ -674,6 +775,7 @@ struct bus_type i2c_bus_type = { · 41 unmodified lines | ||
| 674 | 775 | .probe = i2c_device_probe, |
| 675 | 776 | .remove = i2c_device_remove, |
| 676 | 777 | .shutdown = i2c_device_shutdown, |
| 778 | + .pm = &i2c_device_pm, | |
| 677 | 779 | }; |
| 678 | 780 | EXPORT_SYMBOL_GPL(i2c_bus_type); |
| 679 | 781 | |
| @@ -37,8 +37,15 @@ static u8 crc8(u16 data) · 36 unmodified lines | ||
| 37 | 37 | return (u8)(data >> 8); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | −/* Incremental CRC8 over count bytes in the array pointed to by p */ | |
| 41 | −static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) | |
| 40 | +/** | |
| 41 | + * i2c_smbus_pec - Incremental CRC8 over the given input data array | |
| 42 | + * @crc: previous return crc8 value | |
| 43 | + * @p: pointer to data buffer. | |
| 44 | + * @count: number of bytes in data buffer. | |
| 45 | + * | |
| 46 | + * Incremental CRC8 over count bytes in the array pointed to by p | |
| 47 | + */ | |
| 48 | +u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) | |
| 42 | 49 | { |
| 43 | 50 | int i; |
| 44 | 51 | |
| @@ -46,6 +53,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) · 1 unmodified line | ||
| 46 | 53 | crc = crc8((crc ^ p[i]) << 8); |
| 47 | 54 | return crc; |
| 48 | 55 | } |
| 56 | +EXPORT_SYMBOL(i2c_smbus_pec); | |
| 49 | 57 | |
| 50 | 58 | /* Assume a 7-bit address, which is reasonable for SMBus */ |
| 51 | 59 | static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg) |
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <linux/device.h> /* for struct device */ |
| 16 | 16 | #include <linux/sched.h> /* for completion */ |
| 17 | 17 | #include <linux/mutex.h> |
| 18 | +#include <linux/regulator/consumer.h> | |
| 18 | 19 | #include <linux/rtmutex.h> |
| 19 | 20 | #include <linux/irqdomain.h> /* for Host Notify IRQ */ |
| 20 | 21 | #include <linux/of.h> /* for struct device_node */ |
| @@ -147,6 +148,7 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, · 126 unmodified lines | ||
| 147 | 148 | /* Now follow the 'nice' access routines. These also document the calling |
| 148 | 149 | conventions of i2c_smbus_xfer. */ |
| 149 | 150 | |
| 151 | +u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count); | |
| 150 | 152 | s32 i2c_smbus_read_byte(const struct i2c_client *client); |
| 151 | 153 | s32 i2c_smbus_write_byte(const struct i2c_client *client, u8 value); |
| 152 | 154 | s32 i2c_smbus_read_byte_data(const struct i2c_client *client, u8 command); |
| @@ -729,6 +731,7 @@ struct i2c_adapter { · 576 unmodified lines | ||
| 729 | 731 | const struct i2c_adapter_quirks *quirks; |
| 730 | 732 | |
| 731 | 733 | struct irq_domain *host_notify_domain; |
| 734 | + struct regulator *bus_regulator; | |
| 732 | 735 | }; |
| 733 | 736 | #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) |
| 734 | 737 | |