1 From 934337080c6c59b75db76b180b509f218640ad48 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
3 Date: Thu, 3 Feb 2022 22:44:41 +0100
4 Subject: [PATCH 2/2] phy: marvell: phy-mvebu-a3700-comphy: Add native kernel
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Remove old RPC implementation and add a new native kernel implementation.
12 The old implementation uses ARM SMC API to issue RPC calls to ARM Trusted
13 Firmware which provides real implementation of PHY configuration.
15 But older versions of ARM Trusted Firmware do not provide this PHY
16 configuration functionality, simply returning: operation not supported; or
17 worse, some versions provide the configuration functionality incorrectly.
19 For example the firmware shipped in ESPRESSObin board has this older
20 version of ARM Trusted Firmware and therefore SATA, USB 3.0 and PCIe
21 functionality do not work with newer versions of Linux kernel.
23 Due to the above reasons, the following commits were introduced into Linux,
24 to workaround these issues by ignoring -EOPNOTSUPP error code from
25 phy-mvebu-a3700-comphy driver function phy_power_on():
27 commit 45aefe3d2251 ("ata: ahci: mvebu: Make SATA PHY optional for Armada
29 commit 3241929b67d2 ("usb: host: xhci: mvebu: make USB 3.0 PHY optional for
31 commit b0c6ae0f8948 ("PCI: aardvark: Fix initialization with old Marvell's
32 Arm Trusted Firmware")
34 Replace this RPC implementation with proper native kernel implementation,
35 which is independent on the firmware. Never return -EOPNOTSUPP for proper
38 This should solve multiple issues with real-world boards, where it is not
39 possible or really inconvenient to change the firmware. Let's eliminate
42 This implementation is ported directly from Armada 3720 comphy driver found
43 in newest version of ARM Trusted Firmware source code, but with various
44 fixes of register names, some added comments, some refactoring due to the
45 original code not conforming to kernel standards. Also PCIe mode poweroff
46 support was added here, and PHY reset support. These changes are also going
47 to be sent to ARM Trusted Firmware.
49 [ Pali did the porting from ATF.
50 I (Marek) then fixed some register names, some various other things,
51 added some comments and refactored the code to kernel standards. Also
52 fixed PHY poweroff and added PHY reset. ]
54 Signed-off-by: Pali Rohár <pali@kernel.org>
55 Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
56 Signed-off-by: Marek Behún <kabel@kernel.org>
57 Link: https://lore.kernel.org/r/20220203214444.1508-3-kabel@kernel.org
58 Signed-off-by: Vinod Koul <vkoul@kernel.org>
60 drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 1332 ++++++++++++++++--
61 1 file changed, 1215 insertions(+), 117 deletions(-)
63 --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
64 +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
67 * Evan Wang <xswang@marvell.com>
68 * Miquèl Raynal <miquel.raynal@bootlin.com>
69 + * Pali Rohár <pali@kernel.org>
70 + * Marek Behún <kabel@kernel.org>
72 * Structure inspired from phy-mvebu-cp110-comphy.c written by Antoine Tenart.
73 - * SMC call initial support done by Grzegorz Jaszczyk.
74 + * Comphy code from ARM Trusted Firmware ported by Pali Rohár <pali@kernel.org>
75 + * and Marek Behún <kabel@kernel.org>.
78 -#include <linux/arm-smccc.h>
79 +#include <linux/bitfield.h>
80 +#include <linux/clk.h>
82 #include <linux/iopoll.h>
83 #include <linux/mfd/syscon.h>
84 @@ -18,103 +22,1118 @@
85 #include <linux/phy.h>
86 #include <linux/phy/phy.h>
87 #include <linux/platform_device.h>
88 +#include <linux/spinlock.h>
90 -#define MVEBU_A3700_COMPHY_LANES 3
91 +#define PLL_SET_DELAY_US 600
92 +#define COMPHY_PLL_SLEEP 1000
93 +#define COMPHY_PLL_TIMEOUT 150000
95 +/* Comphy lane2 indirect access register offset */
96 +#define COMPHY_LANE2_INDIR_ADDR 0x0
97 +#define COMPHY_LANE2_INDIR_DATA 0x4
99 +/* SATA and USB3 PHY offset compared to SATA PHY */
100 +#define COMPHY_LANE2_REGS_BASE 0x200
103 + * When accessing common PHY lane registers directly, we need to shift by 1,
104 + * since the registers are 16-bit.
106 +#define COMPHY_LANE_REG_DIRECT(reg) (((reg) & 0x7FF) << 1)
108 +/* COMPHY registers */
109 +#define COMPHY_POWER_PLL_CTRL 0x01
110 +#define PU_IVREF_BIT BIT(15)
111 +#define PU_PLL_BIT BIT(14)
112 +#define PU_RX_BIT BIT(13)
113 +#define PU_TX_BIT BIT(12)
114 +#define PU_TX_INTP_BIT BIT(11)
115 +#define PU_DFE_BIT BIT(10)
116 +#define RESET_DTL_RX_BIT BIT(9)
117 +#define PLL_LOCK_BIT BIT(8)
118 +#define REF_FREF_SEL_MASK GENMASK(4, 0)
119 +#define REF_FREF_SEL_SERDES_25MHZ FIELD_PREP(REF_FREF_SEL_MASK, 0x1)
120 +#define REF_FREF_SEL_SERDES_40MHZ FIELD_PREP(REF_FREF_SEL_MASK, 0x3)
121 +#define REF_FREF_SEL_SERDES_50MHZ FIELD_PREP(REF_FREF_SEL_MASK, 0x4)
122 +#define REF_FREF_SEL_PCIE_USB3_25MHZ FIELD_PREP(REF_FREF_SEL_MASK, 0x2)
123 +#define REF_FREF_SEL_PCIE_USB3_40MHZ FIELD_PREP(REF_FREF_SEL_MASK, 0x3)
124 +#define COMPHY_MODE_MASK GENMASK(7, 5)
125 +#define COMPHY_MODE_SATA FIELD_PREP(COMPHY_MODE_MASK, 0x0)
126 +#define COMPHY_MODE_PCIE FIELD_PREP(COMPHY_MODE_MASK, 0x3)
127 +#define COMPHY_MODE_SERDES FIELD_PREP(COMPHY_MODE_MASK, 0x4)
128 +#define COMPHY_MODE_USB3 FIELD_PREP(COMPHY_MODE_MASK, 0x5)
130 +#define COMPHY_KVCO_CAL_CTRL 0x02
131 +#define USE_MAX_PLL_RATE_BIT BIT(12)
132 +#define SPEED_PLL_MASK GENMASK(7, 2)
133 +#define SPEED_PLL_VALUE_16 FIELD_PREP(SPEED_PLL_MASK, 0x10)
135 +#define COMPHY_DIG_LOOPBACK_EN 0x23
136 +#define SEL_DATA_WIDTH_MASK GENMASK(11, 10)
137 +#define DATA_WIDTH_10BIT FIELD_PREP(SEL_DATA_WIDTH_MASK, 0x0)
138 +#define DATA_WIDTH_20BIT FIELD_PREP(SEL_DATA_WIDTH_MASK, 0x1)
139 +#define DATA_WIDTH_40BIT FIELD_PREP(SEL_DATA_WIDTH_MASK, 0x2)
140 +#define PLL_READY_TX_BIT BIT(4)
142 +#define COMPHY_SYNC_PATTERN 0x24
143 +#define TXD_INVERT_BIT BIT(10)
144 +#define RXD_INVERT_BIT BIT(11)
146 +#define COMPHY_SYNC_MASK_GEN 0x25
147 +#define PHY_GEN_MAX_MASK GENMASK(11, 10)
148 +#define PHY_GEN_MAX_USB3_5G FIELD_PREP(PHY_GEN_MAX_MASK, 0x1)
150 +#define COMPHY_ISOLATION_CTRL 0x26
151 +#define PHY_ISOLATE_MODE BIT(15)
153 +#define COMPHY_GEN2_SET2 0x3e
154 +#define GS2_TX_SSC_AMP_MASK GENMASK(15, 9)
155 +#define GS2_TX_SSC_AMP_4128 FIELD_PREP(GS2_TX_SSC_AMP_MASK, 0x20)
156 +#define GS2_VREG_RXTX_MAS_ISET_MASK GENMASK(8, 7)
157 +#define GS2_VREG_RXTX_MAS_ISET_60U FIELD_PREP(GS2_VREG_RXTX_MAS_ISET_MASK,\
159 +#define GS2_VREG_RXTX_MAS_ISET_80U FIELD_PREP(GS2_VREG_RXTX_MAS_ISET_MASK,\
161 +#define GS2_VREG_RXTX_MAS_ISET_100U FIELD_PREP(GS2_VREG_RXTX_MAS_ISET_MASK,\
163 +#define GS2_VREG_RXTX_MAS_ISET_120U FIELD_PREP(GS2_VREG_RXTX_MAS_ISET_MASK,\
165 +#define GS2_RSVD_6_0_MASK GENMASK(6, 0)
167 +#define COMPHY_GEN3_SET2 0x3f
169 +#define COMPHY_IDLE_SYNC_EN 0x48
170 +#define IDLE_SYNC_EN BIT(12)
172 +#define COMPHY_MISC_CTRL0 0x4F
173 +#define CLK100M_125M_EN BIT(4)
174 +#define TXDCLK_2X_SEL BIT(6)
175 +#define CLK500M_EN BIT(7)
176 +#define PHY_REF_CLK_SEL BIT(10)
178 +#define COMPHY_SFT_RESET 0x52
179 +#define SFT_RST BIT(9)
180 +#define SFT_RST_NO_REG BIT(10)
182 +#define COMPHY_MISC_CTRL1 0x73
183 +#define SEL_BITS_PCIE_FORCE BIT(15)
185 +#define COMPHY_GEN2_SET3 0x112
186 +#define GS3_FFE_CAP_SEL_MASK GENMASK(3, 0)
187 +#define GS3_FFE_CAP_SEL_VALUE FIELD_PREP(GS3_FFE_CAP_SEL_MASK, 0xF)
189 +/* PIPE registers */
190 +#define COMPHY_PIPE_LANE_CFG0 0x180
191 +#define PRD_TXDEEMPH0_MASK BIT(0)
192 +#define PRD_TXMARGIN_MASK GENMASK(3, 1)
193 +#define PRD_TXSWING_MASK BIT(4)
194 +#define CFG_TX_ALIGN_POS_MASK GENMASK(8, 5)
196 +#define COMPHY_PIPE_LANE_CFG1 0x181
197 +#define PRD_TXDEEMPH1_MASK BIT(15)
198 +#define USE_MAX_PLL_RATE_EN BIT(9)
199 +#define TX_DET_RX_MODE BIT(6)
200 +#define GEN2_TX_DATA_DLY_MASK GENMASK(4, 3)
201 +#define GEN2_TX_DATA_DLY_DEFT FIELD_PREP(GEN2_TX_DATA_DLY_MASK, 2)
202 +#define TX_ELEC_IDLE_MODE_EN BIT(0)
204 +#define COMPHY_PIPE_LANE_STAT1 0x183
205 +#define TXDCLK_PCLK_EN BIT(0)
207 +#define COMPHY_PIPE_LANE_CFG4 0x188
208 +#define SPREAD_SPECTRUM_CLK_EN BIT(7)
210 +#define COMPHY_PIPE_RST_CLK_CTRL 0x1C1
211 +#define PIPE_SOFT_RESET BIT(0)
212 +#define PIPE_REG_RESET BIT(1)
213 +#define MODE_CORE_CLK_FREQ_SEL BIT(9)
214 +#define MODE_PIPE_WIDTH_32 BIT(3)
215 +#define MODE_REFDIV_MASK GENMASK(5, 4)
216 +#define MODE_REFDIV_BY_4 FIELD_PREP(MODE_REFDIV_MASK, 0x2)
218 +#define COMPHY_PIPE_TEST_MODE_CTRL 0x1C2
219 +#define MODE_MARGIN_OVERRIDE BIT(2)
221 +#define COMPHY_PIPE_CLK_SRC_LO 0x1C3
222 +#define MODE_CLK_SRC BIT(0)
223 +#define BUNDLE_PERIOD_SEL BIT(1)
224 +#define BUNDLE_PERIOD_SCALE_MASK GENMASK(3, 2)
225 +#define BUNDLE_SAMPLE_CTRL BIT(4)
226 +#define PLL_READY_DLY_MASK GENMASK(7, 5)
227 +#define CFG_SEL_20B BIT(15)
229 +#define COMPHY_PIPE_PWR_MGM_TIM1 0x1D0
230 +#define CFG_PM_OSCCLK_WAIT_MASK GENMASK(15, 12)
231 +#define CFG_PM_RXDEN_WAIT_MASK GENMASK(11, 8)
232 +#define CFG_PM_RXDEN_WAIT_1_UNIT FIELD_PREP(CFG_PM_RXDEN_WAIT_MASK, 0x1)
233 +#define CFG_PM_RXDLOZ_WAIT_MASK GENMASK(7, 0)
234 +#define CFG_PM_RXDLOZ_WAIT_7_UNIT FIELD_PREP(CFG_PM_RXDLOZ_WAIT_MASK, 0x7)
235 +#define CFG_PM_RXDLOZ_WAIT_12_UNIT FIELD_PREP(CFG_PM_RXDLOZ_WAIT_MASK, 0xC)
238 + * This register is not from PHY lane register space. It only exists in the
239 + * indirect register space, before the actual PHY lane 2 registers. So the
240 + * offset is absolute, not relative to COMPHY_LANE2_REGS_BASE.
241 + * It is used only for SATA PHY initialization.
243 +#define COMPHY_RESERVED_REG 0x0E
244 +#define PHYCTRL_FRM_PIN_BIT BIT(13)
246 -/* COMPHY Fast SMC function identifiers */
247 -#define COMPHY_SIP_POWER_ON 0x82000001
248 -#define COMPHY_SIP_POWER_OFF 0x82000002
249 -#define COMPHY_SIP_PLL_LOCK 0x82000003
251 -#define COMPHY_FW_MODE_SATA 0x1
252 -#define COMPHY_FW_MODE_SGMII 0x2
253 -#define COMPHY_FW_MODE_2500BASEX 0x3
254 -#define COMPHY_FW_MODE_USB3H 0x4
255 -#define COMPHY_FW_MODE_USB3D 0x5
256 -#define COMPHY_FW_MODE_PCIE 0x6
257 -#define COMPHY_FW_MODE_USB3 0xa
259 -#define COMPHY_FW_SPEED_1_25G 0 /* SGMII 1G */
260 -#define COMPHY_FW_SPEED_2_5G 1
261 -#define COMPHY_FW_SPEED_3_125G 2 /* 2500BASE-X */
262 -#define COMPHY_FW_SPEED_5G 3
263 -#define COMPHY_FW_SPEED_MAX 0x3F
265 -#define COMPHY_FW_MODE(mode) ((mode) << 12)
266 -#define COMPHY_FW_NET(mode, idx, speed) (COMPHY_FW_MODE(mode) | \
269 -#define COMPHY_FW_PCIE(mode, speed, width) (COMPHY_FW_NET(mode, 0, speed) | \
271 +/* South Bridge PHY Configuration Registers */
272 +#define COMPHY_PHY_REG(lane, reg) (((1 - (lane)) * 0x28) + ((reg) & 0x3f))
275 + * lane0: USB3/GbE1 PHY Configuration 1
276 + * lane1: PCIe/GbE0 PHY Configuration 1
277 + * (used only by SGMII code)
279 +#define COMPHY_PHY_CFG1 0x0
280 +#define PIN_PU_IVREF_BIT BIT(1)
281 +#define PIN_RESET_CORE_BIT BIT(11)
282 +#define PIN_RESET_COMPHY_BIT BIT(12)
283 +#define PIN_PU_PLL_BIT BIT(16)
284 +#define PIN_PU_RX_BIT BIT(17)
285 +#define PIN_PU_TX_BIT BIT(18)
286 +#define PIN_TX_IDLE_BIT BIT(19)
287 +#define GEN_RX_SEL_MASK GENMASK(25, 22)
288 +#define GEN_RX_SEL_VALUE(val) FIELD_PREP(GEN_RX_SEL_MASK, (val))
289 +#define GEN_TX_SEL_MASK GENMASK(29, 26)
290 +#define GEN_TX_SEL_VALUE(val) FIELD_PREP(GEN_TX_SEL_MASK, (val))
291 +#define SERDES_SPEED_1_25_G 0x6
292 +#define SERDES_SPEED_3_125_G 0x8
293 +#define PHY_RX_INIT_BIT BIT(30)
296 + * lane0: USB3/GbE1 PHY Status 1
297 + * lane1: PCIe/GbE0 PHY Status 1
298 + * (used only by SGMII code)
300 +#define COMPHY_PHY_STAT1 0x18
301 +#define PHY_RX_INIT_DONE_BIT BIT(0)
302 +#define PHY_PLL_READY_RX_BIT BIT(2)
303 +#define PHY_PLL_READY_TX_BIT BIT(3)
306 +#define COMPHY_SELECTOR_PHY_REG 0xFC
307 +/* bit0: 0: Lane1 is GbE0; 1: Lane1 is PCIe */
308 +#define COMPHY_SELECTOR_PCIE_GBE0_SEL_BIT BIT(0)
309 +/* bit4: 0: Lane0 is GbE1; 1: Lane0 is USB3 */
310 +#define COMPHY_SELECTOR_USB3_GBE1_SEL_BIT BIT(4)
311 +/* bit8: 0: Lane0 is USB3 instead of GbE1, Lane2 is SATA; 1: Lane2 is USB3 */
312 +#define COMPHY_SELECTOR_USB3_PHY_SEL_BIT BIT(8)
314 struct mvebu_a3700_comphy_conf {
321 -#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode, _fw) \
322 +#define MVEBU_A3700_COMPHY_CONF(_lane, _mode, _smode) \
330 -#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode, _fw) \
331 - MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA, _fw)
332 +#define MVEBU_A3700_COMPHY_CONF_GEN(_lane, _mode) \
333 + MVEBU_A3700_COMPHY_CONF(_lane, _mode, PHY_INTERFACE_MODE_NA)
335 -#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode, _fw) \
336 - MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode, _fw)
337 +#define MVEBU_A3700_COMPHY_CONF_ETH(_lane, _smode) \
338 + MVEBU_A3700_COMPHY_CONF(_lane, PHY_MODE_ETHERNET, _smode)
340 static const struct mvebu_a3700_comphy_conf mvebu_a3700_comphy_modes[] = {
342 - MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS,
343 - COMPHY_FW_MODE_USB3H),
344 - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII,
345 - COMPHY_FW_MODE_SGMII),
346 - MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX,
347 - COMPHY_FW_MODE_2500BASEX),
348 + MVEBU_A3700_COMPHY_CONF_GEN(0, PHY_MODE_USB_HOST_SS),
349 + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_SGMII),
350 + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_1000BASEX),
351 + MVEBU_A3700_COMPHY_CONF_ETH(0, PHY_INTERFACE_MODE_2500BASEX),
353 - MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE, COMPHY_FW_MODE_PCIE),
354 - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII,
355 - COMPHY_FW_MODE_SGMII),
356 - MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX,
357 - COMPHY_FW_MODE_2500BASEX),
358 + MVEBU_A3700_COMPHY_CONF_GEN(1, PHY_MODE_PCIE),
359 + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_SGMII),
360 + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_1000BASEX),
361 + MVEBU_A3700_COMPHY_CONF_ETH(1, PHY_INTERFACE_MODE_2500BASEX),
363 - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA, COMPHY_FW_MODE_SATA),
364 - MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS,
365 - COMPHY_FW_MODE_USB3H),
366 + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_SATA),
367 + MVEBU_A3700_COMPHY_CONF_GEN(2, PHY_MODE_USB_HOST_SS),
370 +struct mvebu_a3700_comphy_priv {
371 + void __iomem *comphy_regs;
372 + void __iomem *lane0_phy_regs; /* USB3 and GbE1 */
373 + void __iomem *lane1_phy_regs; /* PCIe and GbE0 */
374 + void __iomem *lane2_phy_indirect; /* SATA and USB3 */
375 + spinlock_t lock; /* for PHY selector access */
379 struct mvebu_a3700_comphy_lane {
380 + struct mvebu_a3700_comphy_priv *priv;
390 +struct gbe_phy_init_data_fix {
395 +/* Changes to 40M1G25 mode data required for running 40M3G125 init mode */
396 +static struct gbe_phy_init_data_fix gbe_phy_init_fix[] = {
397 + { 0x005, 0x07CC }, { 0x015, 0x0000 }, { 0x01B, 0x0000 },
398 + { 0x01D, 0x0000 }, { 0x01E, 0x0000 }, { 0x01F, 0x0000 },
399 + { 0x020, 0x0000 }, { 0x021, 0x0030 }, { 0x026, 0x0888 },
400 + { 0x04D, 0x0152 }, { 0x04F, 0xA020 }, { 0x050, 0x07CC },
401 + { 0x053, 0xE9CA }, { 0x055, 0xBD97 }, { 0x071, 0x3015 },
402 + { 0x076, 0x03AA }, { 0x07C, 0x0FDF }, { 0x0C2, 0x3030 },
403 + { 0x0C3, 0x8000 }, { 0x0E2, 0x5550 }, { 0x0E3, 0x12A4 },
404 + { 0x0E4, 0x7D00 }, { 0x0E6, 0x0C83 }, { 0x101, 0xFCC0 },
408 -static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
409 - unsigned long mode)
410 +/* 40M1G25 mode init data */
411 +static u16 gbe_phy_init[512] = {
412 + /* 0 1 2 3 4 5 6 7 */
413 + /*-----------------------------------------------------------*/
414 + /* 8 9 A B C D E F */
415 + 0x3110, 0xFD83, 0x6430, 0x412F, 0x82C0, 0x06FA, 0x4500, 0x6D26, /* 00 */
416 + 0xAFC0, 0x8000, 0xC000, 0x0000, 0x2000, 0x49CC, 0x0BC9, 0x2A52, /* 08 */
417 + 0x0BD2, 0x0CDE, 0x13D2, 0x0CE8, 0x1149, 0x10E0, 0x0000, 0x0000, /* 10 */
418 + 0x0000, 0x0000, 0x0000, 0x0001, 0x0000, 0x4134, 0x0D2D, 0xFFFF, /* 18 */
419 + 0xFFE0, 0x4030, 0x1016, 0x0030, 0x0000, 0x0800, 0x0866, 0x0000, /* 20 */
420 + 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, /* 28 */
421 + 0xFFFF, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 30 */
422 + 0x0000, 0x0000, 0x000F, 0x6A62, 0x1988, 0x3100, 0x3100, 0x3100, /* 38 */
423 + 0x3100, 0xA708, 0x2430, 0x0830, 0x1030, 0x4610, 0xFF00, 0xFF00, /* 40 */
424 + 0x0060, 0x1000, 0x0400, 0x0040, 0x00F0, 0x0155, 0x1100, 0xA02A, /* 48 */
425 + 0x06FA, 0x0080, 0xB008, 0xE3ED, 0x5002, 0xB592, 0x7A80, 0x0001, /* 50 */
426 + 0x020A, 0x8820, 0x6014, 0x8054, 0xACAA, 0xFC88, 0x2A02, 0x45CF, /* 58 */
427 + 0x000F, 0x1817, 0x2860, 0x064F, 0x0000, 0x0204, 0x1800, 0x6000, /* 60 */
428 + 0x810F, 0x4F23, 0x4000, 0x4498, 0x0850, 0x0000, 0x000E, 0x1002, /* 68 */
429 + 0x9D3A, 0x3009, 0xD066, 0x0491, 0x0001, 0x6AB0, 0x0399, 0x3780, /* 70 */
430 + 0x0040, 0x5AC0, 0x4A80, 0x0000, 0x01DF, 0x0000, 0x0007, 0x0000, /* 78 */
431 + 0x2D54, 0x00A1, 0x4000, 0x0100, 0xA20A, 0x0000, 0x0000, 0x0000, /* 80 */
432 + 0x0000, 0x0000, 0x0000, 0x7400, 0x0E81, 0x1000, 0x1242, 0x0210, /* 88 */
433 + 0x80DF, 0x0F1F, 0x2F3F, 0x4F5F, 0x6F7F, 0x0F1F, 0x2F3F, 0x4F5F, /* 90 */
434 + 0x6F7F, 0x4BAD, 0x0000, 0x0000, 0x0800, 0x0000, 0x2400, 0xB651, /* 98 */
435 + 0xC9E0, 0x4247, 0x0A24, 0x0000, 0xAF19, 0x1004, 0x0000, 0x0000, /* A0 */
436 + 0x0000, 0x0013, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* A8 */
437 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* B0 */
438 + 0x0000, 0x0000, 0x0000, 0x0060, 0x0000, 0x0000, 0x0000, 0x0000, /* B8 */
439 + 0x0000, 0x0000, 0x3010, 0xFA00, 0x0000, 0x0000, 0x0000, 0x0003, /* C0 */
440 + 0x1618, 0x8200, 0x8000, 0x0400, 0x050F, 0x0000, 0x0000, 0x0000, /* C8 */
441 + 0x4C93, 0x0000, 0x1000, 0x1120, 0x0010, 0x1242, 0x1242, 0x1E00, /* D0 */
442 + 0x0000, 0x0000, 0x0000, 0x00F8, 0x0000, 0x0041, 0x0800, 0x0000, /* D8 */
443 + 0x82A0, 0x572E, 0x2490, 0x14A9, 0x4E00, 0x0000, 0x0803, 0x0541, /* E0 */
444 + 0x0C15, 0x0000, 0x0000, 0x0400, 0x2626, 0x0000, 0x0000, 0x4200, /* E8 */
445 + 0x0000, 0xAA55, 0x1020, 0x0000, 0x0000, 0x5010, 0x0000, 0x0000, /* F0 */
446 + 0x0000, 0x0000, 0x5000, 0x0000, 0x0000, 0x0000, 0x02F2, 0x0000, /* F8 */
447 + 0x101F, 0xFDC0, 0x4000, 0x8010, 0x0110, 0x0006, 0x0000, 0x0000, /*100 */
448 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*108 */
449 + 0x04CF, 0x0000, 0x04CF, 0x0000, 0x04CF, 0x0000, 0x04C6, 0x0000, /*110 */
450 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*118 */
451 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*120 */
452 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*128 */
453 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*130 */
454 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*138 */
455 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*140 */
456 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*148 */
457 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*150 */
458 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*158 */
459 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*160 */
460 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*168 */
461 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*170 */
462 + 0x0000, 0x0000, 0x0000, 0x00F0, 0x08A2, 0x3112, 0x0A14, 0x0000, /*178 */
463 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*180 */
464 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*188 */
465 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*190 */
466 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*198 */
467 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1A0 */
468 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1A8 */
469 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1B0 */
470 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1B8 */
471 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1C0 */
472 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1C8 */
473 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1D0 */
474 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1D8 */
475 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1E0 */
476 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1E8 */
477 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /*1F0 */
478 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 /*1F8 */
481 +static inline void comphy_reg_set(void __iomem *addr, u32 data, u32 mask)
483 - struct arm_smccc_res res;
488 + val = (val & ~mask) | (data & mask);
492 - arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
494 +static inline void comphy_reg_set16(void __iomem *addr, u16 data, u16 mask)
499 - case SMCCC_RET_SUCCESS:
501 - case SMCCC_RET_NOT_SUPPORTED:
502 - return -EOPNOTSUPP;
504 + val = (val & ~mask) | (data & mask);
508 +/* Used for accessing lane 2 registers (SATA/USB3 PHY) */
509 +static void comphy_set_indirect(struct mvebu_a3700_comphy_priv *priv,
510 + u32 offset, u16 data, u16 mask)
513 + priv->lane2_phy_indirect + COMPHY_LANE2_INDIR_ADDR);
514 + comphy_reg_set(priv->lane2_phy_indirect + COMPHY_LANE2_INDIR_DATA,
518 +static void comphy_lane_reg_set(struct mvebu_a3700_comphy_lane *lane,
519 + u16 reg, u16 data, u16 mask)
521 + if (lane->id == 2) {
522 + /* lane 2 PHY registers are accessed indirectly */
523 + comphy_set_indirect(lane->priv,
524 + reg + COMPHY_LANE2_REGS_BASE,
527 + void __iomem *base = lane->id == 1 ?
528 + lane->priv->lane1_phy_regs :
529 + lane->priv->lane0_phy_regs;
531 + comphy_reg_set16(base + COMPHY_LANE_REG_DIRECT(reg),
536 +static int comphy_lane_reg_poll(struct mvebu_a3700_comphy_lane *lane,
538 + ulong sleep_us, ulong timeout_us)
542 + if (lane->id == 2) {
545 + /* lane 2 PHY registers are accessed indirectly */
546 + writel(reg + COMPHY_LANE2_REGS_BASE,
547 + lane->priv->lane2_phy_indirect +
548 + COMPHY_LANE2_INDIR_ADDR);
550 + ret = readl_poll_timeout(lane->priv->lane2_phy_indirect +
551 + COMPHY_LANE2_INDIR_DATA,
552 + data, (data & bits) == bits,
553 + sleep_us, timeout_us);
555 + void __iomem *base = lane->id == 1 ?
556 + lane->priv->lane1_phy_regs :
557 + lane->priv->lane0_phy_regs;
560 + ret = readw_poll_timeout(base + COMPHY_LANE_REG_DIRECT(reg),
561 + data, (data & bits) == bits,
562 + sleep_us, timeout_us);
568 +static void comphy_periph_reg_set(struct mvebu_a3700_comphy_lane *lane,
569 + u8 reg, u32 data, u32 mask)
571 + comphy_reg_set(lane->priv->comphy_regs + COMPHY_PHY_REG(lane->id, reg),
575 +static int comphy_periph_reg_poll(struct mvebu_a3700_comphy_lane *lane,
577 + ulong sleep_us, ulong timeout_us)
581 + return readl_poll_timeout(lane->priv->comphy_regs +
582 + COMPHY_PHY_REG(lane->id, reg),
583 + data, (data & bits) == bits,
584 + sleep_us, timeout_us);
587 +/* PHY selector configures with corresponding modes */
589 +mvebu_a3700_comphy_set_phy_selector(struct mvebu_a3700_comphy_lane *lane)
591 + u32 old, new, clr = 0, set = 0;
592 + unsigned long flags;
594 + switch (lane->mode) {
595 + case PHY_MODE_SATA:
596 + /* SATA must be in Lane2 */
598 + clr = COMPHY_SELECTOR_USB3_PHY_SEL_BIT;
603 + case PHY_MODE_ETHERNET:
605 + clr = COMPHY_SELECTOR_USB3_GBE1_SEL_BIT;
606 + else if (lane->id == 1)
607 + clr = COMPHY_SELECTOR_PCIE_GBE0_SEL_BIT;
612 + case PHY_MODE_USB_HOST_SS:
614 + set = COMPHY_SELECTOR_USB3_PHY_SEL_BIT;
615 + else if (lane->id == 0)
616 + set = COMPHY_SELECTOR_USB3_GBE1_SEL_BIT;
621 + case PHY_MODE_PCIE:
622 + /* PCIE must be in Lane1 */
624 + set = COMPHY_SELECTOR_PCIE_GBE0_SEL_BIT;
633 + spin_lock_irqsave(&lane->priv->lock, flags);
635 + old = readl(lane->priv->comphy_regs + COMPHY_SELECTOR_PHY_REG);
636 + new = (old & ~clr) | set;
637 + writel(new, lane->priv->comphy_regs + COMPHY_SELECTOR_PHY_REG);
639 + spin_unlock_irqrestore(&lane->priv->lock, flags);
642 + "COMPHY[%d] mode[%d] changed PHY selector 0x%08x -> 0x%08x\n",
643 + lane->id, lane->mode, old, new);
647 + dev_err(lane->dev, "COMPHY[%d] mode[%d] is invalid\n", lane->id,
653 +mvebu_a3700_comphy_sata_power_on(struct mvebu_a3700_comphy_lane *lane)
655 + u32 mask, data, ref_clk;
658 + /* Configure phy selector for SATA */
659 + ret = mvebu_a3700_comphy_set_phy_selector(lane);
663 + /* Clear phy isolation mode to make it work in normal mode */
664 + comphy_lane_reg_set(lane, COMPHY_ISOLATION_CTRL,
665 + 0x0, PHY_ISOLATE_MODE);
667 + /* 0. Check the Polarity invert bits */
669 + if (lane->invert_tx)
670 + data |= TXD_INVERT_BIT;
671 + if (lane->invert_rx)
672 + data |= RXD_INVERT_BIT;
673 + mask = TXD_INVERT_BIT | RXD_INVERT_BIT;
674 + comphy_lane_reg_set(lane, COMPHY_SYNC_PATTERN, data, mask);
676 + /* 1. Select 40-bit data width */
677 + comphy_lane_reg_set(lane, COMPHY_DIG_LOOPBACK_EN,
678 + DATA_WIDTH_40BIT, SEL_DATA_WIDTH_MASK);
680 + /* 2. Select reference clock(25M) and PHY mode (SATA) */
681 + if (lane->priv->xtal_is_40m)
682 + ref_clk = REF_FREF_SEL_SERDES_40MHZ;
684 + ref_clk = REF_FREF_SEL_SERDES_25MHZ;
686 + data = ref_clk | COMPHY_MODE_SATA;
687 + mask = REF_FREF_SEL_MASK | COMPHY_MODE_MASK;
688 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL, data, mask);
690 + /* 3. Use maximum PLL rate (no power save) */
691 + comphy_lane_reg_set(lane, COMPHY_KVCO_CAL_CTRL,
692 + USE_MAX_PLL_RATE_BIT, USE_MAX_PLL_RATE_BIT);
694 + /* 4. Reset reserved bit */
695 + comphy_set_indirect(lane->priv, COMPHY_RESERVED_REG,
696 + 0x0, PHYCTRL_FRM_PIN_BIT);
698 + /* 5. Set vendor-specific configuration (It is done in sata driver) */
699 + /* XXX: in U-Boot below sequence was executed in this place, in Linux
700 + * not. Now it is done only in U-Boot before this comphy
701 + * initialization - tests shows that it works ok, but in case of any
702 + * future problem it is left for reference.
703 + * reg_set(MVEBU_REGS_BASE + 0xe00a0, 0, 0xffffffff);
704 + * reg_set(MVEBU_REGS_BASE + 0xe00a4, BIT(6), BIT(6));
707 + /* Wait for > 55 us to allow PLL be enabled */
708 + udelay(PLL_SET_DELAY_US);
710 + /* Polling status */
711 + ret = comphy_lane_reg_poll(lane, COMPHY_DIG_LOOPBACK_EN,
712 + PLL_READY_TX_BIT, COMPHY_PLL_SLEEP,
713 + COMPHY_PLL_TIMEOUT);
715 + dev_err(lane->dev, "Failed to lock SATA PLL\n");
720 +static void comphy_gbe_phy_init(struct mvebu_a3700_comphy_lane *lane,
727 + for (addr = 0; addr < 512; addr++) {
729 + * All PHY register values are defined in full for 3.125Gbps
730 + * SERDES speed. The values required for 1.25 Gbps are almost
731 + * the same and only few registers should be "fixed" in
732 + * comparison to 3.125 Gbps values. These register values are
733 + * stored in "gbe_phy_init_fix" array.
735 + if (!is_1gbps && gbe_phy_init_fix[fix_idx].addr == addr) {
736 + /* Use new value */
737 + val = gbe_phy_init_fix[fix_idx].value;
738 + if (fix_idx < ARRAY_SIZE(gbe_phy_init_fix))
741 + val = gbe_phy_init[addr];
744 + comphy_lane_reg_set(lane, addr, val, 0xFFFF);
749 +mvebu_a3700_comphy_ethernet_power_on(struct mvebu_a3700_comphy_lane *lane)
751 + u32 mask, data, speed_sel;
755 + ret = mvebu_a3700_comphy_set_phy_selector(lane);
760 + * 1. Reset PHY by setting PHY input port PIN_RESET=1.
761 + * 2. Set PHY input port PIN_TX_IDLE=1, PIN_PU_IVREF=1 to keep
762 + * PHY TXP/TXN output to idle state during PHY initialization
763 + * 3. Set PHY input port PIN_PU_PLL=0, PIN_PU_RX=0, PIN_PU_TX=0.
765 + data = PIN_PU_IVREF_BIT | PIN_TX_IDLE_BIT | PIN_RESET_COMPHY_BIT;
766 + mask = data | PIN_RESET_CORE_BIT | PIN_PU_PLL_BIT | PIN_PU_RX_BIT |
767 + PIN_PU_TX_BIT | PHY_RX_INIT_BIT;
768 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
770 + /* 4. Release reset to the PHY by setting PIN_RESET=0. */
772 + mask = PIN_RESET_COMPHY_BIT;
773 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
776 + * 5. Set PIN_PHY_GEN_TX[3:0] and PIN_PHY_GEN_RX[3:0] to decide COMPHY
779 + switch (lane->submode) {
780 + case PHY_INTERFACE_MODE_SGMII:
781 + case PHY_INTERFACE_MODE_1000BASEX:
782 + /* SGMII 1G, SerDes speed 1.25G */
783 + speed_sel = SERDES_SPEED_1_25_G;
785 + case PHY_INTERFACE_MODE_2500BASEX:
786 + /* 2500Base-X, SerDes speed 3.125G */
787 + speed_sel = SERDES_SPEED_3_125_G;
790 + /* Other rates are not supported */
792 + "unsupported phy speed %d on comphy lane%d\n",
793 + lane->submode, lane->id);
796 + data = GEN_RX_SEL_VALUE(speed_sel) | GEN_TX_SEL_VALUE(speed_sel);
797 + mask = GEN_RX_SEL_MASK | GEN_TX_SEL_MASK;
798 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
801 + * 6. Wait 10mS for bandgap and reference clocks to stabilize; then
802 + * start SW programming.
806 + /* 7. Program COMPHY register PHY_MODE */
807 + data = COMPHY_MODE_SERDES;
808 + mask = COMPHY_MODE_MASK;
809 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL, data, mask);
812 + * 8. Set COMPHY register REFCLK_SEL to select the correct REFCLK
816 + mask = PHY_REF_CLK_SEL;
817 + comphy_lane_reg_set(lane, COMPHY_MISC_CTRL0, data, mask);
820 + * 9. Set correct reference clock frequency in COMPHY register
823 + if (lane->priv->xtal_is_40m)
824 + data = REF_FREF_SEL_SERDES_50MHZ;
826 + data = REF_FREF_SEL_SERDES_25MHZ;
828 + mask = REF_FREF_SEL_MASK;
829 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL, data, mask);
832 + * 10. Program COMPHY register PHY_GEN_MAX[1:0]
833 + * This step is mentioned in the flow received from verification team.
834 + * However the PHY_GEN_MAX value is only meaningful for other interfaces
835 + * (not SERDES). For instance, it selects SATA speed 1.5/3/6 Gbps or
836 + * PCIe speed 2.5/5 Gbps
840 + * 11. Program COMPHY register SEL_BITS to set correct parallel data
843 + data = DATA_WIDTH_10BIT;
844 + mask = SEL_DATA_WIDTH_MASK;
845 + comphy_lane_reg_set(lane, COMPHY_DIG_LOOPBACK_EN, data, mask);
848 + * 12. As long as DFE function needs to be enabled in any mode,
849 + * COMPHY register DFE_UPDATE_EN[5:0] shall be programmed to 0x3F
850 + * for real chip during COMPHY power on.
851 + * The value of the DFE_UPDATE_EN already is 0x3F, because it is the
852 + * default value after reset of the PHY.
856 + * 13. Program COMPHY GEN registers.
857 + * These registers should be programmed based on the lab testing result
858 + * to achieve optimal performance. Please contact the CEA group to get
859 + * the related GEN table during real chip bring-up. We only required to
860 + * run though the entire registers programming flow defined by
861 + * "comphy_gbe_phy_init" when the REF clock is 40 MHz. For REF clock
862 + * 25 MHz the default values stored in PHY registers are OK.
864 + dev_dbg(lane->dev, "Running C-DPI phy init %s mode\n",
865 + lane->submode == PHY_INTERFACE_MODE_2500BASEX ? "2G5" : "1G");
866 + if (lane->priv->xtal_is_40m)
867 + comphy_gbe_phy_init(lane,
868 + lane->submode != PHY_INTERFACE_MODE_2500BASEX);
871 + * 14. Check the PHY Polarity invert bit
874 + if (lane->invert_tx)
875 + data |= TXD_INVERT_BIT;
876 + if (lane->invert_rx)
877 + data |= RXD_INVERT_BIT;
878 + mask = TXD_INVERT_BIT | RXD_INVERT_BIT;
879 + comphy_lane_reg_set(lane, COMPHY_SYNC_PATTERN, data, mask);
882 + * 15. Set PHY input ports PIN_PU_PLL, PIN_PU_TX and PIN_PU_RX to 1 to
883 + * start PHY power up sequence. All the PHY register programming should
884 + * be done before PIN_PU_PLL=1. There should be no register programming
885 + * for normal PHY operation from this point.
887 + data = PIN_PU_PLL_BIT | PIN_PU_RX_BIT | PIN_PU_TX_BIT;
889 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
892 + * 16. Wait for PHY power up sequence to finish by checking output ports
893 + * PIN_PLL_READY_TX=1 and PIN_PLL_READY_RX=1.
895 + ret = comphy_periph_reg_poll(lane, COMPHY_PHY_STAT1,
896 + PHY_PLL_READY_TX_BIT |
897 + PHY_PLL_READY_RX_BIT,
898 + COMPHY_PLL_SLEEP, COMPHY_PLL_TIMEOUT);
900 + dev_err(lane->dev, "Failed to lock PLL for SERDES PHY %d\n",
906 + * 17. Set COMPHY input port PIN_TX_IDLE=0
908 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, 0x0, PIN_TX_IDLE_BIT);
911 + * 18. After valid data appear on PIN_RXDATA bus, set PIN_RX_INIT=1. To
912 + * start RX initialization. PIN_RX_INIT_DONE will be cleared to 0 by the
913 + * PHY After RX initialization is done, PIN_RX_INIT_DONE will be set to
914 + * 1 by COMPHY Set PIN_RX_INIT=0 after PIN_RX_INIT_DONE= 1. Please
915 + * refer to RX initialization part for details.
917 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1,
918 + PHY_RX_INIT_BIT, PHY_RX_INIT_BIT);
920 + ret = comphy_periph_reg_poll(lane, COMPHY_PHY_STAT1,
921 + PHY_PLL_READY_TX_BIT |
922 + PHY_PLL_READY_RX_BIT,
923 + COMPHY_PLL_SLEEP, COMPHY_PLL_TIMEOUT);
925 + dev_err(lane->dev, "Failed to lock PLL for SERDES PHY %d\n",
930 + ret = comphy_periph_reg_poll(lane, COMPHY_PHY_STAT1,
931 + PHY_RX_INIT_DONE_BIT,
932 + COMPHY_PLL_SLEEP, COMPHY_PLL_TIMEOUT);
934 + dev_err(lane->dev, "Failed to init RX of SERDES PHY %d\n",
940 -static int mvebu_a3700_comphy_get_fw_mode(int lane,
942 +mvebu_a3700_comphy_usb3_power_on(struct mvebu_a3700_comphy_lane *lane)
944 + u32 mask, data, cfg, ref_clk;
947 + /* Set phy seclector */
948 + ret = mvebu_a3700_comphy_set_phy_selector(lane);
953 + * 0. Set PHY OTG Control(0x5d034), bit 4, Power up OTG module The
954 + * register belong to UTMI module, so it is set in UTMI phy driver.
958 + * 1. Set PRD_TXDEEMPH (3.5db de-emph)
960 + data = PRD_TXDEEMPH0_MASK;
961 + mask = PRD_TXDEEMPH0_MASK | PRD_TXMARGIN_MASK | PRD_TXSWING_MASK |
962 + CFG_TX_ALIGN_POS_MASK;
963 + comphy_lane_reg_set(lane, COMPHY_PIPE_LANE_CFG0, data, mask);
966 + * 2. Set BIT0: enable transmitter in high impedance mode
967 + * Set BIT[3:4]: delay 2 clock cycles for HiZ off latency
968 + * Set BIT6: Tx detect Rx at HiZ mode
969 + * Unset BIT15: set to 0 to set USB3 De-emphasize level to -3.5db
970 + * together with bit 0 of COMPHY_PIPE_LANE_CFG0 register
972 + data = TX_DET_RX_MODE | GEN2_TX_DATA_DLY_DEFT | TX_ELEC_IDLE_MODE_EN;
973 + mask = PRD_TXDEEMPH1_MASK | TX_DET_RX_MODE | GEN2_TX_DATA_DLY_MASK |
974 + TX_ELEC_IDLE_MODE_EN;
975 + comphy_lane_reg_set(lane, COMPHY_PIPE_LANE_CFG1, data, mask);
978 + * 3. Set Spread Spectrum Clock Enabled
980 + comphy_lane_reg_set(lane, COMPHY_PIPE_LANE_CFG4,
981 + SPREAD_SPECTRUM_CLK_EN, SPREAD_SPECTRUM_CLK_EN);
984 + * 4. Set Override Margining Controls From the MAC:
985 + * Use margining signals from lane configuration
987 + comphy_lane_reg_set(lane, COMPHY_PIPE_TEST_MODE_CTRL,
988 + MODE_MARGIN_OVERRIDE, 0xFFFF);
991 + * 5. Set Lane-to-Lane Bundle Clock Sampling Period = per PCLK cycles
992 + * set Mode Clock Source = PCLK is generated from REFCLK
995 + mask = MODE_CLK_SRC | BUNDLE_PERIOD_SEL | BUNDLE_PERIOD_SCALE_MASK |
996 + BUNDLE_SAMPLE_CTRL | PLL_READY_DLY_MASK;
997 + comphy_lane_reg_set(lane, COMPHY_PIPE_CLK_SRC_LO, data, mask);
1000 + * 6. Set G2 Spread Spectrum Clock Amplitude at 4K
1002 + comphy_lane_reg_set(lane, COMPHY_GEN2_SET2,
1003 + GS2_TX_SSC_AMP_4128, GS2_TX_SSC_AMP_MASK);
1006 + * 7. Unset G3 Spread Spectrum Clock Amplitude
1007 + * set G3 TX and RX Register Master Current Select
1009 + data = GS2_VREG_RXTX_MAS_ISET_60U;
1010 + mask = GS2_TX_SSC_AMP_MASK | GS2_VREG_RXTX_MAS_ISET_MASK |
1011 + GS2_RSVD_6_0_MASK;
1012 + comphy_lane_reg_set(lane, COMPHY_GEN3_SET2, data, mask);
1015 + * 8. Check crystal jumper setting and program the Power and PLL Control
1016 + * accordingly Change RX wait
1018 + if (lane->priv->xtal_is_40m) {
1019 + ref_clk = REF_FREF_SEL_PCIE_USB3_40MHZ;
1020 + cfg = CFG_PM_RXDLOZ_WAIT_12_UNIT;
1022 + ref_clk = REF_FREF_SEL_PCIE_USB3_25MHZ;
1023 + cfg = CFG_PM_RXDLOZ_WAIT_7_UNIT;
1026 + data = PU_IVREF_BIT | PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT |
1027 + PU_TX_INTP_BIT | PU_DFE_BIT | COMPHY_MODE_USB3 | ref_clk;
1028 + mask = PU_IVREF_BIT | PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT |
1029 + PU_TX_INTP_BIT | PU_DFE_BIT | PLL_LOCK_BIT | COMPHY_MODE_MASK |
1030 + REF_FREF_SEL_MASK;
1031 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL, data, mask);
1033 + data = CFG_PM_RXDEN_WAIT_1_UNIT | cfg;
1034 + mask = CFG_PM_OSCCLK_WAIT_MASK | CFG_PM_RXDEN_WAIT_MASK |
1035 + CFG_PM_RXDLOZ_WAIT_MASK;
1036 + comphy_lane_reg_set(lane, COMPHY_PIPE_PWR_MGM_TIM1, data, mask);
1039 + * 9. Enable idle sync
1041 + comphy_lane_reg_set(lane, COMPHY_IDLE_SYNC_EN,
1042 + IDLE_SYNC_EN, IDLE_SYNC_EN);
1045 + * 10. Enable the output of 500M clock
1047 + comphy_lane_reg_set(lane, COMPHY_MISC_CTRL0, CLK500M_EN, CLK500M_EN);
1050 + * 11. Set 20-bit data width
1052 + comphy_lane_reg_set(lane, COMPHY_DIG_LOOPBACK_EN,
1053 + DATA_WIDTH_20BIT, 0xFFFF);
1056 + * 12. Override Speed_PLL value and use MAC PLL
1058 + data = SPEED_PLL_VALUE_16 | USE_MAX_PLL_RATE_BIT;
1060 + comphy_lane_reg_set(lane, COMPHY_KVCO_CAL_CTRL, data, mask);
1063 + * 13. Check the Polarity invert bit
1066 + if (lane->invert_tx)
1067 + data |= TXD_INVERT_BIT;
1068 + if (lane->invert_rx)
1069 + data |= RXD_INVERT_BIT;
1070 + mask = TXD_INVERT_BIT | RXD_INVERT_BIT;
1071 + comphy_lane_reg_set(lane, COMPHY_SYNC_PATTERN, data, mask);
1074 + * 14. Set max speed generation to USB3.0 5Gbps
1076 + comphy_lane_reg_set(lane, COMPHY_SYNC_MASK_GEN,
1077 + PHY_GEN_MAX_USB3_5G, PHY_GEN_MAX_MASK);
1080 + * 15. Set capacitor value for FFE gain peaking to 0xF
1082 + comphy_lane_reg_set(lane, COMPHY_GEN2_SET3,
1083 + GS3_FFE_CAP_SEL_VALUE, GS3_FFE_CAP_SEL_MASK);
1086 + * 16. Release SW reset
1088 + data = MODE_CORE_CLK_FREQ_SEL | MODE_PIPE_WIDTH_32 | MODE_REFDIV_BY_4;
1090 + comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL, data, mask);
1092 + /* Wait for > 55 us to allow PCLK be enabled */
1093 + udelay(PLL_SET_DELAY_US);
1095 + ret = comphy_lane_reg_poll(lane, COMPHY_PIPE_LANE_STAT1, TXDCLK_PCLK_EN,
1096 + COMPHY_PLL_SLEEP, COMPHY_PLL_TIMEOUT);
1098 + dev_err(lane->dev, "Failed to lock USB3 PLL\n");
1104 +mvebu_a3700_comphy_pcie_power_on(struct mvebu_a3700_comphy_lane *lane)
1106 + u32 mask, data, ref_clk;
1109 + /* Configure phy selector for PCIe */
1110 + ret = mvebu_a3700_comphy_set_phy_selector(lane);
1114 + /* 1. Enable max PLL. */
1115 + comphy_lane_reg_set(lane, COMPHY_PIPE_LANE_CFG1,
1116 + USE_MAX_PLL_RATE_EN, USE_MAX_PLL_RATE_EN);
1118 + /* 2. Select 20 bit SERDES interface. */
1119 + comphy_lane_reg_set(lane, COMPHY_PIPE_CLK_SRC_LO,
1120 + CFG_SEL_20B, CFG_SEL_20B);
1122 + /* 3. Force to use reg setting for PCIe mode */
1123 + comphy_lane_reg_set(lane, COMPHY_MISC_CTRL1,
1124 + SEL_BITS_PCIE_FORCE, SEL_BITS_PCIE_FORCE);
1126 + /* 4. Change RX wait */
1127 + data = CFG_PM_RXDEN_WAIT_1_UNIT | CFG_PM_RXDLOZ_WAIT_12_UNIT;
1128 + mask = CFG_PM_OSCCLK_WAIT_MASK | CFG_PM_RXDEN_WAIT_MASK |
1129 + CFG_PM_RXDLOZ_WAIT_MASK;
1130 + comphy_lane_reg_set(lane, COMPHY_PIPE_PWR_MGM_TIM1, data, mask);
1132 + /* 5. Enable idle sync */
1133 + comphy_lane_reg_set(lane, COMPHY_IDLE_SYNC_EN,
1134 + IDLE_SYNC_EN, IDLE_SYNC_EN);
1136 + /* 6. Enable the output of 100M/125M/500M clock */
1137 + data = CLK500M_EN | TXDCLK_2X_SEL | CLK100M_125M_EN;
1139 + comphy_lane_reg_set(lane, COMPHY_MISC_CTRL0, data, mask);
1142 + * 7. Enable TX, PCIE global register, 0xd0074814, it is done in
1147 + * 8. Check crystal jumper setting and program the Power and PLL
1148 + * Control accordingly
1151 + if (lane->priv->xtal_is_40m)
1152 + ref_clk = REF_FREF_SEL_PCIE_USB3_40MHZ;
1154 + ref_clk = REF_FREF_SEL_PCIE_USB3_25MHZ;
1156 + data = PU_IVREF_BIT | PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT |
1157 + PU_TX_INTP_BIT | PU_DFE_BIT | COMPHY_MODE_PCIE | ref_clk;
1159 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL, data, mask);
1161 + /* 9. Override Speed_PLL value and use MAC PLL */
1162 + comphy_lane_reg_set(lane, COMPHY_KVCO_CAL_CTRL,
1163 + SPEED_PLL_VALUE_16 | USE_MAX_PLL_RATE_BIT,
1166 + /* 10. Check the Polarity invert bit */
1168 + if (lane->invert_tx)
1169 + data |= TXD_INVERT_BIT;
1170 + if (lane->invert_rx)
1171 + data |= RXD_INVERT_BIT;
1172 + mask = TXD_INVERT_BIT | RXD_INVERT_BIT;
1173 + comphy_lane_reg_set(lane, COMPHY_SYNC_PATTERN, data, mask);
1175 + /* 11. Release SW reset */
1176 + data = MODE_CORE_CLK_FREQ_SEL | MODE_PIPE_WIDTH_32;
1177 + mask = data | PIPE_SOFT_RESET | MODE_REFDIV_MASK;
1178 + comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL, data, mask);
1180 + /* Wait for > 55 us to allow PCLK be enabled */
1181 + udelay(PLL_SET_DELAY_US);
1183 + ret = comphy_lane_reg_poll(lane, COMPHY_PIPE_LANE_STAT1, TXDCLK_PCLK_EN,
1184 + COMPHY_PLL_SLEEP, COMPHY_PLL_TIMEOUT);
1186 + dev_err(lane->dev, "Failed to lock PCIE PLL\n");
1192 +mvebu_a3700_comphy_sata_power_off(struct mvebu_a3700_comphy_lane *lane)
1194 + /* Set phy isolation mode */
1195 + comphy_lane_reg_set(lane, COMPHY_ISOLATION_CTRL,
1196 + PHY_ISOLATE_MODE, PHY_ISOLATE_MODE);
1198 + /* Power off PLL, Tx, Rx */
1199 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL,
1200 + 0x0, PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT);
1204 +mvebu_a3700_comphy_ethernet_power_off(struct mvebu_a3700_comphy_lane *lane)
1208 + data = PIN_RESET_CORE_BIT | PIN_RESET_COMPHY_BIT | PIN_PU_IVREF_BIT |
1211 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
1215 +mvebu_a3700_comphy_pcie_power_off(struct mvebu_a3700_comphy_lane *lane)
1217 + /* Power off PLL, Tx, Rx */
1218 + comphy_lane_reg_set(lane, COMPHY_POWER_PLL_CTRL,
1219 + 0x0, PU_PLL_BIT | PU_RX_BIT | PU_TX_BIT);
1222 +static int mvebu_a3700_comphy_reset(struct phy *phy)
1224 + struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
1227 + dev_dbg(lane->dev, "resetting lane %d\n", lane->id);
1229 + /* COMPHY reset for internal logic */
1230 + comphy_lane_reg_set(lane, COMPHY_SFT_RESET,
1231 + SFT_RST_NO_REG, SFT_RST_NO_REG);
1233 + /* COMPHY register reset (cleared automatically) */
1234 + comphy_lane_reg_set(lane, COMPHY_SFT_RESET, SFT_RST, SFT_RST);
1236 + /* PIPE soft and register reset */
1237 + data = PIPE_SOFT_RESET | PIPE_REG_RESET;
1239 + comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL, data, mask);
1241 + /* Release PIPE register reset */
1242 + comphy_lane_reg_set(lane, COMPHY_PIPE_RST_CLK_CTRL,
1243 + 0x0, PIPE_REG_RESET);
1245 + /* Reset SB configuration register (only for lanes 0 and 1) */
1246 + if (lane->id == 0 || lane->id == 1) {
1249 + data = PIN_RESET_CORE_BIT | PIN_RESET_COMPHY_BIT |
1250 + PIN_PU_PLL_BIT | PIN_PU_RX_BIT | PIN_PU_TX_BIT;
1251 + mask = data | PIN_PU_IVREF_BIT | PIN_TX_IDLE_BIT;
1252 + comphy_periph_reg_set(lane, COMPHY_PHY_CFG1, data, mask);
1258 +static bool mvebu_a3700_comphy_check_mode(int lane,
1262 @@ -122,7 +1141,7 @@ static int mvebu_a3700_comphy_get_fw_mod
1264 /* Unused PHY mux value is 0x0 */
1265 if (mode == PHY_MODE_INVALID)
1269 for (i = 0; i < n; i++) {
1270 if (mvebu_a3700_comphy_modes[i].lane == lane &&
1271 @@ -132,27 +1151,30 @@ static int mvebu_a3700_comphy_get_fw_mod
1278 - return mvebu_a3700_comphy_modes[i].fw_mode;
1282 static int mvebu_a3700_comphy_set_mode(struct phy *phy, enum phy_mode mode,
1285 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
1288 - if (submode == PHY_INTERFACE_MODE_1000BASEX)
1289 - submode = PHY_INTERFACE_MODE_SGMII;
1291 - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id, mode,
1293 - if (fw_mode < 0) {
1294 + if (!mvebu_a3700_comphy_check_mode(lane->id, mode, submode)) {
1295 dev_err(lane->dev, "invalid COMPHY mode\n");
1300 + /* Mode cannot be changed while the PHY is powered on */
1301 + if (phy->power_count &&
1302 + (lane->mode != mode || lane->submode != submode))
1305 + /* If changing mode, ensure reset is called */
1306 + if (lane->mode != PHY_MODE_INVALID && lane->mode != mode)
1307 + lane->needs_reset = true;
1309 /* Just remember the mode, ->power_on() will do the real setup */
1311 lane->submode = submode;
1312 @@ -163,76 +1185,77 @@ static int mvebu_a3700_comphy_set_mode(s
1313 static int mvebu_a3700_comphy_power_on(struct phy *phy)
1315 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
1321 - fw_mode = mvebu_a3700_comphy_get_fw_mode(lane->id,
1322 - lane->mode, lane->submode);
1323 - if (fw_mode < 0) {
1324 + if (!mvebu_a3700_comphy_check_mode(lane->id, lane->mode,
1326 dev_err(lane->dev, "invalid COMPHY mode\n");
1331 + if (lane->needs_reset) {
1332 + ret = mvebu_a3700_comphy_reset(phy);
1336 + lane->needs_reset = false;
1339 switch (lane->mode) {
1340 case PHY_MODE_USB_HOST_SS:
1341 dev_dbg(lane->dev, "set lane %d to USB3 host mode\n", lane->id);
1342 - fw_param = COMPHY_FW_MODE(fw_mode);
1344 + return mvebu_a3700_comphy_usb3_power_on(lane);
1346 dev_dbg(lane->dev, "set lane %d to SATA mode\n", lane->id);
1347 - fw_param = COMPHY_FW_MODE(fw_mode);
1349 + return mvebu_a3700_comphy_sata_power_on(lane);
1350 case PHY_MODE_ETHERNET:
1351 - fw_port = (lane->id == 0) ? 1 : 0;
1352 - switch (lane->submode) {
1353 - case PHY_INTERFACE_MODE_SGMII:
1354 - dev_dbg(lane->dev, "set lane %d to SGMII mode\n",
1356 - fw_param = COMPHY_FW_NET(fw_mode, fw_port,
1357 - COMPHY_FW_SPEED_1_25G);
1359 - case PHY_INTERFACE_MODE_2500BASEX:
1360 - dev_dbg(lane->dev, "set lane %d to 2500BASEX mode\n",
1362 - fw_param = COMPHY_FW_NET(fw_mode, fw_port,
1363 - COMPHY_FW_SPEED_3_125G);
1366 - dev_err(lane->dev, "unsupported PHY submode (%d)\n",
1371 + dev_dbg(lane->dev, "set lane %d to Ethernet mode\n", lane->id);
1372 + return mvebu_a3700_comphy_ethernet_power_on(lane);
1374 dev_dbg(lane->dev, "set lane %d to PCIe mode\n", lane->id);
1375 - fw_param = COMPHY_FW_PCIE(fw_mode, COMPHY_FW_SPEED_5G,
1376 - phy->attrs.bus_width);
1378 + return mvebu_a3700_comphy_pcie_power_on(lane);
1380 dev_err(lane->dev, "unsupported PHY mode (%d)\n", lane->mode);
1382 + return -EOPNOTSUPP;
1385 - ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param);
1386 - if (ret == -EOPNOTSUPP)
1387 - dev_err(lane->dev,
1388 - "unsupported SMC call, try updating your firmware\n");
1393 static int mvebu_a3700_comphy_power_off(struct phy *phy)
1395 struct mvebu_a3700_comphy_lane *lane = phy_get_drvdata(phy);
1397 - return mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_OFF, lane->id, 0);
1398 + switch (lane->mode) {
1399 + case PHY_MODE_USB_HOST_SS:
1401 + * The USB3 MAC sets the USB3 PHY to low state, so we do not
1402 + * need to power off USB3 PHY again.
1406 + case PHY_MODE_SATA:
1407 + mvebu_a3700_comphy_sata_power_off(lane);
1410 + case PHY_MODE_ETHERNET:
1411 + mvebu_a3700_comphy_ethernet_power_off(lane);
1414 + case PHY_MODE_PCIE:
1415 + mvebu_a3700_comphy_pcie_power_off(lane);
1419 + dev_err(lane->dev, "invalid COMPHY mode\n");
1426 static const struct phy_ops mvebu_a3700_comphy_ops = {
1427 .power_on = mvebu_a3700_comphy_power_on,
1428 .power_off = mvebu_a3700_comphy_power_off,
1429 + .reset = mvebu_a3700_comphy_reset,
1430 .set_mode = mvebu_a3700_comphy_set_mode,
1431 .owner = THIS_MODULE,
1433 @@ -256,13 +1279,75 @@ static struct phy *mvebu_a3700_comphy_xl
1434 return ERR_PTR(-EINVAL);
1437 + lane->invert_tx = args->args[1] & BIT(0);
1438 + lane->invert_rx = args->args[1] & BIT(1);
1443 static int mvebu_a3700_comphy_probe(struct platform_device *pdev)
1445 + struct mvebu_a3700_comphy_priv *priv;
1446 struct phy_provider *provider;
1447 struct device_node *child;
1448 + struct resource *res;
1452 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
1456 + spin_lock_init(&priv->lock);
1458 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "comphy");
1459 + priv->comphy_regs = devm_ioremap_resource(&pdev->dev, res);
1460 + if (IS_ERR(priv->comphy_regs))
1461 + return PTR_ERR(priv->comphy_regs);
1463 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1464 + "lane1_pcie_gbe");
1465 + priv->lane1_phy_regs = devm_ioremap_resource(&pdev->dev, res);
1466 + if (IS_ERR(priv->lane1_phy_regs))
1467 + return PTR_ERR(priv->lane1_phy_regs);
1469 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1470 + "lane0_usb3_gbe");
1471 + priv->lane0_phy_regs = devm_ioremap_resource(&pdev->dev, res);
1472 + if (IS_ERR(priv->lane0_phy_regs))
1473 + return PTR_ERR(priv->lane0_phy_regs);
1475 + res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
1476 + "lane2_sata_usb3");
1477 + priv->lane2_phy_indirect = devm_ioremap_resource(&pdev->dev, res);
1478 + if (IS_ERR(priv->lane2_phy_indirect))
1479 + return PTR_ERR(priv->lane2_phy_indirect);
1482 + * Driver needs to know if reference xtal clock is 40MHz or 25MHz.
1483 + * Old DT bindings do not have xtal clk present. So do not fail here
1484 + * and expects that default 25MHz reference clock is used.
1486 + clk = clk_get(&pdev->dev, "xtal");
1487 + if (IS_ERR(clk)) {
1488 + if (PTR_ERR(clk) == -EPROBE_DEFER)
1489 + return -EPROBE_DEFER;
1490 + dev_warn(&pdev->dev, "missing 'xtal' clk (%ld)\n",
1493 + ret = clk_prepare_enable(clk);
1495 + dev_warn(&pdev->dev, "enabling xtal clk failed (%d)\n",
1498 + if (clk_get_rate(clk) == 40000000)
1499 + priv->xtal_is_40m = true;
1500 + clk_disable_unprepare(clk);
1505 + dev_set_drvdata(&pdev->dev, priv);
1507 for_each_available_child_of_node(pdev->dev.of_node, child) {
1508 struct mvebu_a3700_comphy_lane *lane;
1509 @@ -277,7 +1362,7 @@ static int mvebu_a3700_comphy_probe(stru
1513 - if (lane_id >= MVEBU_A3700_COMPHY_LANES) {
1514 + if (lane_id >= 3) {
1515 dev_err(&pdev->dev, "invalid 'reg' property\n");
1518 @@ -295,15 +1380,26 @@ static int mvebu_a3700_comphy_probe(stru
1519 return PTR_ERR(phy);
1522 + lane->priv = priv;
1523 lane->dev = &pdev->dev;
1524 lane->mode = PHY_MODE_INVALID;
1525 lane->submode = PHY_INTERFACE_MODE_NA;
1527 + lane->invert_tx = false;
1528 + lane->invert_rx = false;
1529 phy_set_drvdata(phy, lane);
1532 + * To avoid relying on the bootloader/firmware configuration,
1533 + * power off all comphys.
1535 + mvebu_a3700_comphy_reset(phy);
1536 + lane->needs_reset = false;
1539 provider = devm_of_phy_provider_register(&pdev->dev,
1540 mvebu_a3700_comphy_xlate);
1542 return PTR_ERR_OR_ZERO(provider);
1545 @@ -323,5 +1419,7 @@ static struct platform_driver mvebu_a370
1546 module_platform_driver(mvebu_a3700_comphy_driver);
1548 MODULE_AUTHOR("Miquèl Raynal <miquel.raynal@bootlin.com>");
1549 +MODULE_AUTHOR("Pali Rohár <pali@kernel.org>");
1550 +MODULE_AUTHOR("Marek Behún <kabel@kernel.org>");
1551 MODULE_DESCRIPTION("Common PHY driver for A3700");
1552 MODULE_LICENSE("GPL v2");