History

Merge tag 'phy-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into usb-next

Kishon writes: phy: for 5.2 *) Add a new *release* phy_ops invoked when the consumer relinquishes PHY that can be used to undo the operation performed in xlate *) Add new driver to support USB2 PHY and shared USB3 + PCIE PHY in Amlogic G12A SoC Family. *) Add new driver to support for Broadcom's Stingray USB PHY (Type 1 has one super speed PHY and one high speed PHY, Type 2 has one high speed PHY) *) Add new driver to support USB PHY in hi3660 SoC of Hisilicon *) Add new driver to support UFS M-PHY in MediaTek SoC *) Add new driver to support XUSB pad controller in Tegra186 SoCs *) Add new driver to support SERDES in TI's AM654 platform *) Add support for generation 2 USB2 PHY and gneration 3 USB2 PHY in r8a77470 to phy-rcar-gen2.c and phy-rcar-gen3-usb2.c respectively *) Add support for PCIe QMP PHY support in msm8998 to phy-qcom-qmp.c *) Add support for SERDES6G in phy-ocelot-serdes.c *) Add support to set drive impedance from device tree in phy-rockchip-emmc.c *) Add support to power up/down the VBUS voltage rail in phy-fsl-imx8mq-usb.c *) Add support to shut off regulators that power UFS during system suspend *) Re-design phy-rcar-gen3-usb2.c to create separate PHY instances for each channel which helps to enable/disable interrupts for each instance independently *) Fix PCIe power up sequence to follow the TRM in order to ensure the DPLL & PHY operates correctly over the entire temperature range. *) Use devm_clk_get_optional to get optional clocks instead of adding custom error checks Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> * tag 'phy-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy: (51 commits) dt-bindings: phy-qcom-qmp: Tweak qcom,msm8998-qmp-ufs-phy dt-bindings: phy-qcom-qmp: Add qcom,msm8998-qmp-pcie-phy phy: Add usb phy support for hi3660 Soc of Hisilicon dt-bindings: phy: Add support for HiSilicon's hi3660 USB PHY scsi: phy: mediatek: fix typo in author's email address phy: ocelot-serdes: Add support for SERDES6G muxing phy: fsl-imx8mq-usb: add support for VBUS power control dt-bindings: phy-imx8mq-usb: add optional vbus supply regulator phy: qcom-qmp: Add msm8998 PCIe QMP PHY support phy: ti: am654-serdes: Support all clksel values phy: ti: Add a new SERDES driver for TI's AM654x SoC dt-bindings: phy: ti: Add dt binding documentation for SERDES in AM654x SoC phy: core: Invoke pm_runtime_get_*/pm_runtime_put_* before invoking reset callback phy: core: Add *release* phy_ops invoked when the consumer relinquishes PHY phy: phy-meson-gxl-usb2: get optional clock by devm_clk_get_optional() phy: socionext: get optional clock by devm_clk_get_optional() phy: qcom-qusb2: get optional clock by devm_clk_get_optional() phy: phy-mtk-tphy: get optional clock by devm_clk_get_optional() phy: renesas: rcar-gen3-usb2: enable/disable independent irqs phy: renesas: rcar-gen3-usb2: Use pdev's device pointer on dev_vdbg() ...

Greg Kroah-Hartman committed 7 years ago

Commit d30e4132 parents 1567d66 708310759 files · +4889 −367Browse files

Unified · Split

59 files
  1. Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt +32 −0
  2. Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.txt +3 −0
  3. Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt +22 −0
  4. Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt +22 −0
  5. Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.txt +9 −0
  6. Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt +26 −0
  7. Documentation/devicetree/bindings/phy/phy-mtk-ufs.txt +38 −0
  8. Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt +11 −3
  9. Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt +53 −4
  10. Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt +11 −3
  11. Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt +6 −2
  12. Documentation/devicetree/bindings/phy/ti,phy-am654-serdes.txt +82 −0
  13. Documentation/devicetree/bindings/ufs/ufs-qcom.txt +4 −1
  14. Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt +3 −0
  15. MAINTAINERS +13 −0
  16. drivers/phy/amlogic/Kconfig +22 −0
  17. drivers/phy/amlogic/Makefile +2 −0
  18. drivers/phy/amlogic/phy-meson-g12a-usb2.c +341 −0
  19. drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c +413 −0
  20. drivers/phy/amlogic/phy-meson-gxl-usb2.c +3 −8
  21. drivers/phy/broadcom/Kconfig +11 −0
  22. drivers/phy/broadcom/Makefile +1 −0
  23. drivers/phy/broadcom/phy-bcm-sr-usb.c +394 −0
  24. drivers/phy/freescale/phy-fsl-imx8mq-usb.c +12 −0
  25. drivers/phy/hisilicon/Kconfig +10 −0
  26. drivers/phy/hisilicon/Makefile +1 −0
  27. drivers/phy/hisilicon/phy-hi3660-usb3.c +233 −0
  28. drivers/phy/mediatek/Kconfig +10 −0
  29. drivers/phy/mediatek/Makefile +1 −0
  30. drivers/phy/mediatek/phy-mtk-tphy.c +3 −7
  31. drivers/phy/mediatek/phy-mtk-ufs.c +245 −0
  32. drivers/phy/mscc/phy-ocelot-serdes.c +238 −2
  33. drivers/phy/phy-core.c +11 −0
  34. drivers/phy/qualcomm/phy-qcom-qmp.c +165 −57
  35. drivers/phy/qualcomm/phy-qcom-qmp.h +12 −0
  36. drivers/phy/qualcomm/phy-qcom-qusb2.c +3 −8
  37. drivers/phy/qualcomm/phy-qcom-ufs-i.h +3 −2
  38. drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c +1 −24
  39. drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c +1 −24
  40. drivers/phy/qualcomm/phy-qcom-ufs.c +41 −16
  41. drivers/phy/renesas/Kconfig +1 −1
  42. drivers/phy/renesas/phy-rcar-gen2.c +118 −12
  43. drivers/phy/renesas/phy-rcar-gen3-usb2.c +198 −34
  44. drivers/phy/rockchip/phy-rockchip-emmc.c +28 −2
  45. drivers/phy/socionext/phy-uniphier-usb3hs.c +3 −7
  46. drivers/phy/socionext/phy-uniphier-usb3ss.c +3 −7
  47. drivers/phy/tegra/Makefile +1 −0
  48. drivers/phy/tegra/xusb-tegra186.c +899 −0
  49. drivers/phy/tegra/xusb.c +65 −2
  50. drivers/phy/tegra/xusb.h +35 −0
  51. drivers/phy/ti/Kconfig +12 −0
  52. drivers/phy/ti/Makefile +1 −0
  53. drivers/phy/ti/phy-am654-serdes.c +658 −0
  54. drivers/phy/ti/phy-ti-pipe3.c +265 −97
  55. drivers/scsi/ufs/Kconfig +1 −0
  56. drivers/scsi/ufs/ufs-qcom.c +70 −44
  57. drivers/scsi/ufs/ufs-qcom.h +4 −0
  58. include/dt-bindings/phy/phy-am654-serdes.h +13 −0
  59. include/linux/phy/phy.h +2 −0
Documentation/devicetree/bindings/phy/brcm,stingray-usb-phy.txt+32−0
@@ -0,0 +1,32 @@
1+Broadcom Stingray USB PHY
2+
3+Required properties:
4+ - compatible : should be one of the listed compatibles
5+ - "brcm,sr-usb-combo-phy" is combo PHY has two PHYs, one SS and one HS.
6+ - "brcm,sr-usb-hs-phy" is a single HS PHY.
7+ - reg: offset and length of the PHY blocks registers
8+ - #phy-cells:
9+ - Must be 1 for brcm,sr-usb-combo-phy as it expects one argument to indicate
10+ the PHY number of two PHYs. 0 for HS PHY and 1 for SS PHY.
11+ - Must be 0 for brcm,sr-usb-hs-phy.
12+
13+Refer to phy/phy-bindings.txt for the generic PHY binding properties
14+
15+Example:
16+ usbphy0: usb-phy@0 {
17+ compatible = "brcm,sr-usb-combo-phy";
18+ reg = <0x00000000 0x100>;
19+ #phy-cells = <1>;
20+ };
21+
22+ usbphy1: usb-phy@10000 {
23+ compatible = "brcm,sr-usb-combo-phy";
24+ reg = <0x00010000 0x100>,
25+ #phy-cells = <1>;
26+ };
27+
28+ usbphy2: usb-phy@20000 {
29+ compatible = "brcm,sr-usb-hs-phy";
30+ reg = <0x00020000 0x100>,
31+ #phy-cells = <0>;
32+ };
Documentation/devicetree/bindings/phy/fsl,imx8mq-usb-phy.txt+3−0
@@ -7,6 +7,9 @@ Required properties: · 6 unmodified lines
77 - clocks: phandles to the clocks for each clock listed in clock-names
88 - clock-names: must contain "phy"
99
10+Optional properties:
11+- vbus-supply: A phandle to the regulator for USB VBUS.
12+
1013 Example:
1114 usb3_phy0: phy@381f0040 {
1215 compatible = "fsl,imx8mq-usb-phy";
Documentation/devicetree/bindings/phy/meson-g12a-usb2-phy.txt+22−0
@@ -0,0 +1,22 @@
1+* Amlogic G12A USB2 PHY binding
2+
3+Required properties:
4+- compatible: Should be "amlogic,meson-g12a-usb2-phy"
5+- reg: The base address and length of the registers
6+- #phys-cells: must be 0 (see phy-bindings.txt in this directory)
7+- clocks: a phandle to the clock of this PHY
8+- clock-names: must be "xtal"
9+- resets: a phandle to the reset line of this PHY
10+- reset-names: must be "phy"
11+- phy-supply: see phy-bindings.txt in this directory
12+
13+Example:
14+ usb2_phy0: phy@36000 {
15+ compatible = "amlogic,g12a-usb2-phy";
16+ reg = <0x0 0x36000 0x0 0x2000>;
17+ clocks = <&xtal>;
18+ clock-names = "xtal";
19+ resets = <&reset RESET_USB_PHY21>;
20+ reset-names = "phy";
21+ #phy-cells = <0>;
22+ };
Documentation/devicetree/bindings/phy/meson-g12a-usb3-pcie-phy.txt+22−0
@@ -0,0 +1,22 @@
1+* Amlogic G12A USB3 + PCIE Combo PHY binding
2+
3+Required properties:
4+- compatible: Should be "amlogic,meson-g12a-usb3-pcie-phy"
5+- #phys-cells: must be 1. The cell number is used to select the phy mode
6+ as defined in <dt-bindings/phy/phy.h> between PHY_TYPE_USB3 and PHY_TYPE_PCIE
7+- reg: The base address and length of the registers
8+- clocks: a phandle to the 100MHz reference clock of this PHY
9+- clock-names: must be "ref_clk"
10+- resets: phandle to the reset lines for the PHY control
11+- reset-names: must be "phy"
12+
13+Example:
14+ usb3_pcie_phy: phy@46000 {
15+ compatible = "amlogic,g12a-usb3-pcie-phy";
16+ reg = <0x0 0x46000 0x0 0x2000>;
17+ clocks = <&clkc CLKID_PCIE_PLL>;
18+ clock-names = "ref_clk";
19+ resets = <&reset RESET_PCIE_PHY>;
20+ reset-names = "phy";
21+ #phy-cells = <1>;
22+ };
Documentation/devicetree/bindings/phy/nvidia,tegra124-xusb-padctl.txt+9−0
@@ -36,11 +36,20 @@ Required properties: · 35 unmodified lines
3636 - Tegra124: "nvidia,tegra124-xusb-padctl"
3737 - Tegra132: "nvidia,tegra132-xusb-padctl", "nvidia,tegra124-xusb-padctl"
3838 - Tegra210: "nvidia,tegra210-xusb-padctl"
39+ - Tegra186: "nvidia,tegra186-xusb-padctl"
3940 - reg: Physical base address and length of the controller's registers.
4041 - resets: Must contain an entry for each entry in reset-names.
4142 - reset-names: Must include the following entries:
4243 - "padctl"
4344
45+For Tegra186:
46+- avdd-pll-erefeut-supply: UPHY brick and reference clock as well as UTMI PHY
47+ power supply. Must supply 1.8 V.
48+- avdd-usb-supply: USB I/Os, VBUS, ID, REXT, D+/D- power supply. Must supply
49+ 3.3 V.
50+- vclamp-usb-supply: Bias rail for USB pad. Must supply 1.8 V.
51+- vddio-hsic-supply: HSIC PHY power supply. Must supply 1.2 V.
52+
4453
4554 Pad nodes:
4655 ==========
Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt+26−0
@@ -0,0 +1,26 @@
1+Hisilicon hi3660 USB PHY
2+-----------------------
3+
4+Required properties:
5+- compatible: should be "hisilicon,hi3660-usb-phy"
6+- #phy-cells: must be 0
7+- hisilicon,pericrg-syscon: phandle of syscon used to control phy.
8+- hisilicon,pctrl-syscon: phandle of syscon used to control phy.
9+- hisilicon,eye-diagram-param: parameter set for phy
10+Refer to phy/phy-bindings.txt for the generic PHY binding properties
11+
12+This is a subnode of usb3_otg_bc register node.
13+
14+Example:
15+ usb3_otg_bc: usb3_otg_bc@ff200000 {
16+ compatible = "syscon", "simple-mfd";
17+ reg = <0x0 0xff200000 0x0 0x1000>;
18+
19+ usb-phy {
20+ compatible = "hisilicon,hi3660-usb-phy";
21+ #phy-cells = <0>;
22+ hisilicon,pericrg-syscon = <&crg_ctrl>;
23+ hisilicon,pctrl-syscon = <&pctrl>;
24+ hisilicon,eye-diagram-param = <0x22466e4>;
25+ };
26+ };
Documentation/devicetree/bindings/phy/phy-mtk-ufs.txt+38−0
@@ -0,0 +1,38 @@
1+MediaTek Universal Flash Storage (UFS) M-PHY binding
2+--------------------------------------------------------
3+
4+UFS M-PHY nodes are defined to describe on-chip UFS M-PHY hardware macro.
5+Each UFS M-PHY node should have its own node.
6+
7+To bind UFS M-PHY with UFS host controller, the controller node should
8+contain a phandle reference to UFS M-PHY node.
9+
10+Required properties for UFS M-PHY nodes:
11+- compatible : Compatible list, contains the following controller:
12+ "mediatek,mt8183-ufsphy" for ufs phy
13+ persent on MT81xx chipsets.
14+- reg : Address and length of the UFS M-PHY register set.
15+- #phy-cells : This property shall be set to 0.
16+- clocks : List of phandle and clock specifier pairs.
17+- clock-names : List of clock input name strings sorted in the same
18+ order as the clocks property. Following clocks are
19+ mandatory.
20+ "unipro": Unipro core control clock.
21+ "mp": M-PHY core control clock.
22+
23+Example:
24+
25+ ufsphy: phy@11fa0000 {
26+ compatible = "mediatek,mt8183-ufsphy";
27+ reg = <0 0x11fa0000 0 0xc000>;
28+ #phy-cells = <0>;
29+
30+ clocks = <&infracfg_ao INFRACFG_AO_UNIPRO_SCK_CG>,
31+ <&infracfg_ao INFRACFG_AO_UFS_MP_SAP_BCLK_CG>;
32+ clock-names = "unipro", "mp";
33+ };
34+
35+ ufshci@11270000 {
36+ ...
37+ phys = <&ufsphy>;
38+ };
Documentation/devicetree/bindings/phy/qcom-qmp-phy.txt+11−3
@@ -11,6 +11,7 @@ Required properties: · 10 unmodified lines
1111 "qcom,msm8996-qmp-usb3-phy" for 14nm USB3 phy on msm8996,
1212 "qcom,msm8998-qmp-usb3-phy" for USB3 QMP V3 phy on msm8998,
1313 "qcom,msm8998-qmp-ufs-phy" for UFS QMP phy on msm8998,
14+ "qcom,msm8998-qmp-pcie-phy" for PCIe QMP phy on msm8998,
1415 "qcom,sdm845-qmp-usb3-phy" for USB3 QMP V3 phy on sdm845,
1516 "qcom,sdm845-qmp-usb3-uni-phy" for USB3 QMP V3 UNI phy on sdm845,
1617 "qcom,sdm845-qmp-ufs-phy" for UFS QMP phy on sdm845.
@@ -48,6 +49,8 @@ Required properties: · 31 unmodified lines
4849 "aux", "cfg_ahb", "ref".
4950 For "qcom,msm8998-qmp-ufs-phy" must contain:
5051 "ref", "ref_aux".
52+ For "qcom,msm8998-qmp-pcie-phy" must contain:
53+ "aux", "cfg_ahb", "ref".
5154 For "qcom,sdm845-qmp-usb3-phy" must contain:
5255 "aux", "cfg_ahb", "ref", "com_aux".
5356 For "qcom,sdm845-qmp-usb3-uni-phy" must contain:
@@ -59,7 +62,8 @@ Required properties: · 5 unmodified lines
5962 one for each entry in reset-names.
6063 - reset-names: "phy" for reset of phy block,
6164 "common" for phy common block reset,
62− "cfg" for phy's ahb cfg block reset.
65+ "cfg" for phy's ahb cfg block reset,
66+ "ufsphy" for the PHY reset in the UFS controller.
6367
6468 For "qcom,ipq8074-qmp-pcie-phy" must contain:
6569 "phy", "common".
@@ -69,12 +73,16 @@ Required properties: · 3 unmodified lines
6973 "phy", "common".
7074 For "qcom,msm8998-qmp-usb3-phy" must contain
7175 "phy", "common".
72− For "qcom,msm8998-qmp-ufs-phy": no resets are listed.
76+ For "qcom,msm8998-qmp-ufs-phy": must contain:
77+ "ufsphy".
78+ For "qcom,msm8998-qmp-pcie-phy" must contain:
79+ "phy", "common".
7380 For "qcom,sdm845-qmp-usb3-phy" must contain:
7481 "phy", "common".
7582 For "qcom,sdm845-qmp-usb3-uni-phy" must contain:
7683 "phy", "common".
77− For "qcom,sdm845-qmp-ufs-phy": no resets are listed.
84+ For "qcom,sdm845-qmp-ufs-phy": must contain:
85+ "ufsphy".
7886
7987 - vdda-phy-supply: Phandle to a regulator supply to PHY core block.
8088 - vdda-pll-supply: Phandle to 1.8V regulator supply to PHY refclk pll block.
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt+53−4
@@ -7,6 +7,7 @@ Required properties: · 6 unmodified lines
77 - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC.
88 "renesas,usb-phy-r8a7744" if the device is a part of R8A7744 SoC.
99 "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC.
10+ "renesas,usb-phy-r8a77470" if the device is a part of R8A77470 SoC.
1011 "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC.
1112 "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC.
1213 "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC.
@@ -30,7 +31,7 @@ channels. These subnodes must contain the following properties: · 17 unmodified lines
3031 - #phy-cells: see phy-bindings.txt in the same directory, must be <1>.
3132
3233 The phandle's argument in the PHY specifier is the USB controller selector for
33−the USB channel; see the selector meanings below:
34+the USB channel other than r8a77470 SoC; see the selector meanings below:
3435
3536 +-----------+---------------+---------------+
3637 |\ Selector | | |
@@ -41,6 +42,16 @@ the USB channel; see the selector meanings below: · 4 unmodified lines
4142 | 2 | PCI EHCI/OHCI | xHCI |
4243 +-----------+---------------+---------------+
4344
45+For r8a77470 SoC;see the selector meaning below:
46+
47++-----------+---------------+---------------+
48+|\ Selector | | |
49++ --------- + 0 | 1 |
50+| Channel \| | |
51++-----------+---------------+---------------+
52+| 0 | EHCI/OHCI | HS-USB |
53++-----------+---------------+---------------+
54+
4455 Example (Lager board):
4556
4657 usb-phy@e6590100 {
@@ -48,15 +59,53 @@ Example (Lager board): · 1 unmodified line
4859 reg = <0 0xe6590100 0 0x100>;
4960 #address-cells = <1>;
5061 #size-cells = <0>;
51− clocks = <&mstp7_clks R8A7790_CLK_HSUSB>;
62+ clocks = <&cpg CPG_MOD 704>;
5263 clock-names = "usbhs";
64+ power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
65+ resets = <&cpg 704>;
5366
54− usb-channel@0 {
67+ usb0: usb-channel@0 {
5568 reg = <0>;
5669 #phy-cells = <1>;
5770 };
58− usb-channel@2 {
71+ usb2: usb-channel@2 {
5972 reg = <2>;
6073 #phy-cells = <1>;
6174 };
6275 };
76+
77+Example (iWave RZ/G1C sbc):
78+
79+ usbphy0: usb-phy0@e6590100 {
80+ compatible = "renesas,usb-phy-r8a77470",
81+ "renesas,rcar-gen2-usb-phy";
82+ reg = <0 0xe6590100 0 0x100>;
83+ #address-cells = <1>;
84+ #size-cells = <0>;
85+ clocks = <&cpg CPG_MOD 704>;
86+ clock-names = "usbhs";
87+ power-domains = <&sysc R8A77470_PD_ALWAYS_ON>;
88+ resets = <&cpg 704>;
89+
90+ usb0: usb-channel@0 {
91+ reg = <0>;
92+ #phy-cells = <1>;
93+ };
94+ };
95+
96+ usbphy1: usb-phy@e6598100 {
97+ compatible = "renesas,usb-phy-r8a77470",
98+ "renesas,rcar-gen2-usb-phy";
99+ reg = <0 0xe6598100 0 0x100>;
100+ #address-cells = <1>;
101+ #size-cells = <0>;
102+ clocks = <&cpg CPG_MOD 706>;
103+ clock-names = "usbhs";
104+ power-domains = <&sysc R8A77470_PD_ALWAYS_ON>;
105+ resets = <&cpg 706>;
106+
107+ usb1: usb-channel@0 {
108+ reg = <0>;
109+ #phy-cells = <1>;
110+ };
111+ };
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt+11−3
@@ -1,10 +1,12 @@
11 * Renesas R-Car generation 3 USB 2.0 PHY
22
33 This file provides information on what the device node for the R-Car generation
4−3 and RZ/G2 USB 2.0 PHY contain.
4+3, RZ/G1C and RZ/G2 USB 2.0 PHY contain.
55
66 Required properties:
7−- compatible: "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1
7+- compatible: "renesas,usb2-phy-r8a77470" if the device is a part of an R8A77470
8+ SoC.
9+ "renesas,usb2-phy-r8a774a1" if the device is a part of an R8A774A1
810 SoC.
911 "renesas,usb2-phy-r8a774c0" if the device is a part of an R8A774C0
1012 SoC.
@@ -27,7 +29,13 @@ Required properties: · 16 unmodified lines
2729
2830 - reg: offset and length of the partial USB 2.0 Host register block.
2931 - clocks: clock phandle and specifier pair(s).
30−- #phy-cells: see phy-bindings.txt in the same directory, must be <0>.
32+- #phy-cells: see phy-bindings.txt in the same directory, must be <1> (and
33+ using <0> is deprecated).
34+
35+The phandle's argument in the PHY specifier is the INT_STATUS bit of controller:
36+- 1 = USBH_INTA (OHCI)
37+- 2 = USBH_INTB (EHCI)
38+- 3 = UCOM_INT (OTG and BC)
3139
3240 Optional properties:
3341 To use a USB channel where USB 2.0 Host and HSUSB (USB 2.0 Peripheral) are
Documentation/devicetree/bindings/phy/rockchip-emmc-phy.txt+6−2
@@ -7,12 +7,15 @@ Required properties: · 6 unmodified lines
77 - reg: PHY register address offset and length in "general
88 register files"
99
10−Optional clocks using the clock bindings (see ../clock/clock-bindings.txt),
11−specified by name:
10+Optional properties:
1211 - clock-names: Should contain "emmcclk". Although this is listed as optional
1312 (because most boards can get basic functionality without having
1413 access to it), it is strongly suggested.
14+ See ../clock/clock-bindings.txt for details.
1515 - clocks: Should have a phandle to the card clock exported by the SDHCI driver.
16+ - drive-impedance-ohm: Specifies the drive impedance in Ohm.
17+ Possible values are 33, 40, 50, 66 and 100.
18+ If not set, the default value of 50 will be applied.
1619
1720 Example:
1821
@@ -29,6 +32,7 @@ grf: syscon@ff770000 { · 10 unmodified lines
2932 reg = <0xf780 0x20>;
3033 clocks = <&sdhci>;
3134 clock-names = "emmcclk";
35+ drive-impedance-ohm = <50>;
3236 #phy-cells = <0>;
3337 };
3438 };
Documentation/devicetree/bindings/phy/ti,phy-am654-serdes.txt+82−0
@@ -0,0 +1,82 @@
1+TI AM654 SERDES
2+
3+Required properties:
4+ - compatible: Should be "ti,phy-am654-serdes"
5+ - reg : Address and length of the register set for the device.
6+ - #phy-cells: determine the number of cells that should be given in the
7+ phandle while referencing this phy. Should be "2". The 1st cell
8+ corresponds to the phy type (should be one of the types specified in
9+ include/dt-bindings/phy/phy.h) and the 2nd cell should be the serdes
10+ lane function.
11+ If SERDES0 is referenced 2nd cell should be:
12+ 0 - USB3
13+ 1 - PCIe0 Lane0
14+ 2 - ICSS2 SGMII Lane0
15+ If SERDES1 is referenced 2nd cell should be:
16+ 0 - PCIe1 Lane0
17+ 1 - PCIe0 Lane1
18+ 2 - ICSS2 SGMII Lane1
19+ - power-domains: As documented by the generic PM domain bindings in
20+ Documentation/devicetree/bindings/power/power_domain.txt.
21+ - clocks: List of clock-specifiers representing the input to the SERDES.
22+ Should have 3 items representing the left input clock, external
23+ reference clock and right input clock in that order.
24+ - clock-output-names: List of clock names for each of the clock outputs of
25+ SERDES. Should have 3 items for CMU reference clock,
26+ left output clock and right output clock in that order.
27+ - assigned-clocks: As defined in
28+ Documentation/devicetree/bindings/clock/clock-bindings.txt
29+ - assigned-clock-parents: As defined in
30+ Documentation/devicetree/bindings/clock/clock-bindings.txt
31+ - #clock-cells: Should be <1> to choose between the 3 output clocks.
32+ Defined in Documentation/devicetree/bindings/clock/clock-bindings.txt
33+
34+ The following macros are defined in dt-bindings/phy/phy-am654-serdes.h
35+ for selecting the correct reference clock. This can be used while
36+ specifying the clocks created by SERDES.
37+ => AM654_SERDES_CMU_REFCLK
38+ => AM654_SERDES_LO_REFCLK
39+ => AM654_SERDES_RO_REFCLK
40+
41+ - mux-controls: Phandle to the multiplexer that is used to select the lane
42+ function. See #phy-cells above to see the multiplex values.
43+
44+Example:
45+
46+Example for SERDES0 is given below. It has 3 clock inputs;
47+left input reference clock as indicated by <&k3_clks 153 4>, external
48+reference clock as indicated by <&k3_clks 153 1> and right input
49+reference clock as indicated by <&serdes1 AM654_SERDES_LO_REFCLK>. (The
50+right input of SERDES0 is connected to the left output of SERDES1).
51+
52+SERDES0 registers 3 clock outputs as indicated in clock-output-names. The
53+first refers to the CMU reference clock, second refers to the left output
54+reference clock and the third refers to the right output reference clock.
55+
56+The assigned-clocks and assigned-clock-parents is used here to set the
57+parent of left input reference clock to MAINHSDIV_CLKOUT4 and parent of
58+CMU reference clock to left input reference clock.
59+
60+serdes0: serdes@900000 {
61+ compatible = "ti,phy-am654-serdes";
62+ reg = <0x0 0x900000 0x0 0x2000>;
63+ reg-names = "serdes";
64+ #phy-cells = <2>;
65+ power-domains = <&k3_pds 153>;
66+ clocks = <&k3_clks 153 4>, <&k3_clks 153 1>,
67+ <&serdes1 AM654_SERDES_LO_REFCLK>;
68+ clock-output-names = "serdes0_cmu_refclk", "serdes0_lo_refclk",
69+ "serdes0_ro_refclk";
70+ assigned-clocks = <&k3_clks 153 4>, <&serdes0 AM654_SERDES_CMU_REFCLK>;
71+ assigned-clock-parents = <&k3_clks 153 8>, <&k3_clks 153 4>;
72+ ti,serdes-clk = <&serdes0_clk>;
73+ mux-controls = <&serdes_mux 0>;
74+ #clock-cells = <1>;
75+};
76+
77+Example for PCIe consumer node using the SERDES PHY specifier is given below.
78+&pcie0_rc {
79+ num-lanes = <2>;
80+ phys = <&serdes0 PHY_TYPE_PCIE 1>, <&serdes1 PHY_TYPE_PCIE 1>;
81+ phy-names = "pcie-phy0", "pcie-phy1";
82+};
Documentation/devicetree/bindings/ufs/ufs-qcom.txt+4−1
@@ -29,6 +29,7 @@ Optional properties: · 28 unmodified lines
2929 - vdda-pll-max-microamp : specifies max. load that can be drawn from pll supply
3030 - vddp-ref-clk-supply : phandle to UFS device ref_clk pad power supply
3131 - vddp-ref-clk-max-microamp : specifies max. load that can be drawn from this supply
32+- resets : specifies the PHY reset in the UFS controller
3233
3334 Example:
3435
@@ -51,9 +52,11 @@ Example: · 16 unmodified lines
5152 <&clock_gcc clk_ufs_phy_ldo>,
5253 <&clock_gcc clk_gcc_ufs_tx_cfg_clk>,
5354 <&clock_gcc clk_gcc_ufs_rx_cfg_clk>;
55+ resets = <&ufshc 0>;
5456 };
5557
56− ufshc@fc598000 {
58+ ufshc: ufshc@fc598000 {
59+ #reset-cells = <1>;
5760 ...
5861 phys = <&ufsphy1>;
5962 phy-names = "ufsphy";
Documentation/devicetree/bindings/ufs/ufshcd-pltfrm.txt+3−0
@@ -50,6 +50,8 @@ Optional properties: · 49 unmodified lines
5050 -lanes-per-direction : number of lanes available per direction - either 1 or 2.
5151 Note that it is assume same number of lanes is used both
5252 directions at once. If not specified, default is 2 lanes per direction.
53+- #reset-cells : Must be <1> for Qualcomm UFS controllers that expose
54+ PHY reset from the UFS controller.
5355 - resets : reset node register
5456 - reset-names : describe reset node register, the "rst" corresponds to reset the whole UFS IP.
5557
@@ -79,4 +81,5 @@ Example: · 23 unmodified lines
7981 reset-names = "rst";
8082 phys = <&ufsphy1>;
8183 phy-names = "ufsphy";
84+ #reset-cells = <1>;
8285 };
MAINTAINERS+13−0
@@ -15313,6 +15313,11 @@ M: Laxman Dewangan <ldewangan@nvidia.com> · 15312 unmodified lines
1531315313 S: Supported
1531415314 F: drivers/spi/spi-tegra*
1531515315
15316+TEGRA XUSB PADCTL DRIVER
15317+M: JC Kuo <jckuo@nvidia.com>
15318+S: Supported
15319+F: drivers/phy/tegra/xusb*
15320+
1531615321 TEHUTI ETHERNET DRIVER
1531715322 M: Andy Gospodarek <andy@greyhouse.net>
1531815323 L: netdev@vger.kernel.org
@@ -16083,6 +16088,14 @@ L: linux-usb@vger.kernel.org · 764 unmodified lines
1608316088 S: Maintained
1608416089 F: drivers/usb/roles/intel-xhci-usb-role-switch.c
1608516090
16091+USB IP DRIVER FOR HISILICON KIRIN
16092+M: Yu Chen <chenyu56@huawei.com>
16093+M: Binghui Wang <wangbinghui@hisilicon.com>
16094+L: linux-usb@vger.kernel.org
16095+S: Maintained
16096+F: Documentation/devicetree/bindings/phy/phy-hi3660-usb3.txt
16097+F: drivers/phy/hisilicon/phy-hi3660-usb3.c
16098+
1608616099 USB ISP116X DRIVER
1608716100 M: Olav Kongas <ok@artecdesign.ee>
1608816101 L: linux-usb@vger.kernel.org
drivers/phy/amlogic/Kconfig+22−0
@@ -36,3 +36,25 @@ config PHY_MESON_GXL_USB3 · 35 unmodified lines
3636 Enable this to support the Meson USB3 PHY and OTG detection
3737 IP block found in Meson GXL and GXM SoCs.
3838 If unsure, say N.
39+
40+config PHY_MESON_G12A_USB2
41+ tristate "Meson G12A USB2 PHY driver"
42+ default ARCH_MESON
43+ depends on OF && (ARCH_MESON || COMPILE_TEST)
44+ select GENERIC_PHY
45+ select REGMAP_MMIO
46+ help
47+ Enable this to support the Meson USB2 PHYs found in Meson
48+ G12A SoCs.
49+ If unsure, say N.
50+
51+config PHY_MESON_G12A_USB3_PCIE
52+ tristate "Meson G12A USB3+PCIE Combo PHY driver"
53+ default ARCH_MESON
54+ depends on OF && (ARCH_MESON || COMPILE_TEST)
55+ select GENERIC_PHY
56+ select REGMAP_MMIO
57+ help
58+ Enable this to support the Meson USB3 + PCIE Combo PHY found
59+ in Meson G12A SoCs.
60+ If unsure, say N.
drivers/phy/amlogic/Makefile+2−0
@@ -1,3 +1,5 @@
11 obj-$(CONFIG_PHY_MESON8B_USB2) += phy-meson8b-usb2.o
22 obj-$(CONFIG_PHY_MESON_GXL_USB2) += phy-meson-gxl-usb2.o
3+obj-$(CONFIG_PHY_MESON_G12A_USB2) += phy-meson-g12a-usb2.o
34 obj-$(CONFIG_PHY_MESON_GXL_USB3) += phy-meson-gxl-usb3.o
5+obj-$(CONFIG_PHY_MESON_G12A_USB3_PCIE) += phy-meson-g12a-usb3-pcie.o
drivers/phy/amlogic/phy-meson-g12a-usb2.c+341−0
@@ -0,0 +1,341 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Meson G12A USB2 PHY driver
4+ *
5+ * Copyright (C) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
6+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved
7+ * Copyright (C) 2019 BayLibre, SAS
8+ * Author: Neil Armstrong <narmstrong@baylibre.com>
9+ */
10+
11+#include <linux/bitfield.h>
12+#include <linux/bitops.h>
13+#include <linux/clk.h>
14+#include <linux/delay.h>
15+#include <linux/io.h>
16+#include <linux/module.h>
17+#include <linux/of_device.h>
18+#include <linux/regmap.h>
19+#include <linux/reset.h>
20+#include <linux/phy/phy.h>
21+#include <linux/platform_device.h>
22+
23+#define PHY_CTRL_R0 0x0
24+#define PHY_CTRL_R1 0x4
25+#define PHY_CTRL_R2 0x8
26+#define PHY_CTRL_R3 0xc
27+ #define PHY_CTRL_R3_SQUELCH_REF GENMASK(1, 0)
28+ #define PHY_CTRL_R3_HSDIC_REF GENMASK(3, 2)
29+ #define PHY_CTRL_R3_DISC_THRESH GENMASK(7, 4)
30+
31+#define PHY_CTRL_R4 0x10
32+ #define PHY_CTRL_R4_CALIB_CODE_7_0 GENMASK(7, 0)
33+ #define PHY_CTRL_R4_CALIB_CODE_15_8 GENMASK(15, 8)
34+ #define PHY_CTRL_R4_CALIB_CODE_23_16 GENMASK(23, 16)
35+ #define PHY_CTRL_R4_I_C2L_CAL_EN BIT(24)
36+ #define PHY_CTRL_R4_I_C2L_CAL_RESET_N BIT(25)
37+ #define PHY_CTRL_R4_I_C2L_CAL_DONE BIT(26)
38+ #define PHY_CTRL_R4_TEST_BYPASS_MODE_EN BIT(27)
39+ #define PHY_CTRL_R4_I_C2L_BIAS_TRIM_1_0 GENMASK(29, 28)
40+ #define PHY_CTRL_R4_I_C2L_BIAS_TRIM_3_2 GENMASK(31, 30)
41+
42+#define PHY_CTRL_R5 0x14
43+#define PHY_CTRL_R6 0x18
44+#define PHY_CTRL_R7 0x1c
45+#define PHY_CTRL_R8 0x20
46+#define PHY_CTRL_R9 0x24
47+#define PHY_CTRL_R10 0x28
48+#define PHY_CTRL_R11 0x2c
49+#define PHY_CTRL_R12 0x30
50+#define PHY_CTRL_R13 0x34
51+ #define PHY_CTRL_R13_CUSTOM_PATTERN_19 GENMASK(7, 0)
52+ #define PHY_CTRL_R13_LOAD_STAT BIT(14)
53+ #define PHY_CTRL_R13_UPDATE_PMA_SIGNALS BIT(15)
54+ #define PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET GENMASK(20, 16)
55+ #define PHY_CTRL_R13_CLEAR_HOLD_HS_DISCONNECT BIT(21)
56+ #define PHY_CTRL_R13_BYPASS_HOST_DISCONNECT_VAL BIT(22)
57+ #define PHY_CTRL_R13_BYPASS_HOST_DISCONNECT_EN BIT(23)
58+ #define PHY_CTRL_R13_I_C2L_HS_EN BIT(24)
59+ #define PHY_CTRL_R13_I_C2L_FS_EN BIT(25)
60+ #define PHY_CTRL_R13_I_C2L_LS_EN BIT(26)
61+ #define PHY_CTRL_R13_I_C2L_HS_OE BIT(27)
62+ #define PHY_CTRL_R13_I_C2L_FS_OE BIT(28)
63+ #define PHY_CTRL_R13_I_C2L_HS_RX_EN BIT(29)
64+ #define PHY_CTRL_R13_I_C2L_FSLS_RX_EN BIT(30)
65+
66+#define PHY_CTRL_R14 0x38
67+ #define PHY_CTRL_R14_I_RDP_EN BIT(0)
68+ #define PHY_CTRL_R14_I_RPU_SW1_EN BIT(1)
69+ #define PHY_CTRL_R14_I_RPU_SW2_EN GENMASK(2, 3)
70+ #define PHY_CTRL_R14_PG_RSTN BIT(4)
71+ #define PHY_CTRL_R14_I_C2L_DATA_16_8 BIT(5)
72+ #define PHY_CTRL_R14_I_C2L_ASSERT_SINGLE_EN_ZERO BIT(6)
73+ #define PHY_CTRL_R14_BYPASS_CTRL_7_0 GENMASK(15, 8)
74+ #define PHY_CTRL_R14_BYPASS_CTRL_15_8 GENMASK(23, 16)
75+
76+#define PHY_CTRL_R15 0x3c
77+#define PHY_CTRL_R16 0x40
78+ #define PHY_CTRL_R16_MPLL_M GENMASK(8, 0)
79+ #define PHY_CTRL_R16_MPLL_N GENMASK(14, 10)
80+ #define PHY_CTRL_R16_MPLL_TDC_MODE BIT(20)
81+ #define PHY_CTRL_R16_MPLL_SDM_EN BIT(21)
82+ #define PHY_CTRL_R16_MPLL_LOAD BIT(22)
83+ #define PHY_CTRL_R16_MPLL_DCO_SDM_EN BIT(23)
84+ #define PHY_CTRL_R16_MPLL_LOCK_LONG GENMASK(25, 24)
85+ #define PHY_CTRL_R16_MPLL_LOCK_F BIT(26)
86+ #define PHY_CTRL_R16_MPLL_FAST_LOCK BIT(27)
87+ #define PHY_CTRL_R16_MPLL_EN BIT(28)
88+ #define PHY_CTRL_R16_MPLL_RESET BIT(29)
89+ #define PHY_CTRL_R16_MPLL_LOCK BIT(30)
90+ #define PHY_CTRL_R16_MPLL_LOCK_DIG BIT(31)
91+
92+#define PHY_CTRL_R17 0x44
93+ #define PHY_CTRL_R17_MPLL_FRAC_IN GENMASK(13, 0)
94+ #define PHY_CTRL_R17_MPLL_FIX_EN BIT(16)
95+ #define PHY_CTRL_R17_MPLL_LAMBDA1 GENMASK(19, 17)
96+ #define PHY_CTRL_R17_MPLL_LAMBDA0 GENMASK(22, 20)
97+ #define PHY_CTRL_R17_MPLL_FILTER_MODE BIT(23)
98+ #define PHY_CTRL_R17_MPLL_FILTER_PVT2 GENMASK(27, 24)
99+ #define PHY_CTRL_R17_MPLL_FILTER_PVT1 GENMASK(31, 28)
100+
101+#define PHY_CTRL_R18 0x48
102+ #define PHY_CTRL_R18_MPLL_LKW_SEL GENMASK(1, 0)
103+ #define PHY_CTRL_R18_MPLL_LK_W GENMASK(5, 2)
104+ #define PHY_CTRL_R18_MPLL_LK_S GENMASK(11, 6)
105+ #define PHY_CTRL_R18_MPLL_DCO_M_EN BIT(12)
106+ #define PHY_CTRL_R18_MPLL_DCO_CLK_SEL BIT(13)
107+ #define PHY_CTRL_R18_MPLL_PFD_GAIN GENMASK(15, 14)
108+ #define PHY_CTRL_R18_MPLL_ROU GENMASK(18, 16)
109+ #define PHY_CTRL_R18_MPLL_DATA_SEL GENMASK(21, 19)
110+ #define PHY_CTRL_R18_MPLL_BIAS_ADJ GENMASK(23, 22)
111+ #define PHY_CTRL_R18_MPLL_BB_MODE GENMASK(25, 24)
112+ #define PHY_CTRL_R18_MPLL_ALPHA GENMASK(28, 26)
113+ #define PHY_CTRL_R18_MPLL_ADJ_LDO GENMASK(30, 29)
114+ #define PHY_CTRL_R18_MPLL_ACG_RANGE BIT(31)
115+
116+#define PHY_CTRL_R19 0x4c
117+#define PHY_CTRL_R20 0x50
118+ #define PHY_CTRL_R20_USB2_IDDET_EN BIT(0)
119+ #define PHY_CTRL_R20_USB2_OTG_VBUS_TRIM_2_0 GENMASK(3, 1)
120+ #define PHY_CTRL_R20_USB2_OTG_VBUSDET_EN BIT(4)
121+ #define PHY_CTRL_R20_USB2_AMON_EN BIT(5)
122+ #define PHY_CTRL_R20_USB2_CAL_CODE_R5 BIT(6)
123+ #define PHY_CTRL_R20_BYPASS_OTG_DET BIT(7)
124+ #define PHY_CTRL_R20_USB2_DMON_EN BIT(8)
125+ #define PHY_CTRL_R20_USB2_DMON_SEL_3_0 GENMASK(12, 9)
126+ #define PHY_CTRL_R20_USB2_EDGE_DRV_EN BIT(13)
127+ #define PHY_CTRL_R20_USB2_EDGE_DRV_TRIM_1_0 GENMASK(15, 14)
128+ #define PHY_CTRL_R20_USB2_BGR_ADJ_4_0 GENMASK(20, 16)
129+ #define PHY_CTRL_R20_USB2_BGR_START BIT(21)
130+ #define PHY_CTRL_R20_USB2_BGR_VREF_4_0 GENMASK(28, 24)
131+ #define PHY_CTRL_R20_USB2_BGR_DBG_1_0 GENMASK(30, 29)
132+ #define PHY_CTRL_R20_BYPASS_CAL_DONE_R5 BIT(31)
133+
134+#define PHY_CTRL_R21 0x54
135+ #define PHY_CTRL_R21_USB2_BGR_FORCE BIT(0)
136+ #define PHY_CTRL_R21_USB2_CAL_ACK_EN BIT(1)
137+ #define PHY_CTRL_R21_USB2_OTG_ACA_EN BIT(2)
138+ #define PHY_CTRL_R21_USB2_TX_STRG_PD BIT(3)
139+ #define PHY_CTRL_R21_USB2_OTG_ACA_TRIM_1_0 GENMASK(5, 4)
140+ #define PHY_CTRL_R21_BYPASS_UTMI_CNTR GENMASK(15, 6)
141+ #define PHY_CTRL_R21_BYPASS_UTMI_REG GENMASK(25, 20)
142+
143+#define PHY_CTRL_R22 0x58
144+#define PHY_CTRL_R23 0x5c
145+
146+#define RESET_COMPLETE_TIME 1000
147+#define PLL_RESET_COMPLETE_TIME 100
148+
149+struct phy_meson_g12a_usb2_priv {
150+ struct device *dev;
151+ struct regmap *regmap;
152+ struct clk *clk;
153+ struct reset_control *reset;
154+};
155+
156+static const struct regmap_config phy_meson_g12a_usb2_regmap_conf = {
157+ .reg_bits = 8,
158+ .val_bits = 32,
159+ .reg_stride = 4,
160+ .max_register = PHY_CTRL_R23,
161+};
162+
163+static int phy_meson_g12a_usb2_init(struct phy *phy)
164+{
165+ struct phy_meson_g12a_usb2_priv *priv = phy_get_drvdata(phy);
166+ int ret;
167+
168+ ret = reset_control_reset(priv->reset);
169+ if (ret)
170+ return ret;
171+
172+ udelay(RESET_COMPLETE_TIME);
173+
174+ /* usb2_otg_aca_en == 0 */
175+ regmap_update_bits(priv->regmap, PHY_CTRL_R21,
176+ PHY_CTRL_R21_USB2_OTG_ACA_EN, 0);
177+
178+ /* PLL Setup : 24MHz * 20 / 1 = 480MHz */
179+ regmap_write(priv->regmap, PHY_CTRL_R16,
180+ FIELD_PREP(PHY_CTRL_R16_MPLL_M, 20) |
181+ FIELD_PREP(PHY_CTRL_R16_MPLL_N, 1) |
182+ PHY_CTRL_R16_MPLL_LOAD |
183+ FIELD_PREP(PHY_CTRL_R16_MPLL_LOCK_LONG, 1) |
184+ PHY_CTRL_R16_MPLL_FAST_LOCK |
185+ PHY_CTRL_R16_MPLL_EN |
186+ PHY_CTRL_R16_MPLL_RESET);
187+
188+ regmap_write(priv->regmap, PHY_CTRL_R17,
189+ FIELD_PREP(PHY_CTRL_R17_MPLL_FRAC_IN, 0) |
190+ FIELD_PREP(PHY_CTRL_R17_MPLL_LAMBDA1, 7) |
191+ FIELD_PREP(PHY_CTRL_R17_MPLL_LAMBDA0, 7) |
192+ FIELD_PREP(PHY_CTRL_R17_MPLL_FILTER_PVT2, 2) |
193+ FIELD_PREP(PHY_CTRL_R17_MPLL_FILTER_PVT1, 9));
194+
195+ regmap_write(priv->regmap, PHY_CTRL_R18,
196+ FIELD_PREP(PHY_CTRL_R18_MPLL_LKW_SEL, 1) |
197+ FIELD_PREP(PHY_CTRL_R18_MPLL_LK_W, 9) |
198+ FIELD_PREP(PHY_CTRL_R18_MPLL_LK_S, 0x27) |
199+ FIELD_PREP(PHY_CTRL_R18_MPLL_PFD_GAIN, 1) |
200+ FIELD_PREP(PHY_CTRL_R18_MPLL_ROU, 7) |
201+ FIELD_PREP(PHY_CTRL_R18_MPLL_DATA_SEL, 3) |
202+ FIELD_PREP(PHY_CTRL_R18_MPLL_BIAS_ADJ, 1) |
203+ FIELD_PREP(PHY_CTRL_R18_MPLL_BB_MODE, 0) |
204+ FIELD_PREP(PHY_CTRL_R18_MPLL_ALPHA, 3) |
205+ FIELD_PREP(PHY_CTRL_R18_MPLL_ADJ_LDO, 1) |
206+ PHY_CTRL_R18_MPLL_ACG_RANGE);
207+
208+ udelay(PLL_RESET_COMPLETE_TIME);
209+
210+ /* UnReset PLL */
211+ regmap_write(priv->regmap, PHY_CTRL_R16,
212+ FIELD_PREP(PHY_CTRL_R16_MPLL_M, 20) |
213+ FIELD_PREP(PHY_CTRL_R16_MPLL_N, 1) |
214+ PHY_CTRL_R16_MPLL_LOAD |
215+ FIELD_PREP(PHY_CTRL_R16_MPLL_LOCK_LONG, 1) |
216+ PHY_CTRL_R16_MPLL_FAST_LOCK |
217+ PHY_CTRL_R16_MPLL_EN);
218+
219+ /* PHY Tuning */
220+ regmap_write(priv->regmap, PHY_CTRL_R20,
221+ FIELD_PREP(PHY_CTRL_R20_USB2_OTG_VBUS_TRIM_2_0, 4) |
222+ PHY_CTRL_R20_USB2_OTG_VBUSDET_EN |
223+ FIELD_PREP(PHY_CTRL_R20_USB2_DMON_SEL_3_0, 15) |
224+ PHY_CTRL_R20_USB2_EDGE_DRV_EN |
225+ FIELD_PREP(PHY_CTRL_R20_USB2_EDGE_DRV_TRIM_1_0, 3) |
226+ FIELD_PREP(PHY_CTRL_R20_USB2_BGR_ADJ_4_0, 0) |
227+ FIELD_PREP(PHY_CTRL_R20_USB2_BGR_VREF_4_0, 0) |
228+ FIELD_PREP(PHY_CTRL_R20_USB2_BGR_DBG_1_0, 0));
229+
230+ regmap_write(priv->regmap, PHY_CTRL_R4,
231+ FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_7_0, 0xf) |
232+ FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_15_8, 0xf) |
233+ FIELD_PREP(PHY_CTRL_R4_CALIB_CODE_23_16, 0xf) |
234+ PHY_CTRL_R4_TEST_BYPASS_MODE_EN |
235+ FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_1_0, 0) |
236+ FIELD_PREP(PHY_CTRL_R4_I_C2L_BIAS_TRIM_3_2, 0));
237+
238+ /* Tuning Disconnect Threshold */
239+ regmap_write(priv->regmap, PHY_CTRL_R3,
240+ FIELD_PREP(PHY_CTRL_R3_SQUELCH_REF, 0) |
241+ FIELD_PREP(PHY_CTRL_R3_HSDIC_REF, 1) |
242+ FIELD_PREP(PHY_CTRL_R3_DISC_THRESH, 3));
243+
244+ /* Analog Settings */
245+ regmap_write(priv->regmap, PHY_CTRL_R14, 0);
246+ regmap_write(priv->regmap, PHY_CTRL_R13,
247+ PHY_CTRL_R13_UPDATE_PMA_SIGNALS |
248+ FIELD_PREP(PHY_CTRL_R13_MIN_COUNT_FOR_SYNC_DET, 7));
249+
250+ return 0;
251+}
252+
253+static int phy_meson_g12a_usb2_exit(struct phy *phy)
254+{
255+ struct phy_meson_g12a_usb2_priv *priv = phy_get_drvdata(phy);
256+
257+ return reset_control_reset(priv->reset);
258+}
259+
260+/* set_mode is not needed, mode setting is handled via the UTMI bus */
261+static const struct phy_ops phy_meson_g12a_usb2_ops = {
262+ .init = phy_meson_g12a_usb2_init,
263+ .exit = phy_meson_g12a_usb2_exit,
264+ .owner = THIS_MODULE,
265+};
266+
267+static int phy_meson_g12a_usb2_probe(struct platform_device *pdev)
268+{
269+ struct device *dev = &pdev->dev;
270+ struct phy_provider *phy_provider;
271+ struct resource *res;
272+ struct phy_meson_g12a_usb2_priv *priv;
273+ struct phy *phy;
274+ void __iomem *base;
275+ int ret;
276+
277+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
278+ if (!priv)
279+ return -ENOMEM;
280+
281+ priv->dev = dev;
282+ platform_set_drvdata(pdev, priv);
283+
284+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
285+ base = devm_ioremap_resource(dev, res);
286+ if (IS_ERR(base))
287+ return PTR_ERR(base);
288+
289+ priv->regmap = devm_regmap_init_mmio(dev, base,
290+ &phy_meson_g12a_usb2_regmap_conf);
291+ if (IS_ERR(priv->regmap))
292+ return PTR_ERR(priv->regmap);
293+
294+ priv->clk = devm_clk_get(dev, "xtal");
295+ if (IS_ERR(priv->clk))
296+ return PTR_ERR(priv->clk);
297+
298+ priv->reset = devm_reset_control_get(dev, "phy");
299+ if (IS_ERR(priv->reset))
300+ return PTR_ERR(priv->reset);
301+
302+ ret = reset_control_deassert(priv->reset);
303+ if (ret)
304+ return ret;
305+
306+ phy = devm_phy_create(dev, NULL, &phy_meson_g12a_usb2_ops);
307+ if (IS_ERR(phy)) {
308+ ret = PTR_ERR(phy);
309+ if (ret != -EPROBE_DEFER)
310+ dev_err(dev, "failed to create PHY\n");
311+
312+ return ret;
313+ }
314+
315+ phy_set_bus_width(phy, 8);
316+ phy_set_drvdata(phy, priv);
317+
318+ phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
319+
320+ return PTR_ERR_OR_ZERO(phy_provider);
321+}
322+
323+static const struct of_device_id phy_meson_g12a_usb2_of_match[] = {
324+ { .compatible = "amlogic,g12a-usb2-phy", },
325+ { },
326+};
327+MODULE_DEVICE_TABLE(of, phy_meson_g12a_usb2_of_match);
328+
329+static struct platform_driver phy_meson_g12a_usb2_driver = {
330+ .probe = phy_meson_g12a_usb2_probe,
331+ .driver = {
332+ .name = "phy-meson-g12a-usb2",
333+ .of_match_table = phy_meson_g12a_usb2_of_match,
334+ },
335+};
336+module_platform_driver(phy_meson_g12a_usb2_driver);
337+
338+MODULE_AUTHOR("Martin Blumenstingl <martin.blumenstingl@googlemail.com>");
339+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
340+MODULE_DESCRIPTION("Meson G12A USB2 PHY driver");
341+MODULE_LICENSE("GPL v2");
drivers/phy/amlogic/phy-meson-g12a-usb3-pcie.c+413−0
@@ -0,0 +1,413 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Amlogic G12A USB3 + PCIE Combo PHY driver
4+ *
5+ * Copyright (C) 2017 Amlogic, Inc. All rights reserved
6+ * Copyright (C) 2019 BayLibre, SAS
7+ * Author: Neil Armstrong <narmstrong@baylibre.com>
8+ */
9+
10+#include <linux/bitfield.h>
11+#include <linux/bitops.h>
12+#include <linux/clk.h>
13+#include <linux/module.h>
14+#include <linux/of_device.h>
15+#include <linux/phy/phy.h>
16+#include <linux/regmap.h>
17+#include <linux/reset.h>
18+#include <linux/platform_device.h>
19+#include <dt-bindings/phy/phy.h>
20+
21+#define PHY_R0 0x00
22+ #define PHY_R0_PCIE_POWER_STATE GENMASK(4, 0)
23+ #define PHY_R0_PCIE_USB3_SWITCH GENMASK(6, 5)
24+
25+#define PHY_R1 0x04
26+ #define PHY_R1_PHY_TX1_TERM_OFFSET GENMASK(4, 0)
27+ #define PHY_R1_PHY_TX0_TERM_OFFSET GENMASK(9, 5)
28+ #define PHY_R1_PHY_RX1_EQ GENMASK(12, 10)
29+ #define PHY_R1_PHY_RX0_EQ GENMASK(15, 13)
30+ #define PHY_R1_PHY_LOS_LEVEL GENMASK(20, 16)
31+ #define PHY_R1_PHY_LOS_BIAS GENMASK(23, 21)
32+ #define PHY_R1_PHY_REF_CLKDIV2 BIT(24)
33+ #define PHY_R1_PHY_MPLL_MULTIPLIER GENMASK(31, 25)
34+
35+#define PHY_R2 0x08
36+ #define PHY_R2_PCS_TX_DEEMPH_GEN2_6DB GENMASK(5, 0)
37+ #define PHY_R2_PCS_TX_DEEMPH_GEN2_3P5DB GENMASK(11, 6)
38+ #define PHY_R2_PCS_TX_DEEMPH_GEN1 GENMASK(17, 12)
39+ #define PHY_R2_PHY_TX_VBOOST_LVL GENMASK(20, 18)
40+
41+#define PHY_R4 0x10
42+ #define PHY_R4_PHY_CR_WRITE BIT(0)
43+ #define PHY_R4_PHY_CR_READ BIT(1)
44+ #define PHY_R4_PHY_CR_DATA_IN GENMASK(17, 2)
45+ #define PHY_R4_PHY_CR_CAP_DATA BIT(18)
46+ #define PHY_R4_PHY_CR_CAP_ADDR BIT(19)
47+
48+#define PHY_R5 0x14
49+ #define PHY_R5_PHY_CR_DATA_OUT GENMASK(15, 0)
50+ #define PHY_R5_PHY_CR_ACK BIT(16)
51+ #define PHY_R5_PHY_BS_OUT BIT(17)
52+
53+struct phy_g12a_usb3_pcie_priv {
54+ struct regmap *regmap;
55+ struct regmap *regmap_cr;
56+ struct clk *clk_ref;
57+ struct reset_control *reset;
58+ struct phy *phy;
59+ unsigned int mode;
60+};
61+
62+static const struct regmap_config phy_g12a_usb3_pcie_regmap_conf = {
63+ .reg_bits = 8,
64+ .val_bits = 32,
65+ .reg_stride = 4,
66+ .max_register = PHY_R5,
67+};
68+
69+static int phy_g12a_usb3_pcie_cr_bus_addr(struct phy_g12a_usb3_pcie_priv *priv,
70+ unsigned int addr)
71+{
72+ unsigned int val, reg;
73+ int ret;
74+
75+ reg = FIELD_PREP(PHY_R4_PHY_CR_DATA_IN, addr);
76+
77+ regmap_write(priv->regmap, PHY_R4, reg);
78+ regmap_write(priv->regmap, PHY_R4, reg);
79+
80+ regmap_write(priv->regmap, PHY_R4, reg | PHY_R4_PHY_CR_CAP_ADDR);
81+
82+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
83+ (val & PHY_R5_PHY_CR_ACK),
84+ 5, 1000);
85+ if (ret)
86+ return ret;
87+
88+ regmap_write(priv->regmap, PHY_R4, reg);
89+
90+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
91+ !(val & PHY_R5_PHY_CR_ACK),
92+ 5, 1000);
93+ if (ret)
94+ return ret;
95+
96+ return 0;
97+}
98+
99+static int phy_g12a_usb3_pcie_cr_bus_read(void *context, unsigned int addr,
100+ unsigned int *data)
101+{
102+ struct phy_g12a_usb3_pcie_priv *priv = context;
103+ unsigned int val;
104+ int ret;
105+
106+ ret = phy_g12a_usb3_pcie_cr_bus_addr(priv, addr);
107+ if (ret)
108+ return ret;
109+
110+ regmap_write(priv->regmap, PHY_R4, 0);
111+ regmap_write(priv->regmap, PHY_R4, PHY_R4_PHY_CR_READ);
112+
113+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
114+ (val & PHY_R5_PHY_CR_ACK),
115+ 5, 1000);
116+ if (ret)
117+ return ret;
118+
119+ *data = FIELD_GET(PHY_R5_PHY_CR_DATA_OUT, val);
120+
121+ regmap_write(priv->regmap, PHY_R4, 0);
122+
123+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
124+ !(val & PHY_R5_PHY_CR_ACK),
125+ 5, 1000);
126+ if (ret)
127+ return ret;
128+
129+ return 0;
130+}
131+
132+static int phy_g12a_usb3_pcie_cr_bus_write(void *context, unsigned int addr,
133+ unsigned int data)
134+{
135+ struct phy_g12a_usb3_pcie_priv *priv = context;
136+ unsigned int val, reg;
137+ int ret;
138+
139+ ret = phy_g12a_usb3_pcie_cr_bus_addr(priv, addr);
140+ if (ret)
141+ return ret;
142+
143+ reg = FIELD_PREP(PHY_R4_PHY_CR_DATA_IN, data);
144+
145+ regmap_write(priv->regmap, PHY_R4, reg);
146+ regmap_write(priv->regmap, PHY_R4, reg);
147+
148+ regmap_write(priv->regmap, PHY_R4, reg | PHY_R4_PHY_CR_CAP_DATA);
149+
150+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
151+ (val & PHY_R5_PHY_CR_ACK),
152+ 5, 1000);
153+ if (ret)
154+ return ret;
155+
156+ regmap_write(priv->regmap, PHY_R4, reg);
157+
158+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
159+ (val & PHY_R5_PHY_CR_ACK) == 0,
160+ 5, 1000);
161+ if (ret)
162+ return ret;
163+
164+ regmap_write(priv->regmap, PHY_R4, reg);
165+
166+ regmap_write(priv->regmap, PHY_R4, reg | PHY_R4_PHY_CR_WRITE);
167+
168+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
169+ (val & PHY_R5_PHY_CR_ACK),
170+ 5, 1000);
171+ if (ret)
172+ return ret;
173+
174+ regmap_write(priv->regmap, PHY_R4, reg);
175+
176+ ret = regmap_read_poll_timeout(priv->regmap, PHY_R5, val,
177+ (val & PHY_R5_PHY_CR_ACK) == 0,
178+ 5, 1000);
179+ if (ret)
180+ return ret;
181+
182+ return 0;
183+}
184+
185+static const struct regmap_config phy_g12a_usb3_pcie_cr_regmap_conf = {
186+ .reg_bits = 16,
187+ .val_bits = 16,
188+ .reg_read = phy_g12a_usb3_pcie_cr_bus_read,
189+ .reg_write = phy_g12a_usb3_pcie_cr_bus_write,
190+ .max_register = 0xffff,
191+ .fast_io = true,
192+};
193+
194+static int phy_g12a_usb3_init(struct phy *phy)
195+{
196+ struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy);
197+ int data, ret;
198+
199+ /* Switch PHY to USB3 */
200+ /* TODO figure out how to handle when PCIe was set in the bootloader */
201+ regmap_update_bits(priv->regmap, PHY_R0,
202+ PHY_R0_PCIE_USB3_SWITCH,
203+ PHY_R0_PCIE_USB3_SWITCH);
204+
205+ /*
206+ * WORKAROUND: There is SSPHY suspend bug due to
207+ * which USB enumerates
208+ * in HS mode instead of SS mode. Workaround it by asserting
209+ * LANE0.TX_ALT_BLOCK.EN_ALT_BUS to enable TX to use alt bus
210+ * mode
211+ */
212+ ret = regmap_update_bits(priv->regmap_cr, 0x102d, BIT(7), BIT(7));
213+ if (ret)
214+ return ret;
215+
216+ ret = regmap_update_bits(priv->regmap_cr, 0x1010, 0xff0, 20);
217+ if (ret)
218+ return ret;
219+
220+ /*
221+ * Fix RX Equalization setting as follows
222+ * LANE0.RX_OVRD_IN_HI. RX_EQ_EN set to 0
223+ * LANE0.RX_OVRD_IN_HI.RX_EQ_EN_OVRD set to 1
224+ * LANE0.RX_OVRD_IN_HI.RX_EQ set to 3
225+ * LANE0.RX_OVRD_IN_HI.RX_EQ_OVRD set to 1
226+ */
227+ ret = regmap_read(priv->regmap_cr, 0x1006, &data);
228+ if (ret)
229+ return ret;
230+
231+ data &= ~BIT(6);
232+ data |= BIT(7);
233+ data &= ~(0x7 << 8);
234+ data |= (0x3 << 8);
235+ data |= (1 << 11);
236+ ret = regmap_write(priv->regmap_cr, 0x1006, data);
237+ if (ret)
238+ return ret;
239+
240+ /*
241+ * Set EQ and TX launch amplitudes as follows
242+ * LANE0.TX_OVRD_DRV_LO.PREEMPH set to 22
243+ * LANE0.TX_OVRD_DRV_LO.AMPLITUDE set to 127
244+ * LANE0.TX_OVRD_DRV_LO.EN set to 1.
245+ */
246+ ret = regmap_read(priv->regmap_cr, 0x1002, &data);
247+ if (ret)
248+ return ret;
249+
250+ data &= ~0x3f80;
251+ data |= (0x16 << 7);
252+ data &= ~0x7f;
253+ data |= (0x7f | BIT(14));
254+ ret = regmap_write(priv->regmap_cr, 0x1002, data);
255+ if (ret)
256+ return ret;
257+
258+ /* MPLL_LOOP_CTL.PROP_CNTRL = 8 */
259+ ret = regmap_update_bits(priv->regmap_cr, 0x30, 0xf << 4, 8 << 4);
260+ if (ret)
261+ return ret;
262+
263+ regmap_update_bits(priv->regmap, PHY_R2,
264+ PHY_R2_PHY_TX_VBOOST_LVL,
265+ FIELD_PREP(PHY_R2_PHY_TX_VBOOST_LVL, 0x4));
266+
267+ regmap_update_bits(priv->regmap, PHY_R1,
268+ PHY_R1_PHY_LOS_BIAS | PHY_R1_PHY_LOS_LEVEL,
269+ FIELD_PREP(PHY_R1_PHY_LOS_BIAS, 4) |
270+ FIELD_PREP(PHY_R1_PHY_LOS_LEVEL, 9));
271+
272+ return 0;
273+}
274+
275+static int phy_g12a_usb3_pcie_init(struct phy *phy)
276+{
277+ struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy);
278+ int ret;
279+
280+ ret = reset_control_reset(priv->reset);
281+ if (ret)
282+ return ret;
283+
284+ if (priv->mode == PHY_TYPE_USB3)
285+ return phy_g12a_usb3_init(phy);
286+
287+ /* Power UP PCIE */
288+ /* TODO figure out when the bootloader has set USB3 mode before */
289+ regmap_update_bits(priv->regmap, PHY_R0,
290+ PHY_R0_PCIE_POWER_STATE,
291+ FIELD_PREP(PHY_R0_PCIE_POWER_STATE, 0x1c));
292+
293+ return 0;
294+}
295+
296+static int phy_g12a_usb3_pcie_exit(struct phy *phy)
297+{
298+ struct phy_g12a_usb3_pcie_priv *priv = phy_get_drvdata(phy);
299+
300+ return reset_control_reset(priv->reset);
301+}
302+
303+static struct phy *phy_g12a_usb3_pcie_xlate(struct device *dev,
304+ struct of_phandle_args *args)
305+{
306+ struct phy_g12a_usb3_pcie_priv *priv = dev_get_drvdata(dev);
307+ unsigned int mode;
308+
309+ if (args->args_count < 1) {
310+ dev_err(dev, "invalid number of arguments\n");
311+ return ERR_PTR(-EINVAL);
312+ }
313+
314+ mode = args->args[0];
315+
316+ if (mode != PHY_TYPE_USB3 && mode != PHY_TYPE_PCIE) {
317+ dev_err(dev, "invalid phy mode select argument\n");
318+ return ERR_PTR(-EINVAL);
319+ }
320+
321+ priv->mode = mode;
322+
323+ return priv->phy;
324+}
325+
326+static const struct phy_ops phy_g12a_usb3_pcie_ops = {
327+ .init = phy_g12a_usb3_pcie_init,
328+ .exit = phy_g12a_usb3_pcie_exit,
329+ .owner = THIS_MODULE,
330+};
331+
332+static int phy_g12a_usb3_pcie_probe(struct platform_device *pdev)
333+{
334+ struct device *dev = &pdev->dev;
335+ struct device_node *np = dev->of_node;
336+ struct phy_g12a_usb3_pcie_priv *priv;
337+ struct resource *res;
338+ struct phy_provider *phy_provider;
339+ void __iomem *base;
340+ int ret;
341+
342+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
343+ if (!priv)
344+ return -ENOMEM;
345+
346+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
347+ base = devm_ioremap_resource(dev, res);
348+ if (IS_ERR(base))
349+ return PTR_ERR(base);
350+
351+ priv->regmap = devm_regmap_init_mmio(dev, base,
352+ &phy_g12a_usb3_pcie_regmap_conf);
353+ if (IS_ERR(priv->regmap))
354+ return PTR_ERR(priv->regmap);
355+
356+ priv->regmap_cr = devm_regmap_init(dev, NULL, priv,
357+ &phy_g12a_usb3_pcie_cr_regmap_conf);
358+ if (IS_ERR(priv->regmap_cr))
359+ return PTR_ERR(priv->regmap_cr);
360+
361+ priv->clk_ref = devm_clk_get(dev, "ref_clk");
362+ if (IS_ERR(priv->clk_ref))
363+ return PTR_ERR(priv->clk_ref);
364+
365+ ret = clk_prepare_enable(priv->clk_ref);
366+ if (ret)
367+ goto err_disable_clk_ref;
368+
369+ priv->reset = devm_reset_control_array_get(dev, false, false);
370+ if (IS_ERR(priv->reset))
371+ return PTR_ERR(priv->reset);
372+
373+ priv->phy = devm_phy_create(dev, np, &phy_g12a_usb3_pcie_ops);
374+ if (IS_ERR(priv->phy)) {
375+ ret = PTR_ERR(priv->phy);
376+ if (ret != -EPROBE_DEFER)
377+ dev_err(dev, "failed to create PHY\n");
378+
379+ return ret;
380+ }
381+
382+ phy_set_drvdata(priv->phy, priv);
383+ dev_set_drvdata(dev, priv);
384+
385+ phy_provider = devm_of_phy_provider_register(dev,
386+ phy_g12a_usb3_pcie_xlate);
387+
388+ return PTR_ERR_OR_ZERO(phy_provider);
389+
390+err_disable_clk_ref:
391+ clk_disable_unprepare(priv->clk_ref);
392+
393+ return ret;
394+}
395+
396+static const struct of_device_id phy_g12a_usb3_pcie_of_match[] = {
397+ { .compatible = "amlogic,g12a-usb3-pcie-phy", },
398+ { },
399+};
400+MODULE_DEVICE_TABLE(of, phy_g12a_usb3_pcie_of_match);
401+
402+static struct platform_driver phy_g12a_usb3_pcie_driver = {
403+ .probe = phy_g12a_usb3_pcie_probe,
404+ .driver = {
405+ .name = "phy-g12a-usb3-pcie",
406+ .of_match_table = phy_g12a_usb3_pcie_of_match,
407+ },
408+};
409+module_platform_driver(phy_g12a_usb3_pcie_driver);
410+
411+MODULE_AUTHOR("Neil Armstrong <narmstrong@baylibre.com>");
412+MODULE_DESCRIPTION("Amlogic G12A USB3 + PCIE Combo PHY driver");
413+MODULE_LICENSE("GPL v2");
drivers/phy/amlogic/phy-meson-gxl-usb2.c+3−8
@@ -261,14 +261,9 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev) · 260 unmodified lines
261261 if (IS_ERR(priv->regmap))
262262 return PTR_ERR(priv->regmap);
263263
264− priv->clk = devm_clk_get(dev, "phy");
265− if (IS_ERR(priv->clk)) {
266− ret = PTR_ERR(priv->clk);
267− if (ret == -ENOENT)
268− priv->clk = NULL;
269− else
270− return ret;
271− }
264+ priv->clk = devm_clk_get_optional(dev, "phy");
265+ if (IS_ERR(priv->clk))
266+ return PTR_ERR(priv->clk);
272267
273268 priv->reset = devm_reset_control_get_optional_shared(dev, "phy");
274269 if (IS_ERR(priv->reset))
drivers/phy/broadcom/Kconfig+11−0
@@ -10,6 +10,17 @@ config PHY_CYGNUS_PCIE · 9 unmodified lines
1010 Enable this to support the Broadcom Cygnus PCIe PHY.
1111 If unsure, say N.
1212
13+config PHY_BCM_SR_USB
14+ tristate "Broadcom Stingray USB PHY driver"
15+ depends on OF && (ARCH_BCM_IPROC || COMPILE_TEST)
16+ select GENERIC_PHY
17+ default ARCH_BCM_IPROC
18+ help
19+ Enable this to support the Broadcom Stingray USB PHY
20+ driver. It supports all versions of Superspeed and
21+ Highspeed PHYs.
22+ If unsure, say N.
23+
1324 config BCM_KONA_USB2_PHY
1425 tristate "Broadcom Kona USB2 PHY Driver"
1526 depends on HAS_IOMEM
drivers/phy/broadcom/Makefile+1−0
@@ -11,3 +11,4 @@ obj-$(CONFIG_PHY_BRCM_USB) += phy-brcm-usb-dvr.o · 10 unmodified lines
1111 phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o
1212
1313 obj-$(CONFIG_PHY_BCM_SR_PCIE) += phy-bcm-sr-pcie.o
14+obj-$(CONFIG_PHY_BCM_SR_USB) += phy-bcm-sr-usb.o
drivers/phy/broadcom/phy-bcm-sr-usb.c+394−0
@@ -0,0 +1,394 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2016-2018 Broadcom
4+ */
5+
6+#include <linux/delay.h>
7+#include <linux/io.h>
8+#include <linux/module.h>
9+#include <linux/of.h>
10+#include <linux/phy/phy.h>
11+#include <linux/platform_device.h>
12+
13+enum bcm_usb_phy_version {
14+ BCM_SR_USB_COMBO_PHY,
15+ BCM_SR_USB_HS_PHY,
16+};
17+
18+enum bcm_usb_phy_reg {
19+ PLL_NDIV_FRAC,
20+ PLL_NDIV_INT,
21+ PLL_CTRL,
22+ PHY_CTRL,
23+ PHY_PLL_CTRL,
24+};
25+
26+/* USB PHY registers */
27+
28+static const u8 bcm_usb_combo_phy_ss[] = {
29+ [PLL_CTRL] = 0x18,
30+ [PHY_CTRL] = 0x14,
31+};
32+
33+static const u8 bcm_usb_combo_phy_hs[] = {
34+ [PLL_NDIV_FRAC] = 0x04,
35+ [PLL_NDIV_INT] = 0x08,
36+ [PLL_CTRL] = 0x0c,
37+ [PHY_CTRL] = 0x10,
38+};
39+
40+#define HSPLL_NDIV_INT_VAL 0x13
41+#define HSPLL_NDIV_FRAC_VAL 0x1005
42+
43+static const u8 bcm_usb_hs_phy[] = {
44+ [PLL_NDIV_FRAC] = 0x0,
45+ [PLL_NDIV_INT] = 0x4,
46+ [PLL_CTRL] = 0x8,
47+ [PHY_CTRL] = 0xc,
48+};
49+
50+enum pll_ctrl_bits {
51+ PLL_RESETB,
52+ SSPLL_SUSPEND_EN,
53+ PLL_SEQ_START,
54+ PLL_LOCK,
55+ PLL_PDIV,
56+};
57+
58+static const u8 u3pll_ctrl[] = {
59+ [PLL_RESETB] = 0,
60+ [SSPLL_SUSPEND_EN] = 1,
61+ [PLL_SEQ_START] = 2,
62+ [PLL_LOCK] = 3,
63+};
64+
65+#define HSPLL_PDIV_MASK 0xF
66+#define HSPLL_PDIV_VAL 0x1
67+
68+static const u8 u2pll_ctrl[] = {
69+ [PLL_PDIV] = 1,
70+ [PLL_RESETB] = 5,
71+ [PLL_LOCK] = 6,
72+};
73+
74+enum bcm_usb_phy_ctrl_bits {
75+ CORERDY,
76+ AFE_LDO_PWRDWNB,
77+ AFE_PLL_PWRDWNB,
78+ AFE_BG_PWRDWNB,
79+ PHY_ISO,
80+ PHY_RESETB,
81+ PHY_PCTL,
82+};
83+
84+#define PHY_PCTL_MASK 0xffff
85+/*
86+ * 0x0806 of PCTL_VAL has below bits set
87+ * BIT-8 : refclk divider 1
88+ * BIT-3:2: device mode; mode is not effect
89+ * BIT-1: soft reset active low
90+ */
91+#define HSPHY_PCTL_VAL 0x0806
92+#define SSPHY_PCTL_VAL 0x0006
93+
94+static const u8 u3phy_ctrl[] = {
95+ [PHY_RESETB] = 1,
96+ [PHY_PCTL] = 2,
97+};
98+
99+static const u8 u2phy_ctrl[] = {
100+ [CORERDY] = 0,
101+ [AFE_LDO_PWRDWNB] = 1,
102+ [AFE_PLL_PWRDWNB] = 2,
103+ [AFE_BG_PWRDWNB] = 3,
104+ [PHY_ISO] = 4,
105+ [PHY_RESETB] = 5,
106+ [PHY_PCTL] = 6,
107+};
108+
109+struct bcm_usb_phy_cfg {
110+ uint32_t type;
111+ uint32_t version;
112+ void __iomem *regs;
113+ struct phy *phy;
114+ const u8 *offset;
115+};
116+
117+#define PLL_LOCK_RETRY_COUNT 1000
118+
119+enum bcm_usb_phy_type {
120+ USB_HS_PHY,
121+ USB_SS_PHY,
122+};
123+
124+#define NUM_BCM_SR_USB_COMBO_PHYS 2
125+
126+static inline void bcm_usb_reg32_clrbits(void __iomem *addr, uint32_t clear)
127+{
128+ writel(readl(addr) & ~clear, addr);
129+}
130+
131+static inline void bcm_usb_reg32_setbits(void __iomem *addr, uint32_t set)
132+{
133+ writel(readl(addr) | set, addr);
134+}
135+
136+static int bcm_usb_pll_lock_check(void __iomem *addr, u32 bit)
137+{
138+ int retry;
139+ u32 rd_data;
140+
141+ retry = PLL_LOCK_RETRY_COUNT;
142+ do {
143+ rd_data = readl(addr);
144+ if (rd_data & bit)
145+ return 0;
146+ udelay(1);
147+ } while (--retry > 0);
148+
149+ pr_err("%s: FAIL\n", __func__);
150+ return -ETIMEDOUT;
151+}
152+
153+static int bcm_usb_ss_phy_init(struct bcm_usb_phy_cfg *phy_cfg)
154+{
155+ int ret = 0;
156+ void __iomem *regs = phy_cfg->regs;
157+ const u8 *offset;
158+ u32 rd_data;
159+
160+ offset = phy_cfg->offset;
161+
162+ /* Set pctl with mode and soft reset */
163+ rd_data = readl(regs + offset[PHY_CTRL]);
164+ rd_data &= ~(PHY_PCTL_MASK << u3phy_ctrl[PHY_PCTL]);
165+ rd_data |= (SSPHY_PCTL_VAL << u3phy_ctrl[PHY_PCTL]);
166+ writel(rd_data, regs + offset[PHY_CTRL]);
167+
168+ bcm_usb_reg32_clrbits(regs + offset[PLL_CTRL],
169+ BIT(u3pll_ctrl[SSPLL_SUSPEND_EN]));
170+ bcm_usb_reg32_setbits(regs + offset[PLL_CTRL],
171+ BIT(u3pll_ctrl[PLL_SEQ_START]));
172+ bcm_usb_reg32_setbits(regs + offset[PLL_CTRL],
173+ BIT(u3pll_ctrl[PLL_RESETB]));
174+
175+ /* Maximum timeout for PLL reset done */
176+ msleep(30);
177+
178+ ret = bcm_usb_pll_lock_check(regs + offset[PLL_CTRL],
179+ BIT(u3pll_ctrl[PLL_LOCK]));
180+
181+ return ret;
182+}
183+
184+static int bcm_usb_hs_phy_init(struct bcm_usb_phy_cfg *phy_cfg)
185+{
186+ int ret = 0;
187+ void __iomem *regs = phy_cfg->regs;
188+ const u8 *offset;
189+ u32 rd_data;
190+
191+ offset = phy_cfg->offset;
192+
193+ writel(HSPLL_NDIV_INT_VAL, regs + offset[PLL_NDIV_INT]);
194+ writel(HSPLL_NDIV_FRAC_VAL, regs + offset[PLL_NDIV_FRAC]);
195+
196+ rd_data = readl(regs + offset[PLL_CTRL]);
197+ rd_data &= ~(HSPLL_PDIV_MASK << u2pll_ctrl[PLL_PDIV]);
198+ rd_data |= (HSPLL_PDIV_VAL << u2pll_ctrl[PLL_PDIV]);
199+ writel(rd_data, regs + offset[PLL_CTRL]);
200+
201+ /* Set Core Ready high */
202+ bcm_usb_reg32_setbits(regs + offset[PHY_CTRL],
203+ BIT(u2phy_ctrl[CORERDY]));
204+
205+ /* Maximum timeout for Core Ready done */
206+ msleep(30);
207+
208+ bcm_usb_reg32_setbits(regs + offset[PLL_CTRL],
209+ BIT(u2pll_ctrl[PLL_RESETB]));
210+ bcm_usb_reg32_setbits(regs + offset[PHY_CTRL],
211+ BIT(u2phy_ctrl[PHY_RESETB]));
212+
213+
214+ rd_data = readl(regs + offset[PHY_CTRL]);
215+ rd_data &= ~(PHY_PCTL_MASK << u2phy_ctrl[PHY_PCTL]);
216+ rd_data |= (HSPHY_PCTL_VAL << u2phy_ctrl[PHY_PCTL]);
217+ writel(rd_data, regs + offset[PHY_CTRL]);
218+
219+ /* Maximum timeout for PLL reset done */
220+ msleep(30);
221+
222+ ret = bcm_usb_pll_lock_check(regs + offset[PLL_CTRL],
223+ BIT(u2pll_ctrl[PLL_LOCK]));
224+
225+ return ret;
226+}
227+
228+static int bcm_usb_phy_reset(struct phy *phy)
229+{
230+ struct bcm_usb_phy_cfg *phy_cfg = phy_get_drvdata(phy);
231+ void __iomem *regs = phy_cfg->regs;
232+ const u8 *offset;
233+
234+ offset = phy_cfg->offset;
235+
236+ if (phy_cfg->type == USB_HS_PHY) {
237+ bcm_usb_reg32_clrbits(regs + offset[PHY_CTRL],
238+ BIT(u2phy_ctrl[CORERDY]));
239+ bcm_usb_reg32_setbits(regs + offset[PHY_CTRL],
240+ BIT(u2phy_ctrl[CORERDY]));
241+ }
242+
243+ return 0;
244+}
245+
246+static int bcm_usb_phy_init(struct phy *phy)
247+{
248+ struct bcm_usb_phy_cfg *phy_cfg = phy_get_drvdata(phy);
249+ int ret = -EINVAL;
250+
251+ if (phy_cfg->type == USB_SS_PHY)
252+ ret = bcm_usb_ss_phy_init(phy_cfg);
253+ else if (phy_cfg->type == USB_HS_PHY)
254+ ret = bcm_usb_hs_phy_init(phy_cfg);
255+
256+ return ret;
257+}
258+
259+static struct phy_ops sr_phy_ops = {
260+ .init = bcm_usb_phy_init,
261+ .reset = bcm_usb_phy_reset,
262+ .owner = THIS_MODULE,
263+};
264+
265+static struct phy *bcm_usb_phy_xlate(struct device *dev,
266+ struct of_phandle_args *args)
267+{
268+ struct bcm_usb_phy_cfg *phy_cfg;
269+ int phy_idx;
270+
271+ phy_cfg = dev_get_drvdata(dev);
272+ if (!phy_cfg)
273+ return ERR_PTR(-EINVAL);
274+
275+ if (phy_cfg->version == BCM_SR_USB_COMBO_PHY) {
276+ phy_idx = args->args[0];
277+
278+ if (WARN_ON(phy_idx > 1))
279+ return ERR_PTR(-ENODEV);
280+
281+ return phy_cfg[phy_idx].phy;
282+ } else
283+ return phy_cfg->phy;
284+}
285+
286+static int bcm_usb_phy_create(struct device *dev, struct device_node *node,
287+ void __iomem *regs, uint32_t version)
288+{
289+ struct bcm_usb_phy_cfg *phy_cfg;
290+ int idx;
291+
292+ if (version == BCM_SR_USB_COMBO_PHY) {
293+ phy_cfg = devm_kzalloc(dev, NUM_BCM_SR_USB_COMBO_PHYS *
294+ sizeof(struct bcm_usb_phy_cfg),
295+ GFP_KERNEL);
296+ if (!phy_cfg)
297+ return -ENOMEM;
298+
299+ for (idx = 0; idx < NUM_BCM_SR_USB_COMBO_PHYS; idx++) {
300+ phy_cfg[idx].regs = regs;
301+ phy_cfg[idx].version = version;
302+ if (idx == 0) {
303+ phy_cfg[idx].offset = bcm_usb_combo_phy_hs;
304+ phy_cfg[idx].type = USB_HS_PHY;
305+ } else {
306+ phy_cfg[idx].offset = bcm_usb_combo_phy_ss;
307+ phy_cfg[idx].type = USB_SS_PHY;
308+ }
309+ phy_cfg[idx].phy = devm_phy_create(dev, node,
310+ &sr_phy_ops);
311+ if (IS_ERR(phy_cfg[idx].phy))
312+ return PTR_ERR(phy_cfg[idx].phy);
313+
314+ phy_set_drvdata(phy_cfg[idx].phy, &phy_cfg[idx]);
315+ }
316+ } else if (version == BCM_SR_USB_HS_PHY) {
317+ phy_cfg = devm_kzalloc(dev, sizeof(struct bcm_usb_phy_cfg),
318+ GFP_KERNEL);
319+ if (!phy_cfg)
320+ return -ENOMEM;
321+
322+ phy_cfg->regs = regs;
323+ phy_cfg->version = version;
324+ phy_cfg->offset = bcm_usb_hs_phy;
325+ phy_cfg->type = USB_HS_PHY;
326+ phy_cfg->phy = devm_phy_create(dev, node, &sr_phy_ops);
327+ if (IS_ERR(phy_cfg->phy))
328+ return PTR_ERR(phy_cfg->phy);
329+
330+ phy_set_drvdata(phy_cfg->phy, phy_cfg);
331+ } else
332+ return -ENODEV;
333+
334+ dev_set_drvdata(dev, phy_cfg);
335+
336+ return 0;
337+}
338+
339+static const struct of_device_id bcm_usb_phy_of_match[] = {
340+ {
341+ .compatible = "brcm,sr-usb-combo-phy",
342+ .data = (void *)BCM_SR_USB_COMBO_PHY,
343+ },
344+ {
345+ .compatible = "brcm,sr-usb-hs-phy",
346+ .data = (void *)BCM_SR_USB_HS_PHY,
347+ },
348+ { /* sentinel */ },
349+};
350+MODULE_DEVICE_TABLE(of, bcm_usb_phy_of_match);
351+
352+static int bcm_usb_phy_probe(struct platform_device *pdev)
353+{
354+ struct device *dev = &pdev->dev;
355+ struct device_node *dn = dev->of_node;
356+ const struct of_device_id *of_id;
357+ struct resource *res;
358+ void __iomem *regs;
359+ int ret;
360+ enum bcm_usb_phy_version version;
361+ struct phy_provider *phy_provider;
362+
363+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
364+ regs = devm_ioremap_resource(dev, res);
365+ if (IS_ERR(regs))
366+ return PTR_ERR(regs);
367+
368+ of_id = of_match_node(bcm_usb_phy_of_match, dn);
369+ if (of_id)
370+ version = (enum bcm_usb_phy_version)of_id->data;
371+ else
372+ return -ENODEV;
373+
374+ ret = bcm_usb_phy_create(dev, dn, regs, version);
375+ if (ret)
376+ return ret;
377+
378+ phy_provider = devm_of_phy_provider_register(dev, bcm_usb_phy_xlate);
379+
380+ return PTR_ERR_OR_ZERO(phy_provider);
381+}
382+
383+static struct platform_driver bcm_usb_phy_driver = {
384+ .driver = {
385+ .name = "phy-bcm-sr-usb",
386+ .of_match_table = bcm_usb_phy_of_match,
387+ },
388+ .probe = bcm_usb_phy_probe,
389+};
390+module_platform_driver(bcm_usb_phy_driver);
391+
392+MODULE_AUTHOR("Broadcom");
393+MODULE_DESCRIPTION("Broadcom stingray USB Phy driver");
394+MODULE_LICENSE("GPL v2");
drivers/phy/freescale/phy-fsl-imx8mq-usb.c+12−0
@@ -6,6 +6,7 @@ · 5 unmodified lines
66 #include <linux/module.h>
77 #include <linux/phy/phy.h>
88 #include <linux/platform_device.h>
9+#include <linux/regulator/consumer.h>
910
1011 #define PHY_CTRL0 0x0
1112 #define PHY_CTRL0_REF_SSP_EN BIT(2)
@@ -24,6 +25,7 @@ struct imx8mq_usb_phy { · 12 unmodified lines
2425 struct phy *phy;
2526 struct clk *clk;
2627 void __iomem *base;
28+ struct regulator *vbus;
2729 };
2830
2931 static int imx8mq_usb_phy_init(struct phy *phy)
@@ -55,6 +57,11 @@ static int imx8mq_usb_phy_init(struct phy *phy) · 25 unmodified lines
5557 static int imx8mq_phy_power_on(struct phy *phy)
5658 {
5759 struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
60+ int ret;
61+
62+ ret = regulator_enable(imx_phy->vbus);
63+ if (ret)
64+ return ret;
5865
5966 return clk_prepare_enable(imx_phy->clk);
6067 }
@@ -64,6 +71,7 @@ static int imx8mq_phy_power_off(struct phy *phy) · 3 unmodified lines
6471 struct imx8mq_usb_phy *imx_phy = phy_get_drvdata(phy);
6572
6673 clk_disable_unprepare(imx_phy->clk);
74+ regulator_disable(imx_phy->vbus);
6775
6876 return 0;
6977 }
@@ -101,6 +109,10 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev) · 31 unmodified lines
101109 if (IS_ERR(imx_phy->phy))
102110 return PTR_ERR(imx_phy->phy);
103111
112+ imx_phy->vbus = devm_regulator_get(dev, "vbus");
113+ if (IS_ERR(imx_phy->vbus))
114+ return PTR_ERR(imx_phy->vbus);
115+
104116 phy_set_drvdata(imx_phy->phy, imx_phy);
105117
106118 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
drivers/phy/hisilicon/Kconfig+10−0
@@ -12,6 +12,16 @@ config PHY_HI6220_USB · 11 unmodified lines
1212
1313 To compile this driver as a module, choose M here.
1414
15+config PHY_HI3660_USB
16+ tristate "hi3660 USB PHY support"
17+ depends on (ARCH_HISI && ARM64) || COMPILE_TEST
18+ select GENERIC_PHY
19+ select MFD_SYSCON
20+ help
21+ Enable this to support the HISILICON HI3660 USB PHY.
22+
23+ To compile this driver as a module, choose M here.
24+
1525 config PHY_HISTB_COMBPHY
1626 tristate "HiSilicon STB SoCs COMBPHY support"
1727 depends on (ARCH_HISI && ARM64) || COMPILE_TEST
drivers/phy/hisilicon/Makefile+1−0
@@ -1,4 +1,5 @@
11 obj-$(CONFIG_PHY_HI6220_USB) += phy-hi6220-usb.o
2+obj-$(CONFIG_PHY_HI3660_USB) += phy-hi3660-usb3.o
23 obj-$(CONFIG_PHY_HISTB_COMBPHY) += phy-histb-combphy.o
34 obj-$(CONFIG_PHY_HISI_INNO_USB2) += phy-hisi-inno-usb2.o
45 obj-$(CONFIG_PHY_HIX5HD2_SATA) += phy-hix5hd2-sata.o
drivers/phy/hisilicon/phy-hi3660-usb3.c+233−0
@@ -0,0 +1,233 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Phy provider for USB 3.0 controller on HiSilicon 3660 platform
4+ *
5+ * Copyright (C) 2017-2018 Hilisicon Electronics Co., Ltd.
6+ * http://www.huawei.com
7+ *
8+ * Authors: Yu Chen <chenyu56@huawei.com>
9+ */
10+
11+#include <linux/kernel.h>
12+#include <linux/mfd/syscon.h>
13+#include <linux/module.h>
14+#include <linux/phy/phy.h>
15+#include <linux/platform_device.h>
16+#include <linux/regmap.h>
17+
18+#define PERI_CRG_CLK_EN4 0x40
19+#define PERI_CRG_CLK_DIS4 0x44
20+#define GT_CLK_USB3OTG_REF BIT(0)
21+#define GT_ACLK_USB3OTG BIT(1)
22+
23+#define PERI_CRG_RSTEN4 0x90
24+#define PERI_CRG_RSTDIS4 0x94
25+#define IP_RST_USB3OTGPHY_POR BIT(3)
26+#define IP_RST_USB3OTG BIT(5)
27+
28+#define PERI_CRG_ISODIS 0x148
29+#define USB_REFCLK_ISO_EN BIT(25)
30+
31+#define PCTRL_PERI_CTRL3 0x10
32+#define PCTRL_PERI_CTRL3_MSK_START 16
33+#define USB_TCXO_EN BIT(1)
34+
35+#define PCTRL_PERI_CTRL24 0x64
36+#define SC_CLK_USB3PHY_3MUX1_SEL BIT(25)
37+
38+#define USBOTG3_CTRL0 0x00
39+#define SC_USB3PHY_ABB_GT_EN BIT(15)
40+
41+#define USBOTG3_CTRL2 0x08
42+#define USBOTG3CTRL2_POWERDOWN_HSP BIT(0)
43+#define USBOTG3CTRL2_POWERDOWN_SSP BIT(1)
44+
45+#define USBOTG3_CTRL3 0x0C
46+#define USBOTG3_CTRL3_VBUSVLDEXT BIT(6)
47+#define USBOTG3_CTRL3_VBUSVLDEXTSEL BIT(5)
48+
49+#define USBOTG3_CTRL4 0x10
50+
51+#define USBOTG3_CTRL7 0x1c
52+#define REF_SSP_EN BIT(16)
53+
54+/* This value config the default txtune parameter of the usb 2.0 phy */
55+#define HI3660_USB_DEFAULT_PHY_PARAM 0x1c466e3
56+
57+struct hi3660_priv {
58+ struct device *dev;
59+ struct regmap *peri_crg;
60+ struct regmap *pctrl;
61+ struct regmap *otg_bc;
62+ u32 eye_diagram_param;
63+};
64+
65+static int hi3660_phy_init(struct phy *phy)
66+{
67+ struct hi3660_priv *priv = phy_get_drvdata(phy);
68+ u32 val, mask;
69+ int ret;
70+
71+ /* usb refclk iso disable */
72+ ret = regmap_write(priv->peri_crg, PERI_CRG_ISODIS, USB_REFCLK_ISO_EN);
73+ if (ret)
74+ goto out;
75+
76+ /* enable usb_tcxo_en */
77+ val = USB_TCXO_EN | (USB_TCXO_EN << PCTRL_PERI_CTRL3_MSK_START);
78+ ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val);
79+ if (ret)
80+ goto out;
81+
82+ /* assert phy */
83+ val = IP_RST_USB3OTGPHY_POR | IP_RST_USB3OTG;
84+ ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val);
85+ if (ret)
86+ goto out;
87+
88+ /* enable phy ref clk */
89+ val = SC_USB3PHY_ABB_GT_EN;
90+ mask = val;
91+ ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL0, mask, val);
92+ if (ret)
93+ goto out;
94+
95+ val = REF_SSP_EN;
96+ mask = val;
97+ ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL7, mask, val);
98+ if (ret)
99+ goto out;
100+
101+ /* exit from IDDQ mode */
102+ mask = USBOTG3CTRL2_POWERDOWN_HSP | USBOTG3CTRL2_POWERDOWN_SSP;
103+ ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL2, mask, 0);
104+ if (ret)
105+ goto out;
106+
107+ /* delay for exit from IDDQ mode */
108+ usleep_range(100, 120);
109+
110+ /* deassert phy */
111+ val = IP_RST_USB3OTGPHY_POR | IP_RST_USB3OTG;
112+ ret = regmap_write(priv->peri_crg, PERI_CRG_RSTDIS4, val);
113+ if (ret)
114+ goto out;
115+
116+ /* delay for phy deasserted */
117+ usleep_range(10000, 15000);
118+
119+ /* fake vbus valid signal */
120+ val = USBOTG3_CTRL3_VBUSVLDEXT | USBOTG3_CTRL3_VBUSVLDEXTSEL;
121+ mask = val;
122+ ret = regmap_update_bits(priv->otg_bc, USBOTG3_CTRL3, mask, val);
123+ if (ret)
124+ goto out;
125+
126+ /* delay for vbus valid */
127+ usleep_range(100, 120);
128+
129+ ret = regmap_write(priv->otg_bc, USBOTG3_CTRL4,
130+ priv->eye_diagram_param);
131+ if (ret)
132+ goto out;
133+
134+ return 0;
135+out:
136+ dev_err(priv->dev, "failed to init phy ret: %d\n", ret);
137+ return ret;
138+}
139+
140+static int hi3660_phy_exit(struct phy *phy)
141+{
142+ struct hi3660_priv *priv = phy_get_drvdata(phy);
143+ u32 val;
144+ int ret;
145+
146+ /* assert phy */
147+ val = IP_RST_USB3OTGPHY_POR;
148+ ret = regmap_write(priv->peri_crg, PERI_CRG_RSTEN4, val);
149+ if (ret)
150+ goto out;
151+
152+ /* disable usb_tcxo_en */
153+ val = USB_TCXO_EN << PCTRL_PERI_CTRL3_MSK_START;
154+ ret = regmap_write(priv->pctrl, PCTRL_PERI_CTRL3, val);
155+ if (ret)
156+ goto out;
157+
158+ return 0;
159+out:
160+ dev_err(priv->dev, "failed to exit phy ret: %d\n", ret);
161+ return ret;
162+}
163+
164+static struct phy_ops hi3660_phy_ops = {
165+ .init = hi3660_phy_init,
166+ .exit = hi3660_phy_exit,
167+ .owner = THIS_MODULE,
168+};
169+
170+static int hi3660_phy_probe(struct platform_device *pdev)
171+{
172+ struct phy_provider *phy_provider;
173+ struct device *dev = &pdev->dev;
174+ struct phy *phy;
175+ struct hi3660_priv *priv;
176+
177+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
178+ if (!priv)
179+ return -ENOMEM;
180+
181+ priv->dev = dev;
182+ priv->peri_crg = syscon_regmap_lookup_by_phandle(dev->of_node,
183+ "hisilicon,pericrg-syscon");
184+ if (IS_ERR(priv->peri_crg)) {
185+ dev_err(dev, "no hisilicon,pericrg-syscon\n");
186+ return PTR_ERR(priv->peri_crg);
187+ }
188+
189+ priv->pctrl = syscon_regmap_lookup_by_phandle(dev->of_node,
190+ "hisilicon,pctrl-syscon");
191+ if (IS_ERR(priv->pctrl)) {
192+ dev_err(dev, "no hisilicon,pctrl-syscon\n");
193+ return PTR_ERR(priv->pctrl);
194+ }
195+
196+ /* node of hi3660 phy is a sub-node of usb3_otg_bc */
197+ priv->otg_bc = syscon_node_to_regmap(dev->parent->of_node);
198+ if (IS_ERR(priv->otg_bc)) {
199+ dev_err(dev, "no hisilicon,usb3-otg-bc-syscon\n");
200+ return PTR_ERR(priv->otg_bc);
201+ }
202+
203+ if (of_property_read_u32(dev->of_node, "hisilicon,eye-diagram-param",
204+ &(priv->eye_diagram_param)))
205+ priv->eye_diagram_param = HI3660_USB_DEFAULT_PHY_PARAM;
206+
207+ phy = devm_phy_create(dev, NULL, &hi3660_phy_ops);
208+ if (IS_ERR(phy))
209+ return PTR_ERR(phy);
210+
211+ phy_set_drvdata(phy, priv);
212+ phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
213+ return PTR_ERR_OR_ZERO(phy_provider);
214+}
215+
216+static const struct of_device_id hi3660_phy_of_match[] = {
217+ {.compatible = "hisilicon,hi3660-usb-phy",},
218+ { }
219+};
220+MODULE_DEVICE_TABLE(of, hi3660_phy_of_match);
221+
222+static struct platform_driver hi3660_phy_driver = {
223+ .probe = hi3660_phy_probe,
224+ .driver = {
225+ .name = "hi3660-usb-phy",
226+ .of_match_table = hi3660_phy_of_match,
227+ }
228+};
229+module_platform_driver(hi3660_phy_driver);
230+
231+MODULE_AUTHOR("Yu Chen <chenyu56@huawei.com>");
232+MODULE_LICENSE("GPL v2");
233+MODULE_DESCRIPTION("Hilisicon Hi3660 USB3 PHY Driver");
drivers/phy/mediatek/Kconfig+10−0
@@ -13,6 +13,16 @@ config PHY_MTK_TPHY · 12 unmodified lines
1313 multi-ports is first version, otherwise is second veriosn,
1414 so you can easily distinguish them by banks layout.
1515
16+config PHY_MTK_UFS
17+ tristate "MediaTek UFS M-PHY driver"
18+ depends on ARCH_MEDIATEK && OF
19+ select GENERIC_PHY
20+ help
21+ Support for UFS M-PHY on MediaTek chipsets.
22+ Enable this to provide vendor-specific probing,
23+ initialization, power on and power off flow of
24+ specified M-PHYs.
25+
1626 config PHY_MTK_XSPHY
1727 tristate "MediaTek XS-PHY Driver"
1828 depends on ARCH_MEDIATEK && OF
drivers/phy/mediatek/Makefile+1−0
@@ -4,4 +4,5 @@ · 3 unmodified lines
44 #
55
66 obj-$(CONFIG_PHY_MTK_TPHY) += phy-mtk-tphy.o
7+obj-$(CONFIG_PHY_MTK_UFS) += phy-mtk-ufs.o
78 obj-$(CONFIG_PHY_MTK_XSPHY) += phy-mtk-xsphy.o
drivers/phy/mediatek/phy-mtk-tphy.c+3−7
@@ -1103,13 +1103,9 @@ static int mtk_tphy_probe(struct platform_device *pdev) · 1102 unmodified lines
11031103 }
11041104
11051105 /* it's deprecated, make it optional for backward compatibility */
1106− tphy->u3phya_ref = devm_clk_get(dev, "u3phya_ref");
1107− if (IS_ERR(tphy->u3phya_ref)) {
1108− if (PTR_ERR(tphy->u3phya_ref) == -EPROBE_DEFER)
1109− return -EPROBE_DEFER;
1110−
1111− tphy->u3phya_ref = NULL;
1112− }
1106+ tphy->u3phya_ref = devm_clk_get_optional(dev, "u3phya_ref");
1107+ if (IS_ERR(tphy->u3phya_ref))
1108+ return PTR_ERR(tphy->u3phya_ref);
11131109
11141110 tphy->src_ref_clk = U3P_REF_CLK;
11151111 tphy->src_coef = U3P_SLEW_RATE_COEF;
drivers/phy/mediatek/phy-mtk-ufs.c+245−0
@@ -0,0 +1,245 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2019 MediaTek Inc.
4+ * Author: Stanley Chu <stanley.chu@mediatek.com>
5+ */
6+
7+#include <linux/clk.h>
8+#include <linux/delay.h>
9+#include <linux/io.h>
10+#include <linux/module.h>
11+#include <linux/phy/phy.h>
12+#include <linux/platform_device.h>
13+
14+/* mphy register and offsets */
15+#define MP_GLB_DIG_8C 0x008C
16+#define FRC_PLL_ISO_EN BIT(8)
17+#define PLL_ISO_EN BIT(9)
18+#define FRC_FRC_PWR_ON BIT(10)
19+#define PLL_PWR_ON BIT(11)
20+
21+#define MP_LN_DIG_RX_9C 0xA09C
22+#define FSM_DIFZ_FRC BIT(18)
23+
24+#define MP_LN_DIG_RX_AC 0xA0AC
25+#define FRC_RX_SQ_EN BIT(0)
26+#define RX_SQ_EN BIT(1)
27+
28+#define MP_LN_RX_44 0xB044
29+#define FRC_CDR_PWR_ON BIT(17)
30+#define CDR_PWR_ON BIT(18)
31+#define FRC_CDR_ISO_EN BIT(19)
32+#define CDR_ISO_EN BIT(20)
33+
34+struct ufs_mtk_phy {
35+ struct device *dev;
36+ void __iomem *mmio;
37+ struct clk *mp_clk;
38+ struct clk *unipro_clk;
39+};
40+
41+static inline u32 mphy_readl(struct ufs_mtk_phy *phy, u32 reg)
42+{
43+ return readl(phy->mmio + reg);
44+}
45+
46+static inline void mphy_writel(struct ufs_mtk_phy *phy, u32 val, u32 reg)
47+{
48+ writel(val, phy->mmio + reg);
49+}
50+
51+static void mphy_set_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit)
52+{
53+ u32 val;
54+
55+ val = mphy_readl(phy, reg);
56+ val |= bit;
57+ mphy_writel(phy, val, reg);
58+}
59+
60+static void mphy_clr_bit(struct ufs_mtk_phy *phy, u32 reg, u32 bit)
61+{
62+ u32 val;
63+
64+ val = mphy_readl(phy, reg);
65+ val &= ~bit;
66+ mphy_writel(phy, val, reg);
67+}
68+
69+static struct ufs_mtk_phy *get_ufs_mtk_phy(struct phy *generic_phy)
70+{
71+ return (struct ufs_mtk_phy *)phy_get_drvdata(generic_phy);
72+}
73+
74+static int ufs_mtk_phy_clk_init(struct ufs_mtk_phy *phy)
75+{
76+ struct device *dev = phy->dev;
77+
78+ phy->unipro_clk = devm_clk_get(dev, "unipro");
79+ if (IS_ERR(phy->unipro_clk)) {
80+ dev_err(dev, "failed to get clock: unipro");
81+ return PTR_ERR(phy->unipro_clk);
82+ }
83+
84+ phy->mp_clk = devm_clk_get(dev, "mp");
85+ if (IS_ERR(phy->mp_clk)) {
86+ dev_err(dev, "failed to get clock: mp");
87+ return PTR_ERR(phy->mp_clk);
88+ }
89+
90+ return 0;
91+}
92+
93+static void ufs_mtk_phy_set_active(struct ufs_mtk_phy *phy)
94+{
95+ /* release DA_MP_PLL_PWR_ON */
96+ mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON);
97+ mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON);
98+
99+ /* release DA_MP_PLL_ISO_EN */
100+ mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN);
101+ mphy_clr_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN);
102+
103+ /* release DA_MP_CDR_PWR_ON */
104+ mphy_set_bit(phy, MP_LN_RX_44, CDR_PWR_ON);
105+ mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON);
106+
107+ /* release DA_MP_CDR_ISO_EN */
108+ mphy_clr_bit(phy, MP_LN_RX_44, CDR_ISO_EN);
109+ mphy_clr_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN);
110+
111+ /* release DA_MP_RX0_SQ_EN */
112+ mphy_set_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN);
113+ mphy_clr_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN);
114+
115+ /* delay 1us to wait DIFZ stable */
116+ udelay(1);
117+
118+ /* release DIFZ */
119+ mphy_clr_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC);
120+}
121+
122+static void ufs_mtk_phy_set_deep_hibern(struct ufs_mtk_phy *phy)
123+{
124+ /* force DIFZ */
125+ mphy_set_bit(phy, MP_LN_DIG_RX_9C, FSM_DIFZ_FRC);
126+
127+ /* force DA_MP_RX0_SQ_EN */
128+ mphy_set_bit(phy, MP_LN_DIG_RX_AC, FRC_RX_SQ_EN);
129+ mphy_clr_bit(phy, MP_LN_DIG_RX_AC, RX_SQ_EN);
130+
131+ /* force DA_MP_CDR_ISO_EN */
132+ mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_ISO_EN);
133+ mphy_set_bit(phy, MP_LN_RX_44, CDR_ISO_EN);
134+
135+ /* force DA_MP_CDR_PWR_ON */
136+ mphy_set_bit(phy, MP_LN_RX_44, FRC_CDR_PWR_ON);
137+ mphy_clr_bit(phy, MP_LN_RX_44, CDR_PWR_ON);
138+
139+ /* force DA_MP_PLL_ISO_EN */
140+ mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_PLL_ISO_EN);
141+ mphy_set_bit(phy, MP_GLB_DIG_8C, PLL_ISO_EN);
142+
143+ /* force DA_MP_PLL_PWR_ON */
144+ mphy_set_bit(phy, MP_GLB_DIG_8C, FRC_FRC_PWR_ON);
145+ mphy_clr_bit(phy, MP_GLB_DIG_8C, PLL_PWR_ON);
146+}
147+
148+static int ufs_mtk_phy_power_on(struct phy *generic_phy)
149+{
150+ struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy);
151+ int ret;
152+
153+ ret = clk_prepare_enable(phy->unipro_clk);
154+ if (ret) {
155+ dev_err(phy->dev, "unipro_clk enable failed %d\n", ret);
156+ goto out;
157+ }
158+
159+ ret = clk_prepare_enable(phy->mp_clk);
160+ if (ret) {
161+ dev_err(phy->dev, "mp_clk enable failed %d\n", ret);
162+ goto out_unprepare_unipro_clk;
163+ }
164+
165+ ufs_mtk_phy_set_active(phy);
166+
167+ return 0;
168+
169+out_unprepare_unipro_clk:
170+ clk_disable_unprepare(phy->unipro_clk);
171+out:
172+ return ret;
173+}
174+
175+static int ufs_mtk_phy_power_off(struct phy *generic_phy)
176+{
177+ struct ufs_mtk_phy *phy = get_ufs_mtk_phy(generic_phy);
178+
179+ ufs_mtk_phy_set_deep_hibern(phy);
180+
181+ clk_disable_unprepare(phy->unipro_clk);
182+ clk_disable_unprepare(phy->mp_clk);
183+
184+ return 0;
185+}
186+
187+static const struct phy_ops ufs_mtk_phy_ops = {
188+ .power_on = ufs_mtk_phy_power_on,
189+ .power_off = ufs_mtk_phy_power_off,
190+ .owner = THIS_MODULE,
191+};
192+
193+static int ufs_mtk_phy_probe(struct platform_device *pdev)
194+{
195+ struct device *dev = &pdev->dev;
196+ struct phy *generic_phy;
197+ struct phy_provider *phy_provider;
198+ struct resource *res;
199+ struct ufs_mtk_phy *phy;
200+ int ret;
201+
202+ phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
203+ if (!phy)
204+ return -ENOMEM;
205+
206+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
207+ phy->mmio = devm_ioremap_resource(dev, res);
208+ if (IS_ERR(phy->mmio))
209+ return PTR_ERR(phy->mmio);
210+
211+ phy->dev = dev;
212+
213+ ret = ufs_mtk_phy_clk_init(phy);
214+ if (ret)
215+ return ret;
216+
217+ generic_phy = devm_phy_create(dev, NULL, &ufs_mtk_phy_ops);
218+ if (IS_ERR(generic_phy))
219+ return PTR_ERR(generic_phy);
220+
221+ phy_set_drvdata(generic_phy, phy);
222+
223+ phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
224+
225+ return PTR_ERR_OR_ZERO(phy_provider);
226+}
227+
228+static const struct of_device_id ufs_mtk_phy_of_match[] = {
229+ {.compatible = "mediatek,mt8183-ufsphy"},
230+ {},
231+};
232+MODULE_DEVICE_TABLE(of, ufs_mtk_phy_of_match);
233+
234+static struct platform_driver ufs_mtk_phy_driver = {
235+ .probe = ufs_mtk_phy_probe,
236+ .driver = {
237+ .of_match_table = ufs_mtk_phy_of_match,
238+ .name = "ufs_mtk_phy",
239+ },
240+};
241+module_platform_driver(ufs_mtk_phy_driver);
242+
243+MODULE_DESCRIPTION("Universal Flash Storage (UFS) MediaTek MPHY");
244+MODULE_AUTHOR("Stanley Chu <stanley.chu@mediatek.com>");
245+MODULE_LICENSE("GPL v2");
drivers/phy/mscc/phy-ocelot-serdes.c+238−2
@@ -31,6 +31,238 @@ struct serdes_macro { · 30 unmodified lines
3131 struct serdes_ctrl *ctrl;
3232 };
3333
34+#define MCB_S6G_CFG_TIMEOUT 50
35+
36+static int __serdes_write_mcb_s6g(struct regmap *regmap, u8 macro, u32 op)
37+{
38+ unsigned int regval = 0;
39+
40+ regmap_write(regmap, HSIO_MCB_S6G_ADDR_CFG, op |
41+ HSIO_MCB_S6G_ADDR_CFG_SERDES6G_ADDR(BIT(macro)));
42+
43+ return regmap_read_poll_timeout(regmap, HSIO_MCB_S6G_ADDR_CFG, regval,
44+ (regval & op) != op, 100,
45+ MCB_S6G_CFG_TIMEOUT * 1000);
46+}
47+
48+static int serdes_commit_mcb_s6g(struct regmap *regmap, u8 macro)
49+{
50+ return __serdes_write_mcb_s6g(regmap, macro,
51+ HSIO_MCB_S6G_ADDR_CFG_SERDES6G_WR_ONE_SHOT);
52+}
53+
54+static int serdes_update_mcb_s6g(struct regmap *regmap, u8 macro)
55+{
56+ return __serdes_write_mcb_s6g(regmap, macro,
57+ HSIO_MCB_S6G_ADDR_CFG_SERDES6G_RD_ONE_SHOT);
58+}
59+
60+static int serdes_init_s6g(struct regmap *regmap, u8 serdes, int mode)
61+{
62+ u32 pll_fsm_ctrl_data;
63+ u32 ob_ena1v_mode;
64+ u32 des_bw_ana;
65+ u32 ob_ena_cas;
66+ u32 if_mode;
67+ u32 ob_lev;
68+ u32 qrate;
69+ int ret;
70+
71+ if (mode == PHY_INTERFACE_MODE_QSGMII) {
72+ pll_fsm_ctrl_data = 120;
73+ ob_ena1v_mode = 0;
74+ ob_ena_cas = 0;
75+ des_bw_ana = 5;
76+ ob_lev = 24;
77+ if_mode = 3;
78+ qrate = 0;
79+ } else {
80+ pll_fsm_ctrl_data = 60;
81+ ob_ena1v_mode = 1;
82+ ob_ena_cas = 2;
83+ des_bw_ana = 3;
84+ ob_lev = 48;
85+ if_mode = 1;
86+ qrate = 1;
87+ }
88+
89+ ret = serdes_update_mcb_s6g(regmap, serdes);
90+ if (ret)
91+ return ret;
92+
93+ /* Test pattern */
94+
95+ regmap_update_bits(regmap, HSIO_S6G_COMMON_CFG,
96+ HSIO_S6G_COMMON_CFG_SYS_RST, 0);
97+
98+ regmap_update_bits(regmap, HSIO_S6G_PLL_CFG,
99+ HSIO_S6G_PLL_CFG_PLL_FSM_ENA, 0);
100+
101+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG,
102+ HSIO_S6G_IB_CFG_IB_SIG_DET_ENA |
103+ HSIO_S6G_IB_CFG_IB_REG_ENA |
104+ HSIO_S6G_IB_CFG_IB_SAM_ENA |
105+ HSIO_S6G_IB_CFG_IB_EQZ_ENA |
106+ HSIO_S6G_IB_CFG_IB_CONCUR |
107+ HSIO_S6G_IB_CFG_IB_CAL_ENA,
108+ HSIO_S6G_IB_CFG_IB_SIG_DET_ENA |
109+ HSIO_S6G_IB_CFG_IB_REG_ENA |
110+ HSIO_S6G_IB_CFG_IB_SAM_ENA |
111+ HSIO_S6G_IB_CFG_IB_EQZ_ENA |
112+ HSIO_S6G_IB_CFG_IB_CONCUR);
113+
114+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG1,
115+ HSIO_S6G_IB_CFG1_IB_FRC_OFFSET |
116+ HSIO_S6G_IB_CFG1_IB_FRC_LP |
117+ HSIO_S6G_IB_CFG1_IB_FRC_MID |
118+ HSIO_S6G_IB_CFG1_IB_FRC_HP |
119+ HSIO_S6G_IB_CFG1_IB_FILT_OFFSET |
120+ HSIO_S6G_IB_CFG1_IB_FILT_LP |
121+ HSIO_S6G_IB_CFG1_IB_FILT_MID |
122+ HSIO_S6G_IB_CFG1_IB_FILT_HP,
123+ HSIO_S6G_IB_CFG1_IB_FILT_OFFSET |
124+ HSIO_S6G_IB_CFG1_IB_FILT_HP |
125+ HSIO_S6G_IB_CFG1_IB_FILT_LP |
126+ HSIO_S6G_IB_CFG1_IB_FILT_MID);
127+
128+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG2,
129+ HSIO_S6G_IB_CFG2_IB_UREG_M,
130+ HSIO_S6G_IB_CFG2_IB_UREG(4));
131+
132+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG3,
133+ HSIO_S6G_IB_CFG3_IB_INI_OFFSET_M |
134+ HSIO_S6G_IB_CFG3_IB_INI_LP_M |
135+ HSIO_S6G_IB_CFG3_IB_INI_MID_M |
136+ HSIO_S6G_IB_CFG3_IB_INI_HP_M,
137+ HSIO_S6G_IB_CFG3_IB_INI_OFFSET(31) |
138+ HSIO_S6G_IB_CFG3_IB_INI_LP(1) |
139+ HSIO_S6G_IB_CFG3_IB_INI_MID(31) |
140+ HSIO_S6G_IB_CFG3_IB_INI_HP(0));
141+
142+ regmap_update_bits(regmap, HSIO_S6G_MISC_CFG,
143+ HSIO_S6G_MISC_CFG_LANE_RST,
144+ HSIO_S6G_MISC_CFG_LANE_RST);
145+
146+ ret = serdes_commit_mcb_s6g(regmap, serdes);
147+ if (ret)
148+ return ret;
149+
150+ /* OB + DES + IB + SER CFG */
151+ regmap_update_bits(regmap, HSIO_S6G_OB_CFG,
152+ HSIO_S6G_OB_CFG_OB_IDLE |
153+ HSIO_S6G_OB_CFG_OB_ENA1V_MODE |
154+ HSIO_S6G_OB_CFG_OB_POST0_M |
155+ HSIO_S6G_OB_CFG_OB_PREC_M,
156+ (ob_ena1v_mode ? HSIO_S6G_OB_CFG_OB_ENA1V_MODE : 0) |
157+ HSIO_S6G_OB_CFG_OB_POST0(0) |
158+ HSIO_S6G_OB_CFG_OB_PREC(0));
159+
160+ regmap_update_bits(regmap, HSIO_S6G_OB_CFG1,
161+ HSIO_S6G_OB_CFG1_OB_ENA_CAS_M |
162+ HSIO_S6G_OB_CFG1_OB_LEV_M,
163+ HSIO_S6G_OB_CFG1_OB_LEV(ob_lev) |
164+ HSIO_S6G_OB_CFG1_OB_ENA_CAS(ob_ena_cas));
165+
166+ regmap_update_bits(regmap, HSIO_S6G_DES_CFG,
167+ HSIO_S6G_DES_CFG_DES_PHS_CTRL_M |
168+ HSIO_S6G_DES_CFG_DES_CPMD_SEL_M |
169+ HSIO_S6G_DES_CFG_DES_BW_ANA_M,
170+ HSIO_S6G_DES_CFG_DES_PHS_CTRL(2) |
171+ HSIO_S6G_DES_CFG_DES_CPMD_SEL(0) |
172+ HSIO_S6G_DES_CFG_DES_BW_ANA(des_bw_ana));
173+
174+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG,
175+ HSIO_S6G_IB_CFG_IB_SIG_DET_CLK_SEL_M |
176+ HSIO_S6G_IB_CFG_IB_REG_PAT_SEL_OFFSET_M,
177+ HSIO_S6G_IB_CFG_IB_REG_PAT_SEL_OFFSET(0) |
178+ HSIO_S6G_IB_CFG_IB_SIG_DET_CLK_SEL(0));
179+
180+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG1,
181+ HSIO_S6G_IB_CFG1_IB_TSDET_M,
182+ HSIO_S6G_IB_CFG1_IB_TSDET(16));
183+
184+ regmap_update_bits(regmap, HSIO_S6G_SER_CFG,
185+ HSIO_S6G_SER_CFG_SER_ALISEL_M |
186+ HSIO_S6G_SER_CFG_SER_ENALI,
187+ HSIO_S6G_SER_CFG_SER_ALISEL(0));
188+
189+ regmap_update_bits(regmap, HSIO_S6G_PLL_CFG,
190+ HSIO_S6G_PLL_CFG_PLL_DIV4 |
191+ HSIO_S6G_PLL_CFG_PLL_ENA_ROT |
192+ HSIO_S6G_PLL_CFG_PLL_FSM_CTRL_DATA_M |
193+ HSIO_S6G_PLL_CFG_PLL_ROT_DIR |
194+ HSIO_S6G_PLL_CFG_PLL_ROT_FRQ,
195+ HSIO_S6G_PLL_CFG_PLL_FSM_CTRL_DATA
196+ (pll_fsm_ctrl_data));
197+
198+ regmap_update_bits(regmap, HSIO_S6G_COMMON_CFG,
199+ HSIO_S6G_COMMON_CFG_SYS_RST |
200+ HSIO_S6G_COMMON_CFG_ENA_LANE |
201+ HSIO_S6G_COMMON_CFG_PWD_RX |
202+ HSIO_S6G_COMMON_CFG_PWD_TX |
203+ HSIO_S6G_COMMON_CFG_HRATE |
204+ HSIO_S6G_COMMON_CFG_QRATE |
205+ HSIO_S6G_COMMON_CFG_ENA_ELOOP |
206+ HSIO_S6G_COMMON_CFG_ENA_FLOOP |
207+ HSIO_S6G_COMMON_CFG_IF_MODE_M,
208+ HSIO_S6G_COMMON_CFG_SYS_RST |
209+ HSIO_S6G_COMMON_CFG_ENA_LANE |
210+ (qrate ? HSIO_S6G_COMMON_CFG_QRATE : 0) |
211+ HSIO_S6G_COMMON_CFG_IF_MODE(if_mode));
212+
213+ regmap_update_bits(regmap, HSIO_S6G_MISC_CFG,
214+ HSIO_S6G_MISC_CFG_LANE_RST |
215+ HSIO_S6G_MISC_CFG_DES_100FX_CPMD_ENA |
216+ HSIO_S6G_MISC_CFG_RX_LPI_MODE_ENA |
217+ HSIO_S6G_MISC_CFG_TX_LPI_MODE_ENA,
218+ HSIO_S6G_MISC_CFG_LANE_RST |
219+ HSIO_S6G_MISC_CFG_RX_LPI_MODE_ENA);
220+
221+
222+ ret = serdes_commit_mcb_s6g(regmap, serdes);
223+ if (ret)
224+ return ret;
225+
226+ regmap_update_bits(regmap, HSIO_S6G_PLL_CFG,
227+ HSIO_S6G_PLL_CFG_PLL_FSM_ENA,
228+ HSIO_S6G_PLL_CFG_PLL_FSM_ENA);
229+
230+ ret = serdes_commit_mcb_s6g(regmap, serdes);
231+ if (ret)
232+ return ret;
233+
234+ /* Wait for PLL bringup */
235+ msleep(20);
236+
237+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG,
238+ HSIO_S6G_IB_CFG_IB_CAL_ENA,
239+ HSIO_S6G_IB_CFG_IB_CAL_ENA);
240+
241+ regmap_update_bits(regmap, HSIO_S6G_MISC_CFG,
242+ HSIO_S6G_MISC_CFG_LANE_RST, 0);
243+
244+ ret = serdes_commit_mcb_s6g(regmap, serdes);
245+ if (ret)
246+ return ret;
247+
248+ /* Wait for calibration */
249+ msleep(60);
250+
251+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG,
252+ HSIO_S6G_IB_CFG_IB_REG_PAT_SEL_OFFSET_M |
253+ HSIO_S6G_IB_CFG_IB_SIG_DET_CLK_SEL_M,
254+ HSIO_S6G_IB_CFG_IB_REG_PAT_SEL_OFFSET(0) |
255+ HSIO_S6G_IB_CFG_IB_SIG_DET_CLK_SEL(7));
256+
257+ regmap_update_bits(regmap, HSIO_S6G_IB_CFG1,
258+ HSIO_S6G_IB_CFG1_IB_TSDET_M,
259+ HSIO_S6G_IB_CFG1_IB_TSDET(3));
260+
261+ /* IB CFG */
262+
263+ return 0;
264+}
265+
34266 #define MCB_S1G_CFG_TIMEOUT 50
35267
36268 static int __serdes_write_mcb_s1g(struct regmap *regmap, u8 macro, u32 op)
@@ -110,7 +342,7 @@ struct serdes_mux { · 73 unmodified lines
110342 u32 mux;
111343 };
112344
113−#define SERDES_MUX(_idx, _port, _mode, _submode, _mask, _mux) { \
345+#define SERDES_MUX(_idx, _port, _mode, _submode, _mask, _mux) { \
114346 .idx = _idx, \
115347 .port = _port, \
116348 .mode = _mode, \
@@ -191,8 +423,12 @@ static int serdes_set_mode(struct phy *phy, enum phy_mode mode, int submode) · 74 unmodified lines
191423
192424 if (macro->idx <= SERDES1G_MAX)
193425 return serdes_init_s1g(macro->ctrl->regs, macro->idx);
426+ else if (macro->idx <= SERDES6G_MAX)
427+ return serdes_init_s6g(macro->ctrl->regs,
428+ macro->idx - (SERDES1G_MAX + 1),
429+ ocelot_serdes_muxes[i].submode);
194430
195− /* SERDES6G and PCIe not supported yet */
431+ /* PCIe not supported yet */
196432 return -EOPNOTSUPP;
197433 }
198434
drivers/phy/phy-core.c+11−0
@@ -384,10 +384,16 @@ int phy_reset(struct phy *phy) · 383 unmodified lines
384384 if (!phy || !phy->ops->reset)
385385 return 0;
386386
387+ ret = phy_pm_runtime_get_sync(phy);
388+ if (ret < 0 && ret != -ENOTSUPP)
389+ return ret;
390+
387391 mutex_lock(&phy->mutex);
388392 ret = phy->ops->reset(phy);
389393 mutex_unlock(&phy->mutex);
390394
395+ phy_pm_runtime_put(phy);
396+
391397 return ret;
392398 }
393399 EXPORT_SYMBOL_GPL(phy_reset);
@@ -564,6 +570,11 @@ void phy_put(struct phy *phy) · 170 unmodified lines
564570 if (!phy || IS_ERR(phy))
565571 return;
566572
573+ mutex_lock(&phy->mutex);
574+ if (phy->ops->release)
575+ phy->ops->release(phy);
576+ mutex_unlock(&phy->mutex);
577+
567578 module_put(phy->ops->owner);
568579 put_device(&phy->dev);
569580 }
drivers/phy/qualcomm/phy-qcom-qmp.c+165−57
@@ -242,6 +242,88 @@ static const struct qmp_phy_init_tbl msm8996_pcie_pcs_tbl[] = { · 241 unmodified lines
242242 QMP_PHY_INIT_CFG(QPHY_TXDEEMPH_M3P5DB_V0, 0x0e),
243243 };
244244
245+static const struct qmp_phy_init_tbl msm8998_pcie_serdes_tbl[] = {
246+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_BIAS_EN_CLKBUFLR_EN, 0x14),
247+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x30),
248+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_IVCO, 0x0f),
249+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
250+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP_EN, 0x01),
251+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_RESETSM_CNTRL, 0x20),
252+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_MAP, 0x00),
253+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE2_MODE0, 0x01),
254+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE1_MODE0, 0xc9),
255+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER1, 0xff),
256+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_VCO_TUNE_TIMER2, 0x3f),
257+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SVS_MODE_CLK_SEL, 0x01),
258+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORE_CLK_EN, 0x00),
259+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CORECLK_DIV_MODE0, 0x0a),
260+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_EP_DIV, 0x19),
261+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_ENABLE1, 0x90),
262+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DEC_START_MODE0, 0x82),
263+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START3_MODE0, 0x03),
264+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START2_MODE0, 0x55),
265+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_DIV_FRAC_START1_MODE0, 0x55),
266+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP3_MODE0, 0x00),
267+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP2_MODE0, 0x0d),
268+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_LOCK_CMP1_MODE0, 0x04),
269+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_HSCLK_SEL, 0x00),
270+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CP_CTRL_MODE0, 0x08),
271+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_RCTRL_MODE0, 0x16),
272+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_PLL_CCTRL_MODE0, 0x34),
273+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CMN_CONFIG, 0x06),
274+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_CLK_SELECT, 0x33),
275+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYS_CLK_CTRL, 0x02),
276+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_BUF_ENABLE, 0x07),
277+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SYSCLK_EN_SEL, 0x04),
278+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN1_MODE0, 0x00),
279+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_INTEGLOOP_GAIN0_MODE0, 0x3f),
280+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_BG_TIMER, 0x09),
281+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_EN_CENTER, 0x01),
282+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER1, 0x40),
283+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_PER2, 0x01),
284+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER1, 0x02),
285+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_ADJ_PER2, 0x00),
286+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE1, 0x7e),
287+ QMP_PHY_INIT_CFG(QSERDES_V3_COM_SSC_STEP_SIZE2, 0x15),
288+};
289+
290+static const struct qmp_phy_init_tbl msm8998_pcie_tx_tbl[] = {
291+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_RES_CODE_LANE_OFFSET_TX, 0x02),
292+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_RCV_DETECT_LVL_2, 0x12),
293+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_HIGHZ_DRVR_EN, 0x10),
294+ QMP_PHY_INIT_CFG(QSERDES_V3_TX_LANE_MODE_1, 0x06),
295+};
296+
297+static const struct qmp_phy_init_tbl msm8998_pcie_rx_tbl[] = {
298+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_CNTRL, 0x03),
299+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_ENABLES, 0x1c),
300+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_SIGDET_DEGLITCH_CNTRL, 0x14),
301+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL2, 0x0a),
302+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL3, 0x04),
303+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQU_ADAPTOR_CNTRL4, 0x1a),
304+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_SATURATION_AND_ENABLE, 0x4b),
305+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN, 0x04),
306+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_SO_GAIN_HALF, 0x04),
307+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1, 0x00),
308+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_OFFSET_ADAPTOR_CNTRL2, 0x80),
309+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_RX_INTERFACE_MODE, 0x40),
310+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_PI_CONTROLS, 0x71),
311+ QMP_PHY_INIT_CFG(QSERDES_V3_RX_UCDR_FASTLOCK_COUNT_LOW, 0x40),
312+};
313+
314+static const struct qmp_phy_init_tbl msm8998_pcie_pcs_tbl[] = {
315+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_ENDPOINT_REFCLK_DRIVE, 0x04),
316+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_OSC_DTCT_ACTIONS, 0x00),
317+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK, 0x01),
318+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
319+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB, 0x20),
320+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB, 0x00),
321+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK, 0x01),
322+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME, 0x73),
323+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_RX_SIGDET_LVL, 0x99),
324+ QMP_PHY_INIT_CFG(QPHY_V3_PCS_SIGDET_CNTRL, 0x03),
325+};
326+
245327 static const struct qmp_phy_init_tbl msm8996_usb3_serdes_tbl[] = {
246328 QMP_PHY_INIT_CFG(QSERDES_COM_SYSCLK_EN_SEL, 0x14),
247329 QMP_PHY_INIT_CFG(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x08),
@@ -897,6 +979,7 @@ struct qmp_phy { · 649 unmodified lines
897979 * @init_count: phy common block initialization count
898980 * @phy_initialized: indicate if PHY has been initialized
899981 * @mode: current PHY mode
982+ * @ufs_reset: optional UFS PHY reset handle
900983 */
901984 struct qcom_qmp {
902985 struct device *dev;
@@ -914,6 +997,8 @@ struct qcom_qmp { · 11 unmodified lines
914997 int init_count;
915998 bool phy_initialized;
916999 enum phy_mode mode;
1000+
1001+ struct reset_control *ufs_reset;
9171002 };
9181003
9191004 static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
@@ -1146,6 +1231,31 @@ static const struct qmp_phy_cfg sdm845_ufsphy_cfg = { · 226 unmodified lines
11461231 .no_pcs_sw_reset = true,
11471232 };
11481233
1234+static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
1235+ .type = PHY_TYPE_PCIE,
1236+ .nlanes = 1,
1237+
1238+ .serdes_tbl = msm8998_pcie_serdes_tbl,
1239+ .serdes_tbl_num = ARRAY_SIZE(msm8998_pcie_serdes_tbl),
1240+ .tx_tbl = msm8998_pcie_tx_tbl,
1241+ .tx_tbl_num = ARRAY_SIZE(msm8998_pcie_tx_tbl),
1242+ .rx_tbl = msm8998_pcie_rx_tbl,
1243+ .rx_tbl_num = ARRAY_SIZE(msm8998_pcie_rx_tbl),
1244+ .pcs_tbl = msm8998_pcie_pcs_tbl,
1245+ .pcs_tbl_num = ARRAY_SIZE(msm8998_pcie_pcs_tbl),
1246+ .clk_list = msm8996_phy_clk_l,
1247+ .num_clks = ARRAY_SIZE(msm8996_phy_clk_l),
1248+ .reset_list = ipq8074_pciephy_reset_l,
1249+ .num_resets = ARRAY_SIZE(ipq8074_pciephy_reset_l),
1250+ .vreg_list = qmp_phy_vreg_l,
1251+ .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l),
1252+ .regs = pciephy_regs_layout,
1253+
1254+ .start_ctrl = SERDES_START | PCS_START,
1255+ .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL,
1256+ .mask_com_pcs_ready = PCS_READY,
1257+};
1258+
11491259 static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
11501260 .type = PHY_TYPE_USB3,
11511261 .nlanes = 1,
@@ -1314,6 +1424,7 @@ static int qcom_qmp_phy_com_exit(struct qcom_qmp *qmp) · 162 unmodified lines
13141424 return 0;
13151425 }
13161426
1427+ reset_control_assert(qmp->ufs_reset);
13171428 if (cfg->has_phy_com_ctrl) {
13181429 qphy_setbits(serdes, cfg->regs[QPHY_COM_START_CONTROL],
13191430 SERDES_START | PCS_START);
@@ -1335,8 +1446,7 @@ static int qcom_qmp_phy_com_exit(struct qcom_qmp *qmp) · 15 unmodified lines
13351446 return 0;
13361447 }
13371448
1338−/* PHY Initialization */
1339−static int qcom_qmp_phy_init(struct phy *phy)
1449+static int qcom_qmp_phy_enable(struct phy *phy)
13401450 {
13411451 struct qmp_phy *qphy = phy_get_drvdata(phy);
13421452 struct qcom_qmp *qmp = qphy->qmp;
@@ -1351,6 +1461,33 @@ static int qcom_qmp_phy_init(struct phy *phy) · 8 unmodified lines
13511461
13521462 dev_vdbg(qmp->dev, "Initializing QMP phy\n");
13531463
1464+ if (cfg->no_pcs_sw_reset) {
1465+ /*
1466+ * Get UFS reset, which is delayed until now to avoid a
1467+ * circular dependency where UFS needs its PHY, but the PHY
1468+ * needs this UFS reset.
1469+ */
1470+ if (!qmp->ufs_reset) {
1471+ qmp->ufs_reset =
1472+ devm_reset_control_get_exclusive(qmp->dev,
1473+ "ufsphy");
1474+
1475+ if (IS_ERR(qmp->ufs_reset)) {
1476+ ret = PTR_ERR(qmp->ufs_reset);
1477+ dev_err(qmp->dev,
1478+ "failed to get UFS reset: %d\n",
1479+ ret);
1480+
1481+ qmp->ufs_reset = NULL;
1482+ return ret;
1483+ }
1484+ }
1485+
1486+ ret = reset_control_assert(qmp->ufs_reset);
1487+ if (ret)
1488+ goto err_lane_rst;
1489+ }
1490+
13541491 ret = qcom_qmp_phy_com_init(qphy);
13551492 if (ret)
13561493 return ret;
@@ -1383,14 +1520,9 @@ static int qcom_qmp_phy_init(struct phy *phy) · 26 unmodified lines
13831520 cfg->rx_tbl, cfg->rx_tbl_num);
13841521
13851522 qcom_qmp_phy_configure(pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num);
1386−
1387− /*
1388− * UFS PHY requires the deassert of software reset before serdes start.
1389− * For UFS PHYs that do not have software reset control bits, defer
1390− * starting serdes until the power on callback.
1391− */
1392− if ((cfg->type == PHY_TYPE_UFS) && cfg->no_pcs_sw_reset)
1393− goto out;
1523+ ret = reset_control_deassert(qmp->ufs_reset);
1524+ if (ret)
1525+ goto err_lane_rst;
13941526
13951527 /*
13961528 * Pull out PHY from POWER DOWN state.
@@ -1403,7 +1535,9 @@ static int qcom_qmp_phy_init(struct phy *phy) · 6 unmodified lines
14031535 usleep_range(cfg->pwrdn_delay_min, cfg->pwrdn_delay_max);
14041536
14051537 /* Pull PHY out of reset state */
1406− qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
1538+ if (!cfg->no_pcs_sw_reset)
1539+ qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
1540+
14071541 if (cfg->has_phy_dp_com_ctrl)
14081542 qphy_clrbits(dp_com, QPHY_V3_DP_COM_SW_RESET, SW_RESET);
14091543
@@ -1420,11 +1554,10 @@ static int qcom_qmp_phy_init(struct phy *phy) · 10 unmodified lines
14201554 goto err_pcs_ready;
14211555 }
14221556 qmp->phy_initialized = true;
1423−
1424−out:
1425− return ret;
1557+ return 0;
14261558
14271559 err_pcs_ready:
1560+ reset_control_assert(qmp->ufs_reset);
14281561 clk_disable_unprepare(qphy->pipe_clk);
14291562 err_clk_enable:
14301563 if (cfg->has_lane_rst)
@@ -1435,7 +1568,7 @@ err_lane_rst: · 4 unmodified lines
14351568 return ret;
14361569 }
14371570
1438−static int qcom_qmp_phy_exit(struct phy *phy)
1571+static int qcom_qmp_phy_disable(struct phy *phy)
14391572 {
14401573 struct qmp_phy *qphy = phy_get_drvdata(phy);
14411574 struct qcom_qmp *qmp = qphy->qmp;
@@ -1463,44 +1596,6 @@ static int qcom_qmp_phy_exit(struct phy *phy) · 21 unmodified lines
14631596 return 0;
14641597 }
14651598
1466−static int qcom_qmp_phy_poweron(struct phy *phy)
1467−{
1468− struct qmp_phy *qphy = phy_get_drvdata(phy);
1469− struct qcom_qmp *qmp = qphy->qmp;
1470− const struct qmp_phy_cfg *cfg = qmp->cfg;
1471− void __iomem *pcs = qphy->pcs;
1472− void __iomem *status;
1473− unsigned int mask, val;
1474− int ret = 0;
1475−
1476− if (cfg->type != PHY_TYPE_UFS)
1477− return 0;
1478−
1479− /*
1480− * For UFS PHY that has not software reset control, serdes start
1481− * should only happen when UFS driver explicitly calls phy_power_on
1482− * after it deasserts software reset.
1483− */
1484− if (cfg->no_pcs_sw_reset && !qmp->phy_initialized &&
1485− (qmp->init_count != 0)) {
1486− /* start SerDes and Phy-Coding-Sublayer */
1487− qphy_setbits(pcs, cfg->regs[QPHY_START_CTRL], cfg->start_ctrl);
1488−
1489− status = pcs + cfg->regs[QPHY_PCS_READY_STATUS];
1490− mask = cfg->mask_pcs_ready;
1491−
1492− ret = readl_poll_timeout(status, val, !(val & mask), 1,
1493− PHY_INIT_COMPLETE_TIMEOUT);
1494− if (ret) {
1495− dev_err(qmp->dev, "phy initialization timed-out\n");
1496− return ret;
1497− }
1498− qmp->phy_initialized = true;
1499− }
1500−
1501− return ret;
1502−}
1503−
15041599 static int qcom_qmp_phy_set_mode(struct phy *phy,
15051600 enum phy_mode mode, int submode)
15061601 {
@@ -1750,9 +1845,15 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) · 243 unmodified lines
17501845 }
17511846
17521847 static const struct phy_ops qcom_qmp_phy_gen_ops = {
1753− .init = qcom_qmp_phy_init,
1754− .exit = qcom_qmp_phy_exit,
1755− .power_on = qcom_qmp_phy_poweron,
1848+ .init = qcom_qmp_phy_enable,
1849+ .exit = qcom_qmp_phy_disable,
1850+ .set_mode = qcom_qmp_phy_set_mode,
1851+ .owner = THIS_MODULE,
1852+};
1853+
1854+static const struct phy_ops qcom_qmp_ufs_ops = {
1855+ .power_on = qcom_qmp_phy_enable,
1856+ .power_off = qcom_qmp_phy_disable,
17561857 .set_mode = qcom_qmp_phy_set_mode,
17571858 .owner = THIS_MODULE,
17581859 };
@@ -1763,6 +1864,7 @@ int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) · 4 unmodified lines
17631864 struct qcom_qmp *qmp = dev_get_drvdata(dev);
17641865 struct phy *generic_phy;
17651866 struct qmp_phy *qphy;
1867+ const struct phy_ops *ops = &qcom_qmp_phy_gen_ops;
17661868 char prop_name[MAX_PROP_NAME];
17671869 int ret;
17681870
@@ -1849,7 +1951,10 @@ int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) · 80 unmodified lines
18491951 }
18501952 }
18511953
1852− generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_gen_ops);
1954+ if (qmp->cfg->type == PHY_TYPE_UFS)
1955+ ops = &qcom_qmp_ufs_ops;
1956+
1957+ generic_phy = devm_phy_create(dev, np, ops);
18531958 if (IS_ERR(generic_phy)) {
18541959 ret = PTR_ERR(generic_phy);
18551960 dev_err(dev, "failed to create qphy %d\n", ret);
@@ -1872,6 +1977,9 @@ static const struct of_device_id qcom_qmp_phy_of_match_table[] = { · 16 unmodified lines
18721977 }, {
18731978 .compatible = "qcom,msm8996-qmp-usb3-phy",
18741979 .data = &msm8996_usb3phy_cfg,
1980+ }, {
1981+ .compatible = "qcom,msm8998-qmp-pcie-phy",
1982+ .data = &msm8998_pciephy_cfg,
18751983 }, {
18761984 .compatible = "qcom,msm8998-qmp-ufs-phy",
18771985 .data = &sdm845_ufsphy_cfg,
drivers/phy/qualcomm/phy-qcom-qmp.h+12−0
@@ -241,6 +241,7 @@ · 240 unmodified lines
241241 #define QSERDES_V3_RX_RX_BAND 0x110
242242 #define QSERDES_V3_RX_RX_INTERFACE_MODE 0x11c
243243 #define QSERDES_V3_RX_RX_MODE_00 0x164
244+#define QSERDES_V3_RX_RX_MODE_01 0x168
244245
245246 /* Only for QMP V3 PHY - PCS registers */
246247 #define QPHY_V3_PCS_POWER_DOWN_CONTROL 0x004
@@ -280,6 +281,7 @@ · 33 unmodified lines
280281 #define QPHY_V3_PCS_TSYNC_RSYNC_TIME 0x08c
281282 #define QPHY_V3_PCS_PWRUP_RESET_DLY_TIME_AUXCLK 0x0a0
282283 #define QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK 0x0a4
284+#define QPHY_V3_PCS_PLL_LOCK_CHK_DLY_TIME 0x0a8
283285 #define QPHY_V3_PCS_LFPS_TX_ECSTART_EQTLOCK 0x0b0
284286 #define QPHY_V3_PCS_RXEQTRAINING_WAIT_TIME 0x0b8
285287 #define QPHY_V3_PCS_RXEQTRAINING_RUN_TIME 0x0bc
@@ -292,13 +294,23 @@ · 6 unmodified lines
292294 #define QPHY_V3_PCS_RX_MIN_HIBERN8_TIME 0x138
293295 #define QPHY_V3_PCS_RX_SIGDET_CTRL1 0x13c
294296 #define QPHY_V3_PCS_RX_SIGDET_CTRL2 0x140
297+#define QPHY_V3_PCS_LP_WAKEUP_DLY_TIME_AUXCLK_MSB 0x1a8
298+#define QPHY_V3_PCS_OSC_DTCT_ACTIONS 0x1ac
299+#define QPHY_V3_PCS_SIGDET_CNTRL 0x1b0
295300 #define QPHY_V3_PCS_TX_MID_TERM_CTRL1 0x1bc
296301 #define QPHY_V3_PCS_MULTI_LANE_CTRL1 0x1c4
297302 #define QPHY_V3_PCS_RX_SIGDET_LVL 0x1d8
303+#define QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_LSB 0x1dc
304+#define QPHY_V3_PCS_L1SS_WAKEUP_DLY_TIME_AUXCLK_MSB 0x1e0
298305 #define QPHY_V3_PCS_REFGEN_REQ_CONFIG1 0x20c
299306 #define QPHY_V3_PCS_REFGEN_REQ_CONFIG2 0x210
300307
301308 /* Only for QMP V3 PHY - PCS_MISC registers */
302309 #define QPHY_V3_PCS_MISC_CLAMP_ENABLE 0x0c
310+#define QPHY_V3_PCS_MISC_OSC_DTCT_CONFIG2 0x2c
311+#define QPHY_V3_PCS_MISC_PCIE_INT_AUX_CLK_CONFIG1 0x44
312+#define QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG2 0x54
313+#define QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG4 0x5c
314+#define QPHY_V3_PCS_MISC_OSC_DTCT_MODE2_CONFIG5 0x60
303315
304316 #endif
drivers/phy/qualcomm/phy-qcom-qusb2.c+3−8
@@ -822,14 +822,9 @@ static int qusb2_phy_probe(struct platform_device *pdev) · 821 unmodified lines
822822 return ret;
823823 }
824824
825− qphy->iface_clk = devm_clk_get(dev, "iface");
826− if (IS_ERR(qphy->iface_clk)) {
827− ret = PTR_ERR(qphy->iface_clk);
828− if (ret == -EPROBE_DEFER)
829− return ret;
830− qphy->iface_clk = NULL;
831− dev_dbg(dev, "failed to get iface clk, %d\n", ret);
832− }
825+ qphy->iface_clk = devm_clk_get_optional(dev, "iface");
826+ if (IS_ERR(qphy->iface_clk))
827+ return PTR_ERR(qphy->iface_clk);
833828
834829 qphy->phy_reset = devm_reset_control_get_by_index(&pdev->dev, 0);
835830 if (IS_ERR(qphy->phy_reset)) {
drivers/phy/qualcomm/phy-qcom-ufs-i.h+3−2
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #include <linux/clk.h>
2020 #include <linux/phy/phy.h>
2121 #include <linux/regulator/consumer.h>
22+#include <linux/reset.h>
2223 #include <linux/slab.h>
2324 #include <linux/platform_device.h>
2425 #include <linux/io.h>
@@ -96,11 +97,10 @@ struct ufs_qcom_phy { · 71 unmodified lines
9697 char name[UFS_QCOM_PHY_NAME_LEN];
9798 struct ufs_qcom_phy_calibration *cached_regs;
9899 int cached_regs_table_size;
99− bool is_powered_on;
100− bool is_started;
101100 struct ufs_qcom_phy_specific_ops *phy_spec_ops;
102101
103102 enum phy_mode mode;
103+ struct reset_control *ufs_reset;
104104 };
105105
106106 /**
@@ -115,6 +115,7 @@ struct ufs_qcom_phy { · 8 unmodified lines
115115 * and writes to QSERDES_RX_SIGDET_CNTRL attribute
116116 */
117117 struct ufs_qcom_phy_specific_ops {
118+ int (*calibrate)(struct ufs_qcom_phy *ufs_qcom_phy, bool is_rate_B);
118119 void (*start_serdes)(struct ufs_qcom_phy *phy);
119120 int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy);
120121 void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c+1−24
@@ -42,28 +42,6 @@ void ufs_qcom_phy_qmp_14nm_advertise_quirks(struct ufs_qcom_phy *phy_common) · 41 unmodified lines
4242 UFS_QCOM_PHY_QUIRK_HIBERN8_EXIT_AFTER_PHY_PWR_COLLAPSE;
4343 }
4444
45−static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy)
46−{
47− struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
48− bool is_rate_B = false;
49− int ret;
50−
51− if (phy_common->mode == PHY_MODE_UFS_HS_B)
52− is_rate_B = true;
53−
54− ret = ufs_qcom_phy_qmp_14nm_phy_calibrate(phy_common, is_rate_B);
55− if (!ret)
56− /* phy calibrated, but yet to be started */
57− phy_common->is_started = false;
58−
59− return ret;
60−}
61−
62−static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy)
63−{
64− return 0;
65−}
66−
6745 static
6846 int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy,
6947 enum phy_mode mode, int submode)
@@ -124,8 +102,6 @@ static int ufs_qcom_phy_qmp_14nm_is_pcs_ready(struct ufs_qcom_phy *phy_common) · 54 unmodified lines
124102 }
125103
126104 static const struct phy_ops ufs_qcom_phy_qmp_14nm_phy_ops = {
127− .init = ufs_qcom_phy_qmp_14nm_init,
128− .exit = ufs_qcom_phy_qmp_14nm_exit,
129105 .power_on = ufs_qcom_phy_power_on,
130106 .power_off = ufs_qcom_phy_power_off,
131107 .set_mode = ufs_qcom_phy_qmp_14nm_set_mode,
@@ -133,6 +109,7 @@ static const struct phy_ops ufs_qcom_phy_qmp_14nm_phy_ops = { · 1 unmodified line
133109 };
134110
135111 static struct ufs_qcom_phy_specific_ops phy_14nm_ops = {
112+ .calibrate = ufs_qcom_phy_qmp_14nm_phy_calibrate,
136113 .start_serdes = ufs_qcom_phy_qmp_14nm_start_serdes,
137114 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready,
138115 .set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c+1−24
@@ -61,28 +61,6 @@ void ufs_qcom_phy_qmp_20nm_advertise_quirks(struct ufs_qcom_phy *phy_common) · 60 unmodified lines
6161 UFS_QCOM_PHY_QUIRK_HIBERN8_EXIT_AFTER_PHY_PWR_COLLAPSE;
6262 }
6363
64−static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy)
65−{
66− struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
67− bool is_rate_B = false;
68− int ret;
69−
70− if (phy_common->mode == PHY_MODE_UFS_HS_B)
71− is_rate_B = true;
72−
73− ret = ufs_qcom_phy_qmp_20nm_phy_calibrate(phy_common, is_rate_B);
74− if (!ret)
75− /* phy calibrated, but yet to be started */
76− phy_common->is_started = false;
77−
78− return ret;
79−}
80−
81−static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy)
82−{
83− return 0;
84−}
85−
8664 static
8765 int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy,
8866 enum phy_mode mode, int submode)
@@ -182,8 +160,6 @@ static int ufs_qcom_phy_qmp_20nm_is_pcs_ready(struct ufs_qcom_phy *phy_common) · 93 unmodified lines
182160 }
183161
184162 static const struct phy_ops ufs_qcom_phy_qmp_20nm_phy_ops = {
185− .init = ufs_qcom_phy_qmp_20nm_init,
186− .exit = ufs_qcom_phy_qmp_20nm_exit,
187163 .power_on = ufs_qcom_phy_power_on,
188164 .power_off = ufs_qcom_phy_power_off,
189165 .set_mode = ufs_qcom_phy_qmp_20nm_set_mode,
@@ -191,6 +167,7 @@ static const struct phy_ops ufs_qcom_phy_qmp_20nm_phy_ops = { · 1 unmodified line
191167 };
192168
193169 static struct ufs_qcom_phy_specific_ops phy_20nm_ops = {
170+ .calibrate = ufs_qcom_phy_qmp_20nm_phy_calibrate,
194171 .start_serdes = ufs_qcom_phy_qmp_20nm_start_serdes,
195172 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready,
196173 .set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable,
drivers/phy/qualcomm/phy-qcom-ufs.c+41−16
@@ -147,6 +147,21 @@ out: · 146 unmodified lines
147147 }
148148 EXPORT_SYMBOL_GPL(ufs_qcom_phy_generic_probe);
149149
150+static int ufs_qcom_phy_get_reset(struct ufs_qcom_phy *phy_common)
151+{
152+ struct reset_control *reset;
153+
154+ if (phy_common->ufs_reset)
155+ return 0;
156+
157+ reset = devm_reset_control_get_exclusive_by_index(phy_common->dev, 0);
158+ if (IS_ERR(reset))
159+ return PTR_ERR(reset);
160+
161+ phy_common->ufs_reset = reset;
162+ return 0;
163+}
164+
150165 static int __ufs_qcom_phy_clk_get(struct device *dev,
151166 const char *name, struct clk **clk_out, bool err_print)
152167 {
@@ -528,23 +543,38 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy) · 375 unmodified lines
528543 {
529544 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
530545 struct device *dev = phy_common->dev;
546+ bool is_rate_B = false;
531547 int err;
532548
533− if (phy_common->is_powered_on)
534− return 0;
549+ err = ufs_qcom_phy_get_reset(phy_common);
550+ if (err)
551+ return err;
535552
536− if (!phy_common->is_started) {
537− err = ufs_qcom_phy_start_serdes(phy_common);
538− if (err)
539− return err;
553+ err = reset_control_assert(phy_common->ufs_reset);
554+ if (err)
555+ return err;
540556
541− err = ufs_qcom_phy_is_pcs_ready(phy_common);
542− if (err)
543− return err;
557+ if (phy_common->mode == PHY_MODE_UFS_HS_B)
558+ is_rate_B = true;
544559
545− phy_common->is_started = true;
560+ err = phy_common->phy_spec_ops->calibrate(phy_common, is_rate_B);
561+ if (err)
562+ return err;
563+
564+ err = reset_control_deassert(phy_common->ufs_reset);
565+ if (err) {
566+ dev_err(dev, "Failed to assert UFS PHY reset");
567+ return err;
546568 }
547569
570+ err = ufs_qcom_phy_start_serdes(phy_common);
571+ if (err)
572+ return err;
573+
574+ err = ufs_qcom_phy_is_pcs_ready(phy_common);
575+ if (err)
576+ return err;
577+
548578 err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy);
549579 if (err) {
550580 dev_err(dev, "%s enable vdda_phy failed, err=%d\n",
@@ -587,7 +617,6 @@ int ufs_qcom_phy_power_on(struct phy *generic_phy) · 36 unmodified lines
587617 }
588618 }
589619
590− phy_common->is_powered_on = true;
591620 goto out;
592621
593622 out_disable_ref_clk:
@@ -607,9 +636,6 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy) · 13 unmodified lines
607636 {
608637 struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy);
609638
610− if (!phy_common->is_powered_on)
611− return 0;
612−
613639 phy_common->phy_spec_ops->power_control(phy_common, false);
614640
615641 if (phy_common->vddp_ref_clk.reg)
@@ -620,8 +646,7 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy) · 4 unmodified lines
620646
621647 ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_pll);
622648 ufs_qcom_phy_disable_vreg(phy_common->dev, &phy_common->vdda_phy);
623− phy_common->is_powered_on = false;
624−
649+ reset_control_assert(phy_common->ufs_reset);
625650 return 0;
626651 }
627652 EXPORT_SYMBOL_GPL(ufs_qcom_phy_power_off);
drivers/phy/renesas/Kconfig+1−1
@@ -19,7 +19,7 @@ config PHY_RCAR_GEN3_PCIE · 18 unmodified lines
1919 config PHY_RCAR_GEN3_USB2
2020 tristate "Renesas R-Car generation 3 USB 2.0 PHY driver"
2121 depends on ARCH_RENESAS
22− depends on EXTCON
22+ depends on EXTCON || !EXTCON # if EXTCON=m, this cannot be built-in
2323 depends on USB_SUPPORT
2424 select GENERIC_PHY
2525 select USB_COMMON
drivers/phy/renesas/phy-rcar-gen2.c+118−12
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 *
55 * Copyright (C) 2014 Renesas Solutions Corp.
66 * Copyright (C) 2014 Cogent Embedded, Inc.
7+ * Copyright (C) 2019 Renesas Electronics Corp.
78 */
89
910 #include <linux/clk.h>
@@ -15,6 +16,7 @@ · 5 unmodified lines
1516 #include <linux/platform_device.h>
1617 #include <linux/spinlock.h>
1718 #include <linux/atomic.h>
19+#include <linux/of_device.h>
1820
1921 #define USBHS_LPSTS 0x02
2022 #define USBHS_UGCTRL 0x80
@@ -35,6 +37,8 @@ · 14 unmodified lines
3537 #define USBHS_UGCTRL2_USB0SEL 0x00000030
3638 #define USBHS_UGCTRL2_USB0SEL_PCI 0x00000010
3739 #define USBHS_UGCTRL2_USB0SEL_HS_USB 0x00000030
40+#define USBHS_UGCTRL2_USB0SEL_USB20 0x00000010
41+#define USBHS_UGCTRL2_USB0SEL_HS_USB20 0x00000020
3842
3943 /* USB General status register (UGSTS) */
4044 #define USBHS_UGSTS_LOCK 0x00000100 /* From technical update */
@@ -64,6 +68,11 @@ struct rcar_gen2_phy_driver { · 23 unmodified lines
6468 struct rcar_gen2_channel *channels;
6569 };
6670
71+struct rcar_gen2_phy_data {
72+ const struct phy_ops *gen2_phy_ops;
73+ const u32 (*select_value)[PHYS_PER_CHANNEL];
74+};
75+
6776 static int rcar_gen2_phy_init(struct phy *p)
6877 {
6978 struct rcar_gen2_phy *phy = phy_get_drvdata(p);
@@ -180,6 +189,60 @@ static int rcar_gen2_phy_power_off(struct phy *p) · 110 unmodified lines
180189 return 0;
181190 }
182191
192+static int rz_g1c_phy_power_on(struct phy *p)
193+{
194+ struct rcar_gen2_phy *phy = phy_get_drvdata(p);
195+ struct rcar_gen2_phy_driver *drv = phy->channel->drv;
196+ void __iomem *base = drv->base;
197+ unsigned long flags;
198+ u32 value;
199+
200+ spin_lock_irqsave(&drv->lock, flags);
201+
202+ /* Power on USBHS PHY */
203+ value = readl(base + USBHS_UGCTRL);
204+ value &= ~USBHS_UGCTRL_PLLRESET;
205+ writel(value, base + USBHS_UGCTRL);
206+
207+ /* As per the data sheet wait 340 micro sec for power stable */
208+ udelay(340);
209+
210+ if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) {
211+ value = readw(base + USBHS_LPSTS);
212+ value |= USBHS_LPSTS_SUSPM;
213+ writew(value, base + USBHS_LPSTS);
214+ }
215+
216+ spin_unlock_irqrestore(&drv->lock, flags);
217+
218+ return 0;
219+}
220+
221+static int rz_g1c_phy_power_off(struct phy *p)
222+{
223+ struct rcar_gen2_phy *phy = phy_get_drvdata(p);
224+ struct rcar_gen2_phy_driver *drv = phy->channel->drv;
225+ void __iomem *base = drv->base;
226+ unsigned long flags;
227+ u32 value;
228+
229+ spin_lock_irqsave(&drv->lock, flags);
230+ /* Power off USBHS PHY */
231+ if (phy->select_value == USBHS_UGCTRL2_USB0SEL_HS_USB20) {
232+ value = readw(base + USBHS_LPSTS);
233+ value &= ~USBHS_LPSTS_SUSPM;
234+ writew(value, base + USBHS_LPSTS);
235+ }
236+
237+ value = readl(base + USBHS_UGCTRL);
238+ value |= USBHS_UGCTRL_PLLRESET;
239+ writel(value, base + USBHS_UGCTRL);
240+
241+ spin_unlock_irqrestore(&drv->lock, flags);
242+
243+ return 0;
244+}
245+
183246 static const struct phy_ops rcar_gen2_phy_ops = {
184247 .init = rcar_gen2_phy_init,
185248 .exit = rcar_gen2_phy_exit,
@@ -188,12 +251,55 @@ static const struct phy_ops rcar_gen2_phy_ops = { · 2 unmodified lines
188251 .owner = THIS_MODULE,
189252 };
190253
254+static const struct phy_ops rz_g1c_phy_ops = {
255+ .init = rcar_gen2_phy_init,
256+ .exit = rcar_gen2_phy_exit,
257+ .power_on = rz_g1c_phy_power_on,
258+ .power_off = rz_g1c_phy_power_off,
259+ .owner = THIS_MODULE,
260+};
261+
262+static const u32 pci_select_value[][PHYS_PER_CHANNEL] = {
263+ [0] = { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
264+ [2] = { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
265+};
266+
267+static const u32 usb20_select_value[][PHYS_PER_CHANNEL] = {
268+ { USBHS_UGCTRL2_USB0SEL_USB20, USBHS_UGCTRL2_USB0SEL_HS_USB20 },
269+};
270+
271+static const struct rcar_gen2_phy_data rcar_gen2_usb_phy_data = {
272+ .gen2_phy_ops = &rcar_gen2_phy_ops,
273+ .select_value = pci_select_value,
274+};
275+
276+static const struct rcar_gen2_phy_data rz_g1c_usb_phy_data = {
277+ .gen2_phy_ops = &rz_g1c_phy_ops,
278+ .select_value = usb20_select_value,
279+};
280+
191281 static const struct of_device_id rcar_gen2_phy_match_table[] = {
192− { .compatible = "renesas,usb-phy-r8a7790" },
193− { .compatible = "renesas,usb-phy-r8a7791" },
194− { .compatible = "renesas,usb-phy-r8a7794" },
195− { .compatible = "renesas,rcar-gen2-usb-phy" },
196− { }
282+ {
283+ .compatible = "renesas,usb-phy-r8a77470",
284+ .data = &rz_g1c_usb_phy_data,
285+ },
286+ {
287+ .compatible = "renesas,usb-phy-r8a7790",
288+ .data = &rcar_gen2_usb_phy_data,
289+ },
290+ {
291+ .compatible = "renesas,usb-phy-r8a7791",
292+ .data = &rcar_gen2_usb_phy_data,
293+ },
294+ {
295+ .compatible = "renesas,usb-phy-r8a7794",
296+ .data = &rcar_gen2_usb_phy_data,
297+ },
298+ {
299+ .compatible = "renesas,rcar-gen2-usb-phy",
300+ .data = &rcar_gen2_usb_phy_data,
301+ },
302+ { /* sentinel */ },
197303 };
198304 MODULE_DEVICE_TABLE(of, rcar_gen2_phy_match_table);
199305
@@ -224,11 +330,6 @@ static const u32 select_mask[] = { · 24 unmodified lines
224330 [2] = USBHS_UGCTRL2_USB2SEL,
225331 };
226332
227−static const u32 select_value[][PHYS_PER_CHANNEL] = {
228− [0] = { USBHS_UGCTRL2_USB0SEL_PCI, USBHS_UGCTRL2_USB0SEL_HS_USB },
229− [2] = { USBHS_UGCTRL2_USB2SEL_PCI, USBHS_UGCTRL2_USB2SEL_USB30 },
230−};
231−
232333 static int rcar_gen2_phy_probe(struct platform_device *pdev)
233334 {
234335 struct device *dev = &pdev->dev;
@@ -238,6 +339,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) · 3 unmodified lines
238339 struct resource *res;
239340 void __iomem *base;
240341 struct clk *clk;
342+ const struct rcar_gen2_phy_data *data;
241343 int i = 0;
242344
243345 if (!dev->of_node) {
@@ -266,6 +368,10 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) · 22 unmodified lines
266368 drv->clk = clk;
267369 drv->base = base;
268370
371+ data = of_device_get_match_data(dev);
372+ if (!data)
373+ return -EINVAL;
374+
269375 drv->num_channels = of_get_child_count(dev->of_node);
270376 drv->channels = devm_kcalloc(dev, drv->num_channels,
271377 sizeof(struct rcar_gen2_channel),
@@ -294,10 +400,10 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) · 22 unmodified lines
294400
295401 phy->channel = channel;
296402 phy->number = n;
297− phy->select_value = select_value[channel_num][n];
403+ phy->select_value = data->select_value[channel_num][n];
298404
299405 phy->phy = devm_phy_create(dev, NULL,
300− &rcar_gen2_phy_ops);
406+ data->gen2_phy_ops);
301407 if (IS_ERR(phy->phy)) {
302408 dev_err(dev, "Failed to create PHY\n");
303409 return PTR_ERR(phy->phy);
drivers/phy/renesas/phy-rcar-gen3-usb2.c+198−34
@@ -37,11 +37,8 @@ · 36 unmodified lines
3737
3838 /* INT_ENABLE */
3939 #define USB2_INT_ENABLE_UCOM_INTEN BIT(3)
40−#define USB2_INT_ENABLE_USBH_INTB_EN BIT(2)
41−#define USB2_INT_ENABLE_USBH_INTA_EN BIT(1)
42−#define USB2_INT_ENABLE_INIT (USB2_INT_ENABLE_UCOM_INTEN | \
43− USB2_INT_ENABLE_USBH_INTB_EN | \
44− USB2_INT_ENABLE_USBH_INTA_EN)
40+#define USB2_INT_ENABLE_USBH_INTB_EN BIT(2) /* For EHCI */
41+#define USB2_INT_ENABLE_USBH_INTA_EN BIT(1) /* For OHCI */
4542
4643 /* USBCTR */
4744 #define USB2_USBCTR_DIRPD BIT(2)
@@ -78,10 +75,35 @@ · 30 unmodified lines
7875 #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */
7976 #define USB2_ADPCTRL_DRVVBUS BIT(4)
8077
78+#define NUM_OF_PHYS 4
79+enum rcar_gen3_phy_index {
80+ PHY_INDEX_BOTH_HC,
81+ PHY_INDEX_OHCI,
82+ PHY_INDEX_EHCI,
83+ PHY_INDEX_HSUSB
84+};
85+
86+static const u32 rcar_gen3_int_enable[NUM_OF_PHYS] = {
87+ USB2_INT_ENABLE_USBH_INTB_EN | USB2_INT_ENABLE_USBH_INTA_EN,
88+ USB2_INT_ENABLE_USBH_INTA_EN,
89+ USB2_INT_ENABLE_USBH_INTB_EN,
90+ 0
91+};
92+
93+struct rcar_gen3_phy {
94+ struct phy *phy;
95+ struct rcar_gen3_chan *ch;
96+ u32 int_enable_bits;
97+ bool initialized;
98+ bool otg_initialized;
99+ bool powered;
100+};
101+
81102 struct rcar_gen3_chan {
82103 void __iomem *base;
104+ struct device *dev; /* platform_device's device */
83105 struct extcon_dev *extcon;
84− struct phy *phy;
106+ struct rcar_gen3_phy rphys[NUM_OF_PHYS];
85107 struct regulator *vbus;
86108 struct work_struct work;
87109 enum usb_dr_mode dr_mode;
@@ -120,7 +142,7 @@ static void rcar_gen3_set_host_mode(struct rcar_gen3_chan *ch, int host) · 32 unmodified lines
120142 void __iomem *usb2_base = ch->base;
121143 u32 val = readl(usb2_base + USB2_COMMCTRL);
122144
123− dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, host);
145+ dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, host);
124146 if (host)
125147 val &= ~USB2_COMMCTRL_OTG_PERI;
126148 else
@@ -133,7 +155,7 @@ static void rcar_gen3_set_linectrl(struct rcar_gen3_chan *ch, int dp, int dm) · 6 unmodified lines
133155 void __iomem *usb2_base = ch->base;
134156 u32 val = readl(usb2_base + USB2_LINECTRL1);
135157
136− dev_vdbg(&ch->phy->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm);
158+ dev_vdbg(ch->dev, "%s: %08x, %d, %d\n", __func__, val, dp, dm);
137159 val &= ~(USB2_LINECTRL1_DP_RPD | USB2_LINECTRL1_DM_RPD);
138160 if (dp)
139161 val |= USB2_LINECTRL1_DP_RPD;
@@ -147,7 +169,7 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus) · 7 unmodified lines
147169 void __iomem *usb2_base = ch->base;
148170 u32 val = readl(usb2_base + USB2_ADPCTRL);
149171
150− dev_vdbg(&ch->phy->dev, "%s: %08x, %d\n", __func__, val, vbus);
172+ dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus);
151173 if (vbus)
152174 val |= USB2_ADPCTRL_DRVVBUS;
153175 else
@@ -249,6 +271,42 @@ static enum phy_mode rcar_gen3_get_phy_mode(struct rcar_gen3_chan *ch) · 95 unmodified lines
249271 return PHY_MODE_USB_DEVICE;
250272 }
251273
274+static bool rcar_gen3_is_any_rphy_initialized(struct rcar_gen3_chan *ch)
275+{
276+ int i;
277+
278+ for (i = 0; i < NUM_OF_PHYS; i++) {
279+ if (ch->rphys[i].initialized)
280+ return true;
281+ }
282+
283+ return false;
284+}
285+
286+static bool rcar_gen3_needs_init_otg(struct rcar_gen3_chan *ch)
287+{
288+ int i;
289+
290+ for (i = 0; i < NUM_OF_PHYS; i++) {
291+ if (ch->rphys[i].otg_initialized)
292+ return false;
293+ }
294+
295+ return true;
296+}
297+
298+static bool rcar_gen3_are_all_rphys_power_off(struct rcar_gen3_chan *ch)
299+{
300+ int i;
301+
302+ for (i = 0; i < NUM_OF_PHYS; i++) {
303+ if (ch->rphys[i].powered)
304+ return false;
305+ }
306+
307+ return true;
308+}
309+
252310 static ssize_t role_store(struct device *dev, struct device_attribute *attr,
253311 const char *buf, size_t count)
254312 {
@@ -256,7 +314,7 @@ static ssize_t role_store(struct device *dev, struct device_attribute *attr, · 1 unmodified line
256314 bool is_b_device;
257315 enum phy_mode cur_mode, new_mode;
258316
259− if (!ch->is_otg_channel || !ch->phy->init_count)
317+ if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch))
260318 return -EIO;
261319
262320 if (!strncmp(buf, "host", strlen("host")))
@@ -294,7 +352,7 @@ static ssize_t role_show(struct device *dev, struct device_attribute *attr, · 31 unmodified lines
294352 {
295353 struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
296354
297− if (!ch->is_otg_channel || !ch->phy->init_count)
355+ if (!ch->is_otg_channel || !rcar_gen3_is_any_rphy_initialized(ch))
298356 return -EIO;
299357
300358 return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" :
@@ -328,37 +386,62 @@ static void rcar_gen3_init_otg(struct rcar_gen3_chan *ch) · 27 unmodified lines
328386
329387 static int rcar_gen3_phy_usb2_init(struct phy *p)
330388 {
331− struct rcar_gen3_chan *channel = phy_get_drvdata(p);
389+ struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
390+ struct rcar_gen3_chan *channel = rphy->ch;
332391 void __iomem *usb2_base = channel->base;
392+ u32 val;
333393
334394 /* Initialize USB2 part */
335− writel(USB2_INT_ENABLE_INIT, usb2_base + USB2_INT_ENABLE);
395+ val = readl(usb2_base + USB2_INT_ENABLE);
396+ val |= USB2_INT_ENABLE_UCOM_INTEN | rphy->int_enable_bits;
397+ writel(val, usb2_base + USB2_INT_ENABLE);
336398 writel(USB2_SPD_RSM_TIMSET_INIT, usb2_base + USB2_SPD_RSM_TIMSET);
337399 writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET);
338400
339401 /* Initialize otg part */
340− if (channel->is_otg_channel)
341− rcar_gen3_init_otg(channel);
402+ if (channel->is_otg_channel) {
403+ if (rcar_gen3_needs_init_otg(channel))
404+ rcar_gen3_init_otg(channel);
405+ rphy->otg_initialized = true;
406+ }
407+
408+ rphy->initialized = true;
342409
343410 return 0;
344411 }
345412
346413 static int rcar_gen3_phy_usb2_exit(struct phy *p)
347414 {
348− struct rcar_gen3_chan *channel = phy_get_drvdata(p);
415+ struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
416+ struct rcar_gen3_chan *channel = rphy->ch;
417+ void __iomem *usb2_base = channel->base;
418+ u32 val;
419+
420+ rphy->initialized = false;
421+
422+ if (channel->is_otg_channel)
423+ rphy->otg_initialized = false;
349424
350− writel(0, channel->base + USB2_INT_ENABLE);
425+ val = readl(usb2_base + USB2_INT_ENABLE);
426+ val &= ~rphy->int_enable_bits;
427+ if (!rcar_gen3_is_any_rphy_initialized(channel))
428+ val &= ~USB2_INT_ENABLE_UCOM_INTEN;
429+ writel(val, usb2_base + USB2_INT_ENABLE);
351430
352431 return 0;
353432 }
354433
355434 static int rcar_gen3_phy_usb2_power_on(struct phy *p)
356435 {
357− struct rcar_gen3_chan *channel = phy_get_drvdata(p);
436+ struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
437+ struct rcar_gen3_chan *channel = rphy->ch;
358438 void __iomem *usb2_base = channel->base;
359439 u32 val;
360440 int ret;
361441
442+ if (!rcar_gen3_are_all_rphys_power_off(channel))
443+ return 0;
444+
362445 if (channel->vbus) {
363446 ret = regulator_enable(channel->vbus);
364447 if (ret)
@@ -371,14 +454,22 @@ static int rcar_gen3_phy_usb2_power_on(struct phy *p) · 6 unmodified lines
371454 val &= ~USB2_USBCTR_PLL_RST;
372455 writel(val, usb2_base + USB2_USBCTR);
373456
457+ rphy->powered = true;
458+
374459 return 0;
375460 }
376461
377462 static int rcar_gen3_phy_usb2_power_off(struct phy *p)
378463 {
379− struct rcar_gen3_chan *channel = phy_get_drvdata(p);
464+ struct rcar_gen3_phy *rphy = phy_get_drvdata(p);
465+ struct rcar_gen3_chan *channel = rphy->ch;
380466 int ret = 0;
381467
468+ rphy->powered = false;
469+
470+ if (!rcar_gen3_are_all_rphys_power_off(channel))
471+ return 0;
472+
382473 if (channel->vbus)
383474 ret = regulator_disable(channel->vbus);
384475
@@ -393,6 +484,12 @@ static const struct phy_ops rcar_gen3_phy_usb2_ops = { · 8 unmodified lines
393484 .owner = THIS_MODULE,
394485 };
395486
487+static const struct phy_ops rz_g1c_phy_usb2_ops = {
488+ .init = rcar_gen3_phy_usb2_init,
489+ .exit = rcar_gen3_phy_usb2_exit,
490+ .owner = THIS_MODULE,
491+};
492+
396493 static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch)
397494 {
398495 struct rcar_gen3_chan *ch = _ch;
@@ -401,7 +498,7 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) · 2 unmodified lines
401498 irqreturn_t ret = IRQ_NONE;
402499
403500 if (status & USB2_OBINT_BITS) {
404− dev_vdbg(&ch->phy->dev, "%s: %08x\n", __func__, status);
501+ dev_vdbg(ch->dev, "%s: %08x\n", __func__, status);
405502 writel(USB2_OBINT_BITS, usb2_base + USB2_OBINTSTA);
406503 rcar_gen3_device_recognition(ch);
407504 ret = IRQ_HANDLED;
@@ -411,11 +508,27 @@ static irqreturn_t rcar_gen3_phy_usb2_irq(int irq, void *_ch) · 3 unmodified lines
411508 }
412509
413510 static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = {
414− { .compatible = "renesas,usb2-phy-r8a7795" },
415− { .compatible = "renesas,usb2-phy-r8a7796" },
416− { .compatible = "renesas,usb2-phy-r8a77965" },
417− { .compatible = "renesas,rcar-gen3-usb2-phy" },
418− { }
511+ {
512+ .compatible = "renesas,usb2-phy-r8a77470",
513+ .data = &rz_g1c_phy_usb2_ops,
514+ },
515+ {
516+ .compatible = "renesas,usb2-phy-r8a7795",
517+ .data = &rcar_gen3_phy_usb2_ops,
518+ },
519+ {
520+ .compatible = "renesas,usb2-phy-r8a7796",
521+ .data = &rcar_gen3_phy_usb2_ops,
522+ },
523+ {
524+ .compatible = "renesas,usb2-phy-r8a77965",
525+ .data = &rcar_gen3_phy_usb2_ops,
526+ },
527+ {
528+ .compatible = "renesas,rcar-gen3-usb2-phy",
529+ .data = &rcar_gen3_phy_usb2_ops,
530+ },
531+ { /* sentinel */ },
419532 };
420533 MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table);
421534
@@ -425,13 +538,54 @@ static const unsigned int rcar_gen3_phy_cable[] = { · 3 unmodified lines
425538 EXTCON_NONE,
426539 };
427540
541+static struct phy *rcar_gen3_phy_usb2_xlate(struct device *dev,
542+ struct of_phandle_args *args)
543+{
544+ struct rcar_gen3_chan *ch = dev_get_drvdata(dev);
545+
546+ if (args->args_count == 0) /* For old version dts */
547+ return ch->rphys[PHY_INDEX_BOTH_HC].phy;
548+ else if (args->args_count > 1) /* Prevent invalid args count */
549+ return ERR_PTR(-ENODEV);
550+
551+ if (args->args[0] >= NUM_OF_PHYS)
552+ return ERR_PTR(-ENODEV);
553+
554+ return ch->rphys[args->args[0]].phy;
555+}
556+
557+static enum usb_dr_mode rcar_gen3_get_dr_mode(struct device_node *np)
558+{
559+ enum usb_dr_mode candidate = USB_DR_MODE_UNKNOWN;
560+ int i;
561+
562+ /*
563+ * If one of device nodes has other dr_mode except UNKNOWN,
564+ * this function returns UNKNOWN. To achieve backward compatibility,
565+ * this loop starts the index as 0.
566+ */
567+ for (i = 0; i < NUM_OF_PHYS; i++) {
568+ enum usb_dr_mode mode = of_usb_get_dr_mode_by_phy(np, i);
569+
570+ if (mode != USB_DR_MODE_UNKNOWN) {
571+ if (candidate == USB_DR_MODE_UNKNOWN)
572+ candidate = mode;
573+ else if (candidate != mode)
574+ return USB_DR_MODE_UNKNOWN;
575+ }
576+ }
577+
578+ return candidate;
579+}
580+
428581 static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
429582 {
430583 struct device *dev = &pdev->dev;
431584 struct rcar_gen3_chan *channel;
432585 struct phy_provider *provider;
433586 struct resource *res;
434− int irq, ret = 0;
587+ const struct phy_ops *phy_usb2_ops;
588+ int irq, ret = 0, i;
435589
436590 if (!dev->of_node) {
437591 dev_err(dev, "This driver needs device tree\n");
@@ -457,7 +611,7 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) · 19 unmodified lines
457611 dev_err(dev, "No irq handler (%d)\n", irq);
458612 }
459613
460− channel->dr_mode = of_usb_get_dr_mode_by_phy(dev->of_node, 0);
614+ channel->dr_mode = rcar_gen3_get_dr_mode(dev->of_node);
461615 if (channel->dr_mode != USB_DR_MODE_UNKNOWN) {
462616 int ret;
463617
@@ -481,11 +635,21 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) · 17 unmodified lines
481635 * And then, phy-core will manage runtime pm for this device.
482636 */
483637 pm_runtime_enable(dev);
484− channel->phy = devm_phy_create(dev, NULL, &rcar_gen3_phy_usb2_ops);
485− if (IS_ERR(channel->phy)) {
486− dev_err(dev, "Failed to create USB2 PHY\n");
487− ret = PTR_ERR(channel->phy);
488− goto error;
638+ phy_usb2_ops = of_device_get_match_data(dev);
639+ if (!phy_usb2_ops)
640+ return -EINVAL;
641+
642+ for (i = 0; i < NUM_OF_PHYS; i++) {
643+ channel->rphys[i].phy = devm_phy_create(dev, NULL,
644+ phy_usb2_ops);
645+ if (IS_ERR(channel->rphys[i].phy)) {
646+ dev_err(dev, "Failed to create USB2 PHY\n");
647+ ret = PTR_ERR(channel->rphys[i].phy);
648+ goto error;
649+ }
650+ channel->rphys[i].ch = channel;
651+ channel->rphys[i].int_enable_bits = rcar_gen3_int_enable[i];
652+ phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
489653 }
490654
491655 channel->vbus = devm_regulator_get_optional(dev, "vbus");
@@ -498,9 +662,9 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev) · 6 unmodified lines
498662 }
499663
500664 platform_set_drvdata(pdev, channel);
501− phy_set_drvdata(channel->phy, channel);
665+ channel->dev = dev;
502666
503− provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
667+ provider = devm_of_phy_provider_register(dev, rcar_gen3_phy_usb2_xlate);
504668 if (IS_ERR(provider)) {
505669 dev_err(dev, "Failed to register PHY provider\n");
506670 ret = PTR_ERR(provider);
drivers/phy/rockchip/phy-rockchip-emmc.c+28−2
@@ -87,6 +87,7 @@ struct rockchip_emmc_phy { · 86 unmodified lines
8787 unsigned int reg_offset;
8888 struct regmap *reg_base;
8989 struct clk *emmcclk;
90+ unsigned int drive_impedance;
9091 };
9192
9293 static int rockchip_emmc_phy_power(struct phy *phy, bool on_off)
@@ -281,10 +282,10 @@ static int rockchip_emmc_phy_power_on(struct phy *phy) · 188 unmodified lines
281282 {
282283 struct rockchip_emmc_phy *rk_phy = phy_get_drvdata(phy);
283284
284− /* Drive impedance: 50 Ohm */
285+ /* Drive impedance: from DTS */
285286 regmap_write(rk_phy->reg_base,
286287 rk_phy->reg_offset + GRF_EMMCPHY_CON6,
287− HIWORD_UPDATE(PHYCTRL_DR_50OHM,
288+ HIWORD_UPDATE(rk_phy->drive_impedance,
288289 PHYCTRL_DR_MASK,
289290 PHYCTRL_DR_SHIFT));
290291
@@ -314,6 +315,26 @@ static const struct phy_ops ops = { · 23 unmodified lines
314315 .owner = THIS_MODULE,
315316 };
316317
318+static u32 convert_drive_impedance_ohm(struct platform_device *pdev, u32 dr_ohm)
319+{
320+ switch (dr_ohm) {
321+ case 100:
322+ return PHYCTRL_DR_100OHM;
323+ case 66:
324+ return PHYCTRL_DR_66OHM;
325+ case 50:
326+ return PHYCTRL_DR_50OHM;
327+ case 40:
328+ return PHYCTRL_DR_40OHM;
329+ case 33:
330+ return PHYCTRL_DR_33OHM;
331+ }
332+
333+ dev_warn(&pdev->dev, "Invalid value %u for drive-impedance-ohm.\n",
334+ dr_ohm);
335+ return PHYCTRL_DR_50OHM;
336+}
337+
317338 static int rockchip_emmc_phy_probe(struct platform_device *pdev)
318339 {
319340 struct device *dev = &pdev->dev;
@@ -322,6 +343,7 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) · 2 unmodified lines
322343 struct phy_provider *phy_provider;
323344 struct regmap *grf;
324345 unsigned int reg_offset;
346+ u32 val;
325347
326348 if (!dev->parent || !dev->parent->of_node)
327349 return -ENODEV;
@@ -344,6 +366,10 @@ static int rockchip_emmc_phy_probe(struct platform_device *pdev) · 16 unmodified lines
344366
345367 rk_phy->reg_offset = reg_offset;
346368 rk_phy->reg_base = grf;
369+ rk_phy->drive_impedance = PHYCTRL_DR_50OHM;
370+
371+ if (!of_property_read_u32(dev->of_node, "drive-impedance-ohm", &val))
372+ rk_phy->drive_impedance = convert_drive_impedance_ohm(pdev, val);
347373
348374 generic_phy = devm_phy_create(dev, dev->of_node, &ops);
349375 if (IS_ERR(generic_phy)) {
drivers/phy/socionext/phy-uniphier-usb3hs.c+3−7
@@ -335,13 +335,9 @@ static int uniphier_u3hsphy_probe(struct platform_device *pdev) · 334 unmodified lines
335335 if (IS_ERR(priv->clk_parent))
336336 return PTR_ERR(priv->clk_parent);
337337
338− priv->clk_ext = devm_clk_get(dev, "phy-ext");
339− if (IS_ERR(priv->clk_ext)) {
340− if (PTR_ERR(priv->clk_ext) == -ENOENT)
341− priv->clk_ext = NULL;
342− else
343− return PTR_ERR(priv->clk_ext);
344− }
338+ priv->clk_ext = devm_clk_get_optional(dev, "phy-ext");
339+ if (IS_ERR(priv->clk_ext))
340+ return PTR_ERR(priv->clk_ext);
345341
346342 priv->rst = devm_reset_control_get_shared(dev, "phy");
347343 if (IS_ERR(priv->rst))
drivers/phy/socionext/phy-uniphier-usb3ss.c+3−7
@@ -238,13 +238,9 @@ static int uniphier_u3ssphy_probe(struct platform_device *pdev) · 237 unmodified lines
238238 if (IS_ERR(priv->clk))
239239 return PTR_ERR(priv->clk);
240240
241− priv->clk_ext = devm_clk_get(dev, "phy-ext");
242− if (IS_ERR(priv->clk_ext)) {
243− if (PTR_ERR(priv->clk_ext) == -ENOENT)
244− priv->clk_ext = NULL;
245− else
246− return PTR_ERR(priv->clk_ext);
247− }
241+ priv->clk_ext = devm_clk_get_optional(dev, "phy-ext");
242+ if (IS_ERR(priv->clk_ext))
243+ return PTR_ERR(priv->clk_ext);
248244
249245 priv->rst = devm_reset_control_get_shared(dev, "phy");
250246 if (IS_ERR(priv->rst))
drivers/phy/tegra/Makefile+1−0
@@ -4,3 +4,4 @@ phy-tegra-xusb-y += xusb.o · 3 unmodified lines
44 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_124_SOC) += xusb-tegra124.o
55 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_132_SOC) += xusb-tegra124.o
66 phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_210_SOC) += xusb-tegra210.o
7+phy-tegra-xusb-$(CONFIG_ARCH_TEGRA_186_SOC) += xusb-tegra186.o
drivers/phy/tegra/xusb-tegra186.c+899−0
@@ -0,0 +1,899 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
4+ */
5+
6+#include <linux/delay.h>
7+#include <linux/io.h>
8+#include <linux/module.h>
9+#include <linux/of.h>
10+#include <linux/phy/phy.h>
11+#include <linux/regulator/consumer.h>
12+#include <linux/platform_device.h>
13+#include <linux/clk.h>
14+#include <linux/slab.h>
15+
16+#include <soc/tegra/fuse.h>
17+
18+#include "xusb.h"
19+
20+/* FUSE USB_CALIB registers */
21+#define HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? (11 + (x - 1) * 6) : 0)
22+#define HS_CURR_LEVEL_PAD_MASK 0x3f
23+#define HS_TERM_RANGE_ADJ_SHIFT 7
24+#define HS_TERM_RANGE_ADJ_MASK 0xf
25+#define HS_SQUELCH_SHIFT 29
26+#define HS_SQUELCH_MASK 0x7
27+
28+#define RPD_CTRL_SHIFT 0
29+#define RPD_CTRL_MASK 0x1f
30+
31+/* XUSB PADCTL registers */
32+#define XUSB_PADCTL_USB2_PAD_MUX 0x4
33+#define USB2_PORT_SHIFT(x) ((x) * 2)
34+#define USB2_PORT_MASK 0x3
35+#define PORT_XUSB 1
36+#define HSIC_PORT_SHIFT(x) ((x) + 20)
37+#define HSIC_PORT_MASK 0x1
38+#define PORT_HSIC 0
39+
40+#define XUSB_PADCTL_USB2_PORT_CAP 0x8
41+#define XUSB_PADCTL_SS_PORT_CAP 0xc
42+#define PORTX_CAP_SHIFT(x) ((x) * 4)
43+#define PORT_CAP_MASK 0x3
44+#define PORT_CAP_DISABLED 0x0
45+#define PORT_CAP_HOST 0x1
46+#define PORT_CAP_DEVICE 0x2
47+#define PORT_CAP_OTG 0x3
48+
49+#define XUSB_PADCTL_ELPG_PROGRAM 0x20
50+#define USB2_PORT_WAKE_INTERRUPT_ENABLE(x) BIT(x)
51+#define USB2_PORT_WAKEUP_EVENT(x) BIT((x) + 7)
52+#define SS_PORT_WAKE_INTERRUPT_ENABLE(x) BIT((x) + 14)
53+#define SS_PORT_WAKEUP_EVENT(x) BIT((x) + 21)
54+#define USB2_HSIC_PORT_WAKE_INTERRUPT_ENABLE(x) BIT((x) + 28)
55+#define USB2_HSIC_PORT_WAKEUP_EVENT(x) BIT((x) + 30)
56+#define ALL_WAKE_EVENTS \
57+ (USB2_PORT_WAKEUP_EVENT(0) | USB2_PORT_WAKEUP_EVENT(1) | \
58+ USB2_PORT_WAKEUP_EVENT(2) | SS_PORT_WAKEUP_EVENT(0) | \
59+ SS_PORT_WAKEUP_EVENT(1) | SS_PORT_WAKEUP_EVENT(2) | \
60+ USB2_HSIC_PORT_WAKEUP_EVENT(0))
61+
62+#define XUSB_PADCTL_ELPG_PROGRAM_1 0x24
63+#define SSPX_ELPG_CLAMP_EN(x) BIT(0 + (x) * 3)
64+#define SSPX_ELPG_CLAMP_EN_EARLY(x) BIT(1 + (x) * 3)
65+#define SSPX_ELPG_VCORE_DOWN(x) BIT(2 + (x) * 3)
66+
67+#define XUSB_PADCTL_USB2_OTG_PADX_CTL0(x) (0x88 + (x) * 0x40)
68+#define HS_CURR_LEVEL(x) ((x) & 0x3f)
69+#define TERM_SEL BIT(25)
70+#define USB2_OTG_PD BIT(26)
71+#define USB2_OTG_PD2 BIT(27)
72+#define USB2_OTG_PD2_OVRD_EN BIT(28)
73+#define USB2_OTG_PD_ZI BIT(29)
74+
75+#define XUSB_PADCTL_USB2_OTG_PADX_CTL1(x) (0x8c + (x) * 0x40)
76+#define USB2_OTG_PD_DR BIT(2)
77+#define TERM_RANGE_ADJ(x) (((x) & 0xf) << 3)
78+#define RPD_CTRL(x) (((x) & 0x1f) << 26)
79+
80+#define XUSB_PADCTL_USB2_BIAS_PAD_CTL0 0x284
81+#define BIAS_PAD_PD BIT(11)
82+#define HS_SQUELCH_LEVEL(x) (((x) & 0x7) << 0)
83+
84+#define XUSB_PADCTL_USB2_BIAS_PAD_CTL1 0x288
85+#define USB2_TRK_START_TIMER(x) (((x) & 0x7f) << 12)
86+#define USB2_TRK_DONE_RESET_TIMER(x) (((x) & 0x7f) << 19)
87+#define USB2_PD_TRK BIT(26)
88+
89+#define XUSB_PADCTL_HSIC_PADX_CTL0(x) (0x300 + (x) * 0x20)
90+#define HSIC_PD_TX_DATA0 BIT(1)
91+#define HSIC_PD_TX_STROBE BIT(3)
92+#define HSIC_PD_RX_DATA0 BIT(4)
93+#define HSIC_PD_RX_STROBE BIT(6)
94+#define HSIC_PD_ZI_DATA0 BIT(7)
95+#define HSIC_PD_ZI_STROBE BIT(9)
96+#define HSIC_RPD_DATA0 BIT(13)
97+#define HSIC_RPD_STROBE BIT(15)
98+#define HSIC_RPU_DATA0 BIT(16)
99+#define HSIC_RPU_STROBE BIT(18)
100+
101+#define XUSB_PADCTL_HSIC_PAD_TRK_CTL0 0x340
102+#define HSIC_TRK_START_TIMER(x) (((x) & 0x7f) << 5)
103+#define HSIC_TRK_DONE_RESET_TIMER(x) (((x) & 0x7f) << 12)
104+#define HSIC_PD_TRK BIT(19)
105+
106+#define USB2_VBUS_ID 0x360
107+#define VBUS_OVERRIDE BIT(14)
108+#define ID_OVERRIDE(x) (((x) & 0xf) << 18)
109+#define ID_OVERRIDE_FLOATING ID_OVERRIDE(8)
110+#define ID_OVERRIDE_GROUNDED ID_OVERRIDE(0)
111+
112+#define TEGRA186_LANE(_name, _offset, _shift, _mask, _type) \
113+ { \
114+ .name = _name, \
115+ .offset = _offset, \
116+ .shift = _shift, \
117+ .mask = _mask, \
118+ .num_funcs = ARRAY_SIZE(tegra186_##_type##_functions), \
119+ .funcs = tegra186_##_type##_functions, \
120+ }
121+
122+struct tegra_xusb_fuse_calibration {
123+ u32 *hs_curr_level;
124+ u32 hs_squelch;
125+ u32 hs_term_range_adj;
126+ u32 rpd_ctrl;
127+};
128+
129+struct tegra186_xusb_padctl {
130+ struct tegra_xusb_padctl base;
131+
132+ struct tegra_xusb_fuse_calibration calib;
133+
134+ /* UTMI bias and tracking */
135+ struct clk *usb2_trk_clk;
136+ unsigned int bias_pad_enable;
137+};
138+
139+static inline struct tegra186_xusb_padctl *
140+to_tegra186_xusb_padctl(struct tegra_xusb_padctl *padctl)
141+{
142+ return container_of(padctl, struct tegra186_xusb_padctl, base);
143+}
144+
145+/* USB 2.0 UTMI PHY support */
146+static struct tegra_xusb_lane *
147+tegra186_usb2_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
148+ unsigned int index)
149+{
150+ struct tegra_xusb_usb2_lane *usb2;
151+ int err;
152+
153+ usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
154+ if (!usb2)
155+ return ERR_PTR(-ENOMEM);
156+
157+ INIT_LIST_HEAD(&usb2->base.list);
158+ usb2->base.soc = &pad->soc->lanes[index];
159+ usb2->base.index = index;
160+ usb2->base.pad = pad;
161+ usb2->base.np = np;
162+
163+ err = tegra_xusb_lane_parse_dt(&usb2->base, np);
164+ if (err < 0) {
165+ kfree(usb2);
166+ return ERR_PTR(err);
167+ }
168+
169+ return &usb2->base;
170+}
171+
172+static void tegra186_usb2_lane_remove(struct tegra_xusb_lane *lane)
173+{
174+ struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
175+
176+ kfree(usb2);
177+}
178+
179+static const struct tegra_xusb_lane_ops tegra186_usb2_lane_ops = {
180+ .probe = tegra186_usb2_lane_probe,
181+ .remove = tegra186_usb2_lane_remove,
182+};
183+
184+static void tegra186_utmi_bias_pad_power_on(struct tegra_xusb_padctl *padctl)
185+{
186+ struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
187+ struct device *dev = padctl->dev;
188+ u32 value;
189+ int err;
190+
191+ mutex_lock(&padctl->lock);
192+
193+ if (priv->bias_pad_enable++ > 0) {
194+ mutex_unlock(&padctl->lock);
195+ return;
196+ }
197+
198+ err = clk_prepare_enable(priv->usb2_trk_clk);
199+ if (err < 0)
200+ dev_warn(dev, "failed to enable USB2 trk clock: %d\n", err);
201+
202+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
203+ value &= ~USB2_TRK_START_TIMER(~0);
204+ value |= USB2_TRK_START_TIMER(0x1e);
205+ value &= ~USB2_TRK_DONE_RESET_TIMER(~0);
206+ value |= USB2_TRK_DONE_RESET_TIMER(0xa);
207+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
208+
209+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
210+ value &= ~BIAS_PAD_PD;
211+ value &= ~HS_SQUELCH_LEVEL(~0);
212+ value |= HS_SQUELCH_LEVEL(priv->calib.hs_squelch);
213+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
214+
215+ udelay(1);
216+
217+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
218+ value &= ~USB2_PD_TRK;
219+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
220+
221+ mutex_unlock(&padctl->lock);
222+}
223+
224+static void tegra186_utmi_bias_pad_power_off(struct tegra_xusb_padctl *padctl)
225+{
226+ struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
227+ u32 value;
228+
229+ mutex_lock(&padctl->lock);
230+
231+ if (WARN_ON(priv->bias_pad_enable == 0)) {
232+ mutex_unlock(&padctl->lock);
233+ return;
234+ }
235+
236+ if (--priv->bias_pad_enable > 0) {
237+ mutex_unlock(&padctl->lock);
238+ return;
239+ }
240+
241+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
242+ value |= USB2_PD_TRK;
243+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
244+
245+ clk_disable_unprepare(priv->usb2_trk_clk);
246+
247+ mutex_unlock(&padctl->lock);
248+}
249+
250+static void tegra_phy_xusb_utmi_pad_power_on(struct phy *phy)
251+{
252+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
253+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
254+ struct tegra_xusb_usb2_port *port;
255+ struct device *dev = padctl->dev;
256+ unsigned int index = lane->index;
257+ u32 value;
258+
259+ if (!phy)
260+ return;
261+
262+ port = tegra_xusb_find_usb2_port(padctl, index);
263+ if (!port) {
264+ dev_err(dev, "no port found for USB2 lane %u\n", index);
265+ return;
266+ }
267+
268+ tegra186_utmi_bias_pad_power_on(padctl);
269+
270+ udelay(2);
271+
272+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
273+ value &= ~USB2_OTG_PD;
274+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
275+
276+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
277+ value &= ~USB2_OTG_PD_DR;
278+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
279+}
280+
281+static void tegra_phy_xusb_utmi_pad_power_down(struct phy *phy)
282+{
283+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
284+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
285+ unsigned int index = lane->index;
286+ u32 value;
287+
288+ if (!phy)
289+ return;
290+
291+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
292+ value |= USB2_OTG_PD;
293+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
294+
295+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
296+ value |= USB2_OTG_PD_DR;
297+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
298+
299+ udelay(2);
300+
301+ tegra186_utmi_bias_pad_power_off(padctl);
302+}
303+
304+static int tegra186_utmi_phy_power_on(struct phy *phy)
305+{
306+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
307+ struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
308+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
309+ struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
310+ struct tegra_xusb_usb2_port *port;
311+ unsigned int index = lane->index;
312+ struct device *dev = padctl->dev;
313+ u32 value;
314+
315+ port = tegra_xusb_find_usb2_port(padctl, index);
316+ if (!port) {
317+ dev_err(dev, "no port found for USB2 lane %u\n", index);
318+ return -ENODEV;
319+ }
320+
321+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX);
322+ value &= ~(USB2_PORT_MASK << USB2_PORT_SHIFT(index));
323+ value |= (PORT_XUSB << USB2_PORT_SHIFT(index));
324+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_PAD_MUX);
325+
326+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
327+ value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
328+
329+ if (port->mode == USB_DR_MODE_UNKNOWN)
330+ value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
331+ else if (port->mode == USB_DR_MODE_PERIPHERAL)
332+ value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
333+ else if (port->mode == USB_DR_MODE_HOST)
334+ value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
335+ else if (port->mode == USB_DR_MODE_OTG)
336+ value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
337+
338+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_PORT_CAP);
339+
340+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
341+ value &= ~USB2_OTG_PD_ZI;
342+ value |= TERM_SEL;
343+ value &= ~HS_CURR_LEVEL(~0);
344+
345+ if (usb2->hs_curr_level_offset) {
346+ int hs_current_level;
347+
348+ hs_current_level = (int)priv->calib.hs_curr_level[index] +
349+ usb2->hs_curr_level_offset;
350+
351+ if (hs_current_level < 0)
352+ hs_current_level = 0;
353+ if (hs_current_level > 0x3f)
354+ hs_current_level = 0x3f;
355+
356+ value |= HS_CURR_LEVEL(hs_current_level);
357+ } else {
358+ value |= HS_CURR_LEVEL(priv->calib.hs_curr_level[index]);
359+ }
360+
361+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
362+
363+ value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
364+ value &= ~TERM_RANGE_ADJ(~0);
365+ value |= TERM_RANGE_ADJ(priv->calib.hs_term_range_adj);
366+ value &= ~RPD_CTRL(~0);
367+ value |= RPD_CTRL(priv->calib.rpd_ctrl);
368+ padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
369+
370+ /* TODO: pad power saving */
371+ tegra_phy_xusb_utmi_pad_power_on(phy);
372+ return 0;
373+}
374+
375+static int tegra186_utmi_phy_power_off(struct phy *phy)
376+{
377+ /* TODO: pad power saving */
378+ tegra_phy_xusb_utmi_pad_power_down(phy);
379+
380+ return 0;
381+}
382+
383+static int tegra186_utmi_phy_init(struct phy *phy)
384+{
385+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
386+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
387+ struct tegra_xusb_usb2_port *port;
388+ unsigned int index = lane->index;
389+ struct device *dev = padctl->dev;
390+ int err;
391+
392+ port = tegra_xusb_find_usb2_port(padctl, index);
393+ if (!port) {
394+ dev_err(dev, "no port found for USB2 lane %u\n", index);
395+ return -ENODEV;
396+ }
397+
398+ if (port->supply && port->mode == USB_DR_MODE_HOST) {
399+ err = regulator_enable(port->supply);
400+ if (err) {
401+ dev_err(dev, "failed to enable port %u VBUS: %d\n",
402+ index, err);
403+ return err;
404+ }
405+ }
406+
407+ return 0;
408+}
409+
410+static int tegra186_utmi_phy_exit(struct phy *phy)
411+{
412+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
413+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
414+ struct tegra_xusb_usb2_port *port;
415+ unsigned int index = lane->index;
416+ struct device *dev = padctl->dev;
417+ int err;
418+
419+ port = tegra_xusb_find_usb2_port(padctl, index);
420+ if (!port) {
421+ dev_err(dev, "no port found for USB2 lane %u\n", index);
422+ return -ENODEV;
423+ }
424+
425+ if (port->supply && port->mode == USB_DR_MODE_HOST) {
426+ err = regulator_disable(port->supply);
427+ if (err) {
428+ dev_err(dev, "failed to disable port %u VBUS: %d\n",
429+ index, err);
430+ return err;
431+ }
432+ }
433+
434+ return 0;
435+}
436+
437+static const struct phy_ops utmi_phy_ops = {
438+ .init = tegra186_utmi_phy_init,
439+ .exit = tegra186_utmi_phy_exit,
440+ .power_on = tegra186_utmi_phy_power_on,
441+ .power_off = tegra186_utmi_phy_power_off,
442+ .owner = THIS_MODULE,
443+};
444+
445+static struct tegra_xusb_pad *
446+tegra186_usb2_pad_probe(struct tegra_xusb_padctl *padctl,
447+ const struct tegra_xusb_pad_soc *soc,
448+ struct device_node *np)
449+{
450+ struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
451+ struct tegra_xusb_usb2_pad *usb2;
452+ struct tegra_xusb_pad *pad;
453+ int err;
454+
455+ usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
456+ if (!usb2)
457+ return ERR_PTR(-ENOMEM);
458+
459+ pad = &usb2->base;
460+ pad->ops = &tegra186_usb2_lane_ops;
461+ pad->soc = soc;
462+
463+ err = tegra_xusb_pad_init(pad, padctl, np);
464+ if (err < 0) {
465+ kfree(usb2);
466+ goto out;
467+ }
468+
469+ priv->usb2_trk_clk = devm_clk_get(&pad->dev, "trk");
470+ if (IS_ERR(priv->usb2_trk_clk)) {
471+ err = PTR_ERR(priv->usb2_trk_clk);
472+ dev_dbg(&pad->dev, "failed to get usb2 trk clock: %d\n", err);
473+ goto unregister;
474+ }
475+
476+ err = tegra_xusb_pad_register(pad, &utmi_phy_ops);
477+ if (err < 0)
478+ goto unregister;
479+
480+ dev_set_drvdata(&pad->dev, pad);
481+
482+ return pad;
483+
484+unregister:
485+ device_unregister(&pad->dev);
486+out:
487+ return ERR_PTR(err);
488+}
489+
490+static void tegra186_usb2_pad_remove(struct tegra_xusb_pad *pad)
491+{
492+ struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
493+
494+ kfree(usb2);
495+}
496+
497+static const struct tegra_xusb_pad_ops tegra186_usb2_pad_ops = {
498+ .probe = tegra186_usb2_pad_probe,
499+ .remove = tegra186_usb2_pad_remove,
500+};
501+
502+static const char * const tegra186_usb2_functions[] = {
503+ "xusb",
504+};
505+
506+static const struct tegra_xusb_lane_soc tegra186_usb2_lanes[] = {
507+ TEGRA186_LANE("usb2-0", 0, 0, 0, usb2),
508+ TEGRA186_LANE("usb2-1", 0, 0, 0, usb2),
509+ TEGRA186_LANE("usb2-2", 0, 0, 0, usb2),
510+};
511+
512+static const struct tegra_xusb_pad_soc tegra186_usb2_pad = {
513+ .name = "usb2",
514+ .num_lanes = ARRAY_SIZE(tegra186_usb2_lanes),
515+ .lanes = tegra186_usb2_lanes,
516+ .ops = &tegra186_usb2_pad_ops,
517+};
518+
519+static int tegra186_usb2_port_enable(struct tegra_xusb_port *port)
520+{
521+ return 0;
522+}
523+
524+static void tegra186_usb2_port_disable(struct tegra_xusb_port *port)
525+{
526+}
527+
528+static struct tegra_xusb_lane *
529+tegra186_usb2_port_map(struct tegra_xusb_port *port)
530+{
531+ return tegra_xusb_find_lane(port->padctl, "usb2", port->index);
532+}
533+
534+static const struct tegra_xusb_port_ops tegra186_usb2_port_ops = {
535+ .enable = tegra186_usb2_port_enable,
536+ .disable = tegra186_usb2_port_disable,
537+ .map = tegra186_usb2_port_map,
538+};
539+
540+/* SuperSpeed PHY support */
541+static struct tegra_xusb_lane *
542+tegra186_usb3_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
543+ unsigned int index)
544+{
545+ struct tegra_xusb_usb3_lane *usb3;
546+ int err;
547+
548+ usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
549+ if (!usb3)
550+ return ERR_PTR(-ENOMEM);
551+
552+ INIT_LIST_HEAD(&usb3->base.list);
553+ usb3->base.soc = &pad->soc->lanes[index];
554+ usb3->base.index = index;
555+ usb3->base.pad = pad;
556+ usb3->base.np = np;
557+
558+ err = tegra_xusb_lane_parse_dt(&usb3->base, np);
559+ if (err < 0) {
560+ kfree(usb3);
561+ return ERR_PTR(err);
562+ }
563+
564+ return &usb3->base;
565+}
566+
567+static void tegra186_usb3_lane_remove(struct tegra_xusb_lane *lane)
568+{
569+ struct tegra_xusb_usb3_lane *usb3 = to_usb3_lane(lane);
570+
571+ kfree(usb3);
572+}
573+
574+static const struct tegra_xusb_lane_ops tegra186_usb3_lane_ops = {
575+ .probe = tegra186_usb3_lane_probe,
576+ .remove = tegra186_usb3_lane_remove,
577+};
578+static int tegra186_usb3_port_enable(struct tegra_xusb_port *port)
579+{
580+ return 0;
581+}
582+
583+static void tegra186_usb3_port_disable(struct tegra_xusb_port *port)
584+{
585+}
586+
587+static struct tegra_xusb_lane *
588+tegra186_usb3_port_map(struct tegra_xusb_port *port)
589+{
590+ return tegra_xusb_find_lane(port->padctl, "usb3", port->index);
591+}
592+
593+static const struct tegra_xusb_port_ops tegra186_usb3_port_ops = {
594+ .enable = tegra186_usb3_port_enable,
595+ .disable = tegra186_usb3_port_disable,
596+ .map = tegra186_usb3_port_map,
597+};
598+
599+static int tegra186_usb3_phy_power_on(struct phy *phy)
600+{
601+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
602+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
603+ struct tegra_xusb_usb3_port *port;
604+ struct tegra_xusb_usb2_port *usb2;
605+ unsigned int index = lane->index;
606+ struct device *dev = padctl->dev;
607+ u32 value;
608+
609+ port = tegra_xusb_find_usb3_port(padctl, index);
610+ if (!port) {
611+ dev_err(dev, "no port found for USB3 lane %u\n", index);
612+ return -ENODEV;
613+ }
614+
615+ usb2 = tegra_xusb_find_usb2_port(padctl, port->port);
616+ if (!usb2) {
617+ dev_err(dev, "no companion port found for USB3 lane %u\n",
618+ index);
619+ return -ENODEV;
620+ }
621+
622+ mutex_lock(&padctl->lock);
623+
624+ value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP);
625+ value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
626+
627+ if (usb2->mode == USB_DR_MODE_UNKNOWN)
628+ value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
629+ else if (usb2->mode == USB_DR_MODE_PERIPHERAL)
630+ value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
631+ else if (usb2->mode == USB_DR_MODE_HOST)
632+ value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
633+ else if (usb2->mode == USB_DR_MODE_OTG)
634+ value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
635+
636+ padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_CAP);
637+
638+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
639+ value &= ~SSPX_ELPG_VCORE_DOWN(index);
640+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
641+
642+ usleep_range(100, 200);
643+
644+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
645+ value &= ~SSPX_ELPG_CLAMP_EN_EARLY(index);
646+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
647+
648+ usleep_range(100, 200);
649+
650+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
651+ value &= ~SSPX_ELPG_CLAMP_EN(index);
652+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
653+
654+ mutex_unlock(&padctl->lock);
655+
656+ return 0;
657+}
658+
659+static int tegra186_usb3_phy_power_off(struct phy *phy)
660+{
661+ struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
662+ struct tegra_xusb_padctl *padctl = lane->pad->padctl;
663+ struct tegra_xusb_usb3_port *port;
664+ unsigned int index = lane->index;
665+ struct device *dev = padctl->dev;
666+ u32 value;
667+
668+ port = tegra_xusb_find_usb3_port(padctl, index);
669+ if (!port) {
670+ dev_err(dev, "no port found for USB3 lane %u\n", index);
671+ return -ENODEV;
672+ }
673+
674+ mutex_lock(&padctl->lock);
675+
676+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
677+ value |= SSPX_ELPG_CLAMP_EN_EARLY(index);
678+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
679+
680+ usleep_range(100, 200);
681+
682+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
683+ value |= SSPX_ELPG_CLAMP_EN(index);
684+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
685+
686+ usleep_range(250, 350);
687+
688+ value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
689+ value |= SSPX_ELPG_VCORE_DOWN(index);
690+ padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
691+
692+ mutex_unlock(&padctl->lock);
693+
694+ return 0;
695+}
696+
697+static int tegra186_usb3_phy_init(struct phy *phy)
698+{
699+ return 0;
700+}
701+
702+static int tegra186_usb3_phy_exit(struct phy *phy)
703+{
704+ return 0;
705+}
706+
707+static const struct phy_ops usb3_phy_ops = {
708+ .init = tegra186_usb3_phy_init,
709+ .exit = tegra186_usb3_phy_exit,
710+ .power_on = tegra186_usb3_phy_power_on,
711+ .power_off = tegra186_usb3_phy_power_off,
712+ .owner = THIS_MODULE,
713+};
714+
715+static struct tegra_xusb_pad *
716+tegra186_usb3_pad_probe(struct tegra_xusb_padctl *padctl,
717+ const struct tegra_xusb_pad_soc *soc,
718+ struct device_node *np)
719+{
720+ struct tegra_xusb_usb3_pad *usb3;
721+ struct tegra_xusb_pad *pad;
722+ int err;
723+
724+ usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
725+ if (!usb3)
726+ return ERR_PTR(-ENOMEM);
727+
728+ pad = &usb3->base;
729+ pad->ops = &tegra186_usb3_lane_ops;
730+ pad->soc = soc;
731+
732+ err = tegra_xusb_pad_init(pad, padctl, np);
733+ if (err < 0) {
734+ kfree(usb3);
735+ goto out;
736+ }
737+
738+ err = tegra_xusb_pad_register(pad, &usb3_phy_ops);
739+ if (err < 0)
740+ goto unregister;
741+
742+ dev_set_drvdata(&pad->dev, pad);
743+
744+ return pad;
745+
746+unregister:
747+ device_unregister(&pad->dev);
748+out:
749+ return ERR_PTR(err);
750+}
751+
752+static void tegra186_usb3_pad_remove(struct tegra_xusb_pad *pad)
753+{
754+ struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
755+
756+ kfree(usb2);
757+}
758+
759+static const struct tegra_xusb_pad_ops tegra186_usb3_pad_ops = {
760+ .probe = tegra186_usb3_pad_probe,
761+ .remove = tegra186_usb3_pad_remove,
762+};
763+
764+static const char * const tegra186_usb3_functions[] = {
765+ "xusb",
766+};
767+
768+static const struct tegra_xusb_lane_soc tegra186_usb3_lanes[] = {
769+ TEGRA186_LANE("usb3-0", 0, 0, 0, usb3),
770+ TEGRA186_LANE("usb3-1", 0, 0, 0, usb3),
771+ TEGRA186_LANE("usb3-2", 0, 0, 0, usb3),
772+};
773+
774+static const struct tegra_xusb_pad_soc tegra186_usb3_pad = {
775+ .name = "usb3",
776+ .num_lanes = ARRAY_SIZE(tegra186_usb3_lanes),
777+ .lanes = tegra186_usb3_lanes,
778+ .ops = &tegra186_usb3_pad_ops,
779+};
780+
781+static const struct tegra_xusb_pad_soc * const tegra186_pads[] = {
782+ &tegra186_usb2_pad,
783+ &tegra186_usb3_pad,
784+#if 0 /* TODO implement */
785+ &tegra186_hsic_pad,
786+#endif
787+};
788+
789+static int
790+tegra186_xusb_read_fuse_calibration(struct tegra186_xusb_padctl *padctl)
791+{
792+ struct device *dev = padctl->base.dev;
793+ unsigned int i, count;
794+ u32 value, *level;
795+ int err;
796+
797+ count = padctl->base.soc->ports.usb2.count;
798+
799+ level = devm_kcalloc(dev, count, sizeof(u32), GFP_KERNEL);
800+ if (!level)
801+ return -ENOMEM;
802+
803+ err = tegra_fuse_readl(TEGRA_FUSE_SKU_CALIB_0, &value);
804+ if (err) {
805+ dev_err(dev, "failed to read calibration fuse: %d\n", err);
806+ return err;
807+ }
808+
809+ dev_dbg(dev, "FUSE_USB_CALIB_0 %#x\n", value);
810+
811+ for (i = 0; i < count; i++)
812+ level[i] = (value >> HS_CURR_LEVEL_PADX_SHIFT(i)) &
813+ HS_CURR_LEVEL_PAD_MASK;
814+
815+ padctl->calib.hs_curr_level = level;
816+
817+ padctl->calib.hs_squelch = (value >> HS_SQUELCH_SHIFT) &
818+ HS_SQUELCH_MASK;
819+ padctl->calib.hs_term_range_adj = (value >> HS_TERM_RANGE_ADJ_SHIFT) &
820+ HS_TERM_RANGE_ADJ_MASK;
821+
822+ err = tegra_fuse_readl(TEGRA_FUSE_USB_CALIB_EXT_0, &value);
823+ if (err) {
824+ dev_err(dev, "failed to read calibration fuse: %d\n", err);
825+ return err;
826+ }
827+
828+ dev_dbg(dev, "FUSE_USB_CALIB_EXT_0 %#x\n", value);
829+
830+ padctl->calib.rpd_ctrl = (value >> RPD_CTRL_SHIFT) & RPD_CTRL_MASK;
831+
832+ return 0;
833+}
834+
835+static struct tegra_xusb_padctl *
836+tegra186_xusb_padctl_probe(struct device *dev,
837+ const struct tegra_xusb_padctl_soc *soc)
838+{
839+ struct tegra186_xusb_padctl *priv;
840+ int err;
841+
842+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
843+ if (!priv)
844+ return ERR_PTR(-ENOMEM);
845+
846+ priv->base.dev = dev;
847+ priv->base.soc = soc;
848+
849+ err = tegra186_xusb_read_fuse_calibration(priv);
850+ if (err < 0)
851+ return ERR_PTR(err);
852+
853+ return &priv->base;
854+}
855+
856+static void tegra186_xusb_padctl_remove(struct tegra_xusb_padctl *padctl)
857+{
858+}
859+
860+static const struct tegra_xusb_padctl_ops tegra186_xusb_padctl_ops = {
861+ .probe = tegra186_xusb_padctl_probe,
862+ .remove = tegra186_xusb_padctl_remove,
863+};
864+
865+static const char * const tegra186_xusb_padctl_supply_names[] = {
866+ "avdd-pll-erefeut",
867+ "avdd-usb",
868+ "vclamp-usb",
869+ "vddio-hsic",
870+};
871+
872+const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc = {
873+ .num_pads = ARRAY_SIZE(tegra186_pads),
874+ .pads = tegra186_pads,
875+ .ports = {
876+ .usb2 = {
877+ .ops = &tegra186_usb2_port_ops,
878+ .count = 3,
879+ },
880+#if 0 /* TODO implement */
881+ .hsic = {
882+ .ops = &tegra186_hsic_port_ops,
883+ .count = 1,
884+ },
885+#endif
886+ .usb3 = {
887+ .ops = &tegra186_usb3_port_ops,
888+ .count = 3,
889+ },
890+ },
891+ .ops = &tegra186_xusb_padctl_ops,
892+ .supply_names = tegra186_xusb_padctl_supply_names,
893+ .num_supplies = ARRAY_SIZE(tegra186_xusb_padctl_supply_names),
894+};
895+EXPORT_SYMBOL_GPL(tegra186_xusb_padctl_soc);
896+
897+MODULE_AUTHOR("JC Kuo <jckuo@nvidia.com>");
898+MODULE_DESCRIPTION("NVIDIA Tegra186 XUSB Pad Controller driver");
899+MODULE_LICENSE("GPL v2");
drivers/phy/tegra/xusb.c+65−2
@@ -1,5 +1,5 @@
11 /*
2− * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
2+ * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved.
33 *
44 * This program is free software; you can redistribute it and/or modify it
55 * under the terms and conditions of the GNU General Public License,
@@ -67,6 +67,12 @@ static const struct of_device_id tegra_xusb_padctl_of_match[] = { · 61 unmodified lines
6767 .compatible = "nvidia,tegra210-xusb-padctl",
6868 .data = &tegra210_xusb_padctl_soc,
6969 },
70+#endif
71+#if defined(CONFIG_ARCH_TEGRA_186_SOC)
72+ {
73+ .compatible = "nvidia,tegra186-xusb-padctl",
74+ .data = &tegra186_xusb_padctl_soc,
75+ },
7076 #endif
7177 { }
7278 };
@@ -313,6 +319,10 @@ static void tegra_xusb_lane_program(struct tegra_xusb_lane *lane) · 240 unmodified lines
313319 const struct tegra_xusb_lane_soc *soc = lane->soc;
314320 u32 value;
315321
322+ /* skip single function lanes */
323+ if (soc->num_funcs < 2)
324+ return;
325+
316326 /* choose function */
317327 value = padctl_readl(padctl, soc->offset);
318328 value &= ~(soc->mask << soc->shift);
@@ -542,13 +552,34 @@ static void tegra_xusb_port_unregister(struct tegra_xusb_port *port) · 223 unmodified lines
542552 device_unregister(&port->dev);
543553 }
544554
555+static const char *const modes[] = {
556+ [USB_DR_MODE_UNKNOWN] = "",
557+ [USB_DR_MODE_HOST] = "host",
558+ [USB_DR_MODE_PERIPHERAL] = "peripheral",
559+ [USB_DR_MODE_OTG] = "otg",
560+};
561+
545562 static int tegra_xusb_usb2_port_parse_dt(struct tegra_xusb_usb2_port *usb2)
546563 {
547564 struct tegra_xusb_port *port = &usb2->base;
548565 struct device_node *np = port->dev.of_node;
566+ const char *mode;
549567
550568 usb2->internal = of_property_read_bool(np, "nvidia,internal");
551569
570+ if (!of_property_read_string(np, "mode", &mode)) {
571+ int err = match_string(modes, ARRAY_SIZE(modes), mode);
572+ if (err < 0) {
573+ dev_err(&port->dev, "invalid value %s for \"mode\"\n",
574+ mode);
575+ usb2->mode = USB_DR_MODE_UNKNOWN;
576+ } else {
577+ usb2->mode = err;
578+ }
579+ } else {
580+ usb2->mode = USB_DR_MODE_HOST;
581+ }
582+
552583 usb2->supply = devm_regulator_get(&port->dev, "vbus");
553584 return PTR_ERR_OR_ZERO(usb2->supply);
554585 }
@@ -839,6 +870,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) · 284 unmodified lines
839870 struct tegra_xusb_padctl *padctl;
840871 const struct of_device_id *match;
841872 struct resource *res;
873+ unsigned int i;
842874 int err;
843875
844876 /* for backwards compatibility with old device trees */
@@ -876,14 +908,38 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) · 31 unmodified lines
876908 goto remove;
877909 }
878910
911+ padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies,
912+ sizeof(*padctl->supplies), GFP_KERNEL);
913+ if (!padctl->supplies) {
914+ err = -ENOMEM;
915+ goto remove;
916+ }
917+
918+ for (i = 0; i < padctl->soc->num_supplies; i++)
919+ padctl->supplies[i].supply = padctl->soc->supply_names[i];
920+
921+ err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies,
922+ padctl->supplies);
923+ if (err < 0) {
924+ dev_err(&pdev->dev, "failed to get regulators: %d\n", err);
925+ goto remove;
926+ }
927+
879928 err = reset_control_deassert(padctl->rst);
880929 if (err < 0)
881930 goto remove;
882931
932+ err = regulator_bulk_enable(padctl->soc->num_supplies,
933+ padctl->supplies);
934+ if (err < 0) {
935+ dev_err(&pdev->dev, "failed to enable supplies: %d\n", err);
936+ goto reset;
937+ }
938+
883939 err = tegra_xusb_setup_pads(padctl);
884940 if (err < 0) {
885941 dev_err(&pdev->dev, "failed to setup pads: %d\n", err);
886− goto reset;
942+ goto power_down;
887943 }
888944
889945 err = tegra_xusb_setup_ports(padctl);
@@ -896,6 +952,8 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) · 6 unmodified lines
896952
897953 remove_pads:
898954 tegra_xusb_remove_pads(padctl);
955+power_down:
956+ regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies);
899957 reset:
900958 reset_control_assert(padctl->rst);
901959 remove:
@@ -911,6 +969,11 @@ static int tegra_xusb_padctl_remove(struct platform_device *pdev) · 9 unmodified lines
911969 tegra_xusb_remove_ports(padctl);
912970 tegra_xusb_remove_pads(padctl);
913971
972+ err = regulator_bulk_disable(padctl->soc->num_supplies,
973+ padctl->supplies);
974+ if (err < 0)
975+ dev_err(&pdev->dev, "failed to disable supplies: %d\n", err);
976+
914977 err = reset_control_assert(padctl->rst);
915978 if (err < 0)
916979 dev_err(&pdev->dev, "failed to assert reset: %d\n", err);
drivers/phy/tegra/xusb.h+35−0
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919 #include <linux/mutex.h>
2020 #include <linux/workqueue.h>
2121
22+#include <linux/usb/otg.h>
23+
2224 /* legacy entry points for backwards-compatibility */
2325 int tegra_xusb_padctl_legacy_probe(struct platform_device *pdev);
2426 int tegra_xusb_padctl_legacy_remove(struct platform_device *pdev);
@@ -54,10 +56,21 @@ struct tegra_xusb_lane { · 29 unmodified lines
5456 int tegra_xusb_lane_parse_dt(struct tegra_xusb_lane *lane,
5557 struct device_node *np);
5658
59+struct tegra_xusb_usb3_lane {
60+ struct tegra_xusb_lane base;
61+};
62+
63+static inline struct tegra_xusb_usb3_lane *
64+to_usb3_lane(struct tegra_xusb_lane *lane)
65+{
66+ return container_of(lane, struct tegra_xusb_usb3_lane, base);
67+}
68+
5769 struct tegra_xusb_usb2_lane {
5870 struct tegra_xusb_lane base;
5971
6072 u32 hs_curr_level_offset;
73+ bool powered_on;
6174 };
6275
6376 static inline struct tegra_xusb_usb2_lane *
@@ -168,6 +181,19 @@ int tegra_xusb_pad_register(struct tegra_xusb_pad *pad, · 104 unmodified lines
168181 const struct phy_ops *ops);
169182 void tegra_xusb_pad_unregister(struct tegra_xusb_pad *pad);
170183
184+struct tegra_xusb_usb3_pad {
185+ struct tegra_xusb_pad base;
186+
187+ unsigned int enable;
188+ struct mutex lock;
189+};
190+
191+static inline struct tegra_xusb_usb3_pad *
192+to_usb3_pad(struct tegra_xusb_pad *pad)
193+{
194+ return container_of(pad, struct tegra_xusb_usb3_pad, base);
195+}
196+
171197 struct tegra_xusb_usb2_pad {
172198 struct tegra_xusb_pad base;
173199
@@ -271,6 +297,7 @@ struct tegra_xusb_usb2_port { · 97 unmodified lines
271297 struct tegra_xusb_port base;
272298
273299 struct regulator *supply;
300+ enum usb_dr_mode mode;
274301 bool internal;
275302 };
276303
@@ -367,6 +394,9 @@ struct tegra_xusb_padctl_soc { · 90 unmodified lines
367394 } ports;
368395
369396 const struct tegra_xusb_padctl_ops *ops;
397+
398+ const char * const *supply_names;
399+ unsigned int num_supplies;
370400 };
371401
372402 struct tegra_xusb_padctl {
@@ -390,6 +420,8 @@ struct tegra_xusb_padctl { · 17 unmodified lines
390420 unsigned int enable;
391421
392422 struct clk *clk;
423+
424+ struct regulator_bulk_data *supplies;
393425 };
394426
395427 static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value,
@@ -417,5 +449,8 @@ extern const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc; · 21 unmodified lines
417449 #if defined(CONFIG_ARCH_TEGRA_210_SOC)
418450 extern const struct tegra_xusb_padctl_soc tegra210_xusb_padctl_soc;
419451 #endif
452+#if defined(CONFIG_ARCH_TEGRA_186_SOC)
453+extern const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc;
454+#endif
420455
421456 #endif /* __PHY_TEGRA_XUSB_H */
drivers/phy/ti/Kconfig+12−0
@@ -20,6 +20,18 @@ config PHY_DM816X_USB · 19 unmodified lines
2020 help
2121 Enable this for dm816x USB to work.
2222
23+config PHY_AM654_SERDES
24+ tristate "TI AM654 SERDES support"
25+ depends on OF && ARCH_K3 || COMPILE_TEST
26+ depends on COMMON_CLK
27+ select GENERIC_PHY
28+ select MULTIPLEXER
29+ select REGMAP_MMIO
30+ select MUX_MMIO
31+ help
32+ This option enables support for TI AM654 SerDes PHY used for
33+ PCIe.
34+
2335 config OMAP_CONTROL_PHY
2436 tristate "OMAP CONTROL PHY Driver"
2537 depends on ARCH_OMAP2PLUS || COMPILE_TEST
drivers/phy/ti/Makefile+1−0
@@ -6,4 +6,5 @@ obj-$(CONFIG_OMAP_USB2) += phy-omap-usb2.o · 5 unmodified lines
66 obj-$(CONFIG_TI_PIPE3) += phy-ti-pipe3.o
77 obj-$(CONFIG_PHY_TUSB1210) += phy-tusb1210.o
88 obj-$(CONFIG_TWL4030_USB) += phy-twl4030-usb.o
9+obj-$(CONFIG_PHY_AM654_SERDES) += phy-am654-serdes.o
910 obj-$(CONFIG_PHY_TI_GMII_SEL) += phy-gmii-sel.o
drivers/phy/ti/phy-am654-serdes.c+658−0
@@ -0,0 +1,658 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/**
3+ * PCIe SERDES driver for AM654x SoC
4+ *
5+ * Copyright (C) 2018 - 2019 Texas Instruments Incorporated - http://www.ti.com/
6+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
7+ */
8+
9+#include <dt-bindings/phy/phy.h>
10+#include <linux/clk.h>
11+#include <linux/clk-provider.h>
12+#include <linux/delay.h>
13+#include <linux/module.h>
14+#include <linux/mfd/syscon.h>
15+#include <linux/mux/consumer.h>
16+#include <linux/of_address.h>
17+#include <linux/phy/phy.h>
18+#include <linux/platform_device.h>
19+#include <linux/pm_runtime.h>
20+#include <linux/regmap.h>
21+
22+#define CMU_R07C 0x7c
23+
24+#define COMLANE_R138 0xb38
25+#define VERSION 0x70
26+
27+#define COMLANE_R190 0xb90
28+
29+#define COMLANE_R194 0xb94
30+
31+#define SERDES_CTRL 0x1fd0
32+
33+#define WIZ_LANEXCTL_STS 0x1fe0
34+#define TX0_DISABLE_STATE 0x4
35+#define TX0_SLEEP_STATE 0x5
36+#define TX0_SNOOZE_STATE 0x6
37+#define TX0_ENABLE_STATE 0x7
38+
39+#define RX0_DISABLE_STATE 0x4
40+#define RX0_SLEEP_STATE 0x5
41+#define RX0_SNOOZE_STATE 0x6
42+#define RX0_ENABLE_STATE 0x7
43+
44+#define WIZ_PLL_CTRL 0x1ff4
45+#define PLL_DISABLE_STATE 0x4
46+#define PLL_SLEEP_STATE 0x5
47+#define PLL_SNOOZE_STATE 0x6
48+#define PLL_ENABLE_STATE 0x7
49+
50+#define PLL_LOCK_TIME 100000 /* in microseconds */
51+#define SLEEP_TIME 100 /* in microseconds */
52+
53+#define LANE_USB3 0x0
54+#define LANE_PCIE0_LANE0 0x1
55+
56+#define LANE_PCIE1_LANE0 0x0
57+#define LANE_PCIE0_LANE1 0x1
58+
59+#define SERDES_NUM_CLOCKS 3
60+
61+#define AM654_SERDES_CTRL_CLKSEL_MASK GENMASK(7, 4)
62+#define AM654_SERDES_CTRL_CLKSEL_SHIFT 4
63+
64+struct serdes_am654_clk_mux {
65+ struct clk_hw hw;
66+ struct regmap *regmap;
67+ unsigned int reg;
68+ int clk_id;
69+ struct clk_init_data clk_data;
70+};
71+
72+#define to_serdes_am654_clk_mux(_hw) \
73+ container_of(_hw, struct serdes_am654_clk_mux, hw)
74+
75+static struct regmap_config serdes_am654_regmap_config = {
76+ .reg_bits = 32,
77+ .val_bits = 32,
78+ .reg_stride = 4,
79+ .fast_io = true,
80+};
81+
82+static const struct reg_field cmu_master_cdn_o = REG_FIELD(CMU_R07C, 24, 24);
83+static const struct reg_field config_version = REG_FIELD(COMLANE_R138, 16, 23);
84+static const struct reg_field l1_master_cdn_o = REG_FIELD(COMLANE_R190, 9, 9);
85+static const struct reg_field cmu_ok_i_0 = REG_FIELD(COMLANE_R194, 19, 19);
86+static const struct reg_field por_en = REG_FIELD(SERDES_CTRL, 29, 29);
87+static const struct reg_field tx0_enable = REG_FIELD(WIZ_LANEXCTL_STS, 29, 31);
88+static const struct reg_field rx0_enable = REG_FIELD(WIZ_LANEXCTL_STS, 13, 15);
89+static const struct reg_field pll_enable = REG_FIELD(WIZ_PLL_CTRL, 29, 31);
90+static const struct reg_field pll_ok = REG_FIELD(WIZ_PLL_CTRL, 28, 28);
91+
92+struct serdes_am654 {
93+ struct regmap *regmap;
94+ struct regmap_field *cmu_master_cdn_o;
95+ struct regmap_field *config_version;
96+ struct regmap_field *l1_master_cdn_o;
97+ struct regmap_field *cmu_ok_i_0;
98+ struct regmap_field *por_en;
99+ struct regmap_field *tx0_enable;
100+ struct regmap_field *rx0_enable;
101+ struct regmap_field *pll_enable;
102+ struct regmap_field *pll_ok;
103+
104+ struct device *dev;
105+ struct mux_control *control;
106+ bool busy;
107+ u32 type;
108+ struct device_node *of_node;
109+ struct clk_onecell_data clk_data;
110+ struct clk *clks[SERDES_NUM_CLOCKS];
111+};
112+
113+static int serdes_am654_enable_pll(struct serdes_am654 *phy)
114+{
115+ int ret;
116+ u32 val;
117+
118+ ret = regmap_field_write(phy->pll_enable, PLL_ENABLE_STATE);
119+ if (ret)
120+ return ret;
121+
122+ return regmap_field_read_poll_timeout(phy->pll_ok, val, val, 1000,
123+ PLL_LOCK_TIME);
124+}
125+
126+static void serdes_am654_disable_pll(struct serdes_am654 *phy)
127+{
128+ struct device *dev = phy->dev;
129+ int ret;
130+
131+ ret = regmap_field_write(phy->pll_enable, PLL_DISABLE_STATE);
132+ if (ret)
133+ dev_err(dev, "Failed to disable PLL\n");
134+}
135+
136+static int serdes_am654_enable_txrx(struct serdes_am654 *phy)
137+{
138+ int ret;
139+
140+ /* Enable TX */
141+ ret = regmap_field_write(phy->tx0_enable, TX0_ENABLE_STATE);
142+ if (ret)
143+ return ret;
144+
145+ /* Enable RX */
146+ ret = regmap_field_write(phy->rx0_enable, RX0_ENABLE_STATE);
147+ if (ret)
148+ return ret;
149+
150+ return 0;
151+}
152+
153+static int serdes_am654_disable_txrx(struct serdes_am654 *phy)
154+{
155+ int ret;
156+
157+ /* Disable TX */
158+ ret = regmap_field_write(phy->tx0_enable, TX0_DISABLE_STATE);
159+ if (ret)
160+ return ret;
161+
162+ /* Disable RX */
163+ ret = regmap_field_write(phy->rx0_enable, RX0_DISABLE_STATE);
164+ if (ret)
165+ return ret;
166+
167+ return 0;
168+}
169+
170+static int serdes_am654_power_on(struct phy *x)
171+{
172+ struct serdes_am654 *phy = phy_get_drvdata(x);
173+ struct device *dev = phy->dev;
174+ int ret;
175+ u32 val;
176+
177+ ret = serdes_am654_enable_pll(phy);
178+ if (ret) {
179+ dev_err(dev, "Failed to enable PLL\n");
180+ return ret;
181+ }
182+
183+ ret = serdes_am654_enable_txrx(phy);
184+ if (ret) {
185+ dev_err(dev, "Failed to enable TX RX\n");
186+ return ret;
187+ }
188+
189+ return regmap_field_read_poll_timeout(phy->cmu_ok_i_0, val, val,
190+ SLEEP_TIME, PLL_LOCK_TIME);
191+}
192+
193+static int serdes_am654_power_off(struct phy *x)
194+{
195+ struct serdes_am654 *phy = phy_get_drvdata(x);
196+
197+ serdes_am654_disable_txrx(phy);
198+ serdes_am654_disable_pll(phy);
199+
200+ return 0;
201+}
202+
203+static int serdes_am654_init(struct phy *x)
204+{
205+ struct serdes_am654 *phy = phy_get_drvdata(x);
206+ int ret;
207+
208+ ret = regmap_field_write(phy->config_version, VERSION);
209+ if (ret)
210+ return ret;
211+
212+ ret = regmap_field_write(phy->cmu_master_cdn_o, 0x1);
213+ if (ret)
214+ return ret;
215+
216+ ret = regmap_field_write(phy->l1_master_cdn_o, 0x1);
217+ if (ret)
218+ return ret;
219+
220+ return 0;
221+}
222+
223+static int serdes_am654_reset(struct phy *x)
224+{
225+ struct serdes_am654 *phy = phy_get_drvdata(x);
226+ int ret;
227+
228+ ret = regmap_field_write(phy->por_en, 0x1);
229+ if (ret)
230+ return ret;
231+
232+ mdelay(1);
233+
234+ ret = regmap_field_write(phy->por_en, 0x0);
235+ if (ret)
236+ return ret;
237+
238+ return 0;
239+}
240+
241+static void serdes_am654_release(struct phy *x)
242+{
243+ struct serdes_am654 *phy = phy_get_drvdata(x);
244+
245+ phy->type = PHY_NONE;
246+ phy->busy = false;
247+ mux_control_deselect(phy->control);
248+}
249+
250+struct phy *serdes_am654_xlate(struct device *dev, struct of_phandle_args
251+ *args)
252+{
253+ struct serdes_am654 *am654_phy;
254+ struct phy *phy;
255+ int ret;
256+
257+ phy = of_phy_simple_xlate(dev, args);
258+ if (IS_ERR(phy))
259+ return phy;
260+
261+ am654_phy = phy_get_drvdata(phy);
262+ if (am654_phy->busy)
263+ return ERR_PTR(-EBUSY);
264+
265+ ret = mux_control_select(am654_phy->control, args->args[1]);
266+ if (ret) {
267+ dev_err(dev, "Failed to select SERDES Lane Function\n");
268+ return ERR_PTR(ret);
269+ }
270+
271+ am654_phy->busy = true;
272+ am654_phy->type = args->args[0];
273+
274+ return phy;
275+}
276+
277+static const struct phy_ops ops = {
278+ .reset = serdes_am654_reset,
279+ .init = serdes_am654_init,
280+ .power_on = serdes_am654_power_on,
281+ .power_off = serdes_am654_power_off,
282+ .release = serdes_am654_release,
283+ .owner = THIS_MODULE,
284+};
285+
286+#define SERDES_NUM_MUX_COMBINATIONS 16
287+
288+#define LICLK 0
289+#define EXT_REFCLK 1
290+#define RICLK 2
291+
292+static const int
293+serdes_am654_mux_table[SERDES_NUM_MUX_COMBINATIONS][SERDES_NUM_CLOCKS] = {
294+ /*
295+ * Each combination maps to one of
296+ * "Figure 12-1986. SerDes Reference Clock Distribution"
297+ * in TRM.
298+ */
299+ /* Parent of CMU refclk, Left output, Right output
300+ * either of EXT_REFCLK, LICLK, RICLK
301+ */
302+ { EXT_REFCLK, EXT_REFCLK, EXT_REFCLK }, /* 0000 */
303+ { RICLK, EXT_REFCLK, EXT_REFCLK }, /* 0001 */
304+ { EXT_REFCLK, RICLK, LICLK }, /* 0010 */
305+ { RICLK, RICLK, EXT_REFCLK }, /* 0011 */
306+ { LICLK, EXT_REFCLK, EXT_REFCLK }, /* 0100 */
307+ { EXT_REFCLK, EXT_REFCLK, EXT_REFCLK }, /* 0101 */
308+ { LICLK, RICLK, LICLK }, /* 0110 */
309+ { EXT_REFCLK, RICLK, LICLK }, /* 0111 */
310+ { EXT_REFCLK, EXT_REFCLK, LICLK }, /* 1000 */
311+ { RICLK, EXT_REFCLK, LICLK }, /* 1001 */
312+ { EXT_REFCLK, RICLK, EXT_REFCLK }, /* 1010 */
313+ { RICLK, RICLK, EXT_REFCLK }, /* 1011 */
314+ { LICLK, EXT_REFCLK, LICLK }, /* 1100 */
315+ { EXT_REFCLK, EXT_REFCLK, LICLK }, /* 1101 */
316+ { LICLK, RICLK, EXT_REFCLK }, /* 1110 */
317+ { EXT_REFCLK, RICLK, EXT_REFCLK }, /* 1111 */
318+};
319+
320+static u8 serdes_am654_clk_mux_get_parent(struct clk_hw *hw)
321+{
322+ struct serdes_am654_clk_mux *mux = to_serdes_am654_clk_mux(hw);
323+ struct regmap *regmap = mux->regmap;
324+ unsigned int reg = mux->reg;
325+ unsigned int val;
326+
327+ regmap_read(regmap, reg, &val);
328+ val &= AM654_SERDES_CTRL_CLKSEL_MASK;
329+ val >>= AM654_SERDES_CTRL_CLKSEL_SHIFT;
330+
331+ return serdes_am654_mux_table[val][mux->clk_id];
332+}
333+
334+static int serdes_am654_clk_mux_set_parent(struct clk_hw *hw, u8 index)
335+{
336+ struct serdes_am654_clk_mux *mux = to_serdes_am654_clk_mux(hw);
337+ struct regmap *regmap = mux->regmap;
338+ unsigned int reg = mux->reg;
339+ int clk_id = mux->clk_id;
340+ int parents[SERDES_NUM_CLOCKS];
341+ const int *p;
342+ u32 val;
343+ int found, i;
344+ int ret;
345+
346+ /* get existing setting */
347+ regmap_read(regmap, reg, &val);
348+ val &= AM654_SERDES_CTRL_CLKSEL_MASK;
349+ val >>= AM654_SERDES_CTRL_CLKSEL_SHIFT;
350+
351+ for (i = 0; i < SERDES_NUM_CLOCKS; i++)
352+ parents[i] = serdes_am654_mux_table[val][i];
353+
354+ /* change parent of this clock. others left intact */
355+ parents[clk_id] = index;
356+
357+ /* Find the match */
358+ for (val = 0; val < SERDES_NUM_MUX_COMBINATIONS; val++) {
359+ p = serdes_am654_mux_table[val];
360+ found = 1;
361+ for (i = 0; i < SERDES_NUM_CLOCKS; i++) {
362+ if (parents[i] != p[i]) {
363+ found = 0;
364+ break;
365+ }
366+ }
367+
368+ if (found)
369+ break;
370+ }
371+
372+ if (!found) {
373+ /*
374+ * This can never happen, unless we missed
375+ * a valid combination in serdes_am654_mux_table.
376+ */
377+ WARN(1, "Failed to find the parent of %s clock\n",
378+ hw->init->name);
379+ return -EINVAL;
380+ }
381+
382+ val <<= AM654_SERDES_CTRL_CLKSEL_SHIFT;
383+ ret = regmap_update_bits(regmap, reg, AM654_SERDES_CTRL_CLKSEL_MASK,
384+ val);
385+
386+ return ret;
387+}
388+
389+static const struct clk_ops serdes_am654_clk_mux_ops = {
390+ .set_parent = serdes_am654_clk_mux_set_parent,
391+ .get_parent = serdes_am654_clk_mux_get_parent,
392+};
393+
394+static int serdes_am654_clk_register(struct serdes_am654 *am654_phy,
395+ const char *clock_name, int clock_num)
396+{
397+ struct device_node *node = am654_phy->of_node;
398+ struct device *dev = am654_phy->dev;
399+ struct serdes_am654_clk_mux *mux;
400+ struct device_node *regmap_node;
401+ const char **parent_names;
402+ struct clk_init_data *init;
403+ unsigned int num_parents;
404+ struct regmap *regmap;
405+ const __be32 *addr;
406+ unsigned int reg;
407+ struct clk *clk;
408+
409+ mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
410+ if (!mux)
411+ return -ENOMEM;
412+
413+ init = &mux->clk_data;
414+
415+ regmap_node = of_parse_phandle(node, "ti,serdes-clk", 0);
416+ of_node_put(regmap_node);
417+ if (!regmap_node) {
418+ dev_err(dev, "Fail to get serdes-clk node\n");
419+ return -ENODEV;
420+ }
421+
422+ regmap = syscon_node_to_regmap(regmap_node->parent);
423+ if (IS_ERR(regmap)) {
424+ dev_err(dev, "Fail to get Syscon regmap\n");
425+ return PTR_ERR(regmap);
426+ }
427+
428+ num_parents = of_clk_get_parent_count(node);
429+ if (num_parents < 2) {
430+ dev_err(dev, "SERDES clock must have parents\n");
431+ return -EINVAL;
432+ }
433+
434+ parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents),
435+ GFP_KERNEL);
436+ if (!parent_names)
437+ return -ENOMEM;
438+
439+ of_clk_parent_fill(node, parent_names, num_parents);
440+
441+ addr = of_get_address(regmap_node, 0, NULL, NULL);
442+ if (!addr)
443+ return -EINVAL;
444+
445+ reg = be32_to_cpu(*addr);
446+
447+ init->ops = &serdes_am654_clk_mux_ops;
448+ init->flags = CLK_SET_RATE_NO_REPARENT;
449+ init->parent_names = parent_names;
450+ init->num_parents = num_parents;
451+ init->name = clock_name;
452+
453+ mux->regmap = regmap;
454+ mux->reg = reg;
455+ mux->clk_id = clock_num;
456+ mux->hw.init = init;
457+
458+ clk = devm_clk_register(dev, &mux->hw);
459+ if (IS_ERR(clk))
460+ return PTR_ERR(clk);
461+
462+ am654_phy->clks[clock_num] = clk;
463+
464+ return 0;
465+}
466+
467+static const struct of_device_id serdes_am654_id_table[] = {
468+ {
469+ .compatible = "ti,phy-am654-serdes",
470+ },
471+ {}
472+};
473+MODULE_DEVICE_TABLE(of, serdes_am654_id_table);
474+
475+static int serdes_am654_regfield_init(struct serdes_am654 *am654_phy)
476+{
477+ struct regmap *regmap = am654_phy->regmap;
478+ struct device *dev = am654_phy->dev;
479+
480+ am654_phy->cmu_master_cdn_o = devm_regmap_field_alloc(dev, regmap,
481+ cmu_master_cdn_o);
482+ if (IS_ERR(am654_phy->cmu_master_cdn_o)) {
483+ dev_err(dev, "CMU_MASTER_CDN_O reg field init failed\n");
484+ return PTR_ERR(am654_phy->cmu_master_cdn_o);
485+ }
486+
487+ am654_phy->config_version = devm_regmap_field_alloc(dev, regmap,
488+ config_version);
489+ if (IS_ERR(am654_phy->config_version)) {
490+ dev_err(dev, "CONFIG_VERSION reg field init failed\n");
491+ return PTR_ERR(am654_phy->config_version);
492+ }
493+
494+ am654_phy->l1_master_cdn_o = devm_regmap_field_alloc(dev, regmap,
495+ l1_master_cdn_o);
496+ if (IS_ERR(am654_phy->l1_master_cdn_o)) {
497+ dev_err(dev, "L1_MASTER_CDN_O reg field init failed\n");
498+ return PTR_ERR(am654_phy->l1_master_cdn_o);
499+ }
500+
501+ am654_phy->cmu_ok_i_0 = devm_regmap_field_alloc(dev, regmap,
502+ cmu_ok_i_0);
503+ if (IS_ERR(am654_phy->cmu_ok_i_0)) {
504+ dev_err(dev, "CMU_OK_I_0 reg field init failed\n");
505+ return PTR_ERR(am654_phy->cmu_ok_i_0);
506+ }
507+
508+ am654_phy->por_en = devm_regmap_field_alloc(dev, regmap, por_en);
509+ if (IS_ERR(am654_phy->por_en)) {
510+ dev_err(dev, "POR_EN reg field init failed\n");
511+ return PTR_ERR(am654_phy->por_en);
512+ }
513+
514+ am654_phy->tx0_enable = devm_regmap_field_alloc(dev, regmap,
515+ tx0_enable);
516+ if (IS_ERR(am654_phy->tx0_enable)) {
517+ dev_err(dev, "TX0_ENABLE reg field init failed\n");
518+ return PTR_ERR(am654_phy->tx0_enable);
519+ }
520+
521+ am654_phy->rx0_enable = devm_regmap_field_alloc(dev, regmap,
522+ rx0_enable);
523+ if (IS_ERR(am654_phy->rx0_enable)) {
524+ dev_err(dev, "RX0_ENABLE reg field init failed\n");
525+ return PTR_ERR(am654_phy->rx0_enable);
526+ }
527+
528+ am654_phy->pll_enable = devm_regmap_field_alloc(dev, regmap,
529+ pll_enable);
530+ if (IS_ERR(am654_phy->pll_enable)) {
531+ dev_err(dev, "PLL_ENABLE reg field init failed\n");
532+ return PTR_ERR(am654_phy->pll_enable);
533+ }
534+
535+ am654_phy->pll_ok = devm_regmap_field_alloc(dev, regmap, pll_ok);
536+ if (IS_ERR(am654_phy->pll_ok)) {
537+ dev_err(dev, "PLL_OK reg field init failed\n");
538+ return PTR_ERR(am654_phy->pll_ok);
539+ }
540+
541+ return 0;
542+}
543+
544+static int serdes_am654_probe(struct platform_device *pdev)
545+{
546+ struct phy_provider *phy_provider;
547+ struct device *dev = &pdev->dev;
548+ struct device_node *node = dev->of_node;
549+ struct clk_onecell_data *clk_data;
550+ struct serdes_am654 *am654_phy;
551+ struct mux_control *control;
552+ const char *clock_name;
553+ struct regmap *regmap;
554+ void __iomem *base;
555+ struct phy *phy;
556+ int ret;
557+ int i;
558+
559+ am654_phy = devm_kzalloc(dev, sizeof(*am654_phy), GFP_KERNEL);
560+ if (!am654_phy)
561+ return -ENOMEM;
562+
563+ base = devm_platform_ioremap_resource(pdev, 0);
564+ if (IS_ERR(base))
565+ return PTR_ERR(base);
566+
567+ regmap = devm_regmap_init_mmio(dev, base, &serdes_am654_regmap_config);
568+ if (IS_ERR(regmap)) {
569+ dev_err(dev, "Failed to initialize regmap\n");
570+ return PTR_ERR(regmap);
571+ }
572+
573+ control = devm_mux_control_get(dev, NULL);
574+ if (IS_ERR(control))
575+ return PTR_ERR(control);
576+
577+ am654_phy->dev = dev;
578+ am654_phy->of_node = node;
579+ am654_phy->regmap = regmap;
580+ am654_phy->control = control;
581+ am654_phy->type = PHY_NONE;
582+
583+ ret = serdes_am654_regfield_init(am654_phy);
584+ if (ret) {
585+ dev_err(dev, "Failed to initialize regfields\n");
586+ return ret;
587+ }
588+
589+ platform_set_drvdata(pdev, am654_phy);
590+
591+ for (i = 0; i < SERDES_NUM_CLOCKS; i++) {
592+ ret = of_property_read_string_index(node, "clock-output-names",
593+ i, &clock_name);
594+ if (ret) {
595+ dev_err(dev, "Failed to get clock name\n");
596+ return ret;
597+ }
598+
599+ ret = serdes_am654_clk_register(am654_phy, clock_name, i);
600+ if (ret) {
601+ dev_err(dev, "Failed to initialize clock %s\n",
602+ clock_name);
603+ return ret;
604+ }
605+ }
606+
607+ clk_data = &am654_phy->clk_data;
608+ clk_data->clks = am654_phy->clks;
609+ clk_data->clk_num = SERDES_NUM_CLOCKS;
610+ ret = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
611+ if (ret)
612+ return ret;
613+
614+ pm_runtime_enable(dev);
615+
616+ phy = devm_phy_create(dev, NULL, &ops);
617+ if (IS_ERR(phy))
618+ return PTR_ERR(phy);
619+
620+ phy_set_drvdata(phy, am654_phy);
621+ phy_provider = devm_of_phy_provider_register(dev, serdes_am654_xlate);
622+ if (IS_ERR(phy_provider)) {
623+ ret = PTR_ERR(phy_provider);
624+ goto clk_err;
625+ }
626+
627+ return 0;
628+
629+clk_err:
630+ of_clk_del_provider(node);
631+
632+ return ret;
633+}
634+
635+static int serdes_am654_remove(struct platform_device *pdev)
636+{
637+ struct serdes_am654 *am654_phy = platform_get_drvdata(pdev);
638+ struct device_node *node = am654_phy->of_node;
639+
640+ pm_runtime_disable(&pdev->dev);
641+ of_clk_del_provider(node);
642+
643+ return 0;
644+}
645+
646+static struct platform_driver serdes_am654_driver = {
647+ .probe = serdes_am654_probe,
648+ .remove = serdes_am654_remove,
649+ .driver = {
650+ .name = "phy-am654",
651+ .of_match_table = serdes_am654_id_table,
652+ },
653+};
654+module_platform_driver(serdes_am654_driver);
655+
656+MODULE_AUTHOR("Texas Instruments Inc.");
657+MODULE_DESCRIPTION("TI AM654x SERDES driver");
658+MODULE_LICENSE("GPL v2");
drivers/phy/ti/phy-ti-pipe3.c+265−97
@@ -56,51 +56,73 @@ · 55 unmodified lines
5656
5757 #define SATA_PLL_SOFT_RESET BIT(18)
5858
59−#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK 0x003FC000
59+#define PIPE3_PHY_PWRCTL_CLK_CMD_MASK GENMASK(21, 14)
6060 #define PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT 14
6161
62−#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK 0xFFC00000
62+#define PIPE3_PHY_PWRCTL_CLK_FREQ_MASK GENMASK(31, 22)
6363 #define PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT 22
6464
65−#define PIPE3_PHY_TX_RX_POWERON 0x3
66−#define PIPE3_PHY_TX_RX_POWEROFF 0x0
65+#define PIPE3_PHY_RX_POWERON (0x1 << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT)
66+#define PIPE3_PHY_TX_POWERON (0x2 << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT)
6767
6868 #define PCIE_PCS_MASK 0xFF0000
6969 #define PCIE_PCS_DELAY_COUNT_SHIFT 0x10
7070
71−#define PCIEPHYRX_ANA_PROGRAMMABILITY 0x0000000C
71+#define PIPE3_PHY_RX_ANA_PROGRAMMABILITY 0x0000000C
7272 #define INTERFACE_MASK GENMASK(31, 27)
7373 #define INTERFACE_SHIFT 27
74+#define INTERFACE_MODE_USBSS BIT(4)
75+#define INTERFACE_MODE_SATA_1P5 BIT(3)
76+#define INTERFACE_MODE_SATA_3P0 BIT(2)
77+#define INTERFACE_MODE_PCIE BIT(0)
78+
7479 #define LOSD_MASK GENMASK(17, 14)
7580 #define LOSD_SHIFT 14
7681 #define MEM_PLLDIV GENMASK(6, 5)
7782
78−#define PCIEPHYRX_TRIM 0x0000001C
79−#define MEM_DLL_TRIM_SEL GENMASK(31, 30)
83+#define PIPE3_PHY_RX_TRIM 0x0000001C
84+#define MEM_DLL_TRIM_SEL_MASK GENMASK(31, 30)
8085 #define MEM_DLL_TRIM_SHIFT 30
8186
82−#define PCIEPHYRX_DLL 0x00000024
83−#define MEM_DLL_PHINT_RATE GENMASK(31, 30)
87+#define PIPE3_PHY_RX_DLL 0x00000024
88+#define MEM_DLL_PHINT_RATE_MASK GENMASK(31, 30)
89+#define MEM_DLL_PHINT_RATE_SHIFT 30
8490
85−#define PCIEPHYRX_DIGITAL_MODES 0x00000028
91+#define PIPE3_PHY_RX_DIGITAL_MODES 0x00000028
92+#define MEM_HS_RATE_MASK GENMASK(28, 27)
93+#define MEM_HS_RATE_SHIFT 27
94+#define MEM_OVRD_HS_RATE BIT(26)
95+#define MEM_OVRD_HS_RATE_SHIFT 26
8696 #define MEM_CDR_FASTLOCK BIT(23)
87−#define MEM_CDR_LBW GENMASK(22, 21)
88−#define MEM_CDR_STEPCNT GENMASK(20, 19)
97+#define MEM_CDR_FASTLOCK_SHIFT 23
98+#define MEM_CDR_LBW_MASK GENMASK(22, 21)
99+#define MEM_CDR_LBW_SHIFT 21
100+#define MEM_CDR_STEPCNT_MASK GENMASK(20, 19)
101+#define MEM_CDR_STEPCNT_SHIFT 19
89102 #define MEM_CDR_STL_MASK GENMASK(18, 16)
90103 #define MEM_CDR_STL_SHIFT 16
91104 #define MEM_CDR_THR_MASK GENMASK(15, 13)
92105 #define MEM_CDR_THR_SHIFT 13
93106 #define MEM_CDR_THR_MODE BIT(12)
94−#define MEM_CDR_CDR_2NDO_SDM_MODE BIT(11)
95−#define MEM_OVRD_HS_RATE BIT(26)
96−
97−#define PCIEPHYRX_EQUALIZER 0x00000038
98−#define MEM_EQLEV GENMASK(31, 16)
99−#define MEM_EQFTC GENMASK(15, 11)
100−#define MEM_EQCTL GENMASK(10, 7)
107+#define MEM_CDR_THR_MODE_SHIFT 12
108+#define MEM_CDR_2NDO_SDM_MODE BIT(11)
109+#define MEM_CDR_2NDO_SDM_MODE_SHIFT 11
110+
111+#define PIPE3_PHY_RX_EQUALIZER 0x00000038
112+#define MEM_EQLEV_MASK GENMASK(31, 16)
113+#define MEM_EQLEV_SHIFT 16
114+#define MEM_EQFTC_MASK GENMASK(15, 11)
115+#define MEM_EQFTC_SHIFT 11
116+#define MEM_EQCTL_MASK GENMASK(10, 7)
101117 #define MEM_EQCTL_SHIFT 7
102118 #define MEM_OVRD_EQLEV BIT(2)
119+#define MEM_OVRD_EQLEV_SHIFT 2
103120 #define MEM_OVRD_EQFTC BIT(1)
121+#define MEM_OVRD_EQFTC_SHIFT 1
122+
123+#define SATA_PHY_RX_IO_AND_A2D_OVERRIDES 0x44
124+#define MEM_CDR_LOS_SOURCE_MASK GENMASK(10, 9)
125+#define MEM_CDR_LOS_SOURCE_SHIFT 9
104126
105127 /*
106128 * This is an Empirical value that works, need to confirm the actual
@@ -110,6 +132,10 @@ · 3 unmodified lines
110132 #define PLL_IDLE_TIME 100 /* in milliseconds */
111133 #define PLL_LOCK_TIME 100 /* in milliseconds */
112134
135+enum pipe3_mode { PIPE3_MODE_PCIE = 1,
136+ PIPE3_MODE_SATA,
137+ PIPE3_MODE_USBSS };
138+
113139 struct pipe3_dpll_params {
114140 u16 m;
115141 u8 n;
@@ -123,6 +149,27 @@ struct pipe3_dpll_map { · 7 unmodified lines
123149 struct pipe3_dpll_params params;
124150 };
125151
152+struct pipe3_settings {
153+ u8 ana_interface;
154+ u8 ana_losd;
155+ u8 dig_fastlock;
156+ u8 dig_lbw;
157+ u8 dig_stepcnt;
158+ u8 dig_stl;
159+ u8 dig_thr;
160+ u8 dig_thr_mode;
161+ u8 dig_2ndo_sdm_mode;
162+ u8 dig_hs_rate;
163+ u8 dig_ovrd_hs_rate;
164+ u8 dll_trim_sel;
165+ u8 dll_phint_rate;
166+ u8 eq_lev;
167+ u8 eq_ftc;
168+ u8 eq_ctl;
169+ u8 eq_ovrd_lev;
170+ u8 eq_ovrd_ftc;
171+};
172+
126173 struct ti_pipe3 {
127174 void __iomem *pll_ctrl_base;
128175 void __iomem *phy_rx;
@@ -141,6 +188,8 @@ struct ti_pipe3 { · 12 unmodified lines
141188 unsigned int power_reg; /* power reg. index within syscon */
142189 unsigned int pcie_pcs_reg; /* pcs reg. index in syscon */
143190 bool sata_refclk_enabled;
191+ enum pipe3_mode mode;
192+ struct pipe3_settings settings;
144193 };
145194
146195 static struct pipe3_dpll_map dpll_map_usb[] = {
@@ -163,6 +212,89 @@ static struct pipe3_dpll_map dpll_map_sata[] = { · 16 unmodified lines
163212 { }, /* Terminator */
164213 };
165214
215+struct pipe3_data {
216+ enum pipe3_mode mode;
217+ struct pipe3_dpll_map *dpll_map;
218+ struct pipe3_settings settings;
219+};
220+
221+static struct pipe3_data data_usb = {
222+ .mode = PIPE3_MODE_USBSS,
223+ .dpll_map = dpll_map_usb,
224+ .settings = {
225+ /* DRA75x TRM Table 26-17 Preferred USB3_PHY_RX SCP Register Settings */
226+ .ana_interface = INTERFACE_MODE_USBSS,
227+ .ana_losd = 0xa,
228+ .dig_fastlock = 1,
229+ .dig_lbw = 3,
230+ .dig_stepcnt = 0,
231+ .dig_stl = 0x3,
232+ .dig_thr = 1,
233+ .dig_thr_mode = 1,
234+ .dig_2ndo_sdm_mode = 0,
235+ .dig_hs_rate = 0,
236+ .dig_ovrd_hs_rate = 1,
237+ .dll_trim_sel = 0x2,
238+ .dll_phint_rate = 0x3,
239+ .eq_lev = 0,
240+ .eq_ftc = 0,
241+ .eq_ctl = 0x9,
242+ .eq_ovrd_lev = 0,
243+ .eq_ovrd_ftc = 0,
244+ },
245+};
246+
247+static struct pipe3_data data_sata = {
248+ .mode = PIPE3_MODE_SATA,
249+ .dpll_map = dpll_map_sata,
250+ .settings = {
251+ /* DRA75x TRM Table 26-9 Preferred SATA_PHY_RX SCP Register Settings */
252+ .ana_interface = INTERFACE_MODE_SATA_3P0,
253+ .ana_losd = 0x5,
254+ .dig_fastlock = 1,
255+ .dig_lbw = 3,
256+ .dig_stepcnt = 0,
257+ .dig_stl = 0x3,
258+ .dig_thr = 1,
259+ .dig_thr_mode = 1,
260+ .dig_2ndo_sdm_mode = 0,
261+ .dig_hs_rate = 0, /* Not in TRM preferred settings */
262+ .dig_ovrd_hs_rate = 0, /* Not in TRM preferred settings */
263+ .dll_trim_sel = 0x1,
264+ .dll_phint_rate = 0x2, /* for 1.5 GHz DPLL clock */
265+ .eq_lev = 0,
266+ .eq_ftc = 0x1f,
267+ .eq_ctl = 0,
268+ .eq_ovrd_lev = 1,
269+ .eq_ovrd_ftc = 1,
270+ },
271+};
272+
273+static struct pipe3_data data_pcie = {
274+ .mode = PIPE3_MODE_PCIE,
275+ .settings = {
276+ /* DRA75x TRM Table 26-62 Preferred PCIe_PHY_RX SCP Register Settings */
277+ .ana_interface = INTERFACE_MODE_PCIE,
278+ .ana_losd = 0xa,
279+ .dig_fastlock = 1,
280+ .dig_lbw = 3,
281+ .dig_stepcnt = 0,
282+ .dig_stl = 0x3,
283+ .dig_thr = 1,
284+ .dig_thr_mode = 1,
285+ .dig_2ndo_sdm_mode = 0,
286+ .dig_hs_rate = 0,
287+ .dig_ovrd_hs_rate = 0,
288+ .dll_trim_sel = 0x2,
289+ .dll_phint_rate = 0x3,
290+ .eq_lev = 0,
291+ .eq_ftc = 0x1f,
292+ .eq_ctl = 1,
293+ .eq_ovrd_lev = 0,
294+ .eq_ovrd_ftc = 0,
295+ },
296+};
297+
166298 static inline u32 ti_pipe3_readl(void __iomem *addr, unsigned offset)
167299 {
168300 return __raw_readl(addr + offset);
@@ -196,7 +328,6 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy); · 27 unmodified lines
196328
197329 static int ti_pipe3_power_off(struct phy *x)
198330 {
199− u32 val;
200331 int ret;
201332 struct ti_pipe3 *phy = phy_get_drvdata(x);
202333
@@ -205,13 +336,13 @@ static int ti_pipe3_power_off(struct phy *x) · 2 unmodified lines
205336 return 0;
206337 }
207338
208− val = PIPE3_PHY_TX_RX_POWEROFF << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
209−
210339 ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
211− PIPE3_PHY_PWRCTL_CLK_CMD_MASK, val);
340+ PIPE3_PHY_PWRCTL_CLK_CMD_MASK, 0);
212341 return ret;
213342 }
214343
344+static void ti_pipe3_calibrate(struct ti_pipe3 *phy);
345+
215346 static int ti_pipe3_power_on(struct phy *x)
216347 {
217348 u32 val;
@@ -219,6 +350,7 @@ static int ti_pipe3_power_on(struct phy *x) · 1 unmodified line
219350 int ret;
220351 unsigned long rate;
221352 struct ti_pipe3 *phy = phy_get_drvdata(x);
353+ bool rx_pending = false;
222354
223355 if (!phy->phy_power_syscon) {
224356 omap_control_phy_power(phy->control_dev, 1);
@@ -231,14 +363,35 @@ static int ti_pipe3_power_on(struct phy *x) · 6 unmodified lines
231363 return -EINVAL;
232364 }
233365 rate = rate / 1000000;
234− mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK |
235− OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
236− val = PIPE3_PHY_TX_RX_POWERON << PIPE3_PHY_PWRCTL_CLK_CMD_SHIFT;
237− val |= rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
238−
366+ mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_MASK;
367+ val = rate << OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_FREQ_SHIFT;
239368 ret = regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
240369 mask, val);
241− return ret;
370+ /*
371+ * For PCIe, TX and RX must be powered on simultaneously.
372+ * For USB and SATA, TX must be powered on before RX
373+ */
374+ mask = OMAP_CTRL_PIPE3_PHY_PWRCTL_CLK_CMD_MASK;
375+ if (phy->mode == PIPE3_MODE_SATA || phy->mode == PIPE3_MODE_USBSS) {
376+ val = PIPE3_PHY_TX_POWERON;
377+ rx_pending = true;
378+ } else {
379+ val = PIPE3_PHY_TX_POWERON | PIPE3_PHY_RX_POWERON;
380+ }
381+
382+ regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
383+ mask, val);
384+
385+ if (rx_pending) {
386+ val = PIPE3_PHY_TX_POWERON | PIPE3_PHY_RX_POWERON;
387+ regmap_update_bits(phy->phy_power_syscon, phy->power_reg,
388+ mask, val);
389+ }
390+
391+ if (phy->mode == PIPE3_MODE_PCIE)
392+ ti_pipe3_calibrate(phy);
393+
394+ return 0;
242395 }
243396
244397 static int ti_pipe3_dpll_wait_lock(struct ti_pipe3 *phy)
@@ -300,32 +453,55 @@ static int ti_pipe3_dpll_program(struct ti_pipe3 *phy) · 55 unmodified lines
300453 static void ti_pipe3_calibrate(struct ti_pipe3 *phy)
301454 {
302455 u32 val;
456+ struct pipe3_settings *s = &phy->settings;
303457
304− val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY);
458+ val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_ANA_PROGRAMMABILITY);
305459 val &= ~(INTERFACE_MASK | LOSD_MASK | MEM_PLLDIV);
306− val = (0x1 << INTERFACE_SHIFT | 0xA << LOSD_SHIFT);
307− ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY, val);
308−
309− val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES);
310− val &= ~(MEM_CDR_STEPCNT | MEM_CDR_STL_MASK | MEM_CDR_THR_MASK |
311− MEM_CDR_CDR_2NDO_SDM_MODE | MEM_OVRD_HS_RATE);
312− val |= (MEM_CDR_FASTLOCK | MEM_CDR_LBW | 0x3 << MEM_CDR_STL_SHIFT |
313− 0x1 << MEM_CDR_THR_SHIFT | MEM_CDR_THR_MODE);
314− ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES, val);
315−
316− val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_TRIM);
317− val &= ~MEM_DLL_TRIM_SEL;
318− val |= 0x2 << MEM_DLL_TRIM_SHIFT;
319− ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_TRIM, val);
320−
321− val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DLL);
322− val |= MEM_DLL_PHINT_RATE;
323− ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DLL, val);
324−
325− val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_EQUALIZER);
326− val &= ~(MEM_EQLEV | MEM_EQCTL | MEM_OVRD_EQLEV | MEM_OVRD_EQFTC);
327− val |= MEM_EQFTC | 0x1 << MEM_EQCTL_SHIFT;
328− ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_EQUALIZER, val);
460+ val |= (s->ana_interface << INTERFACE_SHIFT | s->ana_losd << LOSD_SHIFT);
461+ ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_ANA_PROGRAMMABILITY, val);
462+
463+ val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_DIGITAL_MODES);
464+ val &= ~(MEM_HS_RATE_MASK | MEM_OVRD_HS_RATE | MEM_CDR_FASTLOCK |
465+ MEM_CDR_LBW_MASK | MEM_CDR_STEPCNT_MASK | MEM_CDR_STL_MASK |
466+ MEM_CDR_THR_MASK | MEM_CDR_THR_MODE | MEM_CDR_2NDO_SDM_MODE);
467+ val |= s->dig_hs_rate << MEM_HS_RATE_SHIFT |
468+ s->dig_ovrd_hs_rate << MEM_OVRD_HS_RATE_SHIFT |
469+ s->dig_fastlock << MEM_CDR_FASTLOCK_SHIFT |
470+ s->dig_lbw << MEM_CDR_LBW_SHIFT |
471+ s->dig_stepcnt << MEM_CDR_STEPCNT_SHIFT |
472+ s->dig_stl << MEM_CDR_STL_SHIFT |
473+ s->dig_thr << MEM_CDR_THR_SHIFT |
474+ s->dig_thr_mode << MEM_CDR_THR_MODE_SHIFT |
475+ s->dig_2ndo_sdm_mode << MEM_CDR_2NDO_SDM_MODE_SHIFT;
476+ ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_DIGITAL_MODES, val);
477+
478+ val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_TRIM);
479+ val &= ~MEM_DLL_TRIM_SEL_MASK;
480+ val |= s->dll_trim_sel << MEM_DLL_TRIM_SHIFT;
481+ ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_TRIM, val);
482+
483+ val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_DLL);
484+ val &= ~MEM_DLL_PHINT_RATE_MASK;
485+ val |= s->dll_phint_rate << MEM_DLL_PHINT_RATE_SHIFT;
486+ ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_DLL, val);
487+
488+ val = ti_pipe3_readl(phy->phy_rx, PIPE3_PHY_RX_EQUALIZER);
489+ val &= ~(MEM_EQLEV_MASK | MEM_EQFTC_MASK | MEM_EQCTL_MASK |
490+ MEM_OVRD_EQLEV | MEM_OVRD_EQFTC);
491+ val |= s->eq_lev << MEM_EQLEV_SHIFT |
492+ s->eq_ftc << MEM_EQFTC_SHIFT |
493+ s->eq_ctl << MEM_EQCTL_SHIFT |
494+ s->eq_ovrd_lev << MEM_OVRD_EQLEV_SHIFT |
495+ s->eq_ovrd_ftc << MEM_OVRD_EQFTC_SHIFT;
496+ ti_pipe3_writel(phy->phy_rx, PIPE3_PHY_RX_EQUALIZER, val);
497+
498+ if (phy->mode == PIPE3_MODE_SATA) {
499+ val = ti_pipe3_readl(phy->phy_rx,
500+ SATA_PHY_RX_IO_AND_A2D_OVERRIDES);
501+ val &= ~MEM_CDR_LOS_SOURCE_MASK;
502+ ti_pipe3_writel(phy->phy_rx, SATA_PHY_RX_IO_AND_A2D_OVERRIDES,
503+ val);
504+ }
329505 }
330506
331507 static int ti_pipe3_init(struct phy *x)
@@ -340,7 +516,7 @@ static int ti_pipe3_init(struct phy *x) · 8 unmodified lines
340516 * as recommended in AM572x TRM SPRUHZ6, section 18.5.2.2, table
341517 * 18-1804.
342518 */
343− if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
519+ if (phy->mode == PIPE3_MODE_PCIE) {
344520 if (!phy->pcs_syscon) {
345521 omap_control_pcie_pcs(phy->control_dev, 0x96);
346522 return 0;
@@ -349,12 +525,7 @@ static int ti_pipe3_init(struct phy *x) · 2 unmodified lines
349525 val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT;
350526 ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg,
351527 PCIE_PCS_MASK, val);
352− if (ret)
353− return ret;
354−
355− ti_pipe3_calibrate(phy);
356−
357− return 0;
528+ return ret;
358529 }
359530
360531 /* Bring it out of IDLE if it is IDLE */
@@ -367,8 +538,7 @@ static int ti_pipe3_init(struct phy *x) · 6 unmodified lines
367538
368539 /* SATA has issues if re-programmed when locked */
369540 val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS);
370− if ((val & PLL_LOCK) && of_device_is_compatible(phy->dev->of_node,
371− "ti,phy-pipe3-sata"))
541+ if ((val & PLL_LOCK) && phy->mode == PIPE3_MODE_SATA)
372542 return ret;
373543
374544 /* Program the DPLL */
@@ -378,6 +548,8 @@ static int ti_pipe3_init(struct phy *x) · 3 unmodified lines
378548 return -EINVAL;
379549 }
380550
551+ ti_pipe3_calibrate(phy);
552+
381553 return ret;
382554 }
383555
@@ -390,12 +562,11 @@ static int ti_pipe3_exit(struct phy *x) · 6 unmodified lines
390562 /* If dpll_reset_syscon is not present we wont power down SATA DPLL
391563 * due to Errata i783
392564 */
393− if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata") &&
394− !phy->dpll_reset_syscon)
565+ if (phy->mode == PIPE3_MODE_SATA && !phy->dpll_reset_syscon)
395566 return 0;
396567
397568 /* PCIe doesn't have internal DPLL */
398− if (!of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
569+ if (phy->mode != PIPE3_MODE_PCIE) {
399570 /* Put DPLL in IDLE mode */
400571 val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
401572 val |= PLL_IDLE;
@@ -418,7 +589,7 @@ static int ti_pipe3_exit(struct phy *x) · 16 unmodified lines
418589 }
419590
420591 /* i783: SATA needs control bit toggle after PLL unlock */
421− if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) {
592+ if (phy->mode == PIPE3_MODE_SATA) {
422593 regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
423594 SATA_PLL_SOFT_RESET, SATA_PLL_SOFT_RESET);
424595 regmap_update_bits(phy->dpll_reset_syscon, phy->dpll_reset_reg,
@@ -443,7 +614,6 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy) · 18 unmodified lines
443614 {
444615 struct clk *clk;
445616 struct device *dev = phy->dev;
446− struct device_node *node = dev->of_node;
447617
448618 phy->refclk = devm_clk_get(dev, "refclk");
449619 if (IS_ERR(phy->refclk)) {
@@ -451,11 +621,11 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy) · 1 unmodified line
451621 /* older DTBs have missing refclk in SATA PHY
452622 * so don't bail out in case of SATA PHY.
453623 */
454− if (!of_device_is_compatible(node, "ti,phy-pipe3-sata"))
624+ if (phy->mode != PIPE3_MODE_SATA)
455625 return PTR_ERR(phy->refclk);
456626 }
457627
458− if (!of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
628+ if (phy->mode != PIPE3_MODE_SATA) {
459629 phy->wkupclk = devm_clk_get(dev, "wkupclk");
460630 if (IS_ERR(phy->wkupclk)) {
461631 dev_err(dev, "unable to get wkupclk\n");
@@ -465,8 +635,7 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy) · 3 unmodified lines
465635 phy->wkupclk = ERR_PTR(-ENODEV);
466636 }
467637
468− if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie") ||
469− phy->phy_power_syscon) {
638+ if (phy->mode != PIPE3_MODE_PCIE || phy->phy_power_syscon) {
470639 phy->sys_clk = devm_clk_get(dev, "sysclk");
471640 if (IS_ERR(phy->sys_clk)) {
472641 dev_err(dev, "unable to get sysclk\n");
@@ -474,7 +643,7 @@ static int ti_pipe3_get_clk(struct ti_pipe3 *phy) · 1 unmodified line
474643 }
475644 }
476645
477− if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
646+ if (phy->mode == PIPE3_MODE_PCIE) {
478647 clk = devm_clk_get(dev, "dpll_ref");
479648 if (IS_ERR(clk)) {
480649 dev_err(dev, "unable to get dpll ref clk\n");
@@ -546,7 +715,7 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy) · 65 unmodified lines
546715 phy->control_dev = &control_pdev->dev;
547716 }
548717
549− if (of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
718+ if (phy->mode == PIPE3_MODE_PCIE) {
550719 phy->pcs_syscon = syscon_regmap_lookup_by_phandle(node,
551720 "syscon-pcs");
552721 if (IS_ERR(phy->pcs_syscon)) {
@@ -564,7 +733,7 @@ static int ti_pipe3_get_sysctrl(struct ti_pipe3 *phy) · 11 unmodified lines
564733 }
565734 }
566735
567− if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
736+ if (phy->mode == PIPE3_MODE_SATA) {
568737 phy->dpll_reset_syscon = syscon_regmap_lookup_by_phandle(node,
569738 "syscon-pllreset");
570739 if (IS_ERR(phy->dpll_reset_syscon)) {
@@ -589,12 +758,8 @@ static int ti_pipe3_get_tx_rx_base(struct ti_pipe3 *phy) · 18 unmodified lines
589758 {
590759 struct resource *res;
591760 struct device *dev = phy->dev;
592− struct device_node *node = dev->of_node;
593761 struct platform_device *pdev = to_platform_device(dev);
594762
595− if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
596− return 0;
597−
598763 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
599764 "phy_rx");
600765 phy->phy_rx = devm_ioremap_resource(dev, res);
@@ -611,24 +776,12 @@ static int ti_pipe3_get_tx_rx_base(struct ti_pipe3 *phy) · 10 unmodified lines
611776 static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy)
612777 {
613778 struct resource *res;
614− const struct of_device_id *match;
615779 struct device *dev = phy->dev;
616− struct device_node *node = dev->of_node;
617780 struct platform_device *pdev = to_platform_device(dev);
618781
619− if (of_device_is_compatible(node, "ti,phy-pipe3-pcie"))
782+ if (phy->mode == PIPE3_MODE_PCIE)
620783 return 0;
621784
622− match = of_match_device(ti_pipe3_id_table, dev);
623− if (!match)
624− return -EINVAL;
625−
626− phy->dpll_map = (struct pipe3_dpll_map *)match->data;
627− if (!phy->dpll_map) {
628− dev_err(dev, "no DPLL data\n");
629− return -EINVAL;
630− }
631−
632785 res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
633786 "pll_ctrl");
634787 phy->pll_ctrl_base = devm_ioremap_resource(dev, res);
@@ -640,15 +793,29 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 5 unmodified lines
640793 struct ti_pipe3 *phy;
641794 struct phy *generic_phy;
642795 struct phy_provider *phy_provider;
643− struct device_node *node = pdev->dev.of_node;
644796 struct device *dev = &pdev->dev;
645797 int ret;
798+ const struct of_device_id *match;
799+ struct pipe3_data *data;
646800
647801 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL);
648802 if (!phy)
649803 return -ENOMEM;
650804
651− phy->dev = dev;
805+ match = of_match_device(ti_pipe3_id_table, dev);
806+ if (!match)
807+ return -EINVAL;
808+
809+ data = (struct pipe3_data *)match->data;
810+ if (!data) {
811+ dev_err(dev, "no driver data\n");
812+ return -EINVAL;
813+ }
814+
815+ phy->dev = dev;
816+ phy->mode = data->mode;
817+ phy->dpll_map = data->dpll_map;
818+ phy->settings = data->settings;
652819
653820 ret = ti_pipe3_get_pll_base(phy);
654821 if (ret)
@@ -672,7 +839,7 @@ static int ti_pipe3_probe(struct platform_device *pdev) · 17 unmodified lines
672839 /*
673840 * Prevent auto-disable of refclk for SATA PHY due to Errata i783
674841 */
675− if (of_device_is_compatible(node, "ti,phy-pipe3-sata")) {
842+ if (phy->mode == PIPE3_MODE_SATA) {
676843 if (!IS_ERR(phy->refclk)) {
677844 clk_prepare_enable(phy->refclk);
678845 phy->sata_refclk_enabled = true;
@@ -762,18 +929,19 @@ static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy) · 83 unmodified lines
762929 static const struct of_device_id ti_pipe3_id_table[] = {
763930 {
764931 .compatible = "ti,phy-usb3",
765− .data = dpll_map_usb,
932+ .data = &data_usb,
766933 },
767934 {
768935 .compatible = "ti,omap-usb3",
769− .data = dpll_map_usb,
936+ .data = &data_usb,
770937 },
771938 {
772939 .compatible = "ti,phy-pipe3-sata",
773− .data = dpll_map_sata,
940+ .data = &data_sata,
774941 },
775942 {
776943 .compatible = "ti,phy-pipe3-pcie",
944+ .data = &data_pcie,
777945 },
778946 {}
779947 };
drivers/scsi/ufs/Kconfig+1−0
@@ -99,6 +99,7 @@ config SCSI_UFS_DWC_TC_PLATFORM · 98 unmodified lines
9999 config SCSI_UFS_QCOM
100100 tristate "QCOM specific hooks to UFS controller platform driver"
101101 depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
102+ select RESET_CONTROLLER
102103 help
103104 This selects the QCOM specific additions to UFSHCD platform driver.
104105 UFS host on QCOM needs some vendor specific configuration before
drivers/scsi/ufs/ufs-qcom.c+70−44
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <linux/of.h>
1717 #include <linux/platform_device.h>
1818 #include <linux/phy/phy.h>
19+#include <linux/reset-controller.h>
1920
2021 #include "ufshcd.h"
2122 #include "ufshcd-pltfrm.h"
@@ -49,6 +50,11 @@ static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host *host); · 27 unmodified lines
4950 static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba *hba,
5051 u32 clk_cycles);
5152
53+static struct ufs_qcom_host *rcdev_to_ufs_host(struct reset_controller_dev *rcd)
54+{
55+ return container_of(rcd, struct ufs_qcom_host, rcdev);
56+}
57+
5258 static void ufs_qcom_dump_regs_wrapper(struct ufs_hba *hba, int offset, int len,
5359 const char *prefix, void *priv)
5460 {
@@ -255,11 +261,6 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) · 200 unmodified lines
255261 if (is_rate_B)
256262 phy_set_mode(phy, PHY_MODE_UFS_HS_B);
257263
258− /* Assert PHY reset and apply PHY calibration values */
259− ufs_qcom_assert_reset(hba);
260− /* provide 1ms delay to let the reset pulse propagate */
261− usleep_range(1000, 1100);
262−
263264 /* phy initialization - calibrate the phy */
264265 ret = phy_init(phy);
265266 if (ret) {
@@ -268,15 +269,6 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) · 2 unmodified lines
268269 goto out;
269270 }
270271
271− /* De-assert PHY reset and start serdes */
272− ufs_qcom_deassert_reset(hba);
273−
274− /*
275− * after reset deassertion, phy will need all ref clocks,
276− * voltage, current to settle down before starting serdes.
277− */
278− usleep_range(1000, 1100);
279−
280272 /* power on phy - start serdes and phy's power and clocks */
281273 ret = phy_power_on(phy);
282274 if (ret) {
@@ -290,7 +282,6 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba) · 7 unmodified lines
290282 return 0;
291283
292284 out_disable_phy:
293− ufs_qcom_assert_reset(hba);
294285 phy_exit(phy);
295286 out:
296287 return ret;
@@ -554,21 +545,10 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 257 unmodified lines
554545 ufs_qcom_disable_lane_clks(host);
555546 phy_power_off(phy);
556547
557− /* Assert PHY soft reset */
558− ufs_qcom_assert_reset(hba);
559− goto out;
560− }
561−
562− /*
563− * If UniPro link is not active, PHY ref_clk, main PHY analog power
564− * rail and low noise analog power rail for PLL can be switched off.
565− */
566− if (!ufs_qcom_is_link_active(hba)) {
548+ } else if (!ufs_qcom_is_link_active(hba)) {
567549 ufs_qcom_disable_lane_clks(host);
568− phy_power_off(phy);
569550 }
570551
571−out:
572552 return ret;
573553 }
574554
@@ -578,21 +558,26 @@ static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 3 unmodified lines
578558 struct phy *phy = host->generic_phy;
579559 int err;
580560
581− err = phy_power_on(phy);
582− if (err) {
583− dev_err(hba->dev, "%s: failed enabling regs, err = %d\n",
584− __func__, err);
585− goto out;
586− }
561+ if (ufs_qcom_is_link_off(hba)) {
562+ err = phy_power_on(phy);
563+ if (err) {
564+ dev_err(hba->dev, "%s: failed PHY power on: %d\n",
565+ __func__, err);
566+ return err;
567+ }
587568
588− err = ufs_qcom_enable_lane_clks(host);
589− if (err)
590− goto out;
569+ err = ufs_qcom_enable_lane_clks(host);
570+ if (err)
571+ return err;
591572
592− hba->is_sys_suspended = false;
573+ } else if (!ufs_qcom_is_link_active(hba)) {
574+ err = ufs_qcom_enable_lane_clks(host);
575+ if (err)
576+ return err;
577+ }
593578
594−out:
595− return err;
579+ hba->is_sys_suspended = false;
580+ return 0;
596581 }
597582
598583 struct ufs_qcom_dev_params {
@@ -1118,8 +1103,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on, · 519 unmodified lines
11181103 return 0;
11191104
11201105 if (on && (status == POST_CHANGE)) {
1121− phy_power_on(host->generic_phy);
1122−
11231106 /* enable the device ref clock for HS mode*/
11241107 if (ufshcd_is_hs_mode(&hba->pwr_info))
11251108 ufs_qcom_dev_ref_clk_ctrl(host, true);
@@ -1131,9 +1114,6 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on, · 5 unmodified lines
11311114 if (!ufs_qcom_is_link_active(hba)) {
11321115 /* disable device ref_clk */
11331116 ufs_qcom_dev_ref_clk_ctrl(host, false);
1134−
1135− /* powering off PHY during aggressive clk gating */
1136− phy_power_off(host->generic_phy);
11371117 }
11381118
11391119 vote = host->bus_vote.min_bw_vote;
@@ -1147,6 +1127,41 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on, · 7 unmodified lines
11471127 return err;
11481128 }
11491129
1130+static int
1131+ufs_qcom_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
1132+{
1133+ struct ufs_qcom_host *host = rcdev_to_ufs_host(rcdev);
1134+
1135+ /* Currently this code only knows about a single reset. */
1136+ WARN_ON(id);
1137+ ufs_qcom_assert_reset(host->hba);
1138+ /* provide 1ms delay to let the reset pulse propagate. */
1139+ usleep_range(1000, 1100);
1140+ return 0;
1141+}
1142+
1143+static int
1144+ufs_qcom_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
1145+{
1146+ struct ufs_qcom_host *host = rcdev_to_ufs_host(rcdev);
1147+
1148+ /* Currently this code only knows about a single reset. */
1149+ WARN_ON(id);
1150+ ufs_qcom_deassert_reset(host->hba);
1151+
1152+ /*
1153+ * after reset deassertion, phy will need all ref clocks,
1154+ * voltage, current to settle down before starting serdes.
1155+ */
1156+ usleep_range(1000, 1100);
1157+ return 0;
1158+}
1159+
1160+static const struct reset_control_ops ufs_qcom_reset_ops = {
1161+ .assert = ufs_qcom_reset_assert,
1162+ .deassert = ufs_qcom_reset_deassert,
1163+};
1164+
11501165 #define ANDROID_BOOT_DEV_MAX 30
11511166 static char android_boot_dev[ANDROID_BOOT_DEV_MAX];
11521167
@@ -1191,6 +1206,17 @@ static int ufs_qcom_init(struct ufs_hba *hba) · 38 unmodified lines
11911206 host->hba = hba;
11921207 ufshcd_set_variant(hba, host);
11931208
1209+ /* Fire up the reset controller. Failure here is non-fatal. */
1210+ host->rcdev.of_node = dev->of_node;
1211+ host->rcdev.ops = &ufs_qcom_reset_ops;
1212+ host->rcdev.owner = dev->driver->owner;
1213+ host->rcdev.nr_resets = 1;
1214+ err = devm_reset_controller_register(dev, &host->rcdev);
1215+ if (err) {
1216+ dev_warn(dev, "Failed to register reset controller\n");
1217+ err = 0;
1218+ }
1219+
11941220 /*
11951221 * voting/devoting device ref_clk source is time consuming hence
11961222 * skip devoting it during aggressive clock gating. This clock
drivers/scsi/ufs/ufs-qcom.h+4−0
@@ -14,6 +14,8 @@ · 13 unmodified lines
1414 #ifndef UFS_QCOM_H_
1515 #define UFS_QCOM_H_
1616
17+#include <linux/reset-controller.h>
18+
1719 #define MAX_UFS_QCOM_HOSTS 1
1820 #define MAX_U32 (~(u32)0)
1921 #define MPHY_TX_FSM_STATE 0x41
@@ -237,6 +239,8 @@ struct ufs_qcom_host { · 217 unmodified lines
237239 /* Bitmask for enabling debug prints */
238240 u32 dbg_print_en;
239241 struct ufs_qcom_testbus testbus;
242+
243+ struct reset_controller_dev rcdev;
240244 };
241245
242246 static inline u32
include/dt-bindings/phy/phy-am654-serdes.h+13−0
@@ -0,0 +1,13 @@
1+/* SPDX-License-Identifier: GPL-2.0 */
2+/*
3+ * This header provides constants for AM654 SERDES.
4+ */
5+
6+#ifndef _DT_BINDINGS_AM654_SERDES
7+#define _DT_BINDINGS_AM654_SERDES
8+
9+#define AM654_SERDES_CMU_REFCLK 0
10+#define AM654_SERDES_LO_REFCLK 1
11+#define AM654_SERDES_RO_REFCLK 2
12+
13+#endif /* _DT_BINDINGS_AM654_SERDES */
include/linux/phy/phy.h+2−0
@@ -64,6 +64,7 @@ union phy_configure_opts { · 63 unmodified lines
6464 * @set_mode: set the mode of the phy
6565 * @reset: resetting the phy
6666 * @calibrate: calibrate the phy
67+ * @release: ops to be performed while the consumer relinquishes the PHY
6768 * @owner: the module owner containing the ops
6869 */
6970 struct phy_ops {
@@ -105,6 +106,7 @@ struct phy_ops { · 35 unmodified lines
105106 union phy_configure_opts *opts);
106107 int (*reset)(struct phy *phy);
107108 int (*calibrate)(struct phy *phy);
109+ void (*release)(struct phy *phy);
108110 struct module *owner;
109111 };
110112

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t