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

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

Kishon writes:

phy: for 4.15

*) Add support in phy core to perform phy calibration
*) Return NULL for optional PHY's even if CONFIG_GENERIC_PHY is not selected
*) Add USB Phy driver for Broadcom STB SoCs
*) Add support to force mediatek PHY with USB OTG function to enter
a specific mode
*) Calibrate rockchip-typec PHY according to docs
*) Enable dual route feature for sun4i-usb in V3s SoC
*) Use dr_mode dt property to enable otg capability in rcar-gen3-usb2
*) Add driver data to specify dedicated otg pins in rcar-gen3-usb2 driver
*) Configure the RX equalizer of brcm-sata PHY
*) Update pcie phy settings for ti-pipe3 phy
*) Add set_mode callback in qcom-ufs-qmp-14nm phy
*) Use PHY callbacks in phy-qcom-ufs instead of export APIs

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

+2206 -133
+43
Documentation/devicetree/bindings/phy/brcm,brcmstb-usb-phy.txt
··· 1 + Broadcom STB USB PHY 2 + 3 + Required properties: 4 + - compatible: brcm,brcmstb-usb-phy 5 + - reg: two offset and length pairs. 6 + The first pair specifies a manditory set of memory mapped 7 + registers used for general control of the PHY. 8 + The second pair specifies optional registers used by some of 9 + the SoCs that support USB 3.x 10 + - #phy-cells: Shall be 1 as it expects one argument for setting 11 + the type of the PHY. Possible values are: 12 + - PHY_TYPE_USB2 for USB1.1/2.0 PHY 13 + - PHY_TYPE_USB3 for USB3.x PHY 14 + 15 + Optional Properties: 16 + - clocks : clock phandles. 17 + - clock-names: String, clock name. 18 + - brcm,ipp: Boolean, Invert Port Power. 19 + Possible values are: 0 (Don't invert), 1 (Invert) 20 + - brcm,ioc: Boolean, Invert Over Current detection. 21 + Possible values are: 0 (Don't invert), 1 (Invert) 22 + NOTE: one or both of the following two properties must be set 23 + - brcm,has-xhci: Boolean indicating the phy has an XHCI phy. 24 + - brcm,has-eohci: Boolean indicating the phy has an EHCI/OHCI phy. 25 + - dr_mode: String, PHY Device mode. 26 + Possible values are: "host", "peripheral ", "drd" or "typec-pd" 27 + If this property is not defined, the phy will default to "host" mode. 28 + 29 + Example: 30 + 31 + usbphy_0: usb-phy@f0470200 { 32 + reg = <0xf0470200 0xb8>, 33 + <0xf0471940 0x6c0>; 34 + compatible = "brcm,brcmstb-usb-phy"; 35 + #phy-cells = <1>; 36 + dr_mode = "host" 37 + brcm,ioc = <1>; 38 + brcm,ipp = <1>; 39 + brcm,has-xhci; 40 + brcm,has-eohci; 41 + clocks = <&usb20>, <&usb30>; 42 + clock-names = "sw_usb", "sw_usb3"; 43 + };
+10 -1
Documentation/devicetree/bindings/phy/brcm-sata-phy.txt
··· 27 27 This property is not applicable for "brcm,iproc-ns2-sata-phy", 28 28 "brcm,iproc-nsp-sata-phy" and "brcm,iproc-sr-sata-phy". 29 29 30 - Example: 30 + - brcm,rxaeq-mode: string that indicates the desired RX equalizer 31 + mode, possible values are: 32 + "off" (equivalent to not specifying the property) 33 + "auto" 34 + "manual" (brcm,rxaeq-value is used in that case) 35 + 36 + - brcm,rxaeq-value: when 'rxaeq-mode' is set to "manual", provides the RX 37 + equalizer value that should be used. Allowed range is 0..63. 38 + 39 + Example 31 40 sata-phy@f0458100 { 32 41 compatible = "brcm,bcm7445-sata-phy", "brcm,phy-sata3"; 33 42 reg = <0xf0458100 0x1e00>, <0xf045804c 0x10>;
+5 -2
Documentation/devicetree/bindings/phy/rcar-gen2-phy.txt
··· 4 4 2 USB PHY contains. 5 5 6 6 Required properties: 7 - - compatible: "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. 7 + - compatible: "renesas,usb-phy-r8a7743" if the device is a part of R8A7743 SoC. 8 + "renesas,usb-phy-r8a7745" if the device is a part of R8A7745 SoC. 9 + "renesas,usb-phy-r8a7790" if the device is a part of R8A7790 SoC. 8 10 "renesas,usb-phy-r8a7791" if the device is a part of R8A7791 SoC. 9 11 "renesas,usb-phy-r8a7794" if the device is a part of R8A7794 SoC. 10 - "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 compatible device. 12 + "renesas,rcar-gen2-usb-phy" for a generic R-Car Gen2 or 13 + RZ/G1 compatible device. 11 14 12 15 When compatible with the generic version, nodes must list the 13 16 SoC-specific version corresponding to the platform first
+2
Documentation/devicetree/bindings/phy/rcar-gen3-phy-usb2.txt
··· 8 8 SoC. 9 9 "renesas,usb2-phy-r8a7796" if the device is a part of an R8A7796 10 10 SoC. 11 + "renesas,usb2-phy-r8a77995" if the device is a part of an 12 + R8A77995 SoC. 11 13 "renesas,rcar-gen3-usb2-phy" for a generic R-Car Gen3 compatible device. 12 14 13 15 When compatible with the generic version, nodes must list the
+7
MAINTAINERS
··· 2896 2896 F: drivers/gpio/gpio-brcmstb.c 2897 2897 F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt 2898 2898 2899 + BROADCOM BRCMSTB USB2 and USB3 PHY DRIVER 2900 + M: Al Cooper <alcooperx@gmail.com> 2901 + L: linux-kernel@vger.kernel.org 2902 + L: bcm-kernel-feedback-list@broadcom.com 2903 + S: Maintained 2904 + F: drivers/phy/broadcom/phy-brcm-usb* 2905 + 2899 2906 BROADCOM GENET ETHERNET DRIVER 2900 2907 M: Florian Fainelli <f.fainelli@gmail.com> 2901 2908 L: netdev@vger.kernel.org
+16
drivers/pci/dwc/pci-dra7xx.c
··· 11 11 */ 12 12 13 13 #include <linux/delay.h> 14 + #include <linux/device.h> 14 15 #include <linux/err.h> 15 16 #include <linux/interrupt.h> 16 17 #include <linux/irq.h> ··· 595 594 int i; 596 595 int phy_count; 597 596 struct phy **phy; 597 + struct device_link **link; 598 598 void __iomem *base; 599 599 struct resource *res; 600 600 struct dw_pcie *pci; ··· 651 649 if (!phy) 652 650 return -ENOMEM; 653 651 652 + link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL); 653 + if (!link) 654 + return -ENOMEM; 655 + 654 656 for (i = 0; i < phy_count; i++) { 655 657 snprintf(name, sizeof(name), "pcie-phy%d", i); 656 658 phy[i] = devm_phy_get(dev, name); 657 659 if (IS_ERR(phy[i])) 658 660 return PTR_ERR(phy[i]); 661 + 662 + link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); 663 + if (!link[i]) { 664 + ret = -EINVAL; 665 + goto err_link; 666 + } 659 667 } 660 668 661 669 dra7xx->base = base; ··· 743 731 err_get_sync: 744 732 pm_runtime_disable(dev); 745 733 dra7xx_pcie_disable_phy(dra7xx); 734 + 735 + err_link: 736 + while (--i >= 0) 737 + device_link_del(link[i]); 746 738 747 739 return ret; 748 740 }
+1
drivers/phy/allwinner/phy-sun4i-usb.c
··· 926 926 .phyctl_offset = REG_PHYCTL_A33, 927 927 .dedicated_clocks = true, 928 928 .enable_pmu_unk1 = true, 929 + .phy0_dual_route = true, 929 930 }; 930 931 931 932 static const struct sun4i_usb_phy_cfg sun50i_a64_cfg = {
+13
drivers/phy/broadcom/Kconfig
··· 67 67 help 68 68 Enable this to support the Broadcom SATA PHY. 69 69 If unsure, say N. 70 + 71 + config PHY_BRCM_USB 72 + tristate "Broadcom STB USB PHY driver" 73 + depends on ARCH_BRCMSTB 74 + depends on OF 75 + select GENERIC_PHY 76 + select SOC_BRCMSTB 77 + default ARCH_BRCMSTB 78 + help 79 + Enable this to support the Broadcom STB USB PHY. 80 + This driver is required by the USB XHCI, EHCI and OHCI 81 + drivers. 82 + If unsure, say N.
+3
drivers/phy/broadcom/Makefile
··· 5 5 obj-$(CONFIG_PHY_NS2_PCIE) += phy-bcm-ns2-pcie.o 6 6 obj-$(CONFIG_PHY_NS2_USB_DRD) += phy-bcm-ns2-usbdrd.o 7 7 obj-$(CONFIG_PHY_BRCM_SATA) += phy-brcm-sata.o 8 + obj-$(CONFIG_PHY_BRCM_USB) += phy-brcm-usb-dvr.o 9 + 10 + phy-brcm-usb-dvr-objs := phy-brcm-usb.o phy-brcm-usb-init.o
+73 -1
drivers/phy/broadcom/phy-brcm-sata.c
··· 49 49 BRCM_SATA_PHY_IPROC_SR, 50 50 }; 51 51 52 + enum brcm_sata_phy_rxaeq_mode { 53 + RXAEQ_MODE_OFF = 0, 54 + RXAEQ_MODE_AUTO, 55 + RXAEQ_MODE_MANUAL, 56 + }; 57 + 58 + static enum brcm_sata_phy_rxaeq_mode rxaeq_to_val(const char *m) 59 + { 60 + if (!strcmp(m, "auto")) 61 + return RXAEQ_MODE_AUTO; 62 + else if (!strcmp(m, "manual")) 63 + return RXAEQ_MODE_MANUAL; 64 + else 65 + return RXAEQ_MODE_OFF; 66 + } 67 + 52 68 struct brcm_sata_port { 53 69 int portnum; 54 70 struct phy *phy; 55 71 struct brcm_sata_phy *phy_priv; 56 72 bool ssc_en; 73 + enum brcm_sata_phy_rxaeq_mode rxaeq_mode; 74 + u32 rxaeq_val; 57 75 }; 58 76 59 77 struct brcm_sata_phy { ··· 110 92 TX_REG_BANK = 0x070, 111 93 TX_ACTRL0 = 0x80, 112 94 TX_ACTRL0_TXPOL_FLIP = BIT(6), 95 + 96 + AEQRX_REG_BANK_0 = 0xd0, 97 + AEQ_CONTROL1 = 0x81, 98 + AEQ_CONTROL1_ENABLE = BIT(2), 99 + AEQ_CONTROL1_FREEZE = BIT(3), 100 + AEQ_FRC_EQ = 0x83, 101 + AEQ_FRC_EQ_FORCE = BIT(0), 102 + AEQ_FRC_EQ_FORCE_VAL = BIT(1), 103 + AEQRX_REG_BANK_1 = 0xe0, 113 104 114 105 OOB_REG_BANK = 0x150, 115 106 OOB1_REG_BANK = 0x160, ··· 217 190 #define STB_FMAX_VAL_DEFAULT 0x3df 218 191 #define STB_FMAX_VAL_SSC 0x83 219 192 220 - static int brcm_stb_sata_init(struct brcm_sata_port *port) 193 + static void brcm_stb_sata_ssc_init(struct brcm_sata_port *port) 221 194 { 222 195 void __iomem *base = brcm_sata_pcb_base(port); 223 196 struct brcm_sata_phy *priv = port->phy_priv; ··· 242 215 243 216 brcm_sata_phy_wr(base, TXPMD_REG_BANK, TXPMD_TX_FREQ_CTRL_CONTROL3, 244 217 ~TXPMD_TX_FREQ_CTRL_CONTROL3_FMAX_MASK, tmp); 218 + } 219 + 220 + #define AEQ_FRC_EQ_VAL_SHIFT 2 221 + #define AEQ_FRC_EQ_VAL_MASK 0x3f 222 + 223 + static int brcm_stb_sata_rxaeq_init(struct brcm_sata_port *port) 224 + { 225 + void __iomem *base = brcm_sata_pcb_base(port); 226 + u32 tmp = 0, reg = 0; 227 + 228 + switch (port->rxaeq_mode) { 229 + case RXAEQ_MODE_OFF: 230 + return 0; 231 + 232 + case RXAEQ_MODE_AUTO: 233 + reg = AEQ_CONTROL1; 234 + tmp = AEQ_CONTROL1_ENABLE | AEQ_CONTROL1_FREEZE; 235 + break; 236 + 237 + case RXAEQ_MODE_MANUAL: 238 + reg = AEQ_FRC_EQ; 239 + tmp = AEQ_FRC_EQ_FORCE | AEQ_FRC_EQ_FORCE_VAL; 240 + if (port->rxaeq_val > AEQ_FRC_EQ_VAL_MASK) 241 + return -EINVAL; 242 + tmp |= port->rxaeq_val << AEQ_FRC_EQ_VAL_SHIFT; 243 + break; 244 + } 245 + 246 + brcm_sata_phy_wr(base, AEQRX_REG_BANK_0, reg, ~tmp, tmp); 247 + brcm_sata_phy_wr(base, AEQRX_REG_BANK_1, reg, ~tmp, tmp); 245 248 246 249 return 0; 250 + } 251 + 252 + static int brcm_stb_sata_init(struct brcm_sata_port *port) 253 + { 254 + brcm_stb_sata_ssc_init(port); 255 + 256 + return brcm_stb_sata_rxaeq_init(port); 247 257 } 248 258 249 259 /* NS2 SATA PLL1 defaults were characterized by H/W group */ ··· 527 463 528 464 static int brcm_sata_phy_probe(struct platform_device *pdev) 529 465 { 466 + const char *rxaeq_mode; 530 467 struct device *dev = &pdev->dev; 531 468 struct device_node *dn = dev->of_node, *child; 532 469 const struct of_device_id *of_id; ··· 590 525 port->portnum = id; 591 526 port->phy_priv = priv; 592 527 port->phy = devm_phy_create(dev, child, &phy_ops); 528 + port->rxaeq_mode = RXAEQ_MODE_OFF; 529 + if (!of_property_read_string(child, "brcm,rxaeq-mode", 530 + &rxaeq_mode)) 531 + port->rxaeq_mode = rxaeq_to_val(rxaeq_mode); 532 + if (port->rxaeq_mode == RXAEQ_MODE_MANUAL) 533 + of_property_read_u32(child, "brcm,rxaeq-value", 534 + &port->rxaeq_val); 593 535 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); 594 536 if (IS_ERR(port->phy)) { 595 537 dev_err(dev, "failed to create PHY\n");
+1017
drivers/phy/broadcom/phy-brcm-usb-init.c
··· 1 + /* 2 + * phy-brcm-usb-init.c - Broadcom USB Phy chip specific init functions 3 + * 4 + * Copyright (C) 2014-2017 Broadcom 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + /* 17 + * This module contains USB PHY initialization for power up and S3 resume 18 + */ 19 + 20 + #include <linux/delay.h> 21 + #include <linux/io.h> 22 + 23 + #include <linux/soc/brcmstb/brcmstb.h> 24 + #include "phy-brcm-usb-init.h" 25 + 26 + #define PHY_PORTS 2 27 + #define PHY_PORT_SELECT_0 0 28 + #define PHY_PORT_SELECT_1 0x1000 29 + 30 + /* Register definitions for the USB CTRL block */ 31 + #define USB_CTRL_SETUP 0x00 32 + #define USB_CTRL_SETUP_IOC_MASK 0x00000010 33 + #define USB_CTRL_SETUP_IPP_MASK 0x00000020 34 + #define USB_CTRL_SETUP_BABO_MASK 0x00000001 35 + #define USB_CTRL_SETUP_FNHW_MASK 0x00000002 36 + #define USB_CTRL_SETUP_FNBO_MASK 0x00000004 37 + #define USB_CTRL_SETUP_WABO_MASK 0x00000008 38 + #define USB_CTRL_SETUP_SCB_CLIENT_SWAP_MASK 0x00002000 /* option */ 39 + #define USB_CTRL_SETUP_SCB1_EN_MASK 0x00004000 /* option */ 40 + #define USB_CTRL_SETUP_SCB2_EN_MASK 0x00008000 /* option */ 41 + #define USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK 0X00020000 /* option */ 42 + #define USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK 0x00010000 /* option */ 43 + #define USB_CTRL_SETUP_STRAP_IPP_SEL_MASK 0x02000000 /* option */ 44 + #define USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK 0x04000000 /* option */ 45 + #define USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK 0x08000000 /* opt */ 46 + #define USB_CTRL_SETUP_OC3_DISABLE_MASK 0xc0000000 /* option */ 47 + #define USB_CTRL_PLL_CTL 0x04 48 + #define USB_CTRL_PLL_CTL_PLL_SUSPEND_EN_MASK 0x08000000 49 + #define USB_CTRL_PLL_CTL_PLL_RESETB_MASK 0x40000000 50 + #define USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK 0x80000000 /* option */ 51 + #define USB_CTRL_EBRIDGE 0x0c 52 + #define USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK 0x00020000 /* option */ 53 + #define USB_CTRL_MDIO 0x14 54 + #define USB_CTRL_MDIO2 0x18 55 + #define USB_CTRL_UTMI_CTL_1 0x2c 56 + #define USB_CTRL_UTMI_CTL_1_POWER_UP_FSM_EN_MASK 0x00000800 57 + #define USB_CTRL_UTMI_CTL_1_POWER_UP_FSM_EN_P1_MASK 0x08000000 58 + #define USB_CTRL_USB_PM 0x34 59 + #define USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK 0x00800000 /* option */ 60 + #define USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK 0x00400000 /* option */ 61 + #define USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK 0x40000000 /* option */ 62 + #define USB_CTRL_USB_PM_USB_PWRDN_MASK 0x80000000 /* option */ 63 + #define USB_CTRL_USB_PM_SOFT_RESET_MASK 0x40000000 /* option */ 64 + #define USB_CTRL_USB_PM_USB20_HC_RESETB_MASK 0x30000000 /* option */ 65 + #define USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK 0x00300000 /* option */ 66 + #define USB_CTRL_USB30_CTL1 0x60 67 + #define USB_CTRL_USB30_CTL1_PHY3_PLL_SEQ_START_MASK 0x00000010 68 + #define USB_CTRL_USB30_CTL1_PHY3_RESETB_MASK 0x00010000 69 + #define USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK 0x00020000 /* option */ 70 + #define USB_CTRL_USB30_CTL1_USB3_IOC_MASK 0x10000000 /* option */ 71 + #define USB_CTRL_USB30_CTL1_USB3_IPP_MASK 0x20000000 /* option */ 72 + #define USB_CTRL_USB30_PCTL 0x70 73 + #define USB_CTRL_USB30_PCTL_PHY3_SOFT_RESETB_MASK 0x00000002 74 + #define USB_CTRL_USB30_PCTL_PHY3_SOFT_RESETB_P1_MASK 0x00020000 75 + #define USB_CTRL_USB_DEVICE_CTL1 0x90 76 + #define USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK 0x00000003 /* option */ 77 + 78 + /* Register definitions for the XHCI EC block */ 79 + #define USB_XHCI_EC_IRAADR 0x658 80 + #define USB_XHCI_EC_IRADAT 0x65c 81 + 82 + enum brcm_family_type { 83 + BRCM_FAMILY_3390A0, 84 + BRCM_FAMILY_7250B0, 85 + BRCM_FAMILY_7271A0, 86 + BRCM_FAMILY_7364A0, 87 + BRCM_FAMILY_7366C0, 88 + BRCM_FAMILY_74371A0, 89 + BRCM_FAMILY_7439B0, 90 + BRCM_FAMILY_7445D0, 91 + BRCM_FAMILY_7260A0, 92 + BRCM_FAMILY_7278A0, 93 + BRCM_FAMILY_COUNT, 94 + }; 95 + 96 + #define USB_BRCM_FAMILY(chip) \ 97 + [BRCM_FAMILY_##chip] = __stringify(chip) 98 + 99 + static const char *family_names[BRCM_FAMILY_COUNT] = { 100 + USB_BRCM_FAMILY(3390A0), 101 + USB_BRCM_FAMILY(7250B0), 102 + USB_BRCM_FAMILY(7271A0), 103 + USB_BRCM_FAMILY(7364A0), 104 + USB_BRCM_FAMILY(7366C0), 105 + USB_BRCM_FAMILY(74371A0), 106 + USB_BRCM_FAMILY(7439B0), 107 + USB_BRCM_FAMILY(7445D0), 108 + USB_BRCM_FAMILY(7260A0), 109 + USB_BRCM_FAMILY(7278A0), 110 + }; 111 + 112 + enum { 113 + USB_CTRL_SETUP_SCB1_EN_SELECTOR, 114 + USB_CTRL_SETUP_SCB2_EN_SELECTOR, 115 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_SELECTOR, 116 + USB_CTRL_SETUP_STRAP_IPP_SEL_SELECTOR, 117 + USB_CTRL_SETUP_OC3_DISABLE_SELECTOR, 118 + USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_SELECTOR, 119 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_SELECTOR, 120 + USB_CTRL_USB_PM_BDC_SOFT_RESETB_SELECTOR, 121 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_SELECTOR, 122 + USB_CTRL_USB_PM_USB_PWRDN_SELECTOR, 123 + USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_SELECTOR, 124 + USB_CTRL_USB30_CTL1_USB3_IOC_SELECTOR, 125 + USB_CTRL_USB30_CTL1_USB3_IPP_SELECTOR, 126 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_SELECTOR, 127 + USB_CTRL_USB_PM_SOFT_RESET_SELECTOR, 128 + USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_SELECTOR, 129 + USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_SELECTOR, 130 + USB_CTRL_USB_PM_USB20_HC_RESETB_SELECTOR, 131 + USB_CTRL_SETUP_ENDIAN_SELECTOR, 132 + USB_CTRL_SELECTOR_COUNT, 133 + }; 134 + 135 + #define USB_CTRL_REG(base, reg) ((void *)base + USB_CTRL_##reg) 136 + #define USB_XHCI_EC_REG(base, reg) ((void *)base + USB_XHCI_EC_##reg) 137 + #define USB_CTRL_MASK(reg, field) \ 138 + USB_CTRL_##reg##_##field##_MASK 139 + #define USB_CTRL_MASK_FAMILY(params, reg, field) \ 140 + (params->usb_reg_bits_map[USB_CTRL_##reg##_##field##_SELECTOR]) 141 + 142 + #define USB_CTRL_SET_FAMILY(params, reg, field) \ 143 + usb_ctrl_set_family(params, USB_CTRL_##reg, \ 144 + USB_CTRL_##reg##_##field##_SELECTOR) 145 + #define USB_CTRL_UNSET_FAMILY(params, reg, field) \ 146 + usb_ctrl_unset_family(params, USB_CTRL_##reg, \ 147 + USB_CTRL_##reg##_##field##_SELECTOR) 148 + 149 + #define USB_CTRL_SET(base, reg, field) \ 150 + usb_ctrl_set(USB_CTRL_REG(base, reg), \ 151 + USB_CTRL_##reg##_##field##_MASK) 152 + #define USB_CTRL_UNSET(base, reg, field) \ 153 + usb_ctrl_unset(USB_CTRL_REG(base, reg), \ 154 + USB_CTRL_##reg##_##field##_MASK) 155 + 156 + #define MDIO_USB2 0 157 + #define MDIO_USB3 BIT(31) 158 + 159 + #define USB_CTRL_SETUP_ENDIAN_BITS ( \ 160 + USB_CTRL_MASK(SETUP, BABO) | \ 161 + USB_CTRL_MASK(SETUP, FNHW) | \ 162 + USB_CTRL_MASK(SETUP, FNBO) | \ 163 + USB_CTRL_MASK(SETUP, WABO)) 164 + 165 + #ifdef __LITTLE_ENDIAN 166 + #define ENDIAN_SETTINGS ( \ 167 + USB_CTRL_MASK(SETUP, BABO) | \ 168 + USB_CTRL_MASK(SETUP, FNHW)) 169 + #else 170 + #define ENDIAN_SETTINGS ( \ 171 + USB_CTRL_MASK(SETUP, FNHW) | \ 172 + USB_CTRL_MASK(SETUP, FNBO) | \ 173 + USB_CTRL_MASK(SETUP, WABO)) 174 + #endif 175 + 176 + struct id_to_type { 177 + u32 id; 178 + int type; 179 + }; 180 + 181 + static const struct id_to_type id_to_type_table[] = { 182 + { 0x33900000, BRCM_FAMILY_3390A0 }, 183 + { 0x72500010, BRCM_FAMILY_7250B0 }, 184 + { 0x72600000, BRCM_FAMILY_7260A0 }, 185 + { 0x72680000, BRCM_FAMILY_7271A0 }, 186 + { 0x72710000, BRCM_FAMILY_7271A0 }, 187 + { 0x73640000, BRCM_FAMILY_7364A0 }, 188 + { 0x73660020, BRCM_FAMILY_7366C0 }, 189 + { 0x07437100, BRCM_FAMILY_74371A0 }, 190 + { 0x74390010, BRCM_FAMILY_7439B0 }, 191 + { 0x74450030, BRCM_FAMILY_7445D0 }, 192 + { 0x72780000, BRCM_FAMILY_7278A0 }, 193 + { 0, BRCM_FAMILY_7271A0 }, /* default */ 194 + }; 195 + 196 + static const u32 197 + usb_reg_bits_map_table[BRCM_FAMILY_COUNT][USB_CTRL_SELECTOR_COUNT] = { 198 + /* 3390B0 */ 199 + [BRCM_FAMILY_3390A0] = { 200 + USB_CTRL_SETUP_SCB1_EN_MASK, 201 + USB_CTRL_SETUP_SCB2_EN_MASK, 202 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 203 + USB_CTRL_SETUP_STRAP_IPP_SEL_MASK, 204 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 205 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 206 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 207 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 208 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK, 209 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 210 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 211 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 212 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 213 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK, 214 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 215 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 216 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 217 + USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK, 218 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 219 + }, 220 + /* 7250b0 */ 221 + [BRCM_FAMILY_7250B0] = { 222 + USB_CTRL_SETUP_SCB1_EN_MASK, 223 + USB_CTRL_SETUP_SCB2_EN_MASK, 224 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 225 + 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */ 226 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 227 + USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK, 228 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 229 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 230 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK, 231 + 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */ 232 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 233 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 234 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 235 + 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */ 236 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 237 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 238 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 239 + USB_CTRL_USB_PM_USB20_HC_RESETB_MASK, 240 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 241 + }, 242 + /* 7271a0 */ 243 + [BRCM_FAMILY_7271A0] = { 244 + 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */ 245 + 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */ 246 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 247 + USB_CTRL_SETUP_STRAP_IPP_SEL_MASK, 248 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 249 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 250 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 251 + USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK, 252 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK, 253 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 254 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 255 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 256 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 257 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK, 258 + USB_CTRL_USB_PM_SOFT_RESET_MASK, 259 + USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK, 260 + USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK, 261 + USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK, 262 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 263 + }, 264 + /* 7364a0 */ 265 + [BRCM_FAMILY_7364A0] = { 266 + USB_CTRL_SETUP_SCB1_EN_MASK, 267 + USB_CTRL_SETUP_SCB2_EN_MASK, 268 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 269 + 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */ 270 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 271 + USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK, 272 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 273 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 274 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK, 275 + 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */ 276 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 277 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 278 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 279 + 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */ 280 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 281 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 282 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 283 + USB_CTRL_USB_PM_USB20_HC_RESETB_MASK, 284 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 285 + }, 286 + /* 7366c0 */ 287 + [BRCM_FAMILY_7366C0] = { 288 + USB_CTRL_SETUP_SCB1_EN_MASK, 289 + USB_CTRL_SETUP_SCB2_EN_MASK, 290 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 291 + 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */ 292 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 293 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 294 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 295 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 296 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_VAR_MASK, 297 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 298 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 299 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 300 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 301 + 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */ 302 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 303 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 304 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 305 + USB_CTRL_USB_PM_USB20_HC_RESETB_MASK, 306 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 307 + }, 308 + /* 74371A0 */ 309 + [BRCM_FAMILY_74371A0] = { 310 + USB_CTRL_SETUP_SCB1_EN_MASK, 311 + USB_CTRL_SETUP_SCB2_EN_MASK, 312 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK, 313 + 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */ 314 + 0, /* USB_CTRL_SETUP_OC3_DISABLE_MASK */ 315 + USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK, 316 + 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */ 317 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 318 + 0, /* USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK */ 319 + 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */ 320 + USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK, 321 + USB_CTRL_USB30_CTL1_USB3_IOC_MASK, 322 + USB_CTRL_USB30_CTL1_USB3_IPP_MASK, 323 + 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */ 324 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 325 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 326 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 327 + 0, /* USB_CTRL_USB_PM_USB20_HC_RESETB_MASK */ 328 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 329 + }, 330 + /* 7439B0 */ 331 + [BRCM_FAMILY_7439B0] = { 332 + USB_CTRL_SETUP_SCB1_EN_MASK, 333 + USB_CTRL_SETUP_SCB2_EN_MASK, 334 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 335 + USB_CTRL_SETUP_STRAP_IPP_SEL_MASK, 336 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 337 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 338 + 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */ 339 + USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK, 340 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK, 341 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 342 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 343 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 344 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 345 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK, 346 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 347 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 348 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 349 + USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK, 350 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 351 + }, 352 + /* 7445d0 */ 353 + [BRCM_FAMILY_7445D0] = { 354 + USB_CTRL_SETUP_SCB1_EN_MASK, 355 + USB_CTRL_SETUP_SCB2_EN_MASK, 356 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_VAR_MASK, 357 + 0, /* USB_CTRL_SETUP_STRAP_IPP_SEL_MASK */ 358 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 359 + USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK, 360 + 0, /* USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK */ 361 + 0, /* USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK */ 362 + 0, /* USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK */ 363 + 0, /* USB_CTRL_USB_PM_USB_PWRDN_MASK */ 364 + USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK, 365 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 366 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 367 + 0, /* USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK */ 368 + 0, /* USB_CTRL_USB_PM_SOFT_RESET_MASK */ 369 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 370 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 371 + USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK, 372 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 373 + }, 374 + /* 7260a0 */ 375 + [BRCM_FAMILY_7260A0] = { 376 + 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */ 377 + 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */ 378 + USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK, 379 + USB_CTRL_SETUP_STRAP_IPP_SEL_MASK, 380 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 381 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 382 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 383 + USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK, 384 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK, 385 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 386 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 387 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 388 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 389 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK, 390 + USB_CTRL_USB_PM_SOFT_RESET_MASK, 391 + USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK, 392 + USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK, 393 + USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK, 394 + ENDIAN_SETTINGS, /* USB_CTRL_SETUP ENDIAN bits */ 395 + }, 396 + /* 7278a0 */ 397 + [BRCM_FAMILY_7278A0] = { 398 + 0, /* USB_CTRL_SETUP_SCB1_EN_MASK */ 399 + 0, /* USB_CTRL_SETUP_SCB2_EN_MASK */ 400 + 0, /*USB_CTRL_SETUP_SS_EHCI64BIT_EN_MASK */ 401 + USB_CTRL_SETUP_STRAP_IPP_SEL_MASK, 402 + USB_CTRL_SETUP_OC3_DISABLE_MASK, 403 + 0, /* USB_CTRL_PLL_CTL_PLL_IDDQ_PWRDN_MASK */ 404 + USB_CTRL_EBRIDGE_ESTOP_SCB_REQ_MASK, 405 + USB_CTRL_USB_PM_BDC_SOFT_RESETB_MASK, 406 + USB_CTRL_USB_PM_XHC_SOFT_RESETB_MASK, 407 + USB_CTRL_USB_PM_USB_PWRDN_MASK, 408 + 0, /* USB_CTRL_USB30_CTL1_XHC_SOFT_RESETB_MASK */ 409 + 0, /* USB_CTRL_USB30_CTL1_USB3_IOC_MASK */ 410 + 0, /* USB_CTRL_USB30_CTL1_USB3_IPP_MASK */ 411 + USB_CTRL_USB_DEVICE_CTL1_PORT_MODE_MASK, 412 + USB_CTRL_USB_PM_SOFT_RESET_MASK, 413 + 0, /* USB_CTRL_SETUP_CC_DRD_MODE_ENABLE_MASK */ 414 + 0, /* USB_CTRL_SETUP_STRAP_CC_DRD_MODE_ENABLE_SEL_MASK */ 415 + 0, /* USB_CTRL_USB_PM_USB20_HC_RESETB_MASK */ 416 + 0, /* USB_CTRL_SETUP ENDIAN bits */ 417 + }, 418 + }; 419 + 420 + static inline u32 brcmusb_readl(void __iomem *addr) 421 + { 422 + return readl(addr); 423 + } 424 + 425 + static inline void brcmusb_writel(u32 val, void __iomem *addr) 426 + { 427 + writel(val, addr); 428 + } 429 + 430 + static inline 431 + void usb_ctrl_unset_family(struct brcm_usb_init_params *params, 432 + u32 reg_offset, u32 field) 433 + { 434 + u32 mask; 435 + void *reg; 436 + 437 + mask = params->usb_reg_bits_map[field]; 438 + reg = params->ctrl_regs + reg_offset; 439 + brcmusb_writel(brcmusb_readl(reg) & ~mask, reg); 440 + }; 441 + 442 + static inline 443 + void usb_ctrl_set_family(struct brcm_usb_init_params *params, 444 + u32 reg_offset, u32 field) 445 + { 446 + u32 mask; 447 + void *reg; 448 + 449 + mask = params->usb_reg_bits_map[field]; 450 + reg = params->ctrl_regs + reg_offset; 451 + brcmusb_writel(brcmusb_readl(reg) | mask, reg); 452 + }; 453 + 454 + static inline void usb_ctrl_set(void __iomem *reg, u32 field) 455 + { 456 + u32 value; 457 + 458 + value = brcmusb_readl(reg); 459 + brcmusb_writel(value | field, reg); 460 + } 461 + 462 + static inline void usb_ctrl_unset(void __iomem *reg, u32 field) 463 + { 464 + u32 value; 465 + 466 + value = brcmusb_readl(reg); 467 + brcmusb_writel(value & ~field, reg); 468 + } 469 + 470 + static u32 brcmusb_usb_mdio_read(void __iomem *ctrl_base, u32 reg, int mode) 471 + { 472 + u32 data; 473 + 474 + data = (reg << 16) | mode; 475 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 476 + data |= (1 << 24); 477 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 478 + data &= ~(1 << 24); 479 + /* wait for the 60MHz parallel to serial shifter */ 480 + usleep_range(10, 20); 481 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 482 + /* wait for the 60MHz parallel to serial shifter */ 483 + usleep_range(10, 20); 484 + 485 + return brcmusb_readl(USB_CTRL_REG(ctrl_base, MDIO2)) & 0xffff; 486 + } 487 + 488 + static void brcmusb_usb_mdio_write(void __iomem *ctrl_base, u32 reg, 489 + u32 val, int mode) 490 + { 491 + u32 data; 492 + 493 + data = (reg << 16) | val | mode; 494 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 495 + data |= (1 << 25); 496 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 497 + data &= ~(1 << 25); 498 + 499 + /* wait for the 60MHz parallel to serial shifter */ 500 + usleep_range(10, 20); 501 + brcmusb_writel(data, USB_CTRL_REG(ctrl_base, MDIO)); 502 + /* wait for the 60MHz parallel to serial shifter */ 503 + usleep_range(10, 20); 504 + } 505 + 506 + static void brcmusb_usb_phy_ldo_fix(void __iomem *ctrl_base) 507 + { 508 + /* first disable FSM but also leave it that way */ 509 + /* to allow normal suspend/resume */ 510 + USB_CTRL_UNSET(ctrl_base, UTMI_CTL_1, POWER_UP_FSM_EN); 511 + USB_CTRL_UNSET(ctrl_base, UTMI_CTL_1, POWER_UP_FSM_EN_P1); 512 + 513 + /* reset USB 2.0 PLL */ 514 + USB_CTRL_UNSET(ctrl_base, PLL_CTL, PLL_RESETB); 515 + /* PLL reset period */ 516 + udelay(1); 517 + USB_CTRL_SET(ctrl_base, PLL_CTL, PLL_RESETB); 518 + /* Give PLL enough time to lock */ 519 + usleep_range(1000, 2000); 520 + } 521 + 522 + static void brcmusb_usb2_eye_fix(void __iomem *ctrl_base) 523 + { 524 + /* Increase USB 2.0 TX level to meet spec requirement */ 525 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x80a0, MDIO_USB2); 526 + brcmusb_usb_mdio_write(ctrl_base, 0x0a, 0xc6a0, MDIO_USB2); 527 + } 528 + 529 + static void brcmusb_usb3_pll_fix(void __iomem *ctrl_base) 530 + { 531 + /* Set correct window for PLL lock detect */ 532 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3); 533 + brcmusb_usb_mdio_write(ctrl_base, 0x07, 0x1503, MDIO_USB3); 534 + } 535 + 536 + static void brcmusb_usb3_enable_pipe_reset(void __iomem *ctrl_base) 537 + { 538 + u32 val; 539 + 540 + /* Re-enable USB 3.0 pipe reset */ 541 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3); 542 + val = brcmusb_usb_mdio_read(ctrl_base, 0x0f, MDIO_USB3) | 0x200; 543 + brcmusb_usb_mdio_write(ctrl_base, 0x0f, val, MDIO_USB3); 544 + } 545 + 546 + static void brcmusb_usb3_enable_sigdet(void __iomem *ctrl_base) 547 + { 548 + u32 val, ofs; 549 + int ii; 550 + 551 + ofs = 0; 552 + for (ii = 0; ii < PHY_PORTS; ++ii) { 553 + /* Set correct default for sigdet */ 554 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8080 + ofs), 555 + MDIO_USB3); 556 + val = brcmusb_usb_mdio_read(ctrl_base, 0x05, MDIO_USB3); 557 + val = (val & ~0x800f) | 0x800d; 558 + brcmusb_usb_mdio_write(ctrl_base, 0x05, val, MDIO_USB3); 559 + ofs = PHY_PORT_SELECT_1; 560 + } 561 + } 562 + 563 + static void brcmusb_usb3_enable_skip_align(void __iomem *ctrl_base) 564 + { 565 + u32 val, ofs; 566 + int ii; 567 + 568 + ofs = 0; 569 + for (ii = 0; ii < PHY_PORTS; ++ii) { 570 + /* Set correct default for SKIP align */ 571 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8060 + ofs), 572 + MDIO_USB3); 573 + val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0x200; 574 + brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3); 575 + ofs = PHY_PORT_SELECT_1; 576 + } 577 + } 578 + 579 + static void brcmusb_usb3_unfreeze_aeq(void __iomem *ctrl_base) 580 + { 581 + u32 val, ofs; 582 + int ii; 583 + 584 + ofs = 0; 585 + for (ii = 0; ii < PHY_PORTS; ++ii) { 586 + /* Let EQ freeze after TSEQ */ 587 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x80e0 + ofs), 588 + MDIO_USB3); 589 + val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3); 590 + val &= ~0x0008; 591 + brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3); 592 + ofs = PHY_PORT_SELECT_1; 593 + } 594 + } 595 + 596 + static void brcmusb_usb3_pll_54mhz(struct brcm_usb_init_params *params) 597 + { 598 + u32 ofs; 599 + int ii; 600 + void __iomem *ctrl_base = params->ctrl_regs; 601 + 602 + /* 603 + * On newer B53 based SoC's, the reference clock for the 604 + * 3.0 PLL has been changed from 50MHz to 54MHz so the 605 + * PLL needs to be reprogrammed. 606 + * See SWLINUX-4006. 607 + * 608 + * On the 7364C0, the reference clock for the 609 + * 3.0 PLL has been changed from 50MHz to 54MHz to 610 + * work around a MOCA issue. 611 + * See SWLINUX-4169. 612 + */ 613 + switch (params->selected_family) { 614 + case BRCM_FAMILY_3390A0: 615 + case BRCM_FAMILY_7250B0: 616 + case BRCM_FAMILY_7366C0: 617 + case BRCM_FAMILY_74371A0: 618 + case BRCM_FAMILY_7439B0: 619 + case BRCM_FAMILY_7445D0: 620 + case BRCM_FAMILY_7260A0: 621 + return; 622 + case BRCM_FAMILY_7364A0: 623 + if (BRCM_REV(params->family_id) < 0x20) 624 + return; 625 + break; 626 + } 627 + 628 + /* set USB 3.0 PLL to accept 54Mhz reference clock */ 629 + USB_CTRL_UNSET(ctrl_base, USB30_CTL1, PHY3_PLL_SEQ_START); 630 + 631 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8000, MDIO_USB3); 632 + brcmusb_usb_mdio_write(ctrl_base, 0x10, 0x5784, MDIO_USB3); 633 + brcmusb_usb_mdio_write(ctrl_base, 0x11, 0x01d0, MDIO_USB3); 634 + brcmusb_usb_mdio_write(ctrl_base, 0x12, 0x1DE8, MDIO_USB3); 635 + brcmusb_usb_mdio_write(ctrl_base, 0x13, 0xAA80, MDIO_USB3); 636 + brcmusb_usb_mdio_write(ctrl_base, 0x14, 0x8826, MDIO_USB3); 637 + brcmusb_usb_mdio_write(ctrl_base, 0x15, 0x0044, MDIO_USB3); 638 + brcmusb_usb_mdio_write(ctrl_base, 0x16, 0x8000, MDIO_USB3); 639 + brcmusb_usb_mdio_write(ctrl_base, 0x17, 0x0851, MDIO_USB3); 640 + brcmusb_usb_mdio_write(ctrl_base, 0x18, 0x0000, MDIO_USB3); 641 + 642 + /* both ports */ 643 + ofs = 0; 644 + for (ii = 0; ii < PHY_PORTS; ++ii) { 645 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8040 + ofs), 646 + MDIO_USB3); 647 + brcmusb_usb_mdio_write(ctrl_base, 0x03, 0x0090, MDIO_USB3); 648 + brcmusb_usb_mdio_write(ctrl_base, 0x04, 0x0134, MDIO_USB3); 649 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, (0x8020 + ofs), 650 + MDIO_USB3); 651 + brcmusb_usb_mdio_write(ctrl_base, 0x01, 0x00e2, MDIO_USB3); 652 + ofs = PHY_PORT_SELECT_1; 653 + } 654 + 655 + /* restart PLL sequence */ 656 + USB_CTRL_SET(ctrl_base, USB30_CTL1, PHY3_PLL_SEQ_START); 657 + /* Give PLL enough time to lock */ 658 + usleep_range(1000, 2000); 659 + } 660 + 661 + static void brcmusb_usb3_ssc_enable(void __iomem *ctrl_base) 662 + { 663 + u32 val; 664 + 665 + /* Enable USB 3.0 TX spread spectrum */ 666 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x8040, MDIO_USB3); 667 + val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0xf; 668 + brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3); 669 + 670 + /* Currently, USB 3.0 SSC is enabled via port 0 MDIO registers, 671 + * which should have been adequate. However, due to a bug in the 672 + * USB 3.0 PHY, it must be enabled via both ports (HWUSB3DVT-26). 673 + */ 674 + brcmusb_usb_mdio_write(ctrl_base, 0x1f, 0x9040, MDIO_USB3); 675 + val = brcmusb_usb_mdio_read(ctrl_base, 0x01, MDIO_USB3) | 0xf; 676 + brcmusb_usb_mdio_write(ctrl_base, 0x01, val, MDIO_USB3); 677 + } 678 + 679 + static void brcmusb_usb3_phy_workarounds(struct brcm_usb_init_params *params) 680 + { 681 + void __iomem *ctrl_base = params->ctrl_regs; 682 + 683 + brcmusb_usb3_pll_fix(ctrl_base); 684 + brcmusb_usb3_pll_54mhz(params); 685 + brcmusb_usb3_ssc_enable(ctrl_base); 686 + brcmusb_usb3_enable_pipe_reset(ctrl_base); 687 + brcmusb_usb3_enable_sigdet(ctrl_base); 688 + brcmusb_usb3_enable_skip_align(ctrl_base); 689 + brcmusb_usb3_unfreeze_aeq(ctrl_base); 690 + } 691 + 692 + static void brcmusb_memc_fix(struct brcm_usb_init_params *params) 693 + { 694 + u32 prid; 695 + 696 + if (params->selected_family != BRCM_FAMILY_7445D0) 697 + return; 698 + /* 699 + * This is a workaround for HW7445-1869 where a DMA write ends up 700 + * doing a read pre-fetch after the end of the DMA buffer. This 701 + * causes a problem when the DMA buffer is at the end of physical 702 + * memory, causing the pre-fetch read to access non-existent memory, 703 + * and the chip bondout has MEMC2 disabled. When the pre-fetch read 704 + * tries to use the disabled MEMC2, it hangs the bus. The workaround 705 + * is to disable MEMC2 access in the usb controller which avoids 706 + * the hang. 707 + */ 708 + 709 + prid = params->product_id & 0xfffff000; 710 + switch (prid) { 711 + case 0x72520000: 712 + case 0x74480000: 713 + case 0x74490000: 714 + case 0x07252000: 715 + case 0x07448000: 716 + case 0x07449000: 717 + USB_CTRL_UNSET_FAMILY(params, SETUP, SCB2_EN); 718 + } 719 + } 720 + 721 + static void brcmusb_usb3_otp_fix(struct brcm_usb_init_params *params) 722 + { 723 + void __iomem *xhci_ec_base = params->xhci_ec_regs; 724 + u32 val; 725 + 726 + if (params->family_id != 0x74371000 || xhci_ec_base == 0) 727 + return; 728 + brcmusb_writel(0xa20c, USB_XHCI_EC_REG(xhci_ec_base, IRAADR)); 729 + val = brcmusb_readl(USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 730 + 731 + /* set cfg_pick_ss_lock */ 732 + val |= (1 << 27); 733 + brcmusb_writel(val, USB_XHCI_EC_REG(xhci_ec_base, IRADAT)); 734 + 735 + /* Reset USB 3.0 PHY for workaround to take effect */ 736 + USB_CTRL_UNSET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); 737 + USB_CTRL_SET(params->ctrl_regs, USB30_CTL1, PHY3_RESETB); 738 + } 739 + 740 + static void brcmusb_xhci_soft_reset(struct brcm_usb_init_params *params, 741 + int on_off) 742 + { 743 + /* Assert reset */ 744 + if (on_off) { 745 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, XHC_SOFT_RESETB)) 746 + USB_CTRL_UNSET_FAMILY(params, USB_PM, XHC_SOFT_RESETB); 747 + else 748 + USB_CTRL_UNSET_FAMILY(params, 749 + USB30_CTL1, XHC_SOFT_RESETB); 750 + } else { /* De-assert reset */ 751 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, XHC_SOFT_RESETB)) 752 + USB_CTRL_SET_FAMILY(params, USB_PM, XHC_SOFT_RESETB); 753 + else 754 + USB_CTRL_SET_FAMILY(params, USB30_CTL1, 755 + XHC_SOFT_RESETB); 756 + } 757 + } 758 + 759 + /* 760 + * Return the best map table family. The order is: 761 + * - exact match of chip and major rev 762 + * - exact match of chip and closest older major rev 763 + * - default chip/rev. 764 + * NOTE: The minor rev is always ignored. 765 + */ 766 + static enum brcm_family_type brcmusb_get_family_type( 767 + struct brcm_usb_init_params *params) 768 + { 769 + int last_type = -1; 770 + u32 last_family = 0; 771 + u32 family_no_major; 772 + unsigned int x; 773 + u32 family; 774 + 775 + family = params->family_id & 0xfffffff0; 776 + family_no_major = params->family_id & 0xffffff00; 777 + for (x = 0; id_to_type_table[x].id; x++) { 778 + if (family == id_to_type_table[x].id) 779 + return id_to_type_table[x].type; 780 + if (family_no_major == (id_to_type_table[x].id & 0xffffff00)) 781 + if (family > id_to_type_table[x].id && 782 + last_family < id_to_type_table[x].id) { 783 + last_family = id_to_type_table[x].id; 784 + last_type = id_to_type_table[x].type; 785 + } 786 + } 787 + 788 + /* If no match, return the default family */ 789 + if (last_type == -1) 790 + return id_to_type_table[x].type; 791 + return last_type; 792 + } 793 + 794 + void brcm_usb_init_ipp(struct brcm_usb_init_params *params) 795 + { 796 + void __iomem *ctrl = params->ctrl_regs; 797 + u32 reg; 798 + u32 orig_reg; 799 + 800 + /* Starting with the 7445d0, there are no longer separate 3.0 801 + * versions of IOC and IPP. 802 + */ 803 + if (USB_CTRL_MASK_FAMILY(params, USB30_CTL1, USB3_IOC)) { 804 + if (params->ioc) 805 + USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IOC); 806 + if (params->ipp == 1) 807 + USB_CTRL_SET_FAMILY(params, USB30_CTL1, USB3_IPP); 808 + } 809 + 810 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 811 + orig_reg = reg; 812 + if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_CC_DRD_MODE_ENABLE_SEL)) 813 + /* Never use the strap, it's going away. */ 814 + reg &= ~(USB_CTRL_MASK_FAMILY(params, 815 + SETUP, 816 + STRAP_CC_DRD_MODE_ENABLE_SEL)); 817 + if (USB_CTRL_MASK_FAMILY(params, SETUP, STRAP_IPP_SEL)) 818 + if (params->ipp != 2) 819 + /* override ipp strap pin (if it exits) */ 820 + reg &= ~(USB_CTRL_MASK_FAMILY(params, SETUP, 821 + STRAP_IPP_SEL)); 822 + 823 + /* Override the default OC and PP polarity */ 824 + reg &= ~(USB_CTRL_MASK(SETUP, IPP) | USB_CTRL_MASK(SETUP, IOC)); 825 + if (params->ioc) 826 + reg |= USB_CTRL_MASK(SETUP, IOC); 827 + if (params->ipp == 1 && ((reg & USB_CTRL_MASK(SETUP, IPP)) == 0)) 828 + reg |= USB_CTRL_MASK(SETUP, IPP); 829 + brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 830 + 831 + /* 832 + * If we're changing IPP, make sure power is off long enough 833 + * to turn off any connected devices. 834 + */ 835 + if (reg != orig_reg) 836 + msleep(50); 837 + } 838 + 839 + int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params) 840 + { 841 + void __iomem *ctrl = params->ctrl_regs; 842 + u32 reg = 0; 843 + 844 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 845 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 846 + reg &= USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 847 + PORT_MODE); 848 + } 849 + return reg; 850 + } 851 + 852 + void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, 853 + int mode) 854 + { 855 + void __iomem *ctrl = params->ctrl_regs; 856 + u32 reg; 857 + 858 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 859 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 860 + reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 861 + PORT_MODE); 862 + reg |= mode; 863 + brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 864 + } 865 + } 866 + 867 + void brcm_usb_init_common(struct brcm_usb_init_params *params) 868 + { 869 + u32 reg; 870 + void __iomem *ctrl = params->ctrl_regs; 871 + 872 + /* Take USB out of power down */ 873 + if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) { 874 + USB_CTRL_UNSET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); 875 + /* 1 millisecond - for USB clocks to settle down */ 876 + usleep_range(1000, 2000); 877 + } 878 + 879 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN)) { 880 + USB_CTRL_UNSET_FAMILY(params, USB_PM, USB_PWRDN); 881 + /* 1 millisecond - for USB clocks to settle down */ 882 + usleep_range(1000, 2000); 883 + } 884 + 885 + if (params->selected_family != BRCM_FAMILY_74371A0 && 886 + (BRCM_ID(params->family_id) != 0x7364)) 887 + /* 888 + * HW7439-637: 7439a0 and its derivatives do not have large 889 + * enough descriptor storage for this. 890 + */ 891 + USB_CTRL_SET_FAMILY(params, SETUP, SS_EHCI64BIT_EN); 892 + 893 + /* Block auto PLL suspend by USB2 PHY (Sasi) */ 894 + USB_CTRL_SET(ctrl, PLL_CTL, PLL_SUSPEND_EN); 895 + 896 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 897 + if (params->selected_family == BRCM_FAMILY_7364A0) 898 + /* Suppress overcurrent indication from USB30 ports for A0 */ 899 + reg |= USB_CTRL_MASK_FAMILY(params, SETUP, OC3_DISABLE); 900 + 901 + brcmusb_usb_phy_ldo_fix(ctrl); 902 + brcmusb_usb2_eye_fix(ctrl); 903 + 904 + /* 905 + * Make sure the the second and third memory controller 906 + * interfaces are enabled if they exist. 907 + */ 908 + if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN)) 909 + reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB1_EN); 910 + if (USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN)) 911 + reg |= USB_CTRL_MASK_FAMILY(params, SETUP, SCB2_EN); 912 + brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 913 + 914 + brcmusb_memc_fix(params); 915 + 916 + if (USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, PORT_MODE)) { 917 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 918 + reg &= ~USB_CTRL_MASK_FAMILY(params, USB_DEVICE_CTL1, 919 + PORT_MODE); 920 + reg |= params->mode; 921 + brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_DEVICE_CTL1)); 922 + } 923 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, BDC_SOFT_RESETB)) { 924 + switch (params->mode) { 925 + case USB_CTLR_MODE_HOST: 926 + USB_CTRL_UNSET_FAMILY(params, USB_PM, BDC_SOFT_RESETB); 927 + break; 928 + default: 929 + USB_CTRL_SET_FAMILY(params, USB_PM, BDC_SOFT_RESETB); 930 + break; 931 + } 932 + } 933 + if (USB_CTRL_MASK_FAMILY(params, SETUP, CC_DRD_MODE_ENABLE)) { 934 + if (params->mode == USB_CTLR_MODE_TYPEC_PD) 935 + USB_CTRL_SET_FAMILY(params, SETUP, CC_DRD_MODE_ENABLE); 936 + else 937 + USB_CTRL_UNSET_FAMILY(params, SETUP, 938 + CC_DRD_MODE_ENABLE); 939 + } 940 + } 941 + 942 + void brcm_usb_init_eohci(struct brcm_usb_init_params *params) 943 + { 944 + u32 reg; 945 + void __iomem *ctrl = params->ctrl_regs; 946 + 947 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB)) 948 + USB_CTRL_SET_FAMILY(params, USB_PM, USB20_HC_RESETB); 949 + 950 + if (params->selected_family == BRCM_FAMILY_7366C0) 951 + /* 952 + * Don't enable this so the memory controller doesn't read 953 + * into memory holes. NOTE: This bit is low true on 7366C0. 954 + */ 955 + USB_CTRL_SET_FAMILY(params, EBRIDGE, ESTOP_SCB_REQ); 956 + 957 + /* Setup the endian bits */ 958 + reg = brcmusb_readl(USB_CTRL_REG(ctrl, SETUP)); 959 + reg &= ~USB_CTRL_SETUP_ENDIAN_BITS; 960 + reg |= USB_CTRL_MASK_FAMILY(params, SETUP, ENDIAN); 961 + brcmusb_writel(reg, USB_CTRL_REG(ctrl, SETUP)); 962 + } 963 + 964 + void brcm_usb_init_xhci(struct brcm_usb_init_params *params) 965 + { 966 + void __iomem *ctrl = params->ctrl_regs; 967 + 968 + if (BRCM_ID(params->family_id) == 0x7366) { 969 + /* 970 + * The PHY3_SOFT_RESETB bits default to the wrong state. 971 + */ 972 + USB_CTRL_SET(ctrl, USB30_PCTL, PHY3_SOFT_RESETB); 973 + USB_CTRL_SET(ctrl, USB30_PCTL, PHY3_SOFT_RESETB_P1); 974 + } 975 + 976 + /* 977 + * Kick start USB3 PHY 978 + * Make sure it's low to insure a rising edge. 979 + */ 980 + USB_CTRL_UNSET(ctrl, USB30_CTL1, PHY3_PLL_SEQ_START); 981 + USB_CTRL_SET(ctrl, USB30_CTL1, PHY3_PLL_SEQ_START); 982 + 983 + brcmusb_usb3_phy_workarounds(params); 984 + brcmusb_xhci_soft_reset(params, 0); 985 + brcmusb_usb3_otp_fix(params); 986 + } 987 + 988 + void brcm_usb_uninit_common(struct brcm_usb_init_params *params) 989 + { 990 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB_PWRDN)) 991 + USB_CTRL_SET_FAMILY(params, USB_PM, USB_PWRDN); 992 + 993 + if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) 994 + USB_CTRL_SET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN); 995 + } 996 + 997 + void brcm_usb_uninit_eohci(struct brcm_usb_init_params *params) 998 + { 999 + if (USB_CTRL_MASK_FAMILY(params, USB_PM, USB20_HC_RESETB)) 1000 + USB_CTRL_UNSET_FAMILY(params, USB_PM, USB20_HC_RESETB); 1001 + } 1002 + 1003 + void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params) 1004 + { 1005 + brcmusb_xhci_soft_reset(params, 1); 1006 + } 1007 + 1008 + void brcm_usb_set_family_map(struct brcm_usb_init_params *params) 1009 + { 1010 + int fam; 1011 + 1012 + fam = brcmusb_get_family_type(params); 1013 + params->selected_family = fam; 1014 + params->usb_reg_bits_map = 1015 + &usb_reg_bits_map_table[fam][0]; 1016 + params->family_name = family_names[fam]; 1017 + }
+50
drivers/phy/broadcom/phy-brcm-usb-init.h
··· 1 + /* 2 + * Copyright (C) 2014-2017 Broadcom 3 + * 4 + * This software is licensed under the terms of the GNU General Public 5 + * License version 2, as published by the Free Software Foundation, and 6 + * may be copied, distributed, and modified under those terms. 7 + * 8 + * This program is distributed in the hope that it will be useful, 9 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 + * GNU General Public License for more details. 12 + */ 13 + 14 + #ifndef _USB_BRCM_COMMON_INIT_H 15 + #define _USB_BRCM_COMMON_INIT_H 16 + 17 + #define USB_CTLR_MODE_HOST 0 18 + #define USB_CTLR_MODE_DEVICE 1 19 + #define USB_CTLR_MODE_DRD 2 20 + #define USB_CTLR_MODE_TYPEC_PD 3 21 + 22 + struct brcm_usb_init_params; 23 + 24 + struct brcm_usb_init_params { 25 + void __iomem *ctrl_regs; 26 + void __iomem *xhci_ec_regs; 27 + int ioc; 28 + int ipp; 29 + int mode; 30 + u32 family_id; 31 + u32 product_id; 32 + int selected_family; 33 + const char *family_name; 34 + const u32 *usb_reg_bits_map; 35 + }; 36 + 37 + void brcm_usb_set_family_map(struct brcm_usb_init_params *params); 38 + int brcm_usb_init_get_dual_select(struct brcm_usb_init_params *params); 39 + void brcm_usb_init_set_dual_select(struct brcm_usb_init_params *params, 40 + int mode); 41 + 42 + void brcm_usb_init_ipp(struct brcm_usb_init_params *ini); 43 + void brcm_usb_init_common(struct brcm_usb_init_params *ini); 44 + void brcm_usb_init_eohci(struct brcm_usb_init_params *ini); 45 + void brcm_usb_init_xhci(struct brcm_usb_init_params *ini); 46 + void brcm_usb_uninit_common(struct brcm_usb_init_params *ini); 47 + void brcm_usb_uninit_eohci(struct brcm_usb_init_params *ini); 48 + void brcm_usb_uninit_xhci(struct brcm_usb_init_params *ini); 49 + 50 + #endif /* _USB_BRCM_COMMON_INIT_H */
+459
drivers/phy/broadcom/phy-brcm-usb.c
··· 1 + /* 2 + * phy-brcm-usb.c - Broadcom USB Phy Driver 3 + * 4 + * Copyright (C) 2015-2017 Broadcom 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + */ 15 + 16 + #include <linux/clk.h> 17 + #include <linux/delay.h> 18 + #include <linux/err.h> 19 + #include <linux/io.h> 20 + #include <linux/module.h> 21 + #include <linux/of.h> 22 + #include <linux/phy/phy.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/interrupt.h> 25 + #include <linux/soc/brcmstb/brcmstb.h> 26 + #include <dt-bindings/phy/phy.h> 27 + 28 + #include "phy-brcm-usb-init.h" 29 + 30 + static DEFINE_MUTEX(sysfs_lock); 31 + 32 + enum brcm_usb_phy_id { 33 + BRCM_USB_PHY_2_0 = 0, 34 + BRCM_USB_PHY_3_0, 35 + BRCM_USB_PHY_ID_MAX 36 + }; 37 + 38 + struct value_to_name_map { 39 + int value; 40 + const char *name; 41 + }; 42 + 43 + static struct value_to_name_map brcm_dr_mode_to_name[] = { 44 + { USB_CTLR_MODE_HOST, "host" }, 45 + { USB_CTLR_MODE_DEVICE, "peripheral" }, 46 + { USB_CTLR_MODE_DRD, "drd" }, 47 + { USB_CTLR_MODE_TYPEC_PD, "typec-pd" } 48 + }; 49 + 50 + static struct value_to_name_map brcm_dual_mode_to_name[] = { 51 + { 0, "host" }, 52 + { 1, "device" }, 53 + { 2, "auto" }, 54 + }; 55 + 56 + struct brcm_usb_phy { 57 + struct phy *phy; 58 + unsigned int id; 59 + bool inited; 60 + }; 61 + 62 + struct brcm_usb_phy_data { 63 + struct brcm_usb_init_params ini; 64 + bool has_eohci; 65 + bool has_xhci; 66 + struct clk *usb_20_clk; 67 + struct clk *usb_30_clk; 68 + struct mutex mutex; /* serialize phy init */ 69 + int init_count; 70 + struct brcm_usb_phy phys[BRCM_USB_PHY_ID_MAX]; 71 + }; 72 + 73 + static int brcm_usb_phy_init(struct phy *gphy) 74 + { 75 + struct brcm_usb_phy *phy = phy_get_drvdata(gphy); 76 + struct brcm_usb_phy_data *priv = 77 + container_of(phy, struct brcm_usb_phy_data, phys[phy->id]); 78 + 79 + /* 80 + * Use a lock to make sure a second caller waits until 81 + * the base phy is inited before using it. 82 + */ 83 + mutex_lock(&priv->mutex); 84 + if (priv->init_count++ == 0) { 85 + clk_enable(priv->usb_20_clk); 86 + clk_enable(priv->usb_30_clk); 87 + brcm_usb_init_common(&priv->ini); 88 + } 89 + mutex_unlock(&priv->mutex); 90 + if (phy->id == BRCM_USB_PHY_2_0) 91 + brcm_usb_init_eohci(&priv->ini); 92 + else if (phy->id == BRCM_USB_PHY_3_0) 93 + brcm_usb_init_xhci(&priv->ini); 94 + phy->inited = true; 95 + dev_dbg(&gphy->dev, "INIT, id: %d, total: %d\n", phy->id, 96 + priv->init_count); 97 + 98 + return 0; 99 + } 100 + 101 + static int brcm_usb_phy_exit(struct phy *gphy) 102 + { 103 + struct brcm_usb_phy *phy = phy_get_drvdata(gphy); 104 + struct brcm_usb_phy_data *priv = 105 + container_of(phy, struct brcm_usb_phy_data, phys[phy->id]); 106 + 107 + dev_dbg(&gphy->dev, "EXIT\n"); 108 + if (phy->id == BRCM_USB_PHY_2_0) 109 + brcm_usb_uninit_eohci(&priv->ini); 110 + if (phy->id == BRCM_USB_PHY_3_0) 111 + brcm_usb_uninit_xhci(&priv->ini); 112 + 113 + /* If both xhci and eohci are gone, reset everything else */ 114 + mutex_lock(&priv->mutex); 115 + if (--priv->init_count == 0) { 116 + brcm_usb_uninit_common(&priv->ini); 117 + clk_disable(priv->usb_20_clk); 118 + clk_disable(priv->usb_30_clk); 119 + } 120 + mutex_unlock(&priv->mutex); 121 + phy->inited = false; 122 + return 0; 123 + } 124 + 125 + static struct phy_ops brcm_usb_phy_ops = { 126 + .init = brcm_usb_phy_init, 127 + .exit = brcm_usb_phy_exit, 128 + .owner = THIS_MODULE, 129 + }; 130 + 131 + static struct phy *brcm_usb_phy_xlate(struct device *dev, 132 + struct of_phandle_args *args) 133 + { 134 + struct brcm_usb_phy_data *data = dev_get_drvdata(dev); 135 + 136 + /* 137 + * values 0 and 1 are for backward compatibility with 138 + * device tree nodes from older bootloaders. 139 + */ 140 + switch (args->args[0]) { 141 + case 0: 142 + case PHY_TYPE_USB2: 143 + if (data->phys[BRCM_USB_PHY_2_0].phy) 144 + return data->phys[BRCM_USB_PHY_2_0].phy; 145 + dev_warn(dev, "Error, 2.0 Phy not found\n"); 146 + break; 147 + case 1: 148 + case PHY_TYPE_USB3: 149 + if (data->phys[BRCM_USB_PHY_3_0].phy) 150 + return data->phys[BRCM_USB_PHY_3_0].phy; 151 + dev_warn(dev, "Error, 3.0 Phy not found\n"); 152 + break; 153 + } 154 + return ERR_PTR(-ENODEV); 155 + } 156 + 157 + static int name_to_value(struct value_to_name_map *table, int count, 158 + const char *name, int *value) 159 + { 160 + int x; 161 + 162 + *value = 0; 163 + for (x = 0; x < count; x++) { 164 + if (sysfs_streq(name, table[x].name)) { 165 + *value = x; 166 + return 0; 167 + } 168 + } 169 + return -EINVAL; 170 + } 171 + 172 + static const char *value_to_name(struct value_to_name_map *table, int count, 173 + int value) 174 + { 175 + if (value >= count) 176 + return "unknown"; 177 + return table[value].name; 178 + } 179 + 180 + static ssize_t dr_mode_show(struct device *dev, 181 + struct device_attribute *attr, 182 + char *buf) 183 + { 184 + struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 185 + 186 + return sprintf(buf, "%s\n", 187 + value_to_name(&brcm_dr_mode_to_name[0], 188 + ARRAY_SIZE(brcm_dr_mode_to_name), 189 + priv->ini.mode)); 190 + } 191 + static DEVICE_ATTR_RO(dr_mode); 192 + 193 + static ssize_t dual_select_store(struct device *dev, 194 + struct device_attribute *attr, 195 + const char *buf, size_t len) 196 + { 197 + struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 198 + int value; 199 + int res; 200 + 201 + mutex_lock(&sysfs_lock); 202 + res = name_to_value(&brcm_dual_mode_to_name[0], 203 + ARRAY_SIZE(brcm_dual_mode_to_name), buf, &value); 204 + if (!res) { 205 + brcm_usb_init_set_dual_select(&priv->ini, value); 206 + res = len; 207 + } 208 + mutex_unlock(&sysfs_lock); 209 + return res; 210 + } 211 + 212 + static ssize_t dual_select_show(struct device *dev, 213 + struct device_attribute *attr, 214 + char *buf) 215 + { 216 + struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 217 + int value; 218 + 219 + mutex_lock(&sysfs_lock); 220 + value = brcm_usb_init_get_dual_select(&priv->ini); 221 + mutex_unlock(&sysfs_lock); 222 + return sprintf(buf, "%s\n", 223 + value_to_name(&brcm_dual_mode_to_name[0], 224 + ARRAY_SIZE(brcm_dual_mode_to_name), 225 + value)); 226 + } 227 + static DEVICE_ATTR_RW(dual_select); 228 + 229 + static struct attribute *brcm_usb_phy_attrs[] = { 230 + &dev_attr_dr_mode.attr, 231 + &dev_attr_dual_select.attr, 232 + NULL 233 + }; 234 + 235 + static const struct attribute_group brcm_usb_phy_group = { 236 + .attrs = brcm_usb_phy_attrs, 237 + }; 238 + 239 + static int brcm_usb_phy_dvr_init(struct device *dev, 240 + struct brcm_usb_phy_data *priv, 241 + struct device_node *dn) 242 + { 243 + struct phy *gphy; 244 + int err; 245 + 246 + priv->usb_20_clk = of_clk_get_by_name(dn, "sw_usb"); 247 + if (IS_ERR(priv->usb_20_clk)) { 248 + dev_info(dev, "Clock not found in Device Tree\n"); 249 + priv->usb_20_clk = NULL; 250 + } 251 + err = clk_prepare_enable(priv->usb_20_clk); 252 + if (err) 253 + return err; 254 + 255 + if (priv->has_eohci) { 256 + gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops); 257 + if (IS_ERR(gphy)) { 258 + dev_err(dev, "failed to create EHCI/OHCI PHY\n"); 259 + return PTR_ERR(gphy); 260 + } 261 + priv->phys[BRCM_USB_PHY_2_0].phy = gphy; 262 + priv->phys[BRCM_USB_PHY_2_0].id = BRCM_USB_PHY_2_0; 263 + phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_2_0]); 264 + } 265 + 266 + if (priv->has_xhci) { 267 + gphy = devm_phy_create(dev, NULL, &brcm_usb_phy_ops); 268 + if (IS_ERR(gphy)) { 269 + dev_err(dev, "failed to create XHCI PHY\n"); 270 + return PTR_ERR(gphy); 271 + } 272 + priv->phys[BRCM_USB_PHY_3_0].phy = gphy; 273 + priv->phys[BRCM_USB_PHY_3_0].id = BRCM_USB_PHY_3_0; 274 + phy_set_drvdata(gphy, &priv->phys[BRCM_USB_PHY_3_0]); 275 + 276 + priv->usb_30_clk = of_clk_get_by_name(dn, "sw_usb3"); 277 + if (IS_ERR(priv->usb_30_clk)) { 278 + dev_info(dev, 279 + "USB3.0 clock not found in Device Tree\n"); 280 + priv->usb_30_clk = NULL; 281 + } 282 + err = clk_prepare_enable(priv->usb_30_clk); 283 + if (err) 284 + return err; 285 + } 286 + return 0; 287 + } 288 + 289 + static int brcm_usb_phy_probe(struct platform_device *pdev) 290 + { 291 + struct resource *res; 292 + struct device *dev = &pdev->dev; 293 + struct brcm_usb_phy_data *priv; 294 + struct phy_provider *phy_provider; 295 + struct device_node *dn = pdev->dev.of_node; 296 + int err; 297 + const char *mode; 298 + 299 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 300 + if (!priv) 301 + return -ENOMEM; 302 + platform_set_drvdata(pdev, priv); 303 + 304 + priv->ini.family_id = brcmstb_get_family_id(); 305 + priv->ini.product_id = brcmstb_get_product_id(); 306 + brcm_usb_set_family_map(&priv->ini); 307 + dev_dbg(dev, "Best mapping table is for %s\n", 308 + priv->ini.family_name); 309 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 310 + if (!res) { 311 + dev_err(dev, "can't get USB_CTRL base address\n"); 312 + return -EINVAL; 313 + } 314 + priv->ini.ctrl_regs = devm_ioremap_resource(dev, res); 315 + if (IS_ERR(priv->ini.ctrl_regs)) { 316 + dev_err(dev, "can't map CTRL register space\n"); 317 + return -EINVAL; 318 + } 319 + 320 + /* The XHCI EC registers are optional */ 321 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 322 + if (res) { 323 + priv->ini.xhci_ec_regs = 324 + devm_ioremap_resource(dev, res); 325 + if (IS_ERR(priv->ini.xhci_ec_regs)) { 326 + dev_err(dev, "can't map XHCI EC register space\n"); 327 + return -EINVAL; 328 + } 329 + } 330 + 331 + of_property_read_u32(dn, "brcm,ipp", &priv->ini.ipp); 332 + of_property_read_u32(dn, "brcm,ioc", &priv->ini.ioc); 333 + 334 + priv->ini.mode = USB_CTLR_MODE_HOST; 335 + err = of_property_read_string(dn, "dr_mode", &mode); 336 + if (err == 0) { 337 + name_to_value(&brcm_dr_mode_to_name[0], 338 + ARRAY_SIZE(brcm_dr_mode_to_name), 339 + mode, &priv->ini.mode); 340 + } 341 + if (of_property_read_bool(dn, "brcm,has_xhci")) 342 + priv->has_xhci = true; 343 + if (of_property_read_bool(dn, "brcm,has_eohci")) 344 + priv->has_eohci = true; 345 + 346 + err = brcm_usb_phy_dvr_init(dev, priv, dn); 347 + if (err) 348 + return err; 349 + 350 + mutex_init(&priv->mutex); 351 + 352 + /* make sure invert settings are correct */ 353 + brcm_usb_init_ipp(&priv->ini); 354 + 355 + /* 356 + * Create sysfs entries for mode. 357 + * Remove "dual_select" attribute if not in dual mode 358 + */ 359 + if (priv->ini.mode != USB_CTLR_MODE_DRD) 360 + brcm_usb_phy_attrs[1] = NULL; 361 + err = sysfs_create_group(&dev->kobj, &brcm_usb_phy_group); 362 + if (err) 363 + dev_warn(dev, "Error creating sysfs attributes\n"); 364 + 365 + /* start with everything off */ 366 + if (priv->has_xhci) 367 + brcm_usb_uninit_xhci(&priv->ini); 368 + if (priv->has_eohci) 369 + brcm_usb_uninit_eohci(&priv->ini); 370 + brcm_usb_uninit_common(&priv->ini); 371 + clk_disable(priv->usb_20_clk); 372 + clk_disable(priv->usb_30_clk); 373 + 374 + phy_provider = devm_of_phy_provider_register(dev, brcm_usb_phy_xlate); 375 + if (IS_ERR(phy_provider)) 376 + return PTR_ERR(phy_provider); 377 + 378 + return 0; 379 + } 380 + 381 + #ifdef CONFIG_PM_SLEEP 382 + static int brcm_usb_phy_suspend(struct device *dev) 383 + { 384 + struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 385 + 386 + if (priv->init_count) { 387 + clk_disable(priv->usb_20_clk); 388 + clk_disable(priv->usb_30_clk); 389 + } 390 + return 0; 391 + } 392 + 393 + static int brcm_usb_phy_resume(struct device *dev) 394 + { 395 + struct brcm_usb_phy_data *priv = dev_get_drvdata(dev); 396 + 397 + clk_enable(priv->usb_20_clk); 398 + clk_enable(priv->usb_30_clk); 399 + brcm_usb_init_ipp(&priv->ini); 400 + 401 + /* 402 + * Initialize anything that was previously initialized. 403 + * Uninitialize anything that wasn't previously initialized. 404 + */ 405 + if (priv->init_count) { 406 + brcm_usb_init_common(&priv->ini); 407 + if (priv->phys[BRCM_USB_PHY_2_0].inited) { 408 + brcm_usb_init_eohci(&priv->ini); 409 + } else if (priv->has_eohci) { 410 + brcm_usb_uninit_eohci(&priv->ini); 411 + clk_disable(priv->usb_20_clk); 412 + } 413 + if (priv->phys[BRCM_USB_PHY_3_0].inited) { 414 + brcm_usb_init_xhci(&priv->ini); 415 + } else if (priv->has_xhci) { 416 + brcm_usb_uninit_xhci(&priv->ini); 417 + clk_disable(priv->usb_30_clk); 418 + } 419 + } else { 420 + if (priv->has_xhci) 421 + brcm_usb_uninit_xhci(&priv->ini); 422 + if (priv->has_eohci) 423 + brcm_usb_uninit_eohci(&priv->ini); 424 + brcm_usb_uninit_common(&priv->ini); 425 + clk_disable(priv->usb_20_clk); 426 + clk_disable(priv->usb_30_clk); 427 + } 428 + 429 + return 0; 430 + } 431 + #endif /* CONFIG_PM_SLEEP */ 432 + 433 + static const struct dev_pm_ops brcm_usb_phy_pm_ops = { 434 + SET_LATE_SYSTEM_SLEEP_PM_OPS(brcm_usb_phy_suspend, brcm_usb_phy_resume) 435 + }; 436 + 437 + static const struct of_device_id brcm_usb_dt_ids[] = { 438 + { .compatible = "brcm,brcmstb-usb-phy" }, 439 + { /* sentinel */ } 440 + }; 441 + 442 + MODULE_DEVICE_TABLE(of, brcm_usb_dt_ids); 443 + 444 + static struct platform_driver brcm_usb_driver = { 445 + .probe = brcm_usb_phy_probe, 446 + .driver = { 447 + .name = "brcmstb-usb-phy", 448 + .owner = THIS_MODULE, 449 + .pm = &brcm_usb_phy_pm_ops, 450 + .of_match_table = brcm_usb_dt_ids, 451 + }, 452 + }; 453 + 454 + module_platform_driver(brcm_usb_driver); 455 + 456 + MODULE_ALIAS("platform:brcmstb-usb-phy"); 457 + MODULE_AUTHOR("Al Cooper <acooper@broadcom.com>"); 458 + MODULE_DESCRIPTION("BRCM USB PHY driver"); 459 + MODULE_LICENSE("GPL v2");
-1
drivers/phy/marvell/phy-mvebu-cp110-comphy.c
··· 154 154 void __iomem *base; 155 155 struct regmap *regmap; 156 156 struct device *dev; 157 - int modes[MVEBU_COMPHY_LANES]; 158 157 }; 159 158 160 159 struct mvebu_comphy_lane {
+39
drivers/phy/mediatek/phy-mtk-tphy.c
··· 96 96 97 97 #define U3P_U2PHYDTM1 0x06C 98 98 #define P2C_RG_UART_EN BIT(16) 99 + #define P2C_FORCE_IDDIG BIT(9) 99 100 #define P2C_RG_VBUSVALID BIT(5) 100 101 #define P2C_RG_SESSEND BIT(4) 101 102 #define P2C_RG_AVALID BIT(2) 103 + #define P2C_RG_IDDIG BIT(1) 102 104 103 105 #define U3P_U3_CHIP_GPIO_CTLD 0x0c 104 106 #define P3C_REG_IP_SW_RST BIT(31) ··· 587 585 } 588 586 } 589 587 588 + static void u2_phy_instance_set_mode(struct mtk_tphy *tphy, 589 + struct mtk_phy_instance *instance, 590 + enum phy_mode mode) 591 + { 592 + struct u2phy_banks *u2_banks = &instance->u2_banks; 593 + u32 tmp; 594 + 595 + tmp = readl(u2_banks->com + U3P_U2PHYDTM1); 596 + switch (mode) { 597 + case PHY_MODE_USB_DEVICE: 598 + tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG; 599 + break; 600 + case PHY_MODE_USB_HOST: 601 + tmp |= P2C_FORCE_IDDIG; 602 + tmp &= ~P2C_RG_IDDIG; 603 + break; 604 + case PHY_MODE_USB_OTG: 605 + tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG); 606 + break; 607 + default: 608 + return; 609 + } 610 + writel(tmp, u2_banks->com + U3P_U2PHYDTM1); 611 + } 612 + 590 613 static void pcie_phy_instance_init(struct mtk_tphy *tphy, 591 614 struct mtk_phy_instance *instance) 592 615 { ··· 908 881 return 0; 909 882 } 910 883 884 + static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode) 885 + { 886 + struct mtk_phy_instance *instance = phy_get_drvdata(phy); 887 + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); 888 + 889 + if (instance->type == PHY_TYPE_USB2) 890 + u2_phy_instance_set_mode(tphy, instance, mode); 891 + 892 + return 0; 893 + } 894 + 911 895 static struct phy *mtk_phy_xlate(struct device *dev, 912 896 struct of_phandle_args *args) 913 897 { ··· 969 931 .exit = mtk_phy_exit, 970 932 .power_on = mtk_phy_power_on, 971 933 .power_off = mtk_phy_power_off, 934 + .set_mode = mtk_phy_set_mode, 972 935 .owner = THIS_MODULE, 973 936 }; 974 937
+15
drivers/phy/phy-core.c
··· 372 372 } 373 373 EXPORT_SYMBOL_GPL(phy_reset); 374 374 375 + int phy_calibrate(struct phy *phy) 376 + { 377 + int ret; 378 + 379 + if (!phy || !phy->ops->calibrate) 380 + return 0; 381 + 382 + mutex_lock(&phy->mutex); 383 + ret = phy->ops->calibrate(phy); 384 + mutex_unlock(&phy->mutex); 385 + 386 + return ret; 387 + } 388 + EXPORT_SYMBOL_GPL(phy_calibrate); 389 + 375 390 /** 376 391 * _of_phy_get() - lookup and obtain a reference to a phy by phandle 377 392 * @np: device_node for which to get the phy
+3 -2
drivers/phy/qualcomm/phy-qcom-ufs-i.h
··· 114 114 struct ufs_qcom_phy_calibration *cached_regs; 115 115 int cached_regs_table_size; 116 116 bool is_powered_on; 117 + bool is_started; 117 118 struct ufs_qcom_phy_specific_ops *phy_spec_ops; 119 + 120 + enum phy_mode mode; 118 121 }; 119 122 120 123 /** 121 124 * struct ufs_qcom_phy_specific_ops - set of pointers to functions which have a 122 125 * specific implementation per phy. Each UFS phy, should implement 123 126 * those functions according to its spec and requirements 124 - * @calibrate_phy: pointer to a function that calibrate the phy 125 127 * @start_serdes: pointer to a function that starts the serdes 126 128 * @is_physical_coding_sublayer_ready: pointer to a function that 127 129 * checks pcs readiness. returns 0 for success and non-zero for error. ··· 132 130 * and writes to QSERDES_RX_SIGDET_CNTRL attribute 133 131 */ 134 132 struct ufs_qcom_phy_specific_ops { 135 - int (*calibrate_phy)(struct ufs_qcom_phy *phy, bool is_rate_B); 136 133 void (*start_serdes)(struct ufs_qcom_phy *phy); 137 134 int (*is_physical_coding_sublayer_ready)(struct ufs_qcom_phy *phy); 138 135 void (*set_tx_lane_enable)(struct ufs_qcom_phy *phy, u32 val);
+27 -2
drivers/phy/qualcomm/phy-qcom-ufs-qmp-14nm.c
··· 44 44 45 45 static int ufs_qcom_phy_qmp_14nm_init(struct phy *generic_phy) 46 46 { 47 - return 0; 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; 48 60 } 49 61 50 62 static int ufs_qcom_phy_qmp_14nm_exit(struct phy *generic_phy) 51 63 { 64 + return 0; 65 + } 66 + 67 + static 68 + int ufs_qcom_phy_qmp_14nm_set_mode(struct phy *generic_phy, enum phy_mode mode) 69 + { 70 + struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy); 71 + 72 + phy_common->mode = PHY_MODE_INVALID; 73 + 74 + if (mode > 0) 75 + phy_common->mode = mode; 76 + 52 77 return 0; 53 78 } 54 79 ··· 127 102 .exit = ufs_qcom_phy_qmp_14nm_exit, 128 103 .power_on = ufs_qcom_phy_power_on, 129 104 .power_off = ufs_qcom_phy_power_off, 105 + .set_mode = ufs_qcom_phy_qmp_14nm_set_mode, 130 106 .owner = THIS_MODULE, 131 107 }; 132 108 133 109 static struct ufs_qcom_phy_specific_ops phy_14nm_ops = { 134 - .calibrate_phy = ufs_qcom_phy_qmp_14nm_phy_calibrate, 135 110 .start_serdes = ufs_qcom_phy_qmp_14nm_start_serdes, 136 111 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_14nm_is_pcs_ready, 137 112 .set_tx_lane_enable = ufs_qcom_phy_qmp_14nm_set_tx_lane_enable,
+27 -2
drivers/phy/qualcomm/phy-qcom-ufs-qmp-20nm.c
··· 63 63 64 64 static int ufs_qcom_phy_qmp_20nm_init(struct phy *generic_phy) 65 65 { 66 - return 0; 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; 67 79 } 68 80 69 81 static int ufs_qcom_phy_qmp_20nm_exit(struct phy *generic_phy) 70 82 { 83 + return 0; 84 + } 85 + 86 + static 87 + int ufs_qcom_phy_qmp_20nm_set_mode(struct phy *generic_phy, enum phy_mode mode) 88 + { 89 + struct ufs_qcom_phy *phy_common = get_ufs_qcom_phy(generic_phy); 90 + 91 + phy_common->mode = PHY_MODE_INVALID; 92 + 93 + if (mode > 0) 94 + phy_common->mode = mode; 95 + 71 96 return 0; 72 97 } 73 98 ··· 185 160 .exit = ufs_qcom_phy_qmp_20nm_exit, 186 161 .power_on = ufs_qcom_phy_power_on, 187 162 .power_off = ufs_qcom_phy_power_off, 163 + .set_mode = ufs_qcom_phy_qmp_20nm_set_mode, 188 164 .owner = THIS_MODULE, 189 165 }; 190 166 191 167 static struct ufs_qcom_phy_specific_ops phy_20nm_ops = { 192 - .calibrate_phy = ufs_qcom_phy_qmp_20nm_phy_calibrate, 193 168 .start_serdes = ufs_qcom_phy_qmp_20nm_start_serdes, 194 169 .is_physical_coding_sublayer_ready = ufs_qcom_phy_qmp_20nm_is_pcs_ready, 195 170 .set_tx_lane_enable = ufs_qcom_phy_qmp_20nm_set_tx_lane_enable,
+14 -28
drivers/phy/qualcomm/phy-qcom-ufs.c
··· 518 518 } 519 519 } 520 520 521 - int ufs_qcom_phy_start_serdes(struct phy *generic_phy) 521 + static int ufs_qcom_phy_start_serdes(struct ufs_qcom_phy *ufs_qcom_phy) 522 522 { 523 - struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy); 524 523 int ret = 0; 525 524 526 525 if (!ufs_qcom_phy->phy_spec_ops->start_serdes) { ··· 532 533 533 534 return ret; 534 535 } 535 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_start_serdes); 536 536 537 537 int ufs_qcom_phy_set_tx_lane_enable(struct phy *generic_phy, u32 tx_lanes) 538 538 { ··· 562 564 } 563 565 EXPORT_SYMBOL_GPL(ufs_qcom_phy_save_controller_version); 564 566 565 - int ufs_qcom_phy_calibrate_phy(struct phy *generic_phy, bool is_rate_B) 567 + static int ufs_qcom_phy_is_pcs_ready(struct ufs_qcom_phy *ufs_qcom_phy) 566 568 { 567 - struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy); 568 - int ret = 0; 569 - 570 - if (!ufs_qcom_phy->phy_spec_ops->calibrate_phy) { 571 - dev_err(ufs_qcom_phy->dev, "%s: calibrate_phy() callback is not supported\n", 572 - __func__); 573 - ret = -ENOTSUPP; 574 - } else { 575 - ret = ufs_qcom_phy->phy_spec_ops-> 576 - calibrate_phy(ufs_qcom_phy, is_rate_B); 577 - if (ret) 578 - dev_err(ufs_qcom_phy->dev, "%s: calibrate_phy() failed %d\n", 579 - __func__, ret); 580 - } 581 - 582 - return ret; 583 - } 584 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_calibrate_phy); 585 - 586 - int ufs_qcom_phy_is_pcs_ready(struct phy *generic_phy) 587 - { 588 - struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(generic_phy); 589 - 590 569 if (!ufs_qcom_phy->phy_spec_ops->is_physical_coding_sublayer_ready) { 591 570 dev_err(ufs_qcom_phy->dev, "%s: is_physical_coding_sublayer_ready() callback is not supported\n", 592 571 __func__); ··· 573 598 return ufs_qcom_phy->phy_spec_ops-> 574 599 is_physical_coding_sublayer_ready(ufs_qcom_phy); 575 600 } 576 - EXPORT_SYMBOL_GPL(ufs_qcom_phy_is_pcs_ready); 577 601 578 602 int ufs_qcom_phy_power_on(struct phy *generic_phy) 579 603 { ··· 582 608 583 609 if (phy_common->is_powered_on) 584 610 return 0; 611 + 612 + if (!phy_common->is_started) { 613 + err = ufs_qcom_phy_start_serdes(phy_common); 614 + if (err) 615 + return err; 616 + 617 + err = ufs_qcom_phy_is_pcs_ready(phy_common); 618 + if (err) 619 + return err; 620 + 621 + phy_common->is_started = true; 622 + } 585 623 586 624 err = ufs_qcom_phy_enable_vreg(dev, &phy_common->vdda_phy); 587 625 if (err) {
+46 -24
drivers/phy/renesas/phy-rcar-gen3-usb2.c
··· 1 1 /* 2 2 * Renesas R-Car Gen3 for USB2.0 PHY driver 3 3 * 4 - * Copyright (C) 2015 Renesas Electronics Corporation 4 + * Copyright (C) 2015-2017 Renesas Electronics Corporation 5 5 * 6 6 * This is based on the phy-rcar-gen2 driver: 7 7 * Copyright (C) 2014 Renesas Solutions Corp. ··· 18 18 #include <linux/module.h> 19 19 #include <linux/of.h> 20 20 #include <linux/of_address.h> 21 + #include <linux/of_device.h> 21 22 #include <linux/phy/phy.h> 22 23 #include <linux/platform_device.h> 23 24 #include <linux/pm_runtime.h> 24 25 #include <linux/regulator/consumer.h> 26 + #include <linux/usb/of.h> 25 27 #include <linux/workqueue.h> 26 28 27 29 /******* USB2.0 Host registers (original offset is +0x200) *******/ ··· 81 79 #define USB2_ADPCTRL_IDPULLUP BIT(5) /* 1 = ID sampling is enabled */ 82 80 #define USB2_ADPCTRL_DRVVBUS BIT(4) 83 81 82 + #define RCAR_GEN3_PHY_HAS_DEDICATED_PINS 1 83 + 84 84 struct rcar_gen3_chan { 85 85 void __iomem *base; 86 86 struct extcon_dev *extcon; ··· 90 86 struct regulator *vbus; 91 87 struct work_struct work; 92 88 bool extcon_host; 93 - bool has_otg; 89 + bool has_otg_pins; 94 90 }; 95 91 96 92 static void rcar_gen3_phy_usb2_work(struct work_struct *work) ··· 222 218 return !(readl(ch->base + USB2_COMMCTRL) & USB2_COMMCTRL_OTG_PERI); 223 219 } 224 220 221 + static enum phy_mode rcar_gen3_get_phy_mode(struct rcar_gen3_chan *ch) 222 + { 223 + if (rcar_gen3_is_host(ch)) 224 + return PHY_MODE_USB_HOST; 225 + 226 + return PHY_MODE_USB_DEVICE; 227 + } 228 + 225 229 static ssize_t role_store(struct device *dev, struct device_attribute *attr, 226 230 const char *buf, size_t count) 227 231 { 228 232 struct rcar_gen3_chan *ch = dev_get_drvdata(dev); 229 - bool is_b_device, is_host, new_mode_is_host; 233 + bool is_b_device; 234 + enum phy_mode cur_mode, new_mode; 230 235 231 - if (!ch->has_otg || !ch->phy->init_count) 236 + if (!ch->has_otg_pins || !ch->phy->init_count) 232 237 return -EIO; 233 238 234 - /* 235 - * is_b_device: true is B-Device. false is A-Device. 236 - * If {new_mode_}is_host: true is Host mode. false is Peripheral mode. 237 - */ 238 - is_b_device = rcar_gen3_check_id(ch); 239 - is_host = rcar_gen3_is_host(ch); 240 239 if (!strncmp(buf, "host", strlen("host"))) 241 - new_mode_is_host = true; 240 + new_mode = PHY_MODE_USB_HOST; 242 241 else if (!strncmp(buf, "peripheral", strlen("peripheral"))) 243 - new_mode_is_host = false; 242 + new_mode = PHY_MODE_USB_DEVICE; 244 243 else 245 244 return -EINVAL; 246 245 246 + /* is_b_device: true is B-Device. false is A-Device. */ 247 + is_b_device = rcar_gen3_check_id(ch); 248 + cur_mode = rcar_gen3_get_phy_mode(ch); 249 + 247 250 /* If current and new mode is the same, this returns the error */ 248 - if (is_host == new_mode_is_host) 251 + if (cur_mode == new_mode) 249 252 return -EINVAL; 250 253 251 - if (new_mode_is_host) { /* And is_host must be false */ 254 + if (new_mode == PHY_MODE_USB_HOST) { /* And is_host must be false */ 252 255 if (!is_b_device) /* A-Peripheral */ 253 256 rcar_gen3_init_from_a_peri_to_a_host(ch); 254 257 else /* B-Peripheral */ ··· 275 264 { 276 265 struct rcar_gen3_chan *ch = dev_get_drvdata(dev); 277 266 278 - if (!ch->has_otg || !ch->phy->init_count) 267 + if (!ch->has_otg_pins || !ch->phy->init_count) 279 268 return -EIO; 280 269 281 270 return sprintf(buf, "%s\n", rcar_gen3_is_host(ch) ? "host" : ··· 314 303 writel(USB2_OC_TIMSET_INIT, usb2_base + USB2_OC_TIMSET); 315 304 316 305 /* Initialize otg part */ 317 - if (channel->has_otg) 306 + if (channel->has_otg_pins) 318 307 rcar_gen3_init_otg(channel); 319 308 320 309 return 0; ··· 388 377 } 389 378 390 379 static const struct of_device_id rcar_gen3_phy_usb2_match_table[] = { 391 - { .compatible = "renesas,usb2-phy-r8a7795" }, 392 - { .compatible = "renesas,usb2-phy-r8a7796" }, 393 - { .compatible = "renesas,rcar-gen3-usb2-phy" }, 380 + { 381 + .compatible = "renesas,usb2-phy-r8a7795", 382 + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS, 383 + }, 384 + { 385 + .compatible = "renesas,usb2-phy-r8a7796", 386 + .data = (void *)RCAR_GEN3_PHY_HAS_DEDICATED_PINS, 387 + }, 388 + { 389 + .compatible = "renesas,rcar-gen3-usb2-phy", 390 + }, 394 391 { } 395 392 }; 396 393 MODULE_DEVICE_TABLE(of, rcar_gen3_phy_usb2_match_table); ··· 434 415 /* call request_irq for OTG */ 435 416 irq = platform_get_irq(pdev, 0); 436 417 if (irq >= 0) { 437 - int ret; 438 - 439 418 INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work); 440 419 irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq, 441 420 IRQF_SHARED, dev_name(dev), channel); 442 421 if (irq < 0) 443 422 dev_err(dev, "No irq handler (%d)\n", irq); 444 - channel->has_otg = true; 423 + } 424 + 425 + if (of_usb_get_dr_mode_by_phy(dev->of_node, 0) == USB_DR_MODE_OTG) { 426 + int ret; 427 + 428 + channel->has_otg_pins = (uintptr_t)of_device_get_match_data(dev); 445 429 channel->extcon = devm_extcon_dev_allocate(dev, 446 430 rcar_gen3_phy_cable); 447 431 if (IS_ERR(channel->extcon)) ··· 486 464 dev_err(dev, "Failed to register PHY provider\n"); 487 465 ret = PTR_ERR(provider); 488 466 goto error; 489 - } else if (channel->has_otg) { 467 + } else if (channel->has_otg_pins) { 490 468 int ret; 491 469 492 470 ret = device_create_file(dev, &dev_attr_role); ··· 506 484 { 507 485 struct rcar_gen3_chan *channel = platform_get_drvdata(pdev); 508 486 509 - if (channel->has_otg) 487 + if (channel->has_otg_pins) 510 488 device_remove_file(&pdev->dev, &dev_attr_role); 511 489 512 490 pm_runtime_disable(&pdev->dev);
+175 -42
drivers/phy/rockchip/phy-rockchip-typec.c
··· 102 102 #define CMN_PLL1_SS_CTRL1 (0xb8 << 2) 103 103 #define CMN_PLL1_SS_CTRL2 (0xb9 << 2) 104 104 #define CMN_RXCAL_OVRD (0xd1 << 2) 105 + 105 106 #define CMN_TXPUCAL_CTRL (0xe0 << 2) 106 107 #define CMN_TXPUCAL_OVRD (0xe1 << 2) 108 + #define CMN_TXPDCAL_CTRL (0xf0 << 2) 107 109 #define CMN_TXPDCAL_OVRD (0xf1 << 2) 110 + 111 + /* For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL */ 112 + #define CMN_TXPXCAL_START BIT(15) 113 + #define CMN_TXPXCAL_DONE BIT(14) 114 + #define CMN_TXPXCAL_NO_RESPONSE BIT(13) 115 + #define CMN_TXPXCAL_CURRENT_RESPONSE BIT(12) 116 + 117 + #define CMN_TXPU_ADJ_CTRL (0x108 << 2) 118 + #define CMN_TXPD_ADJ_CTRL (0x10c << 2) 119 + 120 + /* 121 + * For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL, 122 + * CMN_TXPU_ADJ_CTRL, CMN_TXPDCAL_CTRL 123 + * 124 + * NOTE: some of these registers are documented to be 2's complement 125 + * signed numbers, but then documented to be always positive. Weird. 126 + * In such a case, using CMN_CALIB_CODE_POS() avoids the unnecessary 127 + * sign extension. 128 + */ 129 + #define CMN_CALIB_CODE_WIDTH 7 130 + #define CMN_CALIB_CODE_OFFSET 0 131 + #define CMN_CALIB_CODE_MASK GENMASK(CMN_CALIB_CODE_WIDTH, 0) 132 + #define CMN_CALIB_CODE(x) \ 133 + sign_extend32((x) >> CMN_CALIB_CODE_OFFSET, CMN_CALIB_CODE_WIDTH) 134 + 135 + #define CMN_CALIB_CODE_POS_MASK GENMASK(CMN_CALIB_CODE_WIDTH - 1, 0) 136 + #define CMN_CALIB_CODE_POS(x) \ 137 + (((x) >> CMN_CALIB_CODE_OFFSET) & CMN_CALIB_CODE_POS_MASK) 138 + 108 139 #define CMN_DIAG_PLL0_FBH_OVRD (0x1c0 << 2) 109 140 #define CMN_DIAG_PLL0_FBL_OVRD (0x1c1 << 2) 110 141 #define CMN_DIAG_PLL0_OVRD (0x1c2 << 2) ··· 169 138 #define TX_TXCC_MGNFS_MULT_101(n) ((0x4055 | ((n) << 9)) << 2) 170 139 #define TX_TXCC_MGNFS_MULT_110(n) ((0x4056 | ((n) << 9)) << 2) 171 140 #define TX_TXCC_MGNFS_MULT_111(n) ((0x4057 | ((n) << 9)) << 2) 141 + #define TX_TXCC_MGNLS_MULT_000(n) ((0x4058 | ((n) << 9)) << 2) 142 + #define TX_TXCC_MGNLS_MULT_001(n) ((0x4059 | ((n) << 9)) << 2) 143 + #define TX_TXCC_MGNLS_MULT_010(n) ((0x405a | ((n) << 9)) << 2) 144 + #define TX_TXCC_MGNLS_MULT_011(n) ((0x405b | ((n) << 9)) << 2) 145 + #define TX_TXCC_MGNLS_MULT_100(n) ((0x405c | ((n) << 9)) << 2) 146 + #define TX_TXCC_MGNLS_MULT_101(n) ((0x405d | ((n) << 9)) << 2) 147 + #define TX_TXCC_MGNLS_MULT_110(n) ((0x405e | ((n) << 9)) << 2) 148 + #define TX_TXCC_MGNLS_MULT_111(n) ((0x405f | ((n) << 9)) << 2) 149 + 172 150 #define XCVR_DIAG_PLLDRC_CTRL(n) ((0x40e0 | ((n) << 9)) << 2) 173 151 #define XCVR_DIAG_BIDI_CTRL(n) ((0x40e8 | ((n) << 9)) << 2) 174 152 #define XCVR_DIAG_LANE_FCM_EN_MGN(n) ((0x40f2 | ((n) << 9)) << 2) ··· 190 150 #define TX_RCVDET_ST_TMR(n) ((0x4123 | ((n) << 9)) << 2) 191 151 #define TX_DIAG_TX_DRV(n) ((0x41e1 | ((n) << 9)) << 2) 192 152 #define TX_DIAG_BGREF_PREDRV_DELAY (0x41e7 << 2) 153 + 154 + /* Use this for "n" in macros like "_MULT_XXX" to target the aux channel */ 155 + #define AUX_CH_LANE 8 156 + 193 157 #define TX_ANA_CTRL_REG_1 (0x5020 << 2) 158 + 159 + #define TXDA_DP_AUX_EN BIT(15) 160 + #define AUXDA_SE_EN BIT(14) 161 + #define TXDA_CAL_LATCH_EN BIT(13) 162 + #define AUXDA_POLARITY BIT(12) 163 + #define TXDA_DRV_POWER_ISOLATION_EN BIT(11) 164 + #define TXDA_DRV_POWER_EN_PH_2_N BIT(10) 165 + #define TXDA_DRV_POWER_EN_PH_1_N BIT(9) 166 + #define TXDA_BGREF_EN BIT(8) 167 + #define TXDA_DRV_LDO_EN BIT(7) 168 + #define TXDA_DECAP_EN_DEL BIT(6) 169 + #define TXDA_DECAP_EN BIT(5) 170 + #define TXDA_UPHY_SUPPLY_EN_DEL BIT(4) 171 + #define TXDA_UPHY_SUPPLY_EN BIT(3) 172 + #define TXDA_LOW_LEAKAGE_EN BIT(2) 173 + #define TXDA_DRV_IDLE_LOWI_EN BIT(1) 174 + #define TXDA_DRV_CMN_MODE_EN BIT(0) 175 + 194 176 #define TX_ANA_CTRL_REG_2 (0x5021 << 2) 177 + 178 + #define AUXDA_DEBOUNCING_CLK BIT(15) 179 + #define TXDA_LPBK_RECOVERED_CLK_EN BIT(14) 180 + #define TXDA_LPBK_ISI_GEN_EN BIT(13) 181 + #define TXDA_LPBK_SERIAL_EN BIT(12) 182 + #define TXDA_LPBK_LINE_EN BIT(11) 183 + #define TXDA_DRV_LDO_REDC_SINKIQ BIT(10) 184 + #define XCVR_DECAP_EN_DEL BIT(9) 185 + #define XCVR_DECAP_EN BIT(8) 186 + #define TXDA_MPHY_ENABLE_HS_NT BIT(7) 187 + #define TXDA_MPHY_SA_MODE BIT(6) 188 + #define TXDA_DRV_LDO_RBYR_FB_EN BIT(5) 189 + #define TXDA_DRV_RST_PULL_DOWN BIT(4) 190 + #define TXDA_DRV_LDO_BG_FB_EN BIT(3) 191 + #define TXDA_DRV_LDO_BG_REF_EN BIT(2) 192 + #define TXDA_DRV_PREDRV_EN_DEL BIT(1) 193 + #define TXDA_DRV_PREDRV_EN BIT(0) 194 + 195 195 #define TXDA_COEFF_CALC_CTRL (0x5022 << 2) 196 + 197 + #define TX_HIGH_Z BIT(6) 198 + #define TX_VMARGIN_OFFSET 3 199 + #define TX_VMARGIN_MASK 0x7 200 + #define LOW_POWER_SWING_EN BIT(2) 201 + #define TX_FCM_DRV_MAIN_EN BIT(1) 202 + #define TX_FCM_FULL_MARGIN BIT(0) 203 + 196 204 #define TX_DIG_CTRL_REG_2 (0x5024 << 2) 205 + 206 + #define TX_HIGH_Z_TM_EN BIT(15) 207 + #define TX_RESCAL_CODE_OFFSET 0 208 + #define TX_RESCAL_CODE_MASK 0x3f 209 + 197 210 #define TXDA_CYA_AUXDA_CYA (0x5025 << 2) 198 211 #define TX_ANA_CTRL_REG_3 (0x5026 << 2) 199 212 #define TX_ANA_CTRL_REG_4 (0x5027 << 2) ··· 549 456 */ 550 457 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1); 551 458 if (!tcphy->flip) 552 - tx_ana_ctrl_reg_1 |= BIT(12); 459 + tx_ana_ctrl_reg_1 |= AUXDA_POLARITY; 553 460 else 554 - tx_ana_ctrl_reg_1 &= ~BIT(12); 461 + tx_ana_ctrl_reg_1 &= ~AUXDA_POLARITY; 555 462 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 556 463 } 557 464 558 465 static void tcphy_dp_aux_calibration(struct rockchip_typec_phy *tcphy) 559 466 { 467 + u16 val; 560 468 u16 tx_ana_ctrl_reg_1; 561 - u16 rdata, rdata2, val; 469 + u16 tx_ana_ctrl_reg_2; 470 + s32 pu_calib_code, pd_calib_code; 471 + s32 pu_adj, pd_adj; 472 + u16 calib; 473 + 474 + /* 475 + * Calculate calibration code as per docs: use an average of the 476 + * pull down and pull up. Then add in adjustments. 477 + */ 478 + val = readl(tcphy->base + CMN_TXPUCAL_CTRL); 479 + pu_calib_code = CMN_CALIB_CODE_POS(val); 480 + val = readl(tcphy->base + CMN_TXPDCAL_CTRL); 481 + pd_calib_code = CMN_CALIB_CODE_POS(val); 482 + val = readl(tcphy->base + CMN_TXPU_ADJ_CTRL); 483 + pu_adj = CMN_CALIB_CODE(val); 484 + val = readl(tcphy->base + CMN_TXPD_ADJ_CTRL); 485 + pd_adj = CMN_CALIB_CODE(val); 486 + calib = (pu_calib_code + pd_calib_code) / 2 + pu_adj + pd_adj; 562 487 563 488 /* disable txda_cal_latch_en for rewrite the calibration values */ 564 489 tx_ana_ctrl_reg_1 = readl(tcphy->base + TX_ANA_CTRL_REG_1); 565 - tx_ana_ctrl_reg_1 &= ~BIT(13); 490 + tx_ana_ctrl_reg_1 &= ~TXDA_CAL_LATCH_EN; 566 491 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 567 492 568 - /* 569 - * read a resistor calibration code from CMN_TXPUCAL_CTRL[6:0] and 570 - * write it to TX_DIG_CTRL_REG_2[6:0], and delay 1ms to make sure it 571 - * works. 572 - */ 573 - rdata = readl(tcphy->base + TX_DIG_CTRL_REG_2); 574 - rdata = rdata & 0xffc0; 575 - 576 - rdata2 = readl(tcphy->base + CMN_TXPUCAL_CTRL); 577 - rdata2 = rdata2 & 0x3f; 578 - 579 - val = rdata | rdata2; 493 + /* write the calibration, then delay 10 ms as sample in docs */ 494 + val = readl(tcphy->base + TX_DIG_CTRL_REG_2); 495 + val &= ~(TX_RESCAL_CODE_MASK << TX_RESCAL_CODE_OFFSET); 496 + val |= calib << TX_RESCAL_CODE_OFFSET; 580 497 writel(val, tcphy->base + TX_DIG_CTRL_REG_2); 581 - usleep_range(1000, 1050); 498 + usleep_range(10000, 10050); 582 499 583 500 /* 584 501 * Enable signal for latch that sample and holds calibration values. 585 502 * Activate this signal for 1 clock cycle to sample new calibration 586 503 * values. 587 504 */ 588 - tx_ana_ctrl_reg_1 |= BIT(13); 505 + tx_ana_ctrl_reg_1 |= TXDA_CAL_LATCH_EN; 589 506 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 590 507 usleep_range(150, 200); 591 508 592 509 /* set TX Voltage Level and TX Deemphasis to 0 */ 593 510 writel(0, tcphy->base + PHY_DP_TX_CTL); 511 + 594 512 /* re-enable decap */ 595 - writel(0x100, tcphy->base + TX_ANA_CTRL_REG_2); 596 - writel(0x300, tcphy->base + TX_ANA_CTRL_REG_2); 597 - tx_ana_ctrl_reg_1 |= BIT(3); 513 + tx_ana_ctrl_reg_2 = XCVR_DECAP_EN; 514 + writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2); 515 + udelay(1); 516 + tx_ana_ctrl_reg_2 |= XCVR_DECAP_EN_DEL; 517 + writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2); 518 + 519 + writel(0, tcphy->base + TX_ANA_CTRL_REG_3); 520 + 521 + tx_ana_ctrl_reg_1 |= TXDA_UPHY_SUPPLY_EN; 598 522 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 599 - tx_ana_ctrl_reg_1 |= BIT(4); 523 + udelay(1); 524 + tx_ana_ctrl_reg_1 |= TXDA_UPHY_SUPPLY_EN_DEL; 600 525 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 601 526 602 527 writel(0, tcphy->base + TX_ANA_CTRL_REG_5); ··· 626 515 writel(0x1001, tcphy->base + TX_ANA_CTRL_REG_4); 627 516 628 517 /* re-enables Bandgap reference for LDO */ 629 - tx_ana_ctrl_reg_1 |= BIT(7); 518 + tx_ana_ctrl_reg_1 |= TXDA_DRV_LDO_EN; 630 519 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 631 - tx_ana_ctrl_reg_1 |= BIT(8); 520 + udelay(5); 521 + tx_ana_ctrl_reg_1 |= TXDA_BGREF_EN; 632 522 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 633 523 634 524 /* 635 525 * re-enables the transmitter pre-driver, driver data selection MUX, 636 526 * and receiver detect circuits. 637 527 */ 638 - writel(0x301, tcphy->base + TX_ANA_CTRL_REG_2); 639 - writel(0x303, tcphy->base + TX_ANA_CTRL_REG_2); 528 + tx_ana_ctrl_reg_2 |= TXDA_DRV_PREDRV_EN; 529 + writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2); 530 + udelay(1); 531 + tx_ana_ctrl_reg_2 |= TXDA_DRV_PREDRV_EN_DEL; 532 + writel(tx_ana_ctrl_reg_2, tcphy->base + TX_ANA_CTRL_REG_2); 640 533 641 534 /* 642 - * Do some magic undocumented stuff, some of which appears to 643 - * undo the "re-enables Bandgap reference for LDO" above. 535 + * Do all the undocumented magic: 536 + * - Turn on TXDA_DP_AUX_EN, whatever that is, even though sample 537 + * never shows this going on. 538 + * - Turn on TXDA_DECAP_EN (and TXDA_DECAP_EN_DEL) even though 539 + * docs say for aux it's always 0. 540 + * - Turn off the LDO and BGREF, which we just spent time turning 541 + * on above (???). 542 + * 543 + * Without this magic, things seem worse. 644 544 */ 645 - tx_ana_ctrl_reg_1 |= BIT(15); 646 - tx_ana_ctrl_reg_1 &= ~BIT(8); 647 - tx_ana_ctrl_reg_1 &= ~BIT(7); 648 - tx_ana_ctrl_reg_1 |= BIT(6); 649 - tx_ana_ctrl_reg_1 |= BIT(5); 545 + tx_ana_ctrl_reg_1 |= TXDA_DP_AUX_EN; 546 + tx_ana_ctrl_reg_1 |= TXDA_DECAP_EN; 547 + tx_ana_ctrl_reg_1 &= ~TXDA_DRV_LDO_EN; 548 + tx_ana_ctrl_reg_1 &= ~TXDA_BGREF_EN; 549 + writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 550 + udelay(1); 551 + tx_ana_ctrl_reg_1 |= TXDA_DECAP_EN_DEL; 650 552 writel(tx_ana_ctrl_reg_1, tcphy->base + TX_ANA_CTRL_REG_1); 651 553 652 - writel(0, tcphy->base + TX_ANA_CTRL_REG_3); 653 - writel(0, tcphy->base + TX_ANA_CTRL_REG_4); 654 - writel(0, tcphy->base + TX_ANA_CTRL_REG_5); 655 - 656 554 /* 657 - * Controls low_power_swing_en, don't set the voltage swing of the 658 - * driver to 400mv. The values below are peak to peak (differential) 659 - * values. 555 + * Undo the work we did to set the LDO voltage. 556 + * This doesn't seem to help nor hurt, but it kinda goes with the 557 + * undocumented magic above. 660 558 */ 559 + writel(0, tcphy->base + TX_ANA_CTRL_REG_4); 560 + 561 + /* Don't set voltage swing to 400 mV peak to peak (differential) */ 661 562 writel(0, tcphy->base + TXDA_COEFF_CALC_CTRL); 563 + 564 + /* Init TXDA_CYA_AUXDA_CYA for unknown magic reasons */ 662 565 writel(0, tcphy->base + TXDA_CYA_AUXDA_CYA); 663 566 664 - /* Controls tx_high_z_tm_en */ 567 + /* 568 + * More undocumented magic, presumably the goal of which is to 569 + * make the "auxda_source_aux_oen" be ignored and instead to decide 570 + * about "high impedance state" based on what software puts in the 571 + * register TXDA_COEFF_CALC_CTRL (see TX_HIGH_Z). Since we only 572 + * program that register once and we don't set the bit TX_HIGH_Z, 573 + * presumably the goal here is that we should never put the analog 574 + * driver in high impedance state. 575 + */ 665 576 val = readl(tcphy->base + TX_DIG_CTRL_REG_2); 666 - val |= BIT(15); 577 + val |= TX_HIGH_Z_TM_EN; 667 578 writel(val, tcphy->base + TX_DIG_CTRL_REG_2); 668 579 } 669 580
+100 -1
drivers/phy/ti/phy-ti-pipe3.c
··· 68 68 #define PCIE_PCS_MASK 0xFF0000 69 69 #define PCIE_PCS_DELAY_COUNT_SHIFT 0x10 70 70 71 + #define PCIEPHYRX_ANA_PROGRAMMABILITY 0x0000000C 72 + #define INTERFACE_MASK GENMASK(31, 27) 73 + #define INTERFACE_SHIFT 27 74 + #define LOSD_MASK GENMASK(17, 14) 75 + #define LOSD_SHIFT 14 76 + #define MEM_PLLDIV GENMASK(6, 5) 77 + 78 + #define PCIEPHYRX_TRIM 0x0000001C 79 + #define MEM_DLL_TRIM_SEL GENMASK(31, 30) 80 + #define MEM_DLL_TRIM_SHIFT 30 81 + 82 + #define PCIEPHYRX_DLL 0x00000024 83 + #define MEM_DLL_PHINT_RATE GENMASK(31, 30) 84 + 85 + #define PCIEPHYRX_DIGITAL_MODES 0x00000028 86 + #define MEM_CDR_FASTLOCK BIT(23) 87 + #define MEM_CDR_LBW GENMASK(22, 21) 88 + #define MEM_CDR_STEPCNT GENMASK(20, 19) 89 + #define MEM_CDR_STL_MASK GENMASK(18, 16) 90 + #define MEM_CDR_STL_SHIFT 16 91 + #define MEM_CDR_THR_MASK GENMASK(15, 13) 92 + #define MEM_CDR_THR_SHIFT 13 93 + #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) 101 + #define MEM_EQCTL_SHIFT 7 102 + #define MEM_OVRD_EQLEV BIT(2) 103 + #define MEM_OVRD_EQFTC BIT(1) 104 + 71 105 /* 72 106 * This is an Empirical value that works, need to confirm the actual 73 107 * value required for the PIPE3PHY_PLL_CONFIGURATION2.PLL_IDLE status ··· 125 91 126 92 struct ti_pipe3 { 127 93 void __iomem *pll_ctrl_base; 94 + void __iomem *phy_rx; 95 + void __iomem *phy_tx; 128 96 struct device *dev; 129 97 struct device *control_dev; 130 98 struct clk *wkupclk; ··· 297 261 return ti_pipe3_dpll_wait_lock(phy); 298 262 } 299 263 264 + static void ti_pipe3_calibrate(struct ti_pipe3 *phy) 265 + { 266 + u32 val; 267 + 268 + val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY); 269 + val &= ~(INTERFACE_MASK | LOSD_MASK | MEM_PLLDIV); 270 + val = (0x1 << INTERFACE_SHIFT | 0xA << LOSD_SHIFT); 271 + ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_ANA_PROGRAMMABILITY, val); 272 + 273 + val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES); 274 + val &= ~(MEM_CDR_STEPCNT | MEM_CDR_STL_MASK | MEM_CDR_THR_MASK | 275 + MEM_CDR_CDR_2NDO_SDM_MODE | MEM_OVRD_HS_RATE); 276 + val |= (MEM_CDR_FASTLOCK | MEM_CDR_LBW | 0x3 << MEM_CDR_STL_SHIFT | 277 + 0x1 << MEM_CDR_THR_SHIFT | MEM_CDR_THR_MODE); 278 + ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DIGITAL_MODES, val); 279 + 280 + val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_TRIM); 281 + val &= ~MEM_DLL_TRIM_SEL; 282 + val |= 0x2 << MEM_DLL_TRIM_SHIFT; 283 + ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_TRIM, val); 284 + 285 + val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_DLL); 286 + val |= MEM_DLL_PHINT_RATE; 287 + ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_DLL, val); 288 + 289 + val = ti_pipe3_readl(phy->phy_rx, PCIEPHYRX_EQUALIZER); 290 + val &= ~(MEM_EQLEV | MEM_EQCTL | MEM_OVRD_EQLEV | MEM_OVRD_EQFTC); 291 + val |= MEM_EQFTC | 0x1 << MEM_EQCTL_SHIFT; 292 + ti_pipe3_writel(phy->phy_rx, PCIEPHYRX_EQUALIZER, val); 293 + } 294 + 300 295 static int ti_pipe3_init(struct phy *x) 301 296 { 302 297 struct ti_pipe3 *phy = phy_get_drvdata(x); ··· 349 282 val = 0x96 << OMAP_CTRL_PCIE_PCS_DELAY_COUNT_SHIFT; 350 283 ret = regmap_update_bits(phy->pcs_syscon, phy->pcie_pcs_reg, 351 284 PCIE_PCS_MASK, val); 352 - return ret; 285 + if (ret) 286 + return ret; 287 + 288 + ti_pipe3_calibrate(phy); 289 + 290 + return 0; 353 291 } 354 292 355 293 /* Bring it out of IDLE if it is IDLE */ ··· 585 513 return 0; 586 514 } 587 515 516 + static int ti_pipe3_get_tx_rx_base(struct ti_pipe3 *phy) 517 + { 518 + struct resource *res; 519 + struct device *dev = phy->dev; 520 + struct device_node *node = dev->of_node; 521 + struct platform_device *pdev = to_platform_device(dev); 522 + 523 + if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) 524 + return 0; 525 + 526 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 527 + "phy_rx"); 528 + phy->phy_rx = devm_ioremap_resource(dev, res); 529 + if (IS_ERR(phy->phy_rx)) 530 + return PTR_ERR(phy->phy_rx); 531 + 532 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, 533 + "phy_tx"); 534 + phy->phy_tx = devm_ioremap_resource(dev, res); 535 + 536 + return PTR_ERR_OR_ZERO(phy->phy_tx); 537 + } 538 + 588 539 static int ti_pipe3_get_pll_base(struct ti_pipe3 *phy) 589 540 { 590 541 struct resource *res; ··· 651 556 phy->dev = dev; 652 557 653 558 ret = ti_pipe3_get_pll_base(phy); 559 + if (ret) 560 + return ret; 561 + 562 + ret = ti_pipe3_get_tx_rx_base(phy); 654 563 if (ret) 655 564 return ret; 656 565
+18 -23
drivers/scsi/ufs/ufs-qcom.c
··· 273 273 bool is_rate_B = (UFS_QCOM_LIMIT_HS_RATE == PA_HS_MODE_B) 274 274 ? true : false; 275 275 276 + if (is_rate_B) 277 + phy_set_mode(phy, PHY_MODE_UFS_HS_B); 278 + 276 279 /* Assert PHY reset and apply PHY calibration values */ 277 280 ufs_qcom_assert_reset(hba); 278 281 /* provide 1ms delay to let the reset pulse propagate */ 279 282 usleep_range(1000, 1100); 280 283 281 - ret = ufs_qcom_phy_calibrate_phy(phy, is_rate_B); 282 - 284 + /* phy initialization - calibrate the phy */ 285 + ret = phy_init(phy); 283 286 if (ret) { 284 - dev_err(hba->dev, "%s: ufs_qcom_phy_calibrate_phy() failed, ret = %d\n", 287 + dev_err(hba->dev, "%s: phy init failed, ret = %d\n", 285 288 __func__, ret); 286 289 goto out; 287 290 } ··· 297 294 * voltage, current to settle down before starting serdes. 298 295 */ 299 296 usleep_range(1000, 1100); 300 - ret = ufs_qcom_phy_start_serdes(phy); 301 - if (ret) { 302 - dev_err(hba->dev, "%s: ufs_qcom_phy_start_serdes() failed, ret = %d\n", 303 - __func__, ret); 304 - goto out; 305 - } 306 297 307 - ret = ufs_qcom_phy_is_pcs_ready(phy); 308 - if (ret) 309 - dev_err(hba->dev, 310 - "%s: is_physical_coding_sublayer_ready() failed, ret = %d\n", 298 + /* power on phy - start serdes and phy's power and clocks */ 299 + ret = phy_power_on(phy); 300 + if (ret) { 301 + dev_err(hba->dev, "%s: phy power on failed, ret = %d\n", 311 302 __func__, ret); 303 + goto out_disable_phy; 304 + } 312 305 313 306 ufs_qcom_select_unipro_mode(host); 314 307 308 + return 0; 309 + 310 + out_disable_phy: 311 + ufs_qcom_assert_reset(hba); 312 + phy_exit(phy); 315 313 out: 316 314 return ret; 317 315 } ··· 1277 1273 ufs_qcom_phy_save_controller_version(host->generic_phy, 1278 1274 host->hw_ver.major, host->hw_ver.minor, host->hw_ver.step); 1279 1275 1280 - phy_init(host->generic_phy); 1281 - err = phy_power_on(host->generic_phy); 1282 - if (err) 1283 - goto out_unregister_bus; 1284 - 1285 1276 err = ufs_qcom_init_lane_clks(host); 1286 1277 if (err) 1287 - goto out_disable_phy; 1278 + goto out_variant_clear; 1288 1279 1289 1280 ufs_qcom_set_caps(hba); 1290 1281 ufs_qcom_advertise_quirks(hba); ··· 1300 1301 1301 1302 goto out; 1302 1303 1303 - out_disable_phy: 1304 - phy_power_off(host->generic_phy); 1305 - out_unregister_bus: 1306 - phy_exit(host->generic_phy); 1307 1304 out_variant_clear: 1308 1305 ufshcd_set_variant(hba, NULL); 1309 1306 out:
+12
drivers/soc/bcm/brcmstb/common.c
··· 40 40 return of_match_node(brcmstb_machine_match, root) != NULL; 41 41 } 42 42 43 + u32 brcmstb_get_family_id(void) 44 + { 45 + return family_id; 46 + } 47 + EXPORT_SYMBOL(brcmstb_get_family_id); 48 + 49 + u32 brcmstb_get_product_id(void) 50 + { 51 + return product_id; 52 + } 53 + EXPORT_SYMBOL(brcmstb_get_product_id); 54 + 43 55 static const struct of_device_id sun_top_ctrl_match[] = { 44 56 { .compatible = "brcm,bcm7125-sun-top-ctrl", }, 45 57 { .compatible = "brcm,bcm7346-sun-top-ctrl", },
+1
include/dt-bindings/phy/phy.h
··· 15 15 #define PHY_TYPE_PCIE 2 16 16 #define PHY_TYPE_USB2 3 17 17 #define PHY_TYPE_USB3 4 18 + #define PHY_TYPE_UFS 5 18 19 19 20 #endif /* _DT_BINDINGS_PHY */
-3
include/linux/phy/phy-qcom-ufs.h
··· 31 31 */ 32 32 void ufs_qcom_phy_disable_dev_ref_clk(struct phy *phy); 33 33 34 - int ufs_qcom_phy_start_serdes(struct phy *phy); 35 34 int ufs_qcom_phy_set_tx_lane_enable(struct phy *phy, u32 tx_lanes); 36 - int ufs_qcom_phy_calibrate_phy(struct phy *phy, bool is_rate_B); 37 - int ufs_qcom_phy_is_pcs_ready(struct phy *phy); 38 35 void ufs_qcom_phy_save_controller_version(struct phy *phy, 39 36 u8 major, u16 minor, u16 step); 40 37
+13 -1
include/linux/phy/phy.h
··· 29 29 PHY_MODE_USB_OTG, 30 30 PHY_MODE_SGMII, 31 31 PHY_MODE_10GKR, 32 + PHY_MODE_UFS_HS_A, 33 + PHY_MODE_UFS_HS_B, 32 34 }; 33 35 34 36 /** ··· 41 39 * @power_off: powering off the phy 42 40 * @set_mode: set the mode of the phy 43 41 * @reset: resetting the phy 42 + * @calibrate: calibrate the phy 44 43 * @owner: the module owner containing the ops 45 44 */ 46 45 struct phy_ops { ··· 51 48 int (*power_off)(struct phy *phy); 52 49 int (*set_mode)(struct phy *phy, enum phy_mode mode); 53 50 int (*reset)(struct phy *phy); 51 + int (*calibrate)(struct phy *phy); 54 52 struct module *owner; 55 53 }; 56 54 ··· 145 141 int phy_power_off(struct phy *phy); 146 142 int phy_set_mode(struct phy *phy, enum phy_mode mode); 147 143 int phy_reset(struct phy *phy); 144 + int phy_calibrate(struct phy *phy); 148 145 static inline int phy_get_bus_width(struct phy *phy) 149 146 { 150 147 return phy->attrs.bus_width; ··· 267 262 return -ENOSYS; 268 263 } 269 264 265 + static inline int phy_calibrate(struct phy *phy) 266 + { 267 + if (!phy) 268 + return 0; 269 + return -ENOSYS; 270 + } 271 + 270 272 static inline int phy_get_bus_width(struct phy *phy) 271 273 { 272 274 return -ENOSYS; ··· 303 291 static inline struct phy *devm_phy_optional_get(struct device *dev, 304 292 const char *string) 305 293 { 306 - return ERR_PTR(-ENOSYS); 294 + return NULL; 307 295 } 308 296 309 297 static inline struct phy *devm_of_phy_get(struct device *dev,
+17
include/linux/soc/brcmstb/brcmstb.h
··· 1 1 #ifndef __BRCMSTB_SOC_H 2 2 #define __BRCMSTB_SOC_H 3 3 4 + static inline u32 BRCM_ID(u32 reg) 5 + { 6 + return reg >> 28 ? reg >> 16 : reg >> 8; 7 + } 8 + 9 + static inline u32 BRCM_REV(u32 reg) 10 + { 11 + return reg & 0xff; 12 + } 13 + 4 14 /* 5 15 * Bus Interface Unit control register setup, must happen early during boot, 6 16 * before SMP is brought up, called by machine entry point. 7 17 */ 8 18 void brcmstb_biuctrl_init(void); 19 + 20 + /* 21 + * Helper functions for getting family or product id from the 22 + * SoC driver. 23 + */ 24 + u32 brcmstb_get_family_id(void); 25 + u32 brcmstb_get_product_id(void); 9 26 10 27 #endif /* __BRCMSTB_SOC_H */