Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 MediaTek Inc. |
| 3 | * Author: Chunfeng Yun <chunfeng.yun@mediatek.com> |
| 4 | * |
| 5 | * This software is licensed under the terms of the GNU General Public |
| 6 | * License version 2, as published by the Free Software Foundation, and |
| 7 | * may be copied, distributed, and modified under those terms. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include <dt-bindings/phy/phy.h> |
| 17 | #include <linux/clk.h> |
| 18 | #include <linux/delay.h> |
| 19 | #include <linux/io.h> |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 20 | #include <linux/iopoll.h> |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 21 | #include <linux/module.h> |
| 22 | #include <linux/of_address.h> |
| 23 | #include <linux/phy/phy.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 26 | /* version V1 sub-banks offset base address */ |
| 27 | /* banks shared by multiple phys */ |
| 28 | #define SSUSB_SIFSLV_V1_SPLLC 0x000 /* shared by u3 phys */ |
| 29 | #define SSUSB_SIFSLV_V1_U2FREQ 0x100 /* shared by u2 phys */ |
| 30 | /* u2 phy bank */ |
| 31 | #define SSUSB_SIFSLV_V1_U2PHY_COM 0x000 |
| 32 | /* u3 phy banks */ |
| 33 | #define SSUSB_SIFSLV_V1_U3PHYD 0x000 |
| 34 | #define SSUSB_SIFSLV_V1_U3PHYA 0x200 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 35 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 36 | /* version V2 sub-banks offset base address */ |
| 37 | /* u2 phy banks */ |
| 38 | #define SSUSB_SIFSLV_V2_MISC 0x000 |
| 39 | #define SSUSB_SIFSLV_V2_U2FREQ 0x100 |
| 40 | #define SSUSB_SIFSLV_V2_U2PHY_COM 0x300 |
| 41 | /* u3 phy banks */ |
| 42 | #define SSUSB_SIFSLV_V2_SPLLC 0x000 |
| 43 | #define SSUSB_SIFSLV_V2_CHIP 0x100 |
| 44 | #define SSUSB_SIFSLV_V2_U3PHYD 0x200 |
| 45 | #define SSUSB_SIFSLV_V2_U3PHYA 0x400 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 46 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 47 | #define U3P_USBPHYACR0 0x000 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 48 | #define PA0_RG_U2PLL_FORCE_ON BIT(15) |
Chunfeng Yun | c0250fe | 2017-03-31 15:35:32 +0800 | [diff] [blame] | 49 | #define PA0_RG_USB20_INTR_EN BIT(5) |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 50 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 51 | #define U3P_USBPHYACR2 0x008 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 52 | #define PA2_RG_SIF_U2PLL_FORCE_EN BIT(18) |
| 53 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 54 | #define U3P_USBPHYACR5 0x014 |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 55 | #define PA5_RG_U2_HSTX_SRCAL_EN BIT(15) |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 56 | #define PA5_RG_U2_HSTX_SRCTRL GENMASK(14, 12) |
| 57 | #define PA5_RG_U2_HSTX_SRCTRL_VAL(x) ((0x7 & (x)) << 12) |
| 58 | #define PA5_RG_U2_HS_100U_U3_EN BIT(11) |
| 59 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 60 | #define U3P_USBPHYACR6 0x018 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 61 | #define PA6_RG_U2_BC11_SW_EN BIT(23) |
| 62 | #define PA6_RG_U2_OTG_VBUSCMP_EN BIT(20) |
Chunfeng Yun | 43f53b1 | 2015-12-04 10:08:56 +0800 | [diff] [blame] | 63 | #define PA6_RG_U2_SQTH GENMASK(3, 0) |
| 64 | #define PA6_RG_U2_SQTH_VAL(x) (0xf & (x)) |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 65 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 66 | #define U3P_U2PHYACR4 0x020 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 67 | #define P2C_RG_USB20_GPIO_CTL BIT(9) |
| 68 | #define P2C_USB20_GPIO_MODE BIT(8) |
| 69 | #define P2C_U2_GPIO_CTR_MSK (P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) |
| 70 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 71 | #define U3D_U2PHYDCR0 0x060 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 72 | #define P2C_RG_SIF_U2PLL_FORCE_ON BIT(24) |
| 73 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 74 | #define U3P_U2PHYDTM0 0x068 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 75 | #define P2C_FORCE_UART_EN BIT(26) |
| 76 | #define P2C_FORCE_DATAIN BIT(23) |
| 77 | #define P2C_FORCE_DM_PULLDOWN BIT(21) |
| 78 | #define P2C_FORCE_DP_PULLDOWN BIT(20) |
| 79 | #define P2C_FORCE_XCVRSEL BIT(19) |
| 80 | #define P2C_FORCE_SUSPENDM BIT(18) |
| 81 | #define P2C_FORCE_TERMSEL BIT(17) |
| 82 | #define P2C_RG_DATAIN GENMASK(13, 10) |
| 83 | #define P2C_RG_DATAIN_VAL(x) ((0xf & (x)) << 10) |
| 84 | #define P2C_RG_DMPULLDOWN BIT(7) |
| 85 | #define P2C_RG_DPPULLDOWN BIT(6) |
| 86 | #define P2C_RG_XCVRSEL GENMASK(5, 4) |
| 87 | #define P2C_RG_XCVRSEL_VAL(x) ((0x3 & (x)) << 4) |
| 88 | #define P2C_RG_SUSPENDM BIT(3) |
| 89 | #define P2C_RG_TERMSEL BIT(2) |
| 90 | #define P2C_DTM0_PART_MASK \ |
| 91 | (P2C_FORCE_DATAIN | P2C_FORCE_DM_PULLDOWN | \ |
| 92 | P2C_FORCE_DP_PULLDOWN | P2C_FORCE_XCVRSEL | \ |
| 93 | P2C_FORCE_TERMSEL | P2C_RG_DMPULLDOWN | \ |
| 94 | P2C_RG_DPPULLDOWN | P2C_RG_TERMSEL) |
| 95 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 96 | #define U3P_U2PHYDTM1 0x06C |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 97 | #define P2C_RG_UART_EN BIT(16) |
| 98 | #define P2C_RG_VBUSVALID BIT(5) |
| 99 | #define P2C_RG_SESSEND BIT(4) |
| 100 | #define P2C_RG_AVALID BIT(2) |
| 101 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 102 | #define U3P_U3_PHYA_REG6 0x018 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 103 | #define P3A_RG_TX_EIDLE_CM GENMASK(31, 28) |
| 104 | #define P3A_RG_TX_EIDLE_CM_VAL(x) ((0xf & (x)) << 28) |
| 105 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 106 | #define U3P_U3_PHYA_REG9 0x024 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 107 | #define P3A_RG_RX_DAC_MUX GENMASK(5, 1) |
| 108 | #define P3A_RG_RX_DAC_MUX_VAL(x) ((0x1f & (x)) << 1) |
| 109 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 110 | #define U3P_U3_PHYA_DA_REG0 0x100 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 111 | #define P3A_RG_XTAL_EXT_EN_U3 GENMASK(11, 10) |
| 112 | #define P3A_RG_XTAL_EXT_EN_U3_VAL(x) ((0x3 & (x)) << 10) |
| 113 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 114 | #define U3P_U3_PHYD_LFPS1 0x00c |
Chunfeng Yun | 98cd83a | 2017-03-31 15:35:28 +0800 | [diff] [blame] | 115 | #define P3D_RG_FWAKE_TH GENMASK(21, 16) |
| 116 | #define P3D_RG_FWAKE_TH_VAL(x) ((0x3f & (x)) << 16) |
| 117 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 118 | #define U3P_U3_PHYD_CDR1 0x05c |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 119 | #define P3D_RG_CDR_BIR_LTD1 GENMASK(28, 24) |
| 120 | #define P3D_RG_CDR_BIR_LTD1_VAL(x) ((0x1f & (x)) << 24) |
| 121 | #define P3D_RG_CDR_BIR_LTD0 GENMASK(12, 8) |
| 122 | #define P3D_RG_CDR_BIR_LTD0_VAL(x) ((0x1f & (x)) << 8) |
| 123 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 124 | #define U3P_U3_PHYD_RXDET1 0x128 |
Chunfeng Yun | 1969f69 | 2017-03-31 15:35:27 +0800 | [diff] [blame] | 125 | #define P3D_RG_RXDET_STB2_SET GENMASK(17, 9) |
| 126 | #define P3D_RG_RXDET_STB2_SET_VAL(x) ((0x1ff & (x)) << 9) |
| 127 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 128 | #define U3P_U3_PHYD_RXDET2 0x12c |
Chunfeng Yun | 1969f69 | 2017-03-31 15:35:27 +0800 | [diff] [blame] | 129 | #define P3D_RG_RXDET_STB2_SET_P3 GENMASK(8, 0) |
| 130 | #define P3D_RG_RXDET_STB2_SET_P3_VAL(x) (0x1ff & (x)) |
| 131 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 132 | #define U3P_SPLLC_XTALCTL3 0x018 |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 133 | #define XC3_RG_U3_XTAL_RX_PWD BIT(9) |
| 134 | #define XC3_RG_U3_FRC_XTAL_RX_PWD BIT(8) |
| 135 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 136 | #define U3P_U2FREQ_FMCR0 0x00 |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 137 | #define P2F_RG_MONCLK_SEL GENMASK(27, 26) |
| 138 | #define P2F_RG_MONCLK_SEL_VAL(x) ((0x3 & (x)) << 26) |
| 139 | #define P2F_RG_FREQDET_EN BIT(24) |
| 140 | #define P2F_RG_CYCLECNT GENMASK(23, 0) |
| 141 | #define P2F_RG_CYCLECNT_VAL(x) ((P2F_RG_CYCLECNT) & (x)) |
| 142 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 143 | #define U3P_U2FREQ_VALUE 0x0c |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 144 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 145 | #define U3P_U2FREQ_FMMONR1 0x10 |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 146 | #define P2F_USB_FM_VALID BIT(0) |
| 147 | #define P2F_RG_FRCK_EN BIT(8) |
| 148 | |
| 149 | #define U3P_REF_CLK 26 /* MHZ */ |
| 150 | #define U3P_SLEW_RATE_COEF 28 |
| 151 | #define U3P_SR_COEF_DIVISOR 1000 |
| 152 | #define U3P_FM_DET_CYCLE_CNT 1024 |
| 153 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 154 | enum mt_phy_version { |
| 155 | MT_PHY_V1 = 1, |
| 156 | MT_PHY_V2, |
| 157 | }; |
| 158 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 159 | struct mt65xx_phy_pdata { |
| 160 | /* avoid RX sensitivity level degradation only for mt8173 */ |
| 161 | bool avoid_rx_sen_degradation; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 162 | enum mt_phy_version version; |
| 163 | }; |
| 164 | |
| 165 | struct u2phy_banks { |
| 166 | void __iomem *misc; |
| 167 | void __iomem *fmreg; |
| 168 | void __iomem *com; |
| 169 | }; |
| 170 | |
| 171 | struct u3phy_banks { |
| 172 | void __iomem *spllc; |
| 173 | void __iomem *chip; |
| 174 | void __iomem *phyd; /* include u3phyd_bank2 */ |
| 175 | void __iomem *phya; /* include u3phya_da */ |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 176 | }; |
| 177 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 178 | struct mt65xx_phy_instance { |
| 179 | struct phy *phy; |
| 180 | void __iomem *port_base; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 181 | union { |
| 182 | struct u2phy_banks u2_banks; |
| 183 | struct u3phy_banks u3_banks; |
| 184 | }; |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 185 | struct clk *ref_clk; /* reference clock of anolog phy */ |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 186 | u32 index; |
| 187 | u8 type; |
| 188 | }; |
| 189 | |
| 190 | struct mt65xx_u3phy { |
| 191 | struct device *dev; |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 192 | void __iomem *sif_base; /* only shared sif */ |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 193 | /* deprecated, use @ref_clk instead in phy instance */ |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 194 | struct clk *u3phya_ref; /* reference clock of usb3 anolog phy */ |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 195 | const struct mt65xx_phy_pdata *pdata; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 196 | struct mt65xx_phy_instance **phys; |
| 197 | int nphys; |
| 198 | }; |
| 199 | |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 200 | static void hs_slew_rate_calibrate(struct mt65xx_u3phy *u3phy, |
| 201 | struct mt65xx_phy_instance *instance) |
| 202 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 203 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 204 | void __iomem *fmreg = u2_banks->fmreg; |
| 205 | void __iomem *com = u2_banks->com; |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 206 | int calibration_val; |
| 207 | int fm_out; |
| 208 | u32 tmp; |
| 209 | |
| 210 | /* enable USB ring oscillator */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 211 | tmp = readl(com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 212 | tmp |= PA5_RG_U2_HSTX_SRCAL_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 213 | writel(tmp, com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 214 | udelay(1); |
| 215 | |
| 216 | /*enable free run clock */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 217 | tmp = readl(fmreg + U3P_U2FREQ_FMMONR1); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 218 | tmp |= P2F_RG_FRCK_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 219 | writel(tmp, fmreg + U3P_U2FREQ_FMMONR1); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 220 | |
| 221 | /* set cycle count as 1024, and select u2 channel */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 222 | tmp = readl(fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 223 | tmp &= ~(P2F_RG_CYCLECNT | P2F_RG_MONCLK_SEL); |
| 224 | tmp |= P2F_RG_CYCLECNT_VAL(U3P_FM_DET_CYCLE_CNT); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 225 | if (u3phy->pdata->version == MT_PHY_V1) |
| 226 | tmp |= P2F_RG_MONCLK_SEL_VAL(instance->index >> 1); |
| 227 | |
| 228 | writel(tmp, fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 229 | |
| 230 | /* enable frequency meter */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 231 | tmp = readl(fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 232 | tmp |= P2F_RG_FREQDET_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 233 | writel(tmp, fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 234 | |
| 235 | /* ignore return value */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 236 | readl_poll_timeout(fmreg + U3P_U2FREQ_FMMONR1, tmp, |
| 237 | (tmp & P2F_USB_FM_VALID), 10, 200); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 238 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 239 | fm_out = readl(fmreg + U3P_U2FREQ_VALUE); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 240 | |
| 241 | /* disable frequency meter */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 242 | tmp = readl(fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 243 | tmp &= ~P2F_RG_FREQDET_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 244 | writel(tmp, fmreg + U3P_U2FREQ_FMCR0); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 245 | |
| 246 | /*disable free run clock */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 247 | tmp = readl(fmreg + U3P_U2FREQ_FMMONR1); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 248 | tmp &= ~P2F_RG_FRCK_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 249 | writel(tmp, fmreg + U3P_U2FREQ_FMMONR1); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 250 | |
| 251 | if (fm_out) { |
| 252 | /* ( 1024 / FM_OUT ) x reference clock frequency x 0.028 */ |
| 253 | tmp = U3P_FM_DET_CYCLE_CNT * U3P_REF_CLK * U3P_SLEW_RATE_COEF; |
| 254 | tmp /= fm_out; |
| 255 | calibration_val = DIV_ROUND_CLOSEST(tmp, U3P_SR_COEF_DIVISOR); |
| 256 | } else { |
| 257 | /* if FM detection fail, set default value */ |
| 258 | calibration_val = 4; |
| 259 | } |
| 260 | dev_dbg(u3phy->dev, "phy:%d, fm_out:%d, calib:%d\n", |
| 261 | instance->index, fm_out, calibration_val); |
| 262 | |
| 263 | /* set HS slew rate */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 264 | tmp = readl(com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 265 | tmp &= ~PA5_RG_U2_HSTX_SRCTRL; |
| 266 | tmp |= PA5_RG_U2_HSTX_SRCTRL_VAL(calibration_val); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 267 | writel(tmp, com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 268 | |
| 269 | /* disable USB ring oscillator */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 270 | tmp = readl(com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 271 | tmp &= ~PA5_RG_U2_HSTX_SRCAL_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 272 | writel(tmp, com + U3P_USBPHYACR5); |
Chunfeng Yun | 75f072f | 2015-12-04 10:11:05 +0800 | [diff] [blame] | 273 | } |
| 274 | |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 275 | static void u3_phy_instance_init(struct mt65xx_u3phy *u3phy, |
| 276 | struct mt65xx_phy_instance *instance) |
| 277 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 278 | struct u3phy_banks *u3_banks = &instance->u3_banks; |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 279 | u32 tmp; |
| 280 | |
| 281 | /* gating PCIe Analog XTAL clock */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 282 | tmp = readl(u3_banks->spllc + U3P_SPLLC_XTALCTL3); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 283 | tmp |= XC3_RG_U3_XTAL_RX_PWD | XC3_RG_U3_FRC_XTAL_RX_PWD; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 284 | writel(tmp, u3_banks->spllc + U3P_SPLLC_XTALCTL3); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 285 | |
| 286 | /* gating XSQ */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 287 | tmp = readl(u3_banks->phya + U3P_U3_PHYA_DA_REG0); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 288 | tmp &= ~P3A_RG_XTAL_EXT_EN_U3; |
| 289 | tmp |= P3A_RG_XTAL_EXT_EN_U3_VAL(2); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 290 | writel(tmp, u3_banks->phya + U3P_U3_PHYA_DA_REG0); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 291 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 292 | tmp = readl(u3_banks->phya + U3P_U3_PHYA_REG9); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 293 | tmp &= ~P3A_RG_RX_DAC_MUX; |
| 294 | tmp |= P3A_RG_RX_DAC_MUX_VAL(4); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 295 | writel(tmp, u3_banks->phya + U3P_U3_PHYA_REG9); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 296 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 297 | tmp = readl(u3_banks->phya + U3P_U3_PHYA_REG6); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 298 | tmp &= ~P3A_RG_TX_EIDLE_CM; |
| 299 | tmp |= P3A_RG_TX_EIDLE_CM_VAL(0xe); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 300 | writel(tmp, u3_banks->phya + U3P_U3_PHYA_REG6); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 301 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 302 | tmp = readl(u3_banks->phyd + U3P_U3_PHYD_CDR1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 303 | tmp &= ~(P3D_RG_CDR_BIR_LTD0 | P3D_RG_CDR_BIR_LTD1); |
| 304 | tmp |= P3D_RG_CDR_BIR_LTD0_VAL(0xc) | P3D_RG_CDR_BIR_LTD1_VAL(0x3); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 305 | writel(tmp, u3_banks->phyd + U3P_U3_PHYD_CDR1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 306 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 307 | tmp = readl(u3_banks->phyd + U3P_U3_PHYD_LFPS1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 308 | tmp &= ~P3D_RG_FWAKE_TH; |
| 309 | tmp |= P3D_RG_FWAKE_TH_VAL(0x34); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 310 | writel(tmp, u3_banks->phyd + U3P_U3_PHYD_LFPS1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 311 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 312 | tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RXDET1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 313 | tmp &= ~P3D_RG_RXDET_STB2_SET; |
| 314 | tmp |= P3D_RG_RXDET_STB2_SET_VAL(0x10); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 315 | writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RXDET1); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 316 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 317 | tmp = readl(u3_banks->phyd + U3P_U3_PHYD_RXDET2); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 318 | tmp &= ~P3D_RG_RXDET_STB2_SET_P3; |
| 319 | tmp |= P3D_RG_RXDET_STB2_SET_P3_VAL(0x10); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 320 | writel(tmp, u3_banks->phyd + U3P_U3_PHYD_RXDET2); |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 321 | |
| 322 | dev_dbg(u3phy->dev, "%s(%d)\n", __func__, instance->index); |
| 323 | } |
| 324 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 325 | static void phy_instance_init(struct mt65xx_u3phy *u3phy, |
| 326 | struct mt65xx_phy_instance *instance) |
| 327 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 328 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 329 | void __iomem *com = u2_banks->com; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 330 | u32 index = instance->index; |
| 331 | u32 tmp; |
| 332 | |
| 333 | /* switch to USB function. (system register, force ip into usb mode) */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 334 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 335 | tmp &= ~P2C_FORCE_UART_EN; |
| 336 | tmp |= P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 337 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 338 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 339 | tmp = readl(com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 340 | tmp &= ~P2C_RG_UART_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 341 | writel(tmp, com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 342 | |
Chunfeng Yun | c0250fe | 2017-03-31 15:35:32 +0800 | [diff] [blame] | 343 | tmp = readl(com + U3P_USBPHYACR0); |
| 344 | tmp |= PA0_RG_USB20_INTR_EN; |
| 345 | writel(tmp, com + U3P_USBPHYACR0); |
| 346 | |
| 347 | /* disable switch 100uA current to SSUSB */ |
| 348 | tmp = readl(com + U3P_USBPHYACR5); |
| 349 | tmp &= ~PA5_RG_U2_HS_100U_U3_EN; |
| 350 | writel(tmp, com + U3P_USBPHYACR5); |
| 351 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 352 | if (!index) { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 353 | tmp = readl(com + U3P_U2PHYACR4); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 354 | tmp &= ~P2C_U2_GPIO_CTR_MSK; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 355 | writel(tmp, com + U3P_U2PHYACR4); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 356 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 357 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 358 | if (u3phy->pdata->avoid_rx_sen_degradation) { |
| 359 | if (!index) { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 360 | tmp = readl(com + U3P_USBPHYACR2); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 361 | tmp |= PA2_RG_SIF_U2PLL_FORCE_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 362 | writel(tmp, com + U3P_USBPHYACR2); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 363 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 364 | tmp = readl(com + U3D_U2PHYDCR0); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 365 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 366 | writel(tmp, com + U3D_U2PHYDCR0); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 367 | } else { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 368 | tmp = readl(com + U3D_U2PHYDCR0); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 369 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 370 | writel(tmp, com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 371 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 372 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 373 | tmp |= P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 374 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 375 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 376 | } |
| 377 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 378 | tmp = readl(com + U3P_USBPHYACR6); |
Chunfeng Yun | 43f53b1 | 2015-12-04 10:08:56 +0800 | [diff] [blame] | 379 | tmp &= ~PA6_RG_U2_BC11_SW_EN; /* DP/DM BC1.1 path Disable */ |
| 380 | tmp &= ~PA6_RG_U2_SQTH; |
| 381 | tmp |= PA6_RG_U2_SQTH_VAL(2); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 382 | writel(tmp, com + U3P_USBPHYACR6); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 383 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 384 | dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); |
| 385 | } |
| 386 | |
| 387 | static void phy_instance_power_on(struct mt65xx_u3phy *u3phy, |
| 388 | struct mt65xx_phy_instance *instance) |
| 389 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 390 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 391 | void __iomem *com = u2_banks->com; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 392 | u32 index = instance->index; |
| 393 | u32 tmp; |
| 394 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 395 | /* (force_suspendm=0) (let suspendm=1, enable usb 480MHz pll) */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 396 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 397 | tmp &= ~(P2C_FORCE_SUSPENDM | P2C_RG_XCVRSEL); |
| 398 | tmp &= ~(P2C_RG_DATAIN | P2C_DTM0_PART_MASK); |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 399 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 400 | |
| 401 | /* OTG Enable */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 402 | tmp = readl(com + U3P_USBPHYACR6); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 403 | tmp |= PA6_RG_U2_OTG_VBUSCMP_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 404 | writel(tmp, com + U3P_USBPHYACR6); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 405 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 406 | tmp = readl(com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 407 | tmp |= P2C_RG_VBUSVALID | P2C_RG_AVALID; |
| 408 | tmp &= ~P2C_RG_SESSEND; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 409 | writel(tmp, com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 410 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 411 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 412 | tmp = readl(com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 413 | tmp |= P2C_RG_SIF_U2PLL_FORCE_ON; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 414 | writel(tmp, com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 415 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 416 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 417 | tmp |= P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 418 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 419 | } |
| 420 | dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); |
| 421 | } |
| 422 | |
| 423 | static void phy_instance_power_off(struct mt65xx_u3phy *u3phy, |
| 424 | struct mt65xx_phy_instance *instance) |
| 425 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 426 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 427 | void __iomem *com = u2_banks->com; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 428 | u32 index = instance->index; |
| 429 | u32 tmp; |
| 430 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 431 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 432 | tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN); |
| 433 | tmp |= P2C_FORCE_SUSPENDM; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 434 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 435 | |
| 436 | /* OTG Disable */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 437 | tmp = readl(com + U3P_USBPHYACR6); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 438 | tmp &= ~PA6_RG_U2_OTG_VBUSCMP_EN; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 439 | writel(tmp, com + U3P_USBPHYACR6); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 440 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 441 | /* let suspendm=0, set utmi into analog power down */ |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 442 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 443 | tmp &= ~P2C_RG_SUSPENDM; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 444 | writel(tmp, com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 445 | udelay(1); |
| 446 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 447 | tmp = readl(com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 448 | tmp &= ~(P2C_RG_VBUSVALID | P2C_RG_AVALID); |
| 449 | tmp |= P2C_RG_SESSEND; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 450 | writel(tmp, com + U3P_U2PHYDTM1); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 451 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 452 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 453 | tmp = readl(com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 454 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 455 | writel(tmp, com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | dev_dbg(u3phy->dev, "%s(%d)\n", __func__, index); |
| 459 | } |
| 460 | |
| 461 | static void phy_instance_exit(struct mt65xx_u3phy *u3phy, |
| 462 | struct mt65xx_phy_instance *instance) |
| 463 | { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 464 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 465 | void __iomem *com = u2_banks->com; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 466 | u32 index = instance->index; |
| 467 | u32 tmp; |
| 468 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 469 | if (u3phy->pdata->avoid_rx_sen_degradation && index) { |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 470 | tmp = readl(com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 471 | tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 472 | writel(tmp, com + U3D_U2PHYDCR0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 473 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 474 | tmp = readl(com + U3P_U2PHYDTM0); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 475 | tmp &= ~P2C_FORCE_SUSPENDM; |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 476 | writel(tmp, com + U3P_U2PHYDTM0); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | static void phy_v1_banks_init(struct mt65xx_u3phy *u3phy, |
| 481 | struct mt65xx_phy_instance *instance) |
| 482 | { |
| 483 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 484 | struct u3phy_banks *u3_banks = &instance->u3_banks; |
| 485 | |
| 486 | if (instance->type == PHY_TYPE_USB2) { |
| 487 | u2_banks->misc = NULL; |
| 488 | u2_banks->fmreg = u3phy->sif_base + SSUSB_SIFSLV_V1_U2FREQ; |
| 489 | u2_banks->com = instance->port_base + SSUSB_SIFSLV_V1_U2PHY_COM; |
| 490 | } else if (instance->type == PHY_TYPE_USB3) { |
| 491 | u3_banks->spllc = u3phy->sif_base + SSUSB_SIFSLV_V1_SPLLC; |
| 492 | u3_banks->chip = NULL; |
| 493 | u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V1_U3PHYD; |
| 494 | u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V1_U3PHYA; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | static void phy_v2_banks_init(struct mt65xx_u3phy *u3phy, |
| 499 | struct mt65xx_phy_instance *instance) |
| 500 | { |
| 501 | struct u2phy_banks *u2_banks = &instance->u2_banks; |
| 502 | struct u3phy_banks *u3_banks = &instance->u3_banks; |
| 503 | |
| 504 | if (instance->type == PHY_TYPE_USB2) { |
| 505 | u2_banks->misc = instance->port_base + SSUSB_SIFSLV_V2_MISC; |
| 506 | u2_banks->fmreg = instance->port_base + SSUSB_SIFSLV_V2_U2FREQ; |
| 507 | u2_banks->com = instance->port_base + SSUSB_SIFSLV_V2_U2PHY_COM; |
| 508 | } else if (instance->type == PHY_TYPE_USB3) { |
| 509 | u3_banks->spllc = instance->port_base + SSUSB_SIFSLV_V2_SPLLC; |
| 510 | u3_banks->chip = instance->port_base + SSUSB_SIFSLV_V2_CHIP; |
| 511 | u3_banks->phyd = instance->port_base + SSUSB_SIFSLV_V2_U3PHYD; |
| 512 | u3_banks->phya = instance->port_base + SSUSB_SIFSLV_V2_U3PHYA; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | |
| 516 | static int mt65xx_phy_init(struct phy *phy) |
| 517 | { |
| 518 | struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); |
| 519 | struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); |
| 520 | int ret; |
| 521 | |
| 522 | ret = clk_prepare_enable(u3phy->u3phya_ref); |
| 523 | if (ret) { |
| 524 | dev_err(u3phy->dev, "failed to enable u3phya_ref\n"); |
| 525 | return ret; |
| 526 | } |
| 527 | |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 528 | ret = clk_prepare_enable(instance->ref_clk); |
| 529 | if (ret) { |
| 530 | dev_err(u3phy->dev, "failed to enable ref_clk\n"); |
| 531 | return ret; |
| 532 | } |
| 533 | |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 534 | if (instance->type == PHY_TYPE_USB2) |
| 535 | phy_instance_init(u3phy, instance); |
| 536 | else |
| 537 | u3_phy_instance_init(u3phy, instance); |
| 538 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 539 | return 0; |
| 540 | } |
| 541 | |
| 542 | static int mt65xx_phy_power_on(struct phy *phy) |
| 543 | { |
| 544 | struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); |
| 545 | struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); |
| 546 | |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 547 | if (instance->type == PHY_TYPE_USB2) { |
| 548 | phy_instance_power_on(u3phy, instance); |
| 549 | hs_slew_rate_calibrate(u3phy, instance); |
| 550 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 551 | return 0; |
| 552 | } |
| 553 | |
| 554 | static int mt65xx_phy_power_off(struct phy *phy) |
| 555 | { |
| 556 | struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); |
| 557 | struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); |
| 558 | |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 559 | if (instance->type == PHY_TYPE_USB2) |
| 560 | phy_instance_power_off(u3phy, instance); |
| 561 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | static int mt65xx_phy_exit(struct phy *phy) |
| 566 | { |
| 567 | struct mt65xx_phy_instance *instance = phy_get_drvdata(phy); |
| 568 | struct mt65xx_u3phy *u3phy = dev_get_drvdata(phy->dev.parent); |
| 569 | |
Chunfeng Yun | 04466ef | 2017-03-31 15:35:29 +0800 | [diff] [blame] | 570 | if (instance->type == PHY_TYPE_USB2) |
| 571 | phy_instance_exit(u3phy, instance); |
| 572 | |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 573 | clk_disable_unprepare(instance->ref_clk); |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 574 | clk_disable_unprepare(u3phy->u3phya_ref); |
| 575 | return 0; |
| 576 | } |
| 577 | |
| 578 | static struct phy *mt65xx_phy_xlate(struct device *dev, |
| 579 | struct of_phandle_args *args) |
| 580 | { |
| 581 | struct mt65xx_u3phy *u3phy = dev_get_drvdata(dev); |
| 582 | struct mt65xx_phy_instance *instance = NULL; |
| 583 | struct device_node *phy_np = args->np; |
| 584 | int index; |
| 585 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 586 | if (args->args_count != 1) { |
| 587 | dev_err(dev, "invalid number of cells in 'phy' property\n"); |
| 588 | return ERR_PTR(-EINVAL); |
| 589 | } |
| 590 | |
| 591 | for (index = 0; index < u3phy->nphys; index++) |
| 592 | if (phy_np == u3phy->phys[index]->phy->dev.of_node) { |
| 593 | instance = u3phy->phys[index]; |
| 594 | break; |
| 595 | } |
| 596 | |
| 597 | if (!instance) { |
| 598 | dev_err(dev, "failed to find appropriate phy\n"); |
| 599 | return ERR_PTR(-EINVAL); |
| 600 | } |
| 601 | |
| 602 | instance->type = args->args[0]; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 603 | if (!(instance->type == PHY_TYPE_USB2 || |
| 604 | instance->type == PHY_TYPE_USB3)) { |
| 605 | dev_err(dev, "unsupported device type: %d\n", instance->type); |
| 606 | return ERR_PTR(-EINVAL); |
| 607 | } |
| 608 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 609 | if (u3phy->pdata->version == MT_PHY_V1) { |
| 610 | phy_v1_banks_init(u3phy, instance); |
| 611 | } else if (u3phy->pdata->version == MT_PHY_V2) { |
| 612 | phy_v2_banks_init(u3phy, instance); |
| 613 | } else { |
| 614 | dev_err(dev, "phy version is not supported\n"); |
| 615 | return ERR_PTR(-EINVAL); |
| 616 | } |
| 617 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 618 | return instance->phy; |
| 619 | } |
| 620 | |
Bhumika Goyal | a8df276 | 2017-01-08 16:05:56 +0530 | [diff] [blame] | 621 | static const struct phy_ops mt65xx_u3phy_ops = { |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 622 | .init = mt65xx_phy_init, |
| 623 | .exit = mt65xx_phy_exit, |
| 624 | .power_on = mt65xx_phy_power_on, |
| 625 | .power_off = mt65xx_phy_power_off, |
| 626 | .owner = THIS_MODULE, |
| 627 | }; |
| 628 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 629 | static const struct mt65xx_phy_pdata mt2701_pdata = { |
| 630 | .avoid_rx_sen_degradation = false, |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 631 | .version = MT_PHY_V1, |
| 632 | }; |
| 633 | |
| 634 | static const struct mt65xx_phy_pdata mt2712_pdata = { |
| 635 | .avoid_rx_sen_degradation = false, |
| 636 | .version = MT_PHY_V2, |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 637 | }; |
| 638 | |
| 639 | static const struct mt65xx_phy_pdata mt8173_pdata = { |
| 640 | .avoid_rx_sen_degradation = true, |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 641 | .version = MT_PHY_V1, |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 642 | }; |
| 643 | |
| 644 | static const struct of_device_id mt65xx_u3phy_id_table[] = { |
| 645 | { .compatible = "mediatek,mt2701-u3phy", .data = &mt2701_pdata }, |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 646 | { .compatible = "mediatek,mt2712-u3phy", .data = &mt2712_pdata }, |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 647 | { .compatible = "mediatek,mt8173-u3phy", .data = &mt8173_pdata }, |
| 648 | { }, |
| 649 | }; |
| 650 | MODULE_DEVICE_TABLE(of, mt65xx_u3phy_id_table); |
| 651 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 652 | static int mt65xx_u3phy_probe(struct platform_device *pdev) |
| 653 | { |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 654 | const struct of_device_id *match; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 655 | struct device *dev = &pdev->dev; |
| 656 | struct device_node *np = dev->of_node; |
| 657 | struct device_node *child_np; |
| 658 | struct phy_provider *provider; |
| 659 | struct resource *sif_res; |
| 660 | struct mt65xx_u3phy *u3phy; |
| 661 | struct resource res; |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 662 | int port, retval; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 663 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 664 | match = of_match_node(mt65xx_u3phy_id_table, pdev->dev.of_node); |
| 665 | if (!match) |
| 666 | return -EINVAL; |
| 667 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 668 | u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); |
| 669 | if (!u3phy) |
| 670 | return -ENOMEM; |
| 671 | |
Chunfeng Yun | e1d7653 | 2016-04-20 08:14:02 +0800 | [diff] [blame] | 672 | u3phy->pdata = match->data; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 673 | u3phy->nphys = of_get_child_count(np); |
| 674 | u3phy->phys = devm_kcalloc(dev, u3phy->nphys, |
| 675 | sizeof(*u3phy->phys), GFP_KERNEL); |
| 676 | if (!u3phy->phys) |
| 677 | return -ENOMEM; |
| 678 | |
| 679 | u3phy->dev = dev; |
| 680 | platform_set_drvdata(pdev, u3phy); |
| 681 | |
Chunfeng Yun | 8d6e195 | 2017-03-31 15:35:31 +0800 | [diff] [blame] | 682 | if (u3phy->pdata->version == MT_PHY_V1) { |
| 683 | /* get banks shared by multiple phys */ |
| 684 | sif_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 685 | u3phy->sif_base = devm_ioremap_resource(dev, sif_res); |
| 686 | if (IS_ERR(u3phy->sif_base)) { |
| 687 | dev_err(dev, "failed to remap sif regs\n"); |
| 688 | return PTR_ERR(u3phy->sif_base); |
| 689 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 690 | } |
| 691 | |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 692 | /* it's deprecated, make it optional for backward compatibility */ |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 693 | u3phy->u3phya_ref = devm_clk_get(dev, "u3phya_ref"); |
| 694 | if (IS_ERR(u3phy->u3phya_ref)) { |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 695 | if (PTR_ERR(u3phy->u3phya_ref) == -EPROBE_DEFER) |
| 696 | return -EPROBE_DEFER; |
| 697 | |
| 698 | u3phy->u3phya_ref = NULL; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | port = 0; |
| 702 | for_each_child_of_node(np, child_np) { |
| 703 | struct mt65xx_phy_instance *instance; |
| 704 | struct phy *phy; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 705 | |
| 706 | instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 707 | if (!instance) { |
| 708 | retval = -ENOMEM; |
| 709 | goto put_child; |
| 710 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 711 | |
| 712 | u3phy->phys[port] = instance; |
| 713 | |
| 714 | phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); |
| 715 | if (IS_ERR(phy)) { |
| 716 | dev_err(dev, "failed to create phy\n"); |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 717 | retval = PTR_ERR(phy); |
| 718 | goto put_child; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 719 | } |
| 720 | |
| 721 | retval = of_address_to_resource(child_np, 0, &res); |
| 722 | if (retval) { |
| 723 | dev_err(dev, "failed to get address resource(id-%d)\n", |
| 724 | port); |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 725 | goto put_child; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | instance->port_base = devm_ioremap_resource(&phy->dev, &res); |
| 729 | if (IS_ERR(instance->port_base)) { |
| 730 | dev_err(dev, "failed to remap phy regs\n"); |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 731 | retval = PTR_ERR(instance->port_base); |
| 732 | goto put_child; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | instance->phy = phy; |
| 736 | instance->index = port; |
| 737 | phy_set_drvdata(phy, instance); |
| 738 | port++; |
Chunfeng Yun | 15de15c | 2017-03-31 15:35:30 +0800 | [diff] [blame] | 739 | |
| 740 | /* if deprecated clock is provided, ignore instance's one */ |
| 741 | if (u3phy->u3phya_ref) |
| 742 | continue; |
| 743 | |
| 744 | instance->ref_clk = devm_clk_get(&phy->dev, "ref"); |
| 745 | if (IS_ERR(instance->ref_clk)) { |
| 746 | dev_err(dev, "failed to get ref_clk(id-%d)\n", port); |
| 747 | retval = PTR_ERR(instance->ref_clk); |
| 748 | goto put_child; |
| 749 | } |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); |
| 753 | |
| 754 | return PTR_ERR_OR_ZERO(provider); |
Julia Lawall | 2bb80cc | 2015-11-16 12:33:15 +0100 | [diff] [blame] | 755 | put_child: |
| 756 | of_node_put(child_np); |
| 757 | return retval; |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 758 | } |
| 759 | |
Chunfeng Yun | dc7f190 | 2015-09-29 11:01:36 +0800 | [diff] [blame] | 760 | static struct platform_driver mt65xx_u3phy_driver = { |
| 761 | .probe = mt65xx_u3phy_probe, |
| 762 | .driver = { |
| 763 | .name = "mt65xx-u3phy", |
| 764 | .of_match_table = mt65xx_u3phy_id_table, |
| 765 | }, |
| 766 | }; |
| 767 | |
| 768 | module_platform_driver(mt65xx_u3phy_driver); |
| 769 | |
| 770 | MODULE_AUTHOR("Chunfeng Yun <chunfeng.yun@mediatek.com>"); |
| 771 | MODULE_DESCRIPTION("mt65xx USB PHY driver"); |
| 772 | MODULE_LICENSE("GPL v2"); |