| 1 |
// SPDX-License-Identifier: GPL-2.0-only |
| 2 |
/* |
| 3 |
* Samsung Exynos5 SoC series USB DRD PHY driver |
| 4 |
* |
| 5 |
* Phy provider for USB 3.0 DRD controller on Exynos5 SoC series |
| 6 |
* |
| 7 |
* Copyright (C) 2014 Samsung Electronics Co., Ltd. |
| 8 |
* Author: Vivek Gautam <[email protected]> |
| 9 |
*/ |
| 10 |
|
| 11 |
#include <linux/bitfield.h> |
| 12 |
#include <linux/clk.h> |
| 13 |
#include <linux/delay.h> |
| 14 |
#include <linux/io.h> |
| 15 |
#include <linux/kernel.h> |
| 16 |
#include <linux/module.h> |
| 17 |
#include <linux/of.h> |
| 18 |
#include <linux/iopoll.h> |
| 19 |
#include <linux/phy/phy.h> |
| 20 |
#include <linux/platform_device.h> |
| 21 |
#include <linux/mutex.h> |
| 22 |
#include <linux/mfd/syscon.h> |
| 23 |
#include <linux/regmap.h> |
| 24 |
#include <linux/regulator/consumer.h> |
| 25 |
#include <linux/soc/samsung/exynos-regs-pmu.h> |
| 26 |
#include <linux/usb/typec.h> |
| 27 |
#include <linux/usb/typec_mux.h> |
| 28 |
|
| 29 |
/* Exynos USB PHY registers */ |
| 30 |
#define EXYNOS5_FSEL_9MHZ6 0x0 |
| 31 |
#define EXYNOS5_FSEL_10MHZ 0x1 |
| 32 |
#define EXYNOS5_FSEL_12MHZ 0x2 |
| 33 |
#define EXYNOS5_FSEL_19MHZ2 0x3 |
| 34 |
#define EXYNOS5_FSEL_20MHZ 0x4 |
| 35 |
#define EXYNOS5_FSEL_24MHZ 0x5 |
| 36 |
#define EXYNOS5_FSEL_26MHZ 0x6 |
| 37 |
#define EXYNOS5_FSEL_50MHZ 0x7 |
| 38 |
|
| 39 |
/* USB 3.2 DRD 4nm PHY link controller registers */ |
| 40 |
#define EXYNOS2200_DRD_CLKRST 0x0c |
| 41 |
#define EXYNOS2200_CLKRST_LINK_PCLK_SEL BIT(1) |
| 42 |
|
| 43 |
#define EXYNOS2200_DRD_UTMI 0x10 |
| 44 |
|
| 45 |
/* ExynosAutov920 bits */ |
| 46 |
#define UTMICTL_FORCE_UTMI_SUSPEND BIT(13) |
| 47 |
#define UTMICTL_FORCE_UTMI_SLEEP BIT(12) |
| 48 |
#define UTMICTL_FORCE_DPPULLDOWN BIT(9) |
| 49 |
#define UTMICTL_FORCE_DMPULLDOWN BIT(8) |
| 50 |
|
| 51 |
#define EXYNOS2200_UTMI_FORCE_VBUSVALID BIT(1) |
| 52 |
#define EXYNOS2200_UTMI_FORCE_BVALID BIT(0) |
| 53 |
|
| 54 |
#define EXYNOS2200_DRD_HSP_MISC 0x114 |
| 55 |
#define HSP_MISC_SET_REQ_IN2 BIT(4) |
| 56 |
#define HSP_MISC_RES_TUNE GENMASK(1, 0) |
| 57 |
#define RES_TUNE_PHY1_PHY2 0x1 |
| 58 |
#define RES_TUNE_PHY1 0x2 |
| 59 |
#define RES_TUNE_PHY2 0x3 |
| 60 |
|
| 61 |
/* Exynos5: USB 3.0 DRD PHY registers */ |
| 62 |
#define EXYNOS5_DRD_LINKSYSTEM 0x04 |
| 63 |
#define LINKSYSTEM_XHCI_VERSION_CONTROL BIT(27) |
| 64 |
#define LINKSYSTEM_FORCE_VBUSVALID BIT(8) |
| 65 |
#define LINKSYSTEM_FORCE_BVALID BIT(7) |
| 66 |
#define LINKSYSTEM_FLADJ GENMASK(6, 1) |
| 67 |
|
| 68 |
#define EXYNOS5_DRD_PHYUTMI 0x08 |
| 69 |
#define PHYUTMI_UTMI_SUSPEND_COM_N BIT(12) |
| 70 |
#define PHYUTMI_UTMI_L1_SUSPEND_COM_N BIT(11) |
| 71 |
#define PHYUTMI_VBUSVLDEXTSEL BIT(10) |
| 72 |
#define PHYUTMI_VBUSVLDEXT BIT(9) |
| 73 |
#define PHYUTMI_TXBITSTUFFENH BIT(8) |
| 74 |
#define PHYUTMI_TXBITSTUFFEN BIT(7) |
| 75 |
#define PHYUTMI_OTGDISABLE BIT(6) |
| 76 |
#define PHYUTMI_IDPULLUP BIT(5) |
| 77 |
#define PHYUTMI_DRVVBUS BIT(4) |
| 78 |
#define PHYUTMI_DPPULLDOWN BIT(3) |
| 79 |
#define PHYUTMI_DMPULLDOWN BIT(2) |
| 80 |
#define PHYUTMI_FORCESUSPEND BIT(1) |
| 81 |
#define PHYUTMI_FORCESLEEP BIT(0) |
| 82 |
|
| 83 |
#define EXYNOS5_DRD_PHYPIPE 0x0c |
| 84 |
|
| 85 |
#define EXYNOS5_DRD_PHYCLKRST 0x10 |
| 86 |
#define PHYCLKRST_EN_UTMISUSPEND BIT(31) |
| 87 |
#define PHYCLKRST_SSC_REFCLKSEL GENMASK(30, 23) |
| 88 |
#define PHYCLKRST_SSC_RANGE GENMASK(22, 21) |
| 89 |
#define PHYCLKRST_SSC_EN BIT(20) |
| 90 |
#define PHYCLKRST_REF_SSP_EN BIT(19) |
| 91 |
#define PHYCLKRST_REF_CLKDIV2 BIT(18) |
| 92 |
#define PHYCLKRST_MPLL_MULTIPLIER GENMASK(17, 11) |
| 93 |
#define PHYCLKRST_MPLL_MULTIPLIER_100MHZ_REF 0x19 |
| 94 |
#define PHYCLKRST_MPLL_MULTIPLIER_50M_REF 0x32 |
| 95 |
#define PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF 0x68 |
| 96 |
#define PHYCLKRST_MPLL_MULTIPLIER_20MHZ_REF 0x7d |
| 97 |
#define PHYCLKRST_MPLL_MULTIPLIER_19200KHZ_REF 0x02 |
| 98 |
#define PHYCLKRST_FSEL_PIPE GENMASK(10, 8) |
| 99 |
#define PHYCLKRST_FSEL_UTMI GENMASK(7, 5) |
| 100 |
#define PHYCLKRST_FSEL_PAD_100MHZ 0x27 |
| 101 |
#define PHYCLKRST_FSEL_PAD_24MHZ 0x2a |
| 102 |
#define PHYCLKRST_FSEL_PAD_20MHZ 0x31 |
| 103 |
#define PHYCLKRST_FSEL_PAD_19_2MHZ 0x38 |
| 104 |
#define PHYCLKRST_RETENABLEN BIT(4) |
| 105 |
#define PHYCLKRST_REFCLKSEL GENMASK(3, 2) |
| 106 |
#define PHYCLKRST_REFCLKSEL_PAD_REFCLK 0x2 |
| 107 |
#define PHYCLKRST_REFCLKSEL_EXT_REFCLK 0x3 |
| 108 |
#define PHYCLKRST_PORTRESET BIT(1) |
| 109 |
#define PHYCLKRST_COMMONONN BIT(0) |
| 110 |
|
| 111 |
#define EXYNOS5_DRD_PHYREG0 0x14 |
| 112 |
#define PHYREG0_SSC_REF_CLK_SEL BIT(21) |
| 113 |
#define PHYREG0_SSC_RANGE BIT(20) |
| 114 |
#define PHYREG0_CR_WRITE BIT(19) |
| 115 |
#define PHYREG0_CR_READ BIT(18) |
| 116 |
#define PHYREG0_CR_DATA_IN GENMASK(17, 2) |
| 117 |
#define PHYREG0_CR_CAP_DATA BIT(1) |
| 118 |
#define PHYREG0_CR_CAP_ADDR BIT(0) |
| 119 |
|
| 120 |
#define EXYNOS5_DRD_PHYREG1 0x18 |
| 121 |
#define PHYREG0_CR_DATA_OUT GENMASK(16, 1) |
| 122 |
#define PHYREG1_CR_ACK BIT(0) |
| 123 |
|
| 124 |
#define EXYNOS5_DRD_PHYPARAM0 0x1c |
| 125 |
#define PHYPARAM0_REF_USE_PAD BIT(31) |
| 126 |
#define PHYPARAM0_REF_LOSLEVEL GENMASK(30, 26) |
| 127 |
#define PHYPARAM0_REF_LOSLEVEL_VAL 0x9 |
| 128 |
#define PHYPARAM0_TXVREFTUNE GENMASK(25, 22) |
| 129 |
#define PHYPARAM0_TXRISETUNE GENMASK(21, 20) |
| 130 |
#define PHYPARAM0_TXRESTUNE GENMASK(19, 18) |
| 131 |
#define PHYPARAM0_TXPREEMPPULSETUNE BIT(17) |
| 132 |
#define PHYPARAM0_TXPREEMPAMPTUNE GENMASK(16, 15) |
| 133 |
#define PHYPARAM0_TXHSXVTUNE GENMASK(14, 13) |
| 134 |
#define PHYPARAM0_TXFSLSTUNE GENMASK(12, 9) |
| 135 |
#define PHYPARAM0_SQRXTUNE GENMASK(8, 6) |
| 136 |
#define PHYPARAM0_OTGTUNE GENMASK(5, 3) |
| 137 |
#define PHYPARAM0_COMPDISTUNE GENMASK(2, 0) |
| 138 |
|
| 139 |
#define EXYNOS5_DRD_PHYPARAM1 0x20 |
| 140 |
#define PHYPARAM1_PCS_TXDEEMPH GENMASK(4, 0) |
| 141 |
#define PHYPARAM1_PCS_TXDEEMPH_VAL 0x1c |
| 142 |
|
| 143 |
#define EXYNOS5_DRD_PHYTERM 0x24 |
| 144 |
|
| 145 |
#define EXYNOS5_DRD_PHYTEST 0x28 |
| 146 |
#define PHYTEST_POWERDOWN_SSP BIT(3) |
| 147 |
#define PHYTEST_POWERDOWN_HSP BIT(2) |
| 148 |
|
| 149 |
#define EXYNOS5_DRD_PHYADP 0x2c |
| 150 |
|
| 151 |
#define EXYNOS5_DRD_PHYUTMICLKSEL 0x30 |
| 152 |
#define PHYUTMICLKSEL_UTMI_CLKSEL BIT(2) |
| 153 |
|
| 154 |
#define EXYNOS5_DRD_PHYRESUME 0x34 |
| 155 |
|
| 156 |
#define EXYNOS5_DRD_LINKPORT 0x44 |
| 157 |
#define LINKPORT_HOST_U3_PORT_DISABLE BIT(8) |
| 158 |
#define LINKPORT_HOST_U2_PORT_DISABLE BIT(7) |
| 159 |
#define LINKPORT_HOST_PORT_OVCR_U3 BIT(5) |
| 160 |
#define LINKPORT_HOST_PORT_OVCR_U2 BIT(4) |
| 161 |
#define LINKPORT_HOST_PORT_OVCR_U3_SEL BIT(3) |
| 162 |
#define LINKPORT_HOST_PORT_OVCR_U2_SEL BIT(2) |
| 163 |
|
| 164 |
/* USB 3.0 DRD PHY SS Function Control Reg; accessed by CR_PORT */ |
| 165 |
#define EXYNOS5_DRD_PHYSS_LOSLEVEL_OVRD_IN (0x15) |
| 166 |
#define LOSLEVEL_OVRD_IN_LOS_BIAS_5420 (0x5 << 13) |
| 167 |
#define LOSLEVEL_OVRD_IN_LOS_BIAS_DEFAULT (0x0 << 13) |
| 168 |
#define LOSLEVEL_OVRD_IN_EN (0x1 << 10) |
| 169 |
#define LOSLEVEL_OVRD_IN_LOS_LEVEL_DEFAULT (0x9 << 0) |
| 170 |
|
| 171 |
#define EXYNOS5_DRD_PHYSS_TX_VBOOSTLEVEL_OVRD_IN (0x12) |
| 172 |
#define TX_VBOOSTLEVEL_OVRD_IN_VBOOST_5420 (0x5 << 13) |
| 173 |
#define TX_VBOOSTLEVEL_OVRD_IN_VBOOST_DEFAULT (0x4 << 13) |
| 174 |
|
| 175 |
#define EXYNOS5_DRD_PHYSS_LANE0_TX_DEBUG (0x1010) |
| 176 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_19M2_20M (0x4 << 4) |
| 177 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_24M (0x8 << 4) |
| 178 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_25M_26M (0x8 << 4) |
| 179 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_48M_50M_52M (0x20 << 4) |
| 180 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_62M5 (0x20 << 4) |
| 181 |
#define LANE0_TX_DEBUG_RXDET_MEAS_TIME_96M_100M (0x40 << 4) |
| 182 |
|
| 183 |
/* Exynos7870: USB DRD PHY registers */ |
| 184 |
#define EXYNOS7870_DRD_PHYPCSVAL 0x3C |
| 185 |
#define PHYPCSVAL_PCS_RX_LOS_MASK GENMASK(9, 0) |
| 186 |
|
| 187 |
#define EXYNOS7870_DRD_PHYPARAM2 0x50 |
| 188 |
#define PHYPARAM2_TX_VBOOST_LVL GENMASK(6, 4) |
| 189 |
#define PHYPARAM2_LOS_BIAS GENMASK(2, 0) |
| 190 |
|
| 191 |
#define EXYNOS7870_DRD_HSPHYCTRL 0x54 |
| 192 |
#define HSPHYCTRL_PHYSWRSTALL BIT(31) |
| 193 |
#define HSPHYCTRL_SIDDQ BIT(6) |
| 194 |
#define HSPHYCTRL_PHYSWRST BIT(0) |
| 195 |
|
| 196 |
#define EXYNOS7870_DRD_HSPHYPLLTUNE 0x70 |
| 197 |
#define HSPHYPLLTUNE_PLL_B_TUNE BIT(6) |
| 198 |
#define HSPHYPLLTUNE_PLL_I_TUNE GENMASK(5, 4) |
| 199 |
#define HSPHYPLLTUNE_PLL_P_TUNE GENMASK(3, 0) |
| 200 |
|
| 201 |
/* Exynos850: USB DRD PHY registers */ |
| 202 |
#define EXYNOS850_DRD_LINKCTRL 0x04 |
| 203 |
#define LINKCTRL_FORCE_RXELECIDLE BIT(18) |
| 204 |
#define LINKCTRL_FORCE_PHYSTATUS BIT(17) |
| 205 |
#define LINKCTRL_FORCE_PIPE_EN BIT(16) |
| 206 |
#define LINKCTRL_FORCE_QACT BIT(8) |
| 207 |
#define LINKCTRL_BUS_FILTER_BYPASS GENMASK(7, 4) |
| 208 |
|
| 209 |
#define EXYNOS850_DRD_LINKPORT 0x08 |
| 210 |
#define LINKPORT_HOST_NUM_U3 GENMASK(19, 16) |
| 211 |
#define LINKPORT_HOST_NUM_U2 GENMASK(15, 12) |
| 212 |
|
| 213 |
#define EXYNOS850_DRD_CLKRST 0x20 |
| 214 |
/* |
| 215 |
* On versions without SS ports (like E850), bit 3 is for the 2.0 phy (HS), |
| 216 |
* while on versions with (like gs101), bits 2 and 3 are for the 3.0 phy (SS) |
| 217 |
* and bits 12 & 13 for the 2.0 phy. |
| 218 |
*/ |
| 219 |
#define CLKRST_PHY20_SW_POR BIT(13) |
| 220 |
#define CLKRST_PHY20_SW_POR_SEL BIT(12) |
| 221 |
#define CLKRST_LINK_PCLK_SEL BIT(7) |
| 222 |
#define CLKRST_PHY_SW_RST BIT(3) |
| 223 |
#define CLKRST_PHY_RESET_SEL BIT(2) |
| 224 |
#define CLKRST_PORT_RST BIT(1) |
| 225 |
#define CLKRST_LINK_SW_RST BIT(0) |
| 226 |
|
| 227 |
#define EXYNOS850_DRD_SSPPLLCTL 0x30 |
| 228 |
#define SSPPLLCTL_FSEL GENMASK(2, 0) |
| 229 |
|
| 230 |
#define EXYNOS850_DRD_UTMI 0x50 |
| 231 |
#define UTMI_FORCE_VBUSVALID BIT(5) |
| 232 |
#define UTMI_FORCE_BVALID BIT(4) |
| 233 |
#define UTMI_DP_PULLDOWN BIT(3) |
| 234 |
#define UTMI_DM_PULLDOWN BIT(2) |
| 235 |
#define UTMI_FORCE_SUSPEND BIT(1) |
| 236 |
#define UTMI_FORCE_SLEEP BIT(0) |
| 237 |
|
| 238 |
#define EXYNOS850_DRD_HSP 0x54 |
| 239 |
#define HSP_FSV_OUT_EN BIT(24) |
| 240 |
#define HSP_VBUSVLDEXTSEL BIT(13) |
| 241 |
#define HSP_VBUSVLDEXT BIT(12) |
| 242 |
#define HSP_EN_UTMISUSPEND BIT(9) |
| 243 |
#define HSP_COMMONONN BIT(8) |
| 244 |
|
| 245 |
#define EXYNOS850_DRD_HSPPARACON 0x58 |
| 246 |
#define HSPPARACON_TXVREF GENMASK(31, 28) |
| 247 |
#define HSPPARACON_TXRISE GENMASK(25, 24) |
| 248 |
#define HSPPARACON_TXRES GENMASK(22, 21) |
| 249 |
#define HSPPARACON_TXPREEMPPULSE BIT(20) |
| 250 |
#define HSPPARACON_TXPREEMPAMP GENMASK(19, 18) |
| 251 |
#define HSPPARACON_TXHSXV GENMASK(17, 16) |
| 252 |
#define HSPPARACON_TXFSLS GENMASK(15, 12) |
| 253 |
#define HSPPARACON_SQRX GENMASK(10, 8) |
| 254 |
#define HSPPARACON_OTG GENMASK(6, 4) |
| 255 |
#define HSPPARACON_COMPDIS GENMASK(2, 0) |
| 256 |
|
| 257 |
#define EXYNOS850_DRD_HSP_TEST 0x5c |
| 258 |
#define HSP_TEST_SIDDQ BIT(24) |
| 259 |
|
| 260 |
#define EXYNOSAUTOV920_DRD_HSP_CLKRST 0x100 |
| 261 |
#define HSPCLKRST_PHY20_SW_PORTRESET BIT(3) |
| 262 |
#define HSPCLKRST_PHY20_SW_POR BIT(1) |
| 263 |
#define HSPCLKRST_PHY20_SW_POR_SEL BIT(0) |
| 264 |
|
| 265 |
#define EXYNOSAUTOV920_DRD_HSPCTL 0x104 |
| 266 |
#define HSPCTRL_VBUSVLDEXTSEL BIT(13) |
| 267 |
#define HSPCTRL_VBUSVLDEXT BIT(12) |
| 268 |
#define HSPCTRL_EN_UTMISUSPEND BIT(9) |
| 269 |
#define HSPCTRL_COMMONONN BIT(8) |
| 270 |
|
| 271 |
#define EXYNOSAUTOV920_DRD_HSP_TEST 0x10c |
| 272 |
|
| 273 |
#define EXYNOSAUTOV920_DRD_HSPPLLTUNE 0x110 |
| 274 |
#define HSPPLLTUNE_FSEL GENMASK(18, 16) |
| 275 |
|
| 276 |
/* ExynosAutov920 phy usb31drd port reg */ |
| 277 |
#define EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL 0x000 |
| 278 |
#define PHY_RST_CTRL_PIPE_LANE0_RESET_N_OVRD_EN BIT(5) |
| 279 |
#define PHY_RST_CTRL_PIPE_LANE0_RESET_N BIT(4) |
| 280 |
#define PHY_RST_CTRL_PHY_RESET_OVRD_EN BIT(1) |
| 281 |
#define PHY_RST_CTRL_PHY_RESET BIT(0) |
| 282 |
|
| 283 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0 0x0004 |
| 284 |
#define PHY_CR_PARA_CON0_PHY0_CR_PARA_ADDR GENMASK(31, 16) |
| 285 |
#define PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK BIT(8) |
| 286 |
#define PHY_CR_PARA_CON0_PHY0_CR_PARA_ACK BIT(4) |
| 287 |
#define PHY_CR_PARA_CON0_PHY0_CR_PARA_SEL BIT(0) |
| 288 |
|
| 289 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON1 0x0008 |
| 290 |
|
| 291 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON2 0x000c |
| 292 |
#define PHY_CR_PARA_CON2_PHY0_CR_PARA_WR_EN BIT(0) |
| 293 |
#define PHY_CR_PARA_CON2_PHY0_CR_PARA_WR_DATA GENMASK(31, 16) |
| 294 |
|
| 295 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CONFIG0 0x100 |
| 296 |
#define PHY_CONFIG0_PHY0_PMA_PWR_STABLE BIT(14) |
| 297 |
#define PHY_CONFIG0_PHY0_PCS_PWR_STABLE BIT(13) |
| 298 |
#define PHY_CONFIG0_PHY0_ANA_PWR_EN BIT(1) |
| 299 |
|
| 300 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CONFIG7 0x11c |
| 301 |
#define PHY_CONFIG7_PHY_TEST_POWERDOWN BIT(24) |
| 302 |
|
| 303 |
#define EXYNOSAUTOV920_USB31DRD_PHY_CONFIG4 0x110 |
| 304 |
#define PHY_CONFIG4_PIPE_RX0_SRIS_MODE_EN BIT(2) |
| 305 |
|
| 306 |
/* Exynos9 - GS101 */ |
| 307 |
#define EXYNOS850_DRD_SECPMACTL 0x48 |
| 308 |
#define SECPMACTL_PMA_ROPLL_REF_CLK_SEL GENMASK(13, 12) |
| 309 |
#define SECPMACTL_PMA_LCPLL_REF_CLK_SEL GENMASK(11, 10) |
| 310 |
#define SECPMACTL_PMA_REF_FREQ_SEL GENMASK(9, 8) |
| 311 |
#define SECPMACTL_PMA_LOW_PWR BIT(4) |
| 312 |
#define SECPMACTL_PMA_TRSV_SW_RST BIT(3) |
| 313 |
#define SECPMACTL_PMA_CMN_SW_RST BIT(2) |
| 314 |
#define SECPMACTL_PMA_INIT_SW_RST BIT(1) |
| 315 |
#define SECPMACTL_PMA_APB_SW_RST BIT(0) |
| 316 |
|
| 317 |
/* PMA registers */ |
| 318 |
#define EXYNOS9_PMA_USBDP_CMN_REG0008 0x0020 |
| 319 |
#define CMN_REG0008_OVRD_AUX_EN BIT(3) |
| 320 |
#define CMN_REG0008_AUX_EN BIT(2) |
| 321 |
|
| 322 |
#define EXYNOS9_PMA_USBDP_CMN_REG00B8 0x02e0 |
| 323 |
#define CMN_REG00B8_LANE_MUX_SEL_DP GENMASK(3, 0) |
| 324 |
#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE3 BIT(3) |
| 325 |
#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE2 BIT(2) |
| 326 |
#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE1 BIT(1) |
| 327 |
#define CMN_REG00B8_LANE_MUX_SEL_DP_LANE0 BIT(0) |
| 328 |
|
| 329 |
#define EXYNOS9_PMA_USBDP_CMN_REG01C0 0x0700 |
| 330 |
#define CMN_REG01C0_ANA_LCPLL_LOCK_DONE BIT(7) |
| 331 |
#define CMN_REG01C0_ANA_LCPLL_AFC_DONE BIT(6) |
| 332 |
|
| 333 |
/* these have similar register layout, for lanes 0 and 2 */ |
| 334 |
#define EXYNOS9_PMA_USBDP_TRSV_REG03C3 0x0f0c |
| 335 |
#define EXYNOS9_PMA_USBDP_TRSV_REG07C3 0x1f0c |
| 336 |
#define TRSV_REG03C3_LN0_MON_RX_CDR_AFC_DONE BIT(3) |
| 337 |
#define TRSV_REG03C3_LN0_MON_RX_CDR_CAL_DONE BIT(2) |
| 338 |
#define TRSV_REG03C3_LN0_MON_RX_CDR_FLD_PLL_MODE_DONE BIT(1) |
| 339 |
#define TRSV_REG03C3_LN0_MON_RX_CDR_LOCK_DONE BIT(0) |
| 340 |
|
| 341 |
/* TRSV_REG0413 and TRSV_REG0813 have similar register layout */ |
| 342 |
#define EXYNOS9_PMA_USBDP_TRSV_REG0413 0x104c |
| 343 |
#define TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN BIT(7) |
| 344 |
#define TRSV_REG0413_OVRD_LN1_TX_RXD_EN BIT(5) |
| 345 |
|
| 346 |
#define EXYNOS9_PMA_USBDP_TRSV_REG0813 0x204c |
| 347 |
#define TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN BIT(7) |
| 348 |
#define TRSV_REG0813_OVRD_LN3_TX_RXD_EN BIT(5) |
| 349 |
|
| 350 |
/* PCS registers */ |
| 351 |
#define EXYNOS9_PCS_NS_VEC_PS1_N1 0x010c |
| 352 |
#define EXYNOS9_PCS_NS_VEC_PS2_N0 0x0110 |
| 353 |
#define EXYNOS9_PCS_NS_VEC_PS3_N0 0x0118 |
| 354 |
#define NS_VEC_NS_REQ GENMASK(31, 24) |
| 355 |
#define NS_VEC_ENABLE_TIMER BIT(22) |
| 356 |
#define NS_VEC_SEL_TIMEOUT GENMASK(21, 20) |
| 357 |
#define NS_VEC_INV_MASK GENMASK(19, 16) |
| 358 |
#define NS_VEC_COND_MASK GENMASK(11, 8) |
| 359 |
#define NS_VEC_EXP_COND GENMASK(3, 0) |
| 360 |
|
| 361 |
#define EXYNOS9_PCS_OUT_VEC_2 0x014c |
| 362 |
#define EXYNOS9_PCS_OUT_VEC_3 0x0150 |
| 363 |
#define PCS_OUT_VEC_B9_DYNAMIC BIT(19) |
| 364 |
#define PCS_OUT_VEC_B9_SEL_OUT BIT(18) |
| 365 |
#define PCS_OUT_VEC_B8_DYNAMIC BIT(17) |
| 366 |
#define PCS_OUT_VEC_B8_SEL_OUT BIT(16) |
| 367 |
#define PCS_OUT_VEC_B7_DYNAMIC BIT(15) |
| 368 |
#define PCS_OUT_VEC_B7_SEL_OUT BIT(14) |
| 369 |
#define PCS_OUT_VEC_B6_DYNAMIC BIT(13) |
| 370 |
#define PCS_OUT_VEC_B6_SEL_OUT BIT(12) |
| 371 |
#define PCS_OUT_VEC_B5_DYNAMIC BIT(11) |
| 372 |
#define PCS_OUT_VEC_B5_SEL_OUT BIT(10) |
| 373 |
#define PCS_OUT_VEC_B4_DYNAMIC BIT(9) |
| 374 |
#define PCS_OUT_VEC_B4_SEL_OUT BIT(8) |
| 375 |
#define PCS_OUT_VEC_B3_DYNAMIC BIT(7) |
| 376 |
#define PCS_OUT_VEC_B3_SEL_OUT BIT(6) |
| 377 |
#define PCS_OUT_VEC_B2_DYNAMIC BIT(5) |
| 378 |
#define PCS_OUT_VEC_B2_SEL_OUT BIT(4) |
| 379 |
#define PCS_OUT_VEC_B1_DYNAMIC BIT(3) |
| 380 |
#define PCS_OUT_VEC_B1_SEL_OUT BIT(2) |
| 381 |
#define PCS_OUT_VEC_B0_DYNAMIC BIT(1) |
| 382 |
#define PCS_OUT_VEC_B0_SEL_OUT BIT(0) |
| 383 |
|
| 384 |
#define EXYNOS9_PCS_TIMEOUT_0 0x0170 |
| 385 |
|
| 386 |
#define EXYNOS9_PCS_TIMEOUT_3 0x017c |
| 387 |
|
| 388 |
#define EXYNOS9_PCS_EBUF_PARAM 0x0304 |
| 389 |
#define EBUF_PARAM_SKP_REMOVE_TH_EMPTY_MODE GENMASK(29, 24) |
| 390 |
|
| 391 |
#define EXYNOS9_PCS_BACK_END_MODE_VEC 0x030c |
| 392 |
#define BACK_END_MODE_VEC_FORCE_EBUF_EMPTY_MODE BIT(1) |
| 393 |
#define BACK_END_MODE_VEC_DISABLE_DATA_MASK BIT(0) |
| 394 |
|
| 395 |
#define EXYNOS9_PCS_RX_CONTROL 0x03f0 |
| 396 |
#define RX_CONTROL_EN_BLOCK_ALIGNER_TYPE_B BIT(22) |
| 397 |
|
| 398 |
#define EXYNOS9_PCS_RX_CONTROL_DEBUG 0x03f4 |
| 399 |
#define RX_CONTROL_DEBUG_EN_TS_CHECK BIT(5) |
| 400 |
#define RX_CONTROL_DEBUG_NUM_COM_FOUND GENMASK(3, 0) |
| 401 |
|
| 402 |
#define EXYNOS9_PCS_LOCAL_COEF 0x040c |
| 403 |
#define LOCAL_COEF_PMA_CENTER_COEF GENMASK(21, 16) |
| 404 |
#define LOCAL_COEF_LF GENMASK(13, 8) |
| 405 |
#define LOCAL_COEF_FS GENMASK(5, 0) |
| 406 |
|
| 407 |
#define EXYNOS9_PCS_HS_TX_COEF_MAP_0 0x0410 |
| 408 |
#define HS_TX_COEF_MAP_0_SSTX_DEEMP GENMASK(17, 12) |
| 409 |
#define HS_TX_COEF_MAP_0_SSTX_LEVEL GENMASK(11, 6) |
| 410 |
#define HS_TX_COEF_MAP_0_SSTX_PRE_SHOOT GENMASK(5, 0) |
| 411 |
|
| 412 |
|
| 413 |
#define KHZ 1000 |
| 414 |
#define MHZ (KHZ * KHZ) |
| 415 |
|
| 416 |
#define PHY_TUNING_ENTRY_PHY(o, m, v) { \ |
| 417 |
.off = (o), \ |
| 418 |
.mask = (m), \ |
| 419 |
.val = (v), \ |
| 420 |
.region = PTR_PHY \ |
| 421 |
} |
| 422 |
|
| 423 |
#define PHY_TUNING_ENTRY_PCS(o, m, v) { \ |
| 424 |
.off = (o), \ |
| 425 |
.mask = (m), \ |
| 426 |
.val = (v), \ |
| 427 |
.region = PTR_PCS \ |
| 428 |
} |
| 429 |
|
| 430 |
#define PHY_TUNING_ENTRY_PMA(o, m, v) { \ |
| 431 |
.off = (o), \ |
| 432 |
.mask = (m), \ |
| 433 |
.val = (v), \ |
| 434 |
.region = PTR_PMA, \ |
| 435 |
} |
| 436 |
|
| 437 |
#define PHY_TUNING_ENTRY_LAST { .region = PTR_INVALID } |
| 438 |
|
| 439 |
#define for_each_phy_tune(tune) \ |
| 440 |
for (; (tune)->region != PTR_INVALID; ++(tune)) |
| 441 |
|
| 442 |
struct exynos5_usbdrd_phy_tuning { |
| 443 |
u32 off; |
| 444 |
u32 mask; |
| 445 |
u32 val; |
| 446 |
char region; |
| 447 |
#define PTR_INVALID 0 |
| 448 |
#define PTR_PHY 1 |
| 449 |
#define PTR_PCS 2 |
| 450 |
#define PTR_PMA 3 |
| 451 |
}; |
| 452 |
|
| 453 |
enum exynos5_usbdrd_phy_tuning_state { |
| 454 |
PTS_UTMI_POSTINIT, |
| 455 |
PTS_PIPE3_PREINIT, |
| 456 |
PTS_PIPE3_INIT, |
| 457 |
PTS_PIPE3_POSTINIT, |
| 458 |
PTS_PIPE3_POSTLOCK, |
| 459 |
PTS_MAX, |
| 460 |
}; |
| 461 |
|
| 462 |
enum exynos5_usbdrd_phy_id { |
| 463 |
EXYNOS5_DRDPHY_UTMI, |
| 464 |
EXYNOS5_DRDPHY_PIPE3, |
| 465 |
EXYNOS5_DRDPHYS_NUM, |
| 466 |
}; |
| 467 |
|
| 468 |
struct phy_usb_instance; |
| 469 |
struct exynos5_usbdrd_phy; |
| 470 |
|
| 471 |
struct exynos5_usbdrd_phy_config { |
| 472 |
u32 id; |
| 473 |
void (*phy_isol)(struct phy_usb_instance *inst, bool isolate); |
| 474 |
void (*phy_init)(struct exynos5_usbdrd_phy *phy_drd); |
| 475 |
unsigned int (*set_refclk)(struct phy_usb_instance *inst); |
| 476 |
}; |
| 477 |
|
| 478 |
struct exynos5_usbdrd_phy_drvdata { |
| 479 |
const struct exynos5_usbdrd_phy_config *phy_cfg; |
| 480 |
const struct exynos5_usbdrd_phy_tuning **phy_tunes; |
| 481 |
const struct phy_ops *phy_ops; |
| 482 |
const char * const *clk_names; |
| 483 |
int n_clks; |
| 484 |
const char * const *core_clk_names; |
| 485 |
int n_core_clks; |
| 486 |
const char * const *regulator_names; |
| 487 |
int n_regulators; |
| 488 |
u32 pmu_offset_usbdrd0_phy; |
| 489 |
u32 pmu_offset_usbdrd0_phy_ss; |
| 490 |
u32 pmu_offset_usbdrd1_phy; |
| 491 |
}; |
| 492 |
|
| 493 |
/** |
| 494 |
* struct exynos5_usbdrd_phy - driver data for USB 3.0 PHY |
| 495 |
* @dev: pointer to device instance of this platform device |
| 496 |
* @reg_phy: usb phy controller register memory base |
| 497 |
* @reg_pcs: usb phy physical coding sublayer register memory base |
| 498 |
* @reg_pma: usb phy physical media attachment register memory base |
| 499 |
* @clks: clocks for register access |
| 500 |
* @core_clks: core clocks for phy (ref, pipe3, utmi+, ITP, etc. as required) |
| 501 |
* @drv_data: pointer to SoC level driver data structure |
| 502 |
* @hs_phy: pointer to non-Samsung IP high-speed phy controller |
| 503 |
* @phy_mutex: mutex protecting phy_init/exit & TCPC callbacks |
| 504 |
* @phys: array for 'EXYNOS5_DRDPHYS_NUM' number of PHY |
| 505 |
* instances each with its 'phy' and 'phy_cfg'. |
| 506 |
* @extrefclk: frequency select settings when using 'separate |
| 507 |
* reference clocks' for SS and HS operations |
| 508 |
* @regulators: regulators for phy |
| 509 |
* @sw: TypeC orientation switch handle |
| 510 |
* @orientation: TypeC connector orientation - normal or flipped |
| 511 |
*/ |
| 512 |
struct exynos5_usbdrd_phy { |
| 513 |
struct device *dev; |
| 514 |
void __iomem *reg_phy; |
| 515 |
void __iomem *reg_pcs; |
| 516 |
void __iomem *reg_pma; |
| 517 |
struct clk_bulk_data *clks; |
| 518 |
struct clk_bulk_data *core_clks; |
| 519 |
const struct exynos5_usbdrd_phy_drvdata *drv_data; |
| 520 |
struct phy *hs_phy; |
| 521 |
struct mutex phy_mutex; |
| 522 |
struct phy_usb_instance { |
| 523 |
struct phy *phy; |
| 524 |
u32 index; |
| 525 |
struct regmap *reg_pmu; |
| 526 |
u32 pmu_offset; |
| 527 |
const struct exynos5_usbdrd_phy_config *phy_cfg; |
| 528 |
} phys[EXYNOS5_DRDPHYS_NUM]; |
| 529 |
u32 extrefclk; |
| 530 |
struct regulator_bulk_data *regulators; |
| 531 |
|
| 532 |
struct typec_switch_dev *sw; |
| 533 |
enum typec_orientation orientation; |
| 534 |
}; |
| 535 |
|
| 536 |
static inline |
| 537 |
struct exynos5_usbdrd_phy *to_usbdrd_phy(struct phy_usb_instance *inst) |
| 538 |
{ |
| 539 |
return container_of((inst), struct exynos5_usbdrd_phy, |
| 540 |
phys[(inst)->index]); |
| 541 |
} |
| 542 |
|
| 543 |
/* |
| 544 |
* exynos5_rate_to_clk() converts the supplied clock rate to the value that |
| 545 |
* can be written to the phy register. |
| 546 |
*/ |
| 547 |
static unsigned int exynos5_rate_to_clk(unsigned long rate, u32 *reg) |
| 548 |
{ |
| 549 |
/* EXYNOS5_FSEL_MASK */ |
| 550 |
|
| 551 |
switch (rate) { |
| 552 |
case 9600 * KHZ: |
| 553 |
*reg = EXYNOS5_FSEL_9MHZ6; |
| 554 |
break; |
| 555 |
case 10 * MHZ: |
| 556 |
*reg = EXYNOS5_FSEL_10MHZ; |
| 557 |
break; |
| 558 |
case 12 * MHZ: |
| 559 |
*reg = EXYNOS5_FSEL_12MHZ; |
| 560 |
break; |
| 561 |
case 19200 * KHZ: |
| 562 |
*reg = EXYNOS5_FSEL_19MHZ2; |
| 563 |
break; |
| 564 |
case 20 * MHZ: |
| 565 |
*reg = EXYNOS5_FSEL_20MHZ; |
| 566 |
break; |
| 567 |
case 24 * MHZ: |
| 568 |
*reg = EXYNOS5_FSEL_24MHZ; |
| 569 |
break; |
| 570 |
case 26 * MHZ: |
| 571 |
*reg = EXYNOS5_FSEL_26MHZ; |
| 572 |
break; |
| 573 |
case 50 * MHZ: |
| 574 |
*reg = EXYNOS5_FSEL_50MHZ; |
| 575 |
break; |
| 576 |
default: |
| 577 |
return -EINVAL; |
| 578 |
} |
| 579 |
|
| 580 |
return 0; |
| 581 |
} |
| 582 |
|
| 583 |
static void exynos5_usbdrd_phy_isol(struct phy_usb_instance *inst, |
| 584 |
bool isolate) |
| 585 |
{ |
| 586 |
unsigned int val; |
| 587 |
|
| 588 |
if (!inst->reg_pmu) |
| 589 |
return; |
| 590 |
|
| 591 |
val = isolate ? 0 : EXYNOS4_PHY_ENABLE; |
| 592 |
|
| 593 |
regmap_update_bits(inst->reg_pmu, inst->pmu_offset, |
| 594 |
EXYNOS4_PHY_ENABLE, val); |
| 595 |
} |
| 596 |
|
| 597 |
/* |
| 598 |
* Sets the pipe3 phy's clk as EXTREFCLK (XXTI) which is internal clock |
| 599 |
* from clock core. Further sets multiplier values and spread spectrum |
| 600 |
* clock settings for SuperSpeed operations. |
| 601 |
*/ |
| 602 |
static unsigned int |
| 603 |
exynos5_usbdrd_pipe3_set_refclk(struct phy_usb_instance *inst) |
| 604 |
{ |
| 605 |
u32 reg; |
| 606 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 607 |
|
| 608 |
/* restore any previous reference clock settings */ |
| 609 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 610 |
|
| 611 |
/* Use EXTREFCLK as ref clock */ |
| 612 |
reg &= ~PHYCLKRST_REFCLKSEL; |
| 613 |
reg |= FIELD_PREP(PHYCLKRST_REFCLKSEL, PHYCLKRST_REFCLKSEL_EXT_REFCLK); |
| 614 |
|
| 615 |
/* FSEL settings corresponding to reference clock */ |
| 616 |
reg &= ~(PHYCLKRST_FSEL_PIPE | |
| 617 |
PHYCLKRST_MPLL_MULTIPLIER | |
| 618 |
PHYCLKRST_SSC_REFCLKSEL); |
| 619 |
switch (phy_drd->extrefclk) { |
| 620 |
case EXYNOS5_FSEL_50MHZ: |
| 621 |
reg |= (FIELD_PREP(PHYCLKRST_SSC_REFCLKSEL, 0x00) | |
| 622 |
FIELD_PREP(PHYCLKRST_MPLL_MULTIPLIER, |
| 623 |
PHYCLKRST_MPLL_MULTIPLIER_50M_REF)); |
| 624 |
break; |
| 625 |
case EXYNOS5_FSEL_24MHZ: |
| 626 |
reg |= (FIELD_PREP(PHYCLKRST_SSC_REFCLKSEL, 0x88) | |
| 627 |
FIELD_PREP(PHYCLKRST_MPLL_MULTIPLIER, |
| 628 |
PHYCLKRST_MPLL_MULTIPLIER_24MHZ_REF)); |
| 629 |
break; |
| 630 |
case EXYNOS5_FSEL_20MHZ: |
| 631 |
reg |= (FIELD_PREP(PHYCLKRST_SSC_REFCLKSEL, 0x00) | |
| 632 |
FIELD_PREP(PHYCLKRST_MPLL_MULTIPLIER, |
| 633 |
PHYCLKRST_MPLL_MULTIPLIER_20MHZ_REF)); |
| 634 |
break; |
| 635 |
case EXYNOS5_FSEL_19MHZ2: |
| 636 |
reg |= (FIELD_PREP(PHYCLKRST_SSC_REFCLKSEL, 0x88) | |
| 637 |
FIELD_PREP(PHYCLKRST_MPLL_MULTIPLIER, |
| 638 |
PHYCLKRST_MPLL_MULTIPLIER_19200KHZ_REF)); |
| 639 |
break; |
| 640 |
default: |
| 641 |
dev_dbg(phy_drd->dev, "unsupported ref clk\n"); |
| 642 |
break; |
| 643 |
} |
| 644 |
|
| 645 |
return reg; |
| 646 |
} |
| 647 |
|
| 648 |
/* |
| 649 |
* Sets the utmi phy's clk as EXTREFCLK (XXTI) which is internal clock |
| 650 |
* from clock core. Further sets the FSEL values for HighSpeed operations. |
| 651 |
*/ |
| 652 |
static unsigned int |
| 653 |
exynos5_usbdrd_utmi_set_refclk(struct phy_usb_instance *inst) |
| 654 |
{ |
| 655 |
u32 reg; |
| 656 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 657 |
|
| 658 |
/* restore any previous reference clock settings */ |
| 659 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 660 |
|
| 661 |
reg &= ~PHYCLKRST_REFCLKSEL; |
| 662 |
reg |= FIELD_PREP(PHYCLKRST_REFCLKSEL, PHYCLKRST_REFCLKSEL_EXT_REFCLK); |
| 663 |
|
| 664 |
reg &= ~(PHYCLKRST_FSEL_UTMI | |
| 665 |
PHYCLKRST_MPLL_MULTIPLIER | |
| 666 |
PHYCLKRST_SSC_REFCLKSEL); |
| 667 |
reg |= FIELD_PREP(PHYCLKRST_FSEL_UTMI, phy_drd->extrefclk); |
| 668 |
|
| 669 |
return reg; |
| 670 |
} |
| 671 |
|
| 672 |
static void |
| 673 |
exynos5_usbdrd_apply_phy_tunes(struct exynos5_usbdrd_phy *phy_drd, |
| 674 |
enum exynos5_usbdrd_phy_tuning_state state) |
| 675 |
{ |
| 676 |
const struct exynos5_usbdrd_phy_tuning *tune; |
| 677 |
|
| 678 |
tune = phy_drd->drv_data->phy_tunes[state]; |
| 679 |
if (!tune) |
| 680 |
return; |
| 681 |
|
| 682 |
for_each_phy_tune(tune) { |
| 683 |
void __iomem *reg_base; |
| 684 |
u32 reg = 0; |
| 685 |
|
| 686 |
switch (tune->region) { |
| 687 |
case PTR_PHY: |
| 688 |
reg_base = phy_drd->reg_phy; |
| 689 |
break; |
| 690 |
case PTR_PCS: |
| 691 |
reg_base = phy_drd->reg_pcs; |
| 692 |
break; |
| 693 |
case PTR_PMA: |
| 694 |
reg_base = phy_drd->reg_pma; |
| 695 |
break; |
| 696 |
default: |
| 697 |
dev_warn_once(phy_drd->dev, |
| 698 |
"unknown phy region %d\n", tune->region); |
| 699 |
continue; |
| 700 |
} |
| 701 |
|
| 702 |
if (~tune->mask) { |
| 703 |
reg = readl(reg_base + tune->off); |
| 704 |
reg &= ~tune->mask; |
| 705 |
} |
| 706 |
reg |= tune->val; |
| 707 |
writel(reg, reg_base + tune->off); |
| 708 |
} |
| 709 |
} |
| 710 |
|
| 711 |
static void exynos5_usbdrd_pipe3_init(struct exynos5_usbdrd_phy *phy_drd) |
| 712 |
{ |
| 713 |
u32 reg; |
| 714 |
|
| 715 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM1); |
| 716 |
/* Set Tx De-Emphasis level */ |
| 717 |
reg &= ~PHYPARAM1_PCS_TXDEEMPH; |
| 718 |
reg |= FIELD_PREP(PHYPARAM1_PCS_TXDEEMPH, PHYPARAM1_PCS_TXDEEMPH_VAL); |
| 719 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM1); |
| 720 |
|
| 721 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 722 |
reg &= ~PHYTEST_POWERDOWN_SSP; |
| 723 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 724 |
} |
| 725 |
|
| 726 |
static void |
| 727 |
exynos5_usbdrd_usbdp_g2_v4_ctrl_pma_ready(struct exynos5_usbdrd_phy *phy_drd) |
| 728 |
{ |
| 729 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 730 |
u32 reg; |
| 731 |
|
| 732 |
/* link pipe_clock selection to pclk of PMA */ |
| 733 |
reg = readl(regs_base + EXYNOS850_DRD_CLKRST); |
| 734 |
reg |= CLKRST_LINK_PCLK_SEL; |
| 735 |
writel(reg, regs_base + EXYNOS850_DRD_CLKRST); |
| 736 |
|
| 737 |
reg = readl(regs_base + EXYNOS850_DRD_SECPMACTL); |
| 738 |
reg &= ~SECPMACTL_PMA_REF_FREQ_SEL; |
| 739 |
reg |= FIELD_PREP(SECPMACTL_PMA_REF_FREQ_SEL, 1); |
| 740 |
/* SFR reset */ |
| 741 |
reg |= (SECPMACTL_PMA_LOW_PWR | SECPMACTL_PMA_APB_SW_RST); |
| 742 |
reg &= ~(SECPMACTL_PMA_ROPLL_REF_CLK_SEL | |
| 743 |
SECPMACTL_PMA_LCPLL_REF_CLK_SEL); |
| 744 |
/* PMA power off */ |
| 745 |
reg |= (SECPMACTL_PMA_TRSV_SW_RST | SECPMACTL_PMA_CMN_SW_RST | |
| 746 |
SECPMACTL_PMA_INIT_SW_RST); |
| 747 |
writel(reg, regs_base + EXYNOS850_DRD_SECPMACTL); |
| 748 |
|
| 749 |
udelay(1); |
| 750 |
|
| 751 |
reg = readl(regs_base + EXYNOS850_DRD_SECPMACTL); |
| 752 |
reg &= ~SECPMACTL_PMA_LOW_PWR; |
| 753 |
writel(reg, regs_base + EXYNOS850_DRD_SECPMACTL); |
| 754 |
|
| 755 |
udelay(1); |
| 756 |
|
| 757 |
/* release override */ |
| 758 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 759 |
reg &= ~LINKCTRL_FORCE_PIPE_EN; |
| 760 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 761 |
|
| 762 |
udelay(1); |
| 763 |
|
| 764 |
/* APB enable */ |
| 765 |
reg = readl(regs_base + EXYNOS850_DRD_SECPMACTL); |
| 766 |
reg &= ~SECPMACTL_PMA_APB_SW_RST; |
| 767 |
writel(reg, regs_base + EXYNOS850_DRD_SECPMACTL); |
| 768 |
} |
| 769 |
|
| 770 |
static void |
| 771 |
exynos5_usbdrd_usbdp_g2_v4_pma_lane_mux_sel(struct exynos5_usbdrd_phy *phy_drd) |
| 772 |
{ |
| 773 |
void __iomem *regs_base = phy_drd->reg_pma; |
| 774 |
u32 reg; |
| 775 |
|
| 776 |
/* lane configuration: USB on all lanes */ |
| 777 |
reg = readl(regs_base + EXYNOS9_PMA_USBDP_CMN_REG00B8); |
| 778 |
reg &= ~CMN_REG00B8_LANE_MUX_SEL_DP; |
| 779 |
/* |
| 780 |
* USB on lanes 0 & 1 in normal mode, or 2 & 3 if reversed, DP on the |
| 781 |
* other ones. |
| 782 |
*/ |
| 783 |
reg |= FIELD_PREP(CMN_REG00B8_LANE_MUX_SEL_DP, |
| 784 |
((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) |
| 785 |
? (CMN_REG00B8_LANE_MUX_SEL_DP_LANE3 |
| 786 |
| CMN_REG00B8_LANE_MUX_SEL_DP_LANE2) |
| 787 |
: (CMN_REG00B8_LANE_MUX_SEL_DP_LANE1 |
| 788 |
| CMN_REG00B8_LANE_MUX_SEL_DP_LANE0))); |
| 789 |
writel(reg, regs_base + EXYNOS9_PMA_USBDP_CMN_REG00B8); |
| 790 |
|
| 791 |
/* override of TX receiver detector and comparator: lane 1 */ |
| 792 |
reg = readl(regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0413); |
| 793 |
if (phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) { |
| 794 |
reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN; |
| 795 |
reg &= ~TRSV_REG0413_OVRD_LN1_TX_RXD_EN; |
| 796 |
} else { |
| 797 |
reg |= TRSV_REG0413_OVRD_LN1_TX_RXD_COMP_EN; |
| 798 |
reg |= TRSV_REG0413_OVRD_LN1_TX_RXD_EN; |
| 799 |
} |
| 800 |
writel(reg, regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0413); |
| 801 |
|
| 802 |
/* lane 3 */ |
| 803 |
reg = readl(regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0813); |
| 804 |
if (phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) { |
| 805 |
reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN; |
| 806 |
reg |= TRSV_REG0813_OVRD_LN3_TX_RXD_EN; |
| 807 |
} else { |
| 808 |
reg &= ~TRSV_REG0813_OVRD_LN3_TX_RXD_COMP_EN; |
| 809 |
reg &= ~TRSV_REG0813_OVRD_LN3_TX_RXD_EN; |
| 810 |
} |
| 811 |
writel(reg, regs_base + EXYNOS9_PMA_USBDP_TRSV_REG0813); |
| 812 |
} |
| 813 |
|
| 814 |
static int |
| 815 |
exynos5_usbdrd_usbdp_g2_v4_pma_check_pll_lock(struct exynos5_usbdrd_phy *phy_drd) |
| 816 |
{ |
| 817 |
static const unsigned int timeout_us = 40000; |
| 818 |
static const unsigned int sleep_us = 40; |
| 819 |
static const u32 locked = (CMN_REG01C0_ANA_LCPLL_LOCK_DONE | |
| 820 |
CMN_REG01C0_ANA_LCPLL_AFC_DONE); |
| 821 |
u32 reg; |
| 822 |
int err; |
| 823 |
|
| 824 |
err = readl_poll_timeout( |
| 825 |
phy_drd->reg_pma + EXYNOS9_PMA_USBDP_CMN_REG01C0, |
| 826 |
reg, (reg & locked) == locked, sleep_us, timeout_us); |
| 827 |
if (err) |
| 828 |
dev_err(phy_drd->dev, |
| 829 |
"timed out waiting for PLL lock: %#.8x\n", reg); |
| 830 |
|
| 831 |
return err; |
| 832 |
} |
| 833 |
|
| 834 |
static void |
| 835 |
exynos5_usbdrd_usbdp_g2_v4_pma_check_cdr_lock(struct exynos5_usbdrd_phy *phy_drd) |
| 836 |
{ |
| 837 |
static const unsigned int timeout_us = 40000; |
| 838 |
static const unsigned int sleep_us = 40; |
| 839 |
static const u32 locked = |
| 840 |
(TRSV_REG03C3_LN0_MON_RX_CDR_AFC_DONE |
| 841 |
| TRSV_REG03C3_LN0_MON_RX_CDR_CAL_DONE |
| 842 |
| TRSV_REG03C3_LN0_MON_RX_CDR_FLD_PLL_MODE_DONE |
| 843 |
| TRSV_REG03C3_LN0_MON_RX_CDR_LOCK_DONE); |
| 844 |
u32 reg; |
| 845 |
int err; |
| 846 |
|
| 847 |
err = readl_poll_timeout( |
| 848 |
/* lane depends on cable orientation */ |
| 849 |
(phy_drd->reg_pma |
| 850 |
+ ((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) |
| 851 |
? EXYNOS9_PMA_USBDP_TRSV_REG03C3 |
| 852 |
: EXYNOS9_PMA_USBDP_TRSV_REG07C3)), |
| 853 |
reg, (reg & locked) == locked, sleep_us, timeout_us); |
| 854 |
if (err) |
| 855 |
dev_err(phy_drd->dev, |
| 856 |
"timed out waiting for CDR(l%d) lock: %#.8x\n", |
| 857 |
((phy_drd->orientation == TYPEC_ORIENTATION_NORMAL) |
| 858 |
? 0 |
| 859 |
: 2), reg); |
| 860 |
} |
| 861 |
|
| 862 |
static void exynos5_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd) |
| 863 |
{ |
| 864 |
u32 reg; |
| 865 |
|
| 866 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM0); |
| 867 |
/* Set Loss-of-Signal Detector sensitivity */ |
| 868 |
reg &= ~PHYPARAM0_REF_LOSLEVEL; |
| 869 |
reg |= FIELD_PREP(PHYPARAM0_REF_LOSLEVEL, PHYPARAM0_REF_LOSLEVEL_VAL); |
| 870 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM0); |
| 871 |
|
| 872 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM1); |
| 873 |
/* Set Tx De-Emphasis level */ |
| 874 |
reg &= ~PHYPARAM1_PCS_TXDEEMPH; |
| 875 |
reg |= FIELD_PREP(PHYPARAM1_PCS_TXDEEMPH, PHYPARAM1_PCS_TXDEEMPH_VAL); |
| 876 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM1); |
| 877 |
|
| 878 |
/* UTMI Power Control */ |
| 879 |
writel(PHYUTMI_OTGDISABLE, phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 880 |
|
| 881 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 882 |
reg &= ~PHYTEST_POWERDOWN_HSP; |
| 883 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 884 |
} |
| 885 |
|
| 886 |
static int exynos5_usbdrd_phy_init(struct phy *phy) |
| 887 |
{ |
| 888 |
int ret; |
| 889 |
u32 reg; |
| 890 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 891 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 892 |
|
| 893 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 894 |
if (ret) |
| 895 |
return ret; |
| 896 |
|
| 897 |
/* Reset USB 3.0 PHY */ |
| 898 |
writel(0x0, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); |
| 899 |
writel(0x0, phy_drd->reg_phy + EXYNOS5_DRD_PHYRESUME); |
| 900 |
|
| 901 |
/* |
| 902 |
* Setting the Frame length Adj value[6:1] to default 0x20 |
| 903 |
* See xHCI 1.0 spec, 5.2.4 |
| 904 |
*/ |
| 905 |
reg = LINKSYSTEM_XHCI_VERSION_CONTROL | |
| 906 |
FIELD_PREP(LINKSYSTEM_FLADJ, 0x20); |
| 907 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_LINKSYSTEM); |
| 908 |
|
| 909 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM0); |
| 910 |
/* Select PHY CLK source */ |
| 911 |
reg &= ~PHYPARAM0_REF_USE_PAD; |
| 912 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYPARAM0); |
| 913 |
|
| 914 |
/* This bit must be set for both HS and SS operations */ |
| 915 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMICLKSEL); |
| 916 |
reg |= PHYUTMICLKSEL_UTMI_CLKSEL; |
| 917 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMICLKSEL); |
| 918 |
|
| 919 |
/* UTMI or PIPE3 specific init */ |
| 920 |
inst->phy_cfg->phy_init(phy_drd); |
| 921 |
|
| 922 |
/* reference clock settings */ |
| 923 |
reg = inst->phy_cfg->set_refclk(inst); |
| 924 |
|
| 925 |
/* Digital power supply in normal operating mode */ |
| 926 |
reg |= PHYCLKRST_RETENABLEN | |
| 927 |
/* Enable ref clock for SS function */ |
| 928 |
PHYCLKRST_REF_SSP_EN | |
| 929 |
/* Enable spread spectrum */ |
| 930 |
PHYCLKRST_SSC_EN | |
| 931 |
/* Power down HS Bias and PLL blocks in suspend mode */ |
| 932 |
PHYCLKRST_COMMONONN | |
| 933 |
/* Reset the port */ |
| 934 |
PHYCLKRST_PORTRESET; |
| 935 |
|
| 936 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 937 |
|
| 938 |
fsleep(10); |
| 939 |
|
| 940 |
reg &= ~PHYCLKRST_PORTRESET; |
| 941 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 942 |
|
| 943 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 944 |
|
| 945 |
return 0; |
| 946 |
} |
| 947 |
|
| 948 |
static int exynos5_usbdrd_phy_exit(struct phy *phy) |
| 949 |
{ |
| 950 |
int ret; |
| 951 |
u32 reg; |
| 952 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 953 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 954 |
|
| 955 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 956 |
if (ret) |
| 957 |
return ret; |
| 958 |
|
| 959 |
reg = PHYUTMI_OTGDISABLE | |
| 960 |
PHYUTMI_FORCESUSPEND | |
| 961 |
PHYUTMI_FORCESLEEP; |
| 962 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 963 |
|
| 964 |
/* Resetting the PHYCLKRST enable bits to reduce leakage current */ |
| 965 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 966 |
reg &= ~(PHYCLKRST_REF_SSP_EN | |
| 967 |
PHYCLKRST_SSC_EN | |
| 968 |
PHYCLKRST_COMMONONN); |
| 969 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 970 |
|
| 971 |
/* Control PHYTEST to remove leakage current */ |
| 972 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 973 |
reg |= PHYTEST_POWERDOWN_SSP | |
| 974 |
PHYTEST_POWERDOWN_HSP; |
| 975 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYTEST); |
| 976 |
|
| 977 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 978 |
|
| 979 |
return 0; |
| 980 |
} |
| 981 |
|
| 982 |
static int exynos5_usbdrd_phy_power_on(struct phy *phy) |
| 983 |
{ |
| 984 |
int ret; |
| 985 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 986 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 987 |
|
| 988 |
dev_dbg(phy_drd->dev, "Request to power_on usbdrd_phy phy\n"); |
| 989 |
|
| 990 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_core_clks, |
| 991 |
phy_drd->core_clks); |
| 992 |
if (ret) |
| 993 |
return ret; |
| 994 |
|
| 995 |
/* Enable VBUS supply */ |
| 996 |
ret = regulator_bulk_enable(phy_drd->drv_data->n_regulators, |
| 997 |
phy_drd->regulators); |
| 998 |
if (ret) { |
| 999 |
dev_err(phy_drd->dev, "Failed to enable PHY regulator(s)\n"); |
| 1000 |
goto fail_vbus; |
| 1001 |
} |
| 1002 |
|
| 1003 |
/* Power-on PHY */ |
| 1004 |
inst->phy_cfg->phy_isol(inst, false); |
| 1005 |
|
| 1006 |
return 0; |
| 1007 |
|
| 1008 |
fail_vbus: |
| 1009 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_core_clks, |
| 1010 |
phy_drd->core_clks); |
| 1011 |
|
| 1012 |
return ret; |
| 1013 |
} |
| 1014 |
|
| 1015 |
static int exynos5_usbdrd_phy_power_off(struct phy *phy) |
| 1016 |
{ |
| 1017 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1018 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1019 |
|
| 1020 |
dev_dbg(phy_drd->dev, "Request to power_off usbdrd_phy phy\n"); |
| 1021 |
|
| 1022 |
/* Power-off the PHY */ |
| 1023 |
inst->phy_cfg->phy_isol(inst, true); |
| 1024 |
|
| 1025 |
/* Disable VBUS supply */ |
| 1026 |
regulator_bulk_disable(phy_drd->drv_data->n_regulators, |
| 1027 |
phy_drd->regulators); |
| 1028 |
|
| 1029 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_core_clks, |
| 1030 |
phy_drd->core_clks); |
| 1031 |
|
| 1032 |
return 0; |
| 1033 |
} |
| 1034 |
|
| 1035 |
static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd, |
| 1036 |
u32 val, u32 cmd) |
| 1037 |
{ |
| 1038 |
unsigned int result; |
| 1039 |
int err; |
| 1040 |
|
| 1041 |
writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); |
| 1042 |
|
| 1043 |
err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, |
| 1044 |
result, (result & PHYREG1_CR_ACK), 1, 100); |
| 1045 |
if (err == -ETIMEDOUT) { |
| 1046 |
dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); |
| 1047 |
return err; |
| 1048 |
} |
| 1049 |
|
| 1050 |
writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); |
| 1051 |
|
| 1052 |
err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, |
| 1053 |
result, !(result & PHYREG1_CR_ACK), 1, 100); |
| 1054 |
if (err == -ETIMEDOUT) { |
| 1055 |
dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val); |
| 1056 |
return err; |
| 1057 |
} |
| 1058 |
|
| 1059 |
return 0; |
| 1060 |
} |
| 1061 |
|
| 1062 |
static int crport_ctrl_write(struct exynos5_usbdrd_phy *phy_drd, |
| 1063 |
u32 addr, u32 data) |
| 1064 |
{ |
| 1065 |
u32 val; |
| 1066 |
int ret; |
| 1067 |
|
| 1068 |
/* Write Address */ |
| 1069 |
val = FIELD_PREP(PHYREG0_CR_DATA_IN, addr); |
| 1070 |
writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); |
| 1071 |
ret = crport_handshake(phy_drd, val, PHYREG0_CR_CAP_ADDR); |
| 1072 |
if (ret) |
| 1073 |
return ret; |
| 1074 |
|
| 1075 |
/* Write Data */ |
| 1076 |
val = FIELD_PREP(PHYREG0_CR_DATA_IN, data); |
| 1077 |
writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); |
| 1078 |
ret = crport_handshake(phy_drd, val, PHYREG0_CR_CAP_DATA); |
| 1079 |
if (ret) |
| 1080 |
return ret; |
| 1081 |
|
| 1082 |
ret = crport_handshake(phy_drd, val, PHYREG0_CR_WRITE); |
| 1083 |
|
| 1084 |
return ret; |
| 1085 |
} |
| 1086 |
|
| 1087 |
/* |
| 1088 |
* Calibrate few PHY parameters using CR_PORT register to meet |
| 1089 |
* SuperSpeed requirements on Exynos5420 and Exynos5800 systems, |
| 1090 |
* which have 28nm USB 3.0 DRD PHY. |
| 1091 |
*/ |
| 1092 |
static int exynos5420_usbdrd_phy_calibrate(struct exynos5_usbdrd_phy *phy_drd) |
| 1093 |
{ |
| 1094 |
unsigned int temp; |
| 1095 |
int ret = 0; |
| 1096 |
|
| 1097 |
/* |
| 1098 |
* Change los_bias to (0x5) for 28nm PHY from a |
| 1099 |
* default value (0x0); los_level is set as default |
| 1100 |
* (0x9) as also reflected in los_level[30:26] bits |
| 1101 |
* of PHYPARAM0 register. |
| 1102 |
*/ |
| 1103 |
temp = LOSLEVEL_OVRD_IN_LOS_BIAS_5420 | |
| 1104 |
LOSLEVEL_OVRD_IN_EN | |
| 1105 |
LOSLEVEL_OVRD_IN_LOS_LEVEL_DEFAULT; |
| 1106 |
ret = crport_ctrl_write(phy_drd, |
| 1107 |
EXYNOS5_DRD_PHYSS_LOSLEVEL_OVRD_IN, |
| 1108 |
temp); |
| 1109 |
if (ret) { |
| 1110 |
dev_err(phy_drd->dev, |
| 1111 |
"Failed setting Loss-of-Signal level for SuperSpeed\n"); |
| 1112 |
return ret; |
| 1113 |
} |
| 1114 |
|
| 1115 |
/* |
| 1116 |
* Set tx_vboost_lvl to (0x5) for 28nm PHY Tuning, |
| 1117 |
* to raise Tx signal level from its default value of (0x4) |
| 1118 |
*/ |
| 1119 |
temp = TX_VBOOSTLEVEL_OVRD_IN_VBOOST_5420; |
| 1120 |
ret = crport_ctrl_write(phy_drd, |
| 1121 |
EXYNOS5_DRD_PHYSS_TX_VBOOSTLEVEL_OVRD_IN, |
| 1122 |
temp); |
| 1123 |
if (ret) { |
| 1124 |
dev_err(phy_drd->dev, |
| 1125 |
"Failed setting Tx-Vboost-Level for SuperSpeed\n"); |
| 1126 |
return ret; |
| 1127 |
} |
| 1128 |
|
| 1129 |
/* |
| 1130 |
* Set proper time to wait for RxDetect measurement, for |
| 1131 |
* desired reference clock of PHY, by tuning the CR_PORT |
| 1132 |
* register LANE0.TX_DEBUG which is internal to PHY. |
| 1133 |
* This fixes issue with few USB 3.0 devices, which are |
| 1134 |
* not detected (not even generate interrupts on the bus |
| 1135 |
* on insertion) without this change. |
| 1136 |
* e.g. Samsung SUM-TSB16S 3.0 USB drive. |
| 1137 |
*/ |
| 1138 |
switch (phy_drd->extrefclk) { |
| 1139 |
case EXYNOS5_FSEL_50MHZ: |
| 1140 |
temp = LANE0_TX_DEBUG_RXDET_MEAS_TIME_48M_50M_52M; |
| 1141 |
break; |
| 1142 |
case EXYNOS5_FSEL_20MHZ: |
| 1143 |
case EXYNOS5_FSEL_19MHZ2: |
| 1144 |
temp = LANE0_TX_DEBUG_RXDET_MEAS_TIME_19M2_20M; |
| 1145 |
break; |
| 1146 |
case EXYNOS5_FSEL_24MHZ: |
| 1147 |
default: |
| 1148 |
temp = LANE0_TX_DEBUG_RXDET_MEAS_TIME_24M; |
| 1149 |
break; |
| 1150 |
} |
| 1151 |
|
| 1152 |
ret = crport_ctrl_write(phy_drd, |
| 1153 |
EXYNOS5_DRD_PHYSS_LANE0_TX_DEBUG, |
| 1154 |
temp); |
| 1155 |
if (ret) |
| 1156 |
dev_err(phy_drd->dev, |
| 1157 |
"Fail to set RxDet measurement time for SuperSpeed\n"); |
| 1158 |
|
| 1159 |
return ret; |
| 1160 |
} |
| 1161 |
|
| 1162 |
static struct phy *exynos5_usbdrd_phy_xlate(struct device *dev, |
| 1163 |
const struct of_phandle_args *args) |
| 1164 |
{ |
| 1165 |
struct exynos5_usbdrd_phy *phy_drd = dev_get_drvdata(dev); |
| 1166 |
|
| 1167 |
if (WARN_ON(args->args[0] >= EXYNOS5_DRDPHYS_NUM)) |
| 1168 |
return ERR_PTR(-ENODEV); |
| 1169 |
|
| 1170 |
return phy_drd->phys[args->args[0]].phy; |
| 1171 |
} |
| 1172 |
|
| 1173 |
static int exynos5_usbdrd_phy_calibrate(struct phy *phy) |
| 1174 |
{ |
| 1175 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1176 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1177 |
|
| 1178 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) |
| 1179 |
return exynos5420_usbdrd_phy_calibrate(phy_drd); |
| 1180 |
return 0; |
| 1181 |
} |
| 1182 |
|
| 1183 |
static const struct phy_ops exynos5_usbdrd_phy_ops = { |
| 1184 |
.init = exynos5_usbdrd_phy_init, |
| 1185 |
.exit = exynos5_usbdrd_phy_exit, |
| 1186 |
.power_on = exynos5_usbdrd_phy_power_on, |
| 1187 |
.power_off = exynos5_usbdrd_phy_power_off, |
| 1188 |
.calibrate = exynos5_usbdrd_phy_calibrate, |
| 1189 |
.owner = THIS_MODULE, |
| 1190 |
}; |
| 1191 |
|
| 1192 |
static void exynos7870_usbdrd_phy_isol(struct phy_usb_instance *inst, |
| 1193 |
bool isolate) |
| 1194 |
{ |
| 1195 |
unsigned int val; |
| 1196 |
|
| 1197 |
if (!inst->reg_pmu) |
| 1198 |
return; |
| 1199 |
|
| 1200 |
val = isolate ? 0 : EXYNOS7870_USB2PHY_ENABLE; |
| 1201 |
|
| 1202 |
regmap_update_bits(inst->reg_pmu, inst->pmu_offset, |
| 1203 |
EXYNOS7870_USB2PHY_ENABLE, val); |
| 1204 |
} |
| 1205 |
|
| 1206 |
static void exynos7870_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd) |
| 1207 |
{ |
| 1208 |
u32 reg; |
| 1209 |
|
| 1210 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 1211 |
/* Use PADREFCLK as ref clock */ |
| 1212 |
reg &= ~PHYCLKRST_REFCLKSEL; |
| 1213 |
reg |= FIELD_PREP(PHYCLKRST_REFCLKSEL, PHYCLKRST_REFCLKSEL_PAD_REFCLK); |
| 1214 |
/* Select ref clock rate */ |
| 1215 |
reg &= ~PHYCLKRST_FSEL_UTMI; |
| 1216 |
reg &= ~PHYCLKRST_FSEL_PIPE; |
| 1217 |
reg |= FIELD_PREP(PHYCLKRST_FSEL_UTMI, phy_drd->extrefclk); |
| 1218 |
/* Enable suspend and reset the port */ |
| 1219 |
reg |= PHYCLKRST_EN_UTMISUSPEND; |
| 1220 |
reg |= PHYCLKRST_COMMONONN; |
| 1221 |
reg |= PHYCLKRST_PORTRESET; |
| 1222 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 1223 |
udelay(10); |
| 1224 |
|
| 1225 |
/* Clear the port reset bit */ |
| 1226 |
reg &= ~PHYCLKRST_PORTRESET; |
| 1227 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYCLKRST); |
| 1228 |
|
| 1229 |
/* Change PHY PLL tune value */ |
| 1230 |
reg = readl(phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYPLLTUNE); |
| 1231 |
if (phy_drd->extrefclk == EXYNOS5_FSEL_24MHZ) |
| 1232 |
reg |= HSPHYPLLTUNE_PLL_B_TUNE; |
| 1233 |
else |
| 1234 |
reg &= ~HSPHYPLLTUNE_PLL_B_TUNE; |
| 1235 |
reg &= ~HSPHYPLLTUNE_PLL_P_TUNE; |
| 1236 |
reg |= FIELD_PREP(HSPHYPLLTUNE_PLL_P_TUNE, 14); |
| 1237 |
writel(reg, phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYPLLTUNE); |
| 1238 |
|
| 1239 |
/* High-Speed PHY control */ |
| 1240 |
reg = readl(phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1241 |
reg &= ~HSPHYCTRL_SIDDQ; |
| 1242 |
reg &= ~HSPHYCTRL_PHYSWRST; |
| 1243 |
reg &= ~HSPHYCTRL_PHYSWRSTALL; |
| 1244 |
writel(reg, phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1245 |
udelay(500); |
| 1246 |
|
| 1247 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_LINKSYSTEM); |
| 1248 |
/* |
| 1249 |
* Setting the Frame length Adj value[6:1] to default 0x20 |
| 1250 |
* See xHCI 1.0 spec, 5.2.4 |
| 1251 |
*/ |
| 1252 |
reg |= LINKSYSTEM_XHCI_VERSION_CONTROL; |
| 1253 |
reg &= ~LINKSYSTEM_FLADJ; |
| 1254 |
reg |= FIELD_PREP(LINKSYSTEM_FLADJ, 0x20); |
| 1255 |
/* Set VBUSVALID signal as the VBUS pad is not used */ |
| 1256 |
reg |= LINKSYSTEM_FORCE_BVALID; |
| 1257 |
reg |= LINKSYSTEM_FORCE_VBUSVALID; |
| 1258 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_LINKSYSTEM); |
| 1259 |
|
| 1260 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 1261 |
/* Release force_sleep & force_suspend */ |
| 1262 |
reg &= ~PHYUTMI_FORCESLEEP; |
| 1263 |
reg &= ~PHYUTMI_FORCESUSPEND; |
| 1264 |
/* DP/DM pull down control */ |
| 1265 |
reg &= ~PHYUTMI_DMPULLDOWN; |
| 1266 |
reg &= ~PHYUTMI_DPPULLDOWN; |
| 1267 |
reg &= ~PHYUTMI_DRVVBUS; |
| 1268 |
/* Set DP-pull up as the VBUS pad is not used */ |
| 1269 |
reg |= PHYUTMI_VBUSVLDEXTSEL; |
| 1270 |
reg |= PHYUTMI_VBUSVLDEXT; |
| 1271 |
/* Disable OTG block and VBUS valid comparator */ |
| 1272 |
reg |= PHYUTMI_OTGDISABLE; |
| 1273 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 1274 |
|
| 1275 |
/* Configure OVC IO usage */ |
| 1276 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_LINKPORT); |
| 1277 |
reg |= LINKPORT_HOST_PORT_OVCR_U3_SEL | LINKPORT_HOST_PORT_OVCR_U2_SEL; |
| 1278 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_LINKPORT); |
| 1279 |
|
| 1280 |
/* High-Speed PHY swrst */ |
| 1281 |
reg = readl(phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1282 |
reg |= HSPHYCTRL_PHYSWRST; |
| 1283 |
writel(reg, phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1284 |
udelay(20); |
| 1285 |
|
| 1286 |
/* Clear the PHY swrst bit */ |
| 1287 |
reg = readl(phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1288 |
reg &= ~HSPHYCTRL_PHYSWRST; |
| 1289 |
writel(reg, phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1290 |
|
| 1291 |
if (phy_drd->drv_data->phy_tunes) |
| 1292 |
exynos5_usbdrd_apply_phy_tunes(phy_drd, |
| 1293 |
PTS_UTMI_POSTINIT); |
| 1294 |
} |
| 1295 |
|
| 1296 |
static int exynos7870_usbdrd_phy_init(struct phy *phy) |
| 1297 |
{ |
| 1298 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1299 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1300 |
int ret; |
| 1301 |
|
| 1302 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1303 |
if (ret) |
| 1304 |
return ret; |
| 1305 |
|
| 1306 |
/* UTMI or PIPE3 specific init */ |
| 1307 |
inst->phy_cfg->phy_init(phy_drd); |
| 1308 |
|
| 1309 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1310 |
|
| 1311 |
return 0; |
| 1312 |
} |
| 1313 |
|
| 1314 |
static int exynos7870_usbdrd_phy_exit(struct phy *phy) |
| 1315 |
{ |
| 1316 |
int ret; |
| 1317 |
u32 reg; |
| 1318 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1319 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1320 |
|
| 1321 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1322 |
if (ret) |
| 1323 |
return ret; |
| 1324 |
|
| 1325 |
/* |
| 1326 |
* Disable the VBUS signal and the ID pull-up resistor. |
| 1327 |
* Enable force-suspend and force-sleep modes. |
| 1328 |
*/ |
| 1329 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 1330 |
reg &= ~(PHYUTMI_DRVVBUS | PHYUTMI_VBUSVLDEXT | PHYUTMI_VBUSVLDEXTSEL); |
| 1331 |
reg &= ~PHYUTMI_IDPULLUP; |
| 1332 |
reg |= PHYUTMI_FORCESUSPEND | PHYUTMI_FORCESLEEP; |
| 1333 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_PHYUTMI); |
| 1334 |
|
| 1335 |
/* Power down PHY analog blocks */ |
| 1336 |
reg = readl(phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1337 |
reg |= HSPHYCTRL_SIDDQ; |
| 1338 |
writel(reg, phy_drd->reg_phy + EXYNOS7870_DRD_HSPHYCTRL); |
| 1339 |
|
| 1340 |
/* Clear VBUSVALID signal as the VBUS pad is not used */ |
| 1341 |
reg = readl(phy_drd->reg_phy + EXYNOS5_DRD_LINKSYSTEM); |
| 1342 |
reg &= ~(LINKSYSTEM_FORCE_BVALID | LINKSYSTEM_FORCE_VBUSVALID); |
| 1343 |
writel(reg, phy_drd->reg_phy + EXYNOS5_DRD_LINKSYSTEM); |
| 1344 |
|
| 1345 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1346 |
|
| 1347 |
return 0; |
| 1348 |
} |
| 1349 |
|
| 1350 |
static const struct phy_ops exynos7870_usbdrd_phy_ops = { |
| 1351 |
.init = exynos7870_usbdrd_phy_init, |
| 1352 |
.exit = exynos7870_usbdrd_phy_exit, |
| 1353 |
.power_on = exynos5_usbdrd_phy_power_on, |
| 1354 |
.power_off = exynos5_usbdrd_phy_power_off, |
| 1355 |
.owner = THIS_MODULE, |
| 1356 |
}; |
| 1357 |
|
| 1358 |
static void exynos2200_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd) |
| 1359 |
{ |
| 1360 |
/* Configure non-Samsung IP PHY, responsible for UTMI */ |
| 1361 |
phy_init(phy_drd->hs_phy); |
| 1362 |
} |
| 1363 |
|
| 1364 |
static void exynos2200_usbdrd_link_init(struct exynos5_usbdrd_phy *phy_drd) |
| 1365 |
{ |
| 1366 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1367 |
u32 reg; |
| 1368 |
|
| 1369 |
/* |
| 1370 |
* Disable HWACG (hardware auto clock gating control). This will force |
| 1371 |
* QACTIVE signal in Q-Channel interface to HIGH level, to make sure |
| 1372 |
* the PHY clock is not gated by the hardware. |
| 1373 |
*/ |
| 1374 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1375 |
reg |= LINKCTRL_FORCE_QACT; |
| 1376 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1377 |
|
| 1378 |
/* De-assert link reset */ |
| 1379 |
reg = readl(regs_base + EXYNOS2200_DRD_CLKRST); |
| 1380 |
reg &= ~CLKRST_LINK_SW_RST; |
| 1381 |
writel(reg, regs_base + EXYNOS2200_DRD_CLKRST); |
| 1382 |
|
| 1383 |
/* Set link VBUS Valid */ |
| 1384 |
reg = readl(regs_base + EXYNOS2200_DRD_UTMI); |
| 1385 |
reg |= EXYNOS2200_UTMI_FORCE_BVALID | EXYNOS2200_UTMI_FORCE_VBUSVALID; |
| 1386 |
writel(reg, regs_base + EXYNOS2200_DRD_UTMI); |
| 1387 |
} |
| 1388 |
|
| 1389 |
static void |
| 1390 |
exynos2200_usbdrd_link_attach_detach_pipe3_phy(struct phy_usb_instance *inst) |
| 1391 |
{ |
| 1392 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1393 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1394 |
u32 reg; |
| 1395 |
|
| 1396 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1397 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) { |
| 1398 |
/* force pipe3 signal for link */ |
| 1399 |
reg &= ~LINKCTRL_FORCE_PHYSTATUS; |
| 1400 |
reg |= LINKCTRL_FORCE_PIPE_EN | LINKCTRL_FORCE_RXELECIDLE; |
| 1401 |
} else { |
| 1402 |
/* disable forcing pipe interface */ |
| 1403 |
reg &= ~LINKCTRL_FORCE_PIPE_EN; |
| 1404 |
} |
| 1405 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1406 |
|
| 1407 |
reg = readl(regs_base + EXYNOS2200_DRD_HSP_MISC); |
| 1408 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) { |
| 1409 |
/* calibrate only eUSB phy */ |
| 1410 |
reg |= FIELD_PREP(HSP_MISC_RES_TUNE, RES_TUNE_PHY1); |
| 1411 |
reg |= HSP_MISC_SET_REQ_IN2; |
| 1412 |
} else { |
| 1413 |
/* calibrate for dual phy */ |
| 1414 |
reg |= FIELD_PREP(HSP_MISC_RES_TUNE, RES_TUNE_PHY1_PHY2); |
| 1415 |
reg &= ~HSP_MISC_SET_REQ_IN2; |
| 1416 |
} |
| 1417 |
writel(reg, regs_base + EXYNOS2200_DRD_HSP_MISC); |
| 1418 |
|
| 1419 |
reg = readl(regs_base + EXYNOS2200_DRD_CLKRST); |
| 1420 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) |
| 1421 |
reg &= ~EXYNOS2200_CLKRST_LINK_PCLK_SEL; |
| 1422 |
else |
| 1423 |
reg |= EXYNOS2200_CLKRST_LINK_PCLK_SEL; |
| 1424 |
|
| 1425 |
writel(reg, regs_base + EXYNOS2200_DRD_CLKRST); |
| 1426 |
} |
| 1427 |
|
| 1428 |
static int exynos2200_usbdrd_phy_init(struct phy *phy) |
| 1429 |
{ |
| 1430 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1431 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1432 |
int ret; |
| 1433 |
|
| 1434 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) { |
| 1435 |
/* Power-on PHY ... */ |
| 1436 |
ret = regulator_bulk_enable(phy_drd->drv_data->n_regulators, |
| 1437 |
phy_drd->regulators); |
| 1438 |
if (ret) { |
| 1439 |
dev_err(phy_drd->dev, |
| 1440 |
"Failed to enable PHY regulator(s)\n"); |
| 1441 |
return ret; |
| 1442 |
} |
| 1443 |
} |
| 1444 |
/* |
| 1445 |
* ... and ungate power via PMU. Without this here, we get an SError |
| 1446 |
* trying to access PMA registers |
| 1447 |
*/ |
| 1448 |
exynos5_usbdrd_phy_isol(inst, false); |
| 1449 |
|
| 1450 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1451 |
if (ret) |
| 1452 |
return ret; |
| 1453 |
|
| 1454 |
/* Set up the link controller */ |
| 1455 |
exynos2200_usbdrd_link_init(phy_drd); |
| 1456 |
|
| 1457 |
/* UTMI or PIPE3 link preparation */ |
| 1458 |
exynos2200_usbdrd_link_attach_detach_pipe3_phy(inst); |
| 1459 |
|
| 1460 |
/* UTMI or PIPE3 specific init */ |
| 1461 |
inst->phy_cfg->phy_init(phy_drd); |
| 1462 |
|
| 1463 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1464 |
|
| 1465 |
return 0; |
| 1466 |
} |
| 1467 |
|
| 1468 |
static int exynos2200_usbdrd_phy_exit(struct phy *phy) |
| 1469 |
{ |
| 1470 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1471 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1472 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1473 |
u32 reg; |
| 1474 |
int ret; |
| 1475 |
|
| 1476 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1477 |
if (ret) |
| 1478 |
return ret; |
| 1479 |
|
| 1480 |
reg = readl(regs_base + EXYNOS2200_DRD_UTMI); |
| 1481 |
reg &= ~(EXYNOS2200_UTMI_FORCE_BVALID | EXYNOS2200_UTMI_FORCE_VBUSVALID); |
| 1482 |
writel(reg, regs_base + EXYNOS2200_DRD_UTMI); |
| 1483 |
|
| 1484 |
reg = readl(regs_base + EXYNOS2200_DRD_CLKRST); |
| 1485 |
reg |= CLKRST_LINK_SW_RST; |
| 1486 |
writel(reg, regs_base + EXYNOS2200_DRD_CLKRST); |
| 1487 |
|
| 1488 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1489 |
|
| 1490 |
exynos5_usbdrd_phy_isol(inst, true); |
| 1491 |
return regulator_bulk_disable(phy_drd->drv_data->n_regulators, |
| 1492 |
phy_drd->regulators); |
| 1493 |
} |
| 1494 |
|
| 1495 |
static const struct phy_ops exynos2200_usbdrd_phy_ops = { |
| 1496 |
.init = exynos2200_usbdrd_phy_init, |
| 1497 |
.exit = exynos2200_usbdrd_phy_exit, |
| 1498 |
.owner = THIS_MODULE, |
| 1499 |
}; |
| 1500 |
|
| 1501 |
static void |
| 1502 |
exynos5_usbdrd_usb_v3p1_pipe_override(struct exynos5_usbdrd_phy *phy_drd) |
| 1503 |
{ |
| 1504 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1505 |
u32 reg; |
| 1506 |
|
| 1507 |
/* force pipe3 signal for link */ |
| 1508 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1509 |
reg &= ~LINKCTRL_FORCE_PHYSTATUS; |
| 1510 |
reg |= LINKCTRL_FORCE_PIPE_EN | LINKCTRL_FORCE_RXELECIDLE; |
| 1511 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1512 |
|
| 1513 |
/* PMA disable */ |
| 1514 |
reg = readl(regs_base + EXYNOS850_DRD_SECPMACTL); |
| 1515 |
reg |= SECPMACTL_PMA_LOW_PWR; |
| 1516 |
writel(reg, regs_base + EXYNOS850_DRD_SECPMACTL); |
| 1517 |
} |
| 1518 |
|
| 1519 |
static void exynos850_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd) |
| 1520 |
{ |
| 1521 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1522 |
u32 reg; |
| 1523 |
u32 ss_ports; |
| 1524 |
|
| 1525 |
/* |
| 1526 |
* Disable HWACG (hardware auto clock gating control). This will force |
| 1527 |
* QACTIVE signal in Q-Channel interface to HIGH level, to make sure |
| 1528 |
* the PHY clock is not gated by the hardware. |
| 1529 |
*/ |
| 1530 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1531 |
reg |= LINKCTRL_FORCE_QACT; |
| 1532 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1533 |
|
| 1534 |
reg = readl(regs_base + EXYNOS850_DRD_LINKPORT); |
| 1535 |
ss_ports = FIELD_GET(LINKPORT_HOST_NUM_U3, reg); |
| 1536 |
|
| 1537 |
/* Start PHY Reset (POR=high) */ |
| 1538 |
reg = readl(regs_base + EXYNOS850_DRD_CLKRST); |
| 1539 |
if (ss_ports) { |
| 1540 |
reg |= CLKRST_PHY20_SW_POR; |
| 1541 |
reg |= CLKRST_PHY20_SW_POR_SEL; |
| 1542 |
reg |= CLKRST_PHY_RESET_SEL; |
| 1543 |
} |
| 1544 |
reg |= CLKRST_PHY_SW_RST; |
| 1545 |
writel(reg, regs_base + EXYNOS850_DRD_CLKRST); |
| 1546 |
|
| 1547 |
/* Enable UTMI+ */ |
| 1548 |
reg = readl(regs_base + EXYNOS850_DRD_UTMI); |
| 1549 |
reg &= ~(UTMI_FORCE_SUSPEND | UTMI_FORCE_SLEEP | UTMI_DP_PULLDOWN | |
| 1550 |
UTMI_DM_PULLDOWN); |
| 1551 |
writel(reg, regs_base + EXYNOS850_DRD_UTMI); |
| 1552 |
|
| 1553 |
/* Set PHY clock and control HS PHY */ |
| 1554 |
reg = readl(regs_base + EXYNOS850_DRD_HSP); |
| 1555 |
reg |= HSP_EN_UTMISUSPEND | HSP_COMMONONN; |
| 1556 |
writel(reg, regs_base + EXYNOS850_DRD_HSP); |
| 1557 |
|
| 1558 |
/* Set VBUS Valid and D+ pull-up control by VBUS pad usage */ |
| 1559 |
reg = readl(regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1560 |
reg |= FIELD_PREP(LINKCTRL_BUS_FILTER_BYPASS, 0xf); |
| 1561 |
writel(reg, regs_base + EXYNOS850_DRD_LINKCTRL); |
| 1562 |
|
| 1563 |
if (!phy_drd->sw) { |
| 1564 |
reg = readl(regs_base + EXYNOS850_DRD_UTMI); |
| 1565 |
reg |= UTMI_FORCE_BVALID | UTMI_FORCE_VBUSVALID; |
| 1566 |
writel(reg, regs_base + EXYNOS850_DRD_UTMI); |
| 1567 |
|
| 1568 |
reg = readl(regs_base + EXYNOS850_DRD_HSP); |
| 1569 |
reg |= HSP_VBUSVLDEXT | HSP_VBUSVLDEXTSEL; |
| 1570 |
writel(reg, regs_base + EXYNOS850_DRD_HSP); |
| 1571 |
} |
| 1572 |
|
| 1573 |
reg = readl(regs_base + EXYNOS850_DRD_SSPPLLCTL); |
| 1574 |
reg &= ~SSPPLLCTL_FSEL; |
| 1575 |
switch (phy_drd->extrefclk) { |
| 1576 |
case EXYNOS5_FSEL_50MHZ: |
| 1577 |
reg |= FIELD_PREP(SSPPLLCTL_FSEL, 7); |
| 1578 |
break; |
| 1579 |
case EXYNOS5_FSEL_26MHZ: |
| 1580 |
reg |= FIELD_PREP(SSPPLLCTL_FSEL, 6); |
| 1581 |
break; |
| 1582 |
case EXYNOS5_FSEL_24MHZ: |
| 1583 |
reg |= FIELD_PREP(SSPPLLCTL_FSEL, 2); |
| 1584 |
break; |
| 1585 |
case EXYNOS5_FSEL_20MHZ: |
| 1586 |
reg |= FIELD_PREP(SSPPLLCTL_FSEL, 1); |
| 1587 |
break; |
| 1588 |
case EXYNOS5_FSEL_19MHZ2: |
| 1589 |
reg |= FIELD_PREP(SSPPLLCTL_FSEL, 0); |
| 1590 |
break; |
| 1591 |
default: |
| 1592 |
dev_warn(phy_drd->dev, "unsupported ref clk: %#.2x\n", |
| 1593 |
phy_drd->extrefclk); |
| 1594 |
break; |
| 1595 |
} |
| 1596 |
writel(reg, regs_base + EXYNOS850_DRD_SSPPLLCTL); |
| 1597 |
|
| 1598 |
if (phy_drd->drv_data->phy_tunes) |
| 1599 |
exynos5_usbdrd_apply_phy_tunes(phy_drd, |
| 1600 |
PTS_UTMI_POSTINIT); |
| 1601 |
|
| 1602 |
/* Power up PHY analog blocks */ |
| 1603 |
reg = readl(regs_base + EXYNOS850_DRD_HSP_TEST); |
| 1604 |
reg &= ~HSP_TEST_SIDDQ; |
| 1605 |
writel(reg, regs_base + EXYNOS850_DRD_HSP_TEST); |
| 1606 |
|
| 1607 |
/* Finish PHY reset (POR=low) */ |
| 1608 |
fsleep(10); /* required before doing POR=low */ |
| 1609 |
reg = readl(regs_base + EXYNOS850_DRD_CLKRST); |
| 1610 |
if (ss_ports) { |
| 1611 |
reg |= CLKRST_PHY20_SW_POR_SEL; |
| 1612 |
reg &= ~CLKRST_PHY20_SW_POR; |
| 1613 |
} |
| 1614 |
reg &= ~(CLKRST_PHY_SW_RST | CLKRST_PORT_RST); |
| 1615 |
writel(reg, regs_base + EXYNOS850_DRD_CLKRST); |
| 1616 |
fsleep(75); /* required after POR=low for guaranteed PHY clock */ |
| 1617 |
|
| 1618 |
/* Disable single ended signal out */ |
| 1619 |
reg = readl(regs_base + EXYNOS850_DRD_HSP); |
| 1620 |
reg &= ~HSP_FSV_OUT_EN; |
| 1621 |
writel(reg, regs_base + EXYNOS850_DRD_HSP); |
| 1622 |
|
| 1623 |
if (ss_ports) |
| 1624 |
exynos5_usbdrd_usb_v3p1_pipe_override(phy_drd); |
| 1625 |
} |
| 1626 |
|
| 1627 |
static int exynos850_usbdrd_phy_init(struct phy *phy) |
| 1628 |
{ |
| 1629 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1630 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1631 |
int ret; |
| 1632 |
|
| 1633 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1634 |
if (ret) |
| 1635 |
return ret; |
| 1636 |
|
| 1637 |
/* UTMI or PIPE3 specific init */ |
| 1638 |
scoped_guard(mutex, &phy_drd->phy_mutex) |
| 1639 |
inst->phy_cfg->phy_init(phy_drd); |
| 1640 |
|
| 1641 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1642 |
|
| 1643 |
return 0; |
| 1644 |
} |
| 1645 |
|
| 1646 |
static int exynos850_usbdrd_phy_exit(struct phy *phy) |
| 1647 |
{ |
| 1648 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1649 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1650 |
void __iomem *regs_base = phy_drd->reg_phy; |
| 1651 |
u32 reg; |
| 1652 |
int ret; |
| 1653 |
|
| 1654 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1655 |
if (ret) |
| 1656 |
return ret; |
| 1657 |
|
| 1658 |
guard(mutex)(&phy_drd->phy_mutex); |
| 1659 |
|
| 1660 |
/* Set PHY clock and control HS PHY */ |
| 1661 |
reg = readl(regs_base + EXYNOS850_DRD_UTMI); |
| 1662 |
reg &= ~(UTMI_DP_PULLDOWN | UTMI_DM_PULLDOWN); |
| 1663 |
reg |= UTMI_FORCE_SUSPEND | UTMI_FORCE_SLEEP; |
| 1664 |
writel(reg, regs_base + EXYNOS850_DRD_UTMI); |
| 1665 |
|
| 1666 |
/* Power down PHY analog blocks */ |
| 1667 |
reg = readl(regs_base + EXYNOS850_DRD_HSP_TEST); |
| 1668 |
reg |= HSP_TEST_SIDDQ; |
| 1669 |
writel(reg, regs_base + EXYNOS850_DRD_HSP_TEST); |
| 1670 |
|
| 1671 |
/* Link reset */ |
| 1672 |
reg = readl(regs_base + EXYNOS850_DRD_CLKRST); |
| 1673 |
reg |= CLKRST_LINK_SW_RST; |
| 1674 |
writel(reg, regs_base + EXYNOS850_DRD_CLKRST); |
| 1675 |
fsleep(10); /* required before doing POR=low */ |
| 1676 |
reg &= ~CLKRST_LINK_SW_RST; |
| 1677 |
writel(reg, regs_base + EXYNOS850_DRD_CLKRST); |
| 1678 |
|
| 1679 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1680 |
|
| 1681 |
return 0; |
| 1682 |
} |
| 1683 |
|
| 1684 |
static const struct phy_ops exynos850_usbdrd_phy_ops = { |
| 1685 |
.init = exynos850_usbdrd_phy_init, |
| 1686 |
.exit = exynos850_usbdrd_phy_exit, |
| 1687 |
.power_on = exynos5_usbdrd_phy_power_on, |
| 1688 |
.power_off = exynos5_usbdrd_phy_power_off, |
| 1689 |
.owner = THIS_MODULE, |
| 1690 |
}; |
| 1691 |
|
| 1692 |
static void exynos5_usbdrd_gs101_pipe3_init(struct exynos5_usbdrd_phy *phy_drd) |
| 1693 |
{ |
| 1694 |
void __iomem *regs_pma = phy_drd->reg_pma; |
| 1695 |
void __iomem *regs_phy = phy_drd->reg_phy; |
| 1696 |
u32 reg; |
| 1697 |
|
| 1698 |
exynos5_usbdrd_usbdp_g2_v4_ctrl_pma_ready(phy_drd); |
| 1699 |
|
| 1700 |
/* force aux off */ |
| 1701 |
reg = readl(regs_pma + EXYNOS9_PMA_USBDP_CMN_REG0008); |
| 1702 |
reg &= ~CMN_REG0008_AUX_EN; |
| 1703 |
reg |= CMN_REG0008_OVRD_AUX_EN; |
| 1704 |
writel(reg, regs_pma + EXYNOS9_PMA_USBDP_CMN_REG0008); |
| 1705 |
|
| 1706 |
exynos5_usbdrd_apply_phy_tunes(phy_drd, PTS_PIPE3_PREINIT); |
| 1707 |
exynos5_usbdrd_apply_phy_tunes(phy_drd, PTS_PIPE3_INIT); |
| 1708 |
exynos5_usbdrd_apply_phy_tunes(phy_drd, PTS_PIPE3_POSTINIT); |
| 1709 |
|
| 1710 |
exynos5_usbdrd_usbdp_g2_v4_pma_lane_mux_sel(phy_drd); |
| 1711 |
|
| 1712 |
/* reset release from port */ |
| 1713 |
reg = readl(regs_phy + EXYNOS850_DRD_SECPMACTL); |
| 1714 |
reg &= ~(SECPMACTL_PMA_TRSV_SW_RST | SECPMACTL_PMA_CMN_SW_RST | |
| 1715 |
SECPMACTL_PMA_INIT_SW_RST); |
| 1716 |
writel(reg, regs_phy + EXYNOS850_DRD_SECPMACTL); |
| 1717 |
|
| 1718 |
if (!exynos5_usbdrd_usbdp_g2_v4_pma_check_pll_lock(phy_drd)) |
| 1719 |
exynos5_usbdrd_usbdp_g2_v4_pma_check_cdr_lock(phy_drd); |
| 1720 |
} |
| 1721 |
|
| 1722 |
static int exynos5_usbdrd_gs101_phy_init(struct phy *phy) |
| 1723 |
{ |
| 1724 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1725 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1726 |
int ret; |
| 1727 |
|
| 1728 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) { |
| 1729 |
/* Power-on PHY ... */ |
| 1730 |
ret = regulator_bulk_enable(phy_drd->drv_data->n_regulators, |
| 1731 |
phy_drd->regulators); |
| 1732 |
if (ret) { |
| 1733 |
dev_err(phy_drd->dev, |
| 1734 |
"Failed to enable PHY regulator(s)\n"); |
| 1735 |
return ret; |
| 1736 |
} |
| 1737 |
} |
| 1738 |
/* |
| 1739 |
* ... and ungate power via PMU. Without this here, we get an SError |
| 1740 |
* trying to access PMA registers |
| 1741 |
*/ |
| 1742 |
exynos5_usbdrd_phy_isol(inst, false); |
| 1743 |
|
| 1744 |
return exynos850_usbdrd_phy_init(phy); |
| 1745 |
} |
| 1746 |
|
| 1747 |
static int exynos5_usbdrd_gs101_phy_exit(struct phy *phy) |
| 1748 |
{ |
| 1749 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 1750 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 1751 |
int ret; |
| 1752 |
|
| 1753 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) { |
| 1754 |
ret = exynos850_usbdrd_phy_exit(phy); |
| 1755 |
if (ret) |
| 1756 |
return ret; |
| 1757 |
} |
| 1758 |
|
| 1759 |
exynos5_usbdrd_phy_isol(inst, true); |
| 1760 |
|
| 1761 |
if (inst->phy_cfg->id != EXYNOS5_DRDPHY_UTMI) |
| 1762 |
return 0; |
| 1763 |
|
| 1764 |
return regulator_bulk_disable(phy_drd->drv_data->n_regulators, |
| 1765 |
phy_drd->regulators); |
| 1766 |
} |
| 1767 |
|
| 1768 |
static const struct phy_ops gs101_usbdrd_phy_ops = { |
| 1769 |
.init = exynos5_usbdrd_gs101_phy_init, |
| 1770 |
.exit = exynos5_usbdrd_gs101_phy_exit, |
| 1771 |
.owner = THIS_MODULE, |
| 1772 |
}; |
| 1773 |
|
| 1774 |
static int exynos5_usbdrd_phy_clk_handle(struct exynos5_usbdrd_phy *phy_drd) |
| 1775 |
{ |
| 1776 |
int ret; |
| 1777 |
struct clk *ref_clk; |
| 1778 |
unsigned long ref_rate; |
| 1779 |
|
| 1780 |
phy_drd->clks = devm_kcalloc(phy_drd->dev, phy_drd->drv_data->n_clks, |
| 1781 |
sizeof(*phy_drd->clks), GFP_KERNEL); |
| 1782 |
if (!phy_drd->clks) |
| 1783 |
return -ENOMEM; |
| 1784 |
|
| 1785 |
for (int i = 0; i < phy_drd->drv_data->n_clks; ++i) |
| 1786 |
phy_drd->clks[i].id = phy_drd->drv_data->clk_names[i]; |
| 1787 |
|
| 1788 |
ret = devm_clk_bulk_get(phy_drd->dev, phy_drd->drv_data->n_clks, |
| 1789 |
phy_drd->clks); |
| 1790 |
if (ret) |
| 1791 |
return dev_err_probe(phy_drd->dev, ret, |
| 1792 |
"failed to get phy clock(s)\n"); |
| 1793 |
|
| 1794 |
phy_drd->core_clks = devm_kcalloc(phy_drd->dev, |
| 1795 |
phy_drd->drv_data->n_core_clks, |
| 1796 |
sizeof(*phy_drd->core_clks), |
| 1797 |
GFP_KERNEL); |
| 1798 |
if (!phy_drd->core_clks) |
| 1799 |
return -ENOMEM; |
| 1800 |
|
| 1801 |
for (int i = 0; i < phy_drd->drv_data->n_core_clks; ++i) |
| 1802 |
phy_drd->core_clks[i].id = phy_drd->drv_data->core_clk_names[i]; |
| 1803 |
|
| 1804 |
ret = devm_clk_bulk_get(phy_drd->dev, phy_drd->drv_data->n_core_clks, |
| 1805 |
phy_drd->core_clks); |
| 1806 |
if (ret) |
| 1807 |
return dev_err_probe(phy_drd->dev, ret, |
| 1808 |
"failed to get phy core clock(s)\n"); |
| 1809 |
|
| 1810 |
if (phy_drd->drv_data->n_core_clks) { |
| 1811 |
ref_clk = NULL; |
| 1812 |
for (int i = 0; i < phy_drd->drv_data->n_core_clks; ++i) { |
| 1813 |
if (!strcmp(phy_drd->core_clks[i].id, "ref")) { |
| 1814 |
ref_clk = phy_drd->core_clks[i].clk; |
| 1815 |
break; |
| 1816 |
} |
| 1817 |
} |
| 1818 |
if (!ref_clk) |
| 1819 |
return dev_err_probe(phy_drd->dev, -ENODEV, |
| 1820 |
"failed to find phy reference clock\n"); |
| 1821 |
|
| 1822 |
ref_rate = clk_get_rate(ref_clk); |
| 1823 |
ret = exynos5_rate_to_clk(ref_rate, &phy_drd->extrefclk); |
| 1824 |
if (ret) |
| 1825 |
return dev_err_probe(phy_drd->dev, ret, |
| 1826 |
"clock rate (%ld) not supported\n", |
| 1827 |
ref_rate); |
| 1828 |
} |
| 1829 |
|
| 1830 |
return 0; |
| 1831 |
} |
| 1832 |
|
| 1833 |
static const struct exynos5_usbdrd_phy_config phy_cfg_exynos2200[] = { |
| 1834 |
{ |
| 1835 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 1836 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 1837 |
.phy_init = exynos2200_usbdrd_utmi_init, |
| 1838 |
}, |
| 1839 |
}; |
| 1840 |
|
| 1841 |
static int exynos5_usbdrd_orien_sw_set(struct typec_switch_dev *sw, |
| 1842 |
enum typec_orientation orientation) |
| 1843 |
{ |
| 1844 |
struct exynos5_usbdrd_phy *phy_drd = typec_switch_get_drvdata(sw); |
| 1845 |
int ret; |
| 1846 |
|
| 1847 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1848 |
if (ret) { |
| 1849 |
dev_err(phy_drd->dev, "Failed to enable PHY clocks(s)\n"); |
| 1850 |
return ret; |
| 1851 |
} |
| 1852 |
|
| 1853 |
scoped_guard(mutex, &phy_drd->phy_mutex) { |
| 1854 |
void __iomem * const regs_base = phy_drd->reg_phy; |
| 1855 |
unsigned int reg; |
| 1856 |
|
| 1857 |
if (orientation == TYPEC_ORIENTATION_NONE) { |
| 1858 |
reg = readl(regs_base + EXYNOS850_DRD_UTMI); |
| 1859 |
reg &= ~(UTMI_FORCE_VBUSVALID | UTMI_FORCE_BVALID); |
| 1860 |
writel(reg, regs_base + EXYNOS850_DRD_UTMI); |
| 1861 |
|
| 1862 |
reg = readl(regs_base + EXYNOS850_DRD_HSP); |
| 1863 |
reg |= HSP_VBUSVLDEXTSEL; |
| 1864 |
reg &= ~HSP_VBUSVLDEXT; |
| 1865 |
writel(reg, regs_base + EXYNOS850_DRD_HSP); |
| 1866 |
} else { |
| 1867 |
reg = readl(regs_base + EXYNOS850_DRD_UTMI); |
| 1868 |
reg |= UTMI_FORCE_VBUSVALID | UTMI_FORCE_BVALID; |
| 1869 |
writel(reg, regs_base + EXYNOS850_DRD_UTMI); |
| 1870 |
|
| 1871 |
reg = readl(regs_base + EXYNOS850_DRD_HSP); |
| 1872 |
reg |= HSP_VBUSVLDEXTSEL | HSP_VBUSVLDEXT; |
| 1873 |
writel(reg, regs_base + EXYNOS850_DRD_HSP); |
| 1874 |
} |
| 1875 |
|
| 1876 |
phy_drd->orientation = orientation; |
| 1877 |
} |
| 1878 |
|
| 1879 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 1880 |
|
| 1881 |
return 0; |
| 1882 |
} |
| 1883 |
|
| 1884 |
static void exynos5_usbdrd_orien_switch_unregister(void *data) |
| 1885 |
{ |
| 1886 |
struct exynos5_usbdrd_phy *phy_drd = data; |
| 1887 |
|
| 1888 |
typec_switch_unregister(phy_drd->sw); |
| 1889 |
} |
| 1890 |
|
| 1891 |
static int exynos5_usbdrd_setup_notifiers(struct exynos5_usbdrd_phy *phy_drd) |
| 1892 |
{ |
| 1893 |
int ret; |
| 1894 |
|
| 1895 |
if (!IS_ENABLED(CONFIG_TYPEC)) |
| 1896 |
return 0; |
| 1897 |
|
| 1898 |
if (device_property_present(phy_drd->dev, "orientation-switch")) { |
| 1899 |
struct typec_switch_desc sw_desc = { }; |
| 1900 |
|
| 1901 |
sw_desc.drvdata = phy_drd; |
| 1902 |
sw_desc.fwnode = dev_fwnode(phy_drd->dev); |
| 1903 |
sw_desc.set = exynos5_usbdrd_orien_sw_set; |
| 1904 |
|
| 1905 |
phy_drd->sw = typec_switch_register(phy_drd->dev, &sw_desc); |
| 1906 |
if (IS_ERR(phy_drd->sw)) |
| 1907 |
return dev_err_probe(phy_drd->dev, |
| 1908 |
PTR_ERR(phy_drd->sw), |
| 1909 |
"Failed to register TypeC orientation switch\n"); |
| 1910 |
|
| 1911 |
ret = devm_add_action_or_reset(phy_drd->dev, |
| 1912 |
exynos5_usbdrd_orien_switch_unregister, |
| 1913 |
phy_drd); |
| 1914 |
if (ret) |
| 1915 |
return dev_err_probe(phy_drd->dev, ret, |
| 1916 |
"Failed to register TypeC orientation devm action\n"); |
| 1917 |
} |
| 1918 |
|
| 1919 |
return 0; |
| 1920 |
} |
| 1921 |
|
| 1922 |
static const struct exynos5_usbdrd_phy_config phy_cfg_exynos5[] = { |
| 1923 |
{ |
| 1924 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 1925 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 1926 |
.phy_init = exynos5_usbdrd_utmi_init, |
| 1927 |
.set_refclk = exynos5_usbdrd_utmi_set_refclk, |
| 1928 |
}, |
| 1929 |
{ |
| 1930 |
.id = EXYNOS5_DRDPHY_PIPE3, |
| 1931 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 1932 |
.phy_init = exynos5_usbdrd_pipe3_init, |
| 1933 |
.set_refclk = exynos5_usbdrd_pipe3_set_refclk, |
| 1934 |
}, |
| 1935 |
}; |
| 1936 |
|
| 1937 |
static const struct exynos5_usbdrd_phy_config phy_cfg_exynos7870[] = { |
| 1938 |
{ |
| 1939 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 1940 |
.phy_isol = exynos7870_usbdrd_phy_isol, |
| 1941 |
.phy_init = exynos7870_usbdrd_utmi_init, |
| 1942 |
}, |
| 1943 |
}; |
| 1944 |
|
| 1945 |
static const struct exynos5_usbdrd_phy_config phy_cfg_exynos850[] = { |
| 1946 |
{ |
| 1947 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 1948 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 1949 |
.phy_init = exynos850_usbdrd_utmi_init, |
| 1950 |
}, |
| 1951 |
}; |
| 1952 |
|
| 1953 |
static |
| 1954 |
const struct exynos5_usbdrd_phy_tuning exynos7870_tunes_utmi_postinit[] = { |
| 1955 |
PHY_TUNING_ENTRY_PHY(EXYNOS5_DRD_PHYPARAM0, |
| 1956 |
(PHYPARAM0_TXVREFTUNE | PHYPARAM0_TXRISETUNE | |
| 1957 |
PHYPARAM0_TXRESTUNE | PHYPARAM0_TXPREEMPPULSETUNE | |
| 1958 |
PHYPARAM0_TXPREEMPAMPTUNE | PHYPARAM0_TXHSXVTUNE | |
| 1959 |
PHYPARAM0_TXFSLSTUNE | PHYPARAM0_SQRXTUNE | |
| 1960 |
PHYPARAM0_OTGTUNE | PHYPARAM0_COMPDISTUNE), |
| 1961 |
(FIELD_PREP_CONST(PHYPARAM0_TXVREFTUNE, 3) | |
| 1962 |
FIELD_PREP_CONST(PHYPARAM0_TXRISETUNE, 1) | |
| 1963 |
FIELD_PREP_CONST(PHYPARAM0_TXRESTUNE, 2) | |
| 1964 |
FIELD_PREP_CONST(PHYPARAM0_TXPREEMPPULSETUNE, 0) | |
| 1965 |
FIELD_PREP_CONST(PHYPARAM0_TXPREEMPAMPTUNE, 0) | |
| 1966 |
FIELD_PREP_CONST(PHYPARAM0_TXHSXVTUNE, 0) | |
| 1967 |
FIELD_PREP_CONST(PHYPARAM0_TXFSLSTUNE, 3) | |
| 1968 |
FIELD_PREP_CONST(PHYPARAM0_SQRXTUNE, 5) | |
| 1969 |
FIELD_PREP_CONST(PHYPARAM0_OTGTUNE, 2) | |
| 1970 |
FIELD_PREP_CONST(PHYPARAM0_COMPDISTUNE, 3))), |
| 1971 |
PHY_TUNING_ENTRY_LAST |
| 1972 |
}; |
| 1973 |
|
| 1974 |
static const struct exynos5_usbdrd_phy_tuning *exynos7870_tunes[PTS_MAX] = { |
| 1975 |
[PTS_UTMI_POSTINIT] = exynos7870_tunes_utmi_postinit, |
| 1976 |
}; |
| 1977 |
|
| 1978 |
static const char * const exynos5_clk_names[] = { |
| 1979 |
"phy", |
| 1980 |
}; |
| 1981 |
|
| 1982 |
static const char * const exynos5_core_clk_names[] = { |
| 1983 |
"ref", |
| 1984 |
}; |
| 1985 |
|
| 1986 |
static const char * const exynos5433_core_clk_names[] = { |
| 1987 |
"ref", "phy_pipe", "phy_utmi", "itp", |
| 1988 |
}; |
| 1989 |
|
| 1990 |
static const char * const exynos5_regulator_names[] = { |
| 1991 |
"vbus", "vbus-boost", |
| 1992 |
}; |
| 1993 |
|
| 1994 |
static const struct exynos5_usbdrd_phy_drvdata exynos2200_usb32drd_phy = { |
| 1995 |
.phy_cfg = phy_cfg_exynos2200, |
| 1996 |
.phy_ops = &exynos2200_usbdrd_phy_ops, |
| 1997 |
.pmu_offset_usbdrd0_phy = EXYNOS2200_PHY_CTRL_USB20, |
| 1998 |
.clk_names = exynos5_clk_names, |
| 1999 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2000 |
/* clocks and regulators are specific to the underlying PHY blocks */ |
| 2001 |
.core_clk_names = NULL, |
| 2002 |
.n_core_clks = 0, |
| 2003 |
.regulator_names = NULL, |
| 2004 |
.n_regulators = 0, |
| 2005 |
}; |
| 2006 |
|
| 2007 |
static const struct exynos5_usbdrd_phy_drvdata exynos5420_usbdrd_phy = { |
| 2008 |
.phy_cfg = phy_cfg_exynos5, |
| 2009 |
.phy_ops = &exynos5_usbdrd_phy_ops, |
| 2010 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2011 |
.pmu_offset_usbdrd1_phy = EXYNOS5420_USBDRD1_PHY_CONTROL, |
| 2012 |
.clk_names = exynos5_clk_names, |
| 2013 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2014 |
.core_clk_names = exynos5_core_clk_names, |
| 2015 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2016 |
.regulator_names = exynos5_regulator_names, |
| 2017 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2018 |
}; |
| 2019 |
|
| 2020 |
static const struct exynos5_usbdrd_phy_drvdata exynos5250_usbdrd_phy = { |
| 2021 |
.phy_cfg = phy_cfg_exynos5, |
| 2022 |
.phy_ops = &exynos5_usbdrd_phy_ops, |
| 2023 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2024 |
.clk_names = exynos5_clk_names, |
| 2025 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2026 |
.core_clk_names = exynos5_core_clk_names, |
| 2027 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2028 |
.regulator_names = exynos5_regulator_names, |
| 2029 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2030 |
}; |
| 2031 |
|
| 2032 |
static const struct exynos5_usbdrd_phy_drvdata exynos5433_usbdrd_phy = { |
| 2033 |
.phy_cfg = phy_cfg_exynos5, |
| 2034 |
.phy_ops = &exynos5_usbdrd_phy_ops, |
| 2035 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2036 |
.pmu_offset_usbdrd1_phy = EXYNOS5433_USBHOST30_PHY_CONTROL, |
| 2037 |
.clk_names = exynos5_clk_names, |
| 2038 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2039 |
.core_clk_names = exynos5433_core_clk_names, |
| 2040 |
.n_core_clks = ARRAY_SIZE(exynos5433_core_clk_names), |
| 2041 |
.regulator_names = exynos5_regulator_names, |
| 2042 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2043 |
}; |
| 2044 |
|
| 2045 |
static const struct exynos5_usbdrd_phy_drvdata exynos7_usbdrd_phy = { |
| 2046 |
.phy_cfg = phy_cfg_exynos5, |
| 2047 |
.phy_ops = &exynos5_usbdrd_phy_ops, |
| 2048 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2049 |
.clk_names = exynos5_clk_names, |
| 2050 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2051 |
.core_clk_names = exynos5433_core_clk_names, |
| 2052 |
.n_core_clks = ARRAY_SIZE(exynos5433_core_clk_names), |
| 2053 |
.regulator_names = exynos5_regulator_names, |
| 2054 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2055 |
}; |
| 2056 |
|
| 2057 |
static const struct exynos5_usbdrd_phy_drvdata exynos7870_usbdrd_phy = { |
| 2058 |
.phy_cfg = phy_cfg_exynos7870, |
| 2059 |
.phy_tunes = exynos7870_tunes, |
| 2060 |
.phy_ops = &exynos7870_usbdrd_phy_ops, |
| 2061 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2062 |
.clk_names = exynos5_clk_names, |
| 2063 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2064 |
.core_clk_names = exynos5_core_clk_names, |
| 2065 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2066 |
.regulator_names = exynos5_regulator_names, |
| 2067 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2068 |
}; |
| 2069 |
|
| 2070 |
static const struct exynos5_usbdrd_phy_drvdata exynos850_usbdrd_phy = { |
| 2071 |
.phy_cfg = phy_cfg_exynos850, |
| 2072 |
.phy_ops = &exynos850_usbdrd_phy_ops, |
| 2073 |
.pmu_offset_usbdrd0_phy = EXYNOS5_USBDRD_PHY_CONTROL, |
| 2074 |
.clk_names = exynos5_clk_names, |
| 2075 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2076 |
.core_clk_names = exynos5_core_clk_names, |
| 2077 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2078 |
.regulator_names = exynos5_regulator_names, |
| 2079 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2080 |
}; |
| 2081 |
|
| 2082 |
static const struct exynos5_usbdrd_phy_tuning exynos990_tunes_utmi_postinit[] = { |
| 2083 |
PHY_TUNING_ENTRY_PHY(EXYNOS850_DRD_HSPPARACON, |
| 2084 |
(HSPPARACON_TXVREF | |
| 2085 |
HSPPARACON_TXPREEMPAMP | HSPPARACON_SQRX | |
| 2086 |
HSPPARACON_COMPDIS), |
| 2087 |
(FIELD_PREP_CONST(HSPPARACON_TXVREF, 7) | |
| 2088 |
FIELD_PREP_CONST(HSPPARACON_TXPREEMPAMP, 3) | |
| 2089 |
FIELD_PREP_CONST(HSPPARACON_SQRX, 5) | |
| 2090 |
FIELD_PREP_CONST(HSPPARACON_COMPDIS, 7))), |
| 2091 |
PHY_TUNING_ENTRY_LAST |
| 2092 |
}; |
| 2093 |
|
| 2094 |
static const struct exynos5_usbdrd_phy_tuning *exynos990_tunes[PTS_MAX] = { |
| 2095 |
[PTS_UTMI_POSTINIT] = exynos990_tunes_utmi_postinit, |
| 2096 |
}; |
| 2097 |
|
| 2098 |
static const struct exynos5_usbdrd_phy_drvdata exynos990_usbdrd_phy = { |
| 2099 |
.phy_cfg = phy_cfg_exynos850, |
| 2100 |
.phy_ops = &exynos850_usbdrd_phy_ops, |
| 2101 |
.phy_tunes = exynos990_tunes, |
| 2102 |
.pmu_offset_usbdrd0_phy = EXYNOS990_PHY_CTRL_USB20, |
| 2103 |
.clk_names = exynos5_clk_names, |
| 2104 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2105 |
.core_clk_names = exynos5_core_clk_names, |
| 2106 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2107 |
.regulator_names = exynos5_regulator_names, |
| 2108 |
.n_regulators = ARRAY_SIZE(exynos5_regulator_names), |
| 2109 |
}; |
| 2110 |
|
| 2111 |
static void |
| 2112 |
exynosautov920_usb31drd_cr_clk(struct exynos5_usbdrd_phy *phy_drd, bool high) |
| 2113 |
{ |
| 2114 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2115 |
u32 reg; |
| 2116 |
|
| 2117 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2118 |
if (high) |
| 2119 |
reg |= PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK; |
| 2120 |
else |
| 2121 |
reg &= ~PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK; |
| 2122 |
|
| 2123 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2124 |
fsleep(1); |
| 2125 |
} |
| 2126 |
|
| 2127 |
static void |
| 2128 |
exynosautov920_usb31drd_port_phy_ready(struct exynos5_usbdrd_phy *phy_drd) |
| 2129 |
{ |
| 2130 |
struct device *dev = phy_drd->dev; |
| 2131 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2132 |
static const unsigned int timeout_us = 20000; |
| 2133 |
static const unsigned int sleep_us = 40; |
| 2134 |
u32 reg; |
| 2135 |
int err; |
| 2136 |
|
| 2137 |
/* Clear cr_para_con */ |
| 2138 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2139 |
reg &= ~(PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK | |
| 2140 |
PHY_CR_PARA_CON0_PHY0_CR_PARA_ADDR); |
| 2141 |
reg |= PHY_CR_PARA_CON0_PHY0_CR_PARA_SEL; |
| 2142 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2143 |
writel(0x0, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON1); |
| 2144 |
writel(0x0, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON2); |
| 2145 |
|
| 2146 |
exynosautov920_usb31drd_cr_clk(phy_drd, true); |
| 2147 |
exynosautov920_usb31drd_cr_clk(phy_drd, false); |
| 2148 |
|
| 2149 |
/* |
| 2150 |
* The maximum time from phy reset de-assertion to de-assertion of |
| 2151 |
* tx/rx_ack can be as high as 5ms in fast simulation mode. |
| 2152 |
* Time to phy ready is < 20ms |
| 2153 |
*/ |
| 2154 |
err = readl_poll_timeout(reg_phy + |
| 2155 |
EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0, |
| 2156 |
reg, !(reg & PHY_CR_PARA_CON0_PHY0_CR_PARA_ACK), |
| 2157 |
sleep_us, timeout_us); |
| 2158 |
if (err) |
| 2159 |
dev_err(dev, "timed out waiting for rx/tx_ack: %#.8x\n", reg); |
| 2160 |
|
| 2161 |
reg &= ~PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK; |
| 2162 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2163 |
} |
| 2164 |
|
| 2165 |
static void |
| 2166 |
exynosautov920_usb31drd_cr_write(struct exynos5_usbdrd_phy *phy_drd, |
| 2167 |
u16 addr, u16 data) |
| 2168 |
{ |
| 2169 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2170 |
u32 cnt = 0; |
| 2171 |
u32 reg; |
| 2172 |
|
| 2173 |
/* Pre Clocking */ |
| 2174 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2175 |
reg |= PHY_CR_PARA_CON0_PHY0_CR_PARA_SEL; |
| 2176 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2177 |
|
| 2178 |
/* |
| 2179 |
* tx clks must be available prior to assertion of tx req. |
| 2180 |
* tx pstate p2 to p0 transition directly is not permitted. |
| 2181 |
* tx clk ready must be asserted synchronously on tx clk prior |
| 2182 |
* to internal transmit clk alignment sequence in the phy |
| 2183 |
* when entering from p2 to p1 to p0. |
| 2184 |
*/ |
| 2185 |
do { |
| 2186 |
exynosautov920_usb31drd_cr_clk(phy_drd, true); |
| 2187 |
exynosautov920_usb31drd_cr_clk(phy_drd, false); |
| 2188 |
cnt++; |
| 2189 |
} while (cnt < 15); |
| 2190 |
|
| 2191 |
reg &= ~PHY_CR_PARA_CON0_PHY0_CR_PARA_SEL; |
| 2192 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2193 |
|
| 2194 |
/* |
| 2195 |
* tx data path is active when tx lane is in p0 state |
| 2196 |
* and tx data en asserted. enable cr_para_wr_en. |
| 2197 |
*/ |
| 2198 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON2); |
| 2199 |
reg &= ~PHY_CR_PARA_CON2_PHY0_CR_PARA_WR_DATA; |
| 2200 |
reg |= FIELD_PREP(PHY_CR_PARA_CON2_PHY0_CR_PARA_WR_DATA, data) | |
| 2201 |
PHY_CR_PARA_CON2_PHY0_CR_PARA_WR_EN; |
| 2202 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON2); |
| 2203 |
|
| 2204 |
/* write addr */ |
| 2205 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2206 |
reg &= ~PHY_CR_PARA_CON0_PHY0_CR_PARA_ADDR; |
| 2207 |
reg |= FIELD_PREP(PHY_CR_PARA_CON0_PHY0_CR_PARA_ADDR, addr) | |
| 2208 |
PHY_CR_PARA_CON0_PHY0_CR_PARA_CLK | |
| 2209 |
PHY_CR_PARA_CON0_PHY0_CR_PARA_SEL; |
| 2210 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2211 |
|
| 2212 |
/* check cr_para_ack*/ |
| 2213 |
cnt = 0; |
| 2214 |
do { |
| 2215 |
/* |
| 2216 |
* data symbols are captured by phy on rising edge of the |
| 2217 |
* tx_clk when tx data enabled. |
| 2218 |
* completion of the write cycle is acknowledged by assertion |
| 2219 |
* of the cr_para_ack. |
| 2220 |
*/ |
| 2221 |
exynosautov920_usb31drd_cr_clk(phy_drd, true); |
| 2222 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CR_PARA_CON0); |
| 2223 |
if ((reg & PHY_CR_PARA_CON0_PHY0_CR_PARA_ACK)) |
| 2224 |
break; |
| 2225 |
|
| 2226 |
exynosautov920_usb31drd_cr_clk(phy_drd, false); |
| 2227 |
|
| 2228 |
/* |
| 2229 |
* wait for minimum of 10 cr_para_clk cycles after phy reset |
| 2230 |
* is negated, before accessing control regs to allow for |
| 2231 |
* internal resets. |
| 2232 |
*/ |
| 2233 |
cnt++; |
| 2234 |
} while (cnt < 10); |
| 2235 |
|
| 2236 |
if (cnt < 10) |
| 2237 |
exynosautov920_usb31drd_cr_clk(phy_drd, false); |
| 2238 |
} |
| 2239 |
|
| 2240 |
static void |
| 2241 |
exynosautov920_usb31drd_phy_reset(struct exynos5_usbdrd_phy *phy_drd, int val) |
| 2242 |
{ |
| 2243 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2244 |
u32 reg; |
| 2245 |
|
| 2246 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2247 |
reg &= ~PHY_RST_CTRL_PHY_RESET_OVRD_EN; |
| 2248 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2249 |
|
| 2250 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2251 |
if (val) |
| 2252 |
reg |= PHY_RST_CTRL_PHY_RESET; |
| 2253 |
else |
| 2254 |
reg &= ~PHY_RST_CTRL_PHY_RESET; |
| 2255 |
|
| 2256 |
reg |= PHY_RST_CTRL_PHY_RESET_OVRD_EN; |
| 2257 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2258 |
} |
| 2259 |
|
| 2260 |
static void |
| 2261 |
exynosautov920_usb31drd_lane0_reset(struct exynos5_usbdrd_phy *phy_drd, int val) |
| 2262 |
{ |
| 2263 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2264 |
u32 reg; |
| 2265 |
|
| 2266 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2267 |
reg |= PHY_RST_CTRL_PIPE_LANE0_RESET_N_OVRD_EN; |
| 2268 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2269 |
|
| 2270 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2271 |
if (val) |
| 2272 |
reg &= ~PHY_RST_CTRL_PIPE_LANE0_RESET_N; |
| 2273 |
else |
| 2274 |
reg |= PHY_RST_CTRL_PIPE_LANE0_RESET_N; |
| 2275 |
|
| 2276 |
reg &= ~PHY_RST_CTRL_PIPE_LANE0_RESET_N_OVRD_EN; |
| 2277 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_RST_CTRL); |
| 2278 |
} |
| 2279 |
|
| 2280 |
static void |
| 2281 |
exynosautov920_usb31drd_pipe3_init(struct exynos5_usbdrd_phy *phy_drd) |
| 2282 |
{ |
| 2283 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2284 |
u32 reg; |
| 2285 |
|
| 2286 |
/* |
| 2287 |
* Phy and Pipe Lane reset assert. |
| 2288 |
* assert reset (phy_reset = 1). |
| 2289 |
* The lane-ack outputs are asserted during reset (tx_ack = rx_ack = 1) |
| 2290 |
*/ |
| 2291 |
exynosautov920_usb31drd_phy_reset(phy_drd, 1); |
| 2292 |
exynosautov920_usb31drd_lane0_reset(phy_drd, 1); |
| 2293 |
|
| 2294 |
/* |
| 2295 |
* ANA Power En, PCS & PMA PWR Stable Set |
| 2296 |
* ramp-up power suppiles |
| 2297 |
*/ |
| 2298 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG0); |
| 2299 |
reg |= PHY_CONFIG0_PHY0_ANA_PWR_EN | PHY_CONFIG0_PHY0_PCS_PWR_STABLE | |
| 2300 |
PHY_CONFIG0_PHY0_PMA_PWR_STABLE; |
| 2301 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG0); |
| 2302 |
|
| 2303 |
fsleep(10); |
| 2304 |
|
| 2305 |
/* |
| 2306 |
* phy is not functional in test_powerdown mode, test_powerdown to be |
| 2307 |
* de-asserted for normal operation |
| 2308 |
*/ |
| 2309 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG7); |
| 2310 |
reg &= ~PHY_CONFIG7_PHY_TEST_POWERDOWN; |
| 2311 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG7); |
| 2312 |
|
| 2313 |
/* |
| 2314 |
* phy reset signal be asserted for minimum 10us after power |
| 2315 |
* supplies are ramped-up |
| 2316 |
*/ |
| 2317 |
fsleep(10); |
| 2318 |
|
| 2319 |
/* |
| 2320 |
* Phy and Pipe Lane reset assert de-assert |
| 2321 |
*/ |
| 2322 |
exynosautov920_usb31drd_phy_reset(phy_drd, 0); |
| 2323 |
exynosautov920_usb31drd_lane0_reset(phy_drd, 0); |
| 2324 |
|
| 2325 |
/* Pipe_rx0_sris_mode_en = 1 */ |
| 2326 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG4); |
| 2327 |
reg |= PHY_CONFIG4_PIPE_RX0_SRIS_MODE_EN; |
| 2328 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG4); |
| 2329 |
|
| 2330 |
/* |
| 2331 |
* wait for lane ack outputs to de-assert (tx_ack = rx_ack = 0) |
| 2332 |
* Exit from the reset state is indicated by de-assertion of *_ack |
| 2333 |
*/ |
| 2334 |
exynosautov920_usb31drd_port_phy_ready(phy_drd); |
| 2335 |
|
| 2336 |
/* override values for level settings */ |
| 2337 |
exynosautov920_usb31drd_cr_write(phy_drd, 0x22, 0x00F5); |
| 2338 |
} |
| 2339 |
|
| 2340 |
static void |
| 2341 |
exynosautov920_usb31drd_ssphy_disable(struct exynos5_usbdrd_phy *phy_drd) |
| 2342 |
{ |
| 2343 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2344 |
u32 reg; |
| 2345 |
|
| 2346 |
/* 1. Assert reset (phy_reset = 1) */ |
| 2347 |
exynosautov920_usb31drd_lane0_reset(phy_drd, 1); |
| 2348 |
exynosautov920_usb31drd_phy_reset(phy_drd, 1); |
| 2349 |
|
| 2350 |
/* phy test power down */ |
| 2351 |
reg = readl(reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG7); |
| 2352 |
reg |= PHY_CONFIG7_PHY_TEST_POWERDOWN; |
| 2353 |
writel(reg, reg_phy + EXYNOSAUTOV920_USB31DRD_PHY_CONFIG7); |
| 2354 |
} |
| 2355 |
|
| 2356 |
static void |
| 2357 |
exynosautov920_usbdrd_utmi_init(struct exynos5_usbdrd_phy *phy_drd) |
| 2358 |
{ |
| 2359 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2360 |
u32 reg; |
| 2361 |
|
| 2362 |
/* |
| 2363 |
* Disable HWACG (hardware auto clock gating control). This |
| 2364 |
* forces QACTIVE signal in Q-Channel interface to HIGH level, |
| 2365 |
* to make sure the PHY clock is not gated by the hardware. |
| 2366 |
*/ |
| 2367 |
reg = readl(reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2368 |
reg |= LINKCTRL_FORCE_QACT; |
| 2369 |
writel(reg, reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2370 |
|
| 2371 |
/* De-assert link reset */ |
| 2372 |
reg = readl(reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2373 |
reg &= ~CLKRST_LINK_SW_RST; |
| 2374 |
writel(reg, reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2375 |
|
| 2376 |
/* Set PHY POR High */ |
| 2377 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSP_CLKRST); |
| 2378 |
reg |= HSPCLKRST_PHY20_SW_POR | HSPCLKRST_PHY20_SW_POR_SEL; |
| 2379 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSP_CLKRST); |
| 2380 |
|
| 2381 |
/* Enable UTMI+ */ |
| 2382 |
reg = readl(reg_phy + EXYNOS2200_DRD_UTMI); |
| 2383 |
reg &= ~(UTMICTL_FORCE_UTMI_SUSPEND | UTMICTL_FORCE_UTMI_SLEEP | |
| 2384 |
UTMICTL_FORCE_DPPULLDOWN | UTMICTL_FORCE_DMPULLDOWN); |
| 2385 |
writel(reg, reg_phy + EXYNOS2200_DRD_UTMI); |
| 2386 |
|
| 2387 |
/* set phy clock & control HS phy */ |
| 2388 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSPCTL); |
| 2389 |
reg |= HSPCTRL_EN_UTMISUSPEND | HSPCTRL_COMMONONN; |
| 2390 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSPCTL); |
| 2391 |
|
| 2392 |
fsleep(100); |
| 2393 |
|
| 2394 |
/* Set VBUS Valid and DP-Pull up control by VBUS pad usage */ |
| 2395 |
reg = readl(reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2396 |
reg |= FIELD_PREP_CONST(LINKCTRL_BUS_FILTER_BYPASS, 0xf); |
| 2397 |
writel(reg, reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2398 |
|
| 2399 |
reg = readl(reg_phy + EXYNOS2200_DRD_UTMI); |
| 2400 |
reg |= EXYNOS2200_UTMI_FORCE_VBUSVALID | EXYNOS2200_UTMI_FORCE_BVALID; |
| 2401 |
writel(reg, reg_phy + EXYNOS2200_DRD_UTMI); |
| 2402 |
|
| 2403 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSPCTL); |
| 2404 |
reg |= HSPCTRL_VBUSVLDEXTSEL | HSPCTRL_VBUSVLDEXT; |
| 2405 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSPCTL); |
| 2406 |
|
| 2407 |
/* Setting FSEL for refference clock */ |
| 2408 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSPPLLTUNE); |
| 2409 |
reg &= ~HSPPLLTUNE_FSEL; |
| 2410 |
|
| 2411 |
switch (phy_drd->extrefclk) { |
| 2412 |
case EXYNOS5_FSEL_50MHZ: |
| 2413 |
reg |= FIELD_PREP(HSPPLLTUNE_FSEL, 7); |
| 2414 |
break; |
| 2415 |
case EXYNOS5_FSEL_26MHZ: |
| 2416 |
reg |= FIELD_PREP(HSPPLLTUNE_FSEL, 6); |
| 2417 |
break; |
| 2418 |
case EXYNOS5_FSEL_24MHZ: |
| 2419 |
reg |= FIELD_PREP(HSPPLLTUNE_FSEL, 2); |
| 2420 |
break; |
| 2421 |
case EXYNOS5_FSEL_20MHZ: |
| 2422 |
reg |= FIELD_PREP(HSPPLLTUNE_FSEL, 1); |
| 2423 |
break; |
| 2424 |
case EXYNOS5_FSEL_19MHZ2: |
| 2425 |
reg |= FIELD_PREP(HSPPLLTUNE_FSEL, 0); |
| 2426 |
break; |
| 2427 |
default: |
| 2428 |
dev_warn(phy_drd->dev, "unsupported ref clk: %#.2x\n", |
| 2429 |
phy_drd->extrefclk); |
| 2430 |
break; |
| 2431 |
} |
| 2432 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSPPLLTUNE); |
| 2433 |
|
| 2434 |
/* Enable PHY Power Mode */ |
| 2435 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSP_TEST); |
| 2436 |
reg &= ~HSP_TEST_SIDDQ; |
| 2437 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSP_TEST); |
| 2438 |
|
| 2439 |
/* before POR low, 10us delay is needed to Finish PHY reset */ |
| 2440 |
fsleep(10); |
| 2441 |
|
| 2442 |
/* Set PHY POR Low */ |
| 2443 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSP_CLKRST); |
| 2444 |
reg |= HSPCLKRST_PHY20_SW_POR_SEL; |
| 2445 |
reg &= ~(HSPCLKRST_PHY20_SW_POR | HSPCLKRST_PHY20_SW_PORTRESET); |
| 2446 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSP_CLKRST); |
| 2447 |
|
| 2448 |
/* after POR low and delay 75us, PHYCLOCK is guaranteed. */ |
| 2449 |
fsleep(75); |
| 2450 |
|
| 2451 |
/* Disable forcing pipe interface */ |
| 2452 |
reg = readl(reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2453 |
reg &= ~LINKCTRL_FORCE_PIPE_EN; |
| 2454 |
writel(reg, reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2455 |
|
| 2456 |
/* Pclk to pipe_clk */ |
| 2457 |
reg = readl(reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2458 |
reg |= EXYNOS2200_CLKRST_LINK_PCLK_SEL; |
| 2459 |
writel(reg, reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2460 |
} |
| 2461 |
|
| 2462 |
static void |
| 2463 |
exynosautov920_usbdrd_hsphy_disable(struct exynos5_usbdrd_phy *phy_drd) |
| 2464 |
{ |
| 2465 |
u32 reg; |
| 2466 |
void __iomem *reg_phy = phy_drd->reg_phy; |
| 2467 |
|
| 2468 |
/* set phy clock & control HS phy */ |
| 2469 |
reg = readl(reg_phy + EXYNOS2200_DRD_UTMI); |
| 2470 |
reg |= UTMICTL_FORCE_UTMI_SUSPEND | UTMICTL_FORCE_UTMI_SLEEP; |
| 2471 |
reg &= ~(UTMICTL_FORCE_DPPULLDOWN | UTMICTL_FORCE_DMPULLDOWN); |
| 2472 |
writel(reg, reg_phy + EXYNOS2200_DRD_UTMI); |
| 2473 |
|
| 2474 |
/* Disable PHY Power Mode */ |
| 2475 |
reg = readl(reg_phy + EXYNOSAUTOV920_DRD_HSP_TEST); |
| 2476 |
reg |= HSP_TEST_SIDDQ; |
| 2477 |
writel(reg, reg_phy + EXYNOSAUTOV920_DRD_HSP_TEST); |
| 2478 |
|
| 2479 |
/* clear force q-channel */ |
| 2480 |
reg = readl(reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2481 |
reg &= ~LINKCTRL_FORCE_QACT; |
| 2482 |
writel(reg, reg_phy + EXYNOS850_DRD_LINKCTRL); |
| 2483 |
|
| 2484 |
/* link sw reset is need for USB_DP/DM high-z in host mode */ |
| 2485 |
reg = readl(reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2486 |
reg |= CLKRST_LINK_SW_RST; |
| 2487 |
writel(reg, reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2488 |
fsleep(10); |
| 2489 |
reg &= ~CLKRST_LINK_SW_RST; |
| 2490 |
writel(reg, reg_phy + EXYNOS2200_DRD_CLKRST); |
| 2491 |
} |
| 2492 |
|
| 2493 |
static int exynosautov920_usbdrd_phy_init(struct phy *phy) |
| 2494 |
{ |
| 2495 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 2496 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 2497 |
int ret; |
| 2498 |
|
| 2499 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2500 |
if (ret) |
| 2501 |
return ret; |
| 2502 |
|
| 2503 |
/* Bypass PHY isol */ |
| 2504 |
inst->phy_cfg->phy_isol(inst, false); |
| 2505 |
|
| 2506 |
/* UTMI or PIPE3 specific init */ |
| 2507 |
inst->phy_cfg->phy_init(phy_drd); |
| 2508 |
|
| 2509 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2510 |
|
| 2511 |
return 0; |
| 2512 |
} |
| 2513 |
|
| 2514 |
static int exynosautov920_usbdrd_phy_exit(struct phy *phy) |
| 2515 |
{ |
| 2516 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 2517 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 2518 |
int ret; |
| 2519 |
|
| 2520 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2521 |
if (ret) |
| 2522 |
return ret; |
| 2523 |
|
| 2524 |
exynos850_usbdrd_phy_exit(phy); |
| 2525 |
|
| 2526 |
/* enable PHY isol */ |
| 2527 |
inst->phy_cfg->phy_isol(inst, true); |
| 2528 |
|
| 2529 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2530 |
|
| 2531 |
return 0; |
| 2532 |
} |
| 2533 |
|
| 2534 |
static int exynosautov920_usbdrd_combo_phy_exit(struct phy *phy) |
| 2535 |
{ |
| 2536 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 2537 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 2538 |
int ret = 0; |
| 2539 |
|
| 2540 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2541 |
if (ret) |
| 2542 |
return ret; |
| 2543 |
|
| 2544 |
if (inst->phy_cfg->id == EXYNOS5_DRDPHY_UTMI) |
| 2545 |
exynosautov920_usbdrd_hsphy_disable(phy_drd); |
| 2546 |
else if (inst->phy_cfg->id == EXYNOS5_DRDPHY_PIPE3) |
| 2547 |
exynosautov920_usb31drd_ssphy_disable(phy_drd); |
| 2548 |
|
| 2549 |
/* enable PHY isol */ |
| 2550 |
inst->phy_cfg->phy_isol(inst, true); |
| 2551 |
|
| 2552 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_clks, phy_drd->clks); |
| 2553 |
|
| 2554 |
return 0; |
| 2555 |
} |
| 2556 |
|
| 2557 |
static int exynosautov920_usbdrd_phy_power_on(struct phy *phy) |
| 2558 |
{ |
| 2559 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 2560 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 2561 |
int ret; |
| 2562 |
|
| 2563 |
dev_dbg(phy_drd->dev, "Request to power_on usbdrd_phy phy\n"); |
| 2564 |
|
| 2565 |
ret = clk_bulk_prepare_enable(phy_drd->drv_data->n_core_clks, |
| 2566 |
phy_drd->core_clks); |
| 2567 |
if (ret) |
| 2568 |
return ret; |
| 2569 |
|
| 2570 |
/* Enable supply */ |
| 2571 |
ret = regulator_bulk_enable(phy_drd->drv_data->n_regulators, |
| 2572 |
phy_drd->regulators); |
| 2573 |
if (ret) { |
| 2574 |
dev_err(phy_drd->dev, "Failed to enable PHY regulator(s)\n"); |
| 2575 |
goto fail_supply; |
| 2576 |
} |
| 2577 |
|
| 2578 |
return 0; |
| 2579 |
|
| 2580 |
fail_supply: |
| 2581 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_core_clks, |
| 2582 |
phy_drd->core_clks); |
| 2583 |
|
| 2584 |
return ret; |
| 2585 |
} |
| 2586 |
|
| 2587 |
static int exynosautov920_usbdrd_phy_power_off(struct phy *phy) |
| 2588 |
{ |
| 2589 |
struct phy_usb_instance *inst = phy_get_drvdata(phy); |
| 2590 |
struct exynos5_usbdrd_phy *phy_drd = to_usbdrd_phy(inst); |
| 2591 |
|
| 2592 |
dev_dbg(phy_drd->dev, "Request to power_off usbdrd_phy phy\n"); |
| 2593 |
|
| 2594 |
/* Disable supply */ |
| 2595 |
regulator_bulk_disable(phy_drd->drv_data->n_regulators, |
| 2596 |
phy_drd->regulators); |
| 2597 |
|
| 2598 |
clk_bulk_disable_unprepare(phy_drd->drv_data->n_core_clks, |
| 2599 |
phy_drd->core_clks); |
| 2600 |
|
| 2601 |
return 0; |
| 2602 |
} |
| 2603 |
|
| 2604 |
static const char * const exynosautov920_usb30_regulators[] = { |
| 2605 |
"dvdd", "vdd18", |
| 2606 |
}; |
| 2607 |
|
| 2608 |
static const char * const exynosautov920_usb20_regulators[] = { |
| 2609 |
"dvdd", "vdd18", "vdd33", |
| 2610 |
}; |
| 2611 |
|
| 2612 |
static const struct |
| 2613 |
exynos5_usbdrd_phy_config usb31drd_phy_cfg_exynosautov920[] = { |
| 2614 |
{ |
| 2615 |
.id = EXYNOS5_DRDPHY_PIPE3, |
| 2616 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 2617 |
.phy_init = exynosautov920_usb31drd_pipe3_init, |
| 2618 |
}, |
| 2619 |
}; |
| 2620 |
|
| 2621 |
static const struct phy_ops exynosautov920_usb31drd_combo_ssphy_ops = { |
| 2622 |
.init = exynosautov920_usbdrd_phy_init, |
| 2623 |
.exit = exynosautov920_usbdrd_combo_phy_exit, |
| 2624 |
.power_on = exynosautov920_usbdrd_phy_power_on, |
| 2625 |
.power_off = exynosautov920_usbdrd_phy_power_off, |
| 2626 |
.owner = THIS_MODULE, |
| 2627 |
}; |
| 2628 |
|
| 2629 |
static const |
| 2630 |
struct exynos5_usbdrd_phy_drvdata exynosautov920_usb31drd_combo_ssphy = { |
| 2631 |
.phy_cfg = usb31drd_phy_cfg_exynosautov920, |
| 2632 |
.phy_ops = &exynosautov920_usb31drd_combo_ssphy_ops, |
| 2633 |
.pmu_offset_usbdrd0_phy = EXYNOSAUTOV920_PHY_CTRL_USB31, |
| 2634 |
.clk_names = exynos5_clk_names, |
| 2635 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2636 |
.core_clk_names = exynos5_core_clk_names, |
| 2637 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2638 |
.regulator_names = exynosautov920_usb30_regulators, |
| 2639 |
.n_regulators = ARRAY_SIZE(exynosautov920_usb30_regulators), |
| 2640 |
}; |
| 2641 |
|
| 2642 |
static const struct phy_ops exynosautov920_usbdrd_combo_hsphy_ops = { |
| 2643 |
.init = exynosautov920_usbdrd_phy_init, |
| 2644 |
.exit = exynosautov920_usbdrd_combo_phy_exit, |
| 2645 |
.power_on = exynosautov920_usbdrd_phy_power_on, |
| 2646 |
.power_off = exynosautov920_usbdrd_phy_power_off, |
| 2647 |
.owner = THIS_MODULE, |
| 2648 |
}; |
| 2649 |
|
| 2650 |
static const struct |
| 2651 |
exynos5_usbdrd_phy_config usbdrd_hsphy_cfg_exynosautov920[] = { |
| 2652 |
{ |
| 2653 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 2654 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 2655 |
.phy_init = exynosautov920_usbdrd_utmi_init, |
| 2656 |
}, |
| 2657 |
}; |
| 2658 |
|
| 2659 |
static const |
| 2660 |
struct exynos5_usbdrd_phy_drvdata exynosautov920_usbdrd_combo_hsphy = { |
| 2661 |
.phy_cfg = usbdrd_hsphy_cfg_exynosautov920, |
| 2662 |
.phy_ops = &exynosautov920_usbdrd_combo_hsphy_ops, |
| 2663 |
.pmu_offset_usbdrd0_phy = EXYNOSAUTOV920_PHY_CTRL_USB20, |
| 2664 |
.clk_names = exynos5_clk_names, |
| 2665 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2666 |
.core_clk_names = exynos5_core_clk_names, |
| 2667 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2668 |
.regulator_names = exynosautov920_usb20_regulators, |
| 2669 |
.n_regulators = ARRAY_SIZE(exynosautov920_usb20_regulators), |
| 2670 |
}; |
| 2671 |
|
| 2672 |
static const struct phy_ops exynosautov920_usbdrd_phy_ops = { |
| 2673 |
.init = exynosautov920_usbdrd_phy_init, |
| 2674 |
.exit = exynosautov920_usbdrd_phy_exit, |
| 2675 |
.power_on = exynosautov920_usbdrd_phy_power_on, |
| 2676 |
.power_off = exynosautov920_usbdrd_phy_power_off, |
| 2677 |
.owner = THIS_MODULE, |
| 2678 |
}; |
| 2679 |
|
| 2680 |
static const struct exynos5_usbdrd_phy_config phy_cfg_exynosautov920[] = { |
| 2681 |
{ |
| 2682 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 2683 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 2684 |
.phy_init = exynos850_usbdrd_utmi_init, |
| 2685 |
}, |
| 2686 |
}; |
| 2687 |
|
| 2688 |
static const struct exynos5_usbdrd_phy_drvdata exynosautov920_usbdrd_phy = { |
| 2689 |
.phy_cfg = phy_cfg_exynosautov920, |
| 2690 |
.phy_ops = &exynosautov920_usbdrd_phy_ops, |
| 2691 |
.pmu_offset_usbdrd0_phy = EXYNOSAUTOV920_PHY_CTRL_USB20, |
| 2692 |
.clk_names = exynos5_clk_names, |
| 2693 |
.n_clks = ARRAY_SIZE(exynos5_clk_names), |
| 2694 |
.core_clk_names = exynos5_core_clk_names, |
| 2695 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2696 |
.regulator_names = exynosautov920_usb20_regulators, |
| 2697 |
.n_regulators = ARRAY_SIZE(exynosautov920_usb20_regulators), |
| 2698 |
}; |
| 2699 |
|
| 2700 |
static const struct exynos5_usbdrd_phy_config phy_cfg_gs101[] = { |
| 2701 |
{ |
| 2702 |
.id = EXYNOS5_DRDPHY_UTMI, |
| 2703 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 2704 |
.phy_init = exynos850_usbdrd_utmi_init, |
| 2705 |
}, |
| 2706 |
{ |
| 2707 |
.id = EXYNOS5_DRDPHY_PIPE3, |
| 2708 |
.phy_isol = exynos5_usbdrd_phy_isol, |
| 2709 |
.phy_init = exynos5_usbdrd_gs101_pipe3_init, |
| 2710 |
}, |
| 2711 |
}; |
| 2712 |
|
| 2713 |
static const struct exynos5_usbdrd_phy_tuning gs101_tunes_utmi_postinit[] = { |
| 2714 |
PHY_TUNING_ENTRY_PHY(EXYNOS850_DRD_HSPPARACON, |
| 2715 |
(HSPPARACON_TXVREF | HSPPARACON_TXRES | |
| 2716 |
HSPPARACON_TXPREEMPAMP | HSPPARACON_SQRX | |
| 2717 |
HSPPARACON_COMPDIS), |
| 2718 |
(FIELD_PREP_CONST(HSPPARACON_TXVREF, 6) | |
| 2719 |
FIELD_PREP_CONST(HSPPARACON_TXRES, 1) | |
| 2720 |
FIELD_PREP_CONST(HSPPARACON_TXPREEMPAMP, 3) | |
| 2721 |
FIELD_PREP_CONST(HSPPARACON_SQRX, 5) | |
| 2722 |
FIELD_PREP_CONST(HSPPARACON_COMPDIS, 7))), |
| 2723 |
PHY_TUNING_ENTRY_LAST |
| 2724 |
}; |
| 2725 |
|
| 2726 |
static const struct exynos5_usbdrd_phy_tuning gs101_tunes_pipe3_preinit[] = { |
| 2727 |
/* preinit */ |
| 2728 |
/* CDR data mode exit GEN1 ON / GEN2 OFF */ |
| 2729 |
PHY_TUNING_ENTRY_PMA(0x0c8c, -1, 0xff), |
| 2730 |
PHY_TUNING_ENTRY_PMA(0x1c8c, -1, 0xff), |
| 2731 |
PHY_TUNING_ENTRY_PMA(0x0c9c, -1, 0x7d), |
| 2732 |
PHY_TUNING_ENTRY_PMA(0x1c9c, -1, 0x7d), |
| 2733 |
/* improve EDS distribution */ |
| 2734 |
PHY_TUNING_ENTRY_PMA(0x0e7c, -1, 0x06), |
| 2735 |
PHY_TUNING_ENTRY_PMA(0x09e0, -1, 0x00), |
| 2736 |
PHY_TUNING_ENTRY_PMA(0x09e4, -1, 0x36), |
| 2737 |
PHY_TUNING_ENTRY_PMA(0x1e7c, -1, 0x06), |
| 2738 |
PHY_TUNING_ENTRY_PMA(0x19e0, -1, 0x00), |
| 2739 |
PHY_TUNING_ENTRY_PMA(0x19e4, -1, 0x36), |
| 2740 |
/* fix bootloader bug */ |
| 2741 |
PHY_TUNING_ENTRY_PMA(0x1e90, -1, 0x02), |
| 2742 |
PHY_TUNING_ENTRY_PMA(0x1e94, -1, 0x0b), |
| 2743 |
/* improve LVCC */ |
| 2744 |
PHY_TUNING_ENTRY_PMA(0x08f0, -1, 0x30), |
| 2745 |
PHY_TUNING_ENTRY_PMA(0x18f0, -1, 0x30), |
| 2746 |
/* LFPS RX VIH shmoo hole */ |
| 2747 |
PHY_TUNING_ENTRY_PMA(0x0a08, -1, 0x0c), |
| 2748 |
PHY_TUNING_ENTRY_PMA(0x1a08, -1, 0x0c), |
| 2749 |
/* remove unrelated option for v4 phy */ |
| 2750 |
PHY_TUNING_ENTRY_PMA(0x0a0c, -1, 0x05), |
| 2751 |
PHY_TUNING_ENTRY_PMA(0x1a0c, -1, 0x05), |
| 2752 |
/* improve Gen2 LVCC */ |
| 2753 |
PHY_TUNING_ENTRY_PMA(0x00f8, -1, 0x1c), |
| 2754 |
PHY_TUNING_ENTRY_PMA(0x00fc, -1, 0x54), |
| 2755 |
/* Change Vth of RCV_DET because of TD 7.40 Polling Retry Test */ |
| 2756 |
PHY_TUNING_ENTRY_PMA(0x104c, -1, 0x07), |
| 2757 |
PHY_TUNING_ENTRY_PMA(0x204c, -1, 0x07), |
| 2758 |
/* reduce Ux Exit time, assuming 26MHz clock */ |
| 2759 |
/* Gen1 */ |
| 2760 |
PHY_TUNING_ENTRY_PMA(0x0ca8, -1, 0x00), |
| 2761 |
PHY_TUNING_ENTRY_PMA(0x0cac, -1, 0x04), |
| 2762 |
PHY_TUNING_ENTRY_PMA(0x1ca8, -1, 0x00), |
| 2763 |
PHY_TUNING_ENTRY_PMA(0x1cac, -1, 0x04), |
| 2764 |
/* Gen2 */ |
| 2765 |
PHY_TUNING_ENTRY_PMA(0x0cb8, -1, 0x00), |
| 2766 |
PHY_TUNING_ENTRY_PMA(0x0cbc, -1, 0x04), |
| 2767 |
PHY_TUNING_ENTRY_PMA(0x1cb8, -1, 0x00), |
| 2768 |
PHY_TUNING_ENTRY_PMA(0x1cbc, -1, 0x04), |
| 2769 |
/* RX impedance setting */ |
| 2770 |
PHY_TUNING_ENTRY_PMA(0x0bb0, 0x03, 0x01), |
| 2771 |
PHY_TUNING_ENTRY_PMA(0x0bb4, 0xf0, 0xa0), |
| 2772 |
PHY_TUNING_ENTRY_PMA(0x1bb0, 0x03, 0x01), |
| 2773 |
PHY_TUNING_ENTRY_PMA(0x1bb4, 0xf0, 0xa0), |
| 2774 |
|
| 2775 |
PHY_TUNING_ENTRY_LAST |
| 2776 |
}; |
| 2777 |
|
| 2778 |
static const struct exynos5_usbdrd_phy_tuning gs101_tunes_pipe3_init[] = { |
| 2779 |
/* init */ |
| 2780 |
/* abnormal common pattern mask */ |
| 2781 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_BACK_END_MODE_VEC, |
| 2782 |
BACK_END_MODE_VEC_DISABLE_DATA_MASK, 0), |
| 2783 |
/* de-serializer enabled when U2 */ |
| 2784 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_OUT_VEC_2, PCS_OUT_VEC_B4_DYNAMIC, |
| 2785 |
PCS_OUT_VEC_B4_SEL_OUT), |
| 2786 |
/* TX Keeper Disable, Squelch on when U3 */ |
| 2787 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_OUT_VEC_3, PCS_OUT_VEC_B7_DYNAMIC, |
| 2788 |
PCS_OUT_VEC_B7_SEL_OUT | PCS_OUT_VEC_B2_SEL_OUT), |
| 2789 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_NS_VEC_PS1_N1, -1, |
| 2790 |
(FIELD_PREP_CONST(NS_VEC_NS_REQ, 5) | |
| 2791 |
NS_VEC_ENABLE_TIMER | |
| 2792 |
FIELD_PREP_CONST(NS_VEC_SEL_TIMEOUT, 3))), |
| 2793 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_NS_VEC_PS2_N0, -1, |
| 2794 |
(FIELD_PREP_CONST(NS_VEC_NS_REQ, 1) | |
| 2795 |
NS_VEC_ENABLE_TIMER | |
| 2796 |
FIELD_PREP_CONST(NS_VEC_SEL_TIMEOUT, 3) | |
| 2797 |
FIELD_PREP_CONST(NS_VEC_COND_MASK, 2) | |
| 2798 |
FIELD_PREP_CONST(NS_VEC_EXP_COND, 2))), |
| 2799 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_NS_VEC_PS3_N0, -1, |
| 2800 |
(FIELD_PREP_CONST(NS_VEC_NS_REQ, 1) | |
| 2801 |
NS_VEC_ENABLE_TIMER | |
| 2802 |
FIELD_PREP_CONST(NS_VEC_SEL_TIMEOUT, 3) | |
| 2803 |
FIELD_PREP_CONST(NS_VEC_COND_MASK, 7) | |
| 2804 |
FIELD_PREP_CONST(NS_VEC_EXP_COND, 7))), |
| 2805 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_TIMEOUT_0, -1, 112), |
| 2806 |
/* Block Aligner Type B */ |
| 2807 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_RX_CONTROL, 0, |
| 2808 |
RX_CONTROL_EN_BLOCK_ALIGNER_TYPE_B), |
| 2809 |
/* Block align at TS1/TS2 for Gen2 stability (Gen2 only) */ |
| 2810 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_RX_CONTROL_DEBUG, |
| 2811 |
RX_CONTROL_DEBUG_NUM_COM_FOUND, |
| 2812 |
(RX_CONTROL_DEBUG_EN_TS_CHECK | |
| 2813 |
/* |
| 2814 |
* increase pcs ts1 adding packet-cnt 1 --> 4 |
| 2815 |
* lnx_rx_valid_rstn_delay_rise_sp/ssp : |
| 2816 |
* 19.6us(0x200) -> 15.3us(0x4) |
| 2817 |
*/ |
| 2818 |
FIELD_PREP_CONST(RX_CONTROL_DEBUG_NUM_COM_FOUND, 4))), |
| 2819 |
/* Gen1 Tx DRIVER pre-shoot, de-emphasis, level ctrl */ |
| 2820 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_HS_TX_COEF_MAP_0, |
| 2821 |
(HS_TX_COEF_MAP_0_SSTX_DEEMP | HS_TX_COEF_MAP_0_SSTX_LEVEL | |
| 2822 |
HS_TX_COEF_MAP_0_SSTX_PRE_SHOOT), |
| 2823 |
(FIELD_PREP_CONST(HS_TX_COEF_MAP_0_SSTX_DEEMP, 8) | |
| 2824 |
FIELD_PREP_CONST(HS_TX_COEF_MAP_0_SSTX_LEVEL, 0xb) | |
| 2825 |
FIELD_PREP_CONST(HS_TX_COEF_MAP_0_SSTX_PRE_SHOOT, 0))), |
| 2826 |
/* Gen2 Tx DRIVER level ctrl */ |
| 2827 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_LOCAL_COEF, |
| 2828 |
LOCAL_COEF_PMA_CENTER_COEF, |
| 2829 |
FIELD_PREP_CONST(LOCAL_COEF_PMA_CENTER_COEF, 0xb)), |
| 2830 |
/* Gen2 U1 exit LFPS duration : 900ns ~ 1.2us */ |
| 2831 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_TIMEOUT_3, -1, 4096), |
| 2832 |
/* set skp_remove_th 0x2 -> 0x7 for avoiding retry problem. */ |
| 2833 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_EBUF_PARAM, |
| 2834 |
EBUF_PARAM_SKP_REMOVE_TH_EMPTY_MODE, |
| 2835 |
FIELD_PREP_CONST(EBUF_PARAM_SKP_REMOVE_TH_EMPTY_MODE, 0x7)), |
| 2836 |
|
| 2837 |
PHY_TUNING_ENTRY_LAST |
| 2838 |
}; |
| 2839 |
|
| 2840 |
static const struct exynos5_usbdrd_phy_tuning gs101_tunes_pipe3_postlock[] = { |
| 2841 |
/* Squelch off when U3 */ |
| 2842 |
PHY_TUNING_ENTRY_PCS(EXYNOS9_PCS_OUT_VEC_3, PCS_OUT_VEC_B2_SEL_OUT, 0), |
| 2843 |
|
| 2844 |
PHY_TUNING_ENTRY_LAST |
| 2845 |
}; |
| 2846 |
|
| 2847 |
static const struct exynos5_usbdrd_phy_tuning *gs101_tunes[PTS_MAX] = { |
| 2848 |
[PTS_UTMI_POSTINIT] = gs101_tunes_utmi_postinit, |
| 2849 |
[PTS_PIPE3_PREINIT] = gs101_tunes_pipe3_preinit, |
| 2850 |
[PTS_PIPE3_INIT] = gs101_tunes_pipe3_init, |
| 2851 |
[PTS_PIPE3_POSTLOCK] = gs101_tunes_pipe3_postlock, |
| 2852 |
}; |
| 2853 |
|
| 2854 |
static const char * const gs101_clk_names[] = { |
| 2855 |
"phy", "ctrl_aclk", "ctrl_pclk", "scl_pclk", |
| 2856 |
}; |
| 2857 |
|
| 2858 |
static const char * const gs101_regulator_names[] = { |
| 2859 |
"pll", |
| 2860 |
"dvdd-usb20", "vddh-usb20", "vdd33-usb20", |
| 2861 |
"vdda-usbdp", "vddh-usbdp", |
| 2862 |
}; |
| 2863 |
|
| 2864 |
static const struct exynos5_usbdrd_phy_drvdata gs101_usbd31rd_phy = { |
| 2865 |
.phy_cfg = phy_cfg_gs101, |
| 2866 |
.phy_tunes = gs101_tunes, |
| 2867 |
.phy_ops = &gs101_usbdrd_phy_ops, |
| 2868 |
.pmu_offset_usbdrd0_phy = GS101_PHY_CTRL_USB20, |
| 2869 |
.pmu_offset_usbdrd0_phy_ss = GS101_PHY_CTRL_USBDP, |
| 2870 |
.clk_names = gs101_clk_names, |
| 2871 |
.n_clks = ARRAY_SIZE(gs101_clk_names), |
| 2872 |
.core_clk_names = exynos5_core_clk_names, |
| 2873 |
.n_core_clks = ARRAY_SIZE(exynos5_core_clk_names), |
| 2874 |
.regulator_names = gs101_regulator_names, |
| 2875 |
.n_regulators = ARRAY_SIZE(gs101_regulator_names), |
| 2876 |
}; |
| 2877 |
|
| 2878 |
static const struct of_device_id exynos5_usbdrd_phy_of_match[] = { |
| 2879 |
{ |
| 2880 |
.compatible = "google,gs101-usb31drd-phy", |
| 2881 |
.data = &gs101_usbd31rd_phy |
| 2882 |
}, { |
| 2883 |
.compatible = "samsung,exynos2200-usb32drd-phy", |
| 2884 |
.data = &exynos2200_usb32drd_phy, |
| 2885 |
}, { |
| 2886 |
.compatible = "samsung,exynos5250-usbdrd-phy", |
| 2887 |
.data = &exynos5250_usbdrd_phy |
| 2888 |
}, { |
| 2889 |
.compatible = "samsung,exynos5420-usbdrd-phy", |
| 2890 |
.data = &exynos5420_usbdrd_phy |
| 2891 |
}, { |
| 2892 |
.compatible = "samsung,exynos5433-usbdrd-phy", |
| 2893 |
.data = &exynos5433_usbdrd_phy |
| 2894 |
}, { |
| 2895 |
.compatible = "samsung,exynos7-usbdrd-phy", |
| 2896 |
.data = &exynos7_usbdrd_phy |
| 2897 |
}, { |
| 2898 |
.compatible = "samsung,exynos7870-usbdrd-phy", |
| 2899 |
.data = &exynos7870_usbdrd_phy |
| 2900 |
}, { |
| 2901 |
.compatible = "samsung,exynos850-usbdrd-phy", |
| 2902 |
.data = &exynos850_usbdrd_phy |
| 2903 |
}, { |
| 2904 |
.compatible = "samsung,exynos990-usbdrd-phy", |
| 2905 |
.data = &exynos990_usbdrd_phy |
| 2906 |
}, { |
| 2907 |
.compatible = "samsung,exynosautov920-usb31drd-combo-ssphy", |
| 2908 |
.data = &exynosautov920_usb31drd_combo_ssphy |
| 2909 |
}, { |
| 2910 |
.compatible = "samsung,exynosautov920-usbdrd-combo-hsphy", |
| 2911 |
.data = &exynosautov920_usbdrd_combo_hsphy |
| 2912 |
}, { |
| 2913 |
.compatible = "samsung,exynosautov920-usbdrd-phy", |
| 2914 |
.data = &exynosautov920_usbdrd_phy |
| 2915 |
}, |
| 2916 |
{ }, |
| 2917 |
}; |
| 2918 |
MODULE_DEVICE_TABLE(of, exynos5_usbdrd_phy_of_match); |
| 2919 |
|
| 2920 |
static int exynos5_usbdrd_phy_probe(struct platform_device *pdev) |
| 2921 |
{ |
| 2922 |
struct device *dev = &pdev->dev; |
| 2923 |
struct device_node *node = dev->of_node; |
| 2924 |
struct exynos5_usbdrd_phy *phy_drd; |
| 2925 |
struct phy_provider *phy_provider; |
| 2926 |
const struct exynos5_usbdrd_phy_drvdata *drv_data; |
| 2927 |
struct regmap *reg_pmu; |
| 2928 |
u32 pmu_offset; |
| 2929 |
int i, ret; |
| 2930 |
int channel; |
| 2931 |
|
| 2932 |
phy_drd = devm_kzalloc(dev, sizeof(*phy_drd), GFP_KERNEL); |
| 2933 |
if (!phy_drd) |
| 2934 |
return -ENOMEM; |
| 2935 |
|
| 2936 |
dev_set_drvdata(dev, phy_drd); |
| 2937 |
phy_drd->dev = dev; |
| 2938 |
|
| 2939 |
drv_data = of_device_get_match_data(dev); |
| 2940 |
if (!drv_data) |
| 2941 |
return -EINVAL; |
| 2942 |
phy_drd->drv_data = drv_data; |
| 2943 |
|
| 2944 |
ret = devm_mutex_init(dev, &phy_drd->phy_mutex); |
| 2945 |
if (ret) |
| 2946 |
return ret; |
| 2947 |
|
| 2948 |
if (of_property_present(dev->of_node, "reg-names")) { |
| 2949 |
void __iomem *reg; |
| 2950 |
|
| 2951 |
reg = devm_platform_ioremap_resource_byname(pdev, "phy"); |
| 2952 |
if (IS_ERR(reg)) |
| 2953 |
return PTR_ERR(reg); |
| 2954 |
phy_drd->reg_phy = reg; |
| 2955 |
|
| 2956 |
reg = devm_platform_ioremap_resource_byname(pdev, "pcs"); |
| 2957 |
if (IS_ERR(reg)) |
| 2958 |
return PTR_ERR(reg); |
| 2959 |
phy_drd->reg_pcs = reg; |
| 2960 |
|
| 2961 |
reg = devm_platform_ioremap_resource_byname(pdev, "pma"); |
| 2962 |
if (IS_ERR(reg)) |
| 2963 |
return PTR_ERR(reg); |
| 2964 |
phy_drd->reg_pma = reg; |
| 2965 |
} else { |
| 2966 |
/* DTB with just a single region */ |
| 2967 |
phy_drd->reg_phy = devm_platform_ioremap_resource(pdev, 0); |
| 2968 |
if (IS_ERR(phy_drd->reg_phy)) |
| 2969 |
return PTR_ERR(phy_drd->reg_phy); |
| 2970 |
} |
| 2971 |
|
| 2972 |
/* |
| 2973 |
* USB32DRD 4nm controller implements Synopsys eUSB2.0 PHY |
| 2974 |
* and Synopsys SS/USBDP COMBOPHY, managed by external code. |
| 2975 |
*/ |
| 2976 |
if (of_property_present(dev->of_node, "phy-names")) { |
| 2977 |
phy_drd->hs_phy = devm_of_phy_get(dev, dev->of_node, "hs"); |
| 2978 |
if (IS_ERR(phy_drd->hs_phy)) |
| 2979 |
return dev_err_probe(dev, PTR_ERR(phy_drd->hs_phy), |
| 2980 |
"failed to get hs_phy\n"); |
| 2981 |
} |
| 2982 |
|
| 2983 |
ret = exynos5_usbdrd_phy_clk_handle(phy_drd); |
| 2984 |
if (ret) |
| 2985 |
return ret; |
| 2986 |
|
| 2987 |
reg_pmu = syscon_regmap_lookup_by_phandle(dev->of_node, |
| 2988 |
"samsung,pmu-syscon"); |
| 2989 |
if (IS_ERR(reg_pmu)) |
| 2990 |
return dev_err_probe(dev, PTR_ERR(reg_pmu), |
| 2991 |
"Failed to lookup PMU regmap\n"); |
| 2992 |
|
| 2993 |
/* |
| 2994 |
* Exynos5420 SoC has multiple channels for USB 3.0 PHY, with |
| 2995 |
* each having separate power control registers. |
| 2996 |
* 'channel' facilitates to set such registers. |
| 2997 |
*/ |
| 2998 |
channel = of_alias_get_id(node, "usbdrdphy"); |
| 2999 |
if (channel < 0) |
| 3000 |
dev_dbg(dev, "Not a multi-controller usbdrd phy\n"); |
| 3001 |
|
| 3002 |
/* Get regulators */ |
| 3003 |
phy_drd->regulators = devm_kcalloc(dev, |
| 3004 |
drv_data->n_regulators, |
| 3005 |
sizeof(*phy_drd->regulators), |
| 3006 |
GFP_KERNEL); |
| 3007 |
if (!phy_drd->regulators) |
| 3008 |
return -ENOMEM; |
| 3009 |
regulator_bulk_set_supply_names(phy_drd->regulators, |
| 3010 |
drv_data->regulator_names, |
| 3011 |
drv_data->n_regulators); |
| 3012 |
ret = devm_regulator_bulk_get(dev, drv_data->n_regulators, |
| 3013 |
phy_drd->regulators); |
| 3014 |
if (ret) |
| 3015 |
return dev_err_probe(dev, ret, "failed to get regulators\n"); |
| 3016 |
|
| 3017 |
ret = exynos5_usbdrd_setup_notifiers(phy_drd); |
| 3018 |
if (ret) |
| 3019 |
return ret; |
| 3020 |
|
| 3021 |
dev_vdbg(dev, "Creating usbdrd_phy phy\n"); |
| 3022 |
|
| 3023 |
for (i = 0; i < EXYNOS5_DRDPHYS_NUM; i++) { |
| 3024 |
struct phy *phy = devm_phy_create(dev, NULL, drv_data->phy_ops); |
| 3025 |
|
| 3026 |
if (IS_ERR(phy)) |
| 3027 |
return dev_err_probe(dev, PTR_ERR(phy), |
| 3028 |
"Failed to create usbdrd_phy phy\n"); |
| 3029 |
|
| 3030 |
phy_drd->phys[i].phy = phy; |
| 3031 |
phy_drd->phys[i].index = i; |
| 3032 |
phy_drd->phys[i].reg_pmu = reg_pmu; |
| 3033 |
switch (channel) { |
| 3034 |
case 1: |
| 3035 |
pmu_offset = drv_data->pmu_offset_usbdrd1_phy; |
| 3036 |
break; |
| 3037 |
case 0: |
| 3038 |
default: |
| 3039 |
pmu_offset = drv_data->pmu_offset_usbdrd0_phy; |
| 3040 |
if (i == EXYNOS5_DRDPHY_PIPE3 && drv_data |
| 3041 |
->pmu_offset_usbdrd0_phy_ss) |
| 3042 |
pmu_offset = drv_data->pmu_offset_usbdrd0_phy_ss; |
| 3043 |
break; |
| 3044 |
} |
| 3045 |
phy_drd->phys[i].pmu_offset = pmu_offset; |
| 3046 |
phy_drd->phys[i].phy_cfg = &drv_data->phy_cfg[i]; |
| 3047 |
phy_set_drvdata(phy, &phy_drd->phys[i]); |
| 3048 |
} |
| 3049 |
|
| 3050 |
phy_provider = devm_of_phy_provider_register(dev, |
| 3051 |
exynos5_usbdrd_phy_xlate); |
| 3052 |
if (IS_ERR(phy_provider)) |
| 3053 |
return dev_err_probe(phy_drd->dev, PTR_ERR(phy_provider), |
| 3054 |
"Failed to register phy provider\n"); |
| 3055 |
|
| 3056 |
return 0; |
| 3057 |
} |
| 3058 |
|
| 3059 |
static struct platform_driver exynos5_usb3drd_phy = { |
| 3060 |
.probe = exynos5_usbdrd_phy_probe, |
| 3061 |
.driver = { |
| 3062 |
.of_match_table = exynos5_usbdrd_phy_of_match, |
| 3063 |
.name = "exynos5_usb3drd_phy", |
| 3064 |
.suppress_bind_attrs = true, |
| 3065 |
} |
| 3066 |
}; |
| 3067 |
|
| 3068 |
module_platform_driver(exynos5_usb3drd_phy); |
| 3069 |
MODULE_DESCRIPTION("Samsung Exynos5 SoCs USB 3.0 DRD controller PHY driver"); |
| 3070 |
MODULE_AUTHOR("Vivek Gautam <[email protected]>"); |
| 3071 |
MODULE_LICENSE("GPL v2"); |