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

Merge tag 'phy-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy

Pull phy updates from Vinod Koul:
"This contains bunch of new device support and one new Sunplus driver
along with updates which include another big round of qmp phy
conversion.

New support:
- Qualcomm SC8280XP eDP & DP and USB3 UNI phy (Bjorn Andersson)
- Rockchip rk3568 inno dsidphy (Chris Morgan)
- ocelot-serdes phy yaml binding (Colin Foster)
- Renesas gen2-usb phy yaml binding (Geert Uytterhoeven)
- RGMII suport in lan966x driver (Horatiu Vultur)
- Qualcomm SM6375 usb snps-femto-v2 bindings (Konrad Dybcio)
- Rockchip rk356x csi-dphya (Michael Riesch)
- Qualcomm sdm670 usb2 bindings (Richard Acayan)
- Sunplus USB2 PHY (Vincent Shih)

Updates:
- Mediatek hdmi, ufs, tphy and xsphy updates to use bitfield helpers
(Chunfeng Yun)
- Continued Qualcomm qmp phy driver split and cleanup. More patches
are under review and expected that next cycle might see completion
of this activity (Dmitry Baryshkov & Johan Hovold)
- TI wiz driver support for j7200 10g (Roger Quadros)
- Qualcomm femto phy driver support for override params to help with
tuning (Sandeep Maheswaram)
- SGMII support in TI wiz driver (Siddharth Vadapalli)
- dev_err_probe simplification (Yuan Can)"

* tag 'phy-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: (170 commits)
phy: phy-mtk-dp: make array driving_params static const
dt-bindings: phy: qcom,qusb2: document sdm670 compatible
phy: qcom-qmp-pcie: fix resource mapping for SDM845 QHP PHY
phy: rockchip-snps-pcie3: only look for rockchip,pipe-grf on rk3588
phy: tegra: xusb: Enable usb role switch attribute
phy: mediatek: fix build warning of FIELD_PREP()
phy: qcom-qmp-usb: Use dev_err_probe() to simplify code
phy: qcom-qmp-ufs: Use dev_err_probe() to simplify code
phy: qcom-qmp-pcie-msm8996: Use dev_err_probe() to simplify code
phy: qcom-qmp-combo: Use dev_err_probe() to simplify code
phy: qualcomm: call clk_disable_unprepare in the error handling
phy: intel: Use dev_err_probe() to simplify code
phy: tegra: xusb: Use dev_err_probe() to simplify code
phy: qcom-snps: Use dev_err_probe() to simplify code
phy: qcom-qusb2: Use dev_err_probe() to simplify code
phy: qcom-qmp-pcie: Use dev_err_probe() to simplify code
phy: ti: phy-j721e-wiz: fix reference leaks in wiz_probe()
phy: mediatek: mipi: remove register access helpers
phy: mediatek: mipi: mt8183: use common helper to access registers
phy: mediatek: mipi: mt8183: use GENMASK to generate bits mask
...

+5343 -2646
+6
Documentation/devicetree/bindings/mfd/ti,j721e-system-controller.yaml
··· 54 54 description: 55 55 Clock provider for TI EHRPWM nodes. 56 56 57 + "phy@[0-9a-f]+$": 58 + type: object 59 + $ref: /schemas/phy/ti,phy-gmii-sel.yaml# 60 + description: 61 + The phy node corresponding to the ethernet MAC. 62 + 57 63 required: 58 64 - compatible 59 65 - reg
+1
Documentation/devicetree/bindings/phy/brcm,cygnus-pcie-phy.yaml
··· 32 32 patternProperties: 33 33 "^pcie-phy@[0-9]+$": 34 34 type: object 35 + additionalProperties: false 35 36 description: > 36 37 PCIe PHY child nodes 37 38
+1 -1
Documentation/devicetree/bindings/phy/cdns,dphy-rx.yaml
··· 7 7 title: Cadence DPHY Rx Device Tree Bindings 8 8 9 9 maintainers: 10 - - Pratyush Yadav <p.yadav@ti.com> 10 + - Pratyush Yadav <pratyush@kernel.org> 11 11 12 12 properties: 13 13 compatible:
+1 -1
Documentation/devicetree/bindings/phy/cdns,dphy.yaml
··· 7 7 title: Cadence DPHY Device Tree Bindings 8 8 9 9 maintainers: 10 - - Pratyush Yadav <p.yadav@ti.com> 10 + - Pratyush Yadav <pratyush@kernel.org> 11 11 12 12 properties: 13 13 compatible:
+11
Documentation/devicetree/bindings/phy/mediatek,tphy.yaml
··· 163 163 - PHY_TYPE_USB3 164 164 - PHY_TYPE_PCIE 165 165 - PHY_TYPE_SATA 166 + - PHY_TYPE_SGMII 166 167 167 168 nvmem-cells: 168 169 items: ··· 218 217 $ref: /schemas/types.yaml#/definitions/uint32 219 218 minimum: 1 220 219 maximum: 15 220 + 221 + mediatek,pre-emphasis: 222 + description: 223 + The level of pre-emphasis which used to widen the eye opening and 224 + boost eye swing, the unit step is about 4.16% increment; e.g. the 225 + level 1 means amplitude increases about 4.16%, the level 2 is about 226 + 8.3% etc. (U2 phy) 227 + $ref: /schemas/types.yaml#/definitions/uint32 228 + minimum: 1 229 + maximum: 3 221 230 222 231 mediatek,bc12: 223 232 description:
+56
Documentation/devicetree/bindings/phy/mscc,vsc7514-serdes.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/mscc,vsc7514-serdes.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Microsemi Ocelot SerDes muxing 8 + 9 + maintainers: 10 + - Alexandre Belloni <alexandre.belloni@bootlin.com> 11 + - UNGLinuxDriver@microchip.com 12 + 13 + description: | 14 + On Microsemi Ocelot, there is a handful of registers in HSIO address 15 + space for setting up the SerDes to switch port muxing. 16 + 17 + A SerDes X can be "muxed" to work with switch port Y or Z for example. 18 + One specific SerDes can also be used as a PCIe interface. 19 + 20 + Hence, a SerDes represents an interface, be it an Ethernet or a PCIe one. 21 + 22 + There are two kinds of SerDes: SERDES1G supports 10/100Mbps in 23 + half/full-duplex and 1000Mbps in full-duplex mode while SERDES6G supports 24 + 10/100Mbps in half/full-duplex and 1000/2500Mbps in full-duplex mode. 25 + 26 + Also, SERDES6G number (aka "macro") 0 is the only interface supporting 27 + QSGMII. 28 + 29 + This is a child of the HSIO syscon ("mscc,ocelot-hsio", see 30 + Documentation/devicetree/bindings/mips/mscc.txt) on the Microsemi Ocelot. 31 + 32 + properties: 33 + compatible: 34 + enum: 35 + - mscc,vsc7514-serdes 36 + 37 + "#phy-cells": 38 + const: 2 39 + description: | 40 + The first number defines the input port to use for a given SerDes macro. 41 + The second defines the macro to use. They are defined in 42 + dt-bindings/phy/phy-ocelot-serdes.h 43 + 44 + required: 45 + - compatible 46 + - "#phy-cells" 47 + 48 + additionalProperties: 49 + false 50 + 51 + examples: 52 + - | 53 + serdes: serdes { 54 + compatible = "mscc,vsc7514-serdes"; 55 + #phy-cells = <2>; 56 + };
-43
Documentation/devicetree/bindings/phy/phy-ocelot-serdes.txt
··· 1 - Microsemi Ocelot SerDes muxing driver 2 - ------------------------------------- 3 - 4 - On Microsemi Ocelot, there is a handful of registers in HSIO address 5 - space for setting up the SerDes to switch port muxing. 6 - 7 - A SerDes X can be "muxed" to work with switch port Y or Z for example. 8 - One specific SerDes can also be used as a PCIe interface. 9 - 10 - Hence, a SerDes represents an interface, be it an Ethernet or a PCIe one. 11 - 12 - There are two kinds of SerDes: SERDES1G supports 10/100Mbps in 13 - half/full-duplex and 1000Mbps in full-duplex mode while SERDES6G supports 14 - 10/100Mbps in half/full-duplex and 1000/2500Mbps in full-duplex mode. 15 - 16 - Also, SERDES6G number (aka "macro") 0 is the only interface supporting 17 - QSGMII. 18 - 19 - This is a child of the HSIO syscon ("mscc,ocelot-hsio", see 20 - Documentation/devicetree/bindings/mips/mscc.txt) on the Microsemi Ocelot. 21 - 22 - Required properties: 23 - 24 - - compatible: should be "mscc,vsc7514-serdes" 25 - - #phy-cells : from the generic phy bindings, must be 2. 26 - The first number defines the input port to use for a given 27 - SerDes macro. The second defines the macro to use. They are 28 - defined in dt-bindings/phy/phy-ocelot-serdes.h 29 - 30 - Example: 31 - 32 - serdes: serdes { 33 - compatible = "mscc,vsc7514-serdes"; 34 - #phy-cells = <2>; 35 - }; 36 - 37 - ethernet { 38 - port1 { 39 - phy-handle = <&phy_foo>; 40 - /* Link SERDES1G_5 to port1 */ 41 - phys = <&serdes 1 SERDES1G_5>; 42 - }; 43 - };
+1
Documentation/devicetree/bindings/phy/phy-rockchip-inno-usb2.yaml
··· 13 13 compatible: 14 14 enum: 15 15 - rockchip,px30-usb2phy 16 + - rockchip,rk3128-usb2phy 16 17 - rockchip,rk3228-usb2phy 17 18 - rockchip,rk3308-usb2phy 18 19 - rockchip,rk3328-usb2phy
+2
Documentation/devicetree/bindings/phy/phy-stm32-usbphyc.yaml
··· 77 77 connector: 78 78 type: object 79 79 $ref: /schemas/connector/usb-connector.yaml 80 + unevaluatedProperties: false 81 + 80 82 properties: 81 83 vbus-supply: true 82 84
+2
Documentation/devicetree/bindings/phy/qcom,edp-phy.yaml
··· 19 19 enum: 20 20 - qcom,sc7280-edp-phy 21 21 - qcom,sc8180x-edp-phy 22 + - qcom,sc8280xp-dp-phy 23 + - qcom,sc8280xp-edp-phy 22 24 23 25 reg: 24 26 items:
+189
Documentation/devicetree/bindings/phy/qcom,msm8996-qmp-pcie-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/qcom,msm8996-qmp-pcie-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm QMP PHY controller (MSM8996 PCIe) 8 + 9 + maintainers: 10 + - Vinod Koul <vkoul@kernel.org> 11 + 12 + description: 13 + QMP PHY controller supports physical layer functionality for a number of 14 + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. 15 + 16 + properties: 17 + compatible: 18 + const: qcom,msm8996-qmp-pcie-phy 19 + 20 + reg: 21 + items: 22 + - description: serdes 23 + 24 + "#address-cells": 25 + enum: [ 1, 2 ] 26 + 27 + "#size-cells": 28 + enum: [ 1, 2 ] 29 + 30 + ranges: true 31 + 32 + clocks: 33 + maxItems: 3 34 + 35 + clock-names: 36 + items: 37 + - const: aux 38 + - const: cfg_ahb 39 + - const: ref 40 + 41 + resets: 42 + maxItems: 3 43 + 44 + reset-names: 45 + items: 46 + - const: phy 47 + - const: common 48 + - const: cfg 49 + 50 + vdda-phy-supply: true 51 + 52 + vdda-pll-supply: true 53 + 54 + vddp-ref-clk-supply: true 55 + 56 + patternProperties: 57 + "^phy@[0-9a-f]+$": 58 + type: object 59 + description: one child node per PHY provided by this block 60 + properties: 61 + reg: 62 + items: 63 + - description: TX 64 + - description: RX 65 + - description: PCS 66 + 67 + clocks: 68 + items: 69 + - description: PIPE clock 70 + 71 + clock-names: 72 + deprecated: true 73 + items: 74 + - enum: 75 + - pipe0 76 + - pipe1 77 + - pipe2 78 + 79 + resets: 80 + items: 81 + - description: PHY reset 82 + 83 + reset-names: 84 + deprecated: true 85 + items: 86 + - enum: 87 + - lane0 88 + - lane1 89 + - lane2 90 + 91 + "#clock-cells": 92 + const: 0 93 + 94 + clock-output-names: 95 + maxItems: 1 96 + 97 + "#phy-cells": 98 + const: 0 99 + 100 + required: 101 + - reg 102 + - clocks 103 + - resets 104 + - "#clock-cells" 105 + - clock-output-names 106 + - "#phy-cells" 107 + 108 + additionalProperties: false 109 + 110 + required: 111 + - compatible 112 + - reg 113 + - "#address-cells" 114 + - "#size-cells" 115 + - ranges 116 + - clocks 117 + - clock-names 118 + - resets 119 + - reset-names 120 + - vdda-phy-supply 121 + - vdda-pll-supply 122 + 123 + additionalProperties: false 124 + 125 + examples: 126 + - | 127 + #include <dt-bindings/clock/qcom,gcc-msm8996.h> 128 + pcie_phy: phy-wrapper@34000 { 129 + compatible = "qcom,msm8996-qmp-pcie-phy"; 130 + reg = <0x34000 0x488>; 131 + #address-cells = <1>; 132 + #size-cells = <1>; 133 + ranges = <0x0 0x34000 0x4000>; 134 + 135 + clocks = <&gcc GCC_PCIE_PHY_AUX_CLK>, 136 + <&gcc GCC_PCIE_PHY_CFG_AHB_CLK>, 137 + <&gcc GCC_PCIE_CLKREF_CLK>; 138 + clock-names = "aux", "cfg_ahb", "ref"; 139 + 140 + resets = <&gcc GCC_PCIE_PHY_BCR>, 141 + <&gcc GCC_PCIE_PHY_COM_BCR>, 142 + <&gcc GCC_PCIE_PHY_COM_NOCSR_BCR>; 143 + reset-names = "phy", "common", "cfg"; 144 + 145 + vdda-phy-supply = <&vreg_l28a_0p925>; 146 + vdda-pll-supply = <&vreg_l12a_1p8>; 147 + 148 + pciephy_0: phy@1000 { 149 + reg = <0x1000 0x130>, 150 + <0x1200 0x200>, 151 + <0x1400 0x1dc>; 152 + 153 + clocks = <&gcc GCC_PCIE_0_PIPE_CLK>; 154 + resets = <&gcc GCC_PCIE_0_PHY_BCR>; 155 + 156 + #clock-cells = <0>; 157 + clock-output-names = "pcie_0_pipe_clk_src"; 158 + 159 + #phy-cells = <0>; 160 + }; 161 + 162 + pciephy_1: phy@2000 { 163 + reg = <0x2000 0x130>, 164 + <0x2200 0x200>, 165 + <0x2400 0x1dc>; 166 + 167 + clocks = <&gcc GCC_PCIE_1_PIPE_CLK>; 168 + resets = <&gcc GCC_PCIE_1_PHY_BCR>; 169 + 170 + #clock-cells = <0>; 171 + clock-output-names = "pcie_1_pipe_clk_src"; 172 + 173 + #phy-cells = <0>; 174 + }; 175 + 176 + pciephy_2: phy@3000 { 177 + reg = <0x3000 0x130>, 178 + <0x3200 0x200>, 179 + <0x3400 0x1dc>; 180 + 181 + clocks = <&gcc GCC_PCIE_2_PIPE_CLK>; 182 + resets = <&gcc GCC_PCIE_2_PHY_BCR>; 183 + 184 + #clock-cells = <0>; 185 + clock-output-names = "pcie_2_pipe_clk_src"; 186 + 187 + #phy-cells = <0>; 188 + }; 189 + };
+296
Documentation/devicetree/bindings/phy/qcom,qmp-pcie-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/qcom,qmp-pcie-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm QMP PHY controller (PCIe) 8 + 9 + maintainers: 10 + - Vinod Koul <vkoul@kernel.org> 11 + 12 + description: 13 + QMP PHY controller supports physical layer functionality for a number of 14 + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - qcom,ipq6018-qmp-pcie-phy 20 + - qcom,ipq8074-qmp-gen3-pcie-phy 21 + - qcom,ipq8074-qmp-pcie-phy 22 + - qcom,msm8998-qmp-pcie-phy 23 + - qcom,sc8180x-qmp-pcie-phy 24 + - qcom,sdm845-qhp-pcie-phy 25 + - qcom,sdm845-qmp-pcie-phy 26 + - qcom,sdx55-qmp-pcie-phy 27 + - qcom,sm8250-qmp-gen3x1-pcie-phy 28 + - qcom,sm8250-qmp-gen3x2-pcie-phy 29 + - qcom,sm8250-qmp-modem-pcie-phy 30 + - qcom,sm8450-qmp-gen3x1-pcie-phy 31 + - qcom,sm8450-qmp-gen4x2-pcie-phy 32 + 33 + reg: 34 + items: 35 + - description: serdes 36 + 37 + "#address-cells": 38 + enum: [ 1, 2 ] 39 + 40 + "#size-cells": 41 + enum: [ 1, 2 ] 42 + 43 + ranges: true 44 + 45 + clocks: 46 + minItems: 2 47 + maxItems: 4 48 + 49 + clock-names: 50 + minItems: 2 51 + maxItems: 4 52 + 53 + resets: 54 + minItems: 1 55 + maxItems: 2 56 + 57 + reset-names: 58 + minItems: 1 59 + maxItems: 2 60 + 61 + vdda-phy-supply: true 62 + 63 + vdda-pll-supply: true 64 + 65 + vddp-ref-clk-supply: true 66 + 67 + patternProperties: 68 + "^phy@[0-9a-f]+$": 69 + type: object 70 + description: single PHY-provider child node 71 + properties: 72 + reg: 73 + minItems: 3 74 + maxItems: 6 75 + 76 + clocks: 77 + items: 78 + - description: PIPE clock 79 + 80 + clock-names: 81 + deprecated: true 82 + items: 83 + - const: pipe0 84 + 85 + "#clock-cells": 86 + const: 0 87 + 88 + clock-output-names: 89 + maxItems: 1 90 + 91 + "#phy-cells": 92 + const: 0 93 + 94 + required: 95 + - reg 96 + - clocks 97 + - "#clock-cells" 98 + - clock-output-names 99 + - "#phy-cells" 100 + 101 + additionalProperties: false 102 + 103 + required: 104 + - compatible 105 + - reg 106 + - "#address-cells" 107 + - "#size-cells" 108 + - ranges 109 + - clocks 110 + - clock-names 111 + - resets 112 + - reset-names 113 + 114 + additionalProperties: false 115 + 116 + allOf: 117 + - if: 118 + properties: 119 + compatible: 120 + contains: 121 + enum: 122 + - qcom,msm8998-qmp-pcie-phy 123 + then: 124 + properties: 125 + clocks: 126 + maxItems: 3 127 + clock-names: 128 + items: 129 + - const: aux 130 + - const: cfg_ahb 131 + - const: ref 132 + resets: 133 + maxItems: 2 134 + reset-names: 135 + items: 136 + - const: phy 137 + - const: common 138 + required: 139 + - vdda-phy-supply 140 + - vdda-pll-supply 141 + 142 + - if: 143 + properties: 144 + compatible: 145 + contains: 146 + enum: 147 + - qcom,ipq6018-qmp-pcie-phy 148 + - qcom,ipq8074-qmp-gen3-pcie-phy 149 + - qcom,ipq8074-qmp-pcie-phy 150 + then: 151 + properties: 152 + clocks: 153 + maxItems: 2 154 + clock-names: 155 + items: 156 + - const: aux 157 + - const: cfg_ahb 158 + resets: 159 + maxItems: 2 160 + reset-names: 161 + items: 162 + - const: phy 163 + - const: common 164 + 165 + - if: 166 + properties: 167 + compatible: 168 + contains: 169 + enum: 170 + - qcom,sc8180x-qmp-pcie-phy 171 + - qcom,sdm845-qhp-pcie-phy 172 + - qcom,sdm845-qmp-pcie-phy 173 + - qcom,sdx55-qmp-pcie-phy 174 + - qcom,sm8250-qmp-gen3x1-pcie-phy 175 + - qcom,sm8250-qmp-gen3x2-pcie-phy 176 + - qcom,sm8250-qmp-modem-pcie-phy 177 + - qcom,sm8450-qmp-gen3x1-pcie-phy 178 + - qcom,sm8450-qmp-gen4x2-pcie-phy 179 + then: 180 + properties: 181 + clocks: 182 + maxItems: 4 183 + clock-names: 184 + items: 185 + - const: aux 186 + - const: cfg_ahb 187 + - const: ref 188 + - const: refgen 189 + resets: 190 + maxItems: 1 191 + reset-names: 192 + items: 193 + - const: phy 194 + required: 195 + - vdda-phy-supply 196 + - vdda-pll-supply 197 + 198 + - if: 199 + properties: 200 + compatible: 201 + contains: 202 + enum: 203 + - qcom,sm8250-qmp-gen3x2-pcie-phy 204 + - qcom,sm8250-qmp-modem-pcie-phy 205 + - qcom,sm8450-qmp-gen4x2-pcie-phy 206 + then: 207 + patternProperties: 208 + "^phy@[0-9a-f]+$": 209 + properties: 210 + reg: 211 + items: 212 + - description: TX lane 1 213 + - description: RX lane 1 214 + - description: PCS 215 + - description: TX lane 2 216 + - description: RX lane 2 217 + - description: PCS_MISC 218 + 219 + - if: 220 + properties: 221 + compatible: 222 + contains: 223 + enum: 224 + - qcom,sc8180x-qmp-pcie-phy 225 + - qcom,sdm845-qmp-pcie-phy 226 + - qcom,sdx55-qmp-pcie-phy 227 + - qcom,sm8250-qmp-gen3x1-pcie-phy 228 + - qcom,sm8450-qmp-gen3x1-pcie-phy 229 + then: 230 + patternProperties: 231 + "^phy@[0-9a-f]+$": 232 + properties: 233 + reg: 234 + items: 235 + - description: TX 236 + - description: RX 237 + - description: PCS 238 + - description: PCS_MISC 239 + 240 + - if: 241 + properties: 242 + compatible: 243 + contains: 244 + enum: 245 + - qcom,ipq6018-qmp-pcie-phy 246 + - qcom,ipq8074-qmp-pcie-phy 247 + - qcom,msm8998-qmp-pcie-phy 248 + - qcom,sdm845-qhp-pcie-phy 249 + then: 250 + patternProperties: 251 + "^phy@[0-9a-f]+$": 252 + properties: 253 + reg: 254 + items: 255 + - description: TX 256 + - description: RX 257 + - description: PCS 258 + 259 + examples: 260 + - | 261 + #include <dt-bindings/clock/qcom,gcc-sm8250.h> 262 + phy-wrapper@1c0e000 { 263 + compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy"; 264 + reg = <0x01c0e000 0x1c0>; 265 + #address-cells = <1>; 266 + #size-cells = <1>; 267 + ranges = <0x0 0x01c0e000 0x1000>; 268 + 269 + clocks = <&gcc GCC_PCIE_PHY_AUX_CLK>, 270 + <&gcc GCC_PCIE_1_CFG_AHB_CLK>, 271 + <&gcc GCC_PCIE_WIGIG_CLKREF_EN>, 272 + <&gcc GCC_PCIE1_PHY_REFGEN_CLK>; 273 + clock-names = "aux", "cfg_ahb", "ref", "refgen"; 274 + 275 + resets = <&gcc GCC_PCIE_1_PHY_BCR>; 276 + reset-names = "phy"; 277 + 278 + vdda-phy-supply = <&vreg_l10c_0p88>; 279 + vdda-pll-supply = <&vreg_l6b_1p2>; 280 + 281 + phy@200 { 282 + reg = <0x200 0x170>, 283 + <0x400 0x200>, 284 + <0xa00 0x1f0>, 285 + <0x600 0x170>, 286 + <0x800 0x200>, 287 + <0xe00 0xf4>; 288 + 289 + clocks = <&gcc GCC_PCIE_1_PIPE_CLK>; 290 + 291 + #clock-cells = <0>; 292 + clock-output-names = "pcie_1_pipe_clk"; 293 + 294 + #phy-cells = <0>; 295 + }; 296 + };
-502
Documentation/devicetree/bindings/phy/qcom,qmp-phy.yaml
··· 1 - # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 - 3 - %YAML 1.2 4 - --- 5 - $id: "http://devicetree.org/schemas/phy/qcom,qmp-phy.yaml#" 6 - $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 - 8 - title: Qualcomm QMP PHY controller 9 - 10 - maintainers: 11 - - Vinod Koul <vkoul@kernel.org> 12 - 13 - description: 14 - QMP phy controller supports physical layer functionality for a number of 15 - controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. 16 - 17 - properties: 18 - compatible: 19 - enum: 20 - - qcom,ipq6018-qmp-pcie-phy 21 - - qcom,ipq6018-qmp-usb3-phy 22 - - qcom,ipq8074-qmp-gen3-pcie-phy 23 - - qcom,ipq8074-qmp-pcie-phy 24 - - qcom,ipq8074-qmp-usb3-phy 25 - - qcom,msm8996-qmp-pcie-phy 26 - - qcom,msm8996-qmp-ufs-phy 27 - - qcom,msm8996-qmp-usb3-phy 28 - - qcom,msm8998-qmp-pcie-phy 29 - - qcom,msm8998-qmp-ufs-phy 30 - - qcom,msm8998-qmp-usb3-phy 31 - - qcom,qcm2290-qmp-usb3-phy 32 - - qcom,sc7180-qmp-usb3-phy 33 - - qcom,sc8180x-qmp-pcie-phy 34 - - qcom,sc8180x-qmp-ufs-phy 35 - - qcom,sc8180x-qmp-usb3-phy 36 - - qcom,sc8280xp-qmp-ufs-phy 37 - - qcom,sdm845-qhp-pcie-phy 38 - - qcom,sdm845-qmp-pcie-phy 39 - - qcom,sdm845-qmp-ufs-phy 40 - - qcom,sdm845-qmp-usb3-phy 41 - - qcom,sdm845-qmp-usb3-uni-phy 42 - - qcom,sm6115-qmp-ufs-phy 43 - - qcom,sm6350-qmp-ufs-phy 44 - - qcom,sm8150-qmp-ufs-phy 45 - - qcom,sm8150-qmp-usb3-phy 46 - - qcom,sm8150-qmp-usb3-uni-phy 47 - - qcom,sm8250-qmp-ufs-phy 48 - - qcom,sm8250-qmp-gen3x1-pcie-phy 49 - - qcom,sm8250-qmp-gen3x2-pcie-phy 50 - - qcom,sm8250-qmp-modem-pcie-phy 51 - - qcom,sm8250-qmp-usb3-phy 52 - - qcom,sm8250-qmp-usb3-uni-phy 53 - - qcom,sm8350-qmp-ufs-phy 54 - - qcom,sm8350-qmp-usb3-phy 55 - - qcom,sm8350-qmp-usb3-uni-phy 56 - - qcom,sm8450-qmp-gen3x1-pcie-phy 57 - - qcom,sm8450-qmp-gen4x2-pcie-phy 58 - - qcom,sm8450-qmp-ufs-phy 59 - - qcom,sm8450-qmp-usb3-phy 60 - - qcom,sdx55-qmp-pcie-phy 61 - - qcom,sdx55-qmp-usb3-uni-phy 62 - - qcom,sdx65-qmp-usb3-uni-phy 63 - 64 - reg: 65 - minItems: 1 66 - items: 67 - - description: Address and length of PHY's common serdes block. 68 - - description: Address and length of PHY's DP_COM control block. 69 - 70 - "#clock-cells": 71 - enum: [ 1, 2 ] 72 - 73 - "#address-cells": 74 - enum: [ 1, 2 ] 75 - 76 - "#size-cells": 77 - enum: [ 1, 2 ] 78 - 79 - ranges: true 80 - 81 - clocks: 82 - minItems: 1 83 - maxItems: 4 84 - 85 - clock-names: 86 - minItems: 1 87 - maxItems: 4 88 - 89 - resets: 90 - minItems: 1 91 - maxItems: 3 92 - 93 - reset-names: 94 - minItems: 1 95 - maxItems: 3 96 - 97 - vdda-phy-supply: 98 - description: 99 - Phandle to a regulator supply to PHY core block. 100 - 101 - vdda-pll-supply: 102 - description: 103 - Phandle to 1.8V regulator supply to PHY refclk pll block. 104 - 105 - vddp-ref-clk-supply: 106 - description: 107 - Phandle to a regulator supply to any specific refclk pll block. 108 - 109 - #Required nodes: 110 - patternProperties: 111 - "^phy@[0-9a-f]+$": 112 - type: object 113 - description: 114 - Each device node of QMP phy is required to have as many child nodes as 115 - the number of lanes the PHY has. 116 - 117 - required: 118 - - compatible 119 - - reg 120 - - "#clock-cells" 121 - - "#address-cells" 122 - - "#size-cells" 123 - - ranges 124 - - clocks 125 - - clock-names 126 - - resets 127 - - reset-names 128 - 129 - additionalProperties: false 130 - 131 - allOf: 132 - - if: 133 - properties: 134 - compatible: 135 - contains: 136 - enum: 137 - - qcom,sdm845-qmp-usb3-uni-phy 138 - then: 139 - properties: 140 - clocks: 141 - items: 142 - - description: Phy aux clock. 143 - - description: Phy config clock. 144 - - description: 19.2 MHz ref clk. 145 - - description: Phy common block aux clock. 146 - clock-names: 147 - items: 148 - - const: aux 149 - - const: cfg_ahb 150 - - const: ref 151 - - const: com_aux 152 - resets: 153 - items: 154 - - description: reset of phy block. 155 - - description: phy common block reset. 156 - reset-names: 157 - items: 158 - - const: phy 159 - - const: common 160 - required: 161 - - vdda-phy-supply 162 - - vdda-pll-supply 163 - - if: 164 - properties: 165 - compatible: 166 - contains: 167 - enum: 168 - - qcom,sdx55-qmp-usb3-uni-phy 169 - - qcom,sdx65-qmp-usb3-uni-phy 170 - then: 171 - properties: 172 - clocks: 173 - items: 174 - - description: Phy aux clock. 175 - - description: Phy config clock. 176 - - description: 19.2 MHz ref clk. 177 - clock-names: 178 - items: 179 - - const: aux 180 - - const: cfg_ahb 181 - - const: ref 182 - resets: 183 - items: 184 - - description: reset of phy block. 185 - - description: phy common block reset. 186 - reset-names: 187 - items: 188 - - const: phy 189 - - const: common 190 - required: 191 - - vdda-phy-supply 192 - - vdda-pll-supply 193 - - if: 194 - properties: 195 - compatible: 196 - contains: 197 - enum: 198 - - qcom,msm8996-qmp-pcie-phy 199 - then: 200 - properties: 201 - clocks: 202 - items: 203 - - description: Phy aux clock. 204 - - description: Phy config clock. 205 - - description: 19.2 MHz ref clk. 206 - clock-names: 207 - items: 208 - - const: aux 209 - - const: cfg_ahb 210 - - const: ref 211 - resets: 212 - items: 213 - - description: reset of phy block. 214 - - description: phy common block reset. 215 - - description: phy's ahb cfg block reset. 216 - reset-names: 217 - items: 218 - - const: phy 219 - - const: common 220 - - const: cfg 221 - required: 222 - - vdda-phy-supply 223 - - vdda-pll-supply 224 - - if: 225 - properties: 226 - compatible: 227 - contains: 228 - enum: 229 - - qcom,ipq8074-qmp-usb3-phy 230 - - qcom,msm8996-qmp-usb3-phy 231 - - qcom,msm8998-qmp-pcie-phy 232 - - qcom,msm8998-qmp-usb3-phy 233 - then: 234 - properties: 235 - clocks: 236 - items: 237 - - description: Phy aux clock. 238 - - description: Phy config clock. 239 - - description: 19.2 MHz ref clk. 240 - clock-names: 241 - items: 242 - - const: aux 243 - - const: cfg_ahb 244 - - const: ref 245 - resets: 246 - items: 247 - - description: reset of phy block. 248 - - description: phy common block reset. 249 - reset-names: 250 - items: 251 - - const: phy 252 - - const: common 253 - required: 254 - - vdda-phy-supply 255 - - vdda-pll-supply 256 - - if: 257 - properties: 258 - compatible: 259 - contains: 260 - enum: 261 - - qcom,msm8996-qmp-ufs-phy 262 - then: 263 - properties: 264 - clocks: 265 - items: 266 - - description: 19.2 MHz ref clk. 267 - clock-names: 268 - items: 269 - - const: ref 270 - resets: 271 - items: 272 - - description: PHY reset in the UFS controller. 273 - reset-names: 274 - items: 275 - - const: ufsphy 276 - required: 277 - - vdda-phy-supply 278 - - vdda-pll-supply 279 - - if: 280 - properties: 281 - compatible: 282 - contains: 283 - enum: 284 - - qcom,msm8998-qmp-ufs-phy 285 - - qcom,sdm845-qmp-ufs-phy 286 - - qcom,sm6350-qmp-ufs-phy 287 - - qcom,sm8150-qmp-ufs-phy 288 - - qcom,sm8250-qmp-ufs-phy 289 - - qcom,sc8180x-qmp-ufs-phy 290 - - qcom,sc8280xp-qmp-ufs-phy 291 - then: 292 - properties: 293 - clocks: 294 - items: 295 - - description: 19.2 MHz ref clk. 296 - - description: Phy reference aux clock. 297 - clock-names: 298 - items: 299 - - const: ref 300 - - const: ref_aux 301 - resets: 302 - items: 303 - - description: PHY reset in the UFS controller. 304 - reset-names: 305 - items: 306 - - const: ufsphy 307 - required: 308 - - vdda-phy-supply 309 - - vdda-pll-supply 310 - - if: 311 - properties: 312 - compatible: 313 - contains: 314 - enum: 315 - - qcom,ipq6018-qmp-pcie-phy 316 - - qcom,ipq8074-qmp-gen3-pcie-phy 317 - - qcom,ipq8074-qmp-pcie-phy 318 - then: 319 - properties: 320 - clocks: 321 - items: 322 - - description: Phy aux clock. 323 - - description: Phy config clock. 324 - clock-names: 325 - items: 326 - - const: aux 327 - - const: cfg_ahb 328 - resets: 329 - items: 330 - - description: reset of phy block. 331 - - description: phy common block reset. 332 - reset-names: 333 - items: 334 - - const: phy 335 - - const: common 336 - - if: 337 - properties: 338 - compatible: 339 - contains: 340 - enum: 341 - - qcom,sc8180x-qmp-pcie-phy 342 - - qcom,sdm845-qhp-pcie-phy 343 - - qcom,sdm845-qmp-pcie-phy 344 - - qcom,sdx55-qmp-pcie-phy 345 - - qcom,sm8250-qmp-gen3x1-pcie-phy 346 - - qcom,sm8250-qmp-gen3x2-pcie-phy 347 - - qcom,sm8250-qmp-modem-pcie-phy 348 - - qcom,sm8450-qmp-gen3x1-pcie-phy 349 - - qcom,sm8450-qmp-gen4x2-pcie-phy 350 - then: 351 - properties: 352 - clocks: 353 - items: 354 - - description: Phy aux clock. 355 - - description: Phy config clock. 356 - - description: 19.2 MHz ref clk. 357 - - description: Phy refgen clk. 358 - clock-names: 359 - items: 360 - - const: aux 361 - - const: cfg_ahb 362 - - const: ref 363 - - const: refgen 364 - resets: 365 - items: 366 - - description: reset of phy block. 367 - reset-names: 368 - items: 369 - - const: phy 370 - required: 371 - - vdda-phy-supply 372 - - vdda-pll-supply 373 - - if: 374 - properties: 375 - compatible: 376 - contains: 377 - enum: 378 - - qcom,sm8150-qmp-usb3-phy 379 - - qcom,sm8150-qmp-usb3-uni-phy 380 - - qcom,sm8250-qmp-usb3-uni-phy 381 - - qcom,sm8350-qmp-usb3-uni-phy 382 - then: 383 - properties: 384 - clocks: 385 - items: 386 - - description: Phy aux clock. 387 - - description: 19.2 MHz ref clk source. 388 - - description: 19.2 MHz ref clk. 389 - - description: Phy common block aux clock. 390 - clock-names: 391 - items: 392 - - const: aux 393 - - const: ref_clk_src 394 - - const: ref 395 - - const: com_aux 396 - resets: 397 - items: 398 - - description: reset of phy block. 399 - - description: phy common block reset. 400 - reset-names: 401 - items: 402 - - const: phy 403 - - const: common 404 - required: 405 - - vdda-phy-supply 406 - - vdda-pll-supply 407 - - if: 408 - properties: 409 - compatible: 410 - contains: 411 - enum: 412 - - qcom,sm8250-qmp-usb3-phy 413 - - qcom,sm8350-qmp-usb3-phy 414 - then: 415 - properties: 416 - clocks: 417 - items: 418 - - description: Phy aux clock. 419 - - description: 19.2 MHz ref clk. 420 - - description: Phy common block aux clock. 421 - clock-names: 422 - items: 423 - - const: aux 424 - - const: ref_clk_src 425 - - const: com_aux 426 - resets: 427 - items: 428 - - description: reset of phy block. 429 - - description: phy common block reset. 430 - reset-names: 431 - items: 432 - - const: phy 433 - - const: common 434 - required: 435 - - vdda-phy-supply 436 - - vdda-pll-supply 437 - - if: 438 - properties: 439 - compatible: 440 - contains: 441 - enum: 442 - - qcom,qcm2290-qmp-usb3-phy 443 - then: 444 - properties: 445 - clocks: 446 - items: 447 - - description: Phy config clock. 448 - - description: 19.2 MHz ref clk. 449 - - description: Phy common block aux clock. 450 - clock-names: 451 - items: 452 - - const: cfg_ahb 453 - - const: ref 454 - - const: com_aux 455 - resets: 456 - items: 457 - - description: phy_phy reset. 458 - - description: reset of phy block. 459 - reset-names: 460 - items: 461 - - const: phy_phy 462 - - const: phy 463 - required: 464 - - vdda-phy-supply 465 - - vdda-pll-supply 466 - 467 - examples: 468 - - | 469 - #include <dt-bindings/clock/qcom,gcc-sdm845.h> 470 - usb_2_qmpphy: phy-wrapper@88eb000 { 471 - compatible = "qcom,sdm845-qmp-usb3-uni-phy"; 472 - reg = <0x088eb000 0x18c>; 473 - #clock-cells = <1>; 474 - #address-cells = <1>; 475 - #size-cells = <1>; 476 - ranges = <0x0 0x088eb000 0x2000>; 477 - 478 - clocks = <&gcc GCC_USB3_SEC_PHY_AUX_CLK >, 479 - <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>, 480 - <&gcc GCC_USB3_SEC_CLKREF_CLK>, 481 - <&gcc GCC_USB3_SEC_PHY_COM_AUX_CLK>; 482 - clock-names = "aux", "cfg_ahb", "ref", "com_aux"; 483 - 484 - resets = <&gcc GCC_USB3PHY_PHY_SEC_BCR>, 485 - <&gcc GCC_USB3_PHY_SEC_BCR>; 486 - reset-names = "phy", "common"; 487 - 488 - vdda-phy-supply = <&vdda_usb2_ss_1p2>; 489 - vdda-pll-supply = <&vdda_usb2_ss_core>; 490 - 491 - usb_2_ssphy: phy@200 { 492 - reg = <0x200 0x128>, 493 - <0x400 0x1fc>, 494 - <0x800 0x218>, 495 - <0x600 0x70>; 496 - #clock-cells = <0>; 497 - #phy-cells = <0>; 498 - clocks = <&gcc GCC_USB3_SEC_PHY_PIPE_CLK>; 499 - clock-names = "pipe0"; 500 - clock-output-names = "usb3_uni_phy_pipe_clk_src"; 501 - }; 502 - };
+240
Documentation/devicetree/bindings/phy/qcom,qmp-ufs-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/qcom,qmp-ufs-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm QMP PHY controller (UFS) 8 + 9 + maintainers: 10 + - Vinod Koul <vkoul@kernel.org> 11 + 12 + description: 13 + QMP PHY controller supports physical layer functionality for a number of 14 + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - qcom,msm8996-qmp-ufs-phy 20 + - qcom,msm8998-qmp-ufs-phy 21 + - qcom,sc8180x-qmp-ufs-phy 22 + - qcom,sc8280xp-qmp-ufs-phy 23 + - qcom,sdm845-qmp-ufs-phy 24 + - qcom,sm6115-qmp-ufs-phy 25 + - qcom,sm6350-qmp-ufs-phy 26 + - qcom,sm8150-qmp-ufs-phy 27 + - qcom,sm8250-qmp-ufs-phy 28 + - qcom,sm8350-qmp-ufs-phy 29 + - qcom,sm8450-qmp-ufs-phy 30 + 31 + reg: 32 + items: 33 + - description: serdes 34 + 35 + "#address-cells": 36 + enum: [ 1, 2 ] 37 + 38 + "#size-cells": 39 + enum: [ 1, 2 ] 40 + 41 + ranges: true 42 + 43 + clocks: 44 + minItems: 1 45 + maxItems: 3 46 + 47 + clock-names: 48 + minItems: 1 49 + maxItems: 3 50 + 51 + power-domains: 52 + maxItems: 1 53 + 54 + resets: 55 + maxItems: 1 56 + 57 + reset-names: 58 + items: 59 + - const: ufsphy 60 + 61 + vdda-phy-supply: true 62 + 63 + vdda-pll-supply: true 64 + 65 + vddp-ref-clk-supply: true 66 + 67 + patternProperties: 68 + "^phy@[0-9a-f]+$": 69 + type: object 70 + description: single PHY-provider child node 71 + properties: 72 + reg: 73 + minItems: 3 74 + maxItems: 6 75 + 76 + "#phy-cells": 77 + const: 0 78 + 79 + required: 80 + - reg 81 + - "#phy-cells" 82 + 83 + additionalProperties: false 84 + 85 + required: 86 + - compatible 87 + - reg 88 + - "#address-cells" 89 + - "#size-cells" 90 + - ranges 91 + - clocks 92 + - clock-names 93 + - resets 94 + - reset-names 95 + - vdda-phy-supply 96 + - vdda-pll-supply 97 + 98 + additionalProperties: false 99 + 100 + allOf: 101 + - if: 102 + properties: 103 + compatible: 104 + contains: 105 + enum: 106 + - qcom,msm8996-qmp-ufs-phy 107 + then: 108 + properties: 109 + clocks: 110 + maxItems: 1 111 + clock-names: 112 + items: 113 + - const: ref 114 + 115 + - if: 116 + properties: 117 + compatible: 118 + contains: 119 + enum: 120 + - qcom,msm8998-qmp-ufs-phy 121 + - qcom,sc8180x-qmp-ufs-phy 122 + - qcom,sc8280xp-qmp-ufs-phy 123 + - qcom,sdm845-qmp-ufs-phy 124 + - qcom,sm6115-qmp-ufs-phy 125 + - qcom,sm6350-qmp-ufs-phy 126 + - qcom,sm8150-qmp-ufs-phy 127 + - qcom,sm8250-qmp-ufs-phy 128 + then: 129 + properties: 130 + clocks: 131 + maxItems: 2 132 + clock-names: 133 + items: 134 + - const: ref 135 + - const: ref_aux 136 + 137 + - if: 138 + properties: 139 + compatible: 140 + contains: 141 + enum: 142 + - qcom,sm8450-qmp-ufs-phy 143 + then: 144 + properties: 145 + clocks: 146 + maxItems: 3 147 + clock-names: 148 + items: 149 + - const: ref 150 + - const: ref_aux 151 + - const: qref 152 + 153 + - if: 154 + properties: 155 + compatible: 156 + contains: 157 + enum: 158 + - qcom,msm8998-qmp-ufs-phy 159 + - qcom,sc8280xp-qmp-ufs-phy 160 + - qcom,sdm845-qmp-ufs-phy 161 + - qcom,sm6350-qmp-ufs-phy 162 + - qcom,sm8150-qmp-ufs-phy 163 + - qcom,sm8250-qmp-ufs-phy 164 + - qcom,sm8350-qmp-ufs-phy 165 + - qcom,sm8450-qmp-ufs-phy 166 + then: 167 + patternProperties: 168 + "^phy@[0-9a-f]+$": 169 + properties: 170 + reg: 171 + items: 172 + - description: TX lane 1 173 + - description: RX lane 1 174 + - description: PCS 175 + - description: TX lane 2 176 + - description: RX lane 2 177 + 178 + - if: 179 + properties: 180 + compatible: 181 + contains: 182 + enum: 183 + - qcom,sc8180x-qmp-ufs-phy 184 + then: 185 + patternProperties: 186 + "^phy@[0-9a-f]+$": 187 + properties: 188 + reg: 189 + items: 190 + - description: TX 191 + - description: RX 192 + - description: PCS 193 + - description: PCS_MISC 194 + 195 + - if: 196 + properties: 197 + compatible: 198 + contains: 199 + enum: 200 + - qcom,msm8996-qmp-ufs-phy 201 + - qcom,sm6115-qmp-ufs-phy 202 + then: 203 + patternProperties: 204 + "^phy@[0-9a-f]+$": 205 + properties: 206 + reg: 207 + items: 208 + - description: TX 209 + - description: RX 210 + - description: PCS 211 + 212 + examples: 213 + - | 214 + #include <dt-bindings/clock/qcom,gcc-sc8280xp.h> 215 + #include <dt-bindings/clock/qcom,rpmh.h> 216 + phy-wrapper@1d87000 { 217 + compatible = "qcom,sc8280xp-qmp-ufs-phy"; 218 + reg = <0x01d87000 0xe10>; 219 + #address-cells = <1>; 220 + #size-cells = <1>; 221 + ranges = <0x0 0x01d87000 0x1000>; 222 + 223 + clocks = <&rpmhcc RPMH_CXO_CLK>, <&gcc GCC_UFS_PHY_PHY_AUX_CLK>; 224 + clock-names = "ref", "ref_aux"; 225 + 226 + resets = <&ufs_mem_hc 0>; 227 + reset-names = "ufsphy"; 228 + 229 + vdda-phy-supply = <&vreg_l6b>; 230 + vdda-pll-supply = <&vreg_l3b>; 231 + 232 + phy@400 { 233 + reg = <0x400 0x108>, 234 + <0x600 0x1e0>, 235 + <0xc00 0x1dc>, 236 + <0x800 0x108>, 237 + <0xa00 0x1e0>; 238 + #phy-cells = <0>; 239 + }; 240 + };
+401
Documentation/devicetree/bindings/phy/qcom,qmp-usb-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/qcom,qmp-usb-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Qualcomm QMP PHY controller (USB) 8 + 9 + maintainers: 10 + - Vinod Koul <vkoul@kernel.org> 11 + 12 + description: 13 + QMP PHY controller supports physical layer functionality for a number of 14 + controllers on Qualcomm chipsets, such as, PCIe, UFS, and USB. 15 + 16 + properties: 17 + compatible: 18 + enum: 19 + - qcom,ipq6018-qmp-usb3-phy 20 + - qcom,ipq8074-qmp-usb3-phy 21 + - qcom,msm8996-qmp-usb3-phy 22 + - qcom,msm8998-qmp-usb3-phy 23 + - qcom,qcm2290-qmp-usb3-phy 24 + - qcom,sc7180-qmp-usb3-phy 25 + - qcom,sc8180x-qmp-usb3-phy 26 + - qcom,sc8280xp-qmp-usb3-uni-phy 27 + - qcom,sdm845-qmp-usb3-phy 28 + - qcom,sdm845-qmp-usb3-uni-phy 29 + - qcom,sdx55-qmp-usb3-uni-phy 30 + - qcom,sdx65-qmp-usb3-uni-phy 31 + - qcom,sm8150-qmp-usb3-phy 32 + - qcom,sm8150-qmp-usb3-uni-phy 33 + - qcom,sm8250-qmp-usb3-phy 34 + - qcom,sm8250-qmp-usb3-uni-phy 35 + - qcom,sm8350-qmp-usb3-phy 36 + - qcom,sm8350-qmp-usb3-uni-phy 37 + - qcom,sm8450-qmp-usb3-phy 38 + 39 + reg: 40 + minItems: 1 41 + items: 42 + - description: serdes 43 + - description: DP_COM 44 + 45 + "#address-cells": 46 + enum: [ 1, 2 ] 47 + 48 + "#size-cells": 49 + enum: [ 1, 2 ] 50 + 51 + ranges: true 52 + 53 + clocks: 54 + minItems: 3 55 + maxItems: 4 56 + 57 + clock-names: 58 + minItems: 3 59 + maxItems: 4 60 + 61 + power-domains: 62 + maxItems: 1 63 + 64 + resets: 65 + maxItems: 2 66 + 67 + reset-names: 68 + maxItems: 2 69 + 70 + vdda-phy-supply: true 71 + 72 + vdda-pll-supply: true 73 + 74 + vddp-ref-clk-supply: true 75 + 76 + patternProperties: 77 + "^phy@[0-9a-f]+$": 78 + type: object 79 + description: single PHY-provider child node 80 + properties: 81 + reg: 82 + minItems: 3 83 + maxItems: 6 84 + 85 + clocks: 86 + items: 87 + - description: PIPE clock 88 + 89 + clock-names: 90 + deprecated: true 91 + items: 92 + - const: pipe0 93 + 94 + "#clock-cells": 95 + const: 0 96 + 97 + clock-output-names: 98 + maxItems: 1 99 + 100 + "#phy-cells": 101 + const: 0 102 + 103 + required: 104 + - reg 105 + - clocks 106 + - "#clock-cells" 107 + - clock-output-names 108 + - "#phy-cells" 109 + 110 + additionalProperties: false 111 + 112 + required: 113 + - compatible 114 + - reg 115 + - "#address-cells" 116 + - "#size-cells" 117 + - ranges 118 + - clocks 119 + - clock-names 120 + - resets 121 + - reset-names 122 + - vdda-phy-supply 123 + - vdda-pll-supply 124 + 125 + additionalProperties: false 126 + 127 + allOf: 128 + - if: 129 + properties: 130 + compatible: 131 + contains: 132 + enum: 133 + - qcom,sc7180-qmp-usb3-phy 134 + then: 135 + properties: 136 + clocks: 137 + maxItems: 4 138 + clock-names: 139 + items: 140 + - const: aux 141 + - const: cfg_ahb 142 + - const: ref 143 + - const: com_aux 144 + resets: 145 + maxItems: 1 146 + reset-names: 147 + items: 148 + - const: phy 149 + 150 + - if: 151 + properties: 152 + compatible: 153 + contains: 154 + enum: 155 + - qcom,sdm845-qmp-usb3-uni-phy 156 + then: 157 + properties: 158 + clocks: 159 + maxItems: 4 160 + clock-names: 161 + items: 162 + - const: aux 163 + - const: cfg_ahb 164 + - const: ref 165 + - const: com_aux 166 + resets: 167 + maxItems: 2 168 + reset-names: 169 + items: 170 + - const: phy 171 + - const: common 172 + 173 + - if: 174 + properties: 175 + compatible: 176 + contains: 177 + enum: 178 + - qcom,ipq8074-qmp-usb3-phy 179 + - qcom,msm8996-qmp-usb3-phy 180 + - qcom,msm8998-qmp-usb3-phy 181 + - qcom,sdx55-qmp-usb3-uni-phy 182 + - qcom,sdx65-qmp-usb3-uni-phy 183 + then: 184 + properties: 185 + clocks: 186 + maxItems: 3 187 + clock-names: 188 + items: 189 + - const: aux 190 + - const: cfg_ahb 191 + - const: ref 192 + resets: 193 + maxItems: 2 194 + reset-names: 195 + items: 196 + - const: phy 197 + - const: common 198 + 199 + - if: 200 + properties: 201 + compatible: 202 + contains: 203 + enum: 204 + - qcom,sc8280xp-qmp-usb3-uni-phy 205 + - qcom,sm8150-qmp-usb3-phy 206 + - qcom,sm8150-qmp-usb3-uni-phy 207 + - qcom,sm8250-qmp-usb3-uni-phy 208 + - qcom,sm8350-qmp-usb3-uni-phy 209 + then: 210 + properties: 211 + clocks: 212 + maxItems: 4 213 + clock-names: 214 + items: 215 + - const: aux 216 + - const: ref_clk_src 217 + - const: ref 218 + - const: com_aux 219 + resets: 220 + maxItems: 2 221 + reset-names: 222 + items: 223 + - const: phy 224 + - const: common 225 + 226 + - if: 227 + properties: 228 + compatible: 229 + contains: 230 + enum: 231 + - qcom,sm8250-qmp-usb3-phy 232 + - qcom,sm8350-qmp-usb3-phy 233 + then: 234 + properties: 235 + clocks: 236 + maxItems: 3 237 + clock-names: 238 + items: 239 + - const: aux 240 + - const: ref_clk_src 241 + - const: com_aux 242 + resets: 243 + maxItems: 2 244 + reset-names: 245 + items: 246 + - const: phy 247 + - const: common 248 + 249 + - if: 250 + properties: 251 + compatible: 252 + contains: 253 + enum: 254 + - qcom,qcm2290-qmp-usb3-phy 255 + then: 256 + properties: 257 + clocks: 258 + maxItems: 3 259 + clock-names: 260 + items: 261 + - const: cfg_ahb 262 + - const: ref 263 + - const: com_aux 264 + resets: 265 + maxItems: 2 266 + reset-names: 267 + items: 268 + - const: phy_phy 269 + - const: phy 270 + 271 + - if: 272 + properties: 273 + compatible: 274 + contains: 275 + enum: 276 + - qcom,sc8280xp-qmp-usb3-uni-phy 277 + then: 278 + required: 279 + - power-domains 280 + 281 + - if: 282 + properties: 283 + compatible: 284 + contains: 285 + enum: 286 + - qcom,sdm845-qmp-usb3-phy 287 + - qcom,sm8150-qmp-usb3-phy 288 + - qcom,sm8350-qmp-usb3-phy 289 + - qcom,sm8450-qmp-usb3-phy 290 + then: 291 + patternProperties: 292 + "^phy@[0-9a-f]+$": 293 + properties: 294 + reg: 295 + items: 296 + - description: TX lane 1 297 + - description: RX lane 1 298 + - description: PCS 299 + - description: TX lane 2 300 + - description: RX lane 2 301 + - description: PCS_MISC 302 + 303 + - if: 304 + properties: 305 + compatible: 306 + contains: 307 + enum: 308 + - qcom,msm8998-qmp-usb3-phy 309 + then: 310 + patternProperties: 311 + "^phy@[0-9a-f]+$": 312 + properties: 313 + reg: 314 + items: 315 + - description: TX lane 1 316 + - description: RX lane 1 317 + - description: PCS 318 + - description: TX lane 2 319 + - description: RX lane 2 320 + 321 + - if: 322 + properties: 323 + compatible: 324 + contains: 325 + enum: 326 + - qcom,ipq6018-qmp-usb3-phy 327 + - qcom,ipq8074-qmp-usb3-phy 328 + - qcom,qcm2290-qmp-usb3-phy 329 + - qcom,sc7180-qmp-usb3-phy 330 + - qcom,sc8180x-qmp-usb3-phy 331 + - qcom,sdx55-qmp-usb3-uni-phy 332 + - qcom,sdx65-qmp-usb3-uni-phy 333 + - qcom,sm8150-qmp-usb3-uni-phy 334 + - qcom,sm8250-qmp-usb3-phy 335 + then: 336 + patternProperties: 337 + "^phy@[0-9a-f]+$": 338 + properties: 339 + reg: 340 + items: 341 + - description: TX 342 + - description: RX 343 + - description: PCS 344 + - description: PCS_MISC 345 + 346 + - if: 347 + properties: 348 + compatible: 349 + contains: 350 + enum: 351 + - qcom,msm8996-qmp-usb3-phy 352 + - qcom,sc8280xp-qmp-usb3-uni-phy 353 + - qcom,sm8250-qmp-usb3-uni-phy 354 + - qcom,sm8350-qmp-usb3-uni-phy 355 + then: 356 + patternProperties: 357 + "^phy@[0-9a-f]+$": 358 + properties: 359 + reg: 360 + items: 361 + - description: TX 362 + - description: RX 363 + - description: PCS 364 + 365 + examples: 366 + - | 367 + #include <dt-bindings/clock/qcom,gcc-sdm845.h> 368 + usb_2_qmpphy: phy-wrapper@88eb000 { 369 + compatible = "qcom,sdm845-qmp-usb3-uni-phy"; 370 + reg = <0x088eb000 0x18c>; 371 + #address-cells = <1>; 372 + #size-cells = <1>; 373 + ranges = <0x0 0x088eb000 0x2000>; 374 + 375 + clocks = <&gcc GCC_USB3_SEC_PHY_AUX_CLK >, 376 + <&gcc GCC_USB_PHY_CFG_AHB2PHY_CLK>, 377 + <&gcc GCC_USB3_SEC_CLKREF_CLK>, 378 + <&gcc GCC_USB3_SEC_PHY_COM_AUX_CLK>; 379 + clock-names = "aux", "cfg_ahb", "ref", "com_aux"; 380 + 381 + resets = <&gcc GCC_USB3PHY_PHY_SEC_BCR>, 382 + <&gcc GCC_USB3_PHY_SEC_BCR>; 383 + reset-names = "phy", "common"; 384 + 385 + vdda-phy-supply = <&vdda_usb2_ss_1p2>; 386 + vdda-pll-supply = <&vdda_usb2_ss_core>; 387 + 388 + usb_2_ssphy: phy@200 { 389 + reg = <0x200 0x128>, 390 + <0x400 0x1fc>, 391 + <0x800 0x218>, 392 + <0x600 0x70>; 393 + 394 + clocks = <&gcc GCC_USB3_SEC_PHY_PIPE_CLK>; 395 + 396 + #clock-cells = <0>; 397 + clock-output-names = "usb3_uni_phy_pipe_clk_src"; 398 + 399 + #phy-cells = <0>; 400 + }; 401 + };
+18 -7
Documentation/devicetree/bindings/phy/qcom,qmp-usb3-dp-phy.yaml
··· 16 16 - qcom,sc7180-qmp-usb3-dp-phy 17 17 - qcom,sc7280-qmp-usb3-dp-phy 18 18 - qcom,sc8180x-qmp-usb3-dp-phy 19 + - qcom,sc8280xp-qmp-usb43dp-phy 19 20 - qcom,sdm845-qmp-usb3-dp-phy 20 21 - qcom,sm8250-qmp-usb3-dp-phy 21 22 reg: ··· 30 29 - const: usb 31 30 - const: dp_com 32 31 - const: dp 33 - 34 - "#clock-cells": 35 - enum: [ 1, 2 ] 36 32 37 33 "#address-cells": 38 34 enum: [ 1, 2 ] ··· 52 54 - const: cfg_ahb 53 55 - const: ref 54 56 - const: com_aux 57 + 58 + power-domains: 59 + maxItems: 1 55 60 56 61 resets: 57 62 items: ··· 82 81 patternProperties: 83 82 "^usb3-phy@[0-9a-f]+$": 84 83 type: object 84 + additionalProperties: false 85 85 description: 86 86 The USB3 PHY. 87 87 ··· 101 99 - description: pipe clock 102 100 103 101 clock-names: 102 + deprecated: true 104 103 items: 105 104 - const: pipe0 106 105 ··· 118 115 required: 119 116 - reg 120 117 - clocks 121 - - clock-names 122 118 - '#clock-cells' 123 119 - '#phy-cells' 124 120 125 121 "^dp-phy@[0-9a-f]+$": 126 122 type: object 123 + additionalProperties: false 127 124 description: 128 125 The DP PHY. 129 126 ··· 150 147 required: 151 148 - compatible 152 149 - reg 153 - - "#clock-cells" 154 150 - "#address-cells" 155 151 - "#size-cells" 156 152 - ranges ··· 162 160 163 161 additionalProperties: false 164 162 163 + allOf: 164 + - if: 165 + properties: 166 + compatible: 167 + contains: 168 + enum: 169 + - qcom,sc8280xp-qmp-usb43dp-phy 170 + then: 171 + required: 172 + - power-domains 173 + 165 174 examples: 166 175 - | 167 176 #include <dt-bindings/clock/qcom,gcc-sdm845.h> ··· 182 169 <0x088e8000 0x10>, 183 170 <0x088ea000 0x40>; 184 171 reg-names = "usb", "dp_com", "dp"; 185 - #clock-cells = <1>; 186 172 #address-cells = <1>; 187 173 #size-cells = <1>; 188 174 ranges = <0x0 0x088e9000 0x2000>; ··· 209 197 #clock-cells = <0>; 210 198 #phy-cells = <0>; 211 199 clocks = <&gcc GCC_USB3_PRIM_PHY_PIPE_CLK>; 212 - clock-names = "pipe0"; 213 200 clock-output-names = "usb3_phy_pipe_clk_src"; 214 201 }; 215 202
+1
Documentation/devicetree/bindings/phy/qcom,qusb2-phy.yaml
··· 30 30 - items: 31 31 - enum: 32 32 - qcom,sc7180-qusb2-phy 33 + - qcom,sdm670-qusb2-phy 33 34 - qcom,sdm845-qusb2-phy 34 35 - qcom,sm6350-qusb2-phy 35 36 - const: qcom,qusb2-v2-phy
+89
Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml
··· 20 20 - qcom,sc7280-usb-hs-phy 21 21 - qcom,sc8180x-usb-hs-phy 22 22 - qcom,sc8280xp-usb-hs-phy 23 + - qcom,sm6375-usb-hs-phy 23 24 - qcom,sm8150-usb-hs-phy 24 25 - qcom,sm8250-usb-hs-phy 25 26 - qcom,sm8350-usb-hs-phy ··· 53 52 54 53 vdda33-supply: 55 54 description: phandle to the regulator 3.3V supply node. 55 + 56 + qcom,hs-disconnect-bp: 57 + description: 58 + This adjusts the voltage level for the threshold used to 59 + detect a disconnect event at the host. 60 + The hardware accepts only discrete values. The value closest to the 61 + provided input will be chosen as the override value for this param. 62 + minimum: -272 63 + maximum: 2156 64 + 65 + qcom,squelch-detector-bp: 66 + description: 67 + This adjusts the voltage level for the threshold used to 68 + detect valid high-speed data. 69 + The hardware accepts only discrete values. The value closest to the 70 + provided input will be chosen as the override value for this param. 71 + minimum: -2090 72 + maximum: 1590 73 + 74 + qcom,hs-amplitude-bp: 75 + description: 76 + This adjusts the high-speed DC level voltage. 77 + The hardware accepts only discrete values. The value closest to the 78 + provided input will be chosen as the override value for this param. 79 + minimum: -660 80 + maximum: 2670 81 + 82 + qcom,pre-emphasis-duration-bp: 83 + description: 84 + This signal controls the duration for which the 85 + HS pre-emphasis current is sourced onto DP<#> or DM<#>. 86 + The HS Transmitter pre-emphasis duration is defined in terms of 87 + unit amounts. One unit of pre-emphasis duration is approximately 88 + 650 ps and is defined as 1X pre-emphasis duration. 89 + The hardware accepts only discrete values. The value closest to the 90 + provided input will be chosen as the override value for this param. 91 + minimum: 10000 92 + maximum: 20000 93 + 94 + qcom,pre-emphasis-amplitude-bp: 95 + description: 96 + This signal controls the amount of current sourced to 97 + DP<#> and DM<#> after a J-to-K or K-to-J transition. 98 + The HS Transmitter pre-emphasis current is defined in terms of unit 99 + amounts. One unit amount is approximately 2 mA and is defined as 100 + 1X pre-emphasis current. 101 + The hardware accepts only discrete values. The value closest to the 102 + provided input will be chosen as the override value for this param. 103 + minimum: 10000 104 + maximum: 40000 105 + 106 + qcom,hs-rise-fall-time-bp: 107 + description: 108 + This adjusts the rise/fall times of the high-speed waveform. 109 + The hardware accepts only discrete values. The value closest to the 110 + provided input will be chosen as the override value for this param. 111 + minimum: -4100 112 + maximum: 5430 113 + 114 + qcom,hs-crossover-voltage-microvolt: 115 + description: 116 + This adjusts the voltage at which the DP<#> and DM<#> 117 + signals cross while transmitting in HS mode. 118 + The hardware accepts only discrete values. The value closest to the 119 + provided input will be chosen as the override value for this param. 120 + minimum: -31000 121 + maximum: 28000 122 + 123 + qcom,hs-output-impedance-micro-ohms: 124 + description: 125 + In some applications, there can be significant series resistance 126 + on the D+ and D- paths between the transceiver and cable. This adjusts 127 + the driver source impedance to compensate for added series 128 + resistance on the USB. The hardware accepts only discrete values. The 129 + value closest to the provided input will be chosen as the override value 130 + for this param. 131 + minimum: -2300000 132 + maximum: 6100000 133 + 134 + qcom,ls-fs-output-impedance-bp: 135 + description: 136 + This adjusts the low- and full-speed single-ended source 137 + impedance while driving high. The following adjustment values are based 138 + on nominal process, voltage, and temperature. 139 + The hardware accepts only discrete values. The value closest to the 140 + provided input will be chosen as the override value for this param. 141 + minimum: -1053 142 + maximum: 1310 56 143 57 144 required: 58 145 - compatible
-112
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
··· 1 - * Renesas R-Car generation 2 USB PHY 2 - 3 - This file provides information on what the device node for the R-Car generation 4 - 2 USB PHY contains. 5 - 6 - Required properties: 7 - - compatible: "renesas,usb-phy-r8a7742" if the device is a part of R8A7742 SoC. 8 - "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. 9 - "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC. 10 - "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. 11 - "renesas,usb-phy-r8a77470" if the device is a part of R8A77470 SoC. 12 - "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. 13 - "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. 14 - "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC. 15 - "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 or 16 - RZ/G1 compatible device. 17 - 18 - When compatible with the generic version, nodes must list the 19 - SoC-specific version corresponding to the platform first 20 - followed by the generic version. 21 - 22 - - reg: offset and length of the register block. 23 - - #address-cells: number of address cells for the USB channel subnodes, must 24 - be <1>. 25 - - #size-cells: number of size cells for the USB channel subnodes, must be <0>. 26 - - clocks: clock phandle and specifier pair. 27 - - clock-names: string, clock input name, must be "usbhs". 28 - 29 - The USB PHY device tree node should have the subnodes corresponding to the USB 30 - channels. These subnodes must contain the following properties: 31 - - reg: the USB controller selector; see the table below for the values. 32 - - #phy-cells: see phy-bindings.txt in the same directory, must be <1>. 33 - 34 - The phandle's argument in the PHY specifier is the USB controller selector for 35 - the USB channel other than r8a77470 SoC; see the selector meanings below: 36 - 37 - +-----------+---------------+---------------+ 38 - |\ Selector | | | 39 - + --------- + 0 | 1 | 40 - | Channel \| | | 41 - +-----------+---------------+---------------+ 42 - | 0 | PCI EHCI/OHCI | HS-USB | 43 - | 2 | PCI EHCI/OHCI | xHCI | 44 - +-----------+---------------+---------------+ 45 - 46 - For r8a77470 SoC;see the selector meaning below: 47 - 48 - +-----------+---------------+---------------+ 49 - |\ Selector | | | 50 - + --------- + 0 | 1 | 51 - | Channel \| | | 52 - +-----------+---------------+---------------+ 53 - | 0 | EHCI/OHCI | HS-USB | 54 - +-----------+---------------+---------------+ 55 - 56 - Example (Lager board): 57 - 58 - usb-phy@e6590100 { 59 - compatible = "renesas,usb-phy-r8a7790", "renesas,rcar-gen2-usb-phy"; 60 - reg = <0 0xe6590100 0 0x100>; 61 - #address-cells = <1>; 62 - #size-cells = <0>; 63 - clocks = <&cpg CPG_MOD 704>; 64 - clock-names = "usbhs"; 65 - power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; 66 - resets = <&cpg 704>; 67 - 68 - usb0: usb-channel@0 { 69 - reg = <0>; 70 - #phy-cells = <1>; 71 - }; 72 - usb2: usb-channel@2 { 73 - reg = <2>; 74 - #phy-cells = <1>; 75 - }; 76 - }; 77 - 78 - Example (iWave RZ/G1C sbc): 79 - 80 - usbphy0: usb-phy0@e6590100 { 81 - compatible = "renesas,usb-phy-r8a77470", 82 - "renesas,rcar-gen2-usb-phy"; 83 - reg = <0 0xe6590100 0 0x100>; 84 - #address-cells = <1>; 85 - #size-cells = <0>; 86 - clocks = <&cpg CPG_MOD 704>; 87 - clock-names = "usbhs"; 88 - power-domains = <&sysc R8A77470_PD_ALWAYS_ON>; 89 - resets = <&cpg 704>; 90 - 91 - usb0: usb-channel@0 { 92 - reg = <0>; 93 - #phy-cells = <1>; 94 - }; 95 - }; 96 - 97 - usbphy1: usb-phy@e6598100 { 98 - compatible = "renesas,usb-phy-r8a77470", 99 - "renesas,rcar-gen2-usb-phy"; 100 - reg = <0 0xe6598100 0 0x100>; 101 - #address-cells = <1>; 102 - #size-cells = <0>; 103 - clocks = <&cpg CPG_MOD 706>; 104 - clock-names = "usbhs"; 105 - power-domains = <&sysc R8A77470_PD_ALWAYS_ON>; 106 - resets = <&cpg 706>; 107 - 108 - usb1: usb-channel@0 { 109 - reg = <0>; 110 - #phy-cells = <1>; 111 - }; 112 - };
+123
Documentation/devicetree/bindings/phy/renesas,rcar-gen2-usb-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/renesas,rcar-gen2-usb-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Renesas R-Car Gen2 USB PHY 8 + 9 + maintainers: 10 + - Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> 11 + 12 + properties: 13 + compatible: 14 + items: 15 + - enum: 16 + - renesas,usb-phy-r8a7742 # RZ/G1H 17 + - renesas,usb-phy-r8a7743 # RZ/G1M 18 + - renesas,usb-phy-r8a7744 # RZ/G1N 19 + - renesas,usb-phy-r8a7745 # RZ/G1E 20 + - renesas,usb-phy-r8a77470 # RZ/G1C 21 + - renesas,usb-phy-r8a7790 # R-Car H2 22 + - renesas,usb-phy-r8a7791 # R-Car M2-W 23 + - renesas,usb-phy-r8a7794 # R-Car E2 24 + - const: renesas,rcar-gen2-usb-phy # R-Car Gen2 or RZ/G1 25 + 26 + reg: 27 + maxItems: 1 28 + 29 + '#address-cells': 30 + const: 1 31 + 32 + '#size-cells': 33 + const: 0 34 + 35 + clocks: 36 + maxItems: 1 37 + 38 + clock-names: 39 + items: 40 + - const: usbhs 41 + 42 + power-domains: 43 + maxItems: 1 44 + 45 + resets: 46 + maxItems: 1 47 + 48 + patternProperties: 49 + "^usb-phy@[02]$": 50 + type: object 51 + description: Subnode corresponding to a USB channel. 52 + 53 + properties: 54 + reg: 55 + description: FIXME RZ/G1C supports channel 0 only 56 + enum: [0, 2] 57 + 58 + '#phy-cells': 59 + description: | 60 + The phandle's argument in the PHY specifier is the USB controller 61 + selector for the USB channel. 62 + For RZ/G1C: 63 + - 0 for EHCI/OHCI 64 + - 1 for HS-USB 65 + For all other SoCS: 66 + - 0 for PCI EHCI/OHCI 67 + - 1 for HS-USB (channel 0) or xHCI (channel 2) 68 + const: 1 69 + 70 + required: 71 + - reg 72 + - '#phy-cells' 73 + 74 + additionalProperties: false 75 + 76 + required: 77 + - compatible 78 + - reg 79 + - '#address-cells' 80 + - '#size-cells' 81 + - clocks 82 + - clock-names 83 + - resets 84 + - power-domains 85 + - usb-phy@0 86 + 87 + if: 88 + properties: 89 + compatible: 90 + contains: 91 + const: renesas,usb-phy-r8a77470 92 + then: 93 + properties: 94 + usb-phy@2: false 95 + else: 96 + required: 97 + - usb-phy@2 98 + 99 + additionalProperties: false 100 + 101 + examples: 102 + - | 103 + #include <dt-bindings/clock/r8a7790-cpg-mssr.h> 104 + #include <dt-bindings/power/r8a7790-sysc.h> 105 + usb-phy-controller@e6590100 { 106 + compatible = "renesas,usb-phy-r8a7790", "renesas,rcar-gen2-usb-phy"; 107 + reg = <0xe6590100 0x100>; 108 + #address-cells = <1>; 109 + #size-cells = <0>; 110 + clocks = <&cpg CPG_MOD 704>; 111 + clock-names = "usbhs"; 112 + power-domains = <&sysc R8A7790_PD_ALWAYS_ON>; 113 + resets = <&cpg 704>; 114 + 115 + usb0: usb-phy@0 { 116 + reg = <0>; 117 + #phy-cells = <1>; 118 + }; 119 + usb2: usb-phy@2 { 120 + reg = <2>; 121 + #phy-cells = <1>; 122 + }; 123 + };
+80
Documentation/devicetree/bindings/phy/rockchip,pcie3-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/phy/rockchip,pcie3-phy.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Rockchip PCIe v3 phy 8 + 9 + maintainers: 10 + - Heiko Stuebner <heiko@sntech.de> 11 + 12 + properties: 13 + compatible: 14 + enum: 15 + - rockchip,rk3568-pcie3-phy 16 + 17 + reg: 18 + maxItems: 1 19 + 20 + clocks: 21 + minItems: 3 22 + maxItems: 3 23 + 24 + clock-names: 25 + items: 26 + - const: refclk_m 27 + - const: refclk_n 28 + - const: pclk 29 + 30 + data-lanes: 31 + description: which lanes (by position) should be mapped to which 32 + controller (value). 0 means lane disabled, higher value means used. 33 + (controller-number +1 ) 34 + $ref: /schemas/types.yaml#/definitions/uint32-array 35 + minItems: 2 36 + maxItems: 16 37 + items: 38 + minimum: 0 39 + maximum: 16 40 + 41 + "#phy-cells": 42 + const: 0 43 + 44 + resets: 45 + maxItems: 1 46 + 47 + reset-names: 48 + const: phy 49 + 50 + rockchip,phy-grf: 51 + $ref: /schemas/types.yaml#/definitions/phandle 52 + description: phandle to the syscon managing the phy "general register files" 53 + 54 + rockchip,pipe-grf: 55 + $ref: /schemas/types.yaml#/definitions/phandle 56 + description: phandle to the syscon managing the pipe "general register files" 57 + 58 + required: 59 + - compatible 60 + - reg 61 + - rockchip,phy-grf 62 + - "#phy-cells" 63 + 64 + additionalProperties: false 65 + 66 + examples: 67 + - | 68 + #include <dt-bindings/clock/rk3568-cru.h> 69 + pcie30phy: phy@fe8c0000 { 70 + compatible = "rockchip,rk3568-pcie3-phy"; 71 + reg = <0xfe8c0000 0x20000>; 72 + #phy-cells = <0>; 73 + clocks = <&pmucru CLK_PCIE30PHY_REF_M>, 74 + <&pmucru CLK_PCIE30PHY_REF_N>, 75 + <&cru PCLK_PCIE30PHY>; 76 + clock-names = "refclk_m", "refclk_n", "pclk"; 77 + resets = <&cru SRST_PCIE30PHY>; 78 + reset-names = "phy"; 79 + rockchip,phy-grf = <&pcie30_phy_grf>; 80 + };
+1
Documentation/devicetree/bindings/phy/rockchip,px30-dsi-dphy.yaml
··· 18 18 - rockchip,px30-dsi-dphy 19 19 - rockchip,rk3128-dsi-dphy 20 20 - rockchip,rk3368-dsi-dphy 21 + - rockchip,rk3568-dsi-dphy 21 22 22 23 reg: 23 24 maxItems: 1
+1
Documentation/devicetree/bindings/phy/rockchip-inno-csi-dphy.yaml
··· 20 20 - rockchip,rk1808-csi-dphy 21 21 - rockchip,rk3326-csi-dphy 22 22 - rockchip,rk3368-csi-dphy 23 + - rockchip,rk3568-csi-dphy 23 24 24 25 reg: 25 26 maxItems: 1
+37 -10
Documentation/devicetree/bindings/phy/samsung,ufs-phy.yaml
··· 27 27 - const: phy-pma 28 28 29 29 clocks: 30 - items: 31 - - description: PLL reference clock 32 - - description: symbol clock for input symbol ( rx0-ch0 symbol clock) 33 - - description: symbol clock for input symbol ( rx1-ch1 symbol clock) 34 - - description: symbol clock for output symbol ( tx0 symbol clock) 30 + minItems: 1 31 + maxItems: 4 35 32 36 33 clock-names: 37 - items: 38 - - const: ref_clk 39 - - const: rx1_symbol_clk 40 - - const: rx0_symbol_clk 41 - - const: tx0_symbol_clk 34 + minItems: 1 35 + maxItems: 4 42 36 43 37 samsung,pmu-syscon: 44 38 $ref: '/schemas/types.yaml#/definitions/phandle-array' ··· 55 61 - clocks 56 62 - clock-names 57 63 - samsung,pmu-syscon 64 + 65 + allOf: 66 + - if: 67 + properties: 68 + compatible: 69 + contains: 70 + const: samsung,exynos7-ufs-phy 71 + 72 + then: 73 + properties: 74 + clocks: 75 + items: 76 + - description: PLL reference clock 77 + - description: symbol clock for input symbol (rx0-ch0 symbol clock) 78 + - description: symbol clock for input symbol (rx1-ch1 symbol clock) 79 + - description: symbol clock for output symbol (tx0 symbol clock) 80 + 81 + clock-names: 82 + items: 83 + - const: ref_clk 84 + - const: rx1_symbol_clk 85 + - const: rx0_symbol_clk 86 + - const: tx0_symbol_clk 87 + 88 + else: 89 + properties: 90 + clocks: 91 + items: 92 + - description: PLL reference clock 93 + 94 + clock-names: 95 + items: 96 + - const: ref_clk 58 97 59 98 additionalProperties: false 60 99
+73
Documentation/devicetree/bindings/phy/sunplus,sp7021-usb2-phy.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + # Copyright (C) Sunplus Co., Ltd. 2021 3 + %YAML 1.2 4 + --- 5 + $id: "http://devicetree.org/schemas/phy/sunplus,sp7021-usb2-phy.yaml#" 6 + $schema: "http://devicetree.org/meta-schemas/core.yaml#" 7 + 8 + title: Sunplus SP7021 USB 2.0 PHY Controller 9 + 10 + maintainers: 11 + - Vincent Shih <vincent.sunplus@gmail.com> 12 + 13 + properties: 14 + compatible: 15 + const: sunplus,sp7021-usb2-phy 16 + 17 + reg: 18 + items: 19 + - description: UPHY register region 20 + - description: MOON4 register region 21 + 22 + reg-names: 23 + items: 24 + - const: phy 25 + - const: moon4 26 + 27 + clocks: 28 + maxItems: 1 29 + 30 + resets: 31 + maxItems: 1 32 + 33 + "#phy-cells": 34 + const: 0 35 + 36 + nvmem-cell-names: 37 + description: names corresponding to the nvmem cells of disconnect voltage 38 + const: disc_vol 39 + 40 + nvmem-cells: 41 + description: nvmem cell address of disconnect voltage 42 + maxItems: 1 43 + 44 + sunplus,disc-vol-addr-off: 45 + $ref: /schemas/types.yaml#/definitions/uint32 46 + description: the otp address offset of disconnect voltage 47 + 48 + required: 49 + - compatible 50 + - reg 51 + - reg-names 52 + - clocks 53 + - resets 54 + - "#phy-cells" 55 + - nvmem-cell-names 56 + - nvmem-cells 57 + - sunplus,disc-vol-addr-off 58 + 59 + additionalProperties: false 60 + 61 + examples: 62 + - | 63 + sp_uphy0: usb-phy@9c004a80 { 64 + compatible = "sunplus,sp7021-usb2-phy"; 65 + reg = <0x9c004a80 0x80>, <0x9c000248 0x10>; 66 + reg-names = "phy", "moon4"; 67 + clocks = <&clkc 0x3d>; 68 + resets = <&rstc 0x2d>; 69 + #phy-cells = <0>; 70 + nvmem-cell-names = "disc_vol"; 71 + nvmem-cells = <&disc_vol>; 72 + sunplus,disc-vol-addr-off = <0>; 73 + };
+26 -1
Documentation/devicetree/bindings/phy/ti,phy-gmii-sel.yaml
··· 53 53 - ti,am43xx-phy-gmii-sel 54 54 - ti,dm814-phy-gmii-sel 55 55 - ti,am654-phy-gmii-sel 56 + - ti,j7200-cpsw5g-phy-gmii-sel 56 57 57 58 reg: 58 59 maxItems: 1 59 60 60 61 '#phy-cells': true 62 + 63 + ti,qsgmii-main-ports: 64 + $ref: /schemas/types.yaml#/definitions/uint32-array 65 + description: | 66 + Required only for QSGMII mode. Array to select the port for 67 + QSGMII main mode. Rest of the ports are selected as QSGMII_SUB 68 + ports automatically. Any one of the 4 CPSW5G ports can act as the 69 + main port with the rest of them being the QSGMII_SUB ports. 70 + maxItems: 1 71 + items: 72 + minimum: 1 73 + maximum: 4 61 74 62 75 allOf: 63 76 - if: ··· 86 73 '#phy-cells': 87 74 const: 1 88 75 description: CPSW port number (starting from 1) 76 + 77 + - if: 78 + not: 79 + properties: 80 + compatible: 81 + contains: 82 + enum: 83 + - ti,j7200-cpsw5g-phy-gmii-sel 84 + then: 85 + properties: 86 + ti,qsgmii-main-ports: false 87 + 89 88 - if: 90 89 properties: 91 90 compatible: ··· 122 97 123 98 examples: 124 99 - | 125 - phy_gmii_sel: phy-gmii-sel@650 { 100 + phy_gmii_sel: phy@650 { 126 101 compatible = "ti,am3352-phy-gmii-sel"; 127 102 reg = <0x650 0x4>; 128 103 #phy-cells = <2>;
+26 -1
Documentation/devicetree/bindings/phy/ti,phy-j721e-wiz.yaml
··· 16 16 - ti,j721e-wiz-16g 17 17 - ti,j721e-wiz-10g 18 18 - ti,am64-wiz-10g 19 + - ti,j7200-wiz-10g 19 20 20 21 power-domains: 21 22 maxItems: 1 22 23 23 24 clocks: 24 - maxItems: 3 25 + minItems: 3 26 + maxItems: 4 25 27 description: clock-specifier to represent input to the WIZ 26 28 27 29 clock-names: 30 + minItems: 3 28 31 items: 29 32 - const: fck 30 33 - const: core_ref_clk 31 34 - const: ext_ref_clk 35 + - const: core_ref1_clk 32 36 33 37 num-lanes: 34 38 minimum: 1 ··· 83 79 84 80 refclk-dig: 85 81 type: object 82 + additionalProperties: false 86 83 description: | 87 84 WIZ node should have subnode for refclk_dig to select the reference 88 85 clock source for the reference clock used in the PHY and PMA digital 89 86 logic. 87 + deprecated: true 90 88 properties: 91 89 clocks: 92 90 minItems: 2 ··· 111 105 - assigned-clocks 112 106 - assigned-clock-parents 113 107 108 + ti,scm: 109 + $ref: /schemas/types.yaml#/definitions/phandle 110 + description: | 111 + phandle to System Control Module for syscon regmap access. 112 + 114 113 patternProperties: 115 114 "^pll[0|1]-refclk$": 116 115 type: object 116 + additionalProperties: false 117 117 description: | 118 118 WIZ node should have subnodes for each of the PLLs present in 119 119 the SERDES. 120 + deprecated: true 120 121 properties: 121 122 clocks: 122 123 maxItems: 2 ··· 146 133 147 134 "^cmn-refclk1?-dig-div$": 148 135 type: object 136 + additionalProperties: false 149 137 description: 150 138 WIZ node should have subnodes for each of the PMA common refclock 151 139 provided by the SERDES. 140 + deprecated: true 152 141 properties: 153 142 clocks: 154 143 maxItems: 1 ··· 184 169 - "#size-cells" 185 170 - "#reset-cells" 186 171 - ranges 172 + 173 + allOf: 174 + - if: 175 + properties: 176 + compatible: 177 + contains: 178 + const: ti,j7200-wiz-10g 179 + then: 180 + required: 181 + - ti,scm 187 182 188 183 additionalProperties: false 189 184
+10
MAINTAINERS
··· 13548 13548 L: linux-mips@vger.kernel.org 13549 13549 S: Supported 13550 13550 F: Documentation/devicetree/bindings/mips/mscc.txt 13551 + F: Documentation/devicetree/bindings/phy/mscc,vsc7514-serdes.yaml 13551 13552 F: Documentation/devicetree/bindings/power/reset/ocelot-reset.txt 13552 13553 F: arch/mips/boot/dts/mscc/ 13553 13554 F: arch/mips/configs/generic/board-ocelot.config ··· 19617 19616 S: Maintained 19618 19617 F: Documentation/devicetree/bindings/nvmem/sunplus,sp7021-ocotp.yaml 19619 19618 F: drivers/nvmem/sunplus-ocotp.c 19619 + 19620 + SUNPLUS USB2 PHY DRIVER 19621 + M: Vincent Shih <vincent.sunplus@gmail.com> 19622 + L: linux-usb@vger.kernel.org 19623 + S: Maintained 19624 + F: Documentation/devicetree/bindings/phy/sunplus,sp7021-usb2-phy.yaml 19625 + F: drivers/phy/sunplus/Kconfig 19626 + F: drivers/phy/sunplus/Makefile 19627 + F: drivers/phy/sunplus/phy-sunplus-usb2.c 19620 19628 19621 19629 SUNPLUS PWM DRIVER 19622 19630 M: Hammer Hsieh <hammerh0314@gmail.com>
+1
drivers/phy/Kconfig
··· 91 91 source "drivers/phy/samsung/Kconfig" 92 92 source "drivers/phy/socionext/Kconfig" 93 93 source "drivers/phy/st/Kconfig" 94 + source "drivers/phy/sunplus/Kconfig" 94 95 source "drivers/phy/tegra/Kconfig" 95 96 source "drivers/phy/ti/Kconfig" 96 97 source "drivers/phy/intel/Kconfig"
+1
drivers/phy/Makefile
··· 31 31 samsung/ \ 32 32 socionext/ \ 33 33 st/ \ 34 + sunplus/ \ 34 35 tegra/ \ 35 36 ti/ \ 36 37 xilinx/
+1 -1
drivers/phy/allwinner/phy-sun4i-usb.c
··· 768 768 if (data->cfg->dedicated_clocks) 769 769 snprintf(name, sizeof(name), "usb%d_phy", i); 770 770 else 771 - strlcpy(name, "usb_phy", sizeof(name)); 771 + strscpy(name, "usb_phy", sizeof(name)); 772 772 773 773 phy->clk = devm_clk_get(dev, name); 774 774 if (IS_ERR(phy->clk)) {
+4 -2
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c
··· 197 197 struct phy_provider *phy; 198 198 struct device *dev = &pdev->dev; 199 199 struct phy_axg_mipi_pcie_analog_priv *priv; 200 - struct device_node *np = dev->of_node; 200 + struct device_node *np = dev->of_node, *parent_np; 201 201 struct regmap *map; 202 202 int ret; 203 203 ··· 206 206 return -ENOMEM; 207 207 208 208 /* Get the hhi system controller node */ 209 - map = syscon_node_to_regmap(of_get_parent(dev->of_node)); 209 + parent_np = of_get_parent(dev->of_node); 210 + map = syscon_node_to_regmap(parent_np); 211 + of_node_put(parent_np); 210 212 if (IS_ERR(map)) { 211 213 dev_err(dev, 212 214 "failed to get HHI regmap\n");
+6 -26
drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c
··· 388 388 struct phy_g12a_usb3_pcie_priv *priv; 389 389 struct phy_provider *phy_provider; 390 390 void __iomem *base; 391 - int ret; 392 391 393 392 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 394 393 if (!priv) ··· 407 408 if (IS_ERR(priv->regmap_cr)) 408 409 return PTR_ERR(priv->regmap_cr); 409 410 410 - priv->clk_ref = devm_clk_get(dev, "ref_clk"); 411 + priv->clk_ref = devm_clk_get_enabled(dev, "ref_clk"); 411 412 if (IS_ERR(priv->clk_ref)) 412 413 return PTR_ERR(priv->clk_ref); 413 414 414 - ret = clk_prepare_enable(priv->clk_ref); 415 - if (ret) 416 - return ret; 417 - 418 415 priv->reset = devm_reset_control_array_get_exclusive(dev); 419 - if (IS_ERR(priv->reset)) { 420 - ret = PTR_ERR(priv->reset); 421 - goto err_disable_clk_ref; 422 - } 416 + if (IS_ERR(priv->reset)) 417 + return PTR_ERR(priv->reset); 423 418 424 419 priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops); 425 - if (IS_ERR(priv->phy)) { 426 - ret = PTR_ERR(priv->phy); 427 - dev_err_probe(dev, ret, "failed to create PHY\n"); 428 - goto err_disable_clk_ref; 429 - } 420 + if (IS_ERR(priv->phy)) 421 + return dev_err_probe(dev, PTR_ERR(priv->phy), "failed to create PHY\n"); 430 422 431 423 phy_set_drvdata(priv->phy, priv); 432 424 dev_set_drvdata(dev, priv); 433 425 434 426 phy_provider = devm_of_phy_provider_register(dev, 435 427 phy_g12a_usb3_pcie_xlate); 436 - if (IS_ERR(phy_provider)) { 437 - ret = PTR_ERR(phy_provider); 438 - goto err_disable_clk_ref; 439 - } 440 - 441 - return 0; 442 - 443 - err_disable_clk_ref: 444 - clk_disable_unprepare(priv->clk_ref); 445 - 446 - return ret; 428 + return PTR_ERR_OR_ZERO(phy_provider); 447 429 } 448 430 449 431 static const struct of_device_id phy_g12a_usb3_pcie_of_match[] = {
+15 -30
drivers/phy/intel/phy-intel-lgm-combo.c
··· 413 413 u32 val; 414 414 415 415 cbphy->core_clk = devm_clk_get(dev, NULL); 416 - if (IS_ERR(cbphy->core_clk)) { 417 - ret = PTR_ERR(cbphy->core_clk); 418 - if (ret != -EPROBE_DEFER) 419 - dev_err(dev, "Get clk failed:%d!\n", ret); 420 - return ret; 421 - } 416 + if (IS_ERR(cbphy->core_clk)) 417 + return dev_err_probe(dev, PTR_ERR(cbphy->core_clk), 418 + "Get clk failed!\n"); 422 419 423 420 cbphy->core_rst = devm_reset_control_get_optional(dev, "core"); 424 - if (IS_ERR(cbphy->core_rst)) { 425 - ret = PTR_ERR(cbphy->core_rst); 426 - if (ret != -EPROBE_DEFER) 427 - dev_err(dev, "Get core reset control err: %d!\n", ret); 428 - return ret; 429 - } 421 + if (IS_ERR(cbphy->core_rst)) 422 + return dev_err_probe(dev, PTR_ERR(cbphy->core_rst), 423 + "Get core reset control err!\n"); 430 424 431 425 cbphy->phy_rst = devm_reset_control_get_optional(dev, "phy"); 432 - if (IS_ERR(cbphy->phy_rst)) { 433 - ret = PTR_ERR(cbphy->phy_rst); 434 - if (ret != -EPROBE_DEFER) 435 - dev_err(dev, "Get PHY reset control err: %d!\n", ret); 436 - return ret; 437 - } 426 + if (IS_ERR(cbphy->phy_rst)) 427 + return dev_err_probe(dev, PTR_ERR(cbphy->phy_rst), 428 + "Get PHY reset control err!\n"); 438 429 439 430 cbphy->iphy[0].app_rst = devm_reset_control_get_optional(dev, "iphy0"); 440 - if (IS_ERR(cbphy->iphy[0].app_rst)) { 441 - ret = PTR_ERR(cbphy->iphy[0].app_rst); 442 - if (ret != -EPROBE_DEFER) 443 - dev_err(dev, "Get phy0 reset control err: %d!\n", ret); 444 - return ret; 445 - } 431 + if (IS_ERR(cbphy->iphy[0].app_rst)) 432 + return dev_err_probe(dev, PTR_ERR(cbphy->iphy[0].app_rst), 433 + "Get phy0 reset control err!\n"); 446 434 447 435 cbphy->iphy[1].app_rst = devm_reset_control_get_optional(dev, "iphy1"); 448 - if (IS_ERR(cbphy->iphy[1].app_rst)) { 449 - ret = PTR_ERR(cbphy->iphy[1].app_rst); 450 - if (ret != -EPROBE_DEFER) 451 - dev_err(dev, "Get phy1 reset control err: %d!\n", ret); 452 - return ret; 453 - } 436 + if (IS_ERR(cbphy->iphy[1].app_rst)) 437 + return dev_err_probe(dev, PTR_ERR(cbphy->iphy[1].app_rst), 438 + "Get phy1 reset control err!\n"); 454 439 455 440 cbphy->app_base = devm_platform_ioremap_resource_byname(pdev, "app"); 456 441 if (IS_ERR(cbphy->app_base))
+1 -1
drivers/phy/mediatek/phy-mtk-dp.c
··· 85 85 static int mtk_dp_phy_init(struct phy *phy) 86 86 { 87 87 struct mtk_dp_phy *dp_phy = phy_get_drvdata(phy); 88 - u32 driving_params[] = { 88 + static const u32 driving_params[] = { 89 89 DRIVING_PARAM_3_DEFAULT, 90 90 DRIVING_PARAM_4_DEFAULT, 91 91 DRIVING_PARAM_5_DEFAULT,
+107 -129
drivers/phy/mediatek/phy-mtk-hdmi-mt2701.c
··· 5 5 */ 6 6 7 7 #include "phy-mtk-hdmi.h" 8 + #include "phy-mtk-io.h" 8 9 9 10 #define HDMI_CON0 0x00 10 - #define RG_HDMITX_DRV_IBIAS 0 11 - #define RG_HDMITX_DRV_IBIAS_MASK (0x3f << 0) 12 - #define RG_HDMITX_EN_SER 12 13 - #define RG_HDMITX_EN_SER_MASK (0x0f << 12) 14 - #define RG_HDMITX_EN_SLDO 16 15 - #define RG_HDMITX_EN_SLDO_MASK (0x0f << 16) 16 - #define RG_HDMITX_EN_PRED 20 17 - #define RG_HDMITX_EN_PRED_MASK (0x0f << 20) 18 - #define RG_HDMITX_EN_IMP 24 19 - #define RG_HDMITX_EN_IMP_MASK (0x0f << 24) 20 - #define RG_HDMITX_EN_DRV 28 21 - #define RG_HDMITX_EN_DRV_MASK (0x0f << 28) 11 + #define RG_HDMITX_DRV_IBIAS_MASK GENMASK(5, 0) 12 + #define RG_HDMITX_EN_SER_MASK GENMASK(15, 12) 13 + #define RG_HDMITX_EN_SLDO_MASK GENMASK(19, 16) 14 + #define RG_HDMITX_EN_PRED_MASK GENMASK(23, 20) 15 + #define RG_HDMITX_EN_IMP_MASK GENMASK(27, 24) 16 + #define RG_HDMITX_EN_DRV_MASK GENMASK(31, 28) 22 17 23 18 #define HDMI_CON1 0x04 24 - #define RG_HDMITX_PRED_IBIAS 18 25 - #define RG_HDMITX_PRED_IBIAS_MASK (0x0f << 18) 26 - #define RG_HDMITX_PRED_IMP (0x01 << 22) 27 - #define RG_HDMITX_DRV_IMP 26 28 - #define RG_HDMITX_DRV_IMP_MASK (0x3f << 26) 19 + #define RG_HDMITX_PRED_IBIAS_MASK GENMASK(21, 18) 20 + #define RG_HDMITX_PRED_IMP BIT(22) 21 + #define RG_HDMITX_DRV_IMP_MASK GENMASK(31, 26) 29 22 30 23 #define HDMI_CON2 0x08 31 - #define RG_HDMITX_EN_TX_CKLDO (0x01 << 0) 32 - #define RG_HDMITX_EN_TX_POSDIV (0x01 << 1) 33 - #define RG_HDMITX_TX_POSDIV 3 34 - #define RG_HDMITX_TX_POSDIV_MASK (0x03 << 3) 35 - #define RG_HDMITX_EN_MBIAS (0x01 << 6) 36 - #define RG_HDMITX_MBIAS_LPF_EN (0x01 << 7) 24 + #define RG_HDMITX_EN_TX_CKLDO BIT(0) 25 + #define RG_HDMITX_EN_TX_POSDIV BIT(1) 26 + #define RG_HDMITX_TX_POSDIV_MASK GENMASK(4, 3) 27 + #define RG_HDMITX_EN_MBIAS BIT(6) 28 + #define RG_HDMITX_MBIAS_LPF_EN BIT(7) 37 29 38 30 #define HDMI_CON4 0x10 39 - #define RG_HDMITX_RESERVE_MASK (0xffffffff << 0) 31 + #define RG_HDMITX_RESERVE_MASK GENMASK(31, 0) 40 32 41 33 #define HDMI_CON6 0x18 42 - #define RG_HTPLL_BR 0 43 - #define RG_HTPLL_BR_MASK (0x03 << 0) 44 - #define RG_HTPLL_BC 2 45 - #define RG_HTPLL_BC_MASK (0x03 << 2) 46 - #define RG_HTPLL_BP 4 47 - #define RG_HTPLL_BP_MASK (0x0f << 4) 48 - #define RG_HTPLL_IR 8 49 - #define RG_HTPLL_IR_MASK (0x0f << 8) 50 - #define RG_HTPLL_IC 12 51 - #define RG_HTPLL_IC_MASK (0x0f << 12) 52 - #define RG_HTPLL_POSDIV 16 53 - #define RG_HTPLL_POSDIV_MASK (0x03 << 16) 54 - #define RG_HTPLL_PREDIV 18 55 - #define RG_HTPLL_PREDIV_MASK (0x03 << 18) 56 - #define RG_HTPLL_FBKSEL 20 57 - #define RG_HTPLL_FBKSEL_MASK (0x03 << 20) 58 - #define RG_HTPLL_RLH_EN (0x01 << 22) 59 - #define RG_HTPLL_FBKDIV 24 60 - #define RG_HTPLL_FBKDIV_MASK (0x7f << 24) 61 - #define RG_HTPLL_EN (0x01 << 31) 34 + #define RG_HTPLL_BR_MASK GENMASK(1, 0) 35 + #define RG_HTPLL_BC_MASK GENMASK(3, 2) 36 + #define RG_HTPLL_BP_MASK GENMASK(7, 4) 37 + #define RG_HTPLL_IR_MASK GENMASK(11, 8) 38 + #define RG_HTPLL_IC_MASK GENMASK(15, 12) 39 + #define RG_HTPLL_POSDIV_MASK GENMASK(17, 16) 40 + #define RG_HTPLL_PREDIV_MASK GENMASK(19, 18) 41 + #define RG_HTPLL_FBKSEL_MASK GENMASK(21, 20) 42 + #define RG_HTPLL_RLH_EN BIT(22) 43 + #define RG_HTPLL_FBKDIV_MASK GENMASK(30, 24) 44 + #define RG_HTPLL_EN BIT(31) 62 45 63 46 #define HDMI_CON7 0x1c 64 - #define RG_HTPLL_AUTOK_EN (0x01 << 23) 65 - #define RG_HTPLL_DIVEN 28 66 - #define RG_HTPLL_DIVEN_MASK (0x07 << 28) 47 + #define RG_HTPLL_AUTOK_EN BIT(23) 48 + #define RG_HTPLL_DIVEN_MASK GENMASK(30, 28) 67 49 68 50 static int mtk_hdmi_pll_prepare(struct clk_hw *hw) 69 51 { 70 52 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 53 + void __iomem *base = hdmi_phy->regs; 71 54 72 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON7, RG_HTPLL_AUTOK_EN); 73 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_RLH_EN); 74 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 75 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_MBIAS); 55 + mtk_phy_set_bits(base + HDMI_CON7, RG_HTPLL_AUTOK_EN); 56 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_RLH_EN); 57 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_POSDIV_MASK); 58 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_EN_MBIAS); 76 59 usleep_range(80, 100); 77 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_EN); 78 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 79 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 60 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_EN); 61 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 62 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 80 63 usleep_range(80, 100); 81 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 82 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 83 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 84 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 64 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 65 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_SER_MASK); 66 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 67 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 85 68 usleep_range(80, 100); 86 69 return 0; 87 70 } ··· 72 89 static void mtk_hdmi_pll_unprepare(struct clk_hw *hw) 73 90 { 74 91 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 92 + void __iomem *base = hdmi_phy->regs; 75 93 76 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 77 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 78 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 79 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 94 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 95 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 96 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_SER_MASK); 97 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 80 98 usleep_range(80, 100); 81 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 82 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 83 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_EN); 99 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 100 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 101 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_EN); 84 102 usleep_range(80, 100); 85 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_MBIAS); 86 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 87 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_RLH_EN); 88 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON7, RG_HTPLL_AUTOK_EN); 103 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_EN_MBIAS); 104 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_POSDIV_MASK); 105 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_RLH_EN); 106 + mtk_phy_clear_bits(base + HDMI_CON7, RG_HTPLL_AUTOK_EN); 89 107 usleep_range(80, 100); 90 108 } 91 109 ··· 100 116 unsigned long parent_rate) 101 117 { 102 118 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 119 + void __iomem *base = hdmi_phy->regs; 103 120 u32 pos_div; 104 121 105 122 if (rate <= 64000000) ··· 110 125 else 111 126 pos_div = 1; 112 127 113 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_PREDIV_MASK); 114 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 115 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 116 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IC), 117 - RG_HTPLL_IC_MASK); 118 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_IR), 119 - RG_HTPLL_IR_MASK); 120 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON2, (pos_div << RG_HDMITX_TX_POSDIV), 121 - RG_HDMITX_TX_POSDIV_MASK); 122 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (1 << RG_HTPLL_FBKSEL), 123 - RG_HTPLL_FBKSEL_MASK); 124 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (19 << RG_HTPLL_FBKDIV), 125 - RG_HTPLL_FBKDIV_MASK); 126 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON7, (0x2 << RG_HTPLL_DIVEN), 127 - RG_HTPLL_DIVEN_MASK); 128 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0xc << RG_HTPLL_BP), 129 - RG_HTPLL_BP_MASK); 130 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x2 << RG_HTPLL_BC), 131 - RG_HTPLL_BC_MASK); 132 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, (0x1 << RG_HTPLL_BR), 133 - RG_HTPLL_BR_MASK); 128 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_PREDIV_MASK); 129 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_POSDIV_MASK); 130 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_EN_TX_POSDIV); 131 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_IC_MASK, 0x1); 132 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_IR_MASK, 0x1); 133 + mtk_phy_update_field(base + HDMI_CON2, RG_HDMITX_TX_POSDIV_MASK, pos_div); 134 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_FBKSEL_MASK, 1); 135 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_FBKDIV_MASK, 19); 136 + mtk_phy_update_field(base + HDMI_CON7, RG_HTPLL_DIVEN_MASK, 0x2); 137 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_BP_MASK, 0xc); 138 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_BC_MASK, 0x2); 139 + mtk_phy_update_field(base + HDMI_CON6, RG_HTPLL_BR_MASK, 0x1); 134 140 135 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PRED_IMP); 136 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON1, (0x3 << RG_HDMITX_PRED_IBIAS), 137 - RG_HDMITX_PRED_IBIAS_MASK); 138 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_IMP_MASK); 139 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON1, (0x28 << RG_HDMITX_DRV_IMP), 140 - RG_HDMITX_DRV_IMP_MASK); 141 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON4, 0x28, RG_HDMITX_RESERVE_MASK); 142 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON0, (0xa << RG_HDMITX_DRV_IBIAS), 143 - RG_HDMITX_DRV_IBIAS_MASK); 141 + mtk_phy_clear_bits(base + HDMI_CON1, RG_HDMITX_PRED_IMP); 142 + mtk_phy_update_field(base + HDMI_CON1, RG_HDMITX_PRED_IBIAS_MASK, 0x3); 143 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_IMP_MASK); 144 + mtk_phy_update_field(base + HDMI_CON1, RG_HDMITX_DRV_IMP_MASK, 0x28); 145 + mtk_phy_update_field(base + HDMI_CON4, RG_HDMITX_RESERVE_MASK, 0x28); 146 + mtk_phy_update_field(base + HDMI_CON0, RG_HDMITX_DRV_IBIAS_MASK, 0xa); 144 147 return 0; 145 148 } 146 149 ··· 137 164 { 138 165 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 139 166 unsigned long out_rate, val; 167 + u32 tmp; 140 168 141 - val = (readl(hdmi_phy->regs + HDMI_CON6) 142 - & RG_HTPLL_PREDIV_MASK) >> RG_HTPLL_PREDIV; 169 + tmp = readl(hdmi_phy->regs + HDMI_CON6); 170 + val = FIELD_GET(RG_HTPLL_PREDIV_MASK, tmp); 143 171 switch (val) { 144 172 case 0x00: 145 173 out_rate = parent_rate; ··· 153 179 break; 154 180 } 155 181 156 - val = (readl(hdmi_phy->regs + HDMI_CON6) 157 - & RG_HTPLL_FBKDIV_MASK) >> RG_HTPLL_FBKDIV; 182 + val = FIELD_GET(RG_HTPLL_FBKDIV_MASK, tmp); 158 183 out_rate *= (val + 1) * 2; 159 - val = (readl(hdmi_phy->regs + HDMI_CON2) 160 - & RG_HDMITX_TX_POSDIV_MASK); 161 - out_rate >>= (val >> RG_HDMITX_TX_POSDIV); 162 184 163 - if (readl(hdmi_phy->regs + HDMI_CON2) & RG_HDMITX_EN_TX_POSDIV) 185 + tmp = readl(hdmi_phy->regs + HDMI_CON2); 186 + val = FIELD_GET(RG_HDMITX_TX_POSDIV_MASK, tmp); 187 + out_rate >>= val; 188 + 189 + if (tmp & RG_HDMITX_EN_TX_POSDIV) 164 190 out_rate /= 5; 165 191 166 192 return out_rate; ··· 176 202 177 203 static void mtk_hdmi_phy_enable_tmds(struct mtk_hdmi_phy *hdmi_phy) 178 204 { 179 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON7, RG_HTPLL_AUTOK_EN); 180 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_RLH_EN); 181 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 182 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_MBIAS); 205 + void __iomem *base = hdmi_phy->regs; 206 + 207 + mtk_phy_set_bits(base + HDMI_CON7, RG_HTPLL_AUTOK_EN); 208 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_RLH_EN); 209 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_POSDIV_MASK); 210 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_EN_MBIAS); 183 211 usleep_range(80, 100); 184 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_EN); 185 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 186 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 212 + mtk_phy_set_bits(base + HDMI_CON6, RG_HTPLL_EN); 213 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 214 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 187 215 usleep_range(80, 100); 188 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 189 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 190 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 191 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 216 + mtk_phy_set_bits(base + HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 217 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_SER_MASK); 218 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 219 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 192 220 usleep_range(80, 100); 193 221 } 194 222 195 223 static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) 196 224 { 197 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 198 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 199 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SER_MASK); 200 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 225 + void __iomem *base = hdmi_phy->regs; 226 + 227 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_DRV_MASK); 228 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_PRED_MASK); 229 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_SER_MASK); 230 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_MBIAS_LPF_EN); 201 231 usleep_range(80, 100); 202 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 203 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 204 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_EN); 232 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_EN_SLDO_MASK); 233 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_EN_TX_CKLDO); 234 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_EN); 205 235 usleep_range(80, 100); 206 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON2, RG_HDMITX_EN_MBIAS); 207 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_POSDIV_MASK); 208 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON6, RG_HTPLL_RLH_EN); 209 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON7, RG_HTPLL_AUTOK_EN); 236 + mtk_phy_clear_bits(base + HDMI_CON2, RG_HDMITX_EN_MBIAS); 237 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_POSDIV_MASK); 238 + mtk_phy_clear_bits(base + HDMI_CON6, RG_HTPLL_RLH_EN); 239 + mtk_phy_clear_bits(base + HDMI_CON7, RG_HTPLL_AUTOK_EN); 210 240 usleep_range(80, 100); 211 241 } 212 242
+109 -137
drivers/phy/mediatek/phy-mtk-hdmi-mt8173.c
··· 5 5 */ 6 6 7 7 #include "phy-mtk-hdmi.h" 8 + #include "phy-mtk-io.h" 8 9 9 10 #define HDMI_CON0 0x00 10 11 #define RG_HDMITX_PLL_EN BIT(31) 11 - #define RG_HDMITX_PLL_FBKDIV (0x7f << 24) 12 - #define PLL_FBKDIV_SHIFT 24 13 - #define RG_HDMITX_PLL_FBKSEL (0x3 << 22) 14 - #define PLL_FBKSEL_SHIFT 22 15 - #define RG_HDMITX_PLL_PREDIV (0x3 << 20) 16 - #define PREDIV_SHIFT 20 17 - #define RG_HDMITX_PLL_POSDIV (0x3 << 18) 18 - #define POSDIV_SHIFT 18 19 - #define RG_HDMITX_PLL_RST_DLY (0x3 << 16) 20 - #define RG_HDMITX_PLL_IR (0xf << 12) 21 - #define PLL_IR_SHIFT 12 22 - #define RG_HDMITX_PLL_IC (0xf << 8) 23 - #define PLL_IC_SHIFT 8 24 - #define RG_HDMITX_PLL_BP (0xf << 4) 25 - #define PLL_BP_SHIFT 4 26 - #define RG_HDMITX_PLL_BR (0x3 << 2) 27 - #define PLL_BR_SHIFT 2 28 - #define RG_HDMITX_PLL_BC (0x3 << 0) 29 - #define PLL_BC_SHIFT 0 12 + #define RG_HDMITX_PLL_FBKDIV GENMASK(30, 24) 13 + #define RG_HDMITX_PLL_FBKSEL GENMASK(23, 22) 14 + #define RG_HDMITX_PLL_PREDIV GENMASK(21, 20) 15 + #define RG_HDMITX_PLL_POSDIV GENMASK(19, 18) 16 + #define RG_HDMITX_PLL_RST_DLY GENMASK(17, 16) 17 + #define RG_HDMITX_PLL_IR GENMASK(15, 12) 18 + #define RG_HDMITX_PLL_IC GENMASK(11, 8) 19 + #define RG_HDMITX_PLL_BP GENMASK(7, 4) 20 + #define RG_HDMITX_PLL_BR GENMASK(3, 2) 21 + #define RG_HDMITX_PLL_BC GENMASK(1, 0) 30 22 #define HDMI_CON1 0x04 31 - #define RG_HDMITX_PLL_DIVEN (0x7 << 29) 32 - #define PLL_DIVEN_SHIFT 29 23 + #define RG_HDMITX_PLL_DIVEN GENMASK(31, 29) 33 24 #define RG_HDMITX_PLL_AUTOK_EN BIT(28) 34 - #define RG_HDMITX_PLL_AUTOK_KF (0x3 << 26) 35 - #define RG_HDMITX_PLL_AUTOK_KS (0x3 << 24) 25 + #define RG_HDMITX_PLL_AUTOK_KF GENMASK(27, 26) 26 + #define RG_HDMITX_PLL_AUTOK_KS GENMASK(25, 24) 36 27 #define RG_HDMITX_PLL_AUTOK_LOAD BIT(23) 37 - #define RG_HDMITX_PLL_BAND (0x3f << 16) 28 + #define RG_HDMITX_PLL_BAND GENMASK(21, 16) 38 29 #define RG_HDMITX_PLL_REF_SEL BIT(15) 39 30 #define RG_HDMITX_PLL_BIAS_EN BIT(14) 40 31 #define RG_HDMITX_PLL_BIAS_LPF_EN BIT(13) 41 32 #define RG_HDMITX_PLL_TXDIV_EN BIT(12) 42 - #define RG_HDMITX_PLL_TXDIV (0x3 << 10) 43 - #define PLL_TXDIV_SHIFT 10 33 + #define RG_HDMITX_PLL_TXDIV GENMASK(11, 10) 44 34 #define RG_HDMITX_PLL_LVROD_EN BIT(9) 45 35 #define RG_HDMITX_PLL_MONVC_EN BIT(8) 46 36 #define RG_HDMITX_PLL_MONCK_EN BIT(7) 47 37 #define RG_HDMITX_PLL_MONREF_EN BIT(6) 48 38 #define RG_HDMITX_PLL_TST_EN BIT(5) 49 39 #define RG_HDMITX_PLL_TST_CK_EN BIT(4) 50 - #define RG_HDMITX_PLL_TST_SEL (0xf << 0) 40 + #define RG_HDMITX_PLL_TST_SEL GENMASK(3, 0) 51 41 #define HDMI_CON2 0x08 52 - #define RGS_HDMITX_PLL_AUTOK_BAND (0x7f << 8) 42 + #define RGS_HDMITX_PLL_AUTOK_BAND GENMASK(14, 8) 53 43 #define RGS_HDMITX_PLL_AUTOK_FAIL BIT(1) 54 44 #define RG_HDMITX_EN_TX_CKLDO BIT(0) 55 45 #define HDMI_CON3 0x0c 56 - #define RG_HDMITX_SER_EN (0xf << 28) 57 - #define RG_HDMITX_PRD_EN (0xf << 24) 58 - #define RG_HDMITX_PRD_IMP_EN (0xf << 20) 59 - #define RG_HDMITX_DRV_EN (0xf << 16) 60 - #define RG_HDMITX_DRV_IMP_EN (0xf << 12) 61 - #define DRV_IMP_EN_SHIFT 12 46 + #define RG_HDMITX_SER_EN GENMASK(31, 28) 47 + #define RG_HDMITX_PRD_EN GENMASK(27, 24) 48 + #define RG_HDMITX_PRD_IMP_EN GENMASK(23, 20) 49 + #define RG_HDMITX_DRV_EN GENMASK(19, 16) 50 + #define RG_HDMITX_DRV_IMP_EN GENMASK(15, 12) 62 51 #define RG_HDMITX_MHLCK_FORCE BIT(10) 63 52 #define RG_HDMITX_MHLCK_PPIX_EN BIT(9) 64 53 #define RG_HDMITX_MHLCK_EN BIT(8) 65 - #define RG_HDMITX_SER_DIN_SEL (0xf << 4) 54 + #define RG_HDMITX_SER_DIN_SEL GENMASK(7, 4) 66 55 #define RG_HDMITX_SER_5T1_BIST_EN BIT(3) 67 56 #define RG_HDMITX_SER_BIST_TOG BIT(2) 68 57 #define RG_HDMITX_SER_DIN_TOG BIT(1) 69 58 #define RG_HDMITX_SER_CLKDIG_INV BIT(0) 70 59 #define HDMI_CON4 0x10 71 - #define RG_HDMITX_PRD_IBIAS_CLK (0xf << 24) 72 - #define RG_HDMITX_PRD_IBIAS_D2 (0xf << 16) 73 - #define RG_HDMITX_PRD_IBIAS_D1 (0xf << 8) 74 - #define RG_HDMITX_PRD_IBIAS_D0 (0xf << 0) 75 - #define PRD_IBIAS_CLK_SHIFT 24 76 - #define PRD_IBIAS_D2_SHIFT 16 77 - #define PRD_IBIAS_D1_SHIFT 8 78 - #define PRD_IBIAS_D0_SHIFT 0 60 + #define RG_HDMITX_PRD_IBIAS_CLK GENMASK(27, 24) 61 + #define RG_HDMITX_PRD_IBIAS_D2 GENMASK(19, 16) 62 + #define RG_HDMITX_PRD_IBIAS_D1 GENMASK(11, 8) 63 + #define RG_HDMITX_PRD_IBIAS_D0 GENMASK(3, 0) 79 64 #define HDMI_CON5 0x14 80 - #define RG_HDMITX_DRV_IBIAS_CLK (0x3f << 24) 81 - #define RG_HDMITX_DRV_IBIAS_D2 (0x3f << 16) 82 - #define RG_HDMITX_DRV_IBIAS_D1 (0x3f << 8) 83 - #define RG_HDMITX_DRV_IBIAS_D0 (0x3f << 0) 84 - #define DRV_IBIAS_CLK_SHIFT 24 85 - #define DRV_IBIAS_D2_SHIFT 16 86 - #define DRV_IBIAS_D1_SHIFT 8 87 - #define DRV_IBIAS_D0_SHIFT 0 65 + #define RG_HDMITX_DRV_IBIAS_CLK GENMASK(29, 24) 66 + #define RG_HDMITX_DRV_IBIAS_D2 GENMASK(21, 16) 67 + #define RG_HDMITX_DRV_IBIAS_D1 GENMASK(13, 8) 68 + #define RG_HDMITX_DRV_IBIAS_D0 GENMASK(5, 0) 88 69 #define HDMI_CON6 0x18 89 - #define RG_HDMITX_DRV_IMP_CLK (0x3f << 24) 90 - #define RG_HDMITX_DRV_IMP_D2 (0x3f << 16) 91 - #define RG_HDMITX_DRV_IMP_D1 (0x3f << 8) 92 - #define RG_HDMITX_DRV_IMP_D0 (0x3f << 0) 93 - #define DRV_IMP_CLK_SHIFT 24 94 - #define DRV_IMP_D2_SHIFT 16 95 - #define DRV_IMP_D1_SHIFT 8 96 - #define DRV_IMP_D0_SHIFT 0 70 + #define RG_HDMITX_DRV_IMP_CLK GENMASK(29, 24) 71 + #define RG_HDMITX_DRV_IMP_D2 GENMASK(21, 16) 72 + #define RG_HDMITX_DRV_IMP_D1 GENMASK(13, 8) 73 + #define RG_HDMITX_DRV_IMP_D0 GENMASK(5, 0) 97 74 #define HDMI_CON7 0x1c 98 - #define RG_HDMITX_MHLCK_DRV_IBIAS (0x1f << 27) 99 - #define RG_HDMITX_SER_DIN (0x3ff << 16) 100 - #define RG_HDMITX_CHLDC_TST (0xf << 12) 101 - #define RG_HDMITX_CHLCK_TST (0xf << 8) 102 - #define RG_HDMITX_RESERVE (0xff << 0) 75 + #define RG_HDMITX_MHLCK_DRV_IBIAS GENMASK(31, 27) 76 + #define RG_HDMITX_SER_DIN GENMASK(25, 16) 77 + #define RG_HDMITX_CHLDC_TST GENMASK(15, 12) 78 + #define RG_HDMITX_CHLCK_TST GENMASK(11, 8) 79 + #define RG_HDMITX_RESERVE GENMASK(7, 0) 103 80 #define HDMI_CON8 0x20 104 - #define RGS_HDMITX_2T1_LEV (0xf << 16) 105 - #define RGS_HDMITX_2T1_EDG (0xf << 12) 106 - #define RGS_HDMITX_5T1_LEV (0xf << 8) 107 - #define RGS_HDMITX_5T1_EDG (0xf << 4) 81 + #define RGS_HDMITX_2T1_LEV GENMASK(19, 16) 82 + #define RGS_HDMITX_2T1_EDG GENMASK(15, 12) 83 + #define RGS_HDMITX_5T1_LEV GENMASK(11, 8) 84 + #define RGS_HDMITX_5T1_EDG GENMASK(7, 4) 108 85 #define RGS_HDMITX_PLUG_TST BIT(0) 109 86 110 87 static int mtk_hdmi_pll_prepare(struct clk_hw *hw) 111 88 { 112 89 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 90 + void __iomem *base = hdmi_phy->regs; 113 91 114 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_AUTOK_EN); 115 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_PLL_POSDIV); 116 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON3, RG_HDMITX_MHLCK_EN); 117 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_BIAS_EN); 92 + mtk_phy_set_bits(base + HDMI_CON1, RG_HDMITX_PLL_AUTOK_EN); 93 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_PLL_POSDIV); 94 + mtk_phy_clear_bits(base + HDMI_CON3, RG_HDMITX_MHLCK_EN); 95 + mtk_phy_set_bits(base + HDMI_CON1, RG_HDMITX_PLL_BIAS_EN); 118 96 usleep_range(100, 150); 119 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_PLL_EN); 97 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_PLL_EN); 120 98 usleep_range(100, 150); 121 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_BIAS_LPF_EN); 122 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_TXDIV_EN); 99 + mtk_phy_set_bits(base + HDMI_CON1, RG_HDMITX_PLL_BIAS_LPF_EN); 100 + mtk_phy_set_bits(base + HDMI_CON1, RG_HDMITX_PLL_TXDIV_EN); 123 101 124 102 return 0; 125 103 } ··· 105 127 static void mtk_hdmi_pll_unprepare(struct clk_hw *hw) 106 128 { 107 129 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 130 + void __iomem *base = hdmi_phy->regs; 108 131 109 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_TXDIV_EN); 110 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_BIAS_LPF_EN); 132 + mtk_phy_clear_bits(base + HDMI_CON1, RG_HDMITX_PLL_TXDIV_EN); 133 + mtk_phy_clear_bits(base + HDMI_CON1, RG_HDMITX_PLL_BIAS_LPF_EN); 111 134 usleep_range(100, 150); 112 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_PLL_EN); 135 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_PLL_EN); 113 136 usleep_range(100, 150); 114 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_BIAS_EN); 115 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_PLL_POSDIV); 116 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON1, RG_HDMITX_PLL_AUTOK_EN); 137 + mtk_phy_clear_bits(base + HDMI_CON1, RG_HDMITX_PLL_BIAS_EN); 138 + mtk_phy_clear_bits(base + HDMI_CON0, RG_HDMITX_PLL_POSDIV); 139 + mtk_phy_clear_bits(base + HDMI_CON1, RG_HDMITX_PLL_AUTOK_EN); 117 140 usleep_range(100, 150); 118 141 } 119 142 ··· 136 157 unsigned long parent_rate) 137 158 { 138 159 struct mtk_hdmi_phy *hdmi_phy = to_mtk_hdmi_phy(hw); 160 + void __iomem *base = hdmi_phy->regs; 139 161 unsigned int pre_div; 140 162 unsigned int div; 141 163 unsigned int pre_ibias; ··· 157 177 div = 1; 158 178 } 159 179 160 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON0, 161 - (pre_div << PREDIV_SHIFT), RG_HDMITX_PLL_PREDIV); 162 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON0, RG_HDMITX_PLL_POSDIV); 163 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON0, 164 - (0x1 << PLL_IC_SHIFT) | (0x1 << PLL_IR_SHIFT), 165 - RG_HDMITX_PLL_IC | RG_HDMITX_PLL_IR); 166 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON1, 167 - (div << PLL_TXDIV_SHIFT), RG_HDMITX_PLL_TXDIV); 168 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON0, 169 - (0x1 << PLL_FBKSEL_SHIFT) | (19 << PLL_FBKDIV_SHIFT), 170 - RG_HDMITX_PLL_FBKSEL | RG_HDMITX_PLL_FBKDIV); 171 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON1, 172 - (0x2 << PLL_DIVEN_SHIFT), RG_HDMITX_PLL_DIVEN); 173 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON0, 174 - (0xc << PLL_BP_SHIFT) | (0x2 << PLL_BC_SHIFT) | 175 - (0x1 << PLL_BR_SHIFT), 176 - RG_HDMITX_PLL_BP | RG_HDMITX_PLL_BC | 177 - RG_HDMITX_PLL_BR); 180 + mtk_phy_update_field(base + HDMI_CON0, RG_HDMITX_PLL_PREDIV, pre_div); 181 + mtk_phy_set_bits(base + HDMI_CON0, RG_HDMITX_PLL_POSDIV); 182 + mtk_phy_update_bits(base + HDMI_CON0, 183 + RG_HDMITX_PLL_IC | RG_HDMITX_PLL_IR, 184 + FIELD_PREP(RG_HDMITX_PLL_IC, 0x1) | 185 + FIELD_PREP(RG_HDMITX_PLL_IR, 0x1)); 186 + mtk_phy_update_field(base + HDMI_CON1, RG_HDMITX_PLL_TXDIV, div); 187 + mtk_phy_update_bits(base + HDMI_CON0, 188 + RG_HDMITX_PLL_FBKSEL | RG_HDMITX_PLL_FBKDIV, 189 + FIELD_PREP(RG_HDMITX_PLL_FBKSEL, 0x1) | 190 + FIELD_PREP(RG_HDMITX_PLL_FBKDIV, 19)); 191 + mtk_phy_update_field(base + HDMI_CON1, RG_HDMITX_PLL_DIVEN, 0x2); 192 + mtk_phy_update_bits(base + HDMI_CON0, 193 + RG_HDMITX_PLL_BP | RG_HDMITX_PLL_BC | 194 + RG_HDMITX_PLL_BR, 195 + FIELD_PREP(RG_HDMITX_PLL_BP, 0xc) | 196 + FIELD_PREP(RG_HDMITX_PLL_BC, 0x2) | 197 + FIELD_PREP(RG_HDMITX_PLL_BR, 0x1)); 178 198 if (rate < 165000000) { 179 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON3, 180 - RG_HDMITX_PRD_IMP_EN); 199 + mtk_phy_clear_bits(base + HDMI_CON3, RG_HDMITX_PRD_IMP_EN); 181 200 pre_ibias = 0x3; 182 201 imp_en = 0x0; 183 202 hdmi_ibias = hdmi_phy->ibias; 184 203 } else { 185 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON3, 186 - RG_HDMITX_PRD_IMP_EN); 204 + mtk_phy_set_bits(base + HDMI_CON3, RG_HDMITX_PRD_IMP_EN); 187 205 pre_ibias = 0x6; 188 206 imp_en = 0xf; 189 207 hdmi_ibias = hdmi_phy->ibias_up; 190 208 } 191 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON4, 192 - (pre_ibias << PRD_IBIAS_CLK_SHIFT) | 193 - (pre_ibias << PRD_IBIAS_D2_SHIFT) | 194 - (pre_ibias << PRD_IBIAS_D1_SHIFT) | 195 - (pre_ibias << PRD_IBIAS_D0_SHIFT), 196 - RG_HDMITX_PRD_IBIAS_CLK | 197 - RG_HDMITX_PRD_IBIAS_D2 | 198 - RG_HDMITX_PRD_IBIAS_D1 | 199 - RG_HDMITX_PRD_IBIAS_D0); 200 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON3, 201 - (imp_en << DRV_IMP_EN_SHIFT), 202 - RG_HDMITX_DRV_IMP_EN); 203 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON6, 204 - (hdmi_phy->drv_imp_clk << DRV_IMP_CLK_SHIFT) | 205 - (hdmi_phy->drv_imp_d2 << DRV_IMP_D2_SHIFT) | 206 - (hdmi_phy->drv_imp_d1 << DRV_IMP_D1_SHIFT) | 207 - (hdmi_phy->drv_imp_d0 << DRV_IMP_D0_SHIFT), 208 - RG_HDMITX_DRV_IMP_CLK | RG_HDMITX_DRV_IMP_D2 | 209 - RG_HDMITX_DRV_IMP_D1 | RG_HDMITX_DRV_IMP_D0); 210 - mtk_hdmi_phy_mask(hdmi_phy, HDMI_CON5, 211 - (hdmi_ibias << DRV_IBIAS_CLK_SHIFT) | 212 - (hdmi_ibias << DRV_IBIAS_D2_SHIFT) | 213 - (hdmi_ibias << DRV_IBIAS_D1_SHIFT) | 214 - (hdmi_ibias << DRV_IBIAS_D0_SHIFT), 215 - RG_HDMITX_DRV_IBIAS_CLK | 216 - RG_HDMITX_DRV_IBIAS_D2 | 217 - RG_HDMITX_DRV_IBIAS_D1 | 218 - RG_HDMITX_DRV_IBIAS_D0); 209 + mtk_phy_update_bits(base + HDMI_CON4, 210 + RG_HDMITX_PRD_IBIAS_CLK | RG_HDMITX_PRD_IBIAS_D2 | 211 + RG_HDMITX_PRD_IBIAS_D1 | RG_HDMITX_PRD_IBIAS_D0, 212 + FIELD_PREP(RG_HDMITX_PRD_IBIAS_CLK, pre_ibias) | 213 + FIELD_PREP(RG_HDMITX_PRD_IBIAS_D2, pre_ibias) | 214 + FIELD_PREP(RG_HDMITX_PRD_IBIAS_D1, pre_ibias) | 215 + FIELD_PREP(RG_HDMITX_PRD_IBIAS_D0, pre_ibias)); 216 + mtk_phy_update_field(base + HDMI_CON3, RG_HDMITX_DRV_IMP_EN, imp_en); 217 + mtk_phy_update_bits(base + HDMI_CON6, 218 + RG_HDMITX_DRV_IMP_CLK | RG_HDMITX_DRV_IMP_D2 | 219 + RG_HDMITX_DRV_IMP_D1 | RG_HDMITX_DRV_IMP_D0, 220 + FIELD_PREP(RG_HDMITX_DRV_IMP_CLK, hdmi_phy->drv_imp_clk) | 221 + FIELD_PREP(RG_HDMITX_DRV_IMP_D2, hdmi_phy->drv_imp_d2) | 222 + FIELD_PREP(RG_HDMITX_DRV_IMP_D1, hdmi_phy->drv_imp_d1) | 223 + FIELD_PREP(RG_HDMITX_DRV_IMP_D0, hdmi_phy->drv_imp_d0)); 224 + mtk_phy_update_bits(base + HDMI_CON5, 225 + RG_HDMITX_DRV_IBIAS_CLK | RG_HDMITX_DRV_IBIAS_D2 | 226 + RG_HDMITX_DRV_IBIAS_D1 | RG_HDMITX_DRV_IBIAS_D0, 227 + FIELD_PREP(RG_HDMITX_DRV_IBIAS_CLK, hdmi_ibias) | 228 + FIELD_PREP(RG_HDMITX_DRV_IBIAS_D2, hdmi_ibias) | 229 + FIELD_PREP(RG_HDMITX_DRV_IBIAS_D1, hdmi_ibias) | 230 + FIELD_PREP(RG_HDMITX_DRV_IBIAS_D0, hdmi_ibias)); 219 231 return 0; 220 232 } 221 233 ··· 229 257 230 258 static void mtk_hdmi_phy_enable_tmds(struct mtk_hdmi_phy *hdmi_phy) 231 259 { 232 - mtk_hdmi_phy_set_bits(hdmi_phy, HDMI_CON3, 233 - RG_HDMITX_SER_EN | RG_HDMITX_PRD_EN | 234 - RG_HDMITX_DRV_EN); 260 + mtk_phy_set_bits(hdmi_phy->regs + HDMI_CON3, 261 + RG_HDMITX_SER_EN | RG_HDMITX_PRD_EN | 262 + RG_HDMITX_DRV_EN); 235 263 usleep_range(100, 150); 236 264 } 237 265 238 266 static void mtk_hdmi_phy_disable_tmds(struct mtk_hdmi_phy *hdmi_phy) 239 267 { 240 - mtk_hdmi_phy_clear_bits(hdmi_phy, HDMI_CON3, 241 - RG_HDMITX_DRV_EN | RG_HDMITX_PRD_EN | 242 - RG_HDMITX_SER_EN); 268 + mtk_phy_clear_bits(hdmi_phy->regs + HDMI_CON3, 269 + RG_HDMITX_DRV_EN | RG_HDMITX_PRD_EN | 270 + RG_HDMITX_SER_EN); 243 271 } 244 272 245 273 struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf = {
-33
drivers/phy/mediatek/phy-mtk-hdmi.c
··· 15 15 .owner = THIS_MODULE, 16 16 }; 17 17 18 - void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 19 - u32 bits) 20 - { 21 - void __iomem *reg = hdmi_phy->regs + offset; 22 - u32 tmp; 23 - 24 - tmp = readl(reg); 25 - tmp &= ~bits; 26 - writel(tmp, reg); 27 - } 28 - 29 - void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 30 - u32 bits) 31 - { 32 - void __iomem *reg = hdmi_phy->regs + offset; 33 - u32 tmp; 34 - 35 - tmp = readl(reg); 36 - tmp |= bits; 37 - writel(tmp, reg); 38 - } 39 - 40 - void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 41 - u32 val, u32 mask) 42 - { 43 - void __iomem *reg = hdmi_phy->regs + offset; 44 - u32 tmp; 45 - 46 - tmp = readl(reg); 47 - tmp = (tmp & ~mask) | (val & mask); 48 - writel(tmp, reg); 49 - } 50 - 51 18 inline struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw) 52 19 { 53 20 return container_of(hw, struct mtk_hdmi_phy, pll_hw);
-7
drivers/phy/mediatek/phy-mtk-hdmi.h
··· 9 9 #include <linux/clk.h> 10 10 #include <linux/clk-provider.h> 11 11 #include <linux/delay.h> 12 - #include <linux/io.h> 13 12 #include <linux/mfd/syscon.h> 14 13 #include <linux/module.h> 15 14 #include <linux/of_device.h> ··· 41 42 unsigned int ibias_up; 42 43 }; 43 44 44 - void mtk_hdmi_phy_clear_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 45 - u32 bits); 46 - void mtk_hdmi_phy_set_bits(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 47 - u32 bits); 48 - void mtk_hdmi_phy_mask(struct mtk_hdmi_phy *hdmi_phy, u32 offset, 49 - u32 val, u32 mask); 50 45 struct mtk_hdmi_phy *to_mtk_hdmi_phy(struct clk_hw *hw); 51 46 52 47 extern struct mtk_hdmi_phy_conf mtk_hdmi_phy_8173_conf;
+8
drivers/phy/mediatek/phy-mtk-io.h
··· 8 8 #ifndef __PHY_MTK_H__ 9 9 #define __PHY_MTK_H__ 10 10 11 + #include <linux/bitfield.h> 11 12 #include <linux/io.h> 12 13 13 14 static inline void mtk_phy_clear_bits(void __iomem *reg, u32 bits) ··· 35 34 tmp |= val & mask; 36 35 writel(tmp, reg); 37 36 } 37 + 38 + /* field @mask shall be constant and continuous */ 39 + #define mtk_phy_update_field(reg, mask, val) \ 40 + ({ \ 41 + typeof(mask) mask_ = (mask); \ 42 + mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ 43 + }) 38 44 39 45 #endif
+84 -80
drivers/phy/mediatek/phy-mtk-mipi-dsi-mt8173.c
··· 4 4 * Author: jitao.shi <jitao.shi@mediatek.com> 5 5 */ 6 6 7 + #include "phy-mtk-io.h" 7 8 #include "phy-mtk-mipi-dsi.h" 8 9 9 10 #define MIPITX_DSI_CON 0x00 10 11 #define RG_DSI_LDOCORE_EN BIT(0) 11 12 #define RG_DSI_CKG_LDOOUT_EN BIT(1) 12 - #define RG_DSI_BCLK_SEL (3 << 2) 13 - #define RG_DSI_LD_IDX_SEL (7 << 4) 14 - #define RG_DSI_PHYCLK_SEL (2 << 8) 13 + #define RG_DSI_BCLK_SEL GENMASK(3, 2) 14 + #define RG_DSI_LD_IDX_SEL GENMASK(6, 4) 15 + #define RG_DSI_PHYCLK_SEL GENMASK(9, 8) 15 16 #define RG_DSI_DSICLK_FREQ_SEL BIT(10) 16 17 #define RG_DSI_LPTX_CLMP_EN BIT(11) 17 18 ··· 28 27 #define RG_DSI_LNTx_LPTX_IMINUS BIT(4) 29 28 #define RG_DSI_LNTx_LPCD_IPLUS BIT(5) 30 29 #define RG_DSI_LNTx_LPCD_IMINUS BIT(6) 31 - #define RG_DSI_LNTx_RT_CODE (0xf << 8) 30 + #define RG_DSI_LNTx_RT_CODE GENMASK(11, 8) 32 31 33 32 #define MIPITX_DSI_TOP_CON 0x40 34 33 #define RG_DSI_LNT_INTR_EN BIT(0) 35 34 #define RG_DSI_LNT_HS_BIAS_EN BIT(1) 36 35 #define RG_DSI_LNT_IMP_CAL_EN BIT(2) 37 36 #define RG_DSI_LNT_TESTMODE_EN BIT(3) 38 - #define RG_DSI_LNT_IMP_CAL_CODE (0xf << 4) 39 - #define RG_DSI_LNT_AIO_SEL (7 << 8) 37 + #define RG_DSI_LNT_IMP_CAL_CODE GENMASK(7, 4) 38 + #define RG_DSI_LNT_AIO_SEL GENMASK(10, 8) 40 39 #define RG_DSI_PAD_TIE_LOW_EN BIT(11) 41 40 #define RG_DSI_DEBUG_INPUT_EN BIT(12) 42 - #define RG_DSI_PRESERVE (7 << 13) 41 + #define RG_DSI_PRESERVE GENMASK(15, 13) 43 42 44 43 #define MIPITX_DSI_BG_CON 0x44 45 44 #define RG_DSI_BG_CORE_EN BIT(0) 46 45 #define RG_DSI_BG_CKEN BIT(1) 47 - #define RG_DSI_BG_DIV (0x3 << 2) 46 + #define RG_DSI_BG_DIV GENMASK(3, 2) 48 47 #define RG_DSI_BG_FAST_CHARGE BIT(4) 49 - #define RG_DSI_VOUT_MSK (0x3ffff << 5) 50 - #define RG_DSI_V12_SEL (7 << 5) 51 - #define RG_DSI_V10_SEL (7 << 8) 52 - #define RG_DSI_V072_SEL (7 << 11) 53 - #define RG_DSI_V04_SEL (7 << 14) 54 - #define RG_DSI_V032_SEL (7 << 17) 55 - #define RG_DSI_V02_SEL (7 << 20) 56 - #define RG_DSI_BG_R1_TRIM (0xf << 24) 57 - #define RG_DSI_BG_R2_TRIM (0xf << 28) 48 + 49 + #define RG_DSI_V12_SEL GENMASK(7, 5) 50 + #define RG_DSI_V10_SEL GENMASK(10, 8) 51 + #define RG_DSI_V072_SEL GENMASK(13, 11) 52 + #define RG_DSI_V04_SEL GENMASK(16, 14) 53 + #define RG_DSI_V032_SEL GENMASK(19, 17) 54 + #define RG_DSI_V02_SEL GENMASK(22, 20) 55 + #define RG_DSI_VOUT_MSK \ 56 + (RG_DSI_V12_SEL | RG_DSI_V10_SEL | RG_DSI_V072_SEL | \ 57 + RG_DSI_V04_SEL | RG_DSI_V032_SEL | RG_DSI_V02_SEL) 58 + #define RG_DSI_BG_R1_TRIM GENMASK(27, 24) 59 + #define RG_DSI_BG_R2_TRIM GENMASK(31, 28) 58 60 59 61 #define MIPITX_DSI_PLL_CON0 0x50 60 62 #define RG_DSI_MPPLL_PLL_EN BIT(0) 61 - #define RG_DSI_MPPLL_DIV_MSK (0x1ff << 1) 62 - #define RG_DSI_MPPLL_PREDIV (3 << 1) 63 - #define RG_DSI_MPPLL_TXDIV0 (3 << 3) 64 - #define RG_DSI_MPPLL_TXDIV1 (3 << 5) 65 - #define RG_DSI_MPPLL_POSDIV (7 << 7) 63 + #define RG_DSI_MPPLL_PREDIV GENMASK(2, 1) 64 + #define RG_DSI_MPPLL_TXDIV0 GENMASK(4, 3) 65 + #define RG_DSI_MPPLL_TXDIV1 GENMASK(6, 5) 66 + #define RG_DSI_MPPLL_POSDIV GENMASK(9, 7) 67 + #define RG_DSI_MPPLL_DIV_MSK \ 68 + (RG_DSI_MPPLL_PREDIV | RG_DSI_MPPLL_TXDIV0 | \ 69 + RG_DSI_MPPLL_TXDIV1 | RG_DSI_MPPLL_POSDIV) 66 70 #define RG_DSI_MPPLL_MONVC_EN BIT(10) 67 71 #define RG_DSI_MPPLL_MONREF_EN BIT(11) 68 72 #define RG_DSI_MPPLL_VOD_EN BIT(12) ··· 76 70 #define RG_DSI_MPPLL_SDM_FRA_EN BIT(0) 77 71 #define RG_DSI_MPPLL_SDM_SSC_PH_INIT BIT(1) 78 72 #define RG_DSI_MPPLL_SDM_SSC_EN BIT(2) 79 - #define RG_DSI_MPPLL_SDM_SSC_PRD (0xffff << 16) 73 + #define RG_DSI_MPPLL_SDM_SSC_PRD GENMASK(31, 16) 80 74 81 75 #define MIPITX_DSI_PLL_CON2 0x58 82 76 83 77 #define MIPITX_DSI_PLL_TOP 0x64 84 - #define RG_DSI_MPPLL_PRESERVE (0xff << 8) 78 + #define RG_DSI_MPPLL_PRESERVE GENMASK(15, 8) 85 79 86 80 #define MIPITX_DSI_PLL_PWR 0x68 87 81 #define RG_DSI_MPPLL_SDM_PWR_ON BIT(0) ··· 122 116 static int mtk_mipi_tx_pll_prepare(struct clk_hw *hw) 123 117 { 124 118 struct mtk_mipi_tx *mipi_tx = mtk_mipi_tx_from_clk_hw(hw); 119 + void __iomem *base = mipi_tx->regs; 125 120 u8 txdiv, txdiv0, txdiv1; 126 121 u64 pcw; 127 122 ··· 152 145 return -EINVAL; 153 146 } 154 147 155 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_BG_CON, 156 - RG_DSI_VOUT_MSK | 157 - RG_DSI_BG_CKEN | RG_DSI_BG_CORE_EN, 158 - (4 << 20) | (4 << 17) | (4 << 14) | 159 - (4 << 11) | (4 << 8) | (4 << 5) | 160 - RG_DSI_BG_CKEN | RG_DSI_BG_CORE_EN); 148 + mtk_phy_update_bits(base + MIPITX_DSI_BG_CON, 149 + RG_DSI_VOUT_MSK | RG_DSI_BG_CKEN | 150 + RG_DSI_BG_CORE_EN, 151 + FIELD_PREP(RG_DSI_V02_SEL, 4) | 152 + FIELD_PREP(RG_DSI_V032_SEL, 4) | 153 + FIELD_PREP(RG_DSI_V04_SEL, 4) | 154 + FIELD_PREP(RG_DSI_V072_SEL, 4) | 155 + FIELD_PREP(RG_DSI_V10_SEL, 4) | 156 + FIELD_PREP(RG_DSI_V12_SEL, 4) | 157 + RG_DSI_BG_CKEN | RG_DSI_BG_CORE_EN); 161 158 162 159 usleep_range(30, 100); 163 160 164 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_TOP_CON, 165 - RG_DSI_LNT_IMP_CAL_CODE | RG_DSI_LNT_HS_BIAS_EN, 166 - (8 << 4) | RG_DSI_LNT_HS_BIAS_EN); 161 + mtk_phy_update_bits(base + MIPITX_DSI_TOP_CON, 162 + RG_DSI_LNT_IMP_CAL_CODE | RG_DSI_LNT_HS_BIAS_EN, 163 + FIELD_PREP(RG_DSI_LNT_IMP_CAL_CODE, 8) | 164 + RG_DSI_LNT_HS_BIAS_EN); 167 165 168 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_DSI_CON, 169 - RG_DSI_CKG_LDOOUT_EN | RG_DSI_LDOCORE_EN); 166 + mtk_phy_set_bits(base + MIPITX_DSI_CON, 167 + RG_DSI_CKG_LDOOUT_EN | RG_DSI_LDOCORE_EN); 170 168 171 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_PLL_PWR, 172 - RG_DSI_MPPLL_SDM_PWR_ON | 173 - RG_DSI_MPPLL_SDM_ISO_EN, 174 - RG_DSI_MPPLL_SDM_PWR_ON); 169 + mtk_phy_update_bits(base + MIPITX_DSI_PLL_PWR, 170 + RG_DSI_MPPLL_SDM_PWR_ON | RG_DSI_MPPLL_SDM_ISO_EN, 171 + RG_DSI_MPPLL_SDM_PWR_ON); 175 172 176 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_PLL_CON0, 177 - RG_DSI_MPPLL_PLL_EN); 173 + mtk_phy_clear_bits(base + MIPITX_DSI_PLL_CON0, RG_DSI_MPPLL_PLL_EN); 178 174 179 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_PLL_CON0, 180 - RG_DSI_MPPLL_TXDIV0 | RG_DSI_MPPLL_TXDIV1 | 181 - RG_DSI_MPPLL_PREDIV, 182 - (txdiv0 << 3) | (txdiv1 << 5)); 175 + mtk_phy_update_bits(base + MIPITX_DSI_PLL_CON0, 176 + RG_DSI_MPPLL_TXDIV0 | RG_DSI_MPPLL_TXDIV1 | 177 + RG_DSI_MPPLL_PREDIV, 178 + FIELD_PREP(RG_DSI_MPPLL_TXDIV0, txdiv0) | 179 + FIELD_PREP(RG_DSI_MPPLL_TXDIV1, txdiv1)); 183 180 184 181 /* 185 182 * PLL PCW config ··· 193 182 * Post DIV =4, so need data_Rate*4 194 183 * Ref_clk is 26MHz 195 184 */ 196 - pcw = div_u64(((u64)mipi_tx->data_rate * 2 * txdiv) << 24, 197 - 26000000); 198 - writel(pcw, mipi_tx->regs + MIPITX_DSI_PLL_CON2); 185 + pcw = div_u64(((u64)mipi_tx->data_rate * 2 * txdiv) << 24, 26000000); 186 + writel(pcw, base + MIPITX_DSI_PLL_CON2); 199 187 200 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_DSI_PLL_CON1, 201 - RG_DSI_MPPLL_SDM_FRA_EN); 188 + mtk_phy_set_bits(base + MIPITX_DSI_PLL_CON1, RG_DSI_MPPLL_SDM_FRA_EN); 202 189 203 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_DSI_PLL_CON0, RG_DSI_MPPLL_PLL_EN); 190 + mtk_phy_set_bits(base + MIPITX_DSI_PLL_CON0, RG_DSI_MPPLL_PLL_EN); 204 191 205 192 usleep_range(20, 100); 206 193 207 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_PLL_CON1, 208 - RG_DSI_MPPLL_SDM_SSC_EN); 194 + mtk_phy_clear_bits(base + MIPITX_DSI_PLL_CON1, RG_DSI_MPPLL_SDM_SSC_EN); 209 195 210 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_PLL_TOP, 211 - RG_DSI_MPPLL_PRESERVE, 212 - mipi_tx->driver_data->mppll_preserve); 196 + mtk_phy_update_field(base + MIPITX_DSI_PLL_TOP, 197 + RG_DSI_MPPLL_PRESERVE, 198 + mipi_tx->driver_data->mppll_preserve); 213 199 214 200 return 0; 215 201 } ··· 214 206 static void mtk_mipi_tx_pll_unprepare(struct clk_hw *hw) 215 207 { 216 208 struct mtk_mipi_tx *mipi_tx = mtk_mipi_tx_from_clk_hw(hw); 209 + void __iomem *base = mipi_tx->regs; 217 210 218 211 dev_dbg(mipi_tx->dev, "unprepare\n"); 219 212 220 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_PLL_CON0, 221 - RG_DSI_MPPLL_PLL_EN); 213 + mtk_phy_clear_bits(base + MIPITX_DSI_PLL_CON0, RG_DSI_MPPLL_PLL_EN); 222 214 223 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_PLL_TOP, 224 - RG_DSI_MPPLL_PRESERVE, 0); 215 + mtk_phy_clear_bits(base + MIPITX_DSI_PLL_TOP, RG_DSI_MPPLL_PRESERVE); 225 216 226 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_DSI_PLL_PWR, 227 - RG_DSI_MPPLL_SDM_ISO_EN | 228 - RG_DSI_MPPLL_SDM_PWR_ON, 229 - RG_DSI_MPPLL_SDM_ISO_EN); 217 + mtk_phy_update_bits(base + MIPITX_DSI_PLL_PWR, 218 + RG_DSI_MPPLL_SDM_ISO_EN | RG_DSI_MPPLL_SDM_PWR_ON, 219 + RG_DSI_MPPLL_SDM_ISO_EN); 230 220 231 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_TOP_CON, 232 - RG_DSI_LNT_HS_BIAS_EN); 221 + mtk_phy_clear_bits(base + MIPITX_DSI_TOP_CON, RG_DSI_LNT_HS_BIAS_EN); 233 222 234 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_CON, 235 - RG_DSI_CKG_LDOOUT_EN | RG_DSI_LDOCORE_EN); 223 + mtk_phy_clear_bits(base + MIPITX_DSI_CON, 224 + RG_DSI_CKG_LDOOUT_EN | RG_DSI_LDOCORE_EN); 236 225 237 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_BG_CON, 238 - RG_DSI_BG_CKEN | RG_DSI_BG_CORE_EN); 226 + mtk_phy_clear_bits(base + MIPITX_DSI_BG_CON, 227 + RG_DSI_BG_CKEN | RG_DSI_BG_CORE_EN); 239 228 240 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_PLL_CON0, 241 - RG_DSI_MPPLL_DIV_MSK); 229 + mtk_phy_clear_bits(base + MIPITX_DSI_PLL_CON0, RG_DSI_MPPLL_DIV_MSK); 242 230 } 243 231 244 232 static long mtk_mipi_tx_pll_round_rate(struct clk_hw *hw, unsigned long rate, ··· 258 254 259 255 for (reg = MIPITX_DSI_CLOCK_LANE; 260 256 reg <= MIPITX_DSI_DATA_LANE3; reg += 4) 261 - mtk_mipi_tx_set_bits(mipi_tx, reg, RG_DSI_LNTx_LDOOUT_EN); 257 + mtk_phy_set_bits(mipi_tx->regs + reg, RG_DSI_LNTx_LDOOUT_EN); 262 258 263 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_DSI_TOP_CON, 264 - RG_DSI_PAD_TIE_LOW_EN); 259 + mtk_phy_clear_bits(mipi_tx->regs + MIPITX_DSI_TOP_CON, 260 + RG_DSI_PAD_TIE_LOW_EN); 265 261 } 266 262 267 263 static void mtk_mipi_tx_power_off_signal(struct phy *phy) ··· 269 265 struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy); 270 266 u32 reg; 271 267 272 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_DSI_TOP_CON, 273 - RG_DSI_PAD_TIE_LOW_EN); 268 + mtk_phy_set_bits(mipi_tx->regs + MIPITX_DSI_TOP_CON, 269 + RG_DSI_PAD_TIE_LOW_EN); 274 270 275 271 for (reg = MIPITX_DSI_CLOCK_LANE; 276 272 reg <= MIPITX_DSI_DATA_LANE3; reg += 4) 277 - mtk_mipi_tx_clear_bits(mipi_tx, reg, RG_DSI_LNTx_LDOOUT_EN); 273 + mtk_phy_clear_bits(mipi_tx->regs + reg, RG_DSI_LNTx_LDOOUT_EN); 278 274 } 279 275 280 276 const struct mtk_mipitx_data mt2701_mipitx_data = { 281 - .mppll_preserve = (3 << 8), 277 + .mppll_preserve = 3, 282 278 .mipi_tx_clk_ops = &mtk_mipi_tx_pll_ops, 283 279 .mipi_tx_enable_signal = mtk_mipi_tx_power_on_signal, 284 280 .mipi_tx_disable_signal = mtk_mipi_tx_power_off_signal, 285 281 }; 286 282 287 283 const struct mtk_mipitx_data mt8173_mipitx_data = { 288 - .mppll_preserve = (0 << 8), 284 + .mppll_preserve = 0, 289 285 .mipi_tx_clk_ops = &mtk_mipi_tx_pll_ops, 290 286 .mipi_tx_enable_signal = mtk_mipi_tx_power_on_signal, 291 287 .mipi_tx_disable_signal = mtk_mipi_tx_power_off_signal,
+36 -36
drivers/phy/mediatek/phy-mtk-mipi-dsi-mt8183.c
··· 4 4 * Author: jitao.shi <jitao.shi@mediatek.com> 5 5 */ 6 6 7 + #include "phy-mtk-io.h" 7 8 #include "phy-mtk-mipi-dsi.h" 8 9 9 10 #define MIPITX_LANE_CON 0x000c ··· 19 18 #define RG_DSI_PAD_TIEL_SEL BIT(8) 20 19 21 20 #define MIPITX_VOLTAGE_SEL 0x0010 22 - #define RG_DSI_HSTX_LDO_REF_SEL (0xf << 6) 21 + #define RG_DSI_HSTX_LDO_REF_SEL GENMASK(9, 6) 23 22 24 23 #define MIPITX_PLL_PWR 0x0028 25 24 #define MIPITX_PLL_CON0 0x002c ··· 27 26 #define MIPITX_PLL_CON2 0x0034 28 27 #define MIPITX_PLL_CON3 0x0038 29 28 #define MIPITX_PLL_CON4 0x003c 30 - #define RG_DSI_PLL_IBIAS (3 << 10) 29 + #define RG_DSI_PLL_IBIAS GENMASK(11, 10) 31 30 32 31 #define MIPITX_D2P_RTCODE 0x0100 33 32 #define MIPITX_D2_SW_CTL_EN 0x0144 ··· 42 41 #define AD_DSI_PLL_SDM_ISO_EN BIT(1) 43 42 44 43 #define RG_DSI_PLL_EN BIT(4) 45 - #define RG_DSI_PLL_POSDIV (0x7 << 8) 44 + #define RG_DSI_PLL_POSDIV GENMASK(10, 8) 46 45 47 46 static int mtk_mipi_tx_pll_enable(struct clk_hw *hw) 48 47 { 49 48 struct mtk_mipi_tx *mipi_tx = mtk_mipi_tx_from_clk_hw(hw); 49 + void __iomem *base = mipi_tx->regs; 50 50 unsigned int txdiv, txdiv0; 51 51 u64 pcw; 52 52 ··· 72 70 return -EINVAL; 73 71 } 74 72 75 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_PLL_CON4, RG_DSI_PLL_IBIAS); 73 + mtk_phy_clear_bits(base + MIPITX_PLL_CON4, RG_DSI_PLL_IBIAS); 76 74 77 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_PLL_PWR, AD_DSI_PLL_SDM_PWR_ON); 78 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_PLL_CON1, RG_DSI_PLL_EN); 75 + mtk_phy_set_bits(base + MIPITX_PLL_PWR, AD_DSI_PLL_SDM_PWR_ON); 76 + mtk_phy_clear_bits(base + MIPITX_PLL_CON1, RG_DSI_PLL_EN); 79 77 udelay(1); 80 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_PLL_PWR, AD_DSI_PLL_SDM_ISO_EN); 78 + mtk_phy_clear_bits(base + MIPITX_PLL_PWR, AD_DSI_PLL_SDM_ISO_EN); 81 79 pcw = div_u64(((u64)mipi_tx->data_rate * txdiv) << 24, 26000000); 82 - writel(pcw, mipi_tx->regs + MIPITX_PLL_CON0); 83 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_PLL_CON1, RG_DSI_PLL_POSDIV, 84 - txdiv0 << 8); 85 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_PLL_CON1, RG_DSI_PLL_EN); 80 + writel(pcw, base + MIPITX_PLL_CON0); 81 + mtk_phy_update_field(base + MIPITX_PLL_CON1, RG_DSI_PLL_POSDIV, txdiv0); 82 + mtk_phy_set_bits(base + MIPITX_PLL_CON1, RG_DSI_PLL_EN); 86 83 87 84 return 0; 88 85 } ··· 89 88 static void mtk_mipi_tx_pll_disable(struct clk_hw *hw) 90 89 { 91 90 struct mtk_mipi_tx *mipi_tx = mtk_mipi_tx_from_clk_hw(hw); 91 + void __iomem *base = mipi_tx->regs; 92 92 93 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_PLL_CON1, RG_DSI_PLL_EN); 93 + mtk_phy_clear_bits(base + MIPITX_PLL_CON1, RG_DSI_PLL_EN); 94 94 95 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_PLL_PWR, AD_DSI_PLL_SDM_ISO_EN); 96 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_PLL_PWR, AD_DSI_PLL_SDM_PWR_ON); 95 + mtk_phy_set_bits(base + MIPITX_PLL_PWR, AD_DSI_PLL_SDM_ISO_EN); 96 + mtk_phy_clear_bits(base + MIPITX_PLL_PWR, AD_DSI_PLL_SDM_PWR_ON); 97 97 } 98 98 99 99 static long mtk_mipi_tx_pll_round_rate(struct clk_hw *hw, unsigned long rate, ··· 123 121 mipi_tx->rt_code[i] |= 0x10 << 5; 124 122 125 123 for (j = 0; j < 10; j++) 126 - mtk_mipi_tx_update_bits(mipi_tx, 124 + mtk_phy_update_bits(mipi_tx->regs + 127 125 MIPITX_D2P_RTCODE * (i + 1) + j * 4, 128 126 1, mipi_tx->rt_code[i] >> j & 1); 129 127 } ··· 132 130 static void mtk_mipi_tx_power_on_signal(struct phy *phy) 133 131 { 134 132 struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy); 133 + void __iomem *base = mipi_tx->regs; 135 134 136 135 /* BG_LPF_EN / BG_CORE_EN */ 137 - writel(RG_DSI_PAD_TIEL_SEL | RG_DSI_BG_CORE_EN, 138 - mipi_tx->regs + MIPITX_LANE_CON); 136 + writel(RG_DSI_PAD_TIEL_SEL | RG_DSI_BG_CORE_EN, base + MIPITX_LANE_CON); 139 137 usleep_range(30, 100); 140 - writel(RG_DSI_BG_CORE_EN | RG_DSI_BG_LPF_EN, 141 - mipi_tx->regs + MIPITX_LANE_CON); 138 + writel(RG_DSI_BG_CORE_EN | RG_DSI_BG_LPF_EN, base + MIPITX_LANE_CON); 142 139 143 140 /* Switch OFF each Lane */ 144 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_D0_SW_CTL_EN, DSI_SW_CTL_EN); 145 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_D1_SW_CTL_EN, DSI_SW_CTL_EN); 146 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_D2_SW_CTL_EN, DSI_SW_CTL_EN); 147 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_D3_SW_CTL_EN, DSI_SW_CTL_EN); 148 - mtk_mipi_tx_clear_bits(mipi_tx, MIPITX_CK_SW_CTL_EN, DSI_SW_CTL_EN); 141 + mtk_phy_clear_bits(base + MIPITX_D0_SW_CTL_EN, DSI_SW_CTL_EN); 142 + mtk_phy_clear_bits(base + MIPITX_D1_SW_CTL_EN, DSI_SW_CTL_EN); 143 + mtk_phy_clear_bits(base + MIPITX_D2_SW_CTL_EN, DSI_SW_CTL_EN); 144 + mtk_phy_clear_bits(base + MIPITX_D3_SW_CTL_EN, DSI_SW_CTL_EN); 145 + mtk_phy_clear_bits(base + MIPITX_CK_SW_CTL_EN, DSI_SW_CTL_EN); 149 146 150 - mtk_mipi_tx_update_bits(mipi_tx, MIPITX_VOLTAGE_SEL, 151 - RG_DSI_HSTX_LDO_REF_SEL, 152 - (mipi_tx->mipitx_drive - 3000) / 200 << 6); 147 + mtk_phy_update_field(base + MIPITX_VOLTAGE_SEL, RG_DSI_HSTX_LDO_REF_SEL, 148 + (mipi_tx->mipitx_drive - 3000) / 200); 153 149 154 150 mtk_mipi_tx_config_calibration_data(mipi_tx); 155 151 156 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN); 152 + mtk_phy_set_bits(base + MIPITX_CK_CKMODE_EN, DSI_CK_CKMODE_EN); 157 153 } 158 154 159 155 static void mtk_mipi_tx_power_off_signal(struct phy *phy) 160 156 { 161 157 struct mtk_mipi_tx *mipi_tx = phy_get_drvdata(phy); 158 + void __iomem *base = mipi_tx->regs; 162 159 163 160 /* Switch ON each Lane */ 164 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_D0_SW_CTL_EN, DSI_SW_CTL_EN); 165 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_D1_SW_CTL_EN, DSI_SW_CTL_EN); 166 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_D2_SW_CTL_EN, DSI_SW_CTL_EN); 167 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_D3_SW_CTL_EN, DSI_SW_CTL_EN); 168 - mtk_mipi_tx_set_bits(mipi_tx, MIPITX_CK_SW_CTL_EN, DSI_SW_CTL_EN); 161 + mtk_phy_set_bits(base + MIPITX_D0_SW_CTL_EN, DSI_SW_CTL_EN); 162 + mtk_phy_set_bits(base + MIPITX_D1_SW_CTL_EN, DSI_SW_CTL_EN); 163 + mtk_phy_set_bits(base + MIPITX_D2_SW_CTL_EN, DSI_SW_CTL_EN); 164 + mtk_phy_set_bits(base + MIPITX_D3_SW_CTL_EN, DSI_SW_CTL_EN); 165 + mtk_phy_set_bits(base + MIPITX_CK_SW_CTL_EN, DSI_SW_CTL_EN); 169 166 170 - writel(RG_DSI_PAD_TIEL_SEL | RG_DSI_BG_CORE_EN, 171 - mipi_tx->regs + MIPITX_LANE_CON); 172 - writel(RG_DSI_PAD_TIEL_SEL, mipi_tx->regs + MIPITX_LANE_CON); 167 + writel(RG_DSI_PAD_TIEL_SEL | RG_DSI_BG_CORE_EN, base + MIPITX_LANE_CON); 168 + writel(RG_DSI_PAD_TIEL_SEL, base + MIPITX_LANE_CON); 173 169 } 174 170 175 171 const struct mtk_mipitx_data mt8183_mipitx_data = {
-24
drivers/phy/mediatek/phy-mtk-mipi-dsi.c
··· 10 10 return container_of(hw, struct mtk_mipi_tx, pll_hw); 11 11 } 12 12 13 - void mtk_mipi_tx_clear_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, 14 - u32 bits) 15 - { 16 - u32 temp = readl(mipi_tx->regs + offset); 17 - 18 - writel(temp & ~bits, mipi_tx->regs + offset); 19 - } 20 - 21 - void mtk_mipi_tx_set_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, 22 - u32 bits) 23 - { 24 - u32 temp = readl(mipi_tx->regs + offset); 25 - 26 - writel(temp | bits, mipi_tx->regs + offset); 27 - } 28 - 29 - void mtk_mipi_tx_update_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, 30 - u32 mask, u32 data) 31 - { 32 - u32 temp = readl(mipi_tx->regs + offset); 33 - 34 - writel((temp & ~mask) | (data & mask), mipi_tx->regs + offset); 35 - } 36 - 37 13 int mtk_mipi_tx_pll_set_rate(struct clk_hw *hw, unsigned long rate, 38 14 unsigned long parent_rate) 39 15 {
-5
drivers/phy/mediatek/phy-mtk-mipi-dsi.h
··· 10 10 #include <linux/clk.h> 11 11 #include <linux/clk-provider.h> 12 12 #include <linux/delay.h> 13 - #include <linux/io.h> 14 13 #include <linux/module.h> 15 14 #include <linux/nvmem-consumer.h> 16 15 #include <linux/of_device.h> ··· 36 37 }; 37 38 38 39 struct mtk_mipi_tx *mtk_mipi_tx_from_clk_hw(struct clk_hw *hw); 39 - void mtk_mipi_tx_clear_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, u32 bits); 40 - void mtk_mipi_tx_set_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, u32 bits); 41 - void mtk_mipi_tx_update_bits(struct mtk_mipi_tx *mipi_tx, u32 offset, u32 mask, 42 - u32 data); 43 40 int mtk_mipi_tx_pll_set_rate(struct clk_hw *hw, unsigned long rate, 44 41 unsigned long parent_rate); 45 42 unsigned long mtk_mipi_tx_pll_recalc_rate(struct clk_hw *hw,
+8 -9
drivers/phy/mediatek/phy-mtk-pcie.c
··· 89 89 addr = pcie_phy->sif_base + PEXTP_ANA_LN0_TRX_REG + 90 90 lane * PEXTP_ANA_LANE_OFFSET; 91 91 92 - mtk_phy_update_bits(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_PMOS_SEL, 93 - FIELD_PREP(EFUSE_LN_TX_PMOS_SEL, data->tx_pmos)); 92 + mtk_phy_update_field(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_PMOS_SEL, 93 + data->tx_pmos); 94 94 95 - mtk_phy_update_bits(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_NMOS_SEL, 96 - FIELD_PREP(EFUSE_LN_TX_NMOS_SEL, data->tx_nmos)); 95 + mtk_phy_update_field(addr + PEXTP_ANA_TX_REG, EFUSE_LN_TX_NMOS_SEL, 96 + data->tx_nmos); 97 97 98 - mtk_phy_update_bits(addr + PEXTP_ANA_RX_REG, EFUSE_LN_RX_SEL, 99 - FIELD_PREP(EFUSE_LN_RX_SEL, data->rx_data)); 98 + mtk_phy_update_field(addr + PEXTP_ANA_RX_REG, EFUSE_LN_RX_SEL, 99 + data->rx_data); 100 100 } 101 101 102 102 /** ··· 116 116 return 0; 117 117 118 118 /* Set global data */ 119 - mtk_phy_update_bits(pcie_phy->sif_base + PEXTP_ANA_GLB_00_REG, 120 - EFUSE_GLB_INTR_SEL, 121 - FIELD_PREP(EFUSE_GLB_INTR_SEL, pcie_phy->efuse_glb_intr)); 119 + mtk_phy_update_field(pcie_phy->sif_base + PEXTP_ANA_GLB_00_REG, 120 + EFUSE_GLB_INTR_SEL, pcie_phy->efuse_glb_intr); 122 121 123 122 for (i = 0; i < pcie_phy->data->num_lanes; i++) 124 123 mtk_pcie_efuse_set_lane(pcie_phy, i);
+87 -136
drivers/phy/mediatek/phy-mtk-tphy.c
··· 49 49 #define U3P_USBPHYACR0 0x000 50 50 #define PA0_RG_U2PLL_FORCE_ON BIT(15) 51 51 #define PA0_USB20_PLL_PREDIV GENMASK(7, 6) 52 - #define PA0_USB20_PLL_PREDIV_VAL(x) ((0x3 & (x)) << 6) 53 52 #define PA0_RG_USB20_INTR_EN BIT(5) 54 53 55 54 #define U3P_USBPHYACR1 0x004 56 55 #define PA1_RG_INTR_CAL GENMASK(23, 19) 57 - #define PA1_RG_INTR_CAL_VAL(x) ((0x1f & (x)) << 19) 58 56 #define PA1_RG_VRT_SEL GENMASK(14, 12) 59 - #define PA1_RG_VRT_SEL_VAL(x) ((0x7 & (x)) << 12) 60 57 #define PA1_RG_TERM_SEL GENMASK(10, 8) 61 - #define PA1_RG_TERM_SEL_VAL(x) ((0x7 & (x)) << 8) 62 58 63 59 #define U3P_USBPHYACR2 0x008 64 60 #define PA2_RG_U2PLL_BW GENMASK(21, 19) 65 - #define PA2_RG_U2PLL_BW_VAL(x) ((0x7 & (x)) << 19) 66 61 #define PA2_RG_SIF_U2PLL_FORCE_EN BIT(18) 67 62 68 63 #define U3P_USBPHYACR5 0x014 69 64 #define PA5_RG_U2_HSTX_SRCAL_EN BIT(15) 70 65 #define PA5_RG_U2_HSTX_SRCTRL GENMASK(14, 12) 71 - #define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 & (x)) << 12) 72 66 #define PA5_RG_U2_HS_100U_U3_EN BIT(11) 73 67 74 68 #define U3P_USBPHYACR6 0x018 69 + #define PA6_RG_U2_PRE_EMP GENMASK(31, 30) 75 70 #define PA6_RG_U2_BC11_SW_EN BIT(23) 76 71 #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) 77 72 #define PA6_RG_U2_DISCTH GENMASK(7, 4) 78 - #define PA6_RG_U2_DISCTH_VAL(x) ((0xf & (x)) << 4) 79 73 #define PA6_RG_U2_SQTH GENMASK(3, 0) 80 - #define PA6_RG_U2_SQTH_VAL(x) (0xf & (x)) 81 74 82 75 #define U3P_U2PHYACR4 0x020 83 76 #define P2C_RG_USB20_GPIO_CTL BIT(9) ··· 97 104 #define P2C_FORCE_SUSPENDM BIT(18) 98 105 #define P2C_FORCE_TERMSEL BIT(17) 99 106 #define P2C_RG_DATAIN GENMASK(13, 10) 100 - #define P2C_RG_DATAIN_VAL(x) ((0xf & (x)) << 10) 101 107 #define P2C_RG_DMPULLDOWN BIT(7) 102 108 #define P2C_RG_DPPULLDOWN BIT(6) 103 109 #define P2C_RG_XCVRSEL GENMASK(5, 4) 104 - #define P2C_RG_XCVRSEL_VAL(x) ((0x3 & (x)) << 4) 105 110 #define P2C_RG_SUSPENDM BIT(3) 106 111 #define P2C_RG_TERMSEL BIT(2) 107 112 #define P2C_DTM0_PART_MASK \ ··· 130 139 131 140 #define U3P_U3_PHYA_REG0 0x000 132 141 #define P3A_RG_IEXT_INTR GENMASK(15, 10) 133 - #define P3A_RG_IEXT_INTR_VAL(x) ((0x3f & (x)) << 10) 134 142 #define P3A_RG_CLKDRV_OFF GENMASK(3, 2) 135 - #define P3A_RG_CLKDRV_OFF_VAL(x) ((0x3 & (x)) << 2) 136 143 137 144 #define U3P_U3_PHYA_REG1 0x004 138 145 #define P3A_RG_CLKDRV_AMP GENMASK(31, 29) 139 - #define P3A_RG_CLKDRV_AMP_VAL(x) ((0x7 & (x)) << 29) 140 146 141 147 #define U3P_U3_PHYA_REG6 0x018 142 148 #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) 143 - #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) 144 149 145 150 #define U3P_U3_PHYA_REG9 0x024 146 151 #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) 147 - #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) 148 152 149 153 #define U3P_U3_PHYA_DA_REG0 0x100 150 154 #define P3A_RG_XTAL_EXT_PE2H GENMASK(17, 16) 151 - #define P3A_RG_XTAL_EXT_PE2H_VAL(x) ((0x3 & (x)) << 16) 152 155 #define P3A_RG_XTAL_EXT_PE1H GENMASK(13, 12) 153 - #define P3A_RG_XTAL_EXT_PE1H_VAL(x) ((0x3 & (x)) << 12) 154 156 #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) 155 - #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) 156 157 157 158 #define U3P_U3_PHYA_DA_REG4 0x108 158 159 #define P3A_RG_PLL_DIVEN_PE2H GENMASK(21, 19) 159 160 #define P3A_RG_PLL_BC_PE2H GENMASK(7, 6) 160 - #define P3A_RG_PLL_BC_PE2H_VAL(x) ((0x3 & (x)) << 6) 161 161 162 162 #define U3P_U3_PHYA_DA_REG5 0x10c 163 163 #define P3A_RG_PLL_BR_PE2H GENMASK(29, 28) 164 - #define P3A_RG_PLL_BR_PE2H_VAL(x) ((0x3 & (x)) << 28) 165 164 #define P3A_RG_PLL_IC_PE2H GENMASK(15, 12) 166 - #define P3A_RG_PLL_IC_PE2H_VAL(x) ((0xf & (x)) << 12) 167 165 168 166 #define U3P_U3_PHYA_DA_REG6 0x110 169 167 #define P3A_RG_PLL_IR_PE2H GENMASK(19, 16) 170 - #define P3A_RG_PLL_IR_PE2H_VAL(x) ((0xf & (x)) << 16) 171 168 172 169 #define U3P_U3_PHYA_DA_REG7 0x114 173 170 #define P3A_RG_PLL_BP_PE2H GENMASK(19, 16) 174 - #define P3A_RG_PLL_BP_PE2H_VAL(x) ((0xf & (x)) << 16) 175 171 176 172 #define U3P_U3_PHYA_DA_REG20 0x13c 177 173 #define P3A_RG_PLL_DELTA1_PE2H GENMASK(31, 16) 178 - #define P3A_RG_PLL_DELTA1_PE2H_VAL(x) ((0xffff & (x)) << 16) 179 174 180 175 #define U3P_U3_PHYA_DA_REG25 0x148 181 176 #define P3A_RG_PLL_DELTA_PE2H GENMASK(15, 0) 182 - #define P3A_RG_PLL_DELTA_PE2H_VAL(x) (0xffff & (x)) 183 177 184 178 #define U3P_U3_PHYD_LFPS1 0x00c 185 179 #define P3D_RG_FWAKE_TH GENMASK(21, 16) 186 - #define P3D_RG_FWAKE_TH_VAL(x) ((0x3f & (x)) << 16) 187 180 188 181 #define U3P_U3_PHYD_IMPCAL0 0x010 189 182 #define P3D_RG_FORCE_TX_IMPEL BIT(31) 190 183 #define P3D_RG_TX_IMPEL GENMASK(28, 24) 191 - #define P3D_RG_TX_IMPEL_VAL(x) ((0x1f & (x)) << 24) 192 184 193 185 #define U3P_U3_PHYD_IMPCAL1 0x014 194 186 #define P3D_RG_FORCE_RX_IMPEL BIT(31) 195 187 #define P3D_RG_RX_IMPEL GENMASK(28, 24) 196 - #define P3D_RG_RX_IMPEL_VAL(x) ((0x1f & (x)) << 24) 197 188 198 189 #define U3P_U3_PHYD_RSV 0x054 199 190 #define P3D_RG_EFUSE_AUTO_LOAD_DIS BIT(12) 200 191 201 192 #define U3P_U3_PHYD_CDR1 0x05c 202 193 #define P3D_RG_CDR_BIR_LTD1 GENMASK(28, 24) 203 - #define P3D_RG_CDR_BIR_LTD1_VAL(x) ((0x1f & (x)) << 24) 204 194 #define P3D_RG_CDR_BIR_LTD0 GENMASK(12, 8) 205 - #define P3D_RG_CDR_BIR_LTD0_VAL(x) ((0x1f & (x)) << 8) 206 195 207 196 #define U3P_U3_PHYD_RXDET1 0x128 208 197 #define P3D_RG_RXDET_STB2_SET GENMASK(17, 9) 209 - #define P3D_RG_RXDET_STB2_SET_VAL(x) ((0x1ff & (x)) << 9) 210 198 211 199 #define U3P_U3_PHYD_RXDET2 0x12c 212 200 #define P3D_RG_RXDET_STB2_SET_P3 GENMASK(8, 0) 213 - #define P3D_RG_RXDET_STB2_SET_P3_VAL(x) (0x1ff & (x)) 214 201 215 202 #define U3P_SPLLC_XTALCTL3 0x018 216 203 #define XC3_RG_U3_XTAL_RX_PWD BIT(9) ··· 196 227 197 228 #define U3P_U2FREQ_FMCR0 0x00 198 229 #define P2F_RG_MONCLK_SEL GENMASK(27, 26) 199 - #define P2F_RG_MONCLK_SEL_VAL(x) ((0x3 & (x)) << 26) 200 230 #define P2F_RG_FREQDET_EN BIT(24) 201 231 #define P2F_RG_CYCLECNT GENMASK(23, 0) 202 - #define P2F_RG_CYCLECNT_VAL(x) ((P2F_RG_CYCLECNT) & (x)) 203 232 204 233 #define U3P_U2FREQ_VALUE 0x0c 205 234 ··· 214 247 #define PHYD_CTRL_SIGNAL_MODE4 0x1c 215 248 /* CDR Charge Pump P-path current adjustment */ 216 249 #define RG_CDR_BICLTD1_GEN1_MSK GENMASK(23, 20) 217 - #define RG_CDR_BICLTD1_GEN1_VAL(x) ((0xf & (x)) << 20) 218 250 #define RG_CDR_BICLTD0_GEN1_MSK GENMASK(11, 8) 219 - #define RG_CDR_BICLTD0_GEN1_VAL(x) ((0xf & (x)) << 8) 220 251 221 252 #define PHYD_DESIGN_OPTION2 0x24 222 253 /* Symbol lock count selection */ 223 254 #define RG_LOCK_CNT_SEL_MSK GENMASK(5, 4) 224 - #define RG_LOCK_CNT_SEL_VAL(x) ((0x3 & (x)) << 4) 225 255 226 256 #define PHYD_DESIGN_OPTION9 0x40 227 257 /* COMWAK GAP width window */ 228 258 #define RG_TG_MAX_MSK GENMASK(20, 16) 229 - #define RG_TG_MAX_VAL(x) ((0x1f & (x)) << 16) 230 259 /* COMINIT GAP width window */ 231 260 #define RG_T2_MAX_MSK GENMASK(13, 8) 232 - #define RG_T2_MAX_VAL(x) ((0x3f & (x)) << 8) 233 261 /* COMWAK GAP width window */ 234 262 #define RG_TG_MIN_MSK GENMASK(7, 5) 235 - #define RG_TG_MIN_VAL(x) ((0x7 & (x)) << 5) 236 263 /* COMINIT GAP width window */ 237 264 #define RG_T2_MIN_MSK GENMASK(4, 0) 238 - #define RG_T2_MIN_VAL(x) (0x1f & (x)) 239 265 240 266 #define ANA_RG_CTRL_SIGNAL1 0x4c 241 267 /* TX driver tail current control for 0dB de-empahsis mdoe for Gen1 speed */ 242 268 #define RG_IDRV_0DB_GEN1_MSK GENMASK(13, 8) 243 - #define RG_IDRV_0DB_GEN1_VAL(x) ((0x3f & (x)) << 8) 244 269 245 270 #define ANA_RG_CTRL_SIGNAL4 0x58 246 271 #define RG_CDR_BICLTR_GEN1_MSK GENMASK(23, 20) 247 - #define RG_CDR_BICLTR_GEN1_VAL(x) ((0xf & (x)) << 20) 248 272 /* Loop filter R1 resistance adjustment for Gen1 speed */ 249 273 #define RG_CDR_BR_GEN2_MSK GENMASK(10, 8) 250 - #define RG_CDR_BR_GEN2_VAL(x) ((0x7 & (x)) << 8) 251 274 252 275 #define ANA_RG_CTRL_SIGNAL6 0x60 253 276 /* I-path capacitance adjustment for Gen1 */ 254 277 #define RG_CDR_BC_GEN1_MSK GENMASK(28, 24) 255 - #define RG_CDR_BC_GEN1_VAL(x) ((0x1f & (x)) << 24) 256 278 #define RG_CDR_BIRLTR_GEN1_MSK GENMASK(4, 0) 257 - #define RG_CDR_BIRLTR_GEN1_VAL(x) (0x1f & (x)) 258 279 259 280 #define ANA_EQ_EYE_CTRL_SIGNAL1 0x6c 260 281 /* RX Gen1 LEQ tuning step */ 261 282 #define RG_EQ_DLEQ_LFI_GEN1_MSK GENMASK(11, 8) 262 - #define RG_EQ_DLEQ_LFI_GEN1_VAL(x) ((0xf & (x)) << 8) 263 283 264 284 #define ANA_EQ_EYE_CTRL_SIGNAL4 0xd8 265 285 #define RG_CDR_BIRLTD0_GEN1_MSK GENMASK(20, 16) 266 - #define RG_CDR_BIRLTD0_GEN1_VAL(x) ((0x1f & (x)) << 16) 267 286 268 287 #define ANA_EQ_EYE_CTRL_SIGNAL5 0xdc 269 288 #define RG_CDR_BIRLTD0_GEN3_MSK GENMASK(4, 0) 270 - #define RG_CDR_BIRLTD0_GEN3_VAL(x) (0x1f & (x)) 271 289 272 290 /* PHY switch between pcie/usb3/sgmii/sata */ 273 291 #define USB_PHY_SWITCH_CTRL 0x0 ··· 322 370 int eye_term; 323 371 int intr; 324 372 int discth; 373 + int pre_emphasis; 325 374 bool bc12_en; 326 375 }; 327 376 ··· 364 411 /* set cycle count as 1024, and select u2 channel */ 365 412 tmp = readl(fmreg + U3P_U2FREQ_FMCR0); 366 413 tmp &= ~(P2F_RG_CYCLECNT | P2F_RG_MONCLK_SEL); 367 - tmp |= P2F_RG_CYCLECNT_VAL(U3P_FM_DET_CYCLE_CNT); 414 + tmp |= FIELD_PREP(P2F_RG_CYCLECNT, U3P_FM_DET_CYCLE_CNT); 368 415 if (tphy->pdata->version == MTK_PHY_V1) 369 - tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index >> 1); 416 + tmp |= FIELD_PREP(P2F_RG_MONCLK_SEL, instance->index >> 1); 370 417 371 418 writel(tmp, fmreg + U3P_U2FREQ_FMCR0); 372 419 ··· 399 446 tphy->src_ref_clk, tphy->src_coef); 400 447 401 448 /* set HS slew rate */ 402 - mtk_phy_update_bits(com + U3P_USBPHYACR5, PA5_RG_U2_HSTX_SRCTRL, 403 - PA5_RG_U2_HSTX_SRCTRL_VAL(calibration_val)); 449 + mtk_phy_update_field(com + U3P_USBPHYACR5, PA5_RG_U2_HSTX_SRCTRL, 450 + calibration_val); 404 451 405 452 /* disable USB ring oscillator */ 406 453 mtk_phy_clear_bits(com + U3P_USBPHYACR5, PA5_RG_U2_HSTX_SRCAL_EN); ··· 410 457 struct mtk_phy_instance *instance) 411 458 { 412 459 struct u3phy_banks *u3_banks = &instance->u3_banks; 460 + void __iomem *phya = u3_banks->phya; 461 + void __iomem *phyd = u3_banks->phyd; 413 462 414 463 /* gating PCIe Analog XTAL clock */ 415 464 mtk_phy_set_bits(u3_banks->spllc + U3P_SPLLC_XTALCTL3, 416 465 XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD); 417 466 418 467 /* gating XSQ */ 419 - mtk_phy_update_bits(u3_banks->phya + U3P_U3_PHYA_DA_REG0, 420 - P3A_RG_XTAL_EXT_EN_U3, P3A_RG_XTAL_EXT_EN_U3_VAL(2)); 468 + mtk_phy_update_field(phya + U3P_U3_PHYA_DA_REG0, P3A_RG_XTAL_EXT_EN_U3, 2); 421 469 422 - mtk_phy_update_bits(u3_banks->phya + U3P_U3_PHYA_REG9, 423 - P3A_RG_RX_DAC_MUX, P3A_RG_RX_DAC_MUX_VAL(4)); 470 + mtk_phy_update_field(phya + U3P_U3_PHYA_REG9, P3A_RG_RX_DAC_MUX, 4); 424 471 425 - mtk_phy_update_bits(u3_banks->phya + U3P_U3_PHYA_REG6, 426 - P3A_RG_TX_EIDLE_CM, P3A_RG_TX_EIDLE_CM_VAL(0xe)); 472 + mtk_phy_update_field(phya + U3P_U3_PHYA_REG6, P3A_RG_TX_EIDLE_CM, 0xe); 427 473 428 474 mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_CDR1, 429 475 P3D_RG_CDR_BIR_LTD0 | P3D_RG_CDR_BIR_LTD1, 430 - P3D_RG_CDR_BIR_LTD0_VAL(0xc) | P3D_RG_CDR_BIR_LTD1_VAL(0x3)); 476 + FIELD_PREP(P3D_RG_CDR_BIR_LTD0, 0xc) | 477 + FIELD_PREP(P3D_RG_CDR_BIR_LTD1, 0x3)); 431 478 432 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_LFPS1, 433 - P3D_RG_FWAKE_TH, P3D_RG_FWAKE_TH_VAL(0x34)); 479 + mtk_phy_update_field(phyd + U3P_U3_PHYD_LFPS1, P3D_RG_FWAKE_TH, 0x34); 434 480 435 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_RXDET1, 436 - P3D_RG_RXDET_STB2_SET, P3D_RG_RXDET_STB2_SET_VAL(0x10)); 481 + mtk_phy_update_field(phyd + U3P_U3_PHYD_RXDET1, P3D_RG_RXDET_STB2_SET, 0x10); 437 482 438 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_RXDET2, 439 - P3D_RG_RXDET_STB2_SET_P3, P3D_RG_RXDET_STB2_SET_P3_VAL(0x10)); 483 + mtk_phy_update_field(phyd + U3P_U3_PHYD_RXDET2, P3D_RG_RXDET_STB2_SET_P3, 0x10); 440 484 441 485 dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); 442 486 } ··· 447 497 if (!tphy->pdata->sw_pll_48m_to_26m) 448 498 return; 449 499 450 - mtk_phy_update_bits(com + U3P_USBPHYACR0, PA0_USB20_PLL_PREDIV, 451 - PA0_USB20_PLL_PREDIV_VAL(0)); 500 + mtk_phy_update_field(com + U3P_USBPHYACR0, PA0_USB20_PLL_PREDIV, 0); 452 501 453 - mtk_phy_update_bits(com + U3P_USBPHYACR2, PA2_RG_U2PLL_BW, 454 - PA2_RG_U2PLL_BW_VAL(3)); 502 + mtk_phy_update_field(com + U3P_USBPHYACR2, PA2_RG_U2PLL_BW, 3); 455 503 456 504 writel(P2R_RG_U2PLL_FBDIV_26M, com + U3P_U2PHYA_RESV); 457 505 ··· 467 519 /* switch to USB function, and enable usb pll */ 468 520 mtk_phy_clear_bits(com + U3P_U2PHYDTM0, P2C_FORCE_UART_EN | P2C_FORCE_SUSPENDM); 469 521 470 - mtk_phy_update_bits(com + U3P_U2PHYDTM0, P2C_RG_XCVRSEL | P2C_RG_DATAIN, 471 - P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0)); 522 + mtk_phy_clear_bits(com + U3P_U2PHYDTM0, 523 + P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK); 472 524 473 525 mtk_phy_clear_bits(com + U3P_U2PHYDTM1, P2C_RG_UART_EN); 474 526 ··· 477 529 /* disable switch 100uA current to SSUSB */ 478 530 mtk_phy_clear_bits(com + U3P_USBPHYACR5, PA5_RG_U2_HS_100U_U3_EN); 479 531 480 - if (!index) 481 - mtk_phy_clear_bits(com + U3P_U2PHYACR4, P2C_U2_GPIO_CTR_MSK); 532 + mtk_phy_clear_bits(com + U3P_U2PHYACR4, P2C_U2_GPIO_CTR_MSK); 482 533 483 534 if (tphy->pdata->avoid_rx_sen_degradation) { 484 535 if (!index) { ··· 495 548 /* DP/DM BC1.1 path Disable */ 496 549 mtk_phy_clear_bits(com + U3P_USBPHYACR6, PA6_RG_U2_BC11_SW_EN); 497 550 498 - mtk_phy_update_bits(com + U3P_USBPHYACR6, PA6_RG_U2_SQTH, PA6_RG_U2_SQTH_VAL(2)); 551 + mtk_phy_update_field(com + U3P_USBPHYACR6, PA6_RG_U2_SQTH, 2); 499 552 500 553 /* Workaround only for mt8195, HW fix it for others (V3) */ 501 554 u2_phy_pll_26m_set(tphy, instance); ··· 509 562 struct u2phy_banks *u2_banks = &instance->u2_banks; 510 563 void __iomem *com = u2_banks->com; 511 564 u32 index = instance->index; 512 - 513 - mtk_phy_clear_bits(com + U3P_U2PHYDTM0, 514 - P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK); 515 565 516 566 /* OTG Enable */ 517 567 mtk_phy_set_bits(com + U3P_USBPHYACR6, PA6_RG_U2_OTG_VBUSCMP_EN); ··· 531 587 struct u2phy_banks *u2_banks = &instance->u2_banks; 532 588 void __iomem *com = u2_banks->com; 533 589 u32 index = instance->index; 534 - 535 - mtk_phy_clear_bits(com + U3P_U2PHYDTM0, P2C_RG_XCVRSEL | P2C_RG_DATAIN); 536 590 537 591 /* OTG Disable */ 538 592 mtk_phy_clear_bits(com + U3P_USBPHYACR6, PA6_RG_U2_OTG_VBUSCMP_EN); ··· 598 656 599 657 mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG0, 600 658 P3A_RG_XTAL_EXT_PE1H | P3A_RG_XTAL_EXT_PE2H, 601 - P3A_RG_XTAL_EXT_PE1H_VAL(0x2) | P3A_RG_XTAL_EXT_PE2H_VAL(0x2)); 659 + FIELD_PREP(P3A_RG_XTAL_EXT_PE1H, 0x2) | 660 + FIELD_PREP(P3A_RG_XTAL_EXT_PE2H, 0x2)); 602 661 603 662 /* ref clk drive */ 604 - mtk_phy_update_bits(phya + U3P_U3_PHYA_REG1, P3A_RG_CLKDRV_AMP, 605 - P3A_RG_CLKDRV_AMP_VAL(0x4)); 663 + mtk_phy_update_field(phya + U3P_U3_PHYA_REG1, P3A_RG_CLKDRV_AMP, 0x4); 606 664 607 - mtk_phy_update_bits(phya + U3P_U3_PHYA_REG0, P3A_RG_CLKDRV_OFF, 608 - P3A_RG_CLKDRV_OFF_VAL(0x1)); 665 + mtk_phy_update_field(phya + U3P_U3_PHYA_REG0, P3A_RG_CLKDRV_OFF, 0x1); 609 666 610 667 /* SSC delta -5000ppm */ 611 - mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG20, P3A_RG_PLL_DELTA1_PE2H, 612 - P3A_RG_PLL_DELTA1_PE2H_VAL(0x3c)); 668 + mtk_phy_update_field(phya + U3P_U3_PHYA_DA_REG20, P3A_RG_PLL_DELTA1_PE2H, 0x3c); 613 669 614 - mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG25, P3A_RG_PLL_DELTA_PE2H, 615 - P3A_RG_PLL_DELTA_PE2H_VAL(0x36)); 670 + mtk_phy_update_field(phya + U3P_U3_PHYA_DA_REG25, P3A_RG_PLL_DELTA_PE2H, 0x36); 616 671 617 672 /* change pll BW 0.6M */ 618 673 mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG5, 619 674 P3A_RG_PLL_BR_PE2H | P3A_RG_PLL_IC_PE2H, 620 - P3A_RG_PLL_BR_PE2H_VAL(0x1) | P3A_RG_PLL_IC_PE2H_VAL(0x1)); 675 + FIELD_PREP(P3A_RG_PLL_BR_PE2H, 0x1) | 676 + FIELD_PREP(P3A_RG_PLL_IC_PE2H, 0x1)); 621 677 622 678 mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG4, 623 679 P3A_RG_PLL_DIVEN_PE2H | P3A_RG_PLL_BC_PE2H, 624 - P3A_RG_PLL_BC_PE2H_VAL(0x3)); 680 + FIELD_PREP(P3A_RG_PLL_BC_PE2H, 0x3)); 625 681 626 - mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG6, P3A_RG_PLL_IR_PE2H, 627 - P3A_RG_PLL_IR_PE2H_VAL(0x2)); 682 + mtk_phy_update_field(phya + U3P_U3_PHYA_DA_REG6, P3A_RG_PLL_IR_PE2H, 0x2); 628 683 629 - mtk_phy_update_bits(phya + U3P_U3_PHYA_DA_REG7, P3A_RG_PLL_BP_PE2H, 630 - P3A_RG_PLL_BP_PE2H_VAL(0xa)); 684 + mtk_phy_update_field(phya + U3P_U3_PHYA_DA_REG7, P3A_RG_PLL_BP_PE2H, 0xa); 631 685 632 686 /* Tx Detect Rx Timing: 10us -> 5us */ 633 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_RXDET1, 634 - P3D_RG_RXDET_STB2_SET, P3D_RG_RXDET_STB2_SET_VAL(0x10)); 687 + mtk_phy_update_field(u3_banks->phyd + U3P_U3_PHYD_RXDET1, 688 + P3D_RG_RXDET_STB2_SET, 0x10); 635 689 636 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_RXDET2, 637 - P3D_RG_RXDET_STB2_SET_P3, P3D_RG_RXDET_STB2_SET_P3_VAL(0x10)); 690 + mtk_phy_update_field(u3_banks->phyd + U3P_U3_PHYD_RXDET2, 691 + P3D_RG_RXDET_STB2_SET_P3, 0x10); 638 692 639 693 /* wait for PCIe subsys register to active */ 640 694 usleep_range(2500, 3000); ··· 671 733 /* charge current adjustment */ 672 734 mtk_phy_update_bits(phyd + ANA_RG_CTRL_SIGNAL6, 673 735 RG_CDR_BIRLTR_GEN1_MSK | RG_CDR_BC_GEN1_MSK, 674 - RG_CDR_BIRLTR_GEN1_VAL(0x6) | RG_CDR_BC_GEN1_VAL(0x1a)); 736 + FIELD_PREP(RG_CDR_BIRLTR_GEN1_MSK, 0x6) | 737 + FIELD_PREP(RG_CDR_BC_GEN1_MSK, 0x1a)); 675 738 676 - mtk_phy_update_bits(phyd + ANA_EQ_EYE_CTRL_SIGNAL4, RG_CDR_BIRLTD0_GEN1_MSK, 677 - RG_CDR_BIRLTD0_GEN1_VAL(0x18)); 739 + mtk_phy_update_field(phyd + ANA_EQ_EYE_CTRL_SIGNAL4, RG_CDR_BIRLTD0_GEN1_MSK, 0x18); 678 740 679 - mtk_phy_update_bits(phyd + ANA_EQ_EYE_CTRL_SIGNAL5, RG_CDR_BIRLTD0_GEN3_MSK, 680 - RG_CDR_BIRLTD0_GEN3_VAL(0x06)); 741 + mtk_phy_update_field(phyd + ANA_EQ_EYE_CTRL_SIGNAL5, RG_CDR_BIRLTD0_GEN3_MSK, 0x06); 681 742 682 743 mtk_phy_update_bits(phyd + ANA_RG_CTRL_SIGNAL4, 683 744 RG_CDR_BICLTR_GEN1_MSK | RG_CDR_BR_GEN2_MSK, 684 - RG_CDR_BICLTR_GEN1_VAL(0x0c) | RG_CDR_BR_GEN2_VAL(0x07)); 745 + FIELD_PREP(RG_CDR_BICLTR_GEN1_MSK, 0x0c) | 746 + FIELD_PREP(RG_CDR_BR_GEN2_MSK, 0x07)); 685 747 686 748 mtk_phy_update_bits(phyd + PHYD_CTRL_SIGNAL_MODE4, 687 749 RG_CDR_BICLTD0_GEN1_MSK | RG_CDR_BICLTD1_GEN1_MSK, 688 - RG_CDR_BICLTD0_GEN1_VAL(0x08) | RG_CDR_BICLTD1_GEN1_VAL(0x02)); 750 + FIELD_PREP(RG_CDR_BICLTD0_GEN1_MSK, 0x08) | 751 + FIELD_PREP(RG_CDR_BICLTD1_GEN1_MSK, 0x02)); 689 752 690 - mtk_phy_update_bits(phyd + PHYD_DESIGN_OPTION2, RG_LOCK_CNT_SEL_MSK, 691 - RG_LOCK_CNT_SEL_VAL(0x02)); 753 + mtk_phy_update_field(phyd + PHYD_DESIGN_OPTION2, RG_LOCK_CNT_SEL_MSK, 0x02); 692 754 693 755 mtk_phy_update_bits(phyd + PHYD_DESIGN_OPTION9, 694 756 RG_T2_MIN_MSK | RG_TG_MIN_MSK, 695 - RG_T2_MIN_VAL(0x12) | RG_TG_MIN_VAL(0x04)); 757 + FIELD_PREP(RG_T2_MIN_MSK, 0x12) | 758 + FIELD_PREP(RG_TG_MIN_MSK, 0x04)); 696 759 697 760 mtk_phy_update_bits(phyd + PHYD_DESIGN_OPTION9, 698 761 RG_T2_MAX_MSK | RG_TG_MAX_MSK, 699 - RG_T2_MAX_VAL(0x31) | RG_TG_MAX_VAL(0x0e)); 762 + FIELD_PREP(RG_T2_MAX_MSK, 0x31) | 763 + FIELD_PREP(RG_TG_MAX_MSK, 0x0e)); 700 764 701 - mtk_phy_update_bits(phyd + ANA_RG_CTRL_SIGNAL1, RG_IDRV_0DB_GEN1_MSK, 702 - RG_IDRV_0DB_GEN1_VAL(0x20)); 765 + mtk_phy_update_field(phyd + ANA_RG_CTRL_SIGNAL1, RG_IDRV_0DB_GEN1_MSK, 0x20); 703 766 704 - mtk_phy_update_bits(phyd + ANA_EQ_EYE_CTRL_SIGNAL1, RG_EQ_DLEQ_LFI_GEN1_MSK, 705 - RG_EQ_DLEQ_LFI_GEN1_VAL(0x03)); 767 + mtk_phy_update_field(phyd + ANA_EQ_EYE_CTRL_SIGNAL1, RG_EQ_DLEQ_LFI_GEN1_MSK, 0x03); 706 768 707 769 dev_dbg(tphy->dev, "%s(%d)\n", __func__, instance->index); 708 770 } ··· 779 841 &instance->intr); 780 842 device_property_read_u32(dev, "mediatek,discth", 781 843 &instance->discth); 844 + device_property_read_u32(dev, "mediatek,pre-emphasis", 845 + &instance->pre_emphasis); 782 846 dev_dbg(dev, "bc12:%d, src:%d, vrt:%d, term:%d, intr:%d, disc:%d\n", 783 847 instance->bc12_en, instance->eye_src, 784 848 instance->eye_vrt, instance->eye_term, 785 849 instance->intr, instance->discth); 850 + dev_dbg(dev, "pre-emp:%d\n", instance->pre_emphasis); 786 851 } 787 852 788 853 static void u2_phy_props_set(struct mtk_tphy *tphy, ··· 798 857 mtk_phy_set_bits(com + U3P_U2PHYBC12C, P2C_RG_CHGDT_EN); 799 858 800 859 if (tphy->pdata->version < MTK_PHY_V3 && instance->eye_src) 801 - mtk_phy_update_bits(com + U3P_USBPHYACR5, PA5_RG_U2_HSTX_SRCTRL, 802 - PA5_RG_U2_HSTX_SRCTRL_VAL(instance->eye_src)); 860 + mtk_phy_update_field(com + U3P_USBPHYACR5, PA5_RG_U2_HSTX_SRCTRL, 861 + instance->eye_src); 803 862 804 863 if (instance->eye_vrt) 805 - mtk_phy_update_bits(com + U3P_USBPHYACR1, PA1_RG_VRT_SEL, 806 - PA1_RG_VRT_SEL_VAL(instance->eye_vrt)); 864 + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_VRT_SEL, 865 + instance->eye_vrt); 807 866 808 867 if (instance->eye_term) 809 - mtk_phy_update_bits(com + U3P_USBPHYACR1, PA1_RG_TERM_SEL, 810 - PA1_RG_TERM_SEL_VAL(instance->eye_term)); 868 + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_TERM_SEL, 869 + instance->eye_term); 811 870 812 - if (instance->intr) 813 - mtk_phy_update_bits(com + U3P_USBPHYACR1, PA1_RG_INTR_CAL, 814 - PA1_RG_INTR_CAL_VAL(instance->intr)); 871 + if (instance->intr) { 872 + if (u2_banks->misc) 873 + mtk_phy_set_bits(u2_banks->misc + U3P_MISC_REG1, 874 + MR1_EFUSE_AUTO_LOAD_DIS); 875 + 876 + mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_INTR_CAL, 877 + instance->intr); 878 + } 815 879 816 880 if (instance->discth) 817 - mtk_phy_update_bits(com + U3P_USBPHYACR6, PA6_RG_U2_DISCTH, 818 - PA6_RG_U2_DISCTH_VAL(instance->discth)); 881 + mtk_phy_update_field(com + U3P_USBPHYACR6, PA6_RG_U2_DISCTH, 882 + instance->discth); 883 + 884 + if (instance->pre_emphasis) 885 + mtk_phy_update_field(com + U3P_USBPHYACR6, PA6_RG_U2_PRE_EMP, 886 + instance->pre_emphasis); 819 887 } 820 888 821 889 /* type switch for usb3/pcie/sgmii/sata */ ··· 856 906 static int phy_type_set(struct mtk_phy_instance *instance) 857 907 { 858 908 int type; 859 - u32 mask; 909 + u32 offset; 860 910 861 911 if (!instance->type_sw) 862 912 return 0; ··· 879 929 return 0; 880 930 } 881 931 882 - mask = RG_PHY_SW_TYPE << (instance->type_sw_index * BITS_PER_BYTE); 883 - regmap_update_bits(instance->type_sw, instance->type_sw_reg, mask, type); 932 + offset = instance->type_sw_index * BITS_PER_BYTE; 933 + regmap_update_bits(instance->type_sw, instance->type_sw_reg, 934 + RG_PHY_SW_TYPE << offset, type << offset); 884 935 885 936 return 0; 886 937 } ··· 973 1022 case PHY_TYPE_USB2: 974 1023 mtk_phy_set_bits(u2_banks->misc + U3P_MISC_REG1, MR1_EFUSE_AUTO_LOAD_DIS); 975 1024 976 - mtk_phy_update_bits(u2_banks->com + U3P_USBPHYACR1, PA1_RG_INTR_CAL, 977 - PA1_RG_INTR_CAL_VAL(instance->efuse_intr)); 1025 + mtk_phy_update_field(u2_banks->com + U3P_USBPHYACR1, PA1_RG_INTR_CAL, 1026 + instance->efuse_intr); 978 1027 break; 979 1028 case PHY_TYPE_USB3: 980 1029 case PHY_TYPE_PCIE: 981 1030 mtk_phy_set_bits(u3_banks->phyd + U3P_U3_PHYD_RSV, P3D_RG_EFUSE_AUTO_LOAD_DIS); 982 1031 983 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_IMPCAL0, P3D_RG_TX_IMPEL, 984 - P3D_RG_TX_IMPEL_VAL(instance->efuse_tx_imp)); 1032 + mtk_phy_update_field(u3_banks->phyd + U3P_U3_PHYD_IMPCAL0, P3D_RG_TX_IMPEL, 1033 + instance->efuse_tx_imp); 985 1034 mtk_phy_set_bits(u3_banks->phyd + U3P_U3_PHYD_IMPCAL0, P3D_RG_FORCE_TX_IMPEL); 986 1035 987 - mtk_phy_update_bits(u3_banks->phyd + U3P_U3_PHYD_IMPCAL1, P3D_RG_RX_IMPEL, 988 - P3D_RG_RX_IMPEL_VAL(instance->efuse_rx_imp)); 1036 + mtk_phy_update_field(u3_banks->phyd + U3P_U3_PHYD_IMPCAL1, P3D_RG_RX_IMPEL, 1037 + instance->efuse_rx_imp); 989 1038 mtk_phy_set_bits(u3_banks->phyd + U3P_U3_PHYD_IMPCAL1, P3D_RG_FORCE_RX_IMPEL); 990 1039 991 - mtk_phy_update_bits(u3_banks->phya + U3P_U3_PHYA_REG0, P3A_RG_IEXT_INTR, 992 - P3A_RG_IEXT_INTR_VAL(instance->efuse_intr)); 1040 + mtk_phy_update_field(u3_banks->phya + U3P_U3_PHYA_REG0, P3A_RG_IEXT_INTR, 1041 + instance->efuse_intr); 993 1042 break; 994 1043 default: 995 1044 dev_warn(dev, "no sw efuse for type %d\n", instance->type);
+28 -50
drivers/phy/mediatek/phy-mtk-ufs.c
··· 11 11 #include <linux/phy/phy.h> 12 12 #include <linux/platform_device.h> 13 13 14 + #include "phy-mtk-io.h" 15 + 14 16 /* mphy register and offsets */ 15 17 #define MP_GLB_DIG_8C 0x008C 16 18 #define FRC_PLL_ISO_EN BIT(8) ··· 41 39 struct clk_bulk_data clks[UFSPHY_CLKS_CNT]; 42 40 }; 43 41 44 - static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg) 45 - { 46 - return readl(phy->mmio + reg); 47 - } 48 - 49 - static inline void mphy_writel(struct ufs_mtk_phy *phy, u32 val, u32 reg) 50 - { 51 - writel(val, phy->mmio + reg); 52 - } 53 - 54 - static void mphy_set_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit) 55 - { 56 - u32 val; 57 - 58 - val = mphy_readl(phy, reg); 59 - val |= bit; 60 - mphy_writel(phy, val, reg); 61 - } 62 - 63 - static void mphy_clr_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit) 64 - { 65 - u32 val; 66 - 67 - val = mphy_readl(phy, reg); 68 - val &= ~bit; 69 - mphy_writel(phy, val, reg); 70 - } 71 - 72 42 static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy) 73 43 { 74 44 return (struct ufs_mtk_phy *)phy_get_drvdata(generic_phy); ··· 58 84 59 85 static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy) 60 86 { 87 + void __iomem *mmio = phy->mmio; 88 + 61 89 /* release DA_MP_PLL_PWR_ON */ 62 - mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON); 63 - mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON); 90 + mtk_phy_set_bits(mmio + MP_GLB_DIG_8C, PLL_PWR_ON); 91 + mtk_phy_clear_bits(mmio + MP_GLB_DIG_8C, FRC_FRC_PWR_ON); 64 92 65 93 /* release DA_MP_PLL_ISO_EN */ 66 - mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN); 67 - mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN); 94 + mtk_phy_clear_bits(mmio + MP_GLB_DIG_8C, PLL_ISO_EN); 95 + mtk_phy_clear_bits(mmio + MP_GLB_DIG_8C, FRC_PLL_ISO_EN); 68 96 69 97 /* release DA_MP_CDR_PWR_ON */ 70 - mphy_set_bit(phy, MP_LN_RX_44, CDR_PWR_ON); 71 - mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON); 98 + mtk_phy_set_bits(mmio + MP_LN_RX_44, CDR_PWR_ON); 99 + mtk_phy_clear_bits(mmio + MP_LN_RX_44, FRC_CDR_PWR_ON); 72 100 73 101 /* release DA_MP_CDR_ISO_EN */ 74 - mphy_clr_bit(phy, MP_LN_RX_44, CDR_ISO_EN); 75 - mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN); 102 + mtk_phy_clear_bits(mmio + MP_LN_RX_44, CDR_ISO_EN); 103 + mtk_phy_clear_bits(mmio + MP_LN_RX_44, FRC_CDR_ISO_EN); 76 104 77 105 /* release DA_MP_RX0_SQ_EN */ 78 - mphy_set_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN); 79 - mphy_clr_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); 106 + mtk_phy_set_bits(mmio + MP_LN_DIG_RX_AC, RX_SQ_EN); 107 + mtk_phy_clear_bits(mmio + MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); 80 108 81 109 /* delay 1us to wait DIFZ stable */ 82 110 udelay(1); 83 111 84 112 /* release DIFZ */ 85 - mphy_clr_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); 113 + mtk_phy_clear_bits(mmio + MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); 86 114 } 87 115 88 116 static void ufs_mtk_phy_set_deep_hibern(struct ufs_mtk_phy *phy) 89 117 { 118 + void __iomem *mmio = phy->mmio; 119 + 90 120 /* force DIFZ */ 91 - mphy_set_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); 121 + mtk_phy_set_bits(mmio + MP_LN_DIG_RX_9C, FSM_DIFZ_FRC); 92 122 93 123 /* force DA_MP_RX0_SQ_EN */ 94 - mphy_set_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); 95 - mphy_clr_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN); 124 + mtk_phy_set_bits(mmio + MP_LN_DIG_RX_AC, FRC_RX_SQ_EN); 125 + mtk_phy_clear_bits(mmio + MP_LN_DIG_RX_AC, RX_SQ_EN); 96 126 97 127 /* force DA_MP_CDR_ISO_EN */ 98 - mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN); 99 - mphy_set_bit(phy, MP_LN_RX_44, CDR_ISO_EN); 128 + mtk_phy_set_bits(mmio + MP_LN_RX_44, FRC_CDR_ISO_EN); 129 + mtk_phy_set_bits(mmio + MP_LN_RX_44, CDR_ISO_EN); 100 130 101 131 /* force DA_MP_CDR_PWR_ON */ 102 - mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON); 103 - mphy_clr_bit(phy, MP_LN_RX_44, CDR_PWR_ON); 132 + mtk_phy_set_bits(mmio + MP_LN_RX_44, FRC_CDR_PWR_ON); 133 + mtk_phy_clear_bits(mmio + MP_LN_RX_44, CDR_PWR_ON); 104 134 105 135 /* force DA_MP_PLL_ISO_EN */ 106 - mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN); 107 - mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN); 136 + mtk_phy_set_bits(mmio + MP_GLB_DIG_8C, FRC_PLL_ISO_EN); 137 + mtk_phy_set_bits(mmio + MP_GLB_DIG_8C, PLL_ISO_EN); 108 138 109 139 /* force DA_MP_PLL_PWR_ON */ 110 - mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON); 111 - mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON); 140 + mtk_phy_set_bits(mmio + MP_GLB_DIG_8C, FRC_FRC_PWR_ON); 141 + mtk_phy_clear_bits(mmio + MP_GLB_DIG_8C, PLL_PWR_ON); 112 142 } 113 143 114 144 static int ufs_mtk_phy_power_on(struct phy *generic_phy)
+17 -29
drivers/phy/mediatek/phy-mtk-xsphy.c
··· 37 37 #define XSP_U2FREQ_FMCR0 ((SSUSB_SIFSLV_U2FREQ) + 0x00) 38 38 #define P2F_RG_FREQDET_EN BIT(24) 39 39 #define P2F_RG_CYCLECNT GENMASK(23, 0) 40 - #define P2F_RG_CYCLECNT_VAL(x) ((P2F_RG_CYCLECNT) & (x)) 41 40 42 41 #define XSP_U2FREQ_MMONR0 ((SSUSB_SIFSLV_U2FREQ) + 0x0c) 43 42 ··· 49 50 50 51 #define XSP_USBPHYACR1 ((SSUSB_SIFSLV_U2PHY_COM) + 0x04) 51 52 #define P2A1_RG_INTR_CAL GENMASK(23, 19) 52 - #define P2A1_RG_INTR_CAL_VAL(x) ((0x1f & (x)) << 19) 53 53 #define P2A1_RG_VRT_SEL GENMASK(14, 12) 54 - #define P2A1_RG_VRT_SEL_VAL(x) ((0x7 & (x)) << 12) 55 54 #define P2A1_RG_TERM_SEL GENMASK(10, 8) 56 - #define P2A1_RG_TERM_SEL_VAL(x) ((0x7 & (x)) << 8) 57 55 58 56 #define XSP_USBPHYACR5 ((SSUSB_SIFSLV_U2PHY_COM) + 0x014) 59 57 #define P2A5_RG_HSTX_SRCAL_EN BIT(15) 60 58 #define P2A5_RG_HSTX_SRCTRL GENMASK(14, 12) 61 - #define P2A5_RG_HSTX_SRCTRL_VAL(x) ((0x7 & (x)) << 12) 62 59 63 60 #define XSP_USBPHYACR6 ((SSUSB_SIFSLV_U2PHY_COM) + 0x018) 64 61 #define P2A6_RG_BC11_SW_EN BIT(23) ··· 69 74 70 75 #define SSPXTP_PHYA_GLB_00 ((SSPXTP_SIFSLV_PHYA_GLB) + 0x00) 71 76 #define RG_XTP_GLB_BIAS_INTR_CTRL GENMASK(21, 16) 72 - #define RG_XTP_GLB_BIAS_INTR_CTRL_VAL(x) ((0x3f & (x)) << 16) 73 77 74 78 #define SSPXTP_PHYA_LN_04 ((SSPXTP_SIFSLV_PHYA_LN) + 0x04) 75 79 #define RG_XTP_LN0_TX_IMPSEL GENMASK(4, 0) 76 - #define RG_XTP_LN0_TX_IMPSEL_VAL(x) (0x1f & (x)) 77 80 78 81 #define SSPXTP_PHYA_LN_14 ((SSPXTP_SIFSLV_PHYA_LN) + 0x014) 79 82 #define RG_XTP_LN0_RX_IMPSEL GENMASK(4, 0) 80 - #define RG_XTP_LN0_RX_IMPSEL_VAL(x) (0x1f & (x)) 81 83 82 84 #define XSP_REF_CLK 26 /* MHZ */ 83 85 #define XSP_SLEW_RATE_COEF 17 ··· 126 134 mtk_phy_set_bits(pbase + XSP_U2FREQ_FMMONR1, P2F_RG_FRCK_EN); 127 135 128 136 /* set cycle count as 1024 */ 129 - mtk_phy_update_bits(pbase + XSP_U2FREQ_FMCR0, P2F_RG_CYCLECNT, 130 - P2F_RG_CYCLECNT_VAL(XSP_FM_DET_CYCLE_CNT)); 137 + mtk_phy_update_field(pbase + XSP_U2FREQ_FMCR0, P2F_RG_CYCLECNT, 138 + XSP_FM_DET_CYCLE_CNT); 131 139 132 140 /* enable frequency meter */ 133 141 mtk_phy_set_bits(pbase + XSP_U2FREQ_FMCR0, P2F_RG_FREQDET_EN); ··· 158 166 xsphy->src_ref_clk, xsphy->src_coef); 159 167 160 168 /* set HS slew rate */ 161 - mtk_phy_update_bits(pbase + XSP_USBPHYACR5, P2A5_RG_HSTX_SRCTRL, 162 - P2A5_RG_HSTX_SRCTRL_VAL(calib_val)); 169 + mtk_phy_update_field(pbase + XSP_USBPHYACR5, P2A5_RG_HSTX_SRCTRL, calib_val); 163 170 164 171 /* disable USB ring oscillator */ 165 172 mtk_phy_clear_bits(pbase + XSP_USBPHYACR5, P2A5_RG_HSTX_SRCAL_EN); ··· 271 280 void __iomem *pbase = inst->port_base; 272 281 273 282 if (inst->efuse_intr) 274 - mtk_phy_update_bits(pbase + XSP_USBPHYACR1, P2A1_RG_INTR_CAL, 275 - P2A1_RG_INTR_CAL_VAL(inst->efuse_intr)); 283 + mtk_phy_update_field(pbase + XSP_USBPHYACR1, P2A1_RG_INTR_CAL, 284 + inst->efuse_intr); 276 285 277 286 if (inst->eye_src) 278 - mtk_phy_update_bits(pbase + XSP_USBPHYACR5, P2A5_RG_HSTX_SRCTRL, 279 - P2A5_RG_HSTX_SRCTRL_VAL(inst->eye_src)); 287 + mtk_phy_update_field(pbase + XSP_USBPHYACR5, P2A5_RG_HSTX_SRCTRL, 288 + inst->eye_src); 280 289 281 290 if (inst->eye_vrt) 282 - mtk_phy_update_bits(pbase + XSP_USBPHYACR1, P2A1_RG_VRT_SEL, 283 - P2A1_RG_VRT_SEL_VAL(inst->eye_vrt)); 291 + mtk_phy_update_field(pbase + XSP_USBPHYACR1, P2A1_RG_VRT_SEL, 292 + inst->eye_vrt); 284 293 285 294 if (inst->eye_term) 286 - mtk_phy_update_bits(pbase + XSP_USBPHYACR1, P2A1_RG_TERM_SEL, 287 - P2A1_RG_TERM_SEL_VAL(inst->eye_term)); 295 + mtk_phy_update_field(pbase + XSP_USBPHYACR1, P2A1_RG_TERM_SEL, 296 + inst->eye_term); 288 297 } 289 298 290 299 static void u3_phy_props_set(struct mtk_xsphy *xsphy, ··· 293 302 void __iomem *pbase = inst->port_base; 294 303 295 304 if (inst->efuse_intr) 296 - mtk_phy_update_bits(xsphy->glb_base + SSPXTP_PHYA_GLB_00, 297 - RG_XTP_GLB_BIAS_INTR_CTRL, 298 - RG_XTP_GLB_BIAS_INTR_CTRL_VAL(inst->efuse_intr)); 305 + mtk_phy_update_field(xsphy->glb_base + SSPXTP_PHYA_GLB_00, 306 + RG_XTP_GLB_BIAS_INTR_CTRL, inst->efuse_intr); 299 307 300 308 if (inst->efuse_tx_imp) 301 - mtk_phy_update_bits(pbase + SSPXTP_PHYA_LN_04, 302 - RG_XTP_LN0_TX_IMPSEL, 303 - RG_XTP_LN0_TX_IMPSEL_VAL(inst->efuse_tx_imp)); 309 + mtk_phy_update_field(pbase + SSPXTP_PHYA_LN_04, 310 + RG_XTP_LN0_TX_IMPSEL, inst->efuse_tx_imp); 304 311 305 312 if (inst->efuse_rx_imp) 306 - mtk_phy_update_bits(pbase + SSPXTP_PHYA_LN_14, 307 - RG_XTP_LN0_RX_IMPSEL, 308 - RG_XTP_LN0_RX_IMPSEL_VAL(inst->efuse_rx_imp)); 313 + mtk_phy_update_field(pbase + SSPXTP_PHYA_LN_14, 314 + RG_XTP_LN0_RX_IMPSEL, inst->efuse_rx_imp); 309 315 } 310 316 311 317 static int mtk_phy_init(struct phy *phy)
+87 -12
drivers/phy/microchip/lan966x_serdes.c
··· 42 42 #define SERDES_MUX_QSGMII(i, p, m, c) \ 43 43 SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_QSGMII, m, c) 44 44 #define SERDES_MUX_RGMII(i, p, m, c) \ 45 - SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_RGMII, m, c) 45 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_RGMII, m, c), \ 46 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_RGMII_TXID, m, c), \ 47 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_RGMII_RXID, m, c), \ 48 + SERDES_MUX(i, p, PHY_MODE_ETHERNET, PHY_INTERFACE_MODE_RGMII_ID, m, c) 46 49 47 50 static void lan_rmw_(u32 val, u32 mask, void __iomem *mem, u32 offset) 48 51 { ··· 97 94 HSIO_HW_CFG_SD6G_1_CFG_SET(1)), 98 95 99 96 SERDES_MUX_RGMII(RGMII(0), 2, HSIO_HW_CFG_RGMII_0_CFG | 100 - HSIO_HW_CFG_RGMII_ENA, 101 - HSIO_HW_CFG_RGMII_0_CFG_SET(BIT(0)) | 102 - HSIO_HW_CFG_RGMII_ENA_SET(BIT(0))), 97 + HSIO_HW_CFG_RGMII_ENA | 98 + HSIO_HW_CFG_GMII_ENA, 99 + HSIO_HW_CFG_RGMII_0_CFG_SET(0) | 100 + HSIO_HW_CFG_RGMII_ENA_SET(BIT(0)) | 101 + HSIO_HW_CFG_GMII_ENA_SET(BIT(2))), 103 102 SERDES_MUX_RGMII(RGMII(1), 3, HSIO_HW_CFG_RGMII_1_CFG | 104 - HSIO_HW_CFG_RGMII_ENA, 105 - HSIO_HW_CFG_RGMII_1_CFG_SET(BIT(0)) | 106 - HSIO_HW_CFG_RGMII_ENA_SET(BIT(1))), 103 + HSIO_HW_CFG_RGMII_ENA | 104 + HSIO_HW_CFG_GMII_ENA, 105 + HSIO_HW_CFG_RGMII_1_CFG_SET(0) | 106 + HSIO_HW_CFG_RGMII_ENA_SET(BIT(1)) | 107 + HSIO_HW_CFG_GMII_ENA_SET(BIT(3))), 107 108 SERDES_MUX_RGMII(RGMII(0), 5, HSIO_HW_CFG_RGMII_0_CFG | 108 - HSIO_HW_CFG_RGMII_ENA, 109 + HSIO_HW_CFG_RGMII_ENA | 110 + HSIO_HW_CFG_GMII_ENA, 109 111 HSIO_HW_CFG_RGMII_0_CFG_SET(BIT(0)) | 110 - HSIO_HW_CFG_RGMII_ENA_SET(BIT(0))), 112 + HSIO_HW_CFG_RGMII_ENA_SET(BIT(0)) | 113 + HSIO_HW_CFG_GMII_ENA_SET(BIT(5))), 111 114 SERDES_MUX_RGMII(RGMII(1), 6, HSIO_HW_CFG_RGMII_1_CFG | 112 - HSIO_HW_CFG_RGMII_ENA, 115 + HSIO_HW_CFG_RGMII_ENA | 116 + HSIO_HW_CFG_GMII_ENA, 113 117 HSIO_HW_CFG_RGMII_1_CFG_SET(BIT(0)) | 114 - HSIO_HW_CFG_RGMII_ENA_SET(BIT(1))), 118 + HSIO_HW_CFG_RGMII_ENA_SET(BIT(1)) | 119 + HSIO_HW_CFG_GMII_ENA_SET(BIT(6))), 115 120 }; 116 121 117 122 struct serdes_ctrl { ··· 393 382 return lan966x_sd6g40_setup_lane(macro, conf, idx); 394 383 } 395 384 385 + static int lan966x_rgmii_setup(struct serdes_macro *macro, u32 idx, int mode) 386 + { 387 + bool tx_delay = false; 388 + bool rx_delay = false; 389 + 390 + /* Configure RGMII */ 391 + lan_rmw(HSIO_RGMII_CFG_RGMII_RX_RST_SET(0) | 392 + HSIO_RGMII_CFG_RGMII_TX_RST_SET(0) | 393 + HSIO_RGMII_CFG_TX_CLK_CFG_SET(macro->speed == SPEED_1000 ? 1 : 394 + macro->speed == SPEED_100 ? 2 : 395 + macro->speed == SPEED_10 ? 3 : 0), 396 + HSIO_RGMII_CFG_RGMII_RX_RST | 397 + HSIO_RGMII_CFG_RGMII_TX_RST | 398 + HSIO_RGMII_CFG_TX_CLK_CFG, 399 + macro->ctrl->regs, HSIO_RGMII_CFG(idx)); 400 + 401 + if (mode == PHY_INTERFACE_MODE_RGMII || 402 + mode == PHY_INTERFACE_MODE_RGMII_TXID) 403 + rx_delay = true; 404 + 405 + if (mode == PHY_INTERFACE_MODE_RGMII || 406 + mode == PHY_INTERFACE_MODE_RGMII_RXID) 407 + tx_delay = true; 408 + 409 + /* Setup DLL configuration */ 410 + lan_rmw(HSIO_DLL_CFG_DLL_RST_SET(0) | 411 + HSIO_DLL_CFG_DLL_ENA_SET(rx_delay), 412 + HSIO_DLL_CFG_DLL_RST | 413 + HSIO_DLL_CFG_DLL_ENA, 414 + macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x0 : 0x2)); 415 + 416 + lan_rmw(HSIO_DLL_CFG_DELAY_ENA_SET(rx_delay), 417 + HSIO_DLL_CFG_DELAY_ENA, 418 + macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x0 : 0x2)); 419 + 420 + lan_rmw(HSIO_DLL_CFG_DLL_RST_SET(0) | 421 + HSIO_DLL_CFG_DLL_ENA_SET(tx_delay), 422 + HSIO_DLL_CFG_DLL_RST | 423 + HSIO_DLL_CFG_DLL_ENA, 424 + macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x1 : 0x3)); 425 + 426 + lan_rmw(HSIO_DLL_CFG_DELAY_ENA_SET(tx_delay), 427 + HSIO_DLL_CFG_DELAY_ENA, 428 + macro->ctrl->regs, HSIO_DLL_CFG(idx == 0 ? 0x1 : 0x3)); 429 + 430 + return 0; 431 + } 432 + 433 + static int serdes_set_speed(struct phy *phy, int speed) 434 + { 435 + struct serdes_macro *macro = phy_get_drvdata(phy); 436 + 437 + if (!phy_interface_mode_is_rgmii(macro->mode)) 438 + return 0; 439 + 440 + macro->speed = speed; 441 + lan966x_rgmii_setup(macro, macro->idx - (SERDES6G_MAX + 1), macro->mode); 442 + 443 + return 0; 444 + } 445 + 396 446 static int serdes_set_mode(struct phy *phy, enum phy_mode mode, int submode) 397 447 { 398 448 struct serdes_macro *macro = phy_get_drvdata(phy); ··· 499 427 macro->mode); 500 428 501 429 if (macro->idx < RGMII_MAX) 502 - return 0; 430 + return lan966x_rgmii_setup(macro, 431 + macro->idx - (SERDES6G_MAX + 1), 432 + macro->mode); 503 433 504 434 return -EOPNOTSUPP; 505 435 } ··· 511 437 512 438 static const struct phy_ops serdes_ops = { 513 439 .set_mode = serdes_set_mode, 440 + .set_speed = serdes_set_speed, 514 441 .owner = THIS_MODULE, 515 442 }; 516 443
+42
drivers/phy/microchip/lan966x_serdes_regs.h
··· 206 206 #define HSIO_HW_CFG_QSGMII_ENA_GET(x)\ 207 207 FIELD_GET(HSIO_HW_CFG_QSGMII_ENA, x) 208 208 209 + /* HSIO:HW_CFGSTAT:RGMII_CFG */ 210 + #define HSIO_RGMII_CFG(r) __REG(TARGET_HSIO, 0, 1, 104, 0, 1, 52, 20, r, 2, 4) 211 + 212 + #define HSIO_RGMII_CFG_TX_CLK_CFG GENMASK(4, 2) 213 + #define HSIO_RGMII_CFG_TX_CLK_CFG_SET(x)\ 214 + FIELD_PREP(HSIO_RGMII_CFG_TX_CLK_CFG, x) 215 + #define HSIO_RGMII_CFG_TX_CLK_CFG_GET(x)\ 216 + FIELD_GET(HSIO_RGMII_CFG_TX_CLK_CFG, x) 217 + 218 + #define HSIO_RGMII_CFG_RGMII_TX_RST BIT(1) 219 + #define HSIO_RGMII_CFG_RGMII_TX_RST_SET(x)\ 220 + FIELD_PREP(HSIO_RGMII_CFG_RGMII_TX_RST, x) 221 + #define HSIO_RGMII_CFG_RGMII_TX_RST_GET(x)\ 222 + FIELD_GET(HSIO_RGMII_CFG_RGMII_TX_RST, x) 223 + 224 + #define HSIO_RGMII_CFG_RGMII_RX_RST BIT(0) 225 + #define HSIO_RGMII_CFG_RGMII_RX_RST_SET(x)\ 226 + FIELD_PREP(HSIO_RGMII_CFG_RGMII_RX_RST, x) 227 + #define HSIO_RGMII_CFG_RGMII_RX_RST_GET(x)\ 228 + FIELD_GET(HSIO_RGMII_CFG_RGMII_RX_RST, x) 229 + 230 + /* HSIO:HW_CFGSTAT:DLL_CFG */ 231 + #define HSIO_DLL_CFG(r) __REG(TARGET_HSIO, 0, 1, 104, 0, 1, 52, 36, r, 4, 4) 232 + 233 + #define HSIO_DLL_CFG_DELAY_ENA BIT(2) 234 + #define HSIO_DLL_CFG_DELAY_ENA_SET(x)\ 235 + FIELD_PREP(HSIO_DLL_CFG_DELAY_ENA, x) 236 + #define HSIO_DLL_CFG_DELAY_ENA_GET(x)\ 237 + FIELD_GET(HSIO_DLL_CFG_DELAY_ENA, x) 238 + 239 + #define HSIO_DLL_CFG_DLL_ENA BIT(1) 240 + #define HSIO_DLL_CFG_DLL_ENA_SET(x)\ 241 + FIELD_PREP(HSIO_DLL_CFG_DLL_ENA, x) 242 + #define HSIO_DLL_CFG_DLL_ENA_GET(x)\ 243 + FIELD_GET(HSIO_DLL_CFG_DLL_ENA, x) 244 + 245 + #define HSIO_DLL_CFG_DLL_RST BIT(0) 246 + #define HSIO_DLL_CFG_DLL_RST_SET(x)\ 247 + FIELD_PREP(HSIO_DLL_CFG_DLL_RST, x) 248 + #define HSIO_DLL_CFG_DLL_RST_GET(x)\ 249 + FIELD_GET(HSIO_DLL_CFG_DLL_RST, x) 250 + 209 251 #endif /* _LAN966X_HSIO_REGS_H_ */
+198 -23
drivers/phy/qualcomm/phy-qcom-edp.c
··· 70 70 71 71 #define TXn_TRAN_DRVR_EMP_EN 0x0078 72 72 73 + struct qcom_edp_cfg { 74 + bool is_dp; 75 + 76 + /* DP PHY swing and pre_emphasis tables */ 77 + const u8 (*swing_hbr_rbr)[4][4]; 78 + const u8 (*swing_hbr3_hbr2)[4][4]; 79 + const u8 (*pre_emphasis_hbr_rbr)[4][4]; 80 + const u8 (*pre_emphasis_hbr3_hbr2)[4][4]; 81 + }; 82 + 73 83 struct qcom_edp { 74 84 struct device *dev; 85 + const struct qcom_edp_cfg *cfg; 75 86 76 87 struct phy *phy; 77 88 ··· 100 89 struct regulator_bulk_data supplies[2]; 101 90 }; 102 91 92 + static const u8 dp_swing_hbr_rbr[4][4] = { 93 + { 0x08, 0x0f, 0x16, 0x1f }, 94 + { 0x11, 0x1e, 0x1f, 0xff }, 95 + { 0x16, 0x1f, 0xff, 0xff }, 96 + { 0x1f, 0xff, 0xff, 0xff } 97 + }; 98 + 99 + static const u8 dp_pre_emp_hbr_rbr[4][4] = { 100 + { 0x00, 0x0d, 0x14, 0x1a }, 101 + { 0x00, 0x0e, 0x15, 0xff }, 102 + { 0x00, 0x0e, 0xff, 0xff }, 103 + { 0x03, 0xff, 0xff, 0xff } 104 + }; 105 + 106 + static const u8 dp_swing_hbr2_hbr3[4][4] = { 107 + { 0x02, 0x12, 0x16, 0x1a }, 108 + { 0x09, 0x19, 0x1f, 0xff }, 109 + { 0x10, 0x1f, 0xff, 0xff }, 110 + { 0x1f, 0xff, 0xff, 0xff } 111 + }; 112 + 113 + static const u8 dp_pre_emp_hbr2_hbr3[4][4] = { 114 + { 0x00, 0x0c, 0x15, 0x1b }, 115 + { 0x02, 0x0e, 0x16, 0xff }, 116 + { 0x02, 0x11, 0xff, 0xff }, 117 + { 0x04, 0xff, 0xff, 0xff } 118 + }; 119 + 120 + static const struct qcom_edp_cfg dp_phy_cfg = { 121 + .is_dp = true, 122 + .swing_hbr_rbr = &dp_swing_hbr_rbr, 123 + .swing_hbr3_hbr2 = &dp_swing_hbr2_hbr3, 124 + .pre_emphasis_hbr_rbr = &dp_pre_emp_hbr_rbr, 125 + .pre_emphasis_hbr3_hbr2 = &dp_pre_emp_hbr2_hbr3, 126 + }; 127 + 128 + static const u8 edp_swing_hbr_rbr[4][4] = { 129 + { 0x07, 0x0f, 0x16, 0x1f }, 130 + { 0x0d, 0x16, 0x1e, 0xff }, 131 + { 0x11, 0x1b, 0xff, 0xff }, 132 + { 0x16, 0xff, 0xff, 0xff } 133 + }; 134 + 135 + static const u8 edp_pre_emp_hbr_rbr[4][4] = { 136 + { 0x05, 0x12, 0x17, 0x1d }, 137 + { 0x05, 0x11, 0x18, 0xff }, 138 + { 0x06, 0x11, 0xff, 0xff }, 139 + { 0x00, 0xff, 0xff, 0xff } 140 + }; 141 + 142 + static const u8 edp_swing_hbr2_hbr3[4][4] = { 143 + { 0x0b, 0x11, 0x17, 0x1c }, 144 + { 0x10, 0x19, 0x1f, 0xff }, 145 + { 0x19, 0x1f, 0xff, 0xff }, 146 + { 0x1f, 0xff, 0xff, 0xff } 147 + }; 148 + 149 + static const u8 edp_pre_emp_hbr2_hbr3[4][4] = { 150 + { 0x08, 0x11, 0x17, 0x1b }, 151 + { 0x00, 0x0c, 0x13, 0xff }, 152 + { 0x05, 0x10, 0xff, 0xff }, 153 + { 0x00, 0xff, 0xff, 0xff } 154 + }; 155 + 156 + static const struct qcom_edp_cfg edp_phy_cfg = { 157 + .is_dp = false, 158 + .swing_hbr_rbr = &edp_swing_hbr_rbr, 159 + .swing_hbr3_hbr2 = &edp_swing_hbr2_hbr3, 160 + .pre_emphasis_hbr_rbr = &edp_pre_emp_hbr_rbr, 161 + .pre_emphasis_hbr3_hbr2 = &edp_pre_emp_hbr2_hbr3, 162 + }; 163 + 103 164 static int qcom_edp_phy_init(struct phy *phy) 104 165 { 105 166 struct qcom_edp *edp = phy_get_drvdata(phy); 167 + const struct qcom_edp_cfg *cfg = edp->cfg; 106 168 int ret; 169 + u8 cfg8; 107 170 108 171 ret = regulator_bulk_enable(ARRAY_SIZE(edp->supplies), edp->supplies); 109 172 if (ret) ··· 202 117 DP_PHY_PD_CTL_PLL_PWRDN | DP_PHY_PD_CTL_DP_CLAMP_EN, 203 118 edp->edp + DP_PHY_PD_CTL); 204 119 120 + if (cfg && cfg->is_dp) 121 + cfg8 = 0xb7; 122 + else 123 + cfg8 = 0x37; 124 + 125 + writel(0xfc, edp->edp + DP_PHY_MODE); 126 + 205 127 writel(0x00, edp->edp + DP_PHY_AUX_CFG0); 206 128 writel(0x13, edp->edp + DP_PHY_AUX_CFG1); 207 129 writel(0x24, edp->edp + DP_PHY_AUX_CFG2); ··· 217 125 writel(0x26, edp->edp + DP_PHY_AUX_CFG5); 218 126 writel(0x0a, edp->edp + DP_PHY_AUX_CFG6); 219 127 writel(0x03, edp->edp + DP_PHY_AUX_CFG7); 220 - writel(0x37, edp->edp + DP_PHY_AUX_CFG8); 128 + writel(cfg8, edp->edp + DP_PHY_AUX_CFG8); 221 129 writel(0x03, edp->edp + DP_PHY_AUX_CFG9); 222 130 223 131 writel(PHY_AUX_STOP_ERR_MASK | PHY_AUX_DEC_ERR_MASK | ··· 234 142 return ret; 235 143 } 236 144 145 + static int qcom_edp_set_voltages(struct qcom_edp *edp, const struct phy_configure_opts_dp *dp_opts) 146 + { 147 + const struct qcom_edp_cfg *cfg = edp->cfg; 148 + unsigned int v_level = 0; 149 + unsigned int p_level = 0; 150 + u8 ldo_config; 151 + u8 swing; 152 + u8 emph; 153 + int i; 154 + 155 + if (!cfg) 156 + return 0; 157 + 158 + for (i = 0; i < dp_opts->lanes; i++) { 159 + v_level = max(v_level, dp_opts->voltage[i]); 160 + p_level = max(p_level, dp_opts->pre[i]); 161 + } 162 + 163 + if (dp_opts->link_rate <= 2700) { 164 + swing = (*cfg->swing_hbr_rbr)[v_level][p_level]; 165 + emph = (*cfg->pre_emphasis_hbr_rbr)[v_level][p_level]; 166 + } else { 167 + swing = (*cfg->swing_hbr3_hbr2)[v_level][p_level]; 168 + emph = (*cfg->pre_emphasis_hbr3_hbr2)[v_level][p_level]; 169 + } 170 + 171 + if (swing == 0xff || emph == 0xff) 172 + return -EINVAL; 173 + 174 + ldo_config = (cfg && cfg->is_dp) ? 0x1 : 0x0; 175 + 176 + writel(ldo_config, edp->tx0 + TXn_LDO_CONFIG); 177 + writel(swing, edp->tx0 + TXn_TX_DRV_LVL); 178 + writel(emph, edp->tx0 + TXn_TX_EMP_POST1_LVL); 179 + 180 + writel(ldo_config, edp->tx1 + TXn_LDO_CONFIG); 181 + writel(swing, edp->tx1 + TXn_TX_DRV_LVL); 182 + writel(emph, edp->tx1 + TXn_TX_EMP_POST1_LVL); 183 + 184 + return 0; 185 + } 186 + 237 187 static int qcom_edp_phy_configure(struct phy *phy, union phy_configure_opts *opts) 238 188 { 239 189 const struct phy_configure_opts_dp *dp_opts = &opts->dp; 240 190 struct qcom_edp *edp = phy_get_drvdata(phy); 191 + int ret = 0; 241 192 242 193 memcpy(&edp->dp_opts, dp_opts, sizeof(*dp_opts)); 243 194 244 - return 0; 195 + if (dp_opts->set_voltages) 196 + ret = qcom_edp_set_voltages(edp, dp_opts); 197 + 198 + return ret; 245 199 } 246 200 247 201 static int qcom_edp_configure_ssc(const struct qcom_edp *edp) ··· 410 272 return 0; 411 273 } 412 274 413 - static int qcom_edp_set_vco_div(const struct qcom_edp *edp) 275 + static int qcom_edp_set_vco_div(const struct qcom_edp *edp, unsigned long *pixel_freq) 414 276 { 415 277 const struct phy_configure_opts_dp *dp_opts = &edp->dp_opts; 416 - unsigned long pixel_freq; 417 278 u32 vco_div; 418 279 419 280 switch (dp_opts->link_rate) { 420 281 case 1620: 421 282 vco_div = 0x1; 422 - pixel_freq = 1620000000UL / 2; 283 + *pixel_freq = 1620000000UL / 2; 423 284 break; 424 285 425 286 case 2700: 426 287 vco_div = 0x1; 427 - pixel_freq = 2700000000UL / 2; 288 + *pixel_freq = 2700000000UL / 2; 428 289 break; 429 290 430 291 case 5400: 431 292 vco_div = 0x2; 432 - pixel_freq = 5400000000UL / 4; 293 + *pixel_freq = 5400000000UL / 4; 433 294 break; 434 295 435 296 case 8100: 436 297 vco_div = 0x0; 437 - pixel_freq = 8100000000UL / 6; 298 + *pixel_freq = 8100000000UL / 6; 438 299 break; 439 300 440 301 default: ··· 443 306 444 307 writel(vco_div, edp->edp + DP_PHY_VCO_DIV); 445 308 446 - clk_set_rate(edp->dp_link_hw.clk, dp_opts->link_rate * 100000); 447 - clk_set_rate(edp->dp_pixel_hw.clk, pixel_freq); 448 - 449 309 return 0; 450 310 } 451 311 452 312 static int qcom_edp_phy_power_on(struct phy *phy) 453 313 { 454 314 const struct qcom_edp *edp = phy_get_drvdata(phy); 315 + const struct qcom_edp_cfg *cfg = edp->cfg; 316 + u32 bias0_en, drvr0_en, bias1_en, drvr1_en; 317 + unsigned long pixel_freq; 318 + u8 ldo_config; 455 319 int timeout; 456 320 int ret; 457 321 u32 val; 322 + u8 cfg1; 458 323 459 324 writel(DP_PHY_PD_CTL_PWRDN | DP_PHY_PD_CTL_AUX_PWRDN | 460 325 DP_PHY_PD_CTL_LANE_0_1_PWRDN | DP_PHY_PD_CTL_LANE_2_3_PWRDN | ··· 469 330 if (timeout) 470 331 return timeout; 471 332 472 - writel(0x01, edp->tx0 + TXn_LDO_CONFIG); 473 - writel(0x01, edp->tx1 + TXn_LDO_CONFIG); 333 + 334 + ldo_config = (cfg && cfg->is_dp) ? 0x1 : 0x0; 335 + 336 + writel(ldo_config, edp->tx0 + TXn_LDO_CONFIG); 337 + writel(ldo_config, edp->tx1 + TXn_LDO_CONFIG); 474 338 writel(0x00, edp->tx0 + TXn_LANE_MODE_1); 475 339 writel(0x00, edp->tx1 + TXn_LANE_MODE_1); 476 340 ··· 505 363 writel(0x01, edp->tx1 + TXn_TRAN_DRVR_EMP_EN); 506 364 writel(0x04, edp->tx1 + TXn_TX_BAND); 507 365 508 - ret = qcom_edp_set_vco_div(edp); 366 + ret = qcom_edp_set_vco_div(edp, &pixel_freq); 509 367 if (ret) 510 368 return ret; 511 369 ··· 540 398 writel(0x1f, edp->tx0 + TXn_TX_DRV_LVL); 541 399 writel(0x1f, edp->tx1 + TXn_TX_DRV_LVL); 542 400 543 - writel(0x4, edp->tx0 + TXn_HIGHZ_DRVR_EN); 544 - writel(0x3, edp->tx0 + TXn_TRANSCEIVER_BIAS_EN); 545 - writel(0x4, edp->tx1 + TXn_HIGHZ_DRVR_EN); 546 - writel(0x0, edp->tx1 + TXn_TRANSCEIVER_BIAS_EN); 547 - writel(0x3, edp->edp + DP_PHY_CFG_1); 401 + if (edp->dp_opts.lanes == 1) { 402 + bias0_en = 0x01; 403 + bias1_en = 0x00; 404 + drvr0_en = 0x06; 405 + drvr1_en = 0x07; 406 + cfg1 = 0x1; 407 + } else if (edp->dp_opts.lanes == 2) { 408 + bias0_en = 0x03; 409 + bias1_en = 0x00; 410 + drvr0_en = 0x04; 411 + drvr1_en = 0x07; 412 + cfg1 = 0x3; 413 + } else { 414 + bias0_en = 0x03; 415 + bias1_en = 0x03; 416 + drvr0_en = 0x04; 417 + drvr1_en = 0x04; 418 + cfg1 = 0xf; 419 + } 420 + 421 + writel(drvr0_en, edp->tx0 + TXn_HIGHZ_DRVR_EN); 422 + writel(bias0_en, edp->tx0 + TXn_TRANSCEIVER_BIAS_EN); 423 + writel(drvr1_en, edp->tx1 + TXn_HIGHZ_DRVR_EN); 424 + writel(bias1_en, edp->tx1 + TXn_TRANSCEIVER_BIAS_EN); 425 + writel(cfg1, edp->edp + DP_PHY_CFG_1); 548 426 549 427 writel(0x18, edp->edp + DP_PHY_CFG); 550 428 usleep_range(100, 1000); 551 429 552 430 writel(0x19, edp->edp + DP_PHY_CFG); 553 431 554 - return readl_poll_timeout(edp->edp + DP_PHY_STATUS, 555 - val, val & BIT(1), 500, 10000); 432 + ret = readl_poll_timeout(edp->edp + DP_PHY_STATUS, 433 + val, val & BIT(1), 500, 10000); 434 + if (ret) 435 + return ret; 436 + 437 + clk_set_rate(edp->dp_link_hw.clk, edp->dp_opts.link_rate * 100000); 438 + clk_set_rate(edp->dp_pixel_hw.clk, pixel_freq); 439 + 440 + return 0; 556 441 } 557 442 558 443 static int qcom_edp_phy_power_off(struct phy *phy) ··· 740 571 { 741 572 struct clk_hw_onecell_data *data; 742 573 struct clk_init_data init = { }; 574 + char name[64]; 743 575 int ret; 744 576 745 577 data = devm_kzalloc(edp->dev, struct_size(data, hws, 2), GFP_KERNEL); 746 578 if (!data) 747 579 return -ENOMEM; 748 580 581 + snprintf(name, sizeof(name), "%s::link_clk", dev_name(edp->dev)); 749 582 init.ops = &qcom_edp_dp_link_clk_ops; 750 - init.name = "edp_phy_pll_link_clk"; 583 + init.name = name; 751 584 edp->dp_link_hw.init = &init; 752 585 ret = devm_clk_hw_register(edp->dev, &edp->dp_link_hw); 753 586 if (ret) 754 587 return ret; 755 588 589 + snprintf(name, sizeof(name), "%s::vco_div_clk", dev_name(edp->dev)); 756 590 init.ops = &qcom_edp_dp_pixel_clk_ops; 757 - init.name = "edp_phy_pll_vco_div_clk"; 591 + init.name = name; 758 592 edp->dp_pixel_hw.init = &init; 759 593 ret = devm_clk_hw_register(edp->dev, &edp->dp_pixel_hw); 760 594 if (ret) ··· 782 610 return -ENOMEM; 783 611 784 612 edp->dev = dev; 613 + edp->cfg = of_device_get_match_data(&pdev->dev); 785 614 786 615 edp->edp = devm_platform_ioremap_resource(pdev, 0); 787 616 if (IS_ERR(edp->edp)) ··· 843 670 static const struct of_device_id qcom_edp_phy_match_table[] = { 844 671 { .compatible = "qcom,sc7280-edp-phy" }, 845 672 { .compatible = "qcom,sc8180x-edp-phy" }, 673 + { .compatible = "qcom,sc8280xp-dp-phy", .data = &dp_phy_cfg }, 674 + { .compatible = "qcom,sc8280xp-edp-phy", .data = &edp_phy_cfg }, 846 675 { } 847 676 }; 848 677 MODULE_DEVICE_TABLE(of, qcom_edp_phy_match_table);
+563 -256
drivers/phy/qualcomm/phy-qcom-qmp-combo.c
··· 28 28 #define SW_RESET BIT(0) 29 29 /* QPHY_POWER_DOWN_CONTROL */ 30 30 #define SW_PWRDN BIT(0) 31 - #define REFCLK_DRV_DSBL BIT(1) 32 31 /* QPHY_START_CONTROL bits */ 33 32 #define SERDES_START BIT(0) 34 33 #define PCS_START BIT(1) 35 - #define PLL_READY_GATE_EN BIT(3) 36 34 /* QPHY_PCS_STATUS bit */ 37 35 #define PHYSTATUS BIT(6) 38 - #define PHYSTATUS_4_20 BIT(7) 39 - /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 40 - #define PCS_READY BIT(0) 41 36 42 37 /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 43 38 /* DP PHY soft reset */ ··· 65 70 #define PHY_INIT_COMPLETE_TIMEOUT 10000 66 71 #define POWER_DOWN_DELAY_US_MIN 10 67 72 #define POWER_DOWN_DELAY_US_MAX 11 68 - 69 - #define MAX_PROP_NAME 32 70 - 71 - /* Define the assumed distance between lanes for underspecified device trees. */ 72 - #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 73 73 74 74 struct qmp_phy_init_tbl { 75 75 unsigned int offset; ··· 105 115 106 116 /* set of registers with offsets different per-PHY */ 107 117 enum qphy_reg_layout { 108 - /* Common block control registers */ 109 - QPHY_COM_SW_RESET, 110 - QPHY_COM_POWER_DOWN_CONTROL, 111 - QPHY_COM_START_CONTROL, 112 - QPHY_COM_PCS_READY_STATUS, 113 118 /* PCS registers */ 114 119 QPHY_SW_RESET, 115 120 QPHY_START_CTRL, 116 - QPHY_PCS_READY_STATUS, 117 121 QPHY_PCS_STATUS, 118 122 QPHY_PCS_AUTONOMOUS_MODE_CTRL, 119 123 QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 120 124 QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 121 125 QPHY_PCS_POWER_DOWN_CONTROL, 122 - /* PCS_MISC registers */ 123 - QPHY_PCS_MISC_TYPEC_CTRL, 124 126 /* Keep last to ensure regs_layout arrays are properly initialized */ 125 127 QPHY_LAYOUT_SIZE 126 128 }; ··· 588 606 QMP_PHY_INIT_CFG(QSERDES_V4_TX_TX_EMP_POST1_LVL, 0x20), 589 607 }; 590 608 609 + static const struct qmp_phy_init_tbl qmp_v5_dp_serdes_tbl[] = { 610 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_SVS_MODE_CLK_SEL, 0x05), 611 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_EN_SEL, 0x3b), 612 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYS_CLK_CTRL, 0x02), 613 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_ENABLE1, 0x0c), 614 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_SYSCLK_BUF_ENABLE, 0x06), 615 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CLK_SELECT, 0x30), 616 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_IVCO, 0x0f), 617 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE0, 0x36), 618 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_CCTRL_MODE1, 0x36), 619 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE0, 0x16), 620 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_PLL_RCTRL_MODE1, 0x16), 621 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE0, 0x06), 622 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CP_CTRL_MODE1, 0x06), 623 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CMN_CONFIG, 0x02), 624 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN0_MODE0, 0x3f), 625 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_INTEGLOOP_GAIN1_MODE0, 0x00), 626 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_MAP, 0x02), 627 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_DIV_FRAC_START1_MODE0, 0x00), 628 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_BG_TIMER, 0x0a), 629 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORECLK_DIV_MODE0, 0x0a), 630 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_VCO_TUNE_CTRL, 0x00), 631 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_BIAS_EN_CLKBUFLR_EN, 0x17), 632 + QMP_PHY_INIT_CFG(QSERDES_V4_COM_CORE_CLK_EN, 0x1f), 633 + }; 634 + 635 + static const struct qmp_phy_init_tbl qmp_v5_5nm_dp_tx_tbl[] = { 636 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_3, 0x51), 637 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN, 0x1a), 638 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_VMODE_CTRL1, 0x40), 639 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_PRE_STALL_LDO_BOOST_EN, 0x0), 640 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_INTERFACE_SELECT, 0xff), 641 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_CLKBUF_ENABLE, 0x0f), 642 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RESET_TSYNC_EN, 0x03), 643 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TRAN_DRVR_EMP_EN, 0xf), 644 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_PARRATE_REC_DETECT_IDLE_EN, 0x00), 645 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX, 0x11), 646 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX, 0x11), 647 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_TX_BAND, 0x01), 648 + }; 649 + 650 + static const struct qmp_phy_init_tbl sc8280xp_usb43dp_serdes_tbl[] = { 651 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01), 652 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 653 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 654 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xfd), 655 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x0d), 656 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0xfd), 657 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x0d), 658 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x0a), 659 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x02), 660 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x02), 661 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 662 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 663 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 664 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 665 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x1a), 666 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x04), 667 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x14), 668 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x34), 669 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x34), 670 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x82), 671 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x04), 672 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MSB_MODE0, 0x01), 673 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x04), 674 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MSB_MODE1, 0x01), 675 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0x55), 676 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0xd5), 677 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x05), 678 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0x55), 679 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xd5), 680 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x05), 681 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 682 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0xd4), 683 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE0, 0x00), 684 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0xd4), 685 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x00), 686 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x13), 687 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_HS_SWITCH_SEL, 0x00), 688 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE0, 0x0a), 689 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x04), 690 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORE_CLK_EN, 0x60), 691 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CMN_CONFIG, 0x76), 692 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_IVCO, 0xff), 693 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE0, 0x20), 694 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_INTEGLOOP_GAIN0_MODE1, 0x20), 695 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_INITVAL2, 0x00), 696 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAXVAL2, 0x01), 697 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SVS_MODE_CLK_SEL, 0x0a), 698 + }; 699 + 700 + static const struct qmp_phy_init_tbl sc8280xp_usb43dp_tx_tbl[] = { 701 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_1, 0x05), 702 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_2, 0xc2), 703 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_LANE_MODE_3, 0x10), 704 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX, 0x1f), 705 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX, 0x0a), 706 + }; 707 + 708 + static const struct qmp_phy_init_tbl sc8280xp_usb43dp_rx_tbl[] = { 709 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_CNTRL, 0x04), 710 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_DEGLITCH_CNTRL, 0x0e), 711 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_SIGDET_ENABLES, 0x00), 712 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B0, 0xd2), 713 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B1, 0xd2), 714 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B2, 0xdb), 715 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B3, 0x21), 716 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B4, 0x3f), 717 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B5, 0x80), 718 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B6, 0x45), 719 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B7, 0x00), 720 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B0, 0x6b), 721 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B1, 0x63), 722 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B2, 0xb6), 723 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B3, 0x23), 724 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B4, 0x35), 725 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B5, 0x30), 726 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B6, 0x8e), 727 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_MODE_RATE2_B7, 0x00), 728 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_CAL_CODE_OVERRIDE, 0x00), 729 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_CAL_CTRL2, 0x80), 730 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_SUMMER_CAL_SPD_MODE, 0x1b), 731 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 732 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_PI_CONTROLS, 0x15), 733 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE2, 0x0a), 734 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_RX_IVCM_POSTCAL_OFFSET, 0x7c), 735 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_VGA_CAL_CNTRL1, 0x00), 736 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_VGA_CAL_MAN_VAL, 0x0d), 737 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_DAC_ENABLE1, 0x00), 738 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_DFE_3, 0x45), 739 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_GM_CAL, 0x09), 740 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE2, 0x09), 741 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE2, 0x05), 742 + QMP_PHY_INIT_CFG(QSERDES_V5_5NM_RX_Q_PI_INTRINSIC_BIAS_RATE32, 0x3f), 743 + }; 744 + 745 + static const struct qmp_phy_init_tbl sc8280xp_usb43dp_pcs_tbl[] = { 746 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), 747 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), 748 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG1, 0xd0), 749 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG2, 0x07), 750 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG3, 0x20), 751 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG6, 0x13), 752 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x21), 753 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0xaa), 754 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_CONFIG, 0x0a), 755 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG1, 0x88), 756 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG2, 0x13), 757 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCS_TX_RX_CONFIG, 0x0c), 758 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG1, 0x4b), 759 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG5, 0x10), 760 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8), 761 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07), 762 + }; 591 763 592 764 /* list of regulators */ 593 765 struct qmp_regulator_data { ··· 754 618 { .name = "vdda-pll", .enable_load = 36000 }, 755 619 }; 756 620 621 + static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = { 622 + { 0x00, 0x0c, 0x15, 0x1a }, 623 + { 0x02, 0x0e, 0x16, 0xff }, 624 + { 0x02, 0x11, 0xff, 0xff }, 625 + { 0x04, 0xff, 0xff, 0xff } 626 + }; 627 + 628 + static const u8 qmp_dp_v3_voltage_swing_hbr3_hbr2[4][4] = { 629 + { 0x02, 0x12, 0x16, 0x1a }, 630 + { 0x09, 0x19, 0x1f, 0xff }, 631 + { 0x10, 0x1f, 0xff, 0xff }, 632 + { 0x1f, 0xff, 0xff, 0xff } 633 + }; 634 + 635 + static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = { 636 + { 0x00, 0x0c, 0x14, 0x19 }, 637 + { 0x00, 0x0b, 0x12, 0xff }, 638 + { 0x00, 0x0b, 0xff, 0xff }, 639 + { 0x04, 0xff, 0xff, 0xff } 640 + }; 641 + 642 + static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = { 643 + { 0x08, 0x0f, 0x16, 0x1f }, 644 + { 0x11, 0x1e, 0x1f, 0xff }, 645 + { 0x19, 0x1f, 0xff, 0xff }, 646 + { 0x1f, 0xff, 0xff, 0xff } 647 + }; 648 + 649 + static const u8 qmp_dp_v5_pre_emphasis_hbr3_hbr2[4][4] = { 650 + { 0x20, 0x2c, 0x35, 0x3b }, 651 + { 0x22, 0x2e, 0x36, 0xff }, 652 + { 0x22, 0x31, 0xff, 0xff }, 653 + { 0x24, 0xff, 0xff, 0xff } 654 + }; 655 + 656 + static const u8 qmp_dp_v5_voltage_swing_hbr3_hbr2[4][4] = { 657 + { 0x22, 0x32, 0x36, 0x3a }, 658 + { 0x29, 0x39, 0x3f, 0xff }, 659 + { 0x30, 0x3f, 0xff, 0xff }, 660 + { 0x3f, 0xff, 0xff, 0xff } 661 + }; 662 + 663 + static const u8 qmp_dp_v5_pre_emphasis_hbr_rbr[4][4] = { 664 + { 0x20, 0x2d, 0x34, 0x3a }, 665 + { 0x20, 0x2e, 0x35, 0xff }, 666 + { 0x20, 0x2e, 0xff, 0xff }, 667 + { 0x24, 0xff, 0xff, 0xff } 668 + }; 669 + 670 + static const u8 qmp_dp_v5_voltage_swing_hbr_rbr[4][4] = { 671 + { 0x28, 0x2f, 0x36, 0x3f }, 672 + { 0x31, 0x3e, 0x3f, 0xff }, 673 + { 0x36, 0x3f, 0xff, 0xff }, 674 + { 0x3f, 0xff, 0xff, 0xff } 675 + }; 676 + 757 677 struct qmp_phy; 758 678 759 679 /* struct qmp_phy_cfg - per-PHY initialization config */ 760 680 struct qmp_phy_cfg { 761 681 /* phy-type - PCIE/UFS/USB */ 762 682 unsigned int type; 763 - /* number of lanes provided by phy */ 764 - int nlanes; 683 + int lanes; 765 684 766 685 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 767 686 const struct qmp_phy_init_tbl *serdes_tbl; ··· 839 648 int serdes_tbl_hbr2_num; 840 649 const struct qmp_phy_init_tbl *serdes_tbl_hbr3; 841 650 int serdes_tbl_hbr3_num; 651 + 652 + /* DP PHY swing and pre_emphasis tables */ 653 + const u8 (*swing_hbr_rbr)[4][4]; 654 + const u8 (*swing_hbr3_hbr2)[4][4]; 655 + const u8 (*pre_emphasis_hbr_rbr)[4][4]; 656 + const u8 (*pre_emphasis_hbr3_hbr2)[4][4]; 842 657 843 658 /* DP PHY callbacks */ 844 659 int (*configure_dp_phy)(struct qmp_phy *qphy); ··· 876 679 int pwrdn_delay_min; 877 680 int pwrdn_delay_max; 878 681 879 - /* true, if PHY has a separate DP_COM control block */ 880 - bool has_phy_dp_com_ctrl; 881 - /* true, if PHY has secondary tx/rx lanes to be configured */ 882 - bool is_dual_lane_phy; 883 - 884 682 /* Offset from PCS to PCS_USB region */ 885 683 unsigned int pcs_usb_offset; 886 684 ··· 900 708 * @pcs_misc: iomapped memory space for lane's pcs_misc 901 709 * @pcs_usb: iomapped memory space for lane's pcs_usb 902 710 * @pipe_clk: pipe clock 903 - * @index: lane index 904 711 * @qmp: QMP phy to which this lane belongs 905 - * @lane_rst: lane's reset controller 906 712 * @mode: current PHY mode 907 713 * @dp_aux_cfg: Display port aux config 908 714 * @dp_opts: Display port optional config ··· 918 728 void __iomem *pcs_misc; 919 729 void __iomem *pcs_usb; 920 730 struct clk *pipe_clk; 921 - unsigned int index; 922 731 struct qcom_qmp *qmp; 923 - struct reset_control *lane_rst; 924 732 enum phy_mode mode; 925 733 unsigned int dp_aux_cfg; 926 734 struct phy_configure_opts_dp dp_opts; ··· 972 784 static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy); 973 785 static int qcom_qmp_v4_dp_phy_calibrate(struct qmp_phy *qphy); 974 786 787 + static int qcom_qmp_v5_phy_configure_dp_phy(struct qmp_phy *qphy); 788 + 975 789 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) 976 790 { 977 791 u32 reg; ··· 1023 833 1024 834 static const struct qmp_phy_cfg sc7180_usb3phy_cfg = { 1025 835 .type = PHY_TYPE_USB3, 1026 - .nlanes = 1, 836 + .lanes = 2, 1027 837 1028 838 .serdes_tbl = qmp_v3_usb3_serdes_tbl, 1029 839 .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), ··· 1048 858 .has_pwrdn_delay = true, 1049 859 .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 1050 860 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1051 - 1052 - .has_phy_dp_com_ctrl = true, 1053 - .is_dual_lane_phy = true, 1054 861 }; 1055 862 1056 863 static const struct qmp_phy_cfg sc7180_dpphy_cfg = { 1057 864 .type = PHY_TYPE_DP, 1058 - .nlanes = 1, 865 + .lanes = 2, 1059 866 1060 867 .serdes_tbl = qmp_v3_dp_serdes_tbl, 1061 868 .serdes_tbl_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl), ··· 1068 881 .serdes_tbl_hbr3 = qmp_v3_dp_serdes_tbl_hbr3, 1069 882 .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v3_dp_serdes_tbl_hbr3), 1070 883 884 + .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr, 885 + .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr, 886 + .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2, 887 + .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2, 888 + 1071 889 .clk_list = qmp_v3_phy_clk_l, 1072 890 .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), 1073 891 .reset_list = sc7180_usb3phy_reset_l, ··· 1080 888 .vreg_list = qmp_phy_vreg_l, 1081 889 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1082 890 .regs = qmp_v3_usb3phy_regs_layout, 1083 - 1084 - .has_phy_dp_com_ctrl = true, 1085 - .is_dual_lane_phy = true, 1086 891 1087 892 .dp_aux_init = qcom_qmp_v3_phy_dp_aux_init, 1088 893 .configure_dp_tx = qcom_qmp_v3_phy_configure_dp_tx, ··· 1092 903 .dp_cfg = &sc7180_dpphy_cfg, 1093 904 }; 1094 905 906 + static const struct qmp_phy_cfg sdm845_usb3phy_cfg = { 907 + .type = PHY_TYPE_USB3, 908 + .lanes = 2, 909 + 910 + .serdes_tbl = qmp_v3_usb3_serdes_tbl, 911 + .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), 912 + .tx_tbl = qmp_v3_usb3_tx_tbl, 913 + .tx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_tx_tbl), 914 + .rx_tbl = qmp_v3_usb3_rx_tbl, 915 + .rx_tbl_num = ARRAY_SIZE(qmp_v3_usb3_rx_tbl), 916 + .pcs_tbl = qmp_v3_usb3_pcs_tbl, 917 + .pcs_tbl_num = ARRAY_SIZE(qmp_v3_usb3_pcs_tbl), 918 + .clk_list = qmp_v3_phy_clk_l, 919 + .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), 920 + .reset_list = msm8996_usb3phy_reset_l, 921 + .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 922 + .vreg_list = qmp_phy_vreg_l, 923 + .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 924 + .regs = qmp_v3_usb3phy_regs_layout, 925 + 926 + .start_ctrl = SERDES_START | PCS_START, 927 + .pwrdn_ctrl = SW_PWRDN, 928 + .phy_status = PHYSTATUS, 929 + 930 + .has_pwrdn_delay = true, 931 + .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 932 + .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 933 + }; 934 + 935 + static const struct qmp_phy_combo_cfg sdm845_usb3dpphy_cfg = { 936 + .usb_cfg = &sdm845_usb3phy_cfg, 937 + .dp_cfg = &sc7180_dpphy_cfg, 938 + }; 939 + 1095 940 static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { 1096 941 .type = PHY_TYPE_USB3, 1097 - .nlanes = 1, 942 + .lanes = 2, 1098 943 1099 944 .serdes_tbl = sm8150_usb3_serdes_tbl, 1100 945 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), ··· 1157 934 .has_pwrdn_delay = true, 1158 935 .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 1159 936 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1160 - 1161 - .has_phy_dp_com_ctrl = true, 1162 - .is_dual_lane_phy = true, 1163 937 }; 1164 938 1165 939 static const struct qmp_phy_cfg sc8180x_dpphy_cfg = { 1166 940 .type = PHY_TYPE_DP, 1167 - .nlanes = 1, 941 + .lanes = 2, 1168 942 1169 943 .serdes_tbl = qmp_v4_dp_serdes_tbl, 1170 944 .serdes_tbl_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl), ··· 1177 957 .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3, 1178 958 .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3), 1179 959 960 + .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr, 961 + .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr, 962 + .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2, 963 + .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2, 964 + 1180 965 .clk_list = qmp_v3_phy_clk_l, 1181 966 .num_clks = ARRAY_SIZE(qmp_v3_phy_clk_l), 1182 967 .reset_list = sc7180_usb3phy_reset_l, ··· 1189 964 .vreg_list = qmp_phy_vreg_l, 1190 965 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1191 966 .regs = qmp_v3_usb3phy_regs_layout, 1192 - 1193 - .has_phy_dp_com_ctrl = true, 1194 - .is_dual_lane_phy = true, 1195 967 1196 968 .dp_aux_init = qcom_qmp_v4_phy_dp_aux_init, 1197 969 .configure_dp_tx = qcom_qmp_v4_phy_configure_dp_tx, ··· 1201 979 .dp_cfg = &sc8180x_dpphy_cfg, 1202 980 }; 1203 981 982 + static const struct qmp_phy_cfg sc8280xp_usb43dp_usb_cfg = { 983 + .type = PHY_TYPE_USB3, 984 + .lanes = 2, 985 + 986 + .serdes_tbl = sc8280xp_usb43dp_serdes_tbl, 987 + .serdes_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_serdes_tbl), 988 + .tx_tbl = sc8280xp_usb43dp_tx_tbl, 989 + .tx_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_tx_tbl), 990 + .rx_tbl = sc8280xp_usb43dp_rx_tbl, 991 + .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_rx_tbl), 992 + .pcs_tbl = sc8280xp_usb43dp_pcs_tbl, 993 + .pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb43dp_pcs_tbl), 994 + .clk_list = qmp_v4_phy_clk_l, 995 + .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 996 + .reset_list = msm8996_usb3phy_reset_l, 997 + .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 998 + .vreg_list = qmp_phy_vreg_l, 999 + .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1000 + .regs = qmp_v4_usb3phy_regs_layout, 1001 + .pcs_usb_offset = 0x300, 1002 + 1003 + .start_ctrl = SERDES_START | PCS_START, 1004 + .pwrdn_ctrl = SW_PWRDN, 1005 + .phy_status = PHYSTATUS, 1006 + 1007 + .has_pwrdn_delay = true, 1008 + .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 1009 + .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1010 + }; 1011 + 1012 + static const struct qmp_phy_cfg sc8280xp_usb43dp_dp_cfg = { 1013 + .type = PHY_TYPE_DP, 1014 + .lanes = 2, 1015 + 1016 + .serdes_tbl = qmp_v5_dp_serdes_tbl, 1017 + .serdes_tbl_num = ARRAY_SIZE(qmp_v5_dp_serdes_tbl), 1018 + .tx_tbl = qmp_v5_5nm_dp_tx_tbl, 1019 + .tx_tbl_num = ARRAY_SIZE(qmp_v5_5nm_dp_tx_tbl), 1020 + 1021 + .serdes_tbl_rbr = qmp_v4_dp_serdes_tbl_rbr, 1022 + .serdes_tbl_rbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_rbr), 1023 + .serdes_tbl_hbr = qmp_v4_dp_serdes_tbl_hbr, 1024 + .serdes_tbl_hbr_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr), 1025 + .serdes_tbl_hbr2 = qmp_v4_dp_serdes_tbl_hbr2, 1026 + .serdes_tbl_hbr2_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr2), 1027 + .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3, 1028 + .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3), 1029 + 1030 + .swing_hbr_rbr = &qmp_dp_v5_voltage_swing_hbr_rbr, 1031 + .pre_emphasis_hbr_rbr = &qmp_dp_v5_pre_emphasis_hbr_rbr, 1032 + .swing_hbr3_hbr2 = &qmp_dp_v5_voltage_swing_hbr3_hbr2, 1033 + .pre_emphasis_hbr3_hbr2 = &qmp_dp_v5_pre_emphasis_hbr3_hbr2, 1034 + 1035 + .clk_list = qmp_v4_phy_clk_l, 1036 + .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 1037 + .reset_list = msm8996_usb3phy_reset_l, 1038 + .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1039 + .vreg_list = qmp_phy_vreg_l, 1040 + .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1041 + .regs = qmp_v4_usb3phy_regs_layout, 1042 + 1043 + .dp_aux_init = qcom_qmp_v4_phy_dp_aux_init, 1044 + .configure_dp_tx = qcom_qmp_v4_phy_configure_dp_tx, 1045 + .configure_dp_phy = qcom_qmp_v5_phy_configure_dp_phy, 1046 + .calibrate_dp_phy = qcom_qmp_v4_dp_phy_calibrate, 1047 + }; 1048 + 1049 + static const struct qmp_phy_combo_cfg sc8280xp_usb43dpphy_combo_cfg = { 1050 + .usb_cfg = &sc8280xp_usb43dp_usb_cfg, 1051 + .dp_cfg = &sc8280xp_usb43dp_dp_cfg, 1052 + }; 1053 + 1204 1054 static const struct qmp_phy_cfg sm8250_usb3phy_cfg = { 1205 1055 .type = PHY_TYPE_USB3, 1206 - .nlanes = 1, 1056 + .lanes = 2, 1207 1057 1208 1058 .serdes_tbl = sm8150_usb3_serdes_tbl, 1209 1059 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), ··· 1303 1009 .has_pwrdn_delay = true, 1304 1010 .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 1305 1011 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1306 - 1307 - .has_phy_dp_com_ctrl = true, 1308 - .is_dual_lane_phy = true, 1309 1012 }; 1310 1013 1311 1014 static const struct qmp_phy_cfg sm8250_dpphy_cfg = { 1312 1015 .type = PHY_TYPE_DP, 1313 - .nlanes = 1, 1016 + .lanes = 2, 1314 1017 1315 1018 .serdes_tbl = qmp_v4_dp_serdes_tbl, 1316 1019 .serdes_tbl_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl), ··· 1323 1032 .serdes_tbl_hbr3 = qmp_v4_dp_serdes_tbl_hbr3, 1324 1033 .serdes_tbl_hbr3_num = ARRAY_SIZE(qmp_v4_dp_serdes_tbl_hbr3), 1325 1034 1035 + .swing_hbr_rbr = &qmp_dp_v3_voltage_swing_hbr_rbr, 1036 + .pre_emphasis_hbr_rbr = &qmp_dp_v3_pre_emphasis_hbr_rbr, 1037 + .swing_hbr3_hbr2 = &qmp_dp_v3_voltage_swing_hbr3_hbr2, 1038 + .pre_emphasis_hbr3_hbr2 = &qmp_dp_v3_pre_emphasis_hbr3_hbr2, 1039 + 1326 1040 .clk_list = qmp_v4_phy_clk_l, 1327 1041 .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 1328 1042 .reset_list = msm8996_usb3phy_reset_l, ··· 1335 1039 .vreg_list = qmp_phy_vreg_l, 1336 1040 .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1337 1041 .regs = qmp_v4_usb3phy_regs_layout, 1338 - 1339 - .has_phy_dp_com_ctrl = true, 1340 - .is_dual_lane_phy = true, 1341 1042 1342 1043 .dp_aux_init = qcom_qmp_v4_phy_dp_aux_init, 1343 1044 .configure_dp_tx = qcom_qmp_v4_phy_configure_dp_tx, ··· 1347 1054 .dp_cfg = &sm8250_dpphy_cfg, 1348 1055 }; 1349 1056 1350 - static void qcom_qmp_phy_combo_configure_lane(void __iomem *base, 1057 + static void qmp_combo_configure_lane(void __iomem *base, 1351 1058 const unsigned int *regs, 1352 1059 const struct qmp_phy_init_tbl tbl[], 1353 1060 int num, ··· 1370 1077 } 1371 1078 } 1372 1079 1373 - static void qcom_qmp_phy_combo_configure(void __iomem *base, 1080 + static void qmp_combo_configure(void __iomem *base, 1374 1081 const unsigned int *regs, 1375 1082 const struct qmp_phy_init_tbl tbl[], 1376 1083 int num) 1377 1084 { 1378 - qcom_qmp_phy_combo_configure_lane(base, regs, tbl, num, 0xff); 1085 + qmp_combo_configure_lane(base, regs, tbl, num, 0xff); 1379 1086 } 1380 1087 1381 - static int qcom_qmp_phy_combo_serdes_init(struct qmp_phy *qphy) 1088 + static int qmp_combo_serdes_init(struct qmp_phy *qphy) 1382 1089 { 1383 1090 const struct qmp_phy_cfg *cfg = qphy->cfg; 1384 1091 void __iomem *serdes = qphy->serdes; ··· 1386 1093 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 1387 1094 int serdes_tbl_num = cfg->serdes_tbl_num; 1388 1095 1389 - qcom_qmp_phy_combo_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 1096 + qmp_combo_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 1390 1097 1391 1098 if (cfg->type == PHY_TYPE_DP) { 1392 1099 switch (dp_opts->link_rate) { 1393 1100 case 1620: 1394 - qcom_qmp_phy_combo_configure(serdes, cfg->regs, 1101 + qmp_combo_configure(serdes, cfg->regs, 1395 1102 cfg->serdes_tbl_rbr, 1396 1103 cfg->serdes_tbl_rbr_num); 1397 1104 break; 1398 1105 case 2700: 1399 - qcom_qmp_phy_combo_configure(serdes, cfg->regs, 1106 + qmp_combo_configure(serdes, cfg->regs, 1400 1107 cfg->serdes_tbl_hbr, 1401 1108 cfg->serdes_tbl_hbr_num); 1402 1109 break; 1403 1110 case 5400: 1404 - qcom_qmp_phy_combo_configure(serdes, cfg->regs, 1111 + qmp_combo_configure(serdes, cfg->regs, 1405 1112 cfg->serdes_tbl_hbr2, 1406 1113 cfg->serdes_tbl_hbr2_num); 1407 1114 break; 1408 1115 case 8100: 1409 - qcom_qmp_phy_combo_configure(serdes, cfg->regs, 1116 + qmp_combo_configure(serdes, cfg->regs, 1410 1117 cfg->serdes_tbl_hbr3, 1411 1118 cfg->serdes_tbl_hbr3_num); 1412 1119 break; ··· 1462 1169 qphy->pcs + QSERDES_V3_DP_PHY_AUX_INTERRUPT_MASK); 1463 1170 } 1464 1171 1465 - static const u8 qmp_dp_v3_pre_emphasis_hbr3_hbr2[4][4] = { 1466 - { 0x00, 0x0c, 0x15, 0x1a }, 1467 - { 0x02, 0x0e, 0x16, 0xff }, 1468 - { 0x02, 0x11, 0xff, 0xff }, 1469 - { 0x04, 0xff, 0xff, 0xff } 1470 - }; 1471 - 1472 - static const u8 qmp_dp_v3_voltage_swing_hbr3_hbr2[4][4] = { 1473 - { 0x02, 0x12, 0x16, 0x1a }, 1474 - { 0x09, 0x19, 0x1f, 0xff }, 1475 - { 0x10, 0x1f, 0xff, 0xff }, 1476 - { 0x1f, 0xff, 0xff, 0xff } 1477 - }; 1478 - 1479 - static const u8 qmp_dp_v3_pre_emphasis_hbr_rbr[4][4] = { 1480 - { 0x00, 0x0c, 0x14, 0x19 }, 1481 - { 0x00, 0x0b, 0x12, 0xff }, 1482 - { 0x00, 0x0b, 0xff, 0xff }, 1483 - { 0x04, 0xff, 0xff, 0xff } 1484 - }; 1485 - 1486 - static const u8 qmp_dp_v3_voltage_swing_hbr_rbr[4][4] = { 1487 - { 0x08, 0x0f, 0x16, 0x1f }, 1488 - { 0x11, 0x1e, 0x1f, 0xff }, 1489 - { 0x19, 0x1f, 0xff, 0xff }, 1490 - { 0x1f, 0xff, 0xff, 0xff } 1491 - }; 1492 - 1493 - static int qcom_qmp_phy_combo_configure_dp_swing(struct qmp_phy *qphy, 1172 + static int qmp_combo_configure_dp_swing(struct qmp_phy *qphy, 1494 1173 unsigned int drv_lvl_reg, unsigned int emp_post_reg) 1495 1174 { 1496 1175 const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; 1176 + const struct qmp_phy_cfg *cfg = qphy->cfg; 1497 1177 unsigned int v_level = 0, p_level = 0; 1498 1178 u8 voltage_swing_cfg, pre_emphasis_cfg; 1499 1179 int i; ··· 1477 1211 } 1478 1212 1479 1213 if (dp_opts->link_rate <= 2700) { 1480 - voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr_rbr[v_level][p_level]; 1481 - pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr_rbr[v_level][p_level]; 1214 + voltage_swing_cfg = (*cfg->swing_hbr_rbr)[v_level][p_level]; 1215 + pre_emphasis_cfg = (*cfg->pre_emphasis_hbr_rbr)[v_level][p_level]; 1482 1216 } else { 1483 - voltage_swing_cfg = qmp_dp_v3_voltage_swing_hbr3_hbr2[v_level][p_level]; 1484 - pre_emphasis_cfg = qmp_dp_v3_pre_emphasis_hbr3_hbr2[v_level][p_level]; 1217 + voltage_swing_cfg = (*cfg->swing_hbr3_hbr2)[v_level][p_level]; 1218 + pre_emphasis_cfg = (*cfg->pre_emphasis_hbr3_hbr2)[v_level][p_level]; 1485 1219 } 1486 1220 1487 1221 /* TODO: Move check to config check */ ··· 1505 1239 const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; 1506 1240 u32 bias_en, drvr_en; 1507 1241 1508 - if (qcom_qmp_phy_combo_configure_dp_swing(qphy, 1509 - QSERDES_V3_TX_TX_DRV_LVL, 1242 + if (qmp_combo_configure_dp_swing(qphy, QSERDES_V3_TX_TX_DRV_LVL, 1510 1243 QSERDES_V3_TX_TX_EMP_POST1_LVL) < 0) 1511 1244 return; 1512 1245 ··· 1523 1258 writel(bias_en, qphy->tx2 + QSERDES_V3_TX_TRANSCEIVER_BIAS_EN); 1524 1259 } 1525 1260 1526 - static bool qcom_qmp_phy_combo_configure_dp_mode(struct qmp_phy *qphy) 1261 + static bool qmp_combo_configure_dp_mode(struct qmp_phy *qphy) 1527 1262 { 1528 1263 u32 val; 1529 1264 bool reverse = false; ··· 1560 1295 u32 phy_vco_div, status; 1561 1296 unsigned long pixel_freq; 1562 1297 1563 - qcom_qmp_phy_combo_configure_dp_mode(qphy); 1298 + qmp_combo_configure_dp_mode(qphy); 1564 1299 1565 1300 writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX0_TX1_LANE_CTL); 1566 1301 writel(0x05, qphy->pcs + QSERDES_V3_DP_PHY_TX2_TX3_LANE_CTL); ··· 1680 1415 writel(0x20, qphy->tx + QSERDES_V4_TX_TX_EMP_POST1_LVL); 1681 1416 writel(0x20, qphy->tx2 + QSERDES_V4_TX_TX_EMP_POST1_LVL); 1682 1417 1683 - qcom_qmp_phy_combo_configure_dp_swing(qphy, 1684 - QSERDES_V4_TX_TX_DRV_LVL, 1418 + qmp_combo_configure_dp_swing(qphy, QSERDES_V4_TX_TX_DRV_LVL, 1685 1419 QSERDES_V4_TX_TX_EMP_POST1_LVL); 1686 1420 } 1687 1421 1688 - static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy) 1422 + static int qcom_qmp_v45_phy_configure_dp_phy(struct qmp_phy *qphy) 1689 1423 { 1690 1424 const struct qmp_phy_dp_clks *dp_clks = qphy->dp_clks; 1691 1425 const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; 1692 1426 u32 phy_vco_div, status; 1693 1427 unsigned long pixel_freq; 1694 - u32 bias0_en, drvr0_en, bias1_en, drvr1_en; 1695 - bool reverse; 1696 1428 1697 1429 writel(0x0f, qphy->pcs + QSERDES_V4_DP_PHY_CFG_1); 1698 1430 1699 - reverse = qcom_qmp_phy_combo_configure_dp_mode(qphy); 1431 + qmp_combo_configure_dp_mode(qphy); 1700 1432 1701 1433 writel(0x13, qphy->pcs + QSERDES_DP_PHY_AUX_CFG1); 1702 1434 writel(0xa4, qphy->pcs + QSERDES_DP_PHY_AUX_CFG2); ··· 1771 1509 10000)) 1772 1510 return -ETIMEDOUT; 1773 1511 1512 + return 0; 1513 + } 1514 + 1515 + static int qcom_qmp_v4_phy_configure_dp_phy(struct qmp_phy *qphy) 1516 + { 1517 + const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; 1518 + u32 bias0_en, drvr0_en, bias1_en, drvr1_en; 1519 + bool reverse = false; 1520 + u32 status; 1521 + int ret; 1522 + 1523 + ret = qcom_qmp_v45_phy_configure_dp_phy(qphy); 1524 + if (ret < 0) 1525 + return ret; 1526 + 1774 1527 /* 1775 1528 * At least for 7nm DP PHY this has to be done after enabling link 1776 1529 * clock. ··· 1836 1559 return 0; 1837 1560 } 1838 1561 1562 + static int qcom_qmp_v5_phy_configure_dp_phy(struct qmp_phy *qphy) 1563 + { 1564 + const struct phy_configure_opts_dp *dp_opts = &qphy->dp_opts; 1565 + u32 bias0_en, drvr0_en, bias1_en, drvr1_en; 1566 + bool reverse = false; 1567 + u32 status; 1568 + int ret; 1569 + 1570 + ret = qcom_qmp_v45_phy_configure_dp_phy(qphy); 1571 + if (ret < 0) 1572 + return ret; 1573 + 1574 + if (dp_opts->lanes == 1) { 1575 + bias0_en = reverse ? 0x3e : 0x1a; 1576 + drvr0_en = reverse ? 0x13 : 0x10; 1577 + bias1_en = reverse ? 0x15 : 0x3e; 1578 + drvr1_en = reverse ? 0x10 : 0x13; 1579 + } else if (dp_opts->lanes == 2) { 1580 + bias0_en = reverse ? 0x3f : 0x15; 1581 + drvr0_en = 0x10; 1582 + bias1_en = reverse ? 0x15 : 0x3f; 1583 + drvr1_en = 0x10; 1584 + } else { 1585 + bias0_en = 0x3f; 1586 + bias1_en = 0x3f; 1587 + drvr0_en = 0x10; 1588 + drvr1_en = 0x10; 1589 + } 1590 + 1591 + writel(drvr0_en, qphy->tx + QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN); 1592 + writel(bias0_en, qphy->tx + QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN); 1593 + writel(drvr1_en, qphy->tx2 + QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN); 1594 + writel(bias1_en, qphy->tx2 + QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN); 1595 + 1596 + writel(0x18, qphy->pcs + QSERDES_DP_PHY_CFG); 1597 + udelay(2000); 1598 + writel(0x19, qphy->pcs + QSERDES_DP_PHY_CFG); 1599 + 1600 + if (readl_poll_timeout(qphy->pcs + QSERDES_V4_DP_PHY_STATUS, 1601 + status, 1602 + ((status & BIT(1)) > 0), 1603 + 500, 1604 + 10000)) 1605 + return -ETIMEDOUT; 1606 + 1607 + writel(0x0a, qphy->tx + QSERDES_V5_5NM_TX_TX_POL_INV); 1608 + writel(0x0a, qphy->tx2 + QSERDES_V5_5NM_TX_TX_POL_INV); 1609 + 1610 + writel(0x27, qphy->tx + QSERDES_V5_5NM_TX_TX_DRV_LVL); 1611 + writel(0x27, qphy->tx2 + QSERDES_V5_5NM_TX_TX_DRV_LVL); 1612 + 1613 + writel(0x20, qphy->tx + QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL); 1614 + writel(0x20, qphy->tx2 + QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL); 1615 + 1616 + return 0; 1617 + } 1618 + 1839 1619 /* 1840 1620 * We need to calibrate the aux setting here as many times 1841 1621 * as the caller tries ··· 1937 1603 return 0; 1938 1604 } 1939 1605 1940 - static int qcom_qmp_phy_combo_com_init(struct qmp_phy *qphy) 1606 + static int qmp_combo_com_init(struct qmp_phy *qphy) 1941 1607 { 1942 1608 struct qcom_qmp *qmp = qphy->qmp; 1943 1609 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 1974 1640 if (ret) 1975 1641 goto err_assert_reset; 1976 1642 1977 - if (cfg->has_phy_dp_com_ctrl) { 1978 - qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, 1979 - SW_PWRDN); 1980 - /* override hardware control for reset of qmp phy */ 1981 - qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, 1982 - SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | 1983 - SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); 1643 + qphy_setbits(dp_com, QPHY_V3_DP_COM_POWER_DOWN_CTRL, SW_PWRDN); 1984 1644 1985 - /* Default type-c orientation, i.e CC1 */ 1986 - qphy_setbits(dp_com, QPHY_V3_DP_COM_TYPEC_CTRL, 0x02); 1645 + /* override hardware control for reset of qmp phy */ 1646 + qphy_setbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, 1647 + SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | 1648 + SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); 1987 1649 1988 - qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL, 1989 - USB3_MODE | DP_MODE); 1650 + /* Default type-c orientation, i.e CC1 */ 1651 + qphy_setbits(dp_com, QPHY_V3_DP_COM_TYPEC_CTRL, 0x02); 1990 1652 1991 - /* bring both QMP USB and QMP DP PHYs PCS block out of reset */ 1992 - qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, 1993 - SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | 1994 - SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); 1653 + qphy_setbits(dp_com, QPHY_V3_DP_COM_PHY_MODE_CTRL, USB3_MODE | DP_MODE); 1995 1654 1996 - qphy_clrbits(dp_com, QPHY_V3_DP_COM_SWI_CTRL, 0x03); 1997 - qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET); 1998 - } 1655 + /* bring both QMP USB and QMP DP PHYs PCS block out of reset */ 1656 + qphy_clrbits(dp_com, QPHY_V3_DP_COM_RESET_OVRD_CTRL, 1657 + SW_DPPHY_RESET_MUX | SW_DPPHY_RESET | 1658 + SW_USB3PHY_RESET_MUX | SW_USB3PHY_RESET); 1659 + 1660 + qphy_clrbits(dp_com, QPHY_V3_DP_COM_SWI_CTRL, 0x03); 1661 + qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET); 1999 1662 2000 1663 if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) 2001 1664 qphy_setbits(pcs, ··· 2016 1685 return ret; 2017 1686 } 2018 1687 2019 - static int qcom_qmp_phy_combo_com_exit(struct qmp_phy *qphy) 1688 + static int qmp_combo_com_exit(struct qmp_phy *qphy) 2020 1689 { 2021 1690 struct qcom_qmp *qmp = qphy->qmp; 2022 1691 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 2040 1709 return 0; 2041 1710 } 2042 1711 2043 - static int qcom_qmp_phy_combo_init(struct phy *phy) 1712 + static int qmp_combo_init(struct phy *phy) 2044 1713 { 2045 1714 struct qmp_phy *qphy = phy_get_drvdata(phy); 2046 1715 struct qcom_qmp *qmp = qphy->qmp; ··· 2048 1717 int ret; 2049 1718 dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 2050 1719 2051 - ret = qcom_qmp_phy_combo_com_init(qphy); 1720 + ret = qmp_combo_com_init(qphy); 2052 1721 if (ret) 2053 1722 return ret; 2054 1723 ··· 2058 1727 return 0; 2059 1728 } 2060 1729 2061 - static int qcom_qmp_phy_combo_power_on(struct phy *phy) 1730 + static int qmp_combo_power_on(struct phy *phy) 2062 1731 { 2063 1732 struct qmp_phy *qphy = phy_get_drvdata(phy); 2064 1733 struct qcom_qmp *qmp = qphy->qmp; ··· 2070 1739 unsigned int mask, val, ready; 2071 1740 int ret; 2072 1741 2073 - qcom_qmp_phy_combo_serdes_init(qphy); 1742 + qmp_combo_serdes_init(qphy); 2074 1743 2075 1744 ret = clk_prepare_enable(qphy->pipe_clk); 2076 1745 if (ret) { ··· 2079 1748 } 2080 1749 2081 1750 /* Tx, Rx, and PCS configurations */ 2082 - qcom_qmp_phy_combo_configure_lane(tx, cfg->regs, 2083 - cfg->tx_tbl, cfg->tx_tbl_num, 1); 1751 + qmp_combo_configure_lane(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2084 1752 2085 - /* Configuration for other LANE for USB-DP combo PHY */ 2086 - if (cfg->is_dual_lane_phy) { 2087 - qcom_qmp_phy_combo_configure_lane(qphy->tx2, cfg->regs, 2088 - cfg->tx_tbl, cfg->tx_tbl_num, 2); 1753 + if (cfg->lanes >= 2) { 1754 + qmp_combo_configure_lane(qphy->tx2, cfg->regs, cfg->tx_tbl, 1755 + cfg->tx_tbl_num, 2); 2089 1756 } 2090 1757 2091 1758 /* Configure special DP tx tunings */ 2092 1759 if (cfg->type == PHY_TYPE_DP) 2093 1760 cfg->configure_dp_tx(qphy); 2094 1761 2095 - qcom_qmp_phy_combo_configure_lane(rx, cfg->regs, 2096 - cfg->rx_tbl, cfg->rx_tbl_num, 1); 1762 + qmp_combo_configure_lane(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2097 1763 2098 - if (cfg->is_dual_lane_phy) { 2099 - qcom_qmp_phy_combo_configure_lane(qphy->rx2, cfg->regs, 2100 - cfg->rx_tbl, cfg->rx_tbl_num, 2); 1764 + if (cfg->lanes >= 2) { 1765 + qmp_combo_configure_lane(qphy->rx2, cfg->regs, cfg->rx_tbl, 1766 + cfg->rx_tbl_num, 2); 2101 1767 } 2102 1768 2103 1769 /* Configure link rate, swing, etc. */ 2104 - if (cfg->type == PHY_TYPE_DP) { 1770 + if (cfg->type == PHY_TYPE_DP) 2105 1771 cfg->configure_dp_phy(qphy); 2106 - } else { 2107 - qcom_qmp_phy_combo_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2108 - } 1772 + else 1773 + qmp_combo_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2109 1774 2110 1775 ret = reset_control_deassert(qmp->ufs_reset); 2111 1776 if (ret) ··· 2135 1808 return ret; 2136 1809 } 2137 1810 2138 - static int qcom_qmp_phy_combo_power_off(struct phy *phy) 1811 + static int qmp_combo_power_off(struct phy *phy) 2139 1812 { 2140 1813 struct qmp_phy *qphy = phy_get_drvdata(phy); 2141 1814 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 2165 1838 return 0; 2166 1839 } 2167 1840 2168 - static int qcom_qmp_phy_combo_exit(struct phy *phy) 1841 + static int qmp_combo_exit(struct phy *phy) 2169 1842 { 2170 1843 struct qmp_phy *qphy = phy_get_drvdata(phy); 2171 1844 2172 - qcom_qmp_phy_combo_com_exit(qphy); 1845 + qmp_combo_com_exit(qphy); 2173 1846 2174 1847 return 0; 2175 1848 } 2176 1849 2177 - static int qcom_qmp_phy_combo_enable(struct phy *phy) 1850 + static int qmp_combo_enable(struct phy *phy) 2178 1851 { 2179 1852 int ret; 2180 1853 2181 - ret = qcom_qmp_phy_combo_init(phy); 1854 + ret = qmp_combo_init(phy); 2182 1855 if (ret) 2183 1856 return ret; 2184 1857 2185 - ret = qcom_qmp_phy_combo_power_on(phy); 1858 + ret = qmp_combo_power_on(phy); 2186 1859 if (ret) 2187 - qcom_qmp_phy_combo_exit(phy); 1860 + qmp_combo_exit(phy); 2188 1861 2189 1862 return ret; 2190 1863 } 2191 1864 2192 - static int qcom_qmp_phy_combo_disable(struct phy *phy) 1865 + static int qmp_combo_disable(struct phy *phy) 2193 1866 { 2194 1867 int ret; 2195 1868 2196 - ret = qcom_qmp_phy_combo_power_off(phy); 1869 + ret = qmp_combo_power_off(phy); 2197 1870 if (ret) 2198 1871 return ret; 2199 - return qcom_qmp_phy_combo_exit(phy); 1872 + return qmp_combo_exit(phy); 2200 1873 } 2201 1874 2202 - static int qcom_qmp_phy_combo_set_mode(struct phy *phy, 2203 - enum phy_mode mode, int submode) 1875 + static int qmp_combo_set_mode(struct phy *phy, enum phy_mode mode, int submode) 2204 1876 { 2205 1877 struct qmp_phy *qphy = phy_get_drvdata(phy); 2206 1878 ··· 2208 1882 return 0; 2209 1883 } 2210 1884 2211 - static void qcom_qmp_phy_combo_enable_autonomous_mode(struct qmp_phy *qphy) 1885 + static void qmp_combo_enable_autonomous_mode(struct qmp_phy *qphy) 2212 1886 { 2213 1887 const struct qmp_phy_cfg *cfg = qphy->cfg; 2214 1888 void __iomem *pcs_usb = qphy->pcs_usb ?: qphy->pcs; ··· 2237 1911 qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); 2238 1912 } 2239 1913 2240 - static void qcom_qmp_phy_combo_disable_autonomous_mode(struct qmp_phy *qphy) 1914 + static void qmp_combo_disable_autonomous_mode(struct qmp_phy *qphy) 2241 1915 { 2242 1916 const struct qmp_phy_cfg *cfg = qphy->cfg; 2243 1917 void __iomem *pcs_usb = qphy->pcs_usb ?: qphy->pcs_usb; ··· 2255 1929 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); 2256 1930 } 2257 1931 2258 - static int __maybe_unused qcom_qmp_phy_combo_runtime_suspend(struct device *dev) 1932 + static int __maybe_unused qmp_combo_runtime_suspend(struct device *dev) 2259 1933 { 2260 1934 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2261 1935 struct qmp_phy *qphy = qmp->phys[0]; ··· 2272 1946 return 0; 2273 1947 } 2274 1948 2275 - qcom_qmp_phy_combo_enable_autonomous_mode(qphy); 1949 + qmp_combo_enable_autonomous_mode(qphy); 2276 1950 2277 1951 clk_disable_unprepare(qphy->pipe_clk); 2278 1952 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); ··· 2280 1954 return 0; 2281 1955 } 2282 1956 2283 - static int __maybe_unused qcom_qmp_phy_combo_runtime_resume(struct device *dev) 1957 + static int __maybe_unused qmp_combo_runtime_resume(struct device *dev) 2284 1958 { 2285 1959 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2286 1960 struct qmp_phy *qphy = qmp->phys[0]; ··· 2309 1983 return ret; 2310 1984 } 2311 1985 2312 - qcom_qmp_phy_combo_disable_autonomous_mode(qphy); 1986 + qmp_combo_disable_autonomous_mode(qphy); 2313 1987 2314 1988 return 0; 2315 1989 } 2316 1990 2317 - static int qcom_qmp_phy_combo_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 1991 + static int qmp_combo_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2318 1992 { 2319 1993 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2320 1994 int num = cfg->num_vregs; ··· 2346 2020 return 0; 2347 2021 } 2348 2022 2349 - static int qcom_qmp_phy_combo_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2023 + static int qmp_combo_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2350 2024 { 2351 2025 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2352 2026 int i; ··· 2367 2041 return 0; 2368 2042 } 2369 2043 2370 - static int qcom_qmp_phy_combo_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2044 + static int qmp_combo_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2371 2045 { 2372 2046 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2373 2047 int num = cfg->num_clks; ··· 2635 2309 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 2636 2310 } 2637 2311 2638 - static const struct phy_ops qcom_qmp_phy_combo_usb_ops = { 2639 - .init = qcom_qmp_phy_combo_enable, 2640 - .exit = qcom_qmp_phy_combo_disable, 2641 - .set_mode = qcom_qmp_phy_combo_set_mode, 2312 + static const struct phy_ops qmp_combo_usb_ops = { 2313 + .init = qmp_combo_enable, 2314 + .exit = qmp_combo_disable, 2315 + .set_mode = qmp_combo_set_mode, 2642 2316 .owner = THIS_MODULE, 2643 2317 }; 2644 2318 2645 - static const struct phy_ops qcom_qmp_phy_combo_dp_ops = { 2646 - .init = qcom_qmp_phy_combo_init, 2319 + static const struct phy_ops qmp_combo_dp_ops = { 2320 + .init = qmp_combo_init, 2647 2321 .configure = qcom_qmp_dp_phy_configure, 2648 - .power_on = qcom_qmp_phy_combo_power_on, 2322 + .power_on = qmp_combo_power_on, 2649 2323 .calibrate = qcom_qmp_dp_phy_calibrate, 2650 - .power_off = qcom_qmp_phy_combo_power_off, 2651 - .exit = qcom_qmp_phy_combo_exit, 2652 - .set_mode = qcom_qmp_phy_combo_set_mode, 2324 + .power_off = qmp_combo_power_off, 2325 + .exit = qmp_combo_exit, 2326 + .set_mode = qmp_combo_set_mode, 2653 2327 .owner = THIS_MODULE, 2654 2328 }; 2655 2329 2656 - static 2657 - int qcom_qmp_phy_combo_create(struct device *dev, struct device_node *np, int id, 2330 + static int qmp_combo_create(struct device *dev, struct device_node *np, int id, 2658 2331 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 2659 2332 { 2660 2333 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2661 2334 struct phy *generic_phy; 2662 2335 struct qmp_phy *qphy; 2663 2336 const struct phy_ops *ops; 2664 - char prop_name[MAX_PROP_NAME]; 2665 2337 int ret; 2666 2338 2667 2339 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); ··· 2674 2350 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 2675 2351 * For single lane PHYs: pcs_misc (optional) -> 3. 2676 2352 */ 2677 - qphy->tx = of_iomap(np, 0); 2678 - if (!qphy->tx) 2679 - return -ENOMEM; 2353 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 2354 + if (IS_ERR(qphy->tx)) 2355 + return PTR_ERR(qphy->tx); 2680 2356 2681 - qphy->rx = of_iomap(np, 1); 2682 - if (!qphy->rx) 2683 - return -ENOMEM; 2357 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 2358 + if (IS_ERR(qphy->rx)) 2359 + return PTR_ERR(qphy->rx); 2684 2360 2685 - qphy->pcs = of_iomap(np, 2); 2686 - if (!qphy->pcs) 2687 - return -ENOMEM; 2361 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 2362 + if (IS_ERR(qphy->pcs)) 2363 + return PTR_ERR(qphy->pcs); 2688 2364 2689 2365 if (cfg->pcs_usb_offset) 2690 2366 qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; 2691 2367 2692 - /* 2693 - * If this is a dual-lane PHY, then there should be registers for the 2694 - * second lane. Some old device trees did not specify this, so fall 2695 - * back to old legacy behavior of assuming they can be reached at an 2696 - * offset from the first lane. 2697 - */ 2698 - if (cfg->is_dual_lane_phy) { 2699 - qphy->tx2 = of_iomap(np, 3); 2700 - qphy->rx2 = of_iomap(np, 4); 2701 - if (!qphy->tx2 || !qphy->rx2) { 2702 - dev_warn(dev, 2703 - "Underspecified device tree, falling back to legacy register regions\n"); 2368 + if (cfg->lanes >= 2) { 2369 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 2370 + if (IS_ERR(qphy->tx2)) 2371 + return PTR_ERR(qphy->tx2); 2704 2372 2705 - /* In the old version, pcs_misc is at index 3. */ 2706 - qphy->pcs_misc = qphy->tx2; 2707 - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 2708 - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 2373 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 2374 + if (IS_ERR(qphy->rx2)) 2375 + return PTR_ERR(qphy->rx2); 2709 2376 2710 - } else { 2711 - qphy->pcs_misc = of_iomap(np, 5); 2712 - } 2713 - 2377 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 2714 2378 } else { 2715 - qphy->pcs_misc = of_iomap(np, 3); 2379 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 2716 2380 } 2717 2381 2718 - if (!qphy->pcs_misc) 2382 + if (IS_ERR(qphy->pcs_misc)) { 2719 2383 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 2384 + qphy->pcs_misc = NULL; 2385 + } 2720 2386 2721 2387 /* 2722 2388 * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 ··· 2715 2401 * Otherwise, we initialize pipe clock to NULL for 2716 2402 * all phys that don't need this. 2717 2403 */ 2718 - snprintf(prop_name, sizeof(prop_name), "pipe%d", id); 2719 - qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name); 2404 + qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 2720 2405 if (IS_ERR(qphy->pipe_clk)) { 2721 - if (cfg->type == PHY_TYPE_USB3) { 2722 - ret = PTR_ERR(qphy->pipe_clk); 2723 - if (ret != -EPROBE_DEFER) 2724 - dev_err(dev, 2725 - "failed to get lane%d pipe_clk, %d\n", 2726 - id, ret); 2727 - return ret; 2728 - } 2406 + if (cfg->type == PHY_TYPE_USB3) 2407 + return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 2408 + "failed to get lane%d pipe_clk\n", 2409 + id); 2729 2410 qphy->pipe_clk = NULL; 2730 2411 } 2731 2412 2732 2413 if (cfg->type == PHY_TYPE_DP) 2733 - ops = &qcom_qmp_phy_combo_dp_ops; 2414 + ops = &qmp_combo_dp_ops; 2734 2415 else 2735 - ops = &qcom_qmp_phy_combo_usb_ops; 2416 + ops = &qmp_combo_usb_ops; 2736 2417 2737 2418 generic_phy = devm_phy_create(dev, np, ops); 2738 2419 if (IS_ERR(generic_phy)) { ··· 2737 2428 } 2738 2429 2739 2430 qphy->phy = generic_phy; 2740 - qphy->index = id; 2741 2431 qphy->qmp = qmp; 2742 2432 qmp->phys[id] = qphy; 2743 2433 phy_set_drvdata(generic_phy, qphy); ··· 2744 2436 return 0; 2745 2437 } 2746 2438 2747 - static const struct of_device_id qcom_qmp_combo_phy_of_match_table[] = { 2439 + static const struct of_device_id qmp_combo_of_match_table[] = { 2748 2440 { 2749 2441 .compatible = "qcom,sc7180-qmp-usb3-dp-phy", 2750 2442 .data = &sc7180_usb3dpphy_cfg, 2443 + }, 2444 + { 2445 + .compatible = "qcom,sdm845-qmp-usb3-dp-phy", 2446 + .data = &sdm845_usb3dpphy_cfg, 2751 2447 }, 2752 2448 { 2753 2449 .compatible = "qcom,sm8250-qmp-usb3-dp-phy", ··· 2761 2449 .compatible = "qcom,sc8180x-qmp-usb3-dp-phy", 2762 2450 .data = &sc8180x_usb3dpphy_cfg, 2763 2451 }, 2452 + { 2453 + .compatible = "qcom,sc8280xp-qmp-usb43dp-phy", 2454 + .data = &sc8280xp_usb43dpphy_combo_cfg, 2455 + }, 2764 2456 { } 2765 2457 }; 2766 - MODULE_DEVICE_TABLE(of, qcom_qmp_combo_phy_of_match_table); 2458 + MODULE_DEVICE_TABLE(of, qmp_combo_of_match_table); 2767 2459 2768 - static const struct dev_pm_ops qcom_qmp_phy_combo_pm_ops = { 2769 - SET_RUNTIME_PM_OPS(qcom_qmp_phy_combo_runtime_suspend, 2770 - qcom_qmp_phy_combo_runtime_resume, NULL) 2460 + static const struct dev_pm_ops qmp_combo_pm_ops = { 2461 + SET_RUNTIME_PM_OPS(qmp_combo_runtime_suspend, 2462 + qmp_combo_runtime_resume, NULL) 2771 2463 }; 2772 2464 2773 - static int qcom_qmp_phy_combo_probe(struct platform_device *pdev) 2465 + static int qmp_combo_probe(struct platform_device *pdev) 2774 2466 { 2775 2467 struct qcom_qmp *qmp; 2776 2468 struct device *dev = &pdev->dev; ··· 2810 2494 if (IS_ERR(serdes)) 2811 2495 return PTR_ERR(serdes); 2812 2496 2813 - /* per PHY dp_com; if PHY has dp_com control block */ 2814 - if (cfg->has_phy_dp_com_ctrl) { 2815 - qmp->dp_com = devm_platform_ioremap_resource(pdev, 1); 2816 - if (IS_ERR(qmp->dp_com)) 2817 - return PTR_ERR(qmp->dp_com); 2818 - } 2497 + qmp->dp_com = devm_platform_ioremap_resource(pdev, 1); 2498 + if (IS_ERR(qmp->dp_com)) 2499 + return PTR_ERR(qmp->dp_com); 2819 2500 2820 2501 /* Only two serdes for combo PHY */ 2821 2502 dp_serdes = devm_platform_ioremap_resource(pdev, 2); ··· 2824 2511 2825 2512 mutex_init(&qmp->phy_mutex); 2826 2513 2827 - ret = qcom_qmp_phy_combo_clk_init(dev, cfg); 2514 + ret = qmp_combo_clk_init(dev, cfg); 2828 2515 if (ret) 2829 2516 return ret; 2830 2517 2831 - ret = qcom_qmp_phy_combo_reset_init(dev, cfg); 2518 + ret = qmp_combo_reset_init(dev, cfg); 2832 2519 if (ret) 2833 2520 return ret; 2834 2521 2835 - ret = qcom_qmp_phy_combo_vreg_init(dev, cfg); 2836 - if (ret) { 2837 - if (ret != -EPROBE_DEFER) 2838 - dev_err(dev, "failed to get regulator supplies: %d\n", 2839 - ret); 2840 - return ret; 2841 - } 2522 + ret = qmp_combo_vreg_init(dev, cfg); 2523 + if (ret) 2524 + return dev_err_probe(dev, ret, 2525 + "failed to get regulator supplies\n"); 2842 2526 2843 2527 num = of_get_available_child_count(dev->of_node); 2844 2528 /* do we have a rogue child node ? */ ··· 2847 2537 return -ENOMEM; 2848 2538 2849 2539 pm_runtime_set_active(dev); 2850 - pm_runtime_enable(dev); 2540 + ret = devm_pm_runtime_enable(dev); 2541 + if (ret) 2542 + return ret; 2851 2543 /* 2852 2544 * Prevent runtime pm from being ON by default. Users can enable 2853 2545 * it using power/control in sysfs. ··· 2863 2551 serdes = dp_serdes; 2864 2552 2865 2553 /* Create per-lane phy */ 2866 - ret = qcom_qmp_phy_combo_create(dev, child, id, serdes, cfg); 2554 + ret = qmp_combo_create(dev, child, id, serdes, cfg); 2867 2555 if (ret) { 2868 2556 dev_err(dev, "failed to create lane%d phy, %d\n", 2869 2557 id, ret); ··· 2881 2569 serdes = usb_serdes; 2882 2570 2883 2571 /* Create per-lane phy */ 2884 - ret = qcom_qmp_phy_combo_create(dev, child, id, serdes, cfg); 2572 + ret = qmp_combo_create(dev, child, id, serdes, cfg); 2885 2573 if (ret) { 2886 2574 dev_err(dev, "failed to create lane%d phy, %d\n", 2887 2575 id, ret); ··· 2904 2592 } 2905 2593 2906 2594 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 2907 - if (!IS_ERR(phy_provider)) 2908 - dev_info(dev, "Registered Qcom-QMP phy\n"); 2909 - else 2910 - pm_runtime_disable(dev); 2911 2595 2912 2596 return PTR_ERR_OR_ZERO(phy_provider); 2913 2597 2914 2598 err_node_put: 2915 - pm_runtime_disable(dev); 2916 2599 of_node_put(child); 2917 2600 return ret; 2918 2601 } 2919 2602 2920 - static struct platform_driver qcom_qmp_phy_combo_driver = { 2921 - .probe = qcom_qmp_phy_combo_probe, 2603 + static struct platform_driver qmp_combo_driver = { 2604 + .probe = qmp_combo_probe, 2922 2605 .driver = { 2923 2606 .name = "qcom-qmp-combo-phy", 2924 - .pm = &qcom_qmp_phy_combo_pm_ops, 2925 - .of_match_table = qcom_qmp_combo_phy_of_match_table, 2607 + .pm = &qmp_combo_pm_ops, 2608 + .of_match_table = qmp_combo_of_match_table, 2926 2609 }, 2927 2610 }; 2928 2611 2929 - module_platform_driver(qcom_qmp_phy_combo_driver); 2612 + module_platform_driver(qmp_combo_driver); 2930 2613 2931 2614 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2932 2615 MODULE_DESCRIPTION("Qualcomm QMP USB+DP combo PHY driver");
+64 -183
drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c
··· 36 36 /* QPHY_PCS_STATUS bit */ 37 37 #define PHYSTATUS BIT(6) 38 38 #define PHYSTATUS_4_20 BIT(7) 39 - /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 39 + /* QPHY_COM_PCS_READY_STATUS bit */ 40 40 #define PCS_READY BIT(0) 41 - 42 - /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 43 - /* DP PHY soft reset */ 44 - #define SW_DPPHY_RESET BIT(0) 45 - /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ 46 - #define SW_DPPHY_RESET_MUX BIT(1) 47 - /* USB3 PHY soft reset */ 48 - #define SW_USB3PHY_RESET BIT(2) 49 - /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ 50 - #define SW_USB3PHY_RESET_MUX BIT(3) 51 - 52 - /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ 53 - #define USB3_MODE BIT(0) /* enables USB3 mode */ 54 - #define DP_MODE BIT(1) /* enables DP mode */ 55 - 56 - /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ 57 - #define ARCVR_DTCT_EN BIT(0) 58 - #define ALFPS_DTCT_EN BIT(1) 59 - #define ARCVR_DTCT_EVENT_SEL BIT(4) 60 - 61 - /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ 62 - #define IRQ_CLEAR BIT(0) 63 - 64 - /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ 65 - #define RCVR_DETECT BIT(0) 66 - 67 - /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ 68 - #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ 69 41 70 42 #define PHY_INIT_COMPLETE_TIMEOUT 10000 71 43 #define POWER_DOWN_DELAY_US_MIN 10 72 44 #define POWER_DOWN_DELAY_US_MAX 11 73 - 74 - #define MAX_PROP_NAME 32 75 - 76 - /* Define the assumed distance between lanes for underspecified device trees. */ 77 - #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 78 45 79 46 struct qmp_phy_init_tbl { 80 47 unsigned int offset; ··· 90 123 /* PCS registers */ 91 124 QPHY_SW_RESET, 92 125 QPHY_START_CTRL, 93 - QPHY_PCS_READY_STATUS, 94 126 QPHY_PCS_STATUS, 95 - QPHY_PCS_AUTONOMOUS_MODE_CTRL, 96 - QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 97 - QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 98 127 QPHY_PCS_POWER_DOWN_CONTROL, 99 - /* PCS_MISC registers */ 100 - QPHY_PCS_MISC_TYPEC_CTRL, 101 128 /* Keep last to ensure regs_layout arrays are properly initialized */ 102 129 QPHY_LAYOUT_SIZE 103 130 }; ··· 184 223 QMP_PHY_INIT_CFG(QPHY_V2_PCS_TXDEEMPH_M3P5DB_V0, 0x0e), 185 224 }; 186 225 187 - struct qmp_phy; 188 - 189 226 /* struct qmp_phy_cfg - per-PHY initialization config */ 190 227 struct qmp_phy_cfg { 191 - /* phy-type - PCIE/UFS/USB */ 192 - unsigned int type; 193 - /* number of lanes provided by phy */ 194 - int nlanes; 228 + /* number of PHYs provided by this block */ 229 + int num_phys; 195 230 196 231 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 197 232 const struct qmp_phy_init_tbl *serdes_tbl; 198 233 int serdes_tbl_num; 199 - const struct qmp_phy_init_tbl *serdes_tbl_sec; 200 - int serdes_tbl_num_sec; 201 234 const struct qmp_phy_init_tbl *tx_tbl; 202 235 int tx_tbl_num; 203 - const struct qmp_phy_init_tbl *tx_tbl_sec; 204 - int tx_tbl_num_sec; 205 236 const struct qmp_phy_init_tbl *rx_tbl; 206 237 int rx_tbl_num; 207 - const struct qmp_phy_init_tbl *rx_tbl_sec; 208 - int rx_tbl_num_sec; 209 238 const struct qmp_phy_init_tbl *pcs_tbl; 210 239 int pcs_tbl_num; 211 - const struct qmp_phy_init_tbl *pcs_tbl_sec; 212 - int pcs_tbl_num_sec; 213 - const struct qmp_phy_init_tbl *pcs_misc_tbl; 214 - int pcs_misc_tbl_num; 215 - const struct qmp_phy_init_tbl *pcs_misc_tbl_sec; 216 - int pcs_misc_tbl_num_sec; 217 240 218 241 /* clock ids to be requested */ 219 242 const char * const *clk_list; ··· 234 289 * @tx: iomapped memory space for lane's tx 235 290 * @rx: iomapped memory space for lane's rx 236 291 * @pcs: iomapped memory space for lane's pcs 237 - * @pcs_misc: iomapped memory space for lane's pcs_misc 238 292 * @pipe_clk: pipe clock 239 293 * @index: lane index 240 294 * @qmp: QMP phy to which this lane belongs 241 295 * @lane_rst: lane's reset controller 242 - * @mode: current PHY mode 243 296 */ 244 297 struct qmp_phy { 245 298 struct phy *phy; ··· 246 303 void __iomem *tx; 247 304 void __iomem *rx; 248 305 void __iomem *pcs; 249 - void __iomem *pcs_misc; 250 306 struct clk *pipe_clk; 251 307 unsigned int index; 252 308 struct qcom_qmp *qmp; 253 309 struct reset_control *lane_rst; 254 - enum phy_mode mode; 255 310 }; 256 311 257 312 /** ··· 318 377 }; 319 378 320 379 static const struct qmp_phy_cfg msm8996_pciephy_cfg = { 321 - .type = PHY_TYPE_PCIE, 322 - .nlanes = 3, 380 + .num_phys = 3, 323 381 324 382 .serdes_tbl = msm8996_pcie_serdes_tbl, 325 383 .serdes_tbl_num = ARRAY_SIZE(msm8996_pcie_serdes_tbl), ··· 346 406 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 347 407 }; 348 408 349 - static void qcom_qmp_phy_pcie_msm8996_configure_lane(void __iomem *base, 409 + static void qmp_pcie_msm8996_configure_lane(void __iomem *base, 350 410 const unsigned int *regs, 351 411 const struct qmp_phy_init_tbl tbl[], 352 412 int num, ··· 369 429 } 370 430 } 371 431 372 - static void qcom_qmp_phy_pcie_msm8996_configure(void __iomem *base, 432 + static void qmp_pcie_msm8996_configure(void __iomem *base, 373 433 const unsigned int *regs, 374 434 const struct qmp_phy_init_tbl tbl[], 375 435 int num) 376 436 { 377 - qcom_qmp_phy_pcie_msm8996_configure_lane(base, regs, tbl, num, 0xff); 437 + qmp_pcie_msm8996_configure_lane(base, regs, tbl, num, 0xff); 378 438 } 379 439 380 - static int qcom_qmp_phy_pcie_msm8996_serdes_init(struct qmp_phy *qphy) 440 + static int qmp_pcie_msm8996_serdes_init(struct qmp_phy *qphy) 381 441 { 382 442 struct qcom_qmp *qmp = qphy->qmp; 383 443 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 388 448 unsigned int mask, val; 389 449 int ret; 390 450 391 - qcom_qmp_phy_pcie_msm8996_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 392 - if (cfg->serdes_tbl_sec) 393 - qcom_qmp_phy_pcie_msm8996_configure(serdes, cfg->regs, cfg->serdes_tbl_sec, 394 - cfg->serdes_tbl_num_sec); 395 - 451 + qmp_pcie_msm8996_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 396 452 397 453 qphy_clrbits(serdes, cfg->regs[QPHY_COM_SW_RESET], SW_RESET); 398 454 qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL], ··· 408 472 return 0; 409 473 } 410 474 411 - static int qcom_qmp_phy_pcie_msm8996_com_init(struct qmp_phy *qphy) 475 + static int qmp_pcie_msm8996_com_init(struct qmp_phy *qphy) 412 476 { 413 477 struct qcom_qmp *qmp = qphy->qmp; 414 478 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 461 525 return ret; 462 526 } 463 527 464 - static int qcom_qmp_phy_pcie_msm8996_com_exit(struct qmp_phy *qphy) 528 + static int qmp_pcie_msm8996_com_exit(struct qmp_phy *qphy) 465 529 { 466 530 struct qcom_qmp *qmp = qphy->qmp; 467 531 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 491 555 return 0; 492 556 } 493 557 494 - static int qcom_qmp_phy_pcie_msm8996_init(struct phy *phy) 558 + static int qmp_pcie_msm8996_init(struct phy *phy) 495 559 { 496 560 struct qmp_phy *qphy = phy_get_drvdata(phy); 497 561 struct qcom_qmp *qmp = qphy->qmp; 498 562 int ret; 499 563 dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 500 564 501 - ret = qcom_qmp_phy_pcie_msm8996_com_init(qphy); 565 + ret = qmp_pcie_msm8996_com_init(qphy); 502 566 if (ret) 503 567 return ret; 504 568 505 569 return 0; 506 570 } 507 571 508 - static int qcom_qmp_phy_pcie_msm8996_power_on(struct phy *phy) 572 + static int qmp_pcie_msm8996_power_on(struct phy *phy) 509 573 { 510 574 struct qmp_phy *qphy = phy_get_drvdata(phy); 511 575 struct qcom_qmp *qmp = qphy->qmp; ··· 513 577 void __iomem *tx = qphy->tx; 514 578 void __iomem *rx = qphy->rx; 515 579 void __iomem *pcs = qphy->pcs; 516 - void __iomem *pcs_misc = qphy->pcs_misc; 517 580 void __iomem *status; 518 581 unsigned int mask, val, ready; 519 582 int ret; 520 583 521 - qcom_qmp_phy_pcie_msm8996_serdes_init(qphy); 584 + qmp_pcie_msm8996_serdes_init(qphy); 522 585 523 586 ret = reset_control_deassert(qphy->lane_rst); 524 587 if (ret) { ··· 533 598 } 534 599 535 600 /* Tx, Rx, and PCS configurations */ 536 - qcom_qmp_phy_pcie_msm8996_configure_lane(tx, cfg->regs, 537 - cfg->tx_tbl, cfg->tx_tbl_num, 1); 538 - if (cfg->tx_tbl_sec) 539 - qcom_qmp_phy_pcie_msm8996_configure_lane(tx, cfg->regs, cfg->tx_tbl_sec, 540 - cfg->tx_tbl_num_sec, 1); 601 + qmp_pcie_msm8996_configure_lane(tx, cfg->regs, cfg->tx_tbl, 602 + cfg->tx_tbl_num, 1); 541 603 542 - qcom_qmp_phy_pcie_msm8996_configure_lane(rx, cfg->regs, 543 - cfg->rx_tbl, cfg->rx_tbl_num, 1); 544 - if (cfg->rx_tbl_sec) 545 - qcom_qmp_phy_pcie_msm8996_configure_lane(rx, cfg->regs, 546 - cfg->rx_tbl_sec, cfg->rx_tbl_num_sec, 1); 604 + qmp_pcie_msm8996_configure_lane(rx, cfg->regs, cfg->rx_tbl, 605 + cfg->rx_tbl_num, 1); 547 606 548 - qcom_qmp_phy_pcie_msm8996_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 549 - if (cfg->pcs_tbl_sec) 550 - qcom_qmp_phy_pcie_msm8996_configure(pcs, cfg->regs, cfg->pcs_tbl_sec, 551 - cfg->pcs_tbl_num_sec); 552 - 553 - qcom_qmp_phy_pcie_msm8996_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, 554 - cfg->pcs_misc_tbl_num); 555 - if (cfg->pcs_misc_tbl_sec) 556 - qcom_qmp_phy_pcie_msm8996_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, 557 - cfg->pcs_misc_tbl_num_sec); 607 + qmp_pcie_msm8996_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 558 608 559 609 /* 560 610 * Pull out PHY from POWER DOWN state. ··· 577 657 return ret; 578 658 } 579 659 580 - static int qcom_qmp_phy_pcie_msm8996_power_off(struct phy *phy) 660 + static int qmp_pcie_msm8996_power_off(struct phy *phy) 581 661 { 582 662 struct qmp_phy *qphy = phy_get_drvdata(phy); 583 663 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 602 682 return 0; 603 683 } 604 684 605 - static int qcom_qmp_phy_pcie_msm8996_exit(struct phy *phy) 685 + static int qmp_pcie_msm8996_exit(struct phy *phy) 606 686 { 607 687 struct qmp_phy *qphy = phy_get_drvdata(phy); 608 688 609 689 reset_control_assert(qphy->lane_rst); 610 690 611 - qcom_qmp_phy_pcie_msm8996_com_exit(qphy); 691 + qmp_pcie_msm8996_com_exit(qphy); 612 692 613 693 return 0; 614 694 } 615 695 616 - static int qcom_qmp_phy_pcie_msm8996_enable(struct phy *phy) 696 + static int qmp_pcie_msm8996_enable(struct phy *phy) 617 697 { 618 698 int ret; 619 699 620 - ret = qcom_qmp_phy_pcie_msm8996_init(phy); 700 + ret = qmp_pcie_msm8996_init(phy); 621 701 if (ret) 622 702 return ret; 623 703 624 - ret = qcom_qmp_phy_pcie_msm8996_power_on(phy); 704 + ret = qmp_pcie_msm8996_power_on(phy); 625 705 if (ret) 626 - qcom_qmp_phy_pcie_msm8996_exit(phy); 706 + qmp_pcie_msm8996_exit(phy); 627 707 628 708 return ret; 629 709 } 630 710 631 - static int qcom_qmp_phy_pcie_msm8996_disable(struct phy *phy) 711 + static int qmp_pcie_msm8996_disable(struct phy *phy) 632 712 { 633 713 int ret; 634 714 635 - ret = qcom_qmp_phy_pcie_msm8996_power_off(phy); 715 + ret = qmp_pcie_msm8996_power_off(phy); 636 716 if (ret) 637 717 return ret; 638 - return qcom_qmp_phy_pcie_msm8996_exit(phy); 718 + return qmp_pcie_msm8996_exit(phy); 639 719 } 640 720 641 - static int qcom_qmp_phy_pcie_msm8996_set_mode(struct phy *phy, 642 - enum phy_mode mode, int submode) 643 - { 644 - struct qmp_phy *qphy = phy_get_drvdata(phy); 645 - 646 - qphy->mode = mode; 647 - 648 - return 0; 649 - } 650 - 651 - static int qcom_qmp_phy_pcie_msm8996_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 721 + static int qmp_pcie_msm8996_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 652 722 { 653 723 struct qcom_qmp *qmp = dev_get_drvdata(dev); 654 724 int num = cfg->num_vregs; ··· 654 744 return devm_regulator_bulk_get(dev, num, qmp->vregs); 655 745 } 656 746 657 - static int qcom_qmp_phy_pcie_msm8996_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 747 + static int qmp_pcie_msm8996_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 658 748 { 659 749 struct qcom_qmp *qmp = dev_get_drvdata(dev); 660 750 int i; ··· 675 765 return 0; 676 766 } 677 767 678 - static int qcom_qmp_phy_pcie_msm8996_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 768 + static int qmp_pcie_msm8996_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 679 769 { 680 770 struct qcom_qmp *qmp = dev_get_drvdata(dev); 681 771 int num = cfg->num_clks; ··· 751 841 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 752 842 } 753 843 754 - static const struct phy_ops qcom_qmp_phy_pcie_msm8996_ops = { 755 - .power_on = qcom_qmp_phy_pcie_msm8996_enable, 756 - .power_off = qcom_qmp_phy_pcie_msm8996_disable, 757 - .set_mode = qcom_qmp_phy_pcie_msm8996_set_mode, 844 + static const struct phy_ops qmp_pcie_msm8996_ops = { 845 + .power_on = qmp_pcie_msm8996_enable, 846 + .power_off = qmp_pcie_msm8996_disable, 758 847 .owner = THIS_MODULE, 759 848 }; 760 849 ··· 762 853 reset_control_put(data); 763 854 } 764 855 765 - static 766 - int qcom_qmp_phy_pcie_msm8996_create(struct device *dev, struct device_node *np, int id, 856 + static int qmp_pcie_msm8996_create(struct device *dev, struct device_node *np, int id, 767 857 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 768 858 { 769 859 struct qcom_qmp *qmp = dev_get_drvdata(dev); 770 860 struct phy *generic_phy; 771 861 struct qmp_phy *qphy; 772 - char prop_name[MAX_PROP_NAME]; 773 862 int ret; 774 863 775 864 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); ··· 779 872 /* 780 873 * Get memory resources for each phy lane: 781 874 * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. 782 - * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 783 - * For single lane PHYs: pcs_misc (optional) -> 3. 784 875 */ 785 - qphy->tx = of_iomap(np, 0); 786 - if (!qphy->tx) 787 - return -ENOMEM; 876 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 877 + if (IS_ERR(qphy->tx)) 878 + return PTR_ERR(qphy->tx); 788 879 789 - qphy->rx = of_iomap(np, 1); 790 - if (!qphy->rx) 791 - return -ENOMEM; 880 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 881 + if (IS_ERR(qphy->rx)) 882 + return PTR_ERR(qphy->rx); 792 883 793 - qphy->pcs = of_iomap(np, 2); 794 - if (!qphy->pcs) 795 - return -ENOMEM; 884 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 885 + if (IS_ERR(qphy->pcs)) 886 + return PTR_ERR(qphy->pcs); 796 887 797 - qphy->pcs_misc = of_iomap(np, 3); 798 - 799 - if (!qphy->pcs_misc) 800 - dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 801 - 802 - snprintf(prop_name, sizeof(prop_name), "pipe%d", id); 803 - qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name); 888 + qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 804 889 if (IS_ERR(qphy->pipe_clk)) { 805 890 return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 806 891 "failed to get lane%d pipe clock\n", id); 807 892 } 808 893 809 - /* Get lane reset, if any */ 810 - snprintf(prop_name, sizeof(prop_name), "lane%d", id); 811 - qphy->lane_rst = of_reset_control_get_exclusive(np, prop_name); 894 + qphy->lane_rst = of_reset_control_get_exclusive_by_index(np, 0); 812 895 if (IS_ERR(qphy->lane_rst)) { 813 896 dev_err(dev, "failed to get lane%d reset\n", id); 814 897 return PTR_ERR(qphy->lane_rst); ··· 808 911 if (ret) 809 912 return ret; 810 913 811 - generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_pcie_msm8996_ops); 914 + generic_phy = devm_phy_create(dev, np, &qmp_pcie_msm8996_ops); 812 915 if (IS_ERR(generic_phy)) { 813 916 ret = PTR_ERR(generic_phy); 814 917 dev_err(dev, "failed to create qphy %d\n", ret); ··· 824 927 return 0; 825 928 } 826 929 827 - static const struct of_device_id qcom_qmp_phy_pcie_msm8996_of_match_table[] = { 930 + static const struct of_device_id qmp_pcie_msm8996_of_match_table[] = { 828 931 { 829 932 .compatible = "qcom,msm8996-qmp-pcie-phy", 830 933 .data = &msm8996_pciephy_cfg, 831 934 }, 832 935 { }, 833 936 }; 834 - MODULE_DEVICE_TABLE(of, qcom_qmp_phy_pcie_msm8996_of_match_table); 937 + MODULE_DEVICE_TABLE(of, qmp_pcie_msm8996_of_match_table); 835 938 836 - static int qcom_qmp_phy_pcie_msm8996_probe(struct platform_device *pdev) 939 + static int qmp_pcie_msm8996_probe(struct platform_device *pdev) 837 940 { 838 941 struct qcom_qmp *qmp; 839 942 struct device *dev = &pdev->dev; ··· 861 964 if (IS_ERR(serdes)) 862 965 return PTR_ERR(serdes); 863 966 864 - expected_phys = cfg->nlanes; 967 + expected_phys = cfg->num_phys; 865 968 866 969 mutex_init(&qmp->phy_mutex); 867 970 868 - ret = qcom_qmp_phy_pcie_msm8996_clk_init(dev, cfg); 971 + ret = qmp_pcie_msm8996_clk_init(dev, cfg); 869 972 if (ret) 870 973 return ret; 871 974 872 - ret = qcom_qmp_phy_pcie_msm8996_reset_init(dev, cfg); 975 + ret = qmp_pcie_msm8996_reset_init(dev, cfg); 873 976 if (ret) 874 977 return ret; 875 978 876 - ret = qcom_qmp_phy_pcie_msm8996_vreg_init(dev, cfg); 877 - if (ret) { 878 - if (ret != -EPROBE_DEFER) 879 - dev_err(dev, "failed to get regulator supplies: %d\n", 880 - ret); 881 - return ret; 882 - } 979 + ret = qmp_pcie_msm8996_vreg_init(dev, cfg); 980 + if (ret) 981 + return dev_err_probe(dev, ret, 982 + "failed to get regulator supplies\n"); 883 983 884 984 num = of_get_available_child_count(dev->of_node); 885 985 /* do we have a rogue child node ? */ ··· 887 993 if (!qmp->phys) 888 994 return -ENOMEM; 889 995 890 - pm_runtime_set_active(dev); 891 - pm_runtime_enable(dev); 892 - /* 893 - * Prevent runtime pm from being ON by default. Users can enable 894 - * it using power/control in sysfs. 895 - */ 896 - pm_runtime_forbid(dev); 897 - 898 996 id = 0; 899 997 for_each_available_child_of_node(dev->of_node, child) { 900 998 /* Create per-lane phy */ 901 - ret = qcom_qmp_phy_pcie_msm8996_create(dev, child, id, serdes, cfg); 999 + ret = qmp_pcie_msm8996_create(dev, child, id, serdes, cfg); 902 1000 if (ret) { 903 1001 dev_err(dev, "failed to create lane%d phy, %d\n", 904 1002 id, ret); ··· 912 1026 } 913 1027 914 1028 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 915 - if (!IS_ERR(phy_provider)) 916 - dev_info(dev, "Registered Qcom-QMP phy\n"); 917 - else 918 - pm_runtime_disable(dev); 919 1029 920 1030 return PTR_ERR_OR_ZERO(phy_provider); 921 1031 922 1032 err_node_put: 923 - pm_runtime_disable(dev); 924 1033 of_node_put(child); 925 1034 return ret; 926 1035 } 927 1036 928 - static struct platform_driver qcom_qmp_phy_pcie_msm8996_driver = { 929 - .probe = qcom_qmp_phy_pcie_msm8996_probe, 1037 + static struct platform_driver qmp_pcie_msm8996_driver = { 1038 + .probe = qmp_pcie_msm8996_probe, 930 1039 .driver = { 931 1040 .name = "qcom-qmp-msm8996-pcie-phy", 932 - .of_match_table = qcom_qmp_phy_pcie_msm8996_of_match_table, 1041 + .of_match_table = qmp_pcie_msm8996_of_match_table, 933 1042 }, 934 1043 }; 935 1044 936 - module_platform_driver(qcom_qmp_phy_pcie_msm8996_driver); 1045 + module_platform_driver(qmp_pcie_msm8996_driver); 937 1046 938 1047 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 939 1048 MODULE_DESCRIPTION("Qualcomm QMP MSM8996 PCIe PHY driver");
+104 -252
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
··· 32 32 /* QPHY_START_CONTROL bits */ 33 33 #define SERDES_START BIT(0) 34 34 #define PCS_START BIT(1) 35 - #define PLL_READY_GATE_EN BIT(3) 36 35 /* QPHY_PCS_STATUS bit */ 37 36 #define PHYSTATUS BIT(6) 38 37 #define PHYSTATUS_4_20 BIT(7) 39 - /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 40 - #define PCS_READY BIT(0) 41 - 42 - /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 43 - /* DP PHY soft reset */ 44 - #define SW_DPPHY_RESET BIT(0) 45 - /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ 46 - #define SW_DPPHY_RESET_MUX BIT(1) 47 - /* USB3 PHY soft reset */ 48 - #define SW_USB3PHY_RESET BIT(2) 49 - /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ 50 - #define SW_USB3PHY_RESET_MUX BIT(3) 51 - 52 - /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ 53 - #define USB3_MODE BIT(0) /* enables USB3 mode */ 54 - #define DP_MODE BIT(1) /* enables DP mode */ 55 - 56 - /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ 57 - #define ARCVR_DTCT_EN BIT(0) 58 - #define ALFPS_DTCT_EN BIT(1) 59 - #define ARCVR_DTCT_EVENT_SEL BIT(4) 60 - 61 - /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ 62 - #define IRQ_CLEAR BIT(0) 63 - 64 - /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ 65 - #define RCVR_DETECT BIT(0) 66 - 67 - /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ 68 - #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ 69 38 70 39 #define PHY_INIT_COMPLETE_TIMEOUT 10000 71 - #define POWER_DOWN_DELAY_US_MIN 10 72 - #define POWER_DOWN_DELAY_US_MAX 11 73 - 74 - #define MAX_PROP_NAME 32 75 - 76 - /* Define the assumed distance between lanes for underspecified device trees. */ 77 - #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 78 40 79 41 struct qmp_phy_init_tbl { 80 42 unsigned int offset; ··· 85 123 /* PCS registers */ 86 124 QPHY_SW_RESET, 87 125 QPHY_START_CTRL, 88 - QPHY_PCS_READY_STATUS, 89 126 QPHY_PCS_STATUS, 90 - QPHY_PCS_AUTONOMOUS_MODE_CTRL, 91 - QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 92 - QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 93 127 QPHY_PCS_POWER_DOWN_CONTROL, 94 - /* PCS_MISC registers */ 95 - QPHY_PCS_MISC_TYPEC_CTRL, 96 128 /* Keep last to ensure regs_layout arrays are properly initialized */ 97 129 QPHY_LAYOUT_SIZE 98 130 }; ··· 1300 1344 QMP_PHY_INIT_CFG(QPHY_V5_20_PCS_PCIE_G4_PRE_GAIN, 0x2e), 1301 1345 }; 1302 1346 1303 - struct qmp_phy; 1304 - 1305 1347 /* struct qmp_phy_cfg - per-PHY initialization config */ 1306 1348 struct qmp_phy_cfg { 1307 - /* phy-type - PCIE/UFS/USB */ 1308 - unsigned int type; 1309 - /* number of lanes provided by phy */ 1310 - int nlanes; 1349 + int lanes; 1311 1350 1312 1351 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 1313 1352 const struct qmp_phy_init_tbl *serdes_tbl; ··· 1341 1390 1342 1391 unsigned int start_ctrl; 1343 1392 unsigned int pwrdn_ctrl; 1344 - unsigned int mask_com_pcs_ready; 1345 1393 /* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ 1346 1394 unsigned int phy_status; 1347 1395 ··· 1349 1399 /* power_down delay in usec */ 1350 1400 int pwrdn_delay_min; 1351 1401 int pwrdn_delay_max; 1352 - 1353 - /* true, if PHY has secondary tx/rx lanes to be configured */ 1354 - bool is_dual_lane_phy; 1355 1402 1356 1403 /* QMP PHY pipe clock interface rate */ 1357 1404 unsigned long pipe_clock_rate; ··· 1367 1420 * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 1368 1421 * @pcs_misc: iomapped memory space for lane's pcs_misc 1369 1422 * @pipe_clk: pipe clock 1370 - * @index: lane index 1371 1423 * @qmp: QMP phy to which this lane belongs 1372 - * @mode: current PHY mode 1373 1424 */ 1374 1425 struct qmp_phy { 1375 1426 struct phy *phy; ··· 1380 1435 void __iomem *rx2; 1381 1436 void __iomem *pcs_misc; 1382 1437 struct clk *pipe_clk; 1383 - unsigned int index; 1384 1438 struct qcom_qmp *qmp; 1385 - enum phy_mode mode; 1386 1439 }; 1387 1440 1388 1441 /** ··· 1457 1514 }; 1458 1515 1459 1516 static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { 1460 - .type = PHY_TYPE_PCIE, 1461 - .nlanes = 1, 1517 + .lanes = 1, 1462 1518 1463 1519 .serdes_tbl = ipq8074_pcie_serdes_tbl, 1464 1520 .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_serdes_tbl), ··· 1485 1543 }; 1486 1544 1487 1545 static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { 1488 - .type = PHY_TYPE_PCIE, 1489 - .nlanes = 1, 1546 + .lanes = 1, 1490 1547 1491 1548 .serdes_tbl = ipq8074_pcie_gen3_serdes_tbl, 1492 1549 .serdes_tbl_num = ARRAY_SIZE(ipq8074_pcie_gen3_serdes_tbl), ··· 1514 1573 }; 1515 1574 1516 1575 static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { 1517 - .type = PHY_TYPE_PCIE, 1518 - .nlanes = 1, 1576 + .lanes = 1, 1519 1577 1520 1578 .serdes_tbl = ipq6018_pcie_serdes_tbl, 1521 1579 .serdes_tbl_num = ARRAY_SIZE(ipq6018_pcie_serdes_tbl), ··· 1543 1603 }; 1544 1604 1545 1605 static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { 1546 - .type = PHY_TYPE_PCIE, 1547 - .nlanes = 1, 1606 + .lanes = 1, 1548 1607 1549 1608 .serdes_tbl = sdm845_qmp_pcie_serdes_tbl, 1550 1609 .serdes_tbl_num = ARRAY_SIZE(sdm845_qmp_pcie_serdes_tbl), ··· 1573 1634 }; 1574 1635 1575 1636 static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { 1576 - .type = PHY_TYPE_PCIE, 1577 - .nlanes = 1, 1637 + .lanes = 1, 1578 1638 1579 1639 .serdes_tbl = sdm845_qhp_pcie_serdes_tbl, 1580 1640 .serdes_tbl_num = ARRAY_SIZE(sdm845_qhp_pcie_serdes_tbl), ··· 1601 1663 }; 1602 1664 1603 1665 static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { 1604 - .type = PHY_TYPE_PCIE, 1605 - .nlanes = 1, 1666 + .lanes = 1, 1606 1667 1607 1668 .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 1608 1669 .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), ··· 1639 1702 }; 1640 1703 1641 1704 static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { 1642 - .type = PHY_TYPE_PCIE, 1643 - .nlanes = 2, 1705 + .lanes = 2, 1644 1706 1645 1707 .serdes_tbl = sm8250_qmp_pcie_serdes_tbl, 1646 1708 .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_serdes_tbl), ··· 1671 1735 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1672 1736 .phy_status = PHYSTATUS, 1673 1737 1674 - .is_dual_lane_phy = true, 1675 1738 .has_pwrdn_delay = true, 1676 1739 .pwrdn_delay_min = 995, /* us */ 1677 1740 .pwrdn_delay_max = 1005, /* us */ 1678 1741 }; 1679 1742 1680 1743 static const struct qmp_phy_cfg msm8998_pciephy_cfg = { 1681 - .type = PHY_TYPE_PCIE, 1682 - .nlanes = 1, 1744 + .lanes = 1, 1683 1745 1684 1746 .serdes_tbl = msm8998_pcie_serdes_tbl, 1685 1747 .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl), ··· 1701 1767 }; 1702 1768 1703 1769 static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { 1704 - .type = PHY_TYPE_PCIE, 1705 - .nlanes = 1, 1770 + .lanes = 1, 1706 1771 1707 1772 .serdes_tbl = sc8180x_qmp_pcie_serdes_tbl, 1708 1773 .serdes_tbl_num = ARRAY_SIZE(sc8180x_qmp_pcie_serdes_tbl), ··· 1730 1797 }; 1731 1798 1732 1799 static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { 1733 - .type = PHY_TYPE_PCIE, 1734 - .nlanes = 2, 1800 + .lanes = 2, 1735 1801 1736 1802 .serdes_tbl = sdx55_qmp_pcie_serdes_tbl, 1737 1803 .serdes_tbl_num = ARRAY_SIZE(sdx55_qmp_pcie_serdes_tbl), ··· 1754 1822 .pwrdn_ctrl = SW_PWRDN, 1755 1823 .phy_status = PHYSTATUS_4_20, 1756 1824 1757 - .is_dual_lane_phy = true, 1758 1825 .has_pwrdn_delay = true, 1759 1826 .pwrdn_delay_min = 995, /* us */ 1760 1827 .pwrdn_delay_max = 1005, /* us */ 1761 1828 }; 1762 1829 1763 1830 static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { 1764 - .type = PHY_TYPE_PCIE, 1765 - .nlanes = 1, 1831 + .lanes = 1, 1766 1832 1767 1833 .serdes_tbl = sm8450_qmp_gen3x1_pcie_serdes_tbl, 1768 1834 .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen3x1_pcie_serdes_tbl), ··· 1790 1860 }; 1791 1861 1792 1862 static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { 1793 - .type = PHY_TYPE_PCIE, 1794 - .nlanes = 2, 1863 + .lanes = 2, 1795 1864 1796 1865 .serdes_tbl = sm8450_qmp_gen4x2_pcie_serdes_tbl, 1797 1866 .serdes_tbl_num = ARRAY_SIZE(sm8450_qmp_gen4x2_pcie_serdes_tbl), ··· 1814 1885 .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, 1815 1886 .phy_status = PHYSTATUS_4_20, 1816 1887 1817 - .is_dual_lane_phy = true, 1818 1888 .has_pwrdn_delay = true, 1819 1889 .pwrdn_delay_min = 995, /* us */ 1820 1890 .pwrdn_delay_max = 1005, /* us */ 1821 1891 }; 1822 1892 1823 - static void qcom_qmp_phy_pcie_configure_lane(void __iomem *base, 1893 + static void qmp_pcie_configure_lane(void __iomem *base, 1824 1894 const unsigned int *regs, 1825 1895 const struct qmp_phy_init_tbl tbl[], 1826 1896 int num, ··· 1842 1914 } 1843 1915 } 1844 1916 1845 - static void qcom_qmp_phy_pcie_configure(void __iomem *base, 1846 - const unsigned int *regs, 1847 - const struct qmp_phy_init_tbl tbl[], 1848 - int num) 1917 + static void qmp_pcie_configure(void __iomem *base, 1918 + const unsigned int *regs, 1919 + const struct qmp_phy_init_tbl tbl[], 1920 + int num) 1849 1921 { 1850 - qcom_qmp_phy_pcie_configure_lane(base, regs, tbl, num, 0xff); 1922 + qmp_pcie_configure_lane(base, regs, tbl, num, 0xff); 1851 1923 } 1852 1924 1853 - static int qcom_qmp_phy_pcie_serdes_init(struct qmp_phy *qphy) 1925 + static int qmp_pcie_serdes_init(struct qmp_phy *qphy) 1854 1926 { 1855 1927 const struct qmp_phy_cfg *cfg = qphy->cfg; 1856 1928 void __iomem *serdes = qphy->serdes; 1857 1929 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 1858 1930 int serdes_tbl_num = cfg->serdes_tbl_num; 1859 1931 1860 - qcom_qmp_phy_pcie_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 1861 - if (cfg->serdes_tbl_sec) 1862 - qcom_qmp_phy_pcie_configure(serdes, cfg->regs, cfg->serdes_tbl_sec, 1863 - cfg->serdes_tbl_num_sec); 1932 + qmp_pcie_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 1933 + qmp_pcie_configure(serdes, cfg->regs, cfg->serdes_tbl_sec, cfg->serdes_tbl_num_sec); 1864 1934 1865 1935 return 0; 1866 1936 } 1867 1937 1868 - static int qcom_qmp_phy_pcie_com_init(struct qmp_phy *qphy) 1938 + static int qmp_pcie_init(struct phy *phy) 1869 1939 { 1940 + struct qmp_phy *qphy = phy_get_drvdata(phy); 1870 1941 struct qcom_qmp *qmp = qphy->qmp; 1871 1942 const struct qmp_phy_cfg *cfg = qphy->cfg; 1872 1943 void __iomem *pcs = qphy->pcs; ··· 1912 1985 return ret; 1913 1986 } 1914 1987 1915 - static int qcom_qmp_phy_pcie_com_exit(struct qmp_phy *qphy) 1988 + static int qmp_pcie_exit(struct phy *phy) 1916 1989 { 1990 + struct qmp_phy *qphy = phy_get_drvdata(phy); 1917 1991 struct qcom_qmp *qmp = qphy->qmp; 1918 1992 const struct qmp_phy_cfg *cfg = qphy->cfg; 1919 1993 ··· 1927 1999 return 0; 1928 2000 } 1929 2001 1930 - static int qcom_qmp_phy_pcie_init(struct phy *phy) 1931 - { 1932 - struct qmp_phy *qphy = phy_get_drvdata(phy); 1933 - struct qcom_qmp *qmp = qphy->qmp; 1934 - int ret; 1935 - dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 1936 - 1937 - ret = qcom_qmp_phy_pcie_com_init(qphy); 1938 - if (ret) 1939 - return ret; 1940 - 1941 - return 0; 1942 - } 1943 - 1944 - static int qcom_qmp_phy_pcie_power_on(struct phy *phy) 2002 + static int qmp_pcie_power_on(struct phy *phy) 1945 2003 { 1946 2004 struct qmp_phy *qphy = phy_get_drvdata(phy); 1947 2005 struct qcom_qmp *qmp = qphy->qmp; ··· 1940 2026 unsigned int mask, val, ready; 1941 2027 int ret; 1942 2028 1943 - qcom_qmp_phy_pcie_serdes_init(qphy); 2029 + qmp_pcie_serdes_init(qphy); 1944 2030 1945 2031 ret = clk_prepare_enable(qphy->pipe_clk); 1946 2032 if (ret) { ··· 1949 2035 } 1950 2036 1951 2037 /* Tx, Rx, and PCS configurations */ 1952 - qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, 1953 - cfg->tx_tbl, cfg->tx_tbl_num, 1); 1954 - if (cfg->tx_tbl_sec) 1955 - qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl_sec, 1956 - cfg->tx_tbl_num_sec, 1); 2038 + qmp_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2039 + qmp_pcie_configure_lane(tx, cfg->regs, cfg->tx_tbl_sec, cfg->tx_tbl_num_sec, 1); 1957 2040 1958 - /* Configuration for other LANE for USB-DP combo PHY */ 1959 - if (cfg->is_dual_lane_phy) { 1960 - qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, 1961 - cfg->tx_tbl, cfg->tx_tbl_num, 2); 1962 - if (cfg->tx_tbl_sec) 1963 - qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, 1964 - cfg->tx_tbl_sec, 1965 - cfg->tx_tbl_num_sec, 2); 2041 + if (cfg->lanes >= 2) { 2042 + qmp_pcie_configure_lane(qphy->tx2, cfg->regs, cfg->tx_tbl, 2043 + cfg->tx_tbl_num, 2); 2044 + qmp_pcie_configure_lane(qphy->tx2, cfg->regs, cfg->tx_tbl_sec, 2045 + cfg->tx_tbl_num_sec, 2); 1966 2046 } 1967 2047 1968 - qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, 1969 - cfg->rx_tbl, cfg->rx_tbl_num, 1); 1970 - if (cfg->rx_tbl_sec) 1971 - qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, 1972 - cfg->rx_tbl_sec, cfg->rx_tbl_num_sec, 1); 2048 + qmp_pcie_configure_lane(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2049 + qmp_pcie_configure_lane(rx, cfg->regs, cfg->rx_tbl_sec, cfg->rx_tbl_num_sec, 1); 1973 2050 1974 - if (cfg->is_dual_lane_phy) { 1975 - qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, 1976 - cfg->rx_tbl, cfg->rx_tbl_num, 2); 1977 - if (cfg->rx_tbl_sec) 1978 - qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, 1979 - cfg->rx_tbl_sec, 1980 - cfg->rx_tbl_num_sec, 2); 2051 + if (cfg->lanes >= 2) { 2052 + qmp_pcie_configure_lane(qphy->rx2, cfg->regs, cfg->rx_tbl, 2053 + cfg->rx_tbl_num, 2); 2054 + qmp_pcie_configure_lane(qphy->rx2, cfg->regs, cfg->rx_tbl_sec, 2055 + cfg->rx_tbl_num_sec, 2); 1981 2056 } 1982 2057 1983 - qcom_qmp_phy_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 1984 - if (cfg->pcs_tbl_sec) 1985 - qcom_qmp_phy_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl_sec, 1986 - cfg->pcs_tbl_num_sec); 2058 + qmp_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2059 + qmp_pcie_configure(pcs, cfg->regs, cfg->pcs_tbl_sec, cfg->pcs_tbl_num_sec); 1987 2060 1988 - qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, 1989 - cfg->pcs_misc_tbl_num); 1990 - if (cfg->pcs_misc_tbl_sec) 1991 - qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, 1992 - cfg->pcs_misc_tbl_num_sec); 2061 + qmp_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num); 2062 + qmp_pcie_configure(pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec); 1993 2063 1994 2064 /* 1995 2065 * Pull out PHY from POWER DOWN state. ··· 2009 2111 return ret; 2010 2112 } 2011 2113 2012 - static int qcom_qmp_phy_pcie_power_off(struct phy *phy) 2114 + static int qmp_pcie_power_off(struct phy *phy) 2013 2115 { 2014 2116 struct qmp_phy *qphy = phy_get_drvdata(phy); 2015 2117 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 2034 2136 return 0; 2035 2137 } 2036 2138 2037 - static int qcom_qmp_phy_pcie_exit(struct phy *phy) 2038 - { 2039 - struct qmp_phy *qphy = phy_get_drvdata(phy); 2040 - 2041 - qcom_qmp_phy_pcie_com_exit(qphy); 2042 - 2043 - return 0; 2044 - } 2045 - 2046 - static int qcom_qmp_phy_pcie_enable(struct phy *phy) 2139 + static int qmp_pcie_enable(struct phy *phy) 2047 2140 { 2048 2141 int ret; 2049 2142 2050 - ret = qcom_qmp_phy_pcie_init(phy); 2143 + ret = qmp_pcie_init(phy); 2051 2144 if (ret) 2052 2145 return ret; 2053 2146 2054 - ret = qcom_qmp_phy_pcie_power_on(phy); 2147 + ret = qmp_pcie_power_on(phy); 2055 2148 if (ret) 2056 - qcom_qmp_phy_pcie_exit(phy); 2149 + qmp_pcie_exit(phy); 2057 2150 2058 2151 return ret; 2059 2152 } 2060 2153 2061 - static int qcom_qmp_phy_pcie_disable(struct phy *phy) 2154 + static int qmp_pcie_disable(struct phy *phy) 2062 2155 { 2063 2156 int ret; 2064 2157 2065 - ret = qcom_qmp_phy_pcie_power_off(phy); 2158 + ret = qmp_pcie_power_off(phy); 2066 2159 if (ret) 2067 2160 return ret; 2068 - return qcom_qmp_phy_pcie_exit(phy); 2161 + 2162 + return qmp_pcie_exit(phy); 2069 2163 } 2070 2164 2071 - static int qcom_qmp_phy_pcie_set_mode(struct phy *phy, 2072 - enum phy_mode mode, int submode) 2073 - { 2074 - struct qmp_phy *qphy = phy_get_drvdata(phy); 2075 - 2076 - qphy->mode = mode; 2077 - 2078 - return 0; 2079 - } 2080 - 2081 - static int qcom_qmp_phy_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2165 + static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2082 2166 { 2083 2167 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2084 2168 int num = cfg->num_vregs; ··· 2076 2196 return devm_regulator_bulk_get(dev, num, qmp->vregs); 2077 2197 } 2078 2198 2079 - static int qcom_qmp_phy_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2199 + static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2080 2200 { 2081 2201 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2082 2202 int i; ··· 2097 2217 return 0; 2098 2218 } 2099 2219 2100 - static int qcom_qmp_phy_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2220 + static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2101 2221 { 2102 2222 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2103 2223 int num = cfg->num_clks; ··· 2180 2300 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 2181 2301 } 2182 2302 2183 - static const struct phy_ops qcom_qmp_phy_pcie_ops = { 2184 - .power_on = qcom_qmp_phy_pcie_enable, 2185 - .power_off = qcom_qmp_phy_pcie_disable, 2186 - .set_mode = qcom_qmp_phy_pcie_set_mode, 2303 + static const struct phy_ops qmp_pcie_ops = { 2304 + .power_on = qmp_pcie_enable, 2305 + .power_off = qmp_pcie_disable, 2187 2306 .owner = THIS_MODULE, 2188 2307 }; 2189 2308 2190 - static 2191 - int qcom_qmp_phy_pcie_create(struct device *dev, struct device_node *np, int id, 2309 + static int qmp_pcie_create(struct device *dev, struct device_node *np, int id, 2192 2310 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 2193 2311 { 2194 2312 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2195 2313 struct phy *generic_phy; 2196 2314 struct qmp_phy *qphy; 2197 - char prop_name[MAX_PROP_NAME]; 2198 2315 int ret; 2199 2316 2200 2317 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); ··· 2206 2329 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 2207 2330 * For single lane PHYs: pcs_misc (optional) -> 3. 2208 2331 */ 2209 - qphy->tx = of_iomap(np, 0); 2210 - if (!qphy->tx) 2211 - return -ENOMEM; 2332 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 2333 + if (IS_ERR(qphy->tx)) 2334 + return PTR_ERR(qphy->tx); 2212 2335 2213 - qphy->rx = of_iomap(np, 1); 2214 - if (!qphy->rx) 2215 - return -ENOMEM; 2336 + if (of_device_is_compatible(dev->of_node, "qcom,sdm845-qhp-pcie-phy")) 2337 + qphy->rx = qphy->tx; 2338 + else 2339 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 2340 + if (IS_ERR(qphy->rx)) 2341 + return PTR_ERR(qphy->rx); 2216 2342 2217 - qphy->pcs = of_iomap(np, 2); 2218 - if (!qphy->pcs) 2219 - return -ENOMEM; 2343 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 2344 + if (IS_ERR(qphy->pcs)) 2345 + return PTR_ERR(qphy->pcs); 2220 2346 2221 - /* 2222 - * If this is a dual-lane PHY, then there should be registers for the 2223 - * second lane. Some old device trees did not specify this, so fall 2224 - * back to old legacy behavior of assuming they can be reached at an 2225 - * offset from the first lane. 2226 - */ 2227 - if (cfg->is_dual_lane_phy) { 2228 - qphy->tx2 = of_iomap(np, 3); 2229 - qphy->rx2 = of_iomap(np, 4); 2230 - if (!qphy->tx2 || !qphy->rx2) { 2231 - dev_warn(dev, 2232 - "Underspecified device tree, falling back to legacy register regions\n"); 2347 + if (cfg->lanes >= 2) { 2348 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 2349 + if (IS_ERR(qphy->tx2)) 2350 + return PTR_ERR(qphy->tx2); 2233 2351 2234 - /* In the old version, pcs_misc is at index 3. */ 2235 - qphy->pcs_misc = qphy->tx2; 2236 - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 2237 - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 2352 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 2353 + if (IS_ERR(qphy->rx2)) 2354 + return PTR_ERR(qphy->rx2); 2238 2355 2239 - } else { 2240 - qphy->pcs_misc = of_iomap(np, 5); 2241 - } 2242 - 2356 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 2243 2357 } else { 2244 - qphy->pcs_misc = of_iomap(np, 3); 2358 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 2245 2359 } 2246 2360 2247 - if (!qphy->pcs_misc && 2361 + if (IS_ERR(qphy->pcs_misc) && 2248 2362 of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) 2249 2363 qphy->pcs_misc = qphy->pcs + 0x400; 2250 2364 2251 - if (!qphy->pcs_misc) 2252 - dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 2365 + if (IS_ERR(qphy->pcs_misc)) { 2366 + if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) 2367 + return PTR_ERR(qphy->pcs_misc); 2368 + } 2253 2369 2254 - snprintf(prop_name, sizeof(prop_name), "pipe%d", id); 2255 - qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name); 2370 + qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 2256 2371 if (IS_ERR(qphy->pipe_clk)) { 2257 2372 return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 2258 2373 "failed to get lane%d pipe clock\n", id); 2259 2374 } 2260 2375 2261 - generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_pcie_ops); 2376 + generic_phy = devm_phy_create(dev, np, &qmp_pcie_ops); 2262 2377 if (IS_ERR(generic_phy)) { 2263 2378 ret = PTR_ERR(generic_phy); 2264 2379 dev_err(dev, "failed to create qphy %d\n", ret); ··· 2258 2389 } 2259 2390 2260 2391 qphy->phy = generic_phy; 2261 - qphy->index = id; 2262 2392 qphy->qmp = qmp; 2263 2393 qmp->phys[id] = qphy; 2264 2394 phy_set_drvdata(generic_phy, qphy); ··· 2265 2397 return 0; 2266 2398 } 2267 2399 2268 - static const struct of_device_id qcom_qmp_phy_pcie_of_match_table[] = { 2400 + static const struct of_device_id qmp_pcie_of_match_table[] = { 2269 2401 { 2270 2402 .compatible = "qcom,msm8998-qmp-pcie-phy", 2271 2403 .data = &msm8998_pciephy_cfg, ··· 2308 2440 }, 2309 2441 { }, 2310 2442 }; 2311 - MODULE_DEVICE_TABLE(of, qcom_qmp_phy_pcie_of_match_table); 2443 + MODULE_DEVICE_TABLE(of, qmp_pcie_of_match_table); 2312 2444 2313 - static int qcom_qmp_phy_pcie_probe(struct platform_device *pdev) 2445 + static int qmp_pcie_probe(struct platform_device *pdev) 2314 2446 { 2315 2447 struct qcom_qmp *qmp; 2316 2448 struct device *dev = &pdev->dev; ··· 2338 2470 if (IS_ERR(serdes)) 2339 2471 return PTR_ERR(serdes); 2340 2472 2341 - ret = qcom_qmp_phy_pcie_clk_init(dev, cfg); 2473 + ret = qmp_pcie_clk_init(dev, cfg); 2342 2474 if (ret) 2343 2475 return ret; 2344 2476 2345 - ret = qcom_qmp_phy_pcie_reset_init(dev, cfg); 2477 + ret = qmp_pcie_reset_init(dev, cfg); 2346 2478 if (ret) 2347 2479 return ret; 2348 2480 2349 - ret = qcom_qmp_phy_pcie_vreg_init(dev, cfg); 2350 - if (ret) { 2351 - if (ret != -EPROBE_DEFER) 2352 - dev_err(dev, "failed to get regulator supplies: %d\n", 2353 - ret); 2354 - return ret; 2355 - } 2481 + ret = qmp_pcie_vreg_init(dev, cfg); 2482 + if (ret) 2483 + return dev_err_probe(dev, ret, 2484 + "failed to get regulator supplies\n"); 2356 2485 2357 2486 num = of_get_available_child_count(dev->of_node); 2358 2487 /* do we have a rogue child node ? */ ··· 2360 2495 if (!qmp->phys) 2361 2496 return -ENOMEM; 2362 2497 2363 - pm_runtime_set_active(dev); 2364 - pm_runtime_enable(dev); 2365 - /* 2366 - * Prevent runtime pm from being ON by default. Users can enable 2367 - * it using power/control in sysfs. 2368 - */ 2369 - pm_runtime_forbid(dev); 2370 - 2371 2498 id = 0; 2372 2499 for_each_available_child_of_node(dev->of_node, child) { 2373 2500 /* Create per-lane phy */ 2374 - ret = qcom_qmp_phy_pcie_create(dev, child, id, serdes, cfg); 2501 + ret = qmp_pcie_create(dev, child, id, serdes, cfg); 2375 2502 if (ret) { 2376 2503 dev_err(dev, "failed to create lane%d phy, %d\n", 2377 2504 id, ret); ··· 2385 2528 } 2386 2529 2387 2530 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 2388 - if (!IS_ERR(phy_provider)) 2389 - dev_info(dev, "Registered Qcom-QMP phy\n"); 2390 - else 2391 - pm_runtime_disable(dev); 2392 2531 2393 2532 return PTR_ERR_OR_ZERO(phy_provider); 2394 2533 2395 2534 err_node_put: 2396 - pm_runtime_disable(dev); 2397 2535 of_node_put(child); 2398 2536 return ret; 2399 2537 } 2400 2538 2401 - static struct platform_driver qcom_qmp_phy_pcie_driver = { 2402 - .probe = qcom_qmp_phy_pcie_probe, 2539 + static struct platform_driver qmp_pcie_driver = { 2540 + .probe = qmp_pcie_probe, 2403 2541 .driver = { 2404 2542 .name = "qcom-qmp-pcie-phy", 2405 - .of_match_table = qcom_qmp_phy_pcie_of_match_table, 2543 + .of_match_table = qmp_pcie_of_match_table, 2406 2544 }, 2407 2545 }; 2408 2546 2409 - module_platform_driver(qcom_qmp_phy_pcie_driver); 2547 + module_platform_driver(qmp_pcie_driver); 2410 2548 2411 2549 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2412 2550 MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver");
+13
drivers/phy/qualcomm/phy-qcom-qmp-pcs-v5.h
··· 7 7 #define QCOM_PHY_QMP_PCS_V5_H_ 8 8 9 9 /* Only for QMP V5 PHY - USB/PCIe PCS registers */ 10 + #define QPHY_V5_PCS_LOCK_DETECT_CONFIG1 0x0c4 11 + #define QPHY_V5_PCS_LOCK_DETECT_CONFIG2 0x0c8 12 + #define QPHY_V5_PCS_LOCK_DETECT_CONFIG3 0x0cc 13 + #define QPHY_V5_PCS_LOCK_DETECT_CONFIG6 0x0d8 10 14 #define QPHY_V5_PCS_REFGEN_REQ_CONFIG1 0x0dc 11 15 #define QPHY_V5_PCS_G3S2_PRE_GAIN 0x170 12 16 #define QPHY_V5_PCS_RX_SIGDET_LVL 0x188 17 + #define QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_L 0x190 18 + #define QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_H 0x194 13 19 #define QPHY_V5_PCS_RATE_SLEW_CNTRL1 0x198 20 + #define QPHY_V5_PCS_CDR_RESET_TIME 0x1b0 21 + #define QPHY_V5_PCS_RX_CONFIG 0x1b0 22 + #define QPHY_V5_PCS_ALIGN_DETECT_CONFIG1 0x1c0 23 + #define QPHY_V5_PCS_ALIGN_DETECT_CONFIG2 0x1c4 24 + #define QPHY_V5_PCS_PCS_TX_RX_CONFIG 0x1d0 25 + #define QPHY_V5_PCS_EQ_CONFIG1 0x1dc 14 26 #define QPHY_V5_PCS_EQ_CONFIG2 0x1e0 15 27 #define QPHY_V5_PCS_EQ_CONFIG3 0x1e4 28 + #define QPHY_V5_PCS_EQ_CONFIG5 0x1ec 16 29 17 30 #endif
+333
drivers/phy/qualcomm/phy-qcom-qmp-qserdes-txrx-v5_5nm.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (c) 2021, The Linux Foundation. All rights reserved. 4 + */ 5 + 6 + #ifndef QCOM_PHY_QMP_QSERDES_TXRX_V5_5NM_H_ 7 + #define QCOM_PHY_QMP_QSERDES_TXRX_V5_5NM_H_ 8 + 9 + /* Only for QMP V5 5NM PHY - TX registers */ 10 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX 0x30 11 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX 0x34 12 + #define QSERDES_V5_5NM_TX_LANE_MODE_1 0x78 13 + #define QSERDES_V5_5NM_TX_LANE_MODE_2 0x7c 14 + #define QSERDES_V5_5NM_TX_LANE_MODE_3 0x80 15 + #define QSERDES_V5_5NM_TX_BIST_MODE_LANENO 0x00 16 + #define QSERDES_V5_5NM_TX_BIST_INVERT 0x04 17 + #define QSERDES_V5_5NM_TX_CLKBUF_ENABLE 0x08 18 + #define QSERDES_V5_5NM_TX_TX_EMP_POST1_LVL 0x0c 19 + #define QSERDES_V5_5NM_TX_TX_IDLE_LVL_LARGE_AMP 0x10 20 + #define QSERDES_V5_5NM_TX_TX_DRV_LVL 0x14 21 + #define QSERDES_V5_5NM_TX_TX_DRV_LVL_OFFSET 0x18 22 + #define QSERDES_V5_5NM_TX_RESET_TSYNC_EN 0x1c 23 + #define QSERDES_V5_5NM_TX_PRE_STALL_LDO_BOOST_EN 0x20 24 + #define QSERDES_V5_5NM_TX_LPB_EN 0x24 25 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_TX 0x28 26 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_RX 0x2c 27 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_TX 0x30 28 + #define QSERDES_V5_5NM_TX_RES_CODE_LANE_OFFSET_RX 0x34 29 + #define QSERDES_V5_5NM_TX_PERL_LENGTH1 0x38 30 + #define QSERDES_V5_5NM_TX_PERL_LENGTH2 0x3c 31 + #define QSERDES_V5_5NM_TX_SERDES_BYP_EN_OUT 0x40 32 + #define QSERDES_V5_5NM_TX_DEBUG_BUS_SEL 0x44 33 + #define QSERDES_V5_5NM_TX_TRANSCEIVER_BIAS_EN 0x48 34 + #define QSERDES_V5_5NM_TX_HIGHZ_DRVR_EN 0x4c 35 + #define QSERDES_V5_5NM_TX_TX_POL_INV 0x50 36 + #define QSERDES_V5_5NM_TX_PARRATE_REC_DETECT_IDLE_EN 0x54 37 + #define QSERDES_V5_5NM_TX_BIST_PATTERN1 0x58 38 + #define QSERDES_V5_5NM_TX_BIST_PATTERN2 0x5c 39 + #define QSERDES_V5_5NM_TX_BIST_PATTERN3 0x60 40 + #define QSERDES_V5_5NM_TX_BIST_PATTERN4 0x64 41 + #define QSERDES_V5_5NM_TX_BIST_PATTERN5 0x68 42 + #define QSERDES_V5_5NM_TX_BIST_PATTERN6 0x6c 43 + #define QSERDES_V5_5NM_TX_BIST_PATTERN7 0x70 44 + #define QSERDES_V5_5NM_TX_BIST_PATTERN8 0x74 45 + #define QSERDES_V5_5NM_TX_LANE_MODE_1 0x78 46 + #define QSERDES_V5_5NM_TX_LANE_MODE_2 0x7c 47 + #define QSERDES_V5_5NM_TX_LANE_MODE_3 0x80 48 + #define QSERDES_V5_5NM_TX_ATB_SEL1 0x84 49 + #define QSERDES_V5_5NM_TX_ATB_SEL2 0x88 50 + #define QSERDES_V5_5NM_TX_RCV_DETECT_LVL 0x8c 51 + #define QSERDES_V5_5NM_TX_RCV_DETECT_LVL_2 0x90 52 + #define QSERDES_V5_5NM_TX_PRBS_SEED1 0x94 53 + #define QSERDES_V5_5NM_TX_PRBS_SEED2 0x98 54 + #define QSERDES_V5_5NM_TX_PRBS_SEED3 0x9c 55 + #define QSERDES_V5_5NM_TX_PRBS_SEED4 0xa0 56 + #define QSERDES_V5_5NM_TX_RESET_GEN 0xa4 57 + #define QSERDES_V5_5NM_TX_RESET_GEN_MUXES 0xa8 58 + #define QSERDES_V5_5NM_TX_TRAN_DRVR_EMP_EN 0xac 59 + #define QSERDES_V5_5NM_TX_VMODE_CTRL1 0xb0 60 + #define QSERDES_V5_5NM_TX_ALOG_OBSV_BUS_CTRL_1 0xb4 61 + #define QSERDES_V5_5NM_TX_BIST_STATUS 0xb8 62 + #define QSERDES_V5_5NM_TX_BIST_ERROR_COUNT1 0xbc 63 + #define QSERDES_V5_5NM_TX_BIST_ERROR_COUNT2 0xc0 64 + #define QSERDES_V5_5NM_TX_ALOG_OBSV_BUS_STATUS_1 0xc4 65 + #define QSERDES_V5_5NM_TX_LANE_DIG_CONFIG 0xc8 66 + #define QSERDES_V5_5NM_TX_PI_QEC_CTRL 0xcc 67 + #define QSERDES_V5_5NM_TX_PRE_EMPH 0xd0 68 + #define QSERDES_V5_5NM_TX_SW_RESET 0xd4 69 + #define QSERDES_V5_5NM_TX_TX_BAND 0xd8 70 + #define QSERDES_V5_5NM_TX_SLEW_CNTL0 0xdc 71 + #define QSERDES_V5_5NM_TX_SLEW_CNTL1 0xe0 72 + #define QSERDES_V5_5NM_TX_INTERFACE_SELECT 0xe4 73 + #define QSERDES_V5_5NM_TX_DIG_BKUP_CTRL 0xe8 74 + #define QSERDES_V5_5NM_TX_DEBUG_BUS0 0xec 75 + #define QSERDES_V5_5NM_TX_DEBUG_BUS1 0xf0 76 + #define QSERDES_V5_5NM_TX_DEBUG_BUS2 0xf4 77 + #define QSERDES_V5_5NM_TX_DEBUG_BUS3 0xf8 78 + #define QSERDES_V5_5NM_TX_TX_BKUP_RO_BUS 0xfc 79 + 80 + /* Only for QMP V5 5NM PHY - RX registers */ 81 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_FO_GAIN_RATE0 0x000 82 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_FO_GAIN_RATE1 0x004 83 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_FO_GAIN_RATE2 0x008 84 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_FO_GAIN_RATE3 0x00c 85 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_SO_GAIN_RATE0 0x010 86 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_SO_GAIN_RATE1 0x014 87 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_SO_GAIN_RATE2 0x018 88 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_SO_GAIN_RATE3 0x01c 89 + #define QSERDES_V5_5NM_RX_UCDR_SO_SATURATION 0x020 90 + #define QSERDES_V5_5NM_RX_UCDR_FO_TO_SO_DELAY 0x024 91 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_LOW_RATE0 0x028 92 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_HIGH_RATE0 0x02c 93 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_LOW_RATE1 0x030 94 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_HIGH_RATE1 0x034 95 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_LOW_RATE2 0x038 96 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_HIGH_RATE2 0x03c 97 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_LOW_RATE3 0x040 98 + #define QSERDES_V5_5NM_RX_UCDR_FASTLOCK_COUNT_HIGH_RATE3 0x044 99 + #define QSERDES_V5_5NM_RX_UCDR_PI_CTRL1 0x048 100 + #define QSERDES_V5_5NM_RX_UCDR_PI_CTRL2 0x04c 101 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH1_RATE0 0x050 102 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH1_RATE1 0x054 103 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH1_RATE2 0x058 104 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH1_RATE3 0x05c 105 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH2_RATE0 0x060 106 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH2_RATE1 0x064 107 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH2_RATE2 0x068 108 + #define QSERDES_V5_5NM_RX_UCDR_SB2_THRESH2_RATE3 0x06c 109 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN1_RATE0 0x070 110 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN1_RATE1 0x074 111 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN1_RATE2 0x078 112 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN1_RATE3 0x07c 113 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE0 0x080 114 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE1 0x084 115 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE2 0x088 116 + #define QSERDES_V5_5NM_RX_UCDR_SB2_GAIN2_RATE3 0x08c 117 + #define QSERDES_V5_5NM_RX_RXCLK_DIV2_CTRL 0x090 118 + #define QSERDES_V5_5NM_RX_RX_BAND 0x094 119 + #define QSERDES_V5_5NM_RX_RX_TERM_BW 0x098 120 + #define QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE0 0x09c 121 + #define QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE1 0x0a0 122 + #define QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE2 0x0a4 123 + #define QSERDES_V5_5NM_RX_UCDR_FO_GAIN_RATE3 0x0a8 124 + #define QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE0 0x0ac 125 + #define QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE1 0x0b0 126 + #define QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE2 0x0b4 127 + #define QSERDES_V5_5NM_RX_UCDR_SO_GAIN_RATE3 0x0b8 128 + #define QSERDES_V5_5NM_RX_UCDR_PI_CONTROLS 0x0bc 129 + #define QSERDES_V5_5NM_RX_UCDR_PD_DATA_FILTER_ENABLES 0x0c0 130 + #define QSERDES_V5_5NM_RX_UCDR_SO_ACC_DEFAULT_VAL_RATE0 0x0c4 131 + #define QSERDES_V5_5NM_RX_UCDR_SO_ACC_DEFAULT_VAL_RATE1 0x0c8 132 + #define QSERDES_V5_5NM_RX_UCDR_SO_ACC_DEFAULT_VAL_RATE2 0x0cc 133 + #define QSERDES_V5_5NM_RX_UCDR_SO_ACC_DEFAULT_VAL_RATE3 0x0d0 134 + #define QSERDES_V5_5NM_RX_AUX_CONTROL 0x0d4 135 + #define QSERDES_V5_5NM_RX_AUXDATA_TB 0x0d8 136 + #define QSERDES_V5_5NM_RX_RCLK_AUXDATA_SEL 0x0dc 137 + #define QSERDES_V5_5NM_RX_EOM_CTRL 0x0e0 138 + #define QSERDES_V5_5NM_RX_AC_JTAG_ENABLE 0x0e4 139 + #define QSERDES_V5_5NM_RX_AC_JTAG_INITP 0x0e8 140 + #define QSERDES_V5_5NM_RX_AC_JTAG_INITN 0x0ec 141 + #define QSERDES_V5_5NM_RX_AC_JTAG_LVL 0x0f0 142 + #define QSERDES_V5_5NM_RX_AC_JTAG_MODE 0x0f4 143 + #define QSERDES_V5_5NM_RX_AC_JTAG_RESET 0x0f8 144 + #define QSERDES_V5_5NM_RX_RX_RCVR_IQ_EN 0x0fc 145 + #define QSERDES_V5_5NM_RX_RX_Q_EN_RATES 0x100 146 + #define QSERDES_V5_5NM_RX_RX_IDAC_I0_DC_OFFSETS 0x104 147 + #define QSERDES_V5_5NM_RX_RX_IDAC_I0BAR_DC_OFFSETS 0x108 148 + #define QSERDES_V5_5NM_RX_RX_IDAC_I1_DC_OFFSETS 0x10c 149 + #define QSERDES_V5_5NM_RX_RX_IDAC_I1BAR_DC_OFFSETS 0x110 150 + #define QSERDES_V5_5NM_RX_RX_IDAC_Q_DC_OFFSETS 0x114 151 + #define QSERDES_V5_5NM_RX_RX_IDAC_QBAR_DC_OFFSETS 0x118 152 + #define QSERDES_V5_5NM_RX_RX_IDAC_A_DC_OFFSETS 0x11c 153 + #define QSERDES_V5_5NM_RX_RX_IDAC_ABAR_DC_OFFSETS 0x120 154 + #define QSERDES_V5_5NM_RX_RX_IDAC_EN 0x124 155 + #define QSERDES_V5_5NM_RX_RX_IDAC_ENABLES 0x128 156 + #define QSERDES_V5_5NM_RX_RX_IDAC_SIGN 0x12c 157 + #define QSERDES_V5_5NM_RX_RX_IVCM_CAL_CODE_OVERRIDE 0x130 158 + #define QSERDES_V5_5NM_RX_RX_IVCM_CAL_CTRL1 0x134 159 + #define QSERDES_V5_5NM_RX_RX_IVCM_CAL_CTRL2 0x138 160 + #define QSERDES_V5_5NM_RX_RX_IVCM_POSTCAL_OFFSET 0x13c 161 + #define QSERDES_V5_5NM_RX_RX_SUMMER_CAL_SPD_MODE 0x140 162 + #define QSERDES_V5_5NM_RX_RX_HIGHZ_PARRATE 0x144 163 + #define QSERDES_V5_5NM_RX_RX_TERM_AC_BYPASS_DC_COUPLE_OFFSET 0x148 164 + #define QSERDES_V5_5NM_RX_DFE_1 0x14c 165 + #define QSERDES_V5_5NM_RX_DFE_2 0x150 166 + #define QSERDES_V5_5NM_RX_DFE_3 0x154 167 + #define QSERDES_V5_5NM_RX_DFE_4 0x158 168 + #define QSERDES_V5_5NM_RX_DFE_TAP3_CTRL 0x15c 169 + #define QSERDES_V5_5NM_RX_DFE_TAP3_MANVAL_KTAP 0x160 170 + #define QSERDES_V5_5NM_RX_DFE_TAP4_CTRL 0x164 171 + #define QSERDES_V5_5NM_RX_DFE_TAP4_MANVAL_KTAP 0x168 172 + #define QSERDES_V5_5NM_RX_DFE_TAP5_CTRL 0x16c 173 + #define QSERDES_V5_5NM_RX_DFE_TAP5_MANVAL_KTAP 0x170 174 + #define QSERDES_V5_5NM_RX_TX_ADPT_CTRL 0x174 175 + #define QSERDES_V5_5NM_RX_DFE_DAC_ENABLE1 0x178 176 + #define QSERDES_V5_5NM_RX_DFE_DAC_ENABLE2 0x17c 177 + #define QSERDES_V5_5NM_RX_TX_ADAPT_PRE_THRESH1 0x180 178 + #define QSERDES_V5_5NM_RX_TX_ADAPT_PRE_THRESH2 0x184 179 + #define QSERDES_V5_5NM_RX_TX_ADAPT_POST_THRESH1 0x188 180 + #define QSERDES_V5_5NM_RX_TX_ADAPT_POST_THRESH2 0x18c 181 + #define QSERDES_V5_5NM_RX_TX_ADAPT_MAIN_THRESH1 0x190 182 + #define QSERDES_V5_5NM_RX_TX_ADAPT_MAIN_THRESH2 0x194 183 + #define QSERDES_V5_5NM_RX_VGA_CAL_CNTRL1 0x198 184 + #define QSERDES_V5_5NM_RX_VGA_CAL_CNTRL2 0x19c 185 + #define QSERDES_V5_5NM_RX_VGA_CAL_MAN_VAL 0x1a0 186 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_CNTRL1 0x1a4 187 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_CNTRL2 0x1a8 188 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_MAN_VAL_RATE0 0x1ac 189 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_MAN_VAL_RATE1 0x1b0 190 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_MAN_VAL_RATE2 0x1b4 191 + #define QSERDES_V5_5NM_RX_VTHRESH_CAL_MAN_VAL_RATE3 0x1b8 192 + #define QSERDES_V5_5NM_RX_GM_CAL 0x1bc 193 + #define QSERDES_V5_5NM_RX_RX_VGA_GAIN2_BLK1 0x1c0 194 + #define QSERDES_V5_5NM_RX_RX_VGA_GAIN2_BLK2 0x1c4 195 + #define QSERDES_V5_5NM_RX_RX_EQU_ADAPTOR_CNTRL2 0x1c8 196 + #define QSERDES_V5_5NM_RX_RX_EQU_ADAPTOR_CNTRL3 0x1cc 197 + #define QSERDES_V5_5NM_RX_RX_EQU_ADAPTOR_CNTRL4 0x1d0 198 + #define QSERDES_V5_5NM_RX_RX_IDAC_TSETTLE_LOW 0x1d4 199 + #define QSERDES_V5_5NM_RX_RX_EQ_OFFSET_LSB 0x1d8 200 + #define QSERDES_V5_5NM_RX_RX_EQ_OFFSET_MSB 0x1dc 201 + #define QSERDES_V5_5NM_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 0x1e0 202 + #define QSERDES_V5_5NM_RX_RX_OFFSET_ADAPTOR_CNTRL2 0x1e4 203 + #define QSERDES_V5_5NM_RX_SIGDET_ENABLES 0x1e8 204 + #define QSERDES_V5_5NM_RX_SIGDET_CNTRL 0x1ec 205 + #define QSERDES_V5_5NM_RX_SIGDET_LVL 0x1f0 206 + #define QSERDES_V5_5NM_RX_SIGDET_DEGLITCH_CNTRL 0x1f4 207 + #define QSERDES_V5_5NM_RX_CDR_FREEZE_UP_DN 0x1f8 208 + #define QSERDES_V5_5NM_RX_CDR_RESET_OVERRIDE 0x1fc 209 + #define QSERDES_V5_5NM_RX_RX_INTERFACE_MODE 0x200 210 + #define QSERDES_V5_5NM_RX_JITTER_GEN_MODE 0x204 211 + #define QSERDES_V5_5NM_RX_SJ_AMP1 0x208 212 + #define QSERDES_V5_5NM_RX_SJ_AMP2 0x20c 213 + #define QSERDES_V5_5NM_RX_SJ_PER1 0x210 214 + #define QSERDES_V5_5NM_RX_SJ_PER2 0x214 215 + #define QSERDES_V5_5NM_RX_PPM_OFFSET1 0x218 216 + #define QSERDES_V5_5NM_RX_PPM_OFFSET2 0x21c 217 + #define QSERDES_V5_5NM_RX_SIGN_PPM_PERIOD1 0x220 218 + #define QSERDES_V5_5NM_RX_SIGN_PPM_PERIOD2 0x224 219 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B0 0x228 220 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B1 0x22c 221 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B2 0x230 222 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B3 0x234 223 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B4 0x238 224 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B5 0x23c 225 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B6 0x240 226 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE_0_1_B7 0x244 227 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B0 0x248 228 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B1 0x24c 229 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B2 0x250 230 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B3 0x254 231 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B4 0x258 232 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B5 0x25c 233 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B6 0x260 234 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE2_B7 0x264 235 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B0 0x268 236 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B1 0x26c 237 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B2 0x270 238 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B3 0x274 239 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B4 0x278 240 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B5 0x27c 241 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B6 0x280 242 + #define QSERDES_V5_5NM_RX_RX_MODE_RATE3_B7 0x284 243 + #define QSERDES_V5_5NM_RX_PHPRE_CTRL 0x288 244 + #define QSERDES_V5_5NM_RX_PHPRE_INITVAL 0x28c 245 + #define QSERDES_V5_5NM_RX_DFE_EN_TIMER 0x290 246 + #define QSERDES_V5_5NM_RX_DFE_CTLE_POST_CAL_OFFSET 0x294 247 + #define QSERDES_V5_5NM_RX_DCC_CTRL1 0x298 248 + #define QSERDES_V5_5NM_RX_DCC_CTRL2 0x29c 249 + #define QSERDES_V5_5NM_RX_DCC_OFFSET 0x2a0 250 + #define QSERDES_V5_5NM_RX_DCC_CMUX_POSTCAL_OFFSET 0x2a4 251 + #define QSERDES_V5_5NM_RX_DCC_CMUX_CAL_CTRL1 0x2a8 252 + #define QSERDES_V5_5NM_RX_DCC_CMUX_CAL_CTRL2 0x2ac 253 + #define QSERDES_V5_5NM_RX_ALOG_OBSV_BUS_CTRL_1 0x2b0 254 + #define QSERDES_V5_5NM_RX_RX_MARG_CTRL1 0x2b4 255 + #define QSERDES_V5_5NM_RX_RX_MARG_CTRL2 0x2b8 256 + #define QSERDES_V5_5NM_RX_RX_MARG_CTRL3 0x2bc 257 + #define QSERDES_V5_5NM_RX_RX_MARG_CTRL_4 0x2c0 258 + #define QSERDES_V5_5NM_RX_RX_MARG_CFG_RATE_0_1 0x2c4 259 + #define QSERDES_V5_5NM_RX_RX_MARG_CFG_RATE_2_3 0x2c8 260 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_CTRL1 0x2cc 261 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_CTRL2 0x2d0 262 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH1_RATE210 0x2d4 263 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH1_RATE3 0x2d8 264 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH2_RATE210 0x2dc 265 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH2_RATE3 0x2e0 266 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH3_RATE210 0x2e4 267 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH3_RATE3 0x2e8 268 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH4_RATE210 0x2ec 269 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH4_RATE3 0x2f0 270 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH5_RATE210 0x2f4 271 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH5_RATE3 0x2f8 272 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH6_RATE210 0x2fc 273 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH6_RATE3 0x300 274 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH7_RATE210 0x304 275 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_THRESH7_RATE3 0x308 276 + #define QSERDES_V5_5NM_RX_Q_PI_INTRINSIC_BIAS_RATE10 0x30c 277 + #define QSERDES_V5_5NM_RX_Q_PI_INTRINSIC_BIAS_RATE32 0x310 278 + #define QSERDES_V5_5NM_RX_RX_MARG_VERTICAL_CTRL 0x314 279 + #define QSERDES_V5_5NM_RX_RX_MARG_VERTICAL_CODE 0x318 280 + #define QSERDES_V5_5NM_RX_RES_CODE_THRESH_HIGH_AND_BYP 0x31c 281 + #define QSERDES_V5_5NM_RX_RES_CODE_THRESH_LOW 0x320 282 + #define QSERDES_V5_5NM_RX_RX_BKUP_CTRL1 0x324 283 + #define QSERDES_V5_5NM_RX_RX_BKUP_CTRL2 0x328 284 + #define QSERDES_V5_5NM_RX_RX_BKUP_CTRL3 0x32c 285 + #define QSERDES_V5_5NM_RX_PI_CTRL1 0x330 286 + #define QSERDES_V5_5NM_RX_PI_CTRL2 0x334 287 + #define QSERDES_V5_5NM_RX_PI_QUAD 0x338 288 + #define QSERDES_V5_5NM_RX_QPI_CTRL1 0x33c 289 + #define QSERDES_V5_5NM_RX_QPI_CTRL2 0x340 290 + #define QSERDES_V5_5NM_RX_QPI_QUAD 0x344 291 + #define QSERDES_V5_5NM_RX_IDATA1 0x348 292 + #define QSERDES_V5_5NM_RX_IDATA2 0x34c 293 + #define QSERDES_V5_5NM_RX_IDATA3 0x350 294 + #define QSERDES_V5_5NM_RX_AC_JTAG_OUTP 0x354 295 + #define QSERDES_V5_5NM_RX_AC_JTAG_OUTN 0x358 296 + #define QSERDES_V5_5NM_RX_RX_SIGDET 0x35c 297 + #define QSERDES_V5_5NM_RX_ALOG_OBSV_BUS_STATUS_1 0x360 298 + #define QSERDES_V5_5NM_RX_READ_EQCODE 0x364 299 + #define QSERDES_V5_5NM_RX_READ_OFFSETCODE 0x368 300 + #define QSERDES_V5_5NM_RX_IA_ERROR_COUNTER_LOW 0x36c 301 + #define QSERDES_V5_5NM_RX_IA_ERROR_COUNTER_HIGH 0x370 302 + #define QSERDES_V5_5NM_RX_VGA_READ_CODE 0x374 303 + #define QSERDES_V5_5NM_RX_VTHRESH_READ_CODE 0x378 304 + #define QSERDES_V5_5NM_RX_DFE_TAP1_READ_CODE 0x37c 305 + #define QSERDES_V5_5NM_RX_DFE_TAP2_READ_CODE 0x380 306 + #define QSERDES_V5_5NM_RX_DFE_TAP3_READ_CODE 0x384 307 + #define QSERDES_V5_5NM_RX_DFE_TAP4_READ_CODE 0x388 308 + #define QSERDES_V5_5NM_RX_DFE_TAP5_READ_CODE 0x38c 309 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_I0 0x390 310 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_I0BAR 0x394 311 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_I1 0x398 312 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_I1BAR 0x39c 313 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_Q 0x3a0 314 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_QBAR 0x3a4 315 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_A 0x3a8 316 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_ABAR 0x3ac 317 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_SM_ON 0x3b0 318 + #define QSERDES_V5_5NM_RX_IDAC_STATUS_SIGNERROR 0x3b4 319 + #define QSERDES_V5_5NM_RX_IVCM_CAL_STATUS 0x3b8 320 + #define QSERDES_V5_5NM_RX_IVCM_CAL_DEBUG_STATUS 0x3bc 321 + #define QSERDES_V5_5NM_RX_DCC_CAL_STATUS 0x3c0 322 + #define QSERDES_V5_5NM_RX_DCC_READ_CODE_STATUS 0x3c4 323 + #define QSERDES_V5_5NM_RX_RX_MARG_DEBUG1_STATUS 0x3c8 324 + #define QSERDES_V5_5NM_RX_RX_MARG_DEBUG2_STATUS 0x3cc 325 + #define QSERDES_V5_5NM_RX_RX_MARG_READ_CODE_STATUS 0x3d0 326 + #define QSERDES_V5_5NM_RX_EOM_ERR_CNT_LSB_STATUS 0x3d4 327 + #define QSERDES_V5_5NM_RX_EOM_ERR_CNT_MSB_STATUS 0x3d8 328 + #define QSERDES_V5_5NM_RX_RX_MARG_COARSE_TUNE_STATUS 0x3dc 329 + #define QSERDES_V5_5NM_RX_RX_BKUP_READ_BUS1_STATUS 0x3e0 330 + #define QSERDES_V5_5NM_RX_RX_BKUP_READ_BUS2_STATUS 0x3e4 331 + #define QSERDES_V5_5NM_RX_RX_BKUP_READ_BUS3_STATUS 0x3e8 332 + 333 + #endif
+75 -193
drivers/phy/qualcomm/phy-qcom-qmp-ufs.c
··· 28 28 #define SW_RESET BIT(0) 29 29 /* QPHY_POWER_DOWN_CONTROL */ 30 30 #define SW_PWRDN BIT(0) 31 - #define REFCLK_DRV_DSBL BIT(1) 32 31 /* QPHY_START_CONTROL bits */ 33 32 #define SERDES_START BIT(0) 34 33 #define PCS_START BIT(1) 35 - #define PLL_READY_GATE_EN BIT(3) 36 34 /* QPHY_PCS_STATUS bit */ 37 35 #define PHYSTATUS BIT(6) 38 - #define PHYSTATUS_4_20 BIT(7) 39 - /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 36 + /* QPHY_PCS_READY_STATUS bit */ 40 37 #define PCS_READY BIT(0) 41 38 42 - /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 43 - /* DP PHY soft reset */ 44 - #define SW_DPPHY_RESET BIT(0) 45 - /* mux to select DP PHY reset control, 0:HW control, 1: software reset */ 46 - #define SW_DPPHY_RESET_MUX BIT(1) 47 - /* USB3 PHY soft reset */ 48 - #define SW_USB3PHY_RESET BIT(2) 49 - /* mux to select USB3 PHY reset control, 0:HW control, 1: software reset */ 50 - #define SW_USB3PHY_RESET_MUX BIT(3) 51 - 52 - /* QPHY_V3_DP_COM_PHY_MODE_CTRL register bits */ 53 - #define USB3_MODE BIT(0) /* enables USB3 mode */ 54 - #define DP_MODE BIT(1) /* enables DP mode */ 55 - 56 - /* QPHY_PCS_AUTONOMOUS_MODE_CTRL register bits */ 57 - #define ARCVR_DTCT_EN BIT(0) 58 - #define ALFPS_DTCT_EN BIT(1) 59 - #define ARCVR_DTCT_EVENT_SEL BIT(4) 60 - 61 - /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ 62 - #define IRQ_CLEAR BIT(0) 63 - 64 - /* QPHY_PCS_LFPS_RXTERM_IRQ_STATUS register bits */ 65 - #define RCVR_DETECT BIT(0) 66 - 67 - /* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ 68 - #define CLAMP_EN BIT(0) /* enables i/o clamp_n */ 69 - 70 39 #define PHY_INIT_COMPLETE_TIMEOUT 10000 71 - #define POWER_DOWN_DELAY_US_MIN 10 72 - #define POWER_DOWN_DELAY_US_MAX 11 73 - 74 - #define MAX_PROP_NAME 32 75 - 76 - /* Define the assumed distance between lanes for underspecified device trees. */ 77 - #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 78 40 79 41 struct qmp_phy_init_tbl { 80 42 unsigned int offset; ··· 77 115 78 116 /* set of registers with offsets different per-PHY */ 79 117 enum qphy_reg_layout { 80 - /* Common block control registers */ 81 - QPHY_COM_SW_RESET, 82 - QPHY_COM_POWER_DOWN_CONTROL, 83 - QPHY_COM_START_CONTROL, 84 - QPHY_COM_PCS_READY_STATUS, 85 118 /* PCS registers */ 86 119 QPHY_SW_RESET, 87 120 QPHY_START_CTRL, 88 121 QPHY_PCS_READY_STATUS, 89 - QPHY_PCS_STATUS, 90 - QPHY_PCS_AUTONOMOUS_MODE_CTRL, 91 - QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, 92 - QPHY_PCS_LFPS_RXTERM_IRQ_STATUS, 93 122 QPHY_PCS_POWER_DOWN_CONTROL, 94 - /* PCS_MISC registers */ 95 - QPHY_PCS_MISC_TYPEC_CTRL, 96 123 /* Keep last to ensure regs_layout arrays are properly initialized */ 97 124 QPHY_LAYOUT_SIZE 98 125 }; ··· 531 580 QMP_PHY_INIT_CFG(QPHY_V5_PCS_UFS_MULTI_LANE_CTRL1, 0x02), 532 581 }; 533 582 534 - struct qmp_phy; 535 - 536 583 /* struct qmp_phy_cfg - per-PHY initialization config */ 537 584 struct qmp_phy_cfg { 538 - /* phy-type - PCIE/UFS/USB */ 539 - unsigned int type; 540 - /* number of lanes provided by phy */ 541 - int nlanes; 585 + int lanes; 542 586 543 587 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 544 588 const struct qmp_phy_init_tbl *serdes_tbl; ··· 560 614 /* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ 561 615 unsigned int phy_status; 562 616 563 - /* true, if PHY has secondary tx/rx lanes to be configured */ 564 - bool is_dual_lane_phy; 565 - 566 617 /* true, if PCS block has no separate SW_RESET register */ 567 618 bool no_pcs_sw_reset; 568 619 }; ··· 576 633 * @tx2: iomapped memory space for second lane's tx (in dual lane PHYs) 577 634 * @rx2: iomapped memory space for second lane's rx (in dual lane PHYs) 578 635 * @pcs_misc: iomapped memory space for lane's pcs_misc 579 - * @index: lane index 580 636 * @qmp: QMP phy to which this lane belongs 581 - * @mode: current PHY mode 582 637 */ 583 638 struct qmp_phy { 584 639 struct phy *phy; ··· 588 647 void __iomem *tx2; 589 648 void __iomem *rx2; 590 649 void __iomem *pcs_misc; 591 - unsigned int index; 592 650 struct qcom_qmp *qmp; 593 - enum phy_mode mode; 594 651 }; 595 652 596 653 /** ··· 658 719 }; 659 720 660 721 static const struct qmp_phy_cfg msm8996_ufs_cfg = { 661 - .type = PHY_TYPE_UFS, 662 - .nlanes = 1, 722 + .lanes = 1, 663 723 664 724 .serdes_tbl = msm8996_ufs_serdes_tbl, 665 725 .serdes_tbl_num = ARRAY_SIZE(msm8996_ufs_serdes_tbl), ··· 683 745 }; 684 746 685 747 static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { 686 - .type = PHY_TYPE_UFS, 687 - .nlanes = 2, 748 + .lanes = 2, 688 749 689 750 .serdes_tbl = sdm845_ufsphy_serdes_tbl, 690 751 .serdes_tbl_num = ARRAY_SIZE(sdm845_ufsphy_serdes_tbl), ··· 703 766 .pwrdn_ctrl = SW_PWRDN, 704 767 .phy_status = PHYSTATUS, 705 768 706 - .is_dual_lane_phy = true, 707 769 .no_pcs_sw_reset = true, 708 770 }; 709 771 710 772 static const struct qmp_phy_cfg sm6115_ufsphy_cfg = { 711 - .type = PHY_TYPE_UFS, 712 - .nlanes = 1, 773 + .lanes = 1, 713 774 714 775 .serdes_tbl = sm6115_ufsphy_serdes_tbl, 715 776 .serdes_tbl_num = ARRAY_SIZE(sm6115_ufsphy_serdes_tbl), ··· 730 795 }; 731 796 732 797 static const struct qmp_phy_cfg sm8150_ufsphy_cfg = { 733 - .type = PHY_TYPE_UFS, 734 - .nlanes = 2, 798 + .lanes = 2, 735 799 736 800 .serdes_tbl = sm8150_ufsphy_serdes_tbl, 737 801 .serdes_tbl_num = ARRAY_SIZE(sm8150_ufsphy_serdes_tbl), ··· 749 815 .start_ctrl = SERDES_START, 750 816 .pwrdn_ctrl = SW_PWRDN, 751 817 .phy_status = PHYSTATUS, 752 - 753 - .is_dual_lane_phy = true, 754 818 }; 755 819 756 820 static const struct qmp_phy_cfg sm8350_ufsphy_cfg = { 757 - .type = PHY_TYPE_UFS, 758 - .nlanes = 2, 821 + .lanes = 2, 759 822 760 823 .serdes_tbl = sm8350_ufsphy_serdes_tbl, 761 824 .serdes_tbl_num = ARRAY_SIZE(sm8350_ufsphy_serdes_tbl), ··· 771 840 .start_ctrl = SERDES_START, 772 841 .pwrdn_ctrl = SW_PWRDN, 773 842 .phy_status = PHYSTATUS, 774 - 775 - .is_dual_lane_phy = true, 776 843 }; 777 844 778 845 static const struct qmp_phy_cfg sm8450_ufsphy_cfg = { 779 - .type = PHY_TYPE_UFS, 780 - .nlanes = 2, 846 + .lanes = 2, 781 847 782 848 .serdes_tbl = sm8350_ufsphy_serdes_tbl, 783 849 .serdes_tbl_num = ARRAY_SIZE(sm8350_ufsphy_serdes_tbl), ··· 793 865 .start_ctrl = SERDES_START, 794 866 .pwrdn_ctrl = SW_PWRDN, 795 867 .phy_status = PHYSTATUS, 796 - 797 - .is_dual_lane_phy = true, 798 868 }; 799 869 800 - static void qcom_qmp_phy_ufs_configure_lane(void __iomem *base, 870 + static void qmp_ufs_configure_lane(void __iomem *base, 801 871 const unsigned int *regs, 802 872 const struct qmp_phy_init_tbl tbl[], 803 873 int num, ··· 818 892 } 819 893 } 820 894 821 - static void qcom_qmp_phy_ufs_configure(void __iomem *base, 895 + static void qmp_ufs_configure(void __iomem *base, 822 896 const unsigned int *regs, 823 897 const struct qmp_phy_init_tbl tbl[], 824 898 int num) 825 899 { 826 - qcom_qmp_phy_ufs_configure_lane(base, regs, tbl, num, 0xff); 900 + qmp_ufs_configure_lane(base, regs, tbl, num, 0xff); 827 901 } 828 902 829 - static int qcom_qmp_phy_ufs_serdes_init(struct qmp_phy *qphy) 903 + static int qmp_ufs_serdes_init(struct qmp_phy *qphy) 830 904 { 831 905 const struct qmp_phy_cfg *cfg = qphy->cfg; 832 906 void __iomem *serdes = qphy->serdes; 833 907 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 834 908 int serdes_tbl_num = cfg->serdes_tbl_num; 835 909 836 - qcom_qmp_phy_ufs_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 910 + qmp_ufs_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 837 911 838 912 return 0; 839 913 } 840 914 841 - static int qcom_qmp_phy_ufs_com_init(struct qmp_phy *qphy) 915 + static int qmp_ufs_com_init(struct qmp_phy *qphy) 842 916 { 843 917 struct qcom_qmp *qmp = qphy->qmp; 844 918 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 872 946 return ret; 873 947 } 874 948 875 - static int qcom_qmp_phy_ufs_com_exit(struct qmp_phy *qphy) 949 + static int qmp_ufs_com_exit(struct qmp_phy *qphy) 876 950 { 877 951 struct qcom_qmp *qmp = qphy->qmp; 878 952 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 886 960 return 0; 887 961 } 888 962 889 - static int qcom_qmp_phy_ufs_init(struct phy *phy) 963 + static int qmp_ufs_init(struct phy *phy) 890 964 { 891 965 struct qmp_phy *qphy = phy_get_drvdata(phy); 892 966 struct qcom_qmp *qmp = qphy->qmp; ··· 921 995 return ret; 922 996 } 923 997 924 - ret = qcom_qmp_phy_ufs_com_init(qphy); 998 + ret = qmp_ufs_com_init(qphy); 925 999 if (ret) 926 1000 return ret; 927 1001 928 1002 return 0; 929 1003 } 930 1004 931 - static int qcom_qmp_phy_ufs_power_on(struct phy *phy) 1005 + static int qmp_ufs_power_on(struct phy *phy) 932 1006 { 933 1007 struct qmp_phy *qphy = phy_get_drvdata(phy); 934 1008 struct qcom_qmp *qmp = qphy->qmp; ··· 940 1014 unsigned int mask, val, ready; 941 1015 int ret; 942 1016 943 - qcom_qmp_phy_ufs_serdes_init(qphy); 1017 + qmp_ufs_serdes_init(qphy); 944 1018 945 1019 /* Tx, Rx, and PCS configurations */ 946 - qcom_qmp_phy_ufs_configure_lane(tx, cfg->regs, 947 - cfg->tx_tbl, cfg->tx_tbl_num, 1); 1020 + qmp_ufs_configure_lane(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num, 1); 948 1021 949 - /* Configuration for other LANE for USB-DP combo PHY */ 950 - if (cfg->is_dual_lane_phy) { 951 - qcom_qmp_phy_ufs_configure_lane(qphy->tx2, cfg->regs, 952 - cfg->tx_tbl, cfg->tx_tbl_num, 2); 1022 + if (cfg->lanes >= 2) { 1023 + qmp_ufs_configure_lane(qphy->tx2, cfg->regs, 1024 + cfg->tx_tbl, cfg->tx_tbl_num, 2); 953 1025 } 954 1026 955 - qcom_qmp_phy_ufs_configure_lane(rx, cfg->regs, 956 - cfg->rx_tbl, cfg->rx_tbl_num, 1); 1027 + qmp_ufs_configure_lane(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num, 1); 957 1028 958 - if (cfg->is_dual_lane_phy) { 959 - qcom_qmp_phy_ufs_configure_lane(qphy->rx2, cfg->regs, 960 - cfg->rx_tbl, cfg->rx_tbl_num, 2); 1029 + if (cfg->lanes >= 2) { 1030 + qmp_ufs_configure_lane(qphy->rx2, cfg->regs, 1031 + cfg->rx_tbl, cfg->rx_tbl_num, 2); 961 1032 } 962 1033 963 - qcom_qmp_phy_ufs_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 1034 + qmp_ufs_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 964 1035 965 1036 ret = reset_control_deassert(qmp->ufs_reset); 966 1037 if (ret) ··· 983 1060 return 0; 984 1061 } 985 1062 986 - static int qcom_qmp_phy_ufs_power_off(struct phy *phy) 1063 + static int qmp_ufs_power_off(struct phy *phy) 987 1064 { 988 1065 struct qmp_phy *qphy = phy_get_drvdata(phy); 989 1066 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 1007 1084 return 0; 1008 1085 } 1009 1086 1010 - static int qcom_qmp_phy_ufs_exit(struct phy *phy) 1087 + static int qmp_ufs_exit(struct phy *phy) 1011 1088 { 1012 1089 struct qmp_phy *qphy = phy_get_drvdata(phy); 1013 1090 1014 - qcom_qmp_phy_ufs_com_exit(qphy); 1091 + qmp_ufs_com_exit(qphy); 1015 1092 1016 1093 return 0; 1017 1094 } 1018 1095 1019 - static int qcom_qmp_phy_ufs_enable(struct phy *phy) 1096 + static int qmp_ufs_enable(struct phy *phy) 1020 1097 { 1021 1098 int ret; 1022 1099 1023 - ret = qcom_qmp_phy_ufs_init(phy); 1100 + ret = qmp_ufs_init(phy); 1024 1101 if (ret) 1025 1102 return ret; 1026 1103 1027 - ret = qcom_qmp_phy_ufs_power_on(phy); 1104 + ret = qmp_ufs_power_on(phy); 1028 1105 if (ret) 1029 - qcom_qmp_phy_ufs_exit(phy); 1106 + qmp_ufs_exit(phy); 1030 1107 1031 1108 return ret; 1032 1109 } 1033 1110 1034 - static int qcom_qmp_phy_ufs_disable(struct phy *phy) 1111 + static int qmp_ufs_disable(struct phy *phy) 1035 1112 { 1036 1113 int ret; 1037 1114 1038 - ret = qcom_qmp_phy_ufs_power_off(phy); 1115 + ret = qmp_ufs_power_off(phy); 1039 1116 if (ret) 1040 1117 return ret; 1041 - return qcom_qmp_phy_ufs_exit(phy); 1118 + return qmp_ufs_exit(phy); 1042 1119 } 1043 1120 1044 - static int qcom_qmp_phy_ufs_set_mode(struct phy *phy, 1045 - enum phy_mode mode, int submode) 1046 - { 1047 - struct qmp_phy *qphy = phy_get_drvdata(phy); 1048 - 1049 - qphy->mode = mode; 1050 - 1051 - return 0; 1052 - } 1053 - 1054 - static int qcom_qmp_phy_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 1121 + static int qmp_ufs_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 1055 1122 { 1056 1123 struct qcom_qmp *qmp = dev_get_drvdata(dev); 1057 1124 int num = cfg->num_vregs; ··· 1057 1144 return devm_regulator_bulk_get(dev, num, qmp->vregs); 1058 1145 } 1059 1146 1060 - static int qcom_qmp_phy_ufs_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 1147 + static int qmp_ufs_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 1061 1148 { 1062 1149 struct qcom_qmp *qmp = dev_get_drvdata(dev); 1063 1150 int num = cfg->num_clks; ··· 1074 1161 } 1075 1162 1076 1163 static const struct phy_ops qcom_qmp_ufs_ops = { 1077 - .power_on = qcom_qmp_phy_ufs_enable, 1078 - .power_off = qcom_qmp_phy_ufs_disable, 1079 - .set_mode = qcom_qmp_phy_ufs_set_mode, 1164 + .power_on = qmp_ufs_enable, 1165 + .power_off = qmp_ufs_disable, 1080 1166 .owner = THIS_MODULE, 1081 1167 }; 1082 1168 1083 - static 1084 - int qcom_qmp_phy_ufs_create(struct device *dev, struct device_node *np, int id, 1169 + static int qmp_ufs_create(struct device *dev, struct device_node *np, int id, 1085 1170 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 1086 1171 { 1087 1172 struct qcom_qmp *qmp = dev_get_drvdata(dev); ··· 1099 1188 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 1100 1189 * For single lane PHYs: pcs_misc (optional) -> 3. 1101 1190 */ 1102 - qphy->tx = of_iomap(np, 0); 1103 - if (!qphy->tx) 1104 - return -ENOMEM; 1191 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 1192 + if (IS_ERR(qphy->tx)) 1193 + return PTR_ERR(qphy->tx); 1105 1194 1106 - qphy->rx = of_iomap(np, 1); 1107 - if (!qphy->rx) 1108 - return -ENOMEM; 1195 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 1196 + if (IS_ERR(qphy->rx)) 1197 + return PTR_ERR(qphy->rx); 1109 1198 1110 - qphy->pcs = of_iomap(np, 2); 1111 - if (!qphy->pcs) 1112 - return -ENOMEM; 1199 + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); 1200 + if (IS_ERR(qphy->pcs)) 1201 + return PTR_ERR(qphy->pcs); 1113 1202 1114 - /* 1115 - * If this is a dual-lane PHY, then there should be registers for the 1116 - * second lane. Some old device trees did not specify this, so fall 1117 - * back to old legacy behavior of assuming they can be reached at an 1118 - * offset from the first lane. 1119 - */ 1120 - if (cfg->is_dual_lane_phy) { 1121 - qphy->tx2 = of_iomap(np, 3); 1122 - qphy->rx2 = of_iomap(np, 4); 1123 - if (!qphy->tx2 || !qphy->rx2) { 1124 - dev_warn(dev, 1125 - "Underspecified device tree, falling back to legacy register regions\n"); 1203 + if (cfg->lanes >= 2) { 1204 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 1205 + if (IS_ERR(qphy->tx2)) 1206 + return PTR_ERR(qphy->tx2); 1126 1207 1127 - /* In the old version, pcs_misc is at index 3. */ 1128 - qphy->pcs_misc = qphy->tx2; 1129 - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 1130 - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 1208 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 1209 + if (IS_ERR(qphy->rx2)) 1210 + return PTR_ERR(qphy->rx2); 1131 1211 1132 - } else { 1133 - qphy->pcs_misc = of_iomap(np, 5); 1134 - } 1135 - 1212 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 1136 1213 } else { 1137 - qphy->pcs_misc = of_iomap(np, 3); 1214 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 1138 1215 } 1139 1216 1140 - if (!qphy->pcs_misc) 1217 + if (IS_ERR(qphy->pcs_misc)) 1141 1218 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 1142 1219 1143 1220 generic_phy = devm_phy_create(dev, np, &qcom_qmp_ufs_ops); ··· 1136 1237 } 1137 1238 1138 1239 qphy->phy = generic_phy; 1139 - qphy->index = id; 1140 1240 qphy->qmp = qmp; 1141 1241 qmp->phys[id] = qphy; 1142 1242 phy_set_drvdata(generic_phy, qphy); ··· 1143 1245 return 0; 1144 1246 } 1145 1247 1146 - static const struct of_device_id qcom_qmp_phy_ufs_of_match_table[] = { 1248 + static const struct of_device_id qmp_ufs_of_match_table[] = { 1147 1249 { 1148 1250 .compatible = "qcom,msm8996-qmp-ufs-phy", 1149 1251 .data = &msm8996_ufs_cfg, ··· 1180 1282 }, 1181 1283 { }, 1182 1284 }; 1183 - MODULE_DEVICE_TABLE(of, qcom_qmp_phy_ufs_of_match_table); 1285 + MODULE_DEVICE_TABLE(of, qmp_ufs_of_match_table); 1184 1286 1185 - static int qcom_qmp_phy_ufs_probe(struct platform_device *pdev) 1287 + static int qmp_ufs_probe(struct platform_device *pdev) 1186 1288 { 1187 1289 struct qcom_qmp *qmp; 1188 1290 struct device *dev = &pdev->dev; ··· 1210 1312 if (IS_ERR(serdes)) 1211 1313 return PTR_ERR(serdes); 1212 1314 1213 - ret = qcom_qmp_phy_ufs_clk_init(dev, cfg); 1315 + ret = qmp_ufs_clk_init(dev, cfg); 1214 1316 if (ret) 1215 1317 return ret; 1216 1318 1217 - ret = qcom_qmp_phy_ufs_vreg_init(dev, cfg); 1218 - if (ret) { 1219 - if (ret != -EPROBE_DEFER) 1220 - dev_err(dev, "failed to get regulator supplies: %d\n", 1221 - ret); 1222 - return ret; 1223 - } 1319 + ret = qmp_ufs_vreg_init(dev, cfg); 1320 + if (ret) 1321 + return dev_err_probe(dev, ret, 1322 + "failed to get regulator supplies\n"); 1224 1323 1225 1324 num = of_get_available_child_count(dev->of_node); 1226 1325 /* do we have a rogue child node ? */ ··· 1228 1333 if (!qmp->phys) 1229 1334 return -ENOMEM; 1230 1335 1231 - pm_runtime_set_active(dev); 1232 - pm_runtime_enable(dev); 1233 - /* 1234 - * Prevent runtime pm from being ON by default. Users can enable 1235 - * it using power/control in sysfs. 1236 - */ 1237 - pm_runtime_forbid(dev); 1238 - 1239 1336 id = 0; 1240 1337 for_each_available_child_of_node(dev->of_node, child) { 1241 1338 /* Create per-lane phy */ 1242 - ret = qcom_qmp_phy_ufs_create(dev, child, id, serdes, cfg); 1339 + ret = qmp_ufs_create(dev, child, id, serdes, cfg); 1243 1340 if (ret) { 1244 1341 dev_err(dev, "failed to create lane%d phy, %d\n", 1245 1342 id, ret); ··· 1242 1355 } 1243 1356 1244 1357 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 1245 - if (!IS_ERR(phy_provider)) 1246 - dev_info(dev, "Registered Qcom-QMP phy\n"); 1247 - else 1248 - pm_runtime_disable(dev); 1249 1358 1250 1359 return PTR_ERR_OR_ZERO(phy_provider); 1251 1360 1252 1361 err_node_put: 1253 - pm_runtime_disable(dev); 1254 1362 of_node_put(child); 1255 1363 return ret; 1256 1364 } 1257 1365 1258 - static struct platform_driver qcom_qmp_phy_ufs_driver = { 1259 - .probe = qcom_qmp_phy_ufs_probe, 1366 + static struct platform_driver qmp_ufs_driver = { 1367 + .probe = qmp_ufs_probe, 1260 1368 .driver = { 1261 1369 .name = "qcom-qmp-ufs-phy", 1262 - .of_match_table = qcom_qmp_phy_ufs_of_match_table, 1370 + .of_match_table = qmp_ufs_of_match_table, 1263 1371 }, 1264 1372 }; 1265 1373 1266 - module_platform_driver(qcom_qmp_phy_ufs_driver); 1374 + module_platform_driver(qmp_ufs_driver); 1267 1375 1268 1376 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 1269 1377 MODULE_DESCRIPTION("Qualcomm QMP UFS PHY driver");
+263 -203
drivers/phy/qualcomm/phy-qcom-qmp-usb.c
··· 28 28 #define SW_RESET BIT(0) 29 29 /* QPHY_POWER_DOWN_CONTROL */ 30 30 #define SW_PWRDN BIT(0) 31 - #define REFCLK_DRV_DSBL BIT(1) 32 31 /* QPHY_START_CONTROL bits */ 33 32 #define SERDES_START BIT(0) 34 33 #define PCS_START BIT(1) 35 - #define PLL_READY_GATE_EN BIT(3) 36 34 /* QPHY_PCS_STATUS bit */ 37 35 #define PHYSTATUS BIT(6) 38 - #define PHYSTATUS_4_20 BIT(7) 39 - /* QPHY_PCS_READY_STATUS & QPHY_COM_PCS_READY_STATUS bit */ 40 - #define PCS_READY BIT(0) 41 36 42 37 /* QPHY_V3_DP_COM_RESET_OVRD_CTRL register bits */ 43 38 /* DP PHY soft reset */ ··· 65 70 #define PHY_INIT_COMPLETE_TIMEOUT 10000 66 71 #define POWER_DOWN_DELAY_US_MIN 10 67 72 #define POWER_DOWN_DELAY_US_MAX 11 68 - 69 - #define MAX_PROP_NAME 32 70 - 71 - /* Define the assumed distance between lanes for underspecified device trees. */ 72 - #define QMP_PHY_LEGACY_LANE_STRIDE 0x400 73 73 74 74 struct qmp_phy_init_tbl { 75 75 unsigned int offset; ··· 105 115 106 116 /* set of registers with offsets different per-PHY */ 107 117 enum qphy_reg_layout { 108 - /* Common block control registers */ 109 - QPHY_COM_SW_RESET, 110 - QPHY_COM_POWER_DOWN_CONTROL, 111 - QPHY_COM_START_CONTROL, 112 - QPHY_COM_PCS_READY_STATUS, 113 118 /* PCS registers */ 114 119 QPHY_SW_RESET, 115 120 QPHY_START_CTRL, 116 - QPHY_PCS_READY_STATUS, 117 121 QPHY_PCS_STATUS, 118 122 QPHY_PCS_AUTONOMOUS_MODE_CTRL, 119 123 QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, ··· 1322 1338 QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x88), 1323 1339 }; 1324 1340 1325 - struct qmp_phy; 1341 + static const struct qmp_phy_init_tbl sc8280xp_usb3_uniphy_serdes_tbl[] = { 1342 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_EN_SEL, 0x1a), 1343 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_HSCLK_SEL, 0x11), 1344 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_HSCLK_SEL, 0x01), 1345 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE0, 0x82), 1346 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE0, 0xab), 1347 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE0, 0xea), 1348 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE0, 0x02), 1349 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE0, 0xca), 1350 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE0, 0x1e), 1351 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE0, 0x06), 1352 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE0, 0x16), 1353 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE0, 0x36), 1354 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE0, 0x24), 1355 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE0, 0x34), 1356 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE0, 0x14), 1357 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP_EN, 0x04), 1358 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SYSCLK_BUF_ENABLE, 0x0a), 1359 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE2_MODE1, 0x02), 1360 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE1_MODE1, 0x24), 1361 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CORECLK_DIV_MODE1, 0x08), 1362 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DEC_START_MODE1, 0x82), 1363 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START1_MODE1, 0xab), 1364 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START2_MODE1, 0xea), 1365 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_DIV_FRAC_START3_MODE1, 0x02), 1366 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP2_MODE1, 0x82), 1367 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_LOCK_CMP1_MODE1, 0x34), 1368 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_CP_CTRL_MODE1, 0x06), 1369 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_RCTRL_MODE1, 0x16), 1370 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_PLL_CCTRL_MODE1, 0x36), 1371 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE1_MODE1, 0xca), 1372 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_BIN_VCOCAL_CMP_CODE2_MODE1, 0x1e), 1373 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_EN_CENTER, 0x01), 1374 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER1, 0x31), 1375 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_PER2, 0x01), 1376 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE1, 0xde), 1377 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE1, 0x07), 1378 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE1_MODE0, 0xde), 1379 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_SSC_STEP_SIZE2_MODE0, 0x07), 1380 + QMP_PHY_INIT_CFG(QSERDES_V5_COM_VCO_TUNE_MAP, 0x02), 1381 + }; 1382 + 1383 + static const struct qmp_phy_init_tbl sc8280xp_usb3_uniphy_tx_tbl[] = { 1384 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_1, 0xa5), 1385 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_2, 0x82), 1386 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_3, 0x3f), 1387 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_LANE_MODE_4, 0x3f), 1388 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_PI_QEC_CTRL, 0x21), 1389 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_TX, 0x10), 1390 + QMP_PHY_INIT_CFG(QSERDES_V5_TX_RES_CODE_LANE_OFFSET_RX, 0x0e), 1391 + }; 1392 + 1393 + static const struct qmp_phy_init_tbl sc8280xp_usb3_uniphy_rx_tbl[] = { 1394 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH4, 0xdc), 1395 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH3, 0xbd), 1396 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH2, 0xff), 1397 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_HIGH, 0x7f), 1398 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_00_LOW, 0xff), 1399 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH4, 0xa9), 1400 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH3, 0x7b), 1401 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH2, 0xe4), 1402 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_HIGH, 0x24), 1403 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_MODE_01_LOW, 0x64), 1404 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_PI_CONTROLS, 0x99), 1405 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH1, 0x08), 1406 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_THRESH2, 0x08), 1407 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_GAIN1, 0x00), 1408 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SB2_GAIN2, 0x04), 1409 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_FO_GAIN, 0x2f), 1410 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_COUNT_LOW, 0xff), 1411 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_FASTLOCK_COUNT_HIGH, 0x0f), 1412 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x0a), 1413 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL1, 0x54), 1414 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_VGA_CAL_CNTRL2, 0x0f), 1415 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0f), 1416 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQU_ADAPTOR_CNTRL4, 0x0a), 1417 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x47), 1418 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80), 1419 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_SIGDET_CNTRL, 0x04), 1420 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_SIGDET_DEGLITCH_CNTRL, 0x0e), 1421 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_DFE_CTLE_POST_CAL_OFFSET, 0x38), 1422 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_UCDR_SO_GAIN, 0x05), 1423 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_GM_CAL, 0x00), 1424 + QMP_PHY_INIT_CFG(QSERDES_V5_RX_SIGDET_ENABLES, 0x00), 1425 + }; 1426 + 1427 + static const struct qmp_phy_init_tbl sc8280xp_usb3_uniphy_pcs_tbl[] = { 1428 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG1, 0xd0), 1429 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG2, 0x07), 1430 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG3, 0x20), 1431 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_LOCK_DETECT_CONFIG6, 0x13), 1432 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_L, 0xe7), 1433 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RCVR_DTCT_DLY_P1U2_H, 0x03), 1434 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_RX_SIGDET_LVL, 0xaa), 1435 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_PCS_TX_RX_CONFIG, 0x0c), 1436 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_RXEQTRAINING_DFE_TIME_S2, 0x07), 1437 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_USB3_LFPS_DET_HIGH_COUNT_VAL, 0xf8), 1438 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_CDR_RESET_TIME, 0x0a), 1439 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG1, 0x88), 1440 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_ALIGN_DETECT_CONFIG2, 0x13), 1441 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG1, 0x4b), 1442 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_EQ_CONFIG5, 0x10), 1443 + QMP_PHY_INIT_CFG(QPHY_V5_PCS_REFGEN_REQ_CONFIG1, 0x21), 1444 + }; 1326 1445 1327 1446 /* struct qmp_phy_cfg - per-PHY initialization config */ 1328 1447 struct qmp_phy_cfg { 1329 - /* phy-type - PCIE/UFS/USB */ 1330 - unsigned int type; 1331 - /* number of lanes provided by phy */ 1332 - int nlanes; 1448 + int lanes; 1333 1449 1334 1450 /* Init sequence for PHY blocks - serdes, tx, rx, pcs */ 1335 1451 const struct qmp_phy_init_tbl *serdes_tbl; ··· 1469 1385 1470 1386 /* true, if PHY has a separate DP_COM control block */ 1471 1387 bool has_phy_dp_com_ctrl; 1472 - /* true, if PHY has secondary tx/rx lanes to be configured */ 1473 - bool is_dual_lane_phy; 1474 1388 1475 1389 /* Offset from PCS to PCS_USB region */ 1476 1390 unsigned int pcs_usb_offset; ··· 1488 1406 * @pcs_misc: iomapped memory space for lane's pcs_misc 1489 1407 * @pcs_usb: iomapped memory space for lane's pcs_usb 1490 1408 * @pipe_clk: pipe clock 1491 - * @index: lane index 1492 1409 * @qmp: QMP phy to which this lane belongs 1493 1410 * @mode: current PHY mode 1494 1411 */ ··· 1503 1422 void __iomem *pcs_misc; 1504 1423 void __iomem *pcs_usb; 1505 1424 struct clk *pipe_clk; 1506 - unsigned int index; 1507 1425 struct qcom_qmp *qmp; 1508 1426 enum phy_mode mode; 1509 1427 }; ··· 1600 1520 }; 1601 1521 1602 1522 static const struct qmp_phy_cfg ipq8074_usb3phy_cfg = { 1603 - .type = PHY_TYPE_USB3, 1604 - .nlanes = 1, 1523 + .lanes = 1, 1605 1524 1606 1525 .serdes_tbl = ipq8074_usb3_serdes_tbl, 1607 1526 .serdes_tbl_num = ARRAY_SIZE(ipq8074_usb3_serdes_tbl), ··· 1624 1545 }; 1625 1546 1626 1547 static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { 1627 - .type = PHY_TYPE_USB3, 1628 - .nlanes = 1, 1548 + .lanes = 1, 1629 1549 1630 1550 .serdes_tbl = msm8996_usb3_serdes_tbl, 1631 1551 .serdes_tbl_num = ARRAY_SIZE(msm8996_usb3_serdes_tbl), ··· 1648 1570 }; 1649 1571 1650 1572 static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { 1651 - .type = PHY_TYPE_USB3, 1652 - .nlanes = 1, 1573 + .lanes = 2, 1653 1574 1654 1575 .serdes_tbl = qmp_v3_usb3_serdes_tbl, 1655 1576 .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), ··· 1675 1598 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1676 1599 1677 1600 .has_phy_dp_com_ctrl = true, 1678 - .is_dual_lane_phy = true, 1679 1601 }; 1680 1602 1681 1603 static const struct qmp_phy_cfg sc7180_usb3phy_cfg = { 1682 - .type = PHY_TYPE_USB3, 1683 - .nlanes = 1, 1604 + .lanes = 2, 1684 1605 1685 1606 .serdes_tbl = qmp_v3_usb3_serdes_tbl, 1686 1607 .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_serdes_tbl), ··· 1705 1630 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1706 1631 1707 1632 .has_phy_dp_com_ctrl = true, 1708 - .is_dual_lane_phy = true, 1633 + }; 1634 + 1635 + static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = { 1636 + .lanes = 1, 1637 + 1638 + .serdes_tbl = sc8280xp_usb3_uniphy_serdes_tbl, 1639 + .serdes_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_serdes_tbl), 1640 + .tx_tbl = sc8280xp_usb3_uniphy_tx_tbl, 1641 + .tx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_tx_tbl), 1642 + .rx_tbl = sc8280xp_usb3_uniphy_rx_tbl, 1643 + .rx_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_rx_tbl), 1644 + .pcs_tbl = sc8280xp_usb3_uniphy_pcs_tbl, 1645 + .pcs_tbl_num = ARRAY_SIZE(sc8280xp_usb3_uniphy_pcs_tbl), 1646 + .clk_list = qmp_v4_phy_clk_l, 1647 + .num_clks = ARRAY_SIZE(qmp_v4_phy_clk_l), 1648 + .reset_list = msm8996_usb3phy_reset_l, 1649 + .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), 1650 + .vreg_list = qmp_phy_vreg_l, 1651 + .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), 1652 + .regs = qmp_v4_usb3phy_regs_layout, 1653 + 1654 + .start_ctrl = SERDES_START | PCS_START, 1655 + .pwrdn_ctrl = SW_PWRDN, 1656 + .phy_status = PHYSTATUS, 1657 + 1658 + .has_pwrdn_delay = true, 1659 + .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, 1660 + .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1709 1661 }; 1710 1662 1711 1663 static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { 1712 - .type = PHY_TYPE_USB3, 1713 - .nlanes = 1, 1664 + .lanes = 1, 1714 1665 1715 1666 .serdes_tbl = qmp_v3_usb3_uniphy_serdes_tbl, 1716 1667 .serdes_tbl_num = ARRAY_SIZE(qmp_v3_usb3_uniphy_serdes_tbl), ··· 1764 1663 }; 1765 1664 1766 1665 static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { 1767 - .type = PHY_TYPE_USB3, 1768 - .nlanes = 1, 1666 + .lanes = 2, 1769 1667 1770 1668 .serdes_tbl = msm8998_usb3_serdes_tbl, 1771 1669 .serdes_tbl_num = ARRAY_SIZE(msm8998_usb3_serdes_tbl), ··· 1785 1685 .start_ctrl = SERDES_START | PCS_START, 1786 1686 .pwrdn_ctrl = SW_PWRDN, 1787 1687 .phy_status = PHYSTATUS, 1788 - 1789 - .is_dual_lane_phy = true, 1790 1688 }; 1791 1689 1792 1690 static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { 1793 - .type = PHY_TYPE_USB3, 1794 - .nlanes = 1, 1691 + .lanes = 2, 1795 1692 1796 1693 .serdes_tbl = sm8150_usb3_serdes_tbl, 1797 1694 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), ··· 1819 1722 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1820 1723 1821 1724 .has_phy_dp_com_ctrl = true, 1822 - .is_dual_lane_phy = true, 1823 1725 }; 1824 1726 1825 1727 static const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = { 1826 - .type = PHY_TYPE_USB3, 1827 - .nlanes = 1, 1728 + .lanes = 1, 1828 1729 1829 1730 .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl, 1830 1731 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl), ··· 1853 1758 }; 1854 1759 1855 1760 static const struct qmp_phy_cfg sm8250_usb3phy_cfg = { 1856 - .type = PHY_TYPE_USB3, 1857 - .nlanes = 1, 1761 + .lanes = 2, 1858 1762 1859 1763 .serdes_tbl = sm8150_usb3_serdes_tbl, 1860 1764 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), ··· 1883 1789 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 1884 1790 1885 1791 .has_phy_dp_com_ctrl = true, 1886 - .is_dual_lane_phy = true, 1887 1792 }; 1888 1793 1889 1794 static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = { 1890 - .type = PHY_TYPE_USB3, 1891 - .nlanes = 1, 1795 + .lanes = 1, 1892 1796 1893 1797 .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl, 1894 1798 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl), ··· 1917 1825 }; 1918 1826 1919 1827 static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = { 1920 - .type = PHY_TYPE_USB3, 1921 - .nlanes = 1, 1828 + .lanes = 1, 1922 1829 1923 1830 .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl, 1924 1831 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl), ··· 1948 1857 }; 1949 1858 1950 1859 static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = { 1951 - .type = PHY_TYPE_USB3, 1952 - .nlanes = 1, 1860 + .lanes = 1, 1953 1861 1954 1862 .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl, 1955 1863 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl), ··· 1979 1889 }; 1980 1890 1981 1891 static const struct qmp_phy_cfg sm8350_usb3phy_cfg = { 1982 - .type = PHY_TYPE_USB3, 1983 - .nlanes = 1, 1892 + .lanes = 2, 1984 1893 1985 1894 .serdes_tbl = sm8150_usb3_serdes_tbl, 1986 1895 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_serdes_tbl), ··· 2009 1920 .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, 2010 1921 2011 1922 .has_phy_dp_com_ctrl = true, 2012 - .is_dual_lane_phy = true, 2013 1923 }; 2014 1924 2015 1925 static const struct qmp_phy_cfg sm8350_usb3_uniphy_cfg = { 2016 - .type = PHY_TYPE_USB3, 2017 - .nlanes = 1, 1926 + .lanes = 1, 2018 1927 2019 1928 .serdes_tbl = sm8150_usb3_uniphy_serdes_tbl, 2020 1929 .serdes_tbl_num = ARRAY_SIZE(sm8150_usb3_uniphy_serdes_tbl), ··· 2043 1956 }; 2044 1957 2045 1958 static const struct qmp_phy_cfg qcm2290_usb3phy_cfg = { 2046 - .type = PHY_TYPE_USB3, 2047 - .nlanes = 1, 1959 + .lanes = 2, 2048 1960 2049 1961 .serdes_tbl = qcm2290_usb3_serdes_tbl, 2050 1962 .serdes_tbl_num = ARRAY_SIZE(qcm2290_usb3_serdes_tbl), ··· 2064 1978 .start_ctrl = SERDES_START | PCS_START, 2065 1979 .pwrdn_ctrl = SW_PWRDN, 2066 1980 .phy_status = PHYSTATUS, 2067 - 2068 - .is_dual_lane_phy = true, 2069 1981 }; 2070 1982 2071 - static void qcom_qmp_phy_usb_configure_lane(void __iomem *base, 1983 + static void qmp_usb_configure_lane(void __iomem *base, 2072 1984 const unsigned int *regs, 2073 1985 const struct qmp_phy_init_tbl tbl[], 2074 1986 int num, ··· 2089 2005 } 2090 2006 } 2091 2007 2092 - static void qcom_qmp_phy_usb_configure(void __iomem *base, 2008 + static void qmp_usb_configure(void __iomem *base, 2093 2009 const unsigned int *regs, 2094 2010 const struct qmp_phy_init_tbl tbl[], 2095 2011 int num) 2096 2012 { 2097 - qcom_qmp_phy_usb_configure_lane(base, regs, tbl, num, 0xff); 2013 + qmp_usb_configure_lane(base, regs, tbl, num, 0xff); 2098 2014 } 2099 2015 2100 - static int qcom_qmp_phy_usb_serdes_init(struct qmp_phy *qphy) 2016 + static int qmp_usb_serdes_init(struct qmp_phy *qphy) 2101 2017 { 2102 2018 const struct qmp_phy_cfg *cfg = qphy->cfg; 2103 2019 void __iomem *serdes = qphy->serdes; 2104 2020 const struct qmp_phy_init_tbl *serdes_tbl = cfg->serdes_tbl; 2105 2021 int serdes_tbl_num = cfg->serdes_tbl_num; 2106 2022 2107 - qcom_qmp_phy_usb_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 2023 + qmp_usb_configure(serdes, cfg->regs, serdes_tbl, serdes_tbl_num); 2108 2024 2109 2025 return 0; 2110 2026 } 2111 2027 2112 - static int qcom_qmp_phy_usb_com_init(struct qmp_phy *qphy) 2028 + static int qmp_usb_init(struct phy *phy) 2113 2029 { 2030 + struct qmp_phy *qphy = phy_get_drvdata(phy); 2114 2031 struct qcom_qmp *qmp = qphy->qmp; 2115 2032 const struct qmp_phy_cfg *cfg = qphy->cfg; 2116 2033 void __iomem *pcs = qphy->pcs; ··· 2182 2097 return ret; 2183 2098 } 2184 2099 2185 - static int qcom_qmp_phy_usb_com_exit(struct qmp_phy *qphy) 2100 + static int qmp_usb_exit(struct phy *phy) 2186 2101 { 2102 + struct qmp_phy *qphy = phy_get_drvdata(phy); 2187 2103 struct qcom_qmp *qmp = qphy->qmp; 2188 2104 const struct qmp_phy_cfg *cfg = qphy->cfg; 2189 2105 ··· 2197 2111 return 0; 2198 2112 } 2199 2113 2200 - static int qcom_qmp_phy_usb_init(struct phy *phy) 2201 - { 2202 - struct qmp_phy *qphy = phy_get_drvdata(phy); 2203 - struct qcom_qmp *qmp = qphy->qmp; 2204 - int ret; 2205 - dev_vdbg(qmp->dev, "Initializing QMP phy\n"); 2206 - 2207 - ret = qcom_qmp_phy_usb_com_init(qphy); 2208 - if (ret) 2209 - return ret; 2210 - 2211 - return 0; 2212 - } 2213 - 2214 - static int qcom_qmp_phy_usb_power_on(struct phy *phy) 2114 + static int qmp_usb_power_on(struct phy *phy) 2215 2115 { 2216 2116 struct qmp_phy *qphy = phy_get_drvdata(phy); 2217 2117 struct qcom_qmp *qmp = qphy->qmp; ··· 2209 2137 unsigned int mask, val, ready; 2210 2138 int ret; 2211 2139 2212 - qcom_qmp_phy_usb_serdes_init(qphy); 2140 + qmp_usb_serdes_init(qphy); 2213 2141 2214 2142 ret = clk_prepare_enable(qphy->pipe_clk); 2215 2143 if (ret) { ··· 2218 2146 } 2219 2147 2220 2148 /* Tx, Rx, and PCS configurations */ 2221 - qcom_qmp_phy_usb_configure_lane(tx, cfg->regs, 2222 - cfg->tx_tbl, cfg->tx_tbl_num, 1); 2149 + qmp_usb_configure_lane(tx, cfg->regs, cfg->tx_tbl, cfg->tx_tbl_num, 1); 2223 2150 2224 - /* Configuration for other LANE for USB-DP combo PHY */ 2225 - if (cfg->is_dual_lane_phy) { 2226 - qcom_qmp_phy_usb_configure_lane(qphy->tx2, cfg->regs, 2227 - cfg->tx_tbl, cfg->tx_tbl_num, 2); 2151 + if (cfg->lanes >= 2) { 2152 + qmp_usb_configure_lane(qphy->tx2, cfg->regs, 2153 + cfg->tx_tbl, cfg->tx_tbl_num, 2); 2228 2154 } 2229 2155 2230 - qcom_qmp_phy_usb_configure_lane(rx, cfg->regs, 2231 - cfg->rx_tbl, cfg->rx_tbl_num, 1); 2156 + qmp_usb_configure_lane(rx, cfg->regs, cfg->rx_tbl, cfg->rx_tbl_num, 1); 2232 2157 2233 - if (cfg->is_dual_lane_phy) { 2234 - qcom_qmp_phy_usb_configure_lane(qphy->rx2, cfg->regs, 2235 - cfg->rx_tbl, cfg->rx_tbl_num, 2); 2158 + if (cfg->lanes >= 2) { 2159 + qmp_usb_configure_lane(qphy->rx2, cfg->regs, 2160 + cfg->rx_tbl, cfg->rx_tbl_num, 2); 2236 2161 } 2237 2162 2238 2163 /* Configure link rate, swing, etc. */ 2239 - qcom_qmp_phy_usb_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2164 + qmp_usb_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num); 2240 2165 2241 2166 if (cfg->has_pwrdn_delay) 2242 2167 usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); ··· 2263 2194 return ret; 2264 2195 } 2265 2196 2266 - static int qcom_qmp_phy_usb_power_off(struct phy *phy) 2197 + static int qmp_usb_power_off(struct phy *phy) 2267 2198 { 2268 2199 struct qmp_phy *qphy = phy_get_drvdata(phy); 2269 2200 const struct qmp_phy_cfg *cfg = qphy->cfg; ··· 2288 2219 return 0; 2289 2220 } 2290 2221 2291 - static int qcom_qmp_phy_usb_exit(struct phy *phy) 2292 - { 2293 - struct qmp_phy *qphy = phy_get_drvdata(phy); 2294 - 2295 - qcom_qmp_phy_usb_com_exit(qphy); 2296 - 2297 - return 0; 2298 - } 2299 - 2300 - static int qcom_qmp_phy_usb_enable(struct phy *phy) 2222 + static int qmp_usb_enable(struct phy *phy) 2301 2223 { 2302 2224 int ret; 2303 2225 2304 - ret = qcom_qmp_phy_usb_init(phy); 2226 + ret = qmp_usb_init(phy); 2305 2227 if (ret) 2306 2228 return ret; 2307 2229 2308 - ret = qcom_qmp_phy_usb_power_on(phy); 2230 + ret = qmp_usb_power_on(phy); 2309 2231 if (ret) 2310 - qcom_qmp_phy_usb_exit(phy); 2232 + qmp_usb_exit(phy); 2311 2233 2312 2234 return ret; 2313 2235 } 2314 2236 2315 - static int qcom_qmp_phy_usb_disable(struct phy *phy) 2237 + static int qmp_usb_disable(struct phy *phy) 2316 2238 { 2317 2239 int ret; 2318 2240 2319 - ret = qcom_qmp_phy_usb_power_off(phy); 2241 + ret = qmp_usb_power_off(phy); 2320 2242 if (ret) 2321 2243 return ret; 2322 - return qcom_qmp_phy_usb_exit(phy); 2244 + return qmp_usb_exit(phy); 2323 2245 } 2324 2246 2325 - static int qcom_qmp_phy_usb_set_mode(struct phy *phy, 2326 - enum phy_mode mode, int submode) 2247 + static int qmp_usb_set_mode(struct phy *phy, enum phy_mode mode, int submode) 2327 2248 { 2328 2249 struct qmp_phy *qphy = phy_get_drvdata(phy); 2329 2250 ··· 2322 2263 return 0; 2323 2264 } 2324 2265 2325 - static void qcom_qmp_phy_usb_enable_autonomous_mode(struct qmp_phy *qphy) 2266 + static void qmp_usb_enable_autonomous_mode(struct qmp_phy *qphy) 2326 2267 { 2327 2268 const struct qmp_phy_cfg *cfg = qphy->cfg; 2328 2269 void __iomem *pcs_usb = qphy->pcs_usb ?: qphy->pcs; ··· 2351 2292 qphy_clrbits(pcs_misc, QPHY_V3_PCS_MISC_CLAMP_ENABLE, CLAMP_EN); 2352 2293 } 2353 2294 2354 - static void qcom_qmp_phy_usb_disable_autonomous_mode(struct qmp_phy *qphy) 2295 + static void qmp_usb_disable_autonomous_mode(struct qmp_phy *qphy) 2355 2296 { 2356 2297 const struct qmp_phy_cfg *cfg = qphy->cfg; 2357 2298 void __iomem *pcs_usb = qphy->pcs_usb ?: qphy->pcs; ··· 2369 2310 qphy_clrbits(pcs_usb, cfg->regs[QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR], IRQ_CLEAR); 2370 2311 } 2371 2312 2372 - static int __maybe_unused qcom_qmp_phy_usb_runtime_suspend(struct device *dev) 2313 + static int __maybe_unused qmp_usb_runtime_suspend(struct device *dev) 2373 2314 { 2374 2315 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2375 2316 struct qmp_phy *qphy = qmp->phys[0]; ··· 2377 2318 2378 2319 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qphy->mode); 2379 2320 2380 - /* Supported only for USB3 PHY and luckily USB3 is the first phy */ 2381 - if (cfg->type != PHY_TYPE_USB3) 2382 - return 0; 2383 - 2384 2321 if (!qphy->phy->init_count) { 2385 2322 dev_vdbg(dev, "PHY not initialized, bailing out\n"); 2386 2323 return 0; 2387 2324 } 2388 2325 2389 - qcom_qmp_phy_usb_enable_autonomous_mode(qphy); 2326 + qmp_usb_enable_autonomous_mode(qphy); 2390 2327 2391 2328 clk_disable_unprepare(qphy->pipe_clk); 2392 2329 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); ··· 2390 2335 return 0; 2391 2336 } 2392 2337 2393 - static int __maybe_unused qcom_qmp_phy_usb_runtime_resume(struct device *dev) 2338 + static int __maybe_unused qmp_usb_runtime_resume(struct device *dev) 2394 2339 { 2395 2340 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2396 2341 struct qmp_phy *qphy = qmp->phys[0]; ··· 2398 2343 int ret = 0; 2399 2344 2400 2345 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qphy->mode); 2401 - 2402 - /* Supported only for USB3 PHY and luckily USB3 is the first phy */ 2403 - if (cfg->type != PHY_TYPE_USB3) 2404 - return 0; 2405 2346 2406 2347 if (!qphy->phy->init_count) { 2407 2348 dev_vdbg(dev, "PHY not initialized, bailing out\n"); ··· 2415 2364 return ret; 2416 2365 } 2417 2366 2418 - qcom_qmp_phy_usb_disable_autonomous_mode(qphy); 2367 + qmp_usb_disable_autonomous_mode(qphy); 2419 2368 2420 2369 return 0; 2421 2370 } 2422 2371 2423 - static int qcom_qmp_phy_usb_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2372 + static int qmp_usb_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2424 2373 { 2425 2374 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2426 2375 int num = cfg->num_vregs; ··· 2436 2385 return devm_regulator_bulk_get(dev, num, qmp->vregs); 2437 2386 } 2438 2387 2439 - static int qcom_qmp_phy_usb_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2388 + static int qmp_usb_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2440 2389 { 2441 2390 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2442 2391 int i; ··· 2457 2406 return 0; 2458 2407 } 2459 2408 2460 - static int qcom_qmp_phy_usb_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2409 + static int qmp_usb_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) 2461 2410 { 2462 2411 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2463 2412 int num = cfg->num_clks; ··· 2533 2482 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); 2534 2483 } 2535 2484 2536 - static const struct phy_ops qcom_qmp_phy_usb_ops = { 2537 - .init = qcom_qmp_phy_usb_enable, 2538 - .exit = qcom_qmp_phy_usb_disable, 2539 - .set_mode = qcom_qmp_phy_usb_set_mode, 2485 + static const struct phy_ops qmp_usb_ops = { 2486 + .init = qmp_usb_enable, 2487 + .exit = qmp_usb_disable, 2488 + .set_mode = qmp_usb_set_mode, 2540 2489 .owner = THIS_MODULE, 2541 2490 }; 2542 2491 2492 + static void __iomem *qmp_usb_iomap(struct device *dev, struct device_node *np, 2493 + int index, bool exclusive) 2494 + { 2495 + struct resource res; 2496 + 2497 + if (!exclusive) { 2498 + if (of_address_to_resource(np, index, &res)) 2499 + return IOMEM_ERR_PTR(-EINVAL); 2500 + 2501 + return devm_ioremap(dev, res.start, resource_size(&res)); 2502 + } 2503 + 2504 + return devm_of_iomap(dev, np, index, NULL); 2505 + } 2506 + 2543 2507 static 2544 - int qcom_qmp_phy_usb_create(struct device *dev, struct device_node *np, int id, 2508 + int qmp_usb_create(struct device *dev, struct device_node *np, int id, 2545 2509 void __iomem *serdes, const struct qmp_phy_cfg *cfg) 2546 2510 { 2547 2511 struct qcom_qmp *qmp = dev_get_drvdata(dev); 2548 2512 struct phy *generic_phy; 2549 2513 struct qmp_phy *qphy; 2550 - char prop_name[MAX_PROP_NAME]; 2514 + bool exclusive = true; 2551 2515 int ret; 2516 + 2517 + /* 2518 + * FIXME: These bindings should be fixed to not rely on overlapping 2519 + * mappings for PCS. 2520 + */ 2521 + if (of_device_is_compatible(dev->of_node, "qcom,sdx65-qmp-usb3-uni-phy")) 2522 + exclusive = false; 2523 + if (of_device_is_compatible(dev->of_node, "qcom,sm8350-qmp-usb3-uni-phy")) 2524 + exclusive = false; 2552 2525 2553 2526 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); 2554 2527 if (!qphy) ··· 2586 2511 * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 2587 2512 * For single lane PHYs: pcs_misc (optional) -> 3. 2588 2513 */ 2589 - qphy->tx = of_iomap(np, 0); 2590 - if (!qphy->tx) 2591 - return -ENOMEM; 2514 + qphy->tx = devm_of_iomap(dev, np, 0, NULL); 2515 + if (IS_ERR(qphy->tx)) 2516 + return PTR_ERR(qphy->tx); 2592 2517 2593 - qphy->rx = of_iomap(np, 1); 2594 - if (!qphy->rx) 2595 - return -ENOMEM; 2518 + qphy->rx = devm_of_iomap(dev, np, 1, NULL); 2519 + if (IS_ERR(qphy->rx)) 2520 + return PTR_ERR(qphy->rx); 2596 2521 2597 - qphy->pcs = of_iomap(np, 2); 2598 - if (!qphy->pcs) 2599 - return -ENOMEM; 2522 + qphy->pcs = qmp_usb_iomap(dev, np, 2, exclusive); 2523 + if (IS_ERR(qphy->pcs)) 2524 + return PTR_ERR(qphy->pcs); 2600 2525 2601 2526 if (cfg->pcs_usb_offset) 2602 2527 qphy->pcs_usb = qphy->pcs + cfg->pcs_usb_offset; 2603 2528 2604 - /* 2605 - * If this is a dual-lane PHY, then there should be registers for the 2606 - * second lane. Some old device trees did not specify this, so fall 2607 - * back to old legacy behavior of assuming they can be reached at an 2608 - * offset from the first lane. 2609 - */ 2610 - if (cfg->is_dual_lane_phy) { 2611 - qphy->tx2 = of_iomap(np, 3); 2612 - qphy->rx2 = of_iomap(np, 4); 2613 - if (!qphy->tx2 || !qphy->rx2) { 2614 - dev_warn(dev, 2615 - "Underspecified device tree, falling back to legacy register regions\n"); 2529 + if (cfg->lanes >= 2) { 2530 + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); 2531 + if (IS_ERR(qphy->tx2)) 2532 + return PTR_ERR(qphy->tx2); 2616 2533 2617 - /* In the old version, pcs_misc is at index 3. */ 2618 - qphy->pcs_misc = qphy->tx2; 2619 - qphy->tx2 = qphy->tx + QMP_PHY_LEGACY_LANE_STRIDE; 2620 - qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; 2534 + qphy->rx2 = devm_of_iomap(dev, np, 4, NULL); 2535 + if (IS_ERR(qphy->rx2)) 2536 + return PTR_ERR(qphy->rx2); 2621 2537 2622 - } else { 2623 - qphy->pcs_misc = of_iomap(np, 5); 2624 - } 2625 - 2538 + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); 2626 2539 } else { 2627 - qphy->pcs_misc = of_iomap(np, 3); 2540 + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); 2628 2541 } 2629 2542 2630 - if (!qphy->pcs_misc) 2543 + if (IS_ERR(qphy->pcs_misc)) { 2631 2544 dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); 2545 + qphy->pcs_misc = NULL; 2546 + } 2632 2547 2633 - snprintf(prop_name, sizeof(prop_name), "pipe%d", id); 2634 - qphy->pipe_clk = devm_get_clk_from_child(dev, np, prop_name); 2548 + qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); 2635 2549 if (IS_ERR(qphy->pipe_clk)) { 2636 2550 return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), 2637 2551 "failed to get lane%d pipe clock\n", id); 2638 2552 } 2639 2553 2640 - generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_usb_ops); 2554 + generic_phy = devm_phy_create(dev, np, &qmp_usb_ops); 2641 2555 if (IS_ERR(generic_phy)) { 2642 2556 ret = PTR_ERR(generic_phy); 2643 2557 dev_err(dev, "failed to create qphy %d\n", ret); ··· 2634 2570 } 2635 2571 2636 2572 qphy->phy = generic_phy; 2637 - qphy->index = id; 2638 2573 qphy->qmp = qmp; 2639 2574 qmp->phys[id] = qphy; 2640 2575 phy_set_drvdata(generic_phy, qphy); ··· 2641 2578 return 0; 2642 2579 } 2643 2580 2644 - static const struct of_device_id qcom_qmp_phy_usb_of_match_table[] = { 2581 + static const struct of_device_id qmp_usb_of_match_table[] = { 2645 2582 { 2646 2583 .compatible = "qcom,ipq8074-qmp-usb3-phy", 2647 2584 .data = &ipq8074_usb3phy_cfg, ··· 2657 2594 }, { 2658 2595 .compatible = "qcom,sc8180x-qmp-usb3-phy", 2659 2596 .data = &sm8150_usb3phy_cfg, 2597 + }, { 2598 + .compatible = "qcom,sc8280xp-qmp-usb3-uni-phy", 2599 + .data = &sc8280xp_usb3_uniphy_cfg, 2660 2600 }, { 2661 2601 .compatible = "qcom,sdm845-qmp-usb3-phy", 2662 2602 .data = &qmp_v3_usb3phy_cfg, ··· 2702 2636 }, 2703 2637 { }, 2704 2638 }; 2705 - MODULE_DEVICE_TABLE(of, qcom_qmp_phy_usb_of_match_table); 2639 + MODULE_DEVICE_TABLE(of, qmp_usb_of_match_table); 2706 2640 2707 - static const struct dev_pm_ops qcom_qmp_phy_usb_pm_ops = { 2708 - SET_RUNTIME_PM_OPS(qcom_qmp_phy_usb_runtime_suspend, 2709 - qcom_qmp_phy_usb_runtime_resume, NULL) 2641 + static const struct dev_pm_ops qmp_usb_pm_ops = { 2642 + SET_RUNTIME_PM_OPS(qmp_usb_runtime_suspend, 2643 + qmp_usb_runtime_resume, NULL) 2710 2644 }; 2711 2645 2712 - static int qcom_qmp_phy_usb_probe(struct platform_device *pdev) 2646 + static int qmp_usb_probe(struct platform_device *pdev) 2713 2647 { 2714 2648 struct qcom_qmp *qmp; 2715 2649 struct device *dev = &pdev->dev; ··· 2744 2678 return PTR_ERR(qmp->dp_com); 2745 2679 } 2746 2680 2747 - ret = qcom_qmp_phy_usb_clk_init(dev, cfg); 2681 + ret = qmp_usb_clk_init(dev, cfg); 2748 2682 if (ret) 2749 2683 return ret; 2750 2684 2751 - ret = qcom_qmp_phy_usb_reset_init(dev, cfg); 2685 + ret = qmp_usb_reset_init(dev, cfg); 2752 2686 if (ret) 2753 2687 return ret; 2754 2688 2755 - ret = qcom_qmp_phy_usb_vreg_init(dev, cfg); 2756 - if (ret) { 2757 - if (ret != -EPROBE_DEFER) 2758 - dev_err(dev, "failed to get regulator supplies: %d\n", 2759 - ret); 2760 - return ret; 2761 - } 2689 + ret = qmp_usb_vreg_init(dev, cfg); 2690 + if (ret) 2691 + return dev_err_probe(dev, ret, 2692 + "failed to get regulator supplies\n"); 2762 2693 2763 2694 num = of_get_available_child_count(dev->of_node); 2764 2695 /* do we have a rogue child node ? */ ··· 2767 2704 return -ENOMEM; 2768 2705 2769 2706 pm_runtime_set_active(dev); 2770 - pm_runtime_enable(dev); 2707 + ret = devm_pm_runtime_enable(dev); 2708 + if (ret) 2709 + return ret; 2771 2710 /* 2772 2711 * Prevent runtime pm from being ON by default. Users can enable 2773 2712 * it using power/control in sysfs. ··· 2779 2714 id = 0; 2780 2715 for_each_available_child_of_node(dev->of_node, child) { 2781 2716 /* Create per-lane phy */ 2782 - ret = qcom_qmp_phy_usb_create(dev, child, id, serdes, cfg); 2717 + ret = qmp_usb_create(dev, child, id, serdes, cfg); 2783 2718 if (ret) { 2784 2719 dev_err(dev, "failed to create lane%d phy, %d\n", 2785 2720 id, ret); ··· 2801 2736 } 2802 2737 2803 2738 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 2804 - if (!IS_ERR(phy_provider)) 2805 - dev_info(dev, "Registered Qcom-QMP phy\n"); 2806 - else 2807 - pm_runtime_disable(dev); 2808 2739 2809 2740 return PTR_ERR_OR_ZERO(phy_provider); 2810 2741 2811 2742 err_node_put: 2812 - pm_runtime_disable(dev); 2813 2743 of_node_put(child); 2814 2744 return ret; 2815 2745 } 2816 2746 2817 - static struct platform_driver qcom_qmp_phy_usb_driver = { 2818 - .probe = qcom_qmp_phy_usb_probe, 2747 + static struct platform_driver qmp_usb_driver = { 2748 + .probe = qmp_usb_probe, 2819 2749 .driver = { 2820 2750 .name = "qcom-qmp-usb-phy", 2821 - .pm = &qcom_qmp_phy_usb_pm_ops, 2822 - .of_match_table = qcom_qmp_phy_usb_of_match_table, 2751 + .pm = &qmp_usb_pm_ops, 2752 + .of_match_table = qmp_usb_of_match_table, 2823 2753 }, 2824 2754 }; 2825 2755 2826 - module_platform_driver(qcom_qmp_phy_usb_driver); 2756 + module_platform_driver(qmp_usb_driver); 2827 2757 2828 2758 MODULE_AUTHOR("Vivek Gautam <vivek.gautam@codeaurora.org>"); 2829 2759 MODULE_DESCRIPTION("Qualcomm QMP USB PHY driver");
+1
drivers/phy/qualcomm/phy-qcom-qmp.h
··· 19 19 #include "phy-qcom-qmp-qserdes-com-v5.h" 20 20 #include "phy-qcom-qmp-qserdes-txrx-v5.h" 21 21 #include "phy-qcom-qmp-qserdes-txrx-v5_20.h" 22 + #include "phy-qcom-qmp-qserdes-txrx-v5_5nm.h" 22 23 23 24 #include "phy-qcom-qmp-qserdes-pll.h" 24 25
+9 -18
drivers/phy/qualcomm/phy-qcom-qusb2.c
··· 973 973 return PTR_ERR(qphy->base); 974 974 975 975 qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb"); 976 - if (IS_ERR(qphy->cfg_ahb_clk)) { 977 - ret = PTR_ERR(qphy->cfg_ahb_clk); 978 - if (ret != -EPROBE_DEFER) 979 - dev_err(dev, "failed to get cfg ahb clk, %d\n", ret); 980 - return ret; 981 - } 976 + if (IS_ERR(qphy->cfg_ahb_clk)) 977 + return dev_err_probe(dev, PTR_ERR(qphy->cfg_ahb_clk), 978 + "failed to get cfg ahb clk\n"); 982 979 983 980 qphy->ref_clk = devm_clk_get(dev, "ref"); 984 - if (IS_ERR(qphy->ref_clk)) { 985 - ret = PTR_ERR(qphy->ref_clk); 986 - if (ret != -EPROBE_DEFER) 987 - dev_err(dev, "failed to get ref clk, %d\n", ret); 988 - return ret; 989 - } 981 + if (IS_ERR(qphy->ref_clk)) 982 + return dev_err_probe(dev, PTR_ERR(qphy->ref_clk), 983 + "failed to get ref clk\n"); 990 984 991 985 qphy->iface_clk = devm_clk_get_optional(dev, "iface"); 992 986 if (IS_ERR(qphy->iface_clk)) ··· 997 1003 qphy->vregs[i].supply = qusb2_phy_vreg_names[i]; 998 1004 999 1005 ret = devm_regulator_bulk_get(dev, num, qphy->vregs); 1000 - if (ret) { 1001 - if (ret != -EPROBE_DEFER) 1002 - dev_err(dev, "failed to get regulator supplies: %d\n", 1003 - ret); 1004 - return ret; 1005 - } 1006 + if (ret) 1007 + return dev_err_probe(dev, ret, 1008 + "failed to get regulator supplies\n"); 1006 1009 1007 1010 /* Get the specific init parameters of QMP phy */ 1008 1011 qphy->cfg = of_device_get_match_data(dev);
+259 -14
drivers/phy/qualcomm/phy-qcom-snps-femto-v2.c
··· 52 52 #define USB2_SUSPEND_N BIT(2) 53 53 #define USB2_SUSPEND_N_SEL BIT(3) 54 54 55 + #define USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X0 (0x6c) 56 + #define USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X1 (0x70) 57 + #define USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X2 (0x74) 58 + #define USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X3 (0x78) 59 + #define PARAM_OVRD_MASK 0xFF 60 + 55 61 #define USB2_PHY_USB_PHY_CFG0 (0x94) 56 62 #define UTMI_PHY_DATAPATH_CTRL_OVERRIDE_EN BIT(0) 57 63 #define UTMI_PHY_CMN_CTRL_OVERRIDE_EN BIT(1) ··· 66 60 #define REFCLK_SEL_MASK GENMASK(1, 0) 67 61 #define REFCLK_SEL_DEFAULT (0x2 << 0) 68 62 63 + #define HS_DISCONNECT_MASK GENMASK(2, 0) 64 + #define SQUELCH_DETECTOR_MASK GENMASK(7, 5) 65 + 66 + #define HS_AMPLITUDE_MASK GENMASK(3, 0) 67 + #define PREEMPHASIS_DURATION_MASK BIT(5) 68 + #define PREEMPHASIS_AMPLITUDE_MASK GENMASK(7, 6) 69 + 70 + #define HS_RISE_FALL_MASK GENMASK(1, 0) 71 + #define HS_CROSSOVER_VOLTAGE_MASK GENMASK(3, 2) 72 + #define HS_OUTPUT_IMPEDANCE_MASK GENMASK(5, 4) 73 + 74 + #define LS_FS_OUTPUT_IMPEDANCE_MASK GENMASK(3, 0) 75 + 69 76 static const char * const qcom_snps_hsphy_vreg_names[] = { 70 77 "vdda-pll", "vdda33", "vdda18", 71 78 }; 72 79 73 80 #define SNPS_HS_NUM_VREGS ARRAY_SIZE(qcom_snps_hsphy_vreg_names) 81 + 82 + struct override_param { 83 + s32 value; 84 + u8 reg_val; 85 + }; 86 + 87 + struct override_param_map { 88 + const char *prop_name; 89 + const struct override_param *param_table; 90 + u8 table_size; 91 + u8 reg_offset; 92 + u8 param_mask; 93 + }; 94 + 95 + struct phy_override_seq { 96 + bool need_update; 97 + u8 offset; 98 + u8 value; 99 + u8 mask; 100 + }; 101 + 102 + #define NUM_HSPHY_TUNING_PARAMS (9) 74 103 75 104 /** 76 105 * struct qcom_snps_hsphy - snps hs phy attributes ··· 132 91 133 92 bool phy_initialized; 134 93 enum phy_mode mode; 94 + struct phy_override_seq update_seq_cfg[NUM_HSPHY_TUNING_PARAMS]; 135 95 }; 136 96 137 97 static inline void qcom_snps_hsphy_write_mask(void __iomem *base, u32 offset, ··· 215 173 return 0; 216 174 } 217 175 176 + static const struct override_param hs_disconnect_sc7280[] = { 177 + { -272, 0 }, 178 + { 0, 1 }, 179 + { 317, 2 }, 180 + { 630, 3 }, 181 + { 973, 4 }, 182 + { 1332, 5 }, 183 + { 1743, 6 }, 184 + { 2156, 7 }, 185 + }; 186 + 187 + static const struct override_param squelch_det_threshold_sc7280[] = { 188 + { -2090, 7 }, 189 + { -1560, 6 }, 190 + { -1030, 5 }, 191 + { -530, 4 }, 192 + { 0, 3 }, 193 + { 530, 2 }, 194 + { 1060, 1 }, 195 + { 1590, 0 }, 196 + }; 197 + 198 + static const struct override_param hs_amplitude_sc7280[] = { 199 + { -660, 0 }, 200 + { -440, 1 }, 201 + { -220, 2 }, 202 + { 0, 3 }, 203 + { 230, 4 }, 204 + { 440, 5 }, 205 + { 650, 6 }, 206 + { 890, 7 }, 207 + { 1110, 8 }, 208 + { 1330, 9 }, 209 + { 1560, 10 }, 210 + { 1780, 11 }, 211 + { 2000, 12 }, 212 + { 2220, 13 }, 213 + { 2430, 14 }, 214 + { 2670, 15 }, 215 + }; 216 + 217 + static const struct override_param preemphasis_duration_sc7280[] = { 218 + { 10000, 1 }, 219 + { 20000, 0 }, 220 + }; 221 + 222 + static const struct override_param preemphasis_amplitude_sc7280[] = { 223 + { 10000, 1 }, 224 + { 20000, 2 }, 225 + { 30000, 3 }, 226 + { 40000, 0 }, 227 + }; 228 + 229 + static const struct override_param hs_rise_fall_time_sc7280[] = { 230 + { -4100, 3 }, 231 + { 0, 2 }, 232 + { 2810, 1 }, 233 + { 5430, 0 }, 234 + }; 235 + 236 + static const struct override_param hs_crossover_voltage_sc7280[] = { 237 + { -31000, 1 }, 238 + { 0, 3 }, 239 + { 28000, 2 }, 240 + }; 241 + 242 + static const struct override_param hs_output_impedance_sc7280[] = { 243 + { -2300000, 3 }, 244 + { 0, 2 }, 245 + { 2600000, 1 }, 246 + { 6100000, 0 }, 247 + }; 248 + 249 + static const struct override_param ls_fs_output_impedance_sc7280[] = { 250 + { -1053, 15 }, 251 + { -557, 7 }, 252 + { 0, 3 }, 253 + { 612, 1 }, 254 + { 1310, 0 }, 255 + }; 256 + 257 + static const struct override_param_map sc7280_snps_7nm_phy[] = { 258 + { 259 + "qcom,hs-disconnect-bp", 260 + hs_disconnect_sc7280, 261 + ARRAY_SIZE(hs_disconnect_sc7280), 262 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X0, 263 + HS_DISCONNECT_MASK 264 + }, 265 + { 266 + "qcom,squelch-detector-bp", 267 + squelch_det_threshold_sc7280, 268 + ARRAY_SIZE(squelch_det_threshold_sc7280), 269 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X0, 270 + SQUELCH_DETECTOR_MASK 271 + }, 272 + { 273 + "qcom,hs-amplitude-bp", 274 + hs_amplitude_sc7280, 275 + ARRAY_SIZE(hs_amplitude_sc7280), 276 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X1, 277 + HS_AMPLITUDE_MASK 278 + }, 279 + { 280 + "qcom,pre-emphasis-duration-bp", 281 + preemphasis_duration_sc7280, 282 + ARRAY_SIZE(preemphasis_duration_sc7280), 283 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X1, 284 + PREEMPHASIS_DURATION_MASK, 285 + }, 286 + { 287 + "qcom,pre-emphasis-amplitude-bp", 288 + preemphasis_amplitude_sc7280, 289 + ARRAY_SIZE(preemphasis_amplitude_sc7280), 290 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X1, 291 + PREEMPHASIS_AMPLITUDE_MASK, 292 + }, 293 + { 294 + "qcom,hs-rise-fall-time-bp", 295 + hs_rise_fall_time_sc7280, 296 + ARRAY_SIZE(hs_rise_fall_time_sc7280), 297 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X2, 298 + HS_RISE_FALL_MASK 299 + }, 300 + { 301 + "qcom,hs-crossover-voltage-microvolt", 302 + hs_crossover_voltage_sc7280, 303 + ARRAY_SIZE(hs_crossover_voltage_sc7280), 304 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X2, 305 + HS_CROSSOVER_VOLTAGE_MASK 306 + }, 307 + { 308 + "qcom,hs-output-impedance-micro-ohms", 309 + hs_output_impedance_sc7280, 310 + ARRAY_SIZE(hs_output_impedance_sc7280), 311 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X2, 312 + HS_OUTPUT_IMPEDANCE_MASK, 313 + }, 314 + { 315 + "qcom,ls-fs-output-impedance-bp", 316 + ls_fs_output_impedance_sc7280, 317 + ARRAY_SIZE(ls_fs_output_impedance_sc7280), 318 + USB2_PHY_USB_PHY_HS_PHY_OVERRIDE_X3, 319 + LS_FS_OUTPUT_IMPEDANCE_MASK, 320 + }, 321 + {}, 322 + }; 323 + 218 324 static int qcom_snps_hsphy_init(struct phy *phy) 219 325 { 220 326 struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy); 221 - int ret; 327 + int ret, i; 222 328 223 329 dev_vdbg(&phy->dev, "%s(): Initializing SNPS HS phy\n", __func__); 224 330 ··· 412 222 VBUSVLDEXTSEL0, VBUSVLDEXTSEL0); 413 223 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL1, 414 224 VBUSVLDEXT0, VBUSVLDEXT0); 225 + 226 + for (i = 0; i < ARRAY_SIZE(hsphy->update_seq_cfg); i++) { 227 + if (hsphy->update_seq_cfg[i].need_update) 228 + qcom_snps_hsphy_write_mask(hsphy->base, 229 + hsphy->update_seq_cfg[i].offset, 230 + hsphy->update_seq_cfg[i].mask, 231 + hsphy->update_seq_cfg[i].value); 232 + } 415 233 416 234 qcom_snps_hsphy_write_mask(hsphy->base, 417 235 USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON2, ··· 478 280 static const struct of_device_id qcom_snps_hsphy_of_match_table[] = { 479 281 { .compatible = "qcom,sm8150-usb-hs-phy", }, 480 282 { .compatible = "qcom,usb-snps-hs-5nm-phy", }, 481 - { .compatible = "qcom,usb-snps-hs-7nm-phy", }, 283 + { 284 + .compatible = "qcom,usb-snps-hs-7nm-phy", 285 + .data = &sc7280_snps_7nm_phy, 286 + }, 482 287 { .compatible = "qcom,usb-snps-femto-v2-phy", }, 483 288 { } 484 289 }; ··· 491 290 SET_RUNTIME_PM_OPS(qcom_snps_hsphy_runtime_suspend, 492 291 qcom_snps_hsphy_runtime_resume, NULL) 493 292 }; 293 + 294 + static void qcom_snps_hsphy_override_param_update_val( 295 + const struct override_param_map map, 296 + s32 dt_val, struct phy_override_seq *seq_entry) 297 + { 298 + int i; 299 + 300 + /* 301 + * Param table for each param is in increasing order 302 + * of dt values. We need to iterate over the list to 303 + * select the entry that matches the dt value and pick 304 + * up the corresponding register value. 305 + */ 306 + for (i = 0; i < map.table_size - 1; i++) { 307 + if (map.param_table[i].value == dt_val) 308 + break; 309 + } 310 + 311 + seq_entry->need_update = true; 312 + seq_entry->offset = map.reg_offset; 313 + seq_entry->mask = map.param_mask; 314 + seq_entry->value = map.param_table[i].reg_val << __ffs(map.param_mask); 315 + } 316 + 317 + static void qcom_snps_hsphy_read_override_param_seq(struct device *dev) 318 + { 319 + struct device_node *node = dev->of_node; 320 + s32 val; 321 + int ret, i; 322 + struct qcom_snps_hsphy *hsphy; 323 + const struct override_param_map *cfg = of_device_get_match_data(dev); 324 + 325 + if (!cfg) 326 + return; 327 + 328 + hsphy = dev_get_drvdata(dev); 329 + 330 + for (i = 0; cfg[i].prop_name != NULL; i++) { 331 + ret = of_property_read_s32(node, cfg[i].prop_name, &val); 332 + if (ret) 333 + continue; 334 + 335 + qcom_snps_hsphy_override_param_update_val(cfg[i], val, 336 + &hsphy->update_seq_cfg[i]); 337 + dev_dbg(&hsphy->phy->dev, "Read param: %s dt_val: %d reg_val: 0x%x\n", 338 + cfg[i].prop_name, val, hsphy->update_seq_cfg[i].value); 339 + 340 + } 341 + } 494 342 495 343 static int qcom_snps_hsphy_probe(struct platform_device *pdev) 496 344 { ··· 559 309 return PTR_ERR(hsphy->base); 560 310 561 311 hsphy->ref_clk = devm_clk_get(dev, "ref"); 562 - if (IS_ERR(hsphy->ref_clk)) { 563 - ret = PTR_ERR(hsphy->ref_clk); 564 - if (ret != -EPROBE_DEFER) 565 - dev_err(dev, "failed to get ref clk, %d\n", ret); 566 - return ret; 567 - } 312 + if (IS_ERR(hsphy->ref_clk)) 313 + return dev_err_probe(dev, PTR_ERR(hsphy->ref_clk), 314 + "failed to get ref clk\n"); 568 315 569 316 hsphy->phy_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); 570 317 if (IS_ERR(hsphy->phy_reset)) { ··· 574 327 hsphy->vregs[i].supply = qcom_snps_hsphy_vreg_names[i]; 575 328 576 329 ret = devm_regulator_bulk_get(dev, num, hsphy->vregs); 577 - if (ret) { 578 - if (ret != -EPROBE_DEFER) 579 - dev_err(dev, "failed to get regulator supplies: %d\n", 580 - ret); 581 - return ret; 582 - } 330 + if (ret) 331 + return dev_err_probe(dev, ret, 332 + "failed to get regulator supplies\n"); 583 333 584 334 pm_runtime_set_active(dev); 585 335 pm_runtime_enable(dev); ··· 596 352 597 353 dev_set_drvdata(dev, hsphy); 598 354 phy_set_drvdata(generic_phy, hsphy); 355 + qcom_snps_hsphy_read_override_param_seq(dev); 599 356 600 357 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 601 358 if (!IS_ERR(phy_provider))
+4 -2
drivers/phy/qualcomm/phy-qcom-usb-hsic.c
··· 54 54 55 55 /* Configure pins for HSIC functionality */ 56 56 pins_default = pinctrl_lookup_state(uphy->pctl, PINCTRL_STATE_DEFAULT); 57 - if (IS_ERR(pins_default)) 58 - return PTR_ERR(pins_default); 57 + if (IS_ERR(pins_default)) { 58 + ret = PTR_ERR(pins_default); 59 + goto err_ulpi; 60 + } 59 61 60 62 ret = pinctrl_select_state(uphy->pctl, pins_default); 61 63 if (ret)
+9
drivers/phy/rockchip/Kconfig
··· 83 83 help 84 84 Enable this to support the Rockchip PCIe PHY. 85 85 86 + config PHY_ROCKCHIP_SNPS_PCIE3 87 + tristate "Rockchip Snps PCIe3 PHY Driver" 88 + depends on (ARCH_ROCKCHIP && OF) || COMPILE_TEST 89 + depends on HAS_IOMEM 90 + select GENERIC_PHY 91 + select MFD_SYSCON 92 + help 93 + Enable this to support the Rockchip snps PCIe3 PHY. 94 + 86 95 config PHY_ROCKCHIP_TYPEC 87 96 tristate "Rockchip TYPEC PHY Driver" 88 97 depends on OF && (ARCH_ROCKCHIP || COMPILE_TEST)
+1
drivers/phy/rockchip/Makefile
··· 8 8 obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o 9 9 obj-$(CONFIG_PHY_ROCKCHIP_NANENG_COMBO_PHY) += phy-rockchip-naneng-combphy.o 10 10 obj-$(CONFIG_PHY_ROCKCHIP_PCIE) += phy-rockchip-pcie.o 11 + obj-$(CONFIG_PHY_ROCKCHIP_SNPS_PCIE3) += phy-rockchip-snps-pcie3.o 11 12 obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o 12 13 obj-$(CONFIG_PHY_ROCKCHIP_USB) += phy-rockchip-usb.o
+24
drivers/phy/rockchip/phy-rockchip-inno-csidphy.c
··· 27 27 28 28 #define RK3368_GRF_SOC_CON6_OFFSET 0x0418 29 29 30 + #define RK3568_GRF_VI_CON0 0x0340 31 + #define RK3568_GRF_VI_CON1 0x0344 32 + 30 33 /* PHY */ 31 34 #define CSIDPHY_CTRL_LANE_ENABLE 0x00 32 35 #define CSIDPHY_CTRL_LANE_ENABLE_CK BIT(6) ··· 61 58 #define RK1808_CSIDPHY_CLK_WR_THS_SETTLE 0x160 62 59 #define RK3326_CSIDPHY_CLK_WR_THS_SETTLE 0x100 63 60 #define RK3368_CSIDPHY_CLK_WR_THS_SETTLE 0x100 61 + #define RK3568_CSIDPHY_CLK_WR_THS_SETTLE 0x160 64 62 65 63 /* Calibration reception enable */ 66 64 #define RK1808_CSIDPHY_CLK_CALIB_EN 0x168 65 + #define RK3568_CSIDPHY_CLK_CALIB_EN 0x168 67 66 68 67 /* 69 68 * The higher 16-bit of this register is used for write protection ··· 106 101 107 102 static const struct dphy_reg rk3368_grf_dphy_regs[] = { 108 103 [GRF_DPHY_CSIPHY_FORCERXMODE] = PHY_REG(RK3368_GRF_SOC_CON6_OFFSET, 4, 8), 104 + }; 105 + 106 + static const struct dphy_reg rk3568_grf_dphy_regs[] = { 107 + [GRF_DPHY_CSIPHY_FORCERXMODE] = PHY_REG(RK3568_GRF_VI_CON0, 4, 0), 108 + [GRF_DPHY_CSIPHY_DATALANE_EN] = PHY_REG(RK3568_GRF_VI_CON0, 4, 4), 109 + [GRF_DPHY_CSIPHY_CLKLANE_EN] = PHY_REG(RK3568_GRF_VI_CON0, 1, 8), 109 110 }; 110 111 111 112 struct hsfreq_range { ··· 363 352 .grf_regs = rk3368_grf_dphy_regs, 364 353 }; 365 354 355 + static const struct dphy_drv_data rk3568_mipidphy_drv_data = { 356 + .pwrctl_offset = -1, 357 + .ths_settle_offset = RK3568_CSIDPHY_CLK_WR_THS_SETTLE, 358 + .calib_offset = RK3568_CSIDPHY_CLK_CALIB_EN, 359 + .hsfreq_ranges = rk1808_mipidphy_hsfreq_ranges, 360 + .num_hsfreq_ranges = ARRAY_SIZE(rk1808_mipidphy_hsfreq_ranges), 361 + .grf_regs = rk3568_grf_dphy_regs, 362 + }; 363 + 366 364 static const struct of_device_id rockchip_inno_csidphy_match_id[] = { 367 365 { 368 366 .compatible = "rockchip,px30-csi-dphy", ··· 388 368 { 389 369 .compatible = "rockchip,rk3368-csi-dphy", 390 370 .data = &rk3368_mipidphy_drv_data, 371 + }, 372 + { 373 + .compatible = "rockchip,rk3568-csi-dphy", 374 + .data = &rk3568_mipidphy_drv_data, 391 375 }, 392 376 {} 393 377 };
+158 -46
drivers/phy/rockchip/phy-rockchip-inno-dsidphy.c
··· 84 84 #define DATA_LANE_0_SKEW_PHASE_MASK GENMASK(2, 0) 85 85 #define DATA_LANE_0_SKEW_PHASE(x) UPDATE(x, 2, 0) 86 86 /* Analog Register Part: reg08 */ 87 + #define PLL_POST_DIV_ENABLE_MASK BIT(5) 88 + #define PLL_POST_DIV_ENABLE BIT(5) 87 89 #define SAMPLE_CLOCK_DIRECTION_MASK BIT(4) 88 90 #define SAMPLE_CLOCK_DIRECTION_REVERSE BIT(4) 89 91 #define SAMPLE_CLOCK_DIRECTION_FORWARD 0 92 + #define LOWFRE_EN_MASK BIT(5) 93 + #define PLL_OUTPUT_FREQUENCY_DIV_BY_1 0 94 + #define PLL_OUTPUT_FREQUENCY_DIV_BY_2 1 95 + /* Analog Register Part: reg0b */ 96 + #define CLOCK_LANE_VOD_RANGE_SET_MASK GENMASK(3, 0) 97 + #define CLOCK_LANE_VOD_RANGE_SET(x) UPDATE(x, 3, 0) 98 + #define VOD_MIN_RANGE 0x1 99 + #define VOD_MID_RANGE 0x3 100 + #define VOD_BIG_RANGE 0x7 101 + #define VOD_MAX_RANGE 0xf 102 + /* Analog Register Part: reg1E */ 103 + #define PLL_MODE_SEL_MASK GENMASK(6, 5) 104 + #define PLL_MODE_SEL_LVDS_MODE 0 105 + #define PLL_MODE_SEL_MIPI_MODE BIT(5) 90 106 /* Digital Register Part: reg00 */ 91 107 #define REG_DIG_RSTN_MASK BIT(0) 92 108 #define REG_DIG_RSTN_NORMAL BIT(0) ··· 118 102 #define T_LPX_CNT_MASK GENMASK(5, 0) 119 103 #define T_LPX_CNT(x) UPDATE(x, 5, 0) 120 104 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg06 */ 105 + #define T_HS_ZERO_CNT_HI_MASK BIT(7) 106 + #define T_HS_ZERO_CNT_HI(x) UPDATE(x, 7, 7) 121 107 #define T_HS_PREPARE_CNT_MASK GENMASK(6, 0) 122 108 #define T_HS_PREPARE_CNT(x) UPDATE(x, 6, 0) 123 109 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg07 */ 124 - #define T_HS_ZERO_CNT_MASK GENMASK(5, 0) 125 - #define T_HS_ZERO_CNT(x) UPDATE(x, 5, 0) 110 + #define T_HS_ZERO_CNT_LO_MASK GENMASK(5, 0) 111 + #define T_HS_ZERO_CNT_LO(x) UPDATE(x, 5, 0) 126 112 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg08 */ 127 113 #define T_HS_TRAIL_CNT_MASK GENMASK(6, 0) 128 114 #define T_HS_TRAIL_CNT(x) UPDATE(x, 6, 0) 129 115 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg09 */ 130 - #define T_HS_EXIT_CNT_MASK GENMASK(4, 0) 131 - #define T_HS_EXIT_CNT(x) UPDATE(x, 4, 0) 116 + #define T_HS_EXIT_CNT_LO_MASK GENMASK(4, 0) 117 + #define T_HS_EXIT_CNT_LO(x) UPDATE(x, 4, 0) 132 118 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg0a */ 133 - #define T_CLK_POST_CNT_MASK GENMASK(3, 0) 134 - #define T_CLK_POST_CNT(x) UPDATE(x, 3, 0) 119 + #define T_CLK_POST_CNT_LO_MASK GENMASK(3, 0) 120 + #define T_CLK_POST_CNT_LO(x) UPDATE(x, 3, 0) 135 121 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg0c */ 136 122 #define LPDT_TX_PPI_SYNC_MASK BIT(2) 137 123 #define LPDT_TX_PPI_SYNC_ENABLE BIT(2) ··· 147 129 #define T_CLK_PRE_CNT_MASK GENMASK(3, 0) 148 130 #define T_CLK_PRE_CNT(x) UPDATE(x, 3, 0) 149 131 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg10 */ 132 + #define T_CLK_POST_CNT_HI_MASK GENMASK(7, 6) 133 + #define T_CLK_POST_CNT_HI(x) UPDATE(x, 7, 6) 150 134 #define T_TA_GO_CNT_MASK GENMASK(5, 0) 151 135 #define T_TA_GO_CNT(x) UPDATE(x, 5, 0) 152 136 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg11 */ 137 + #define T_HS_EXIT_CNT_HI_MASK BIT(6) 138 + #define T_HS_EXIT_CNT_HI(x) UPDATE(x, 6, 6) 153 139 #define T_TA_SURE_CNT_MASK GENMASK(5, 0) 154 140 #define T_TA_SURE_CNT(x) UPDATE(x, 5, 0) 155 141 /* Clock/Data0/Data1/Data2/Data3 Lane Register Part: reg12 */ ··· 191 169 #define DSI_PHY_STATUS 0xb0 192 170 #define PHY_LOCK BIT(0) 193 171 172 + enum phy_max_rate { 173 + MAX_1GHZ, 174 + MAX_2_5GHZ, 175 + }; 176 + 177 + struct inno_video_phy_plat_data { 178 + const struct inno_mipi_dphy_timing *inno_mipi_dphy_timing_table; 179 + const unsigned int num_timings; 180 + enum phy_max_rate max_rate; 181 + }; 182 + 194 183 struct inno_dsidphy { 195 184 struct device *dev; 196 185 struct clk *ref_clk; 197 186 struct clk *pclk_phy; 198 187 struct clk *pclk_host; 188 + const struct inno_video_phy_plat_data *pdata; 199 189 void __iomem *phy_base; 200 190 void __iomem *host_base; 201 191 struct reset_control *rst; ··· 232 198 REGISTER_PART_DATA2_LANE, 233 199 REGISTER_PART_DATA3_LANE, 234 200 REGISTER_PART_LVDS, 201 + }; 202 + 203 + struct inno_mipi_dphy_timing { 204 + unsigned long rate; 205 + u8 lpx; 206 + u8 hs_prepare; 207 + u8 clk_lane_hs_zero; 208 + u8 data_lane_hs_zero; 209 + u8 hs_trail; 210 + }; 211 + 212 + static const 213 + struct inno_mipi_dphy_timing inno_mipi_dphy_timing_table_max_1ghz[] = { 214 + { 110000000, 0x0, 0x20, 0x16, 0x02, 0x22}, 215 + { 150000000, 0x0, 0x06, 0x16, 0x03, 0x45}, 216 + { 200000000, 0x0, 0x18, 0x17, 0x04, 0x0b}, 217 + { 250000000, 0x0, 0x05, 0x17, 0x05, 0x16}, 218 + { 300000000, 0x0, 0x51, 0x18, 0x06, 0x2c}, 219 + { 400000000, 0x0, 0x64, 0x19, 0x07, 0x33}, 220 + { 500000000, 0x0, 0x20, 0x1b, 0x07, 0x4e}, 221 + { 600000000, 0x0, 0x6a, 0x1d, 0x08, 0x3a}, 222 + { 700000000, 0x0, 0x3e, 0x1e, 0x08, 0x6a}, 223 + { 800000000, 0x0, 0x21, 0x1f, 0x09, 0x29}, 224 + {1000000000, 0x0, 0x09, 0x20, 0x09, 0x27}, 225 + }; 226 + 227 + static const 228 + struct inno_mipi_dphy_timing inno_mipi_dphy_timing_table_max_2_5ghz[] = { 229 + { 110000000, 0x02, 0x7f, 0x16, 0x02, 0x02}, 230 + { 150000000, 0x02, 0x7f, 0x16, 0x03, 0x02}, 231 + { 200000000, 0x02, 0x7f, 0x17, 0x04, 0x02}, 232 + { 250000000, 0x02, 0x7f, 0x17, 0x05, 0x04}, 233 + { 300000000, 0x02, 0x7f, 0x18, 0x06, 0x04}, 234 + { 400000000, 0x03, 0x7e, 0x19, 0x07, 0x04}, 235 + { 500000000, 0x03, 0x7c, 0x1b, 0x07, 0x08}, 236 + { 600000000, 0x03, 0x70, 0x1d, 0x08, 0x10}, 237 + { 700000000, 0x05, 0x40, 0x1e, 0x08, 0x30}, 238 + { 800000000, 0x05, 0x02, 0x1f, 0x09, 0x30}, 239 + {1000000000, 0x05, 0x08, 0x20, 0x09, 0x30}, 240 + {1200000000, 0x06, 0x03, 0x32, 0x14, 0x0f}, 241 + {1400000000, 0x09, 0x03, 0x32, 0x14, 0x0f}, 242 + {1600000000, 0x0d, 0x42, 0x36, 0x0e, 0x0f}, 243 + {1800000000, 0x0e, 0x47, 0x7a, 0x0e, 0x0f}, 244 + {2000000000, 0x11, 0x64, 0x7a, 0x0e, 0x0b}, 245 + {2200000000, 0x13, 0x64, 0x7e, 0x15, 0x0b}, 246 + {2400000000, 0x13, 0x33, 0x7f, 0x15, 0x6a}, 247 + {2500000000, 0x15, 0x54, 0x7f, 0x15, 0x6a}, 235 248 }; 236 249 237 250 static inline struct inno_dsidphy *hw_to_inno(struct clk_hw *hw) ··· 371 290 static void inno_dsidphy_mipi_mode_enable(struct inno_dsidphy *inno) 372 291 { 373 292 struct phy_configure_opts_mipi_dphy *cfg = &inno->dphy_cfg; 374 - const struct { 375 - unsigned long rate; 376 - u8 hs_prepare; 377 - u8 clk_lane_hs_zero; 378 - u8 data_lane_hs_zero; 379 - u8 hs_trail; 380 - } timings[] = { 381 - { 110000000, 0x20, 0x16, 0x02, 0x22}, 382 - { 150000000, 0x06, 0x16, 0x03, 0x45}, 383 - { 200000000, 0x18, 0x17, 0x04, 0x0b}, 384 - { 250000000, 0x05, 0x17, 0x05, 0x16}, 385 - { 300000000, 0x51, 0x18, 0x06, 0x2c}, 386 - { 400000000, 0x64, 0x19, 0x07, 0x33}, 387 - { 500000000, 0x20, 0x1b, 0x07, 0x4e}, 388 - { 600000000, 0x6a, 0x1d, 0x08, 0x3a}, 389 - { 700000000, 0x3e, 0x1e, 0x08, 0x6a}, 390 - { 800000000, 0x21, 0x1f, 0x09, 0x29}, 391 - {1000000000, 0x09, 0x20, 0x09, 0x27}, 392 - }; 293 + const struct inno_mipi_dphy_timing *timings; 393 294 u32 t_txbyteclkhs, t_txclkesc; 394 295 u32 txbyteclkhs, txclkesc, esc_clk_div; 395 296 u32 hs_exit, clk_post, clk_pre, wakeup, lpx, ta_go, ta_sure, ta_wait; 396 297 u32 hs_prepare, hs_trail, hs_zero, clk_lane_hs_zero, data_lane_hs_zero; 397 298 unsigned int i; 299 + 300 + timings = inno->pdata->inno_mipi_dphy_timing_table; 398 301 399 302 inno_dsidphy_pll_calc_rate(inno, cfg->hs_clk_rate); 400 303 ··· 392 327 REG_FBDIV_HI_MASK, REG_FBDIV_HI(inno->pll.fbdiv)); 393 328 phy_update_bits(inno, REGISTER_PART_ANALOG, 0x04, 394 329 REG_FBDIV_LO_MASK, REG_FBDIV_LO(inno->pll.fbdiv)); 330 + if (inno->pdata->max_rate == MAX_2_5GHZ) { 331 + phy_update_bits(inno, REGISTER_PART_ANALOG, 0x08, 332 + PLL_POST_DIV_ENABLE_MASK, PLL_POST_DIV_ENABLE); 333 + phy_update_bits(inno, REGISTER_PART_ANALOG, 0x0b, 334 + CLOCK_LANE_VOD_RANGE_SET_MASK, 335 + CLOCK_LANE_VOD_RANGE_SET(VOD_MAX_RANGE)); 336 + } 395 337 /* Enable PLL and LDO */ 396 338 phy_update_bits(inno, REGISTER_PART_ANALOG, 0x01, 397 339 REG_LDOPD_MASK | REG_PLLPD_MASK, ··· 440 368 clk_pre = DIV_ROUND_UP(cfg->clk_pre, BITS_PER_BYTE); 441 369 442 370 /* 443 - * The value of counter for HS Tlpx Time 444 - * Tlpx = Tpin_txbyteclkhs * (2 + value) 445 - */ 446 - lpx = DIV_ROUND_UP(cfg->lpx, t_txbyteclkhs); 447 - if (lpx >= 2) 448 - lpx -= 2; 449 - 450 - /* 451 371 * The value of counter for HS Tta-go 452 372 * Tta-go for turnaround 453 373 * Tta-go = Ttxclkesc * value ··· 458 394 */ 459 395 ta_wait = DIV_ROUND_UP(cfg->ta_get, t_txclkesc); 460 396 461 - for (i = 0; i < ARRAY_SIZE(timings); i++) 397 + for (i = 0; i < inno->pdata->num_timings; i++) 462 398 if (inno->pll.rate <= timings[i].rate) 463 399 break; 464 400 465 - if (i == ARRAY_SIZE(timings)) 401 + if (i == inno->pdata->num_timings) 466 402 --i; 403 + 404 + /* 405 + * The value of counter for HS Tlpx Time 406 + * Tlpx = Tpin_txbyteclkhs * (2 + value) 407 + */ 408 + if (inno->pdata->max_rate == MAX_1GHZ) { 409 + lpx = DIV_ROUND_UP(cfg->lpx, t_txbyteclkhs); 410 + if (lpx >= 2) 411 + lpx -= 2; 412 + } else 413 + lpx = timings[i].lpx; 467 414 468 415 hs_prepare = timings[i].hs_prepare; 469 416 hs_trail = timings[i].hs_trail; ··· 492 417 T_LPX_CNT(lpx)); 493 418 phy_update_bits(inno, i, 0x06, T_HS_PREPARE_CNT_MASK, 494 419 T_HS_PREPARE_CNT(hs_prepare)); 495 - phy_update_bits(inno, i, 0x07, T_HS_ZERO_CNT_MASK, 496 - T_HS_ZERO_CNT(hs_zero)); 420 + if (inno->pdata->max_rate == MAX_2_5GHZ) 421 + phy_update_bits(inno, i, 0x06, T_HS_ZERO_CNT_HI_MASK, 422 + T_HS_ZERO_CNT_HI(hs_zero >> 6)); 423 + phy_update_bits(inno, i, 0x07, T_HS_ZERO_CNT_LO_MASK, 424 + T_HS_ZERO_CNT_LO(hs_zero)); 497 425 phy_update_bits(inno, i, 0x08, T_HS_TRAIL_CNT_MASK, 498 426 T_HS_TRAIL_CNT(hs_trail)); 499 - phy_update_bits(inno, i, 0x09, T_HS_EXIT_CNT_MASK, 500 - T_HS_EXIT_CNT(hs_exit)); 501 - phy_update_bits(inno, i, 0x0a, T_CLK_POST_CNT_MASK, 502 - T_CLK_POST_CNT(clk_post)); 427 + if (inno->pdata->max_rate == MAX_2_5GHZ) 428 + phy_update_bits(inno, i, 0x11, T_HS_EXIT_CNT_HI_MASK, 429 + T_HS_EXIT_CNT_HI(hs_exit >> 5)); 430 + phy_update_bits(inno, i, 0x09, T_HS_EXIT_CNT_LO_MASK, 431 + T_HS_EXIT_CNT_LO(hs_exit)); 432 + if (inno->pdata->max_rate == MAX_2_5GHZ) 433 + phy_update_bits(inno, i, 0x10, T_CLK_POST_CNT_HI_MASK, 434 + T_CLK_POST_CNT_HI(clk_post >> 4)); 435 + phy_update_bits(inno, i, 0x0a, T_CLK_POST_CNT_LO_MASK, 436 + T_CLK_POST_CNT_LO(clk_post)); 503 437 phy_update_bits(inno, i, 0x0e, T_CLK_PRE_CNT_MASK, 504 438 T_CLK_PRE_CNT(clk_pre)); 505 439 phy_update_bits(inno, i, 0x0c, T_WAKEUP_CNT_HI_MASK, ··· 536 452 537 453 /* Sample clock reverse direction */ 538 454 phy_update_bits(inno, REGISTER_PART_ANALOG, 0x08, 539 - SAMPLE_CLOCK_DIRECTION_MASK, 540 - SAMPLE_CLOCK_DIRECTION_REVERSE); 455 + SAMPLE_CLOCK_DIRECTION_MASK | LOWFRE_EN_MASK, 456 + SAMPLE_CLOCK_DIRECTION_REVERSE | 457 + PLL_OUTPUT_FREQUENCY_DIV_BY_1); 541 458 542 459 /* Select LVDS mode */ 543 460 phy_update_bits(inno, REGISTER_PART_LVDS, 0x03, ··· 557 472 LVDS_PLL_POWER_ON | LVDS_BANDGAP_POWER_ON); 558 473 559 474 msleep(20); 475 + 476 + /* Select PLL mode */ 477 + phy_update_bits(inno, REGISTER_PART_ANALOG, 0x1e, 478 + PLL_MODE_SEL_MASK, PLL_MODE_SEL_LVDS_MODE); 560 479 561 480 /* Reset LVDS digital logic */ 562 481 phy_update_bits(inno, REGISTER_PART_LVDS, 0x00, ··· 681 592 .owner = THIS_MODULE, 682 593 }; 683 594 595 + static const struct inno_video_phy_plat_data max_1ghz_video_phy_plat_data = { 596 + .inno_mipi_dphy_timing_table = inno_mipi_dphy_timing_table_max_1ghz, 597 + .num_timings = ARRAY_SIZE(inno_mipi_dphy_timing_table_max_1ghz), 598 + .max_rate = MAX_1GHZ, 599 + }; 600 + 601 + static const struct inno_video_phy_plat_data max_2_5ghz_video_phy_plat_data = { 602 + .inno_mipi_dphy_timing_table = inno_mipi_dphy_timing_table_max_2_5ghz, 603 + .num_timings = ARRAY_SIZE(inno_mipi_dphy_timing_table_max_2_5ghz), 604 + .max_rate = MAX_2_5GHZ, 605 + }; 606 + 684 607 static int inno_dsidphy_probe(struct platform_device *pdev) 685 608 { 686 609 struct device *dev = &pdev->dev; ··· 706 605 return -ENOMEM; 707 606 708 607 inno->dev = dev; 608 + inno->pdata = of_device_get_match_data(inno->dev); 709 609 platform_set_drvdata(pdev, inno); 710 610 711 611 inno->phy_base = devm_platform_ioremap_resource(pdev, 0); ··· 765 663 } 766 664 767 665 static const struct of_device_id inno_dsidphy_of_match[] = { 768 - { .compatible = "rockchip,px30-dsi-dphy", }, 769 - { .compatible = "rockchip,rk3128-dsi-dphy", }, 770 - { .compatible = "rockchip,rk3368-dsi-dphy", }, 666 + { 667 + .compatible = "rockchip,px30-dsi-dphy", 668 + .data = &max_1ghz_video_phy_plat_data, 669 + }, { 670 + .compatible = "rockchip,rk3128-dsi-dphy", 671 + .data = &max_1ghz_video_phy_plat_data, 672 + }, { 673 + .compatible = "rockchip,rk3368-dsi-dphy", 674 + .data = &max_1ghz_video_phy_plat_data, 675 + }, { 676 + .compatible = "rockchip,rk3568-dsi-dphy", 677 + .data = &max_2_5ghz_video_phy_plat_data, 678 + }, 771 679 {} 772 680 }; 773 681 MODULE_DEVICE_TABLE(of, inno_dsidphy_of_match);
+6 -4
drivers/phy/rockchip/phy-rockchip-inno-usb2.c
··· 1124 1124 struct rockchip_usb2phy_port *rport, 1125 1125 struct device_node *child_np) 1126 1126 { 1127 - int ret; 1127 + int ret, id; 1128 1128 1129 1129 rport->port_id = USB2PHY_PORT_OTG; 1130 1130 rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; ··· 1162 1162 1163 1163 ret = devm_extcon_register_notifier(rphy->dev, rphy->edev, 1164 1164 EXTCON_USB_HOST, &rport->event_nb); 1165 - if (ret) 1165 + if (ret) { 1166 1166 dev_err(rphy->dev, "register USB HOST notifier failed\n"); 1167 + goto out; 1168 + } 1167 1169 1168 1170 if (!of_property_read_bool(rphy->dev->of_node, "extcon")) { 1169 1171 /* do initial sync of usb state */ 1170 - ret = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); 1171 - extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !ret); 1172 + id = property_enabled(rphy->grf, &rport->port_cfg->utmi_id); 1173 + extcon_set_state_sync(rphy->edev, EXTCON_USB_HOST, !id); 1172 1174 } 1173 1175 } 1174 1176
+322
drivers/phy/rockchip/phy-rockchip-snps-pcie3.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Rockchip PCIE3.0 phy driver 4 + * 5 + * Copyright (C) 2022 Rockchip Electronics Co., Ltd. 6 + */ 7 + 8 + #include <linux/clk.h> 9 + #include <linux/delay.h> 10 + #include <linux/io.h> 11 + #include <linux/iopoll.h> 12 + #include <linux/kernel.h> 13 + #include <linux/mfd/syscon.h> 14 + #include <linux/module.h> 15 + #include <linux/of_device.h> 16 + #include <linux/phy/pcie.h> 17 + #include <linux/phy/phy.h> 18 + #include <linux/regmap.h> 19 + #include <linux/reset.h> 20 + 21 + /* Register for RK3568 */ 22 + #define GRF_PCIE30PHY_CON1 0x4 23 + #define GRF_PCIE30PHY_CON6 0x18 24 + #define GRF_PCIE30PHY_CON9 0x24 25 + #define GRF_PCIE30PHY_DA_OCM (BIT(15) | BIT(31)) 26 + #define GRF_PCIE30PHY_STATUS0 0x80 27 + #define GRF_PCIE30PHY_WR_EN (0xf << 16) 28 + #define SRAM_INIT_DONE(reg) (reg & BIT(14)) 29 + 30 + #define RK3568_BIFURCATION_LANE_0_1 BIT(0) 31 + 32 + /* Register for RK3588 */ 33 + #define PHP_GRF_PCIESEL_CON 0x100 34 + #define RK3588_PCIE3PHY_GRF_CMN_CON0 0x0 35 + #define RK3588_PCIE3PHY_GRF_PHY0_STATUS1 0x904 36 + #define RK3588_PCIE3PHY_GRF_PHY1_STATUS1 0xa04 37 + #define RK3588_SRAM_INIT_DONE(reg) (reg & BIT(0)) 38 + 39 + #define RK3588_BIFURCATION_LANE_0_1 BIT(0) 40 + #define RK3588_BIFURCATION_LANE_2_3 BIT(1) 41 + #define RK3588_LANE_AGGREGATION BIT(2) 42 + 43 + struct rockchip_p3phy_ops; 44 + 45 + struct rockchip_p3phy_priv { 46 + const struct rockchip_p3phy_ops *ops; 47 + void __iomem *mmio; 48 + /* mode: RC, EP */ 49 + int mode; 50 + /* pcie30_phymode: Aggregation, Bifurcation */ 51 + int pcie30_phymode; 52 + struct regmap *phy_grf; 53 + struct regmap *pipe_grf; 54 + struct reset_control *p30phy; 55 + struct phy *phy; 56 + struct clk_bulk_data *clks; 57 + int num_clks; 58 + int num_lanes; 59 + u32 lanes[4]; 60 + }; 61 + 62 + struct rockchip_p3phy_ops { 63 + int (*phy_init)(struct rockchip_p3phy_priv *priv); 64 + }; 65 + 66 + static int rockchip_p3phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) 67 + { 68 + struct rockchip_p3phy_priv *priv = phy_get_drvdata(phy); 69 + 70 + /* Actually We don't care EP/RC mode, but just record it */ 71 + switch (submode) { 72 + case PHY_MODE_PCIE_RC: 73 + priv->mode = PHY_MODE_PCIE_RC; 74 + break; 75 + case PHY_MODE_PCIE_EP: 76 + priv->mode = PHY_MODE_PCIE_EP; 77 + break; 78 + default: 79 + dev_err(&phy->dev, "%s, invalid mode\n", __func__); 80 + return -EINVAL; 81 + } 82 + 83 + return 0; 84 + } 85 + 86 + static int rockchip_p3phy_rk3568_init(struct rockchip_p3phy_priv *priv) 87 + { 88 + struct phy *phy = priv->phy; 89 + bool bifurcation = false; 90 + int ret; 91 + u32 reg; 92 + 93 + /* Deassert PCIe PMA output clamp mode */ 94 + regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON9, GRF_PCIE30PHY_DA_OCM); 95 + 96 + for (int i = 0; i < priv->num_lanes; i++) { 97 + dev_info(&phy->dev, "lane number %d, val %d\n", i, priv->lanes[i]); 98 + if (priv->lanes[i] > 1) 99 + bifurcation = true; 100 + } 101 + 102 + /* Set bifurcation if needed, and it doesn't care RC/EP */ 103 + if (bifurcation) { 104 + dev_info(&phy->dev, "bifurcation enabled\n"); 105 + regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON6, 106 + GRF_PCIE30PHY_WR_EN | RK3568_BIFURCATION_LANE_0_1); 107 + regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON1, 108 + GRF_PCIE30PHY_DA_OCM); 109 + } else { 110 + dev_dbg(&phy->dev, "bifurcation disabled\n"); 111 + regmap_write(priv->phy_grf, GRF_PCIE30PHY_CON6, 112 + GRF_PCIE30PHY_WR_EN & ~RK3568_BIFURCATION_LANE_0_1); 113 + } 114 + 115 + reset_control_deassert(priv->p30phy); 116 + 117 + ret = regmap_read_poll_timeout(priv->phy_grf, 118 + GRF_PCIE30PHY_STATUS0, 119 + reg, SRAM_INIT_DONE(reg), 120 + 0, 500); 121 + if (ret) 122 + dev_err(&priv->phy->dev, "%s: lock failed 0x%x, check input refclk and power supply\n", 123 + __func__, reg); 124 + return ret; 125 + } 126 + 127 + static const struct rockchip_p3phy_ops rk3568_ops = { 128 + .phy_init = rockchip_p3phy_rk3568_init, 129 + }; 130 + 131 + static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv) 132 + { 133 + u32 reg = 0; 134 + u8 mode = 0; 135 + int ret; 136 + 137 + /* Deassert PCIe PMA output clamp mode */ 138 + regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, BIT(8) | BIT(24)); 139 + 140 + /* Set bifurcation if needed */ 141 + for (int i = 0; i < priv->num_lanes; i++) { 142 + if (!priv->lanes[i]) 143 + mode |= (BIT(i) << 3); 144 + 145 + if (priv->lanes[i] > 1) 146 + mode |= (BIT(i) >> 1); 147 + } 148 + 149 + if (!mode) 150 + reg = RK3588_LANE_AGGREGATION; 151 + else { 152 + if (mode & (BIT(0) | BIT(1))) 153 + reg |= RK3588_BIFURCATION_LANE_0_1; 154 + 155 + if (mode & (BIT(2) | BIT(3))) 156 + reg |= RK3588_BIFURCATION_LANE_2_3; 157 + } 158 + 159 + regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, (0x7<<16) | reg); 160 + 161 + /* Set pcie1ln_sel in PHP_GRF_PCIESEL_CON */ 162 + if (!IS_ERR(priv->pipe_grf)) { 163 + reg = (mode & (BIT(6) | BIT(7))) >> 6; 164 + if (reg) 165 + regmap_write(priv->pipe_grf, PHP_GRF_PCIESEL_CON, 166 + (reg << 16) | reg); 167 + } 168 + 169 + reset_control_deassert(priv->p30phy); 170 + 171 + ret = regmap_read_poll_timeout(priv->phy_grf, 172 + RK3588_PCIE3PHY_GRF_PHY0_STATUS1, 173 + reg, RK3588_SRAM_INIT_DONE(reg), 174 + 0, 500); 175 + ret |= regmap_read_poll_timeout(priv->phy_grf, 176 + RK3588_PCIE3PHY_GRF_PHY1_STATUS1, 177 + reg, RK3588_SRAM_INIT_DONE(reg), 178 + 0, 500); 179 + if (ret) 180 + dev_err(&priv->phy->dev, "lock failed 0x%x, check input refclk and power supply\n", 181 + reg); 182 + return ret; 183 + } 184 + 185 + static const struct rockchip_p3phy_ops rk3588_ops = { 186 + .phy_init = rockchip_p3phy_rk3588_init, 187 + }; 188 + 189 + static int rochchip_p3phy_init(struct phy *phy) 190 + { 191 + struct rockchip_p3phy_priv *priv = phy_get_drvdata(phy); 192 + int ret; 193 + 194 + ret = clk_bulk_prepare_enable(priv->num_clks, priv->clks); 195 + if (ret) { 196 + dev_err(&priv->phy->dev, "failed to enable PCIe bulk clks %d\n", ret); 197 + return ret; 198 + } 199 + 200 + reset_control_assert(priv->p30phy); 201 + udelay(1); 202 + 203 + if (priv->ops->phy_init) { 204 + ret = priv->ops->phy_init(priv); 205 + if (ret) 206 + clk_bulk_disable_unprepare(priv->num_clks, priv->clks); 207 + } 208 + 209 + return ret; 210 + } 211 + 212 + static int rochchip_p3phy_exit(struct phy *phy) 213 + { 214 + struct rockchip_p3phy_priv *priv = phy_get_drvdata(phy); 215 + 216 + clk_bulk_disable_unprepare(priv->num_clks, priv->clks); 217 + reset_control_assert(priv->p30phy); 218 + return 0; 219 + } 220 + 221 + static const struct phy_ops rochchip_p3phy_ops = { 222 + .init = rochchip_p3phy_init, 223 + .exit = rochchip_p3phy_exit, 224 + .set_mode = rockchip_p3phy_set_mode, 225 + .owner = THIS_MODULE, 226 + }; 227 + 228 + static int rockchip_p3phy_probe(struct platform_device *pdev) 229 + { 230 + struct phy_provider *phy_provider; 231 + struct device *dev = &pdev->dev; 232 + struct rockchip_p3phy_priv *priv; 233 + struct device_node *np = dev->of_node; 234 + int ret; 235 + 236 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 237 + if (!priv) 238 + return -ENOMEM; 239 + 240 + priv->mmio = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); 241 + if (IS_ERR(priv->mmio)) { 242 + ret = PTR_ERR(priv->mmio); 243 + return ret; 244 + } 245 + 246 + priv->ops = of_device_get_match_data(&pdev->dev); 247 + if (!priv->ops) { 248 + dev_err(dev, "no of match data provided\n"); 249 + return -EINVAL; 250 + } 251 + 252 + priv->phy_grf = syscon_regmap_lookup_by_phandle(np, "rockchip,phy-grf"); 253 + if (IS_ERR(priv->phy_grf)) { 254 + dev_err(dev, "failed to find rockchip,phy_grf regmap\n"); 255 + return PTR_ERR(priv->phy_grf); 256 + } 257 + 258 + if (of_device_is_compatible(np, "rockchip,rk3588-pcie3-phy")) { 259 + priv->pipe_grf = 260 + syscon_regmap_lookup_by_phandle(dev->of_node, 261 + "rockchip,pipe-grf"); 262 + if (IS_ERR(priv->pipe_grf)) 263 + dev_info(dev, "failed to find rockchip,pipe_grf regmap\n"); 264 + } else { 265 + priv->pipe_grf = NULL; 266 + } 267 + 268 + priv->num_lanes = of_property_read_variable_u32_array(dev->of_node, "data-lanes", 269 + priv->lanes, 2, 270 + ARRAY_SIZE(priv->lanes)); 271 + 272 + /* if no data-lanes assume aggregation */ 273 + if (priv->num_lanes == -EINVAL) { 274 + dev_dbg(dev, "no data-lanes property found\n"); 275 + priv->num_lanes = 1; 276 + priv->lanes[0] = 1; 277 + } else if (priv->num_lanes < 0) { 278 + dev_err(dev, "failed to read data-lanes property %d\n", priv->num_lanes); 279 + return priv->num_lanes; 280 + } 281 + 282 + priv->phy = devm_phy_create(dev, NULL, &rochchip_p3phy_ops); 283 + if (IS_ERR(priv->phy)) { 284 + dev_err(dev, "failed to create combphy\n"); 285 + return PTR_ERR(priv->phy); 286 + } 287 + 288 + priv->p30phy = devm_reset_control_get_optional_exclusive(dev, "phy"); 289 + if (IS_ERR(priv->p30phy)) { 290 + return dev_err_probe(dev, PTR_ERR(priv->p30phy), 291 + "failed to get phy reset control\n"); 292 + } 293 + if (!priv->p30phy) 294 + dev_info(dev, "no phy reset control specified\n"); 295 + 296 + priv->num_clks = devm_clk_bulk_get_all(dev, &priv->clks); 297 + if (priv->num_clks < 1) 298 + return -ENODEV; 299 + 300 + dev_set_drvdata(dev, priv); 301 + phy_set_drvdata(priv->phy, priv); 302 + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 303 + return PTR_ERR_OR_ZERO(phy_provider); 304 + } 305 + 306 + static const struct of_device_id rockchip_p3phy_of_match[] = { 307 + { .compatible = "rockchip,rk3568-pcie3-phy", .data = &rk3568_ops }, 308 + { .compatible = "rockchip,rk3588-pcie3-phy", .data = &rk3588_ops }, 309 + { }, 310 + }; 311 + MODULE_DEVICE_TABLE(of, rockchip_p3phy_of_match); 312 + 313 + static struct platform_driver rockchip_p3phy_driver = { 314 + .probe = rockchip_p3phy_probe, 315 + .driver = { 316 + .name = "rockchip-snps-pcie3-phy", 317 + .of_match_table = rockchip_p3phy_of_match, 318 + }, 319 + }; 320 + module_platform_driver(rockchip_p3phy_driver); 321 + MODULE_DESCRIPTION("Rockchip Synopsys PCIe 3.0 PHY driver"); 322 + MODULE_LICENSE("GPL");
+12
drivers/phy/sunplus/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + config PHY_SUNPLUS_USB 4 + tristate "Sunplus SP7021 USB 2.0 PHY driver" 5 + depends on OF && (SOC_SP7021 || COMPILE_TEST) 6 + select GENERIC_PHY 7 + help 8 + Enable this to support the USB 2.0 PHY on Sunplus SP7021 9 + SoC. The USB 2.0 PHY controller supports battery charger 10 + and synchronous signals, various power down modes including 11 + operating, partial and suspend modes, and high-speed, 12 + full-speed and low-speed data transfer.
+2
drivers/phy/sunplus/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + obj-$(CONFIG_PHY_SUNPLUS_USB) += phy-sunplus-usb2.o
+296
drivers/phy/sunplus/phy-sunplus-usb2.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + /* 4 + * Sunplus SP7021 USB 2.0 phy driver 5 + * 6 + * Copyright (C) 2022 Sunplus Technology Inc., All rights reserved. 7 + * 8 + * Note 1 : non-posted write command for the registers accesses of 9 + * Sunplus SP7021. 10 + * 11 + */ 12 + 13 + #include <linux/bitfield.h> 14 + #include <linux/clk.h> 15 + #include <linux/delay.h> 16 + #include <linux/io.h> 17 + #include <linux/module.h> 18 + #include <linux/nvmem-consumer.h> 19 + #include <linux/of_platform.h> 20 + #include <linux/phy/phy.h> 21 + #include <linux/platform_device.h> 22 + #include <linux/reset.h> 23 + 24 + #define HIGH_MASK_BITS GENMASK(31, 16) 25 + #define LOW_MASK_BITS GENMASK(15, 0) 26 + #define OTP_DISC_LEVEL_DEFAULT 0xd 27 + 28 + /* GROUP UPHY */ 29 + #define CONFIG1 0x4 30 + #define J_HS_TX_PWRSAV BIT(5) 31 + #define CONFIG3 0xc 32 + #define J_FORCE_DISC_ON BIT(5) 33 + #define J_DEBUG_CTRL_ADDR_MACRO BIT(0) 34 + #define CONFIG7 0x1c 35 + #define J_DISC 0X1f 36 + #define CONFIG9 0x24 37 + #define J_ECO_PATH BIT(6) 38 + #define CONFIG16 0x40 39 + #define J_TBCWAIT_MASK GENMASK(6, 5) 40 + #define J_TBCWAIT_1P1_MS FIELD_PREP(J_TBCWAIT_MASK, 0) 41 + #define J_TVDM_SRC_DIS_MASK GENMASK(4, 3) 42 + #define J_TVDM_SRC_DIS_8P2_MS FIELD_PREP(J_TVDM_SRC_DIS_MASK, 3) 43 + #define J_TVDM_SRC_EN_MASK GENMASK(2, 1) 44 + #define J_TVDM_SRC_EN_1P6_MS FIELD_PREP(J_TVDM_SRC_EN_MASK, 0) 45 + #define J_BC_EN BIT(0) 46 + #define CONFIG17 0x44 47 + #define IBG_TRIM0_MASK GENMASK(7, 5) 48 + #define IBG_TRIM0_SSLVHT FIELD_PREP(IBG_TRIM0_MASK, 4) 49 + #define J_VDATREE_TRIM_MASK GENMASK(4, 1) 50 + #define J_VDATREE_TRIM_DEFAULT FIELD_PREP(J_VDATREE_TRIM_MASK, 9) 51 + #define CONFIG23 0x5c 52 + #define PROB_MASK GENMASK(5, 3) 53 + #define PROB FIELD_PREP(PROB_MASK, 7) 54 + 55 + /* GROUP MOON4 */ 56 + #define UPHY_CONTROL0 0x0 57 + #define UPHY_CONTROL1 0x4 58 + #define UPHY_CONTROL2 0x8 59 + #define MO1_UPHY_RX_CLK_SEL BIT(6) 60 + #define MASK_MO1_UPHY_RX_CLK_SEL BIT(6 + 16) 61 + #define UPHY_CONTROL3 0xc 62 + #define MO1_UPHY_PLL_POWER_OFF_SEL BIT(7) 63 + #define MASK_MO1_UPHY_PLL_POWER_OFF_SEL BIT(7 + 16) 64 + #define MO1_UPHY_PLL_POWER_OFF BIT(3) 65 + #define MASK_UPHY_PLL_POWER_OFF BIT(3 + 16) 66 + 67 + struct sp_usbphy { 68 + struct device *dev; 69 + struct resource *phy_res_mem; 70 + struct resource *moon4_res_mem; 71 + struct reset_control *rstc; 72 + struct clk *phy_clk; 73 + void __iomem *phy_regs; 74 + void __iomem *moon4_regs; 75 + u32 disc_vol_addr_off; 76 + }; 77 + 78 + static int update_disc_vol(struct sp_usbphy *usbphy) 79 + { 80 + struct nvmem_cell *cell; 81 + char *disc_name = "disc_vol"; 82 + ssize_t otp_l = 0; 83 + char *otp_v; 84 + u32 val, set; 85 + 86 + cell = nvmem_cell_get(usbphy->dev, disc_name); 87 + if (IS_ERR_OR_NULL(cell)) { 88 + if (PTR_ERR(cell) == -EPROBE_DEFER) 89 + return -EPROBE_DEFER; 90 + } 91 + 92 + otp_v = nvmem_cell_read(cell, &otp_l); 93 + nvmem_cell_put(cell); 94 + 95 + if (!IS_ERR(otp_v)) { 96 + set = *(otp_v + 1); 97 + set = (set << (sizeof(char) * 8)) | *otp_v; 98 + set = (set >> usbphy->disc_vol_addr_off) & J_DISC; 99 + } 100 + 101 + if (IS_ERR(otp_v) || set == 0) 102 + set = OTP_DISC_LEVEL_DEFAULT; 103 + 104 + val = readl(usbphy->phy_regs + CONFIG7); 105 + val = (val & ~J_DISC) | set; 106 + writel(val, usbphy->phy_regs + CONFIG7); 107 + 108 + return 0; 109 + } 110 + 111 + static int sp_uphy_init(struct phy *phy) 112 + { 113 + struct sp_usbphy *usbphy = phy_get_drvdata(phy); 114 + u32 val; 115 + int ret; 116 + 117 + ret = clk_prepare_enable(usbphy->phy_clk); 118 + if (ret) 119 + goto err_clk; 120 + 121 + ret = reset_control_deassert(usbphy->rstc); 122 + if (ret) 123 + goto err_reset; 124 + 125 + /* Default value modification */ 126 + writel(HIGH_MASK_BITS | 0x4002, usbphy->moon4_regs + UPHY_CONTROL0); 127 + writel(HIGH_MASK_BITS | 0x8747, usbphy->moon4_regs + UPHY_CONTROL1); 128 + 129 + /* disconnect voltage */ 130 + ret = update_disc_vol(usbphy); 131 + if (ret < 0) 132 + return ret; 133 + 134 + /* board uphy 0 internal register modification for tid certification */ 135 + val = readl(usbphy->phy_regs + CONFIG9); 136 + val &= ~(J_ECO_PATH); 137 + writel(val, usbphy->phy_regs + CONFIG9); 138 + 139 + val = readl(usbphy->phy_regs + CONFIG1); 140 + val &= ~(J_HS_TX_PWRSAV); 141 + writel(val, usbphy->phy_regs + CONFIG1); 142 + 143 + val = readl(usbphy->phy_regs + CONFIG23); 144 + val = (val & ~PROB) | PROB; 145 + writel(val, usbphy->phy_regs + CONFIG23); 146 + 147 + /* port 0 uphy clk fix */ 148 + writel(MASK_MO1_UPHY_RX_CLK_SEL | MO1_UPHY_RX_CLK_SEL, 149 + usbphy->moon4_regs + UPHY_CONTROL2); 150 + 151 + /* battery charger */ 152 + writel(J_TBCWAIT_1P1_MS | J_TVDM_SRC_DIS_8P2_MS | J_TVDM_SRC_EN_1P6_MS | J_BC_EN, 153 + usbphy->phy_regs + CONFIG16); 154 + writel(IBG_TRIM0_SSLVHT | J_VDATREE_TRIM_DEFAULT, usbphy->phy_regs + CONFIG17); 155 + 156 + /* chirp mode */ 157 + writel(J_FORCE_DISC_ON | J_DEBUG_CTRL_ADDR_MACRO, usbphy->phy_regs + CONFIG3); 158 + 159 + return 0; 160 + 161 + err_reset: 162 + reset_control_assert(usbphy->rstc); 163 + err_clk: 164 + clk_disable_unprepare(usbphy->phy_clk); 165 + 166 + return ret; 167 + } 168 + 169 + static int sp_uphy_power_on(struct phy *phy) 170 + { 171 + struct sp_usbphy *usbphy = phy_get_drvdata(phy); 172 + u32 pll_pwr_on, pll_pwr_off; 173 + 174 + /* PLL power off/on twice */ 175 + pll_pwr_off = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) 176 + | MO1_UPHY_PLL_POWER_OFF_SEL | MO1_UPHY_PLL_POWER_OFF; 177 + pll_pwr_on = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) 178 + | MO1_UPHY_PLL_POWER_OFF_SEL; 179 + 180 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | pll_pwr_off, 181 + usbphy->moon4_regs + UPHY_CONTROL3); 182 + mdelay(1); 183 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | pll_pwr_on, 184 + usbphy->moon4_regs + UPHY_CONTROL3); 185 + mdelay(1); 186 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | pll_pwr_off, 187 + usbphy->moon4_regs + UPHY_CONTROL3); 188 + mdelay(1); 189 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | pll_pwr_on, 190 + usbphy->moon4_regs + UPHY_CONTROL3); 191 + mdelay(1); 192 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | 0x0, 193 + usbphy->moon4_regs + UPHY_CONTROL3); 194 + 195 + return 0; 196 + } 197 + 198 + static int sp_uphy_power_off(struct phy *phy) 199 + { 200 + struct sp_usbphy *usbphy = phy_get_drvdata(phy); 201 + u32 pll_pwr_off; 202 + 203 + pll_pwr_off = (readl(usbphy->moon4_regs + UPHY_CONTROL3) & ~LOW_MASK_BITS) 204 + | MO1_UPHY_PLL_POWER_OFF_SEL | MO1_UPHY_PLL_POWER_OFF; 205 + 206 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | pll_pwr_off, 207 + usbphy->moon4_regs + UPHY_CONTROL3); 208 + mdelay(1); 209 + writel(MASK_MO1_UPHY_PLL_POWER_OFF_SEL | MASK_UPHY_PLL_POWER_OFF | 0x0, 210 + usbphy->moon4_regs + UPHY_CONTROL3); 211 + 212 + return 0; 213 + } 214 + 215 + static int sp_uphy_exit(struct phy *phy) 216 + { 217 + struct sp_usbphy *usbphy = phy_get_drvdata(phy); 218 + 219 + reset_control_assert(usbphy->rstc); 220 + clk_disable_unprepare(usbphy->phy_clk); 221 + 222 + return 0; 223 + } 224 + 225 + static const struct phy_ops sp_uphy_ops = { 226 + .init = sp_uphy_init, 227 + .power_on = sp_uphy_power_on, 228 + .power_off = sp_uphy_power_off, 229 + .exit = sp_uphy_exit, 230 + }; 231 + 232 + static const struct of_device_id sp_uphy_dt_ids[] = { 233 + {.compatible = "sunplus,sp7021-usb2-phy", }, 234 + { } 235 + }; 236 + MODULE_DEVICE_TABLE(of, sp_uphy_dt_ids); 237 + 238 + static int sp_usb_phy_probe(struct platform_device *pdev) 239 + { 240 + struct sp_usbphy *usbphy; 241 + struct phy_provider *phy_provider; 242 + struct phy *phy; 243 + int ret; 244 + 245 + usbphy = devm_kzalloc(&pdev->dev, sizeof(*usbphy), GFP_KERNEL); 246 + if (!usbphy) 247 + return -ENOMEM; 248 + 249 + usbphy->dev = &pdev->dev; 250 + 251 + usbphy->phy_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); 252 + usbphy->phy_regs = devm_ioremap_resource(&pdev->dev, usbphy->phy_res_mem); 253 + if (IS_ERR(usbphy->phy_regs)) 254 + return PTR_ERR(usbphy->phy_regs); 255 + 256 + usbphy->moon4_res_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "moon4"); 257 + usbphy->moon4_regs = devm_ioremap(&pdev->dev, usbphy->moon4_res_mem->start, 258 + resource_size(usbphy->moon4_res_mem)); 259 + if (IS_ERR(usbphy->moon4_regs)) 260 + return PTR_ERR(usbphy->moon4_regs); 261 + 262 + usbphy->phy_clk = devm_clk_get(&pdev->dev, NULL); 263 + if (IS_ERR(usbphy->phy_clk)) 264 + return PTR_ERR(usbphy->phy_clk); 265 + 266 + usbphy->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); 267 + if (IS_ERR(usbphy->rstc)) 268 + return PTR_ERR(usbphy->rstc); 269 + 270 + of_property_read_u32(pdev->dev.of_node, "sunplus,disc-vol-addr-off", 271 + &usbphy->disc_vol_addr_off); 272 + 273 + phy = devm_phy_create(&pdev->dev, NULL, &sp_uphy_ops); 274 + if (IS_ERR(phy)) { 275 + ret = -PTR_ERR(phy); 276 + return ret; 277 + } 278 + 279 + phy_set_drvdata(phy, usbphy); 280 + phy_provider = devm_of_phy_provider_register(&pdev->dev, of_phy_simple_xlate); 281 + 282 + return PTR_ERR_OR_ZERO(phy_provider); 283 + } 284 + 285 + static struct platform_driver sunplus_usb_phy_driver = { 286 + .probe = sp_usb_phy_probe, 287 + .driver = { 288 + .name = "sunplus-usb2-phy", 289 + .of_match_table = sp_uphy_dt_ids, 290 + }, 291 + }; 292 + module_platform_driver(sunplus_usb_phy_driver); 293 + 294 + MODULE_AUTHOR("Vincent Shih <vincent.shih@sunplus.com>"); 295 + MODULE_DESCRIPTION("Sunplus USB 2.0 phy driver"); 296 + MODULE_LICENSE("GPL");
+3 -6
drivers/phy/tegra/xusb-tegra186.c
··· 1381 1381 return -ENOMEM; 1382 1382 1383 1383 err = tegra_fuse_readl(TEGRA_FUSE_SKU_CALIB_0, &value); 1384 - if (err) { 1385 - if (err != -EPROBE_DEFER) 1386 - dev_err(dev, "failed to read calibration fuse: %d\n", 1387 - err); 1388 - return err; 1389 - } 1384 + if (err) 1385 + return dev_err_probe(dev, err, 1386 + "failed to read calibration fuse\n"); 1390 1387 1391 1388 dev_dbg(dev, "FUSE_USB_CALIB_0 %#x\n", value); 1392 1389
+2 -1
drivers/phy/tegra/xusb.c
··· 656 656 struct usb_role_switch_desc role_sx_desc = { 657 657 .fwnode = dev_fwnode(&port->dev), 658 658 .set = tegra_xusb_role_sw_set, 659 + .allow_userspace_control = true, 659 660 }; 660 661 int err = 0; 661 662 ··· 1271 1270 1272 1271 padctl->soc->ops->remove(padctl); 1273 1272 1274 - return err; 1273 + return 0; 1275 1274 } 1276 1275 1277 1276 static __maybe_unused int tegra_xusb_padctl_suspend_noirq(struct device *dev)
+44 -3
drivers/phy/ti/phy-gmii-sel.c
··· 22 22 #define AM33XX_GMII_SEL_MODE_RMII 1 23 23 #define AM33XX_GMII_SEL_MODE_RGMII 2 24 24 25 + /* J72xx SoC specific definitions for the CONTROL port */ 26 + #define J72XX_GMII_SEL_MODE_QSGMII 4 27 + #define J72XX_GMII_SEL_MODE_QSGMII_SUB 6 28 + 29 + #define PHY_GMII_PORT(n) BIT((n) - 1) 30 + 25 31 enum { 26 32 PHY_GMII_SEL_PORT_MODE = 0, 27 33 PHY_GMII_SEL_RGMII_ID_MODE, ··· 49 43 u32 features; 50 44 const struct reg_field (*regfields)[PHY_GMII_SEL_LAST]; 51 45 bool use_of_data; 46 + u64 extra_modes; 52 47 }; 53 48 54 49 struct phy_gmii_sel_priv { ··· 60 53 struct phy_gmii_sel_phy_priv *if_phys; 61 54 u32 num_ports; 62 55 u32 reg_offset; 56 + u32 qsgmii_main_ports; 63 57 }; 64 58 65 59 static int phy_gmii_sel_mode(struct phy *phy, enum phy_mode mode, int submode) ··· 96 88 gmii_sel_mode = AM33XX_GMII_SEL_MODE_MII; 97 89 break; 98 90 91 + case PHY_INTERFACE_MODE_QSGMII: 92 + if (!(soc_data->extra_modes & BIT(PHY_INTERFACE_MODE_QSGMII))) 93 + goto unsupported; 94 + if (if_phy->priv->qsgmii_main_ports & BIT(if_phy->id - 1)) 95 + gmii_sel_mode = J72XX_GMII_SEL_MODE_QSGMII; 96 + else 97 + gmii_sel_mode = J72XX_GMII_SEL_MODE_QSGMII_SUB; 98 + break; 99 + 99 100 default: 100 - dev_warn(dev, "port%u: unsupported mode: \"%s\"\n", 101 - if_phy->id, phy_modes(submode)); 102 - return -EINVAL; 101 + goto unsupported; 103 102 } 104 103 105 104 if_phy->phy_if_mode = submode; ··· 138 123 } 139 124 140 125 return 0; 126 + 127 + unsupported: 128 + dev_warn(dev, "port%u: unsupported mode: \"%s\"\n", 129 + if_phy->id, phy_modes(submode)); 130 + return -EINVAL; 141 131 } 142 132 143 133 static const ··· 208 188 .regfields = phy_gmii_sel_fields_am654, 209 189 }; 210 190 191 + static const 192 + struct phy_gmii_sel_soc_data phy_gmii_sel_cpsw5g_soc_j7200 = { 193 + .use_of_data = true, 194 + .regfields = phy_gmii_sel_fields_am654, 195 + .extra_modes = BIT(PHY_INTERFACE_MODE_QSGMII), 196 + }; 197 + 211 198 static const struct of_device_id phy_gmii_sel_id_table[] = { 212 199 { 213 200 .compatible = "ti,am3352-phy-gmii-sel", ··· 235 208 { 236 209 .compatible = "ti,am654-phy-gmii-sel", 237 210 .data = &phy_gmii_sel_soc_am654, 211 + }, 212 + { 213 + .compatible = "ti,j7200-cpsw5g-phy-gmii-sel", 214 + .data = &phy_gmii_sel_cpsw5g_soc_j7200, 238 215 }, 239 216 {} 240 217 }; ··· 381 350 struct device_node *node = dev->of_node; 382 351 const struct of_device_id *of_id; 383 352 struct phy_gmii_sel_priv *priv; 353 + u32 main_ports = 1; 384 354 int ret; 385 355 386 356 of_id = of_match_node(phy_gmii_sel_id_table, pdev->dev.of_node); ··· 395 363 priv->dev = &pdev->dev; 396 364 priv->soc_data = of_id->data; 397 365 priv->num_ports = priv->soc_data->num_ports; 366 + of_property_read_u32(node, "ti,qsgmii-main-ports", &main_ports); 367 + /* 368 + * Ensure that main_ports is within bounds. If the property 369 + * ti,qsgmii-main-ports is not mentioned, or the value mentioned 370 + * is out of bounds, default to 1. 371 + */ 372 + if (main_ports < 1 || main_ports > 4) 373 + main_ports = 1; 374 + priv->qsgmii_main_ports = PHY_GMII_PORT(main_ports); 398 375 399 376 priv->regmap = syscon_node_to_regmap(node->parent); 400 377 if (IS_ERR(priv->regmap)) {
+231 -17
drivers/phy/ti/phy-j721e-wiz.c
··· 15 15 #include <linux/gpio/consumer.h> 16 16 #include <linux/io.h> 17 17 #include <linux/module.h> 18 + #include <linux/mfd/syscon.h> 18 19 #include <linux/mux/consumer.h> 19 20 #include <linux/of_address.h> 20 21 #include <linux/of_platform.h> ··· 24 23 #include <linux/regmap.h> 25 24 #include <linux/reset-controller.h> 26 25 26 + #define REF_CLK_19_2MHZ 19200000 27 + #define REF_CLK_25MHZ 25000000 28 + #define REF_CLK_100MHZ 100000000 29 + #define REF_CLK_156_25MHZ 156250000 30 + 31 + /* SCM offsets */ 32 + #define SERDES_SUP_CTRL 0x4400 33 + 34 + /* SERDES offsets */ 27 35 #define WIZ_SERDES_CTRL 0x404 28 36 #define WIZ_SERDES_TOP_CTRL 0x408 29 37 #define WIZ_SERDES_RST 0x40c ··· 95 85 REG_FIELD(WIZ_SERDES_TOP_CTRL, 26, 27); 96 86 static const struct reg_field pma_cmn_refclk1_dig_div = 97 87 REG_FIELD(WIZ_SERDES_TOP_CTRL, 24, 25); 88 + 89 + static const struct reg_field sup_pll0_refclk_mux_sel = 90 + REG_FIELD(SERDES_SUP_CTRL, 0, 1); 91 + static const struct reg_field sup_pll1_refclk_mux_sel = 92 + REG_FIELD(SERDES_SUP_CTRL, 2, 3); 93 + static const struct reg_field sup_pma_cmn_refclk1_int_mode = 94 + REG_FIELD(SERDES_SUP_CTRL, 4, 5); 95 + static const struct reg_field sup_refclk_dig_sel_10g = 96 + REG_FIELD(SERDES_SUP_CTRL, 6, 7); 97 + static const struct reg_field sup_legacy_clk_override = 98 + REG_FIELD(SERDES_SUP_CTRL, 8, 8); 99 + 98 100 static const char * const output_clk_names[] = { 99 101 [TI_WIZ_PLL0_REFCLK] = "pll0-refclk", 100 102 [TI_WIZ_PLL1_REFCLK] = "pll1-refclk", ··· 151 129 REG_FIELD(WIZ_LANECTL(3), 22, 23), 152 130 }; 153 131 132 + static const struct reg_field p0_mac_src_sel[WIZ_MAX_LANES] = { 133 + REG_FIELD(WIZ_LANECTL(0), 20, 21), 134 + REG_FIELD(WIZ_LANECTL(1), 20, 21), 135 + REG_FIELD(WIZ_LANECTL(2), 20, 21), 136 + REG_FIELD(WIZ_LANECTL(3), 20, 21), 137 + }; 138 + 139 + static const struct reg_field p0_rxfclk_sel[WIZ_MAX_LANES] = { 140 + REG_FIELD(WIZ_LANECTL(0), 6, 7), 141 + REG_FIELD(WIZ_LANECTL(1), 6, 7), 142 + REG_FIELD(WIZ_LANECTL(2), 6, 7), 143 + REG_FIELD(WIZ_LANECTL(3), 6, 7), 144 + }; 145 + 146 + static const struct reg_field p0_refclk_sel[WIZ_MAX_LANES] = { 147 + REG_FIELD(WIZ_LANECTL(0), 18, 19), 148 + REG_FIELD(WIZ_LANECTL(1), 18, 19), 149 + REG_FIELD(WIZ_LANECTL(2), 18, 19), 150 + REG_FIELD(WIZ_LANECTL(3), 18, 19), 151 + }; 154 152 static const struct reg_field p_mac_div_sel0[WIZ_MAX_LANES] = { 155 153 REG_FIELD(WIZ_LANEDIV(0), 16, 22), 156 154 REG_FIELD(WIZ_LANEDIV(1), 16, 22), ··· 270 228 }, 271 229 }; 272 230 231 + static const struct wiz_clk_mux_sel clk_mux_sel_10g_2_refclk[] = { 232 + { 233 + .num_parents = 3, 234 + .parents = { WIZ_CORE_REFCLK, WIZ_CORE_REFCLK1, WIZ_EXT_REFCLK }, 235 + .table = { 2, 3, 0 }, 236 + .node_name = "pll0-refclk", 237 + }, 238 + { 239 + .num_parents = 3, 240 + .parents = { WIZ_CORE_REFCLK, WIZ_CORE_REFCLK1, WIZ_EXT_REFCLK }, 241 + .table = { 2, 3, 0 }, 242 + .node_name = "pll1-refclk", 243 + }, 244 + { 245 + .num_parents = 3, 246 + .parents = { WIZ_CORE_REFCLK, WIZ_CORE_REFCLK1, WIZ_EXT_REFCLK }, 247 + .table = { 2, 3, 0 }, 248 + .node_name = "refclk-dig", 249 + }, 250 + }; 251 + 273 252 static const struct clk_div_table clk_div_table[] = { 274 253 { .val = 0, .div = 1, }, 275 254 { .val = 1, .div = 2, }, ··· 312 249 313 250 enum wiz_type { 314 251 J721E_WIZ_16G, 315 - J721E_WIZ_10G, 252 + J721E_WIZ_10G, /* Also for J7200 SR1.0 */ 316 253 AM64_WIZ_10G, 254 + J7200_WIZ_10G, /* J7200 SR2.0 */ 317 255 }; 318 256 319 257 struct wiz_data { 320 258 enum wiz_type type; 259 + const struct reg_field *pll0_refclk_mux_sel; 260 + const struct reg_field *pll1_refclk_mux_sel; 321 261 const struct reg_field *refclk_dig_sel; 322 262 const struct reg_field *pma_cmn_refclk1_dig_div; 263 + const struct reg_field *pma_cmn_refclk1_int_mode; 323 264 const struct wiz_clk_mux_sel *clk_mux_sel; 324 265 unsigned int clk_div_sel_num; 325 266 }; ··· 333 266 334 267 struct wiz { 335 268 struct regmap *regmap; 269 + struct regmap *scm_regmap; 336 270 enum wiz_type type; 337 271 const struct wiz_clk_mux_sel *clk_mux_sel; 338 272 const struct wiz_clk_div_sel *clk_div_sel; ··· 348 280 struct regmap_field *p_mac_div_sel0[WIZ_MAX_LANES]; 349 281 struct regmap_field *p_mac_div_sel1[WIZ_MAX_LANES]; 350 282 struct regmap_field *p0_fullrt_div[WIZ_MAX_LANES]; 283 + struct regmap_field *p0_mac_src_sel[WIZ_MAX_LANES]; 284 + struct regmap_field *p0_rxfclk_sel[WIZ_MAX_LANES]; 285 + struct regmap_field *p0_refclk_sel[WIZ_MAX_LANES]; 351 286 struct regmap_field *pma_cmn_refclk_int_mode; 287 + struct regmap_field *pma_cmn_refclk1_int_mode; 352 288 struct regmap_field *pma_cmn_refclk_mode; 353 289 struct regmap_field *pma_cmn_refclk_dig_div; 354 290 struct regmap_field *pma_cmn_refclk1_dig_div; 355 291 struct regmap_field *mux_sel_field[WIZ_MUX_NUM_CLOCKS]; 356 292 struct regmap_field *div_sel_field[WIZ_DIV_NUM_CLOCKS_16G]; 357 293 struct regmap_field *typec_ln10_swap; 294 + struct regmap_field *sup_legacy_clk_override; 358 295 359 296 struct device *dev; 360 297 u32 num_lanes; ··· 398 325 int i; 399 326 400 327 for (i = 0; i < num_lanes; i++) { 401 - if (wiz->lane_phy_type[i] == PHY_TYPE_QSGMII) { 328 + if (wiz->lane_phy_type[i] == PHY_TYPE_SGMII || 329 + wiz->lane_phy_type[i] == PHY_TYPE_QSGMII || 330 + wiz->lane_phy_type[i] == PHY_TYPE_USXGMII) { 402 331 ret = regmap_field_write(wiz->p_mac_div_sel0[i], 1); 403 332 if (ret) 404 333 return ret; ··· 428 353 mode = LANE_MODE_GEN2; 429 354 else 430 355 continue; 356 + 357 + if (wiz->lane_phy_type[i] == PHY_TYPE_USXGMII) { 358 + ret = regmap_field_write(wiz->p0_mac_src_sel[i], 0x3); 359 + ret = regmap_field_write(wiz->p0_rxfclk_sel[i], 0x3); 360 + ret = regmap_field_write(wiz->p0_refclk_sel[i], 0x3); 361 + mode = LANE_MODE_GEN1; 362 + } 431 363 432 364 ret = regmap_field_write(wiz->p_standard_mode[i], mode); 433 365 if (ret) ··· 498 416 static int wiz_regfield_init(struct wiz *wiz) 499 417 { 500 418 struct regmap *regmap = wiz->regmap; 419 + struct regmap *scm_regmap = wiz->regmap; /* updated later to scm_regmap if applicable */ 501 420 int num_lanes = wiz->num_lanes; 502 421 struct device *dev = wiz->dev; 503 422 const struct wiz_data *data = wiz->data; ··· 548 465 } 549 466 } 550 467 468 + if (wiz->scm_regmap) { 469 + scm_regmap = wiz->scm_regmap; 470 + wiz->sup_legacy_clk_override = 471 + devm_regmap_field_alloc(dev, scm_regmap, sup_legacy_clk_override); 472 + if (IS_ERR(wiz->sup_legacy_clk_override)) { 473 + dev_err(dev, "SUP_LEGACY_CLK_OVERRIDE reg field init failed\n"); 474 + return PTR_ERR(wiz->sup_legacy_clk_override); 475 + } 476 + } 477 + 551 478 wiz->mux_sel_field[PLL0_REFCLK] = 552 - devm_regmap_field_alloc(dev, regmap, pll0_refclk_mux_sel); 479 + devm_regmap_field_alloc(dev, scm_regmap, *data->pll0_refclk_mux_sel); 553 480 if (IS_ERR(wiz->mux_sel_field[PLL0_REFCLK])) { 554 481 dev_err(dev, "PLL0_REFCLK_SEL reg field init failed\n"); 555 482 return PTR_ERR(wiz->mux_sel_field[PLL0_REFCLK]); 556 483 } 557 484 558 485 wiz->mux_sel_field[PLL1_REFCLK] = 559 - devm_regmap_field_alloc(dev, regmap, pll1_refclk_mux_sel); 486 + devm_regmap_field_alloc(dev, scm_regmap, *data->pll1_refclk_mux_sel); 560 487 if (IS_ERR(wiz->mux_sel_field[PLL1_REFCLK])) { 561 488 dev_err(dev, "PLL1_REFCLK_SEL reg field init failed\n"); 562 489 return PTR_ERR(wiz->mux_sel_field[PLL1_REFCLK]); 563 490 } 564 491 565 - wiz->mux_sel_field[REFCLK_DIG] = devm_regmap_field_alloc(dev, regmap, 492 + wiz->mux_sel_field[REFCLK_DIG] = devm_regmap_field_alloc(dev, scm_regmap, 566 493 *data->refclk_dig_sel); 567 494 if (IS_ERR(wiz->mux_sel_field[REFCLK_DIG])) { 568 495 dev_err(dev, "REFCLK_DIG_SEL reg field init failed\n"); 569 496 return PTR_ERR(wiz->mux_sel_field[REFCLK_DIG]); 497 + } 498 + 499 + if (data->pma_cmn_refclk1_int_mode) { 500 + wiz->pma_cmn_refclk1_int_mode = 501 + devm_regmap_field_alloc(dev, scm_regmap, *data->pma_cmn_refclk1_int_mode); 502 + if (IS_ERR(wiz->pma_cmn_refclk1_int_mode)) { 503 + dev_err(dev, "PMA_CMN_REFCLK1_INT_MODE reg field init failed\n"); 504 + return PTR_ERR(wiz->pma_cmn_refclk1_int_mode); 505 + } 570 506 } 571 507 572 508 for (i = 0; i < num_lanes; i++) { ··· 623 521 if (IS_ERR(wiz->p0_fullrt_div[i])) { 624 522 dev_err(dev, "P%d_FULLRT_DIV reg field init failed\n", i); 625 523 return PTR_ERR(wiz->p0_fullrt_div[i]); 524 + } 525 + 526 + wiz->p0_mac_src_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_mac_src_sel[i]); 527 + if (IS_ERR(wiz->p0_mac_src_sel[i])) { 528 + dev_err(dev, "P%d_MAC_SRC_SEL reg field init failed\n", i); 529 + return PTR_ERR(wiz->p0_mac_src_sel[i]); 530 + } 531 + 532 + wiz->p0_rxfclk_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_rxfclk_sel[i]); 533 + if (IS_ERR(wiz->p0_rxfclk_sel[i])) { 534 + dev_err(dev, "P%d_RXFCLK_SEL reg field init failed\n", i); 535 + return PTR_ERR(wiz->p0_rxfclk_sel[i]); 536 + } 537 + 538 + wiz->p0_refclk_sel[i] = devm_regmap_field_alloc(dev, regmap, p0_refclk_sel[i]); 539 + if (IS_ERR(wiz->p0_refclk_sel[i])) { 540 + dev_err(dev, "P%d_REFCLK_SEL reg field init failed\n", i); 541 + return PTR_ERR(wiz->p0_refclk_sel[i]); 626 542 } 627 543 628 544 wiz->p_mac_div_sel0[i] = ··· 717 597 struct device *dev = wiz->dev; 718 598 struct clk_init_data *init; 719 599 struct clk *clk; 600 + char *clk_name; 601 + unsigned int sz; 720 602 721 603 wiz_phy_en_refclk = devm_kzalloc(dev, sizeof(*wiz_phy_en_refclk), GFP_KERNEL); 722 604 if (!wiz_phy_en_refclk) ··· 728 606 729 607 init->ops = &wiz_phy_en_refclk_ops; 730 608 init->flags = 0; 731 - init->name = output_clk_names[TI_WIZ_PHY_EN_REFCLK]; 609 + 610 + sz = strlen(dev_name(dev)) + strlen(output_clk_names[TI_WIZ_PHY_EN_REFCLK]) + 2; 611 + 612 + clk_name = kzalloc(sz, GFP_KERNEL); 613 + if (!clk_name) 614 + return -ENOMEM; 615 + 616 + snprintf(clk_name, sz, "%s_%s", dev_name(dev), output_clk_names[TI_WIZ_PHY_EN_REFCLK]); 617 + init->name = clk_name; 732 618 733 619 wiz_phy_en_refclk->phy_en_refclk = wiz->phy_en_refclk; 734 620 wiz_phy_en_refclk->hw.init = init; 735 621 736 622 clk = devm_clk_register(dev, &wiz_phy_en_refclk->hw); 623 + 624 + kfree(clk_name); 625 + 737 626 if (IS_ERR(clk)) 738 627 return PTR_ERR(clk); 739 628 ··· 989 856 struct device_node *clk_node; 990 857 int i; 991 858 992 - if (wiz->type == AM64_WIZ_10G) { 859 + switch (wiz->type) { 860 + case AM64_WIZ_10G: 861 + case J7200_WIZ_10G: 993 862 of_clk_del_provider(dev->of_node); 994 863 return; 864 + default: 865 + break; 995 866 } 996 867 997 868 for (i = 0; i < WIZ_MUX_NUM_CLOCKS; i++) { ··· 1021 884 int clk_index; 1022 885 int ret; 1023 886 int i; 1024 - 1025 - if (wiz->type != AM64_WIZ_10G) 1026 - return 0; 1027 887 1028 888 clk_index = TI_WIZ_PLL0_REFCLK; 1029 889 for (i = 0; i < WIZ_MUX_NUM_CLOCKS; i++, clk_index++) { ··· 1071 937 else 1072 938 regmap_field_write(wiz->pma_cmn_refclk_int_mode, 0x3); 1073 939 940 + switch (wiz->type) { 941 + case AM64_WIZ_10G: 942 + case J7200_WIZ_10G: 943 + switch (rate) { 944 + case REF_CLK_100MHZ: 945 + regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0x2); 946 + break; 947 + case REF_CLK_156_25MHZ: 948 + regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0x3); 949 + break; 950 + default: 951 + regmap_field_write(wiz->div_sel_field[CMN_REFCLK_DIG_DIV], 0); 952 + break; 953 + } 954 + break; 955 + default: 956 + break; 957 + } 958 + 959 + if (wiz->data->pma_cmn_refclk1_int_mode) { 960 + clk = devm_clk_get(dev, "core_ref1_clk"); 961 + if (IS_ERR(clk)) { 962 + dev_err(dev, "core_ref1_clk clock not found\n"); 963 + ret = PTR_ERR(clk); 964 + return ret; 965 + } 966 + wiz->input_clks[WIZ_CORE_REFCLK1] = clk; 967 + 968 + rate = clk_get_rate(clk); 969 + if (rate >= 100000000) 970 + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x1); 971 + else 972 + regmap_field_write(wiz->pma_cmn_refclk1_int_mode, 0x3); 973 + } 974 + 1074 975 clk = devm_clk_get(dev, "ext_ref_clk"); 1075 976 if (IS_ERR(clk)) { 1076 977 dev_err(dev, "ext_ref_clk clock not found\n"); ··· 1120 951 else 1121 952 regmap_field_write(wiz->pma_cmn_refclk_mode, 0x2); 1122 953 1123 - if (wiz->type == AM64_WIZ_10G) { 954 + switch (wiz->type) { 955 + case AM64_WIZ_10G: 956 + case J7200_WIZ_10G: 1124 957 ret = wiz_clock_register(wiz); 1125 958 if (ret) 1126 959 dev_err(dev, "Failed to register wiz clocks\n"); 1127 960 return ret; 961 + default: 962 + break; 1128 963 } 1129 964 1130 965 for (i = 0; i < WIZ_MUX_NUM_CLOCKS; i++) { ··· 1198 1025 1199 1026 static int wiz_phy_fullrt_div(struct wiz *wiz, int lane) 1200 1027 { 1201 - if (wiz->type != AM64_WIZ_10G) 1028 + switch (wiz->type) { 1029 + case AM64_WIZ_10G: 1030 + if (wiz->lane_phy_type[lane] == PHY_TYPE_PCIE) 1031 + return regmap_field_write(wiz->p0_fullrt_div[lane], 0x1); 1032 + break; 1033 + case J721E_WIZ_10G: 1034 + case J7200_WIZ_10G: 1035 + if (wiz->lane_phy_type[lane] == PHY_TYPE_SGMII) 1036 + return regmap_field_write(wiz->p0_fullrt_div[lane], 0x2); 1037 + break; 1038 + default: 1202 1039 return 0; 1203 - 1204 - if (wiz->lane_phy_type[lane] == PHY_TYPE_PCIE) 1205 - return regmap_field_write(wiz->p0_fullrt_div[lane], 0x1); 1206 - 1040 + } 1207 1041 return 0; 1208 1042 } 1209 1043 ··· 1263 1083 1264 1084 static struct wiz_data j721e_16g_data = { 1265 1085 .type = J721E_WIZ_16G, 1086 + .pll0_refclk_mux_sel = &pll0_refclk_mux_sel, 1087 + .pll1_refclk_mux_sel = &pll1_refclk_mux_sel, 1266 1088 .refclk_dig_sel = &refclk_dig_sel_16g, 1267 1089 .pma_cmn_refclk1_dig_div = &pma_cmn_refclk1_dig_div, 1268 1090 .clk_mux_sel = clk_mux_sel_16g, ··· 1273 1091 1274 1092 static struct wiz_data j721e_10g_data = { 1275 1093 .type = J721E_WIZ_10G, 1094 + .pll0_refclk_mux_sel = &pll0_refclk_mux_sel, 1095 + .pll1_refclk_mux_sel = &pll1_refclk_mux_sel, 1276 1096 .refclk_dig_sel = &refclk_dig_sel_10g, 1277 1097 .clk_mux_sel = clk_mux_sel_10g, 1278 1098 .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G, ··· 1282 1098 1283 1099 static struct wiz_data am64_10g_data = { 1284 1100 .type = AM64_WIZ_10G, 1101 + .pll0_refclk_mux_sel = &pll0_refclk_mux_sel, 1102 + .pll1_refclk_mux_sel = &pll1_refclk_mux_sel, 1285 1103 .refclk_dig_sel = &refclk_dig_sel_10g, 1286 1104 .clk_mux_sel = clk_mux_sel_10g, 1105 + .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G, 1106 + }; 1107 + 1108 + static struct wiz_data j7200_pg2_10g_data = { 1109 + .type = J7200_WIZ_10G, 1110 + .pll0_refclk_mux_sel = &sup_pll0_refclk_mux_sel, 1111 + .pll1_refclk_mux_sel = &sup_pll1_refclk_mux_sel, 1112 + .refclk_dig_sel = &sup_refclk_dig_sel_10g, 1113 + .pma_cmn_refclk1_int_mode = &sup_pma_cmn_refclk1_int_mode, 1114 + .clk_mux_sel = clk_mux_sel_10g_2_refclk, 1287 1115 .clk_div_sel_num = WIZ_DIV_NUM_CLOCKS_10G, 1288 1116 }; 1289 1117 ··· 1308 1112 }, 1309 1113 { 1310 1114 .compatible = "ti,am64-wiz-10g", .data = &am64_10g_data, 1115 + }, 1116 + { 1117 + .compatible = "ti,j7200-wiz-10g", .data = &j7200_pg2_10g_data, 1311 1118 }, 1312 1119 {} 1313 1120 }; ··· 1409 1210 goto err_addr_to_resource; 1410 1211 } 1411 1212 1213 + wiz->scm_regmap = syscon_regmap_lookup_by_phandle(node, "ti,scm"); 1214 + if (IS_ERR(wiz->scm_regmap)) { 1215 + if (wiz->type == J7200_WIZ_10G) { 1216 + dev_err(dev, "Couldn't get ti,scm regmap\n"); 1217 + ret = -ENODEV; 1218 + goto err_addr_to_resource; 1219 + } 1220 + 1221 + wiz->scm_regmap = NULL; 1222 + } 1223 + 1412 1224 ret = of_property_read_u32(node, "num-lanes", &num_lanes); 1413 1225 if (ret) { 1414 1226 dev_err(dev, "Failed to read num-lanes property\n"); ··· 1464 1254 1465 1255 ret = wiz_get_lane_phy_types(dev, wiz); 1466 1256 if (ret) 1467 - return ret; 1257 + goto err_addr_to_resource; 1468 1258 1469 1259 wiz->dev = dev; 1470 1260 wiz->regmap = regmap; ··· 1480 1270 dev_err(dev, "Failed to initialize regfields\n"); 1481 1271 goto err_addr_to_resource; 1482 1272 } 1273 + 1274 + /* Enable supplemental Control override if available */ 1275 + if (wiz->scm_regmap) 1276 + regmap_field_write(wiz->sup_legacy_clk_override, 1); 1483 1277 1484 1278 phy_reset_dev = &wiz->wiz_phy_reset_dev; 1485 1279 phy_reset_dev->dev = dev;
+1
include/dt-bindings/phy/phy.h
··· 22 22 #define PHY_TYPE_QSGMII 9 23 23 #define PHY_TYPE_DPHY 10 24 24 #define PHY_TYPE_CPHY 11 25 + #define PHY_TYPE_USXGMII 12 25 26 26 27 #endif /* _DT_BINDINGS_PHY */
+12
include/linux/phy/pcie.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (c) 2022 Rockchip Electronics Co., Ltd. 4 + */ 5 + #ifndef __PHY_PCIE_H 6 + #define __PHY_PCIE_H 7 + 8 + #define PHY_MODE_PCIE_RC 20 9 + #define PHY_MODE_PCIE_EP 21 10 + #define PHY_MODE_PCIE_BIFURCATION 22 11 + 12 + #endif