1 // SPDX-License-Identifier: GPL-2.0+
3 * drivers/net/phy/marvell.c
5 * Driver for Marvell PHYs
9 * Copyright (c) 2004 Freescale Semiconductor, Inc.
11 * Copyright (c) 2013 Michael Stapelberg <michael@stapelberg.de>
13 #include <linux/kernel.h>
14 #include <linux/string.h>
15 #include <linux/ctype.h>
16 #include <linux/errno.h>
17 #include <linux/unistd.h>
18 #include <linux/hwmon.h>
19 #include <linux/interrupt.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
22 #include <linux/netdevice.h>
23 #include <linux/etherdevice.h>
24 #include <linux/skbuff.h>
25 #include <linux/spinlock.h>
27 #include <linux/module.h>
28 #include <linux/mii.h>
29 #include <linux/ethtool.h>
30 #include <linux/ethtool_netlink.h>
31 #include <linux/phy.h>
32 #include <linux/marvell_phy.h>
33 #include <linux/bitfield.h>
38 #include <linux/uaccess.h>
40 #define MII_MARVELL_PHY_PAGE 22
41 #define MII_MARVELL_COPPER_PAGE 0x00
42 #define MII_MARVELL_FIBER_PAGE 0x01
43 #define MII_MARVELL_MSCR_PAGE 0x02
44 #define MII_MARVELL_LED_PAGE 0x03
45 #define MII_MARVELL_VCT5_PAGE 0x05
46 #define MII_MARVELL_MISC_TEST_PAGE 0x06
47 #define MII_MARVELL_VCT7_PAGE 0x07
48 #define MII_MARVELL_WOL_PAGE 0x11
50 #define MII_M1011_IEVENT 0x13
51 #define MII_M1011_IEVENT_CLEAR 0x0000
53 #define MII_M1011_IMASK 0x12
54 #define MII_M1011_IMASK_INIT 0x6400
55 #define MII_M1011_IMASK_CLEAR 0x0000
57 #define MII_M1011_PHY_SCR 0x10
58 #define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
59 #define MII_M1011_PHY_SCR_DOWNSHIFT_MASK GENMASK(14, 12)
60 #define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8
61 #define MII_M1011_PHY_SCR_MDI (0x0 << 5)
62 #define MII_M1011_PHY_SCR_MDI_X (0x1 << 5)
63 #define MII_M1011_PHY_SCR_AUTO_CROSS (0x3 << 5)
65 #define MII_M1011_PHY_SSR 0x11
66 #define MII_M1011_PHY_SSR_DOWNSHIFT BIT(5)
68 #define MII_M1111_PHY_LED_CONTROL 0x18
69 #define MII_M1111_PHY_LED_DIRECT 0x4100
70 #define MII_M1111_PHY_LED_COMBINE 0x411c
71 #define MII_M1111_PHY_EXT_CR 0x14
72 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK GENMASK(11, 9)
73 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX 8
74 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN BIT(8)
75 #define MII_M1111_RGMII_RX_DELAY BIT(7)
76 #define MII_M1111_RGMII_TX_DELAY BIT(1)
77 #define MII_M1111_PHY_EXT_SR 0x1b
79 #define MII_M1111_HWCFG_MODE_MASK 0xf
80 #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
81 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
82 #define MII_M1111_HWCFG_MODE_RTBI 0x7
83 #define MII_M1111_HWCFG_MODE_COPPER_1000X_AN 0x8
84 #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
85 #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
86 #define MII_M1111_HWCFG_MODE_COPPER_1000X_NOAN 0xc
87 #define MII_M1111_HWCFG_SERIAL_AN_BYPASS BIT(12)
88 #define MII_M1111_HWCFG_FIBER_COPPER_RES BIT(13)
89 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO BIT(15)
91 #define MII_88E1121_PHY_MSCR_REG 21
92 #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
93 #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
94 #define MII_88E1121_PHY_MSCR_DELAY_MASK (BIT(5) | BIT(4))
96 #define MII_88E1121_MISC_TEST 0x1a
97 #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK 0x1f00
98 #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT 8
99 #define MII_88E1510_MISC_TEST_TEMP_IRQ_EN BIT(7)
100 #define MII_88E1510_MISC_TEST_TEMP_IRQ BIT(6)
101 #define MII_88E1121_MISC_TEST_TEMP_SENSOR_EN BIT(5)
102 #define MII_88E1121_MISC_TEST_TEMP_MASK 0x1f
104 #define MII_88E1510_TEMP_SENSOR 0x1b
105 #define MII_88E1510_TEMP_SENSOR_MASK 0xff
107 #define MII_88E1540_COPPER_CTRL3 0x1a
108 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK GENMASK(11, 10)
109 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS 0
110 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS 1
111 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS 2
112 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS 3
113 #define MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN BIT(9)
115 #define MII_88E6390_MISC_TEST 0x1b
116 #define MII_88E6390_MISC_TEST_SAMPLE_1S 0
117 #define MII_88E6390_MISC_TEST_SAMPLE_10MS BIT(14)
118 #define MII_88E6390_MISC_TEST_SAMPLE_DISABLE BIT(15)
119 #define MII_88E6390_MISC_TEST_SAMPLE_ENABLE 0
120 #define MII_88E6390_MISC_TEST_SAMPLE_MASK (0x3 << 14)
122 #define MII_88E6390_TEMP_SENSOR 0x1c
123 #define MII_88E6390_TEMP_SENSOR_MASK 0xff
124 #define MII_88E6390_TEMP_SENSOR_SAMPLES 10
126 #define MII_88E1318S_PHY_MSCR1_REG 16
127 #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
129 /* Copper Specific Interrupt Enable Register */
130 #define MII_88E1318S_PHY_CSIER 0x12
131 /* WOL Event Interrupt Enable */
132 #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
134 /* LED Timer Control Register */
135 #define MII_88E1318S_PHY_LED_TCR 0x12
136 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
137 #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
138 #define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
140 /* Magic Packet MAC address registers */
141 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
142 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
143 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
145 #define MII_88E1318S_PHY_WOL_CTRL 0x10
146 #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
147 #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
149 #define MII_PHY_LED_CTRL 16
150 #define MII_88E1121_PHY_LED_DEF 0x0030
151 #define MII_88E1510_PHY_LED_DEF 0x1177
152 #define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE 0x1040
154 #define MII_M1011_PHY_STATUS 0x11
155 #define MII_M1011_PHY_STATUS_1000 0x8000
156 #define MII_M1011_PHY_STATUS_100 0x4000
157 #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
158 #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
159 #define MII_M1011_PHY_STATUS_RESOLVED 0x0800
160 #define MII_M1011_PHY_STATUS_LINK 0x0400
162 #define MII_88E3016_PHY_SPEC_CTRL 0x10
163 #define MII_88E3016_DISABLE_SCRAMBLER 0x0200
164 #define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
166 #define MII_88E1510_GEN_CTRL_REG_1 0x14
167 #define MII_88E1510_GEN_CTRL_REG_1_MODE_MASK 0x7
168 #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII 0x1 /* SGMII to copper */
169 #define MII_88E1510_GEN_CTRL_REG_1_RESET 0x8000 /* Soft reset */
171 #define MII_VCT5_TX_RX_MDI0_COUPLING 0x10
172 #define MII_VCT5_TX_RX_MDI1_COUPLING 0x11
173 #define MII_VCT5_TX_RX_MDI2_COUPLING 0x12
174 #define MII_VCT5_TX_RX_MDI3_COUPLING 0x13
175 #define MII_VCT5_TX_RX_AMPLITUDE_MASK 0x7f00
176 #define MII_VCT5_TX_RX_AMPLITUDE_SHIFT 8
177 #define MII_VCT5_TX_RX_COUPLING_POSITIVE_REFLECTION BIT(15)
179 #define MII_VCT5_CTRL 0x17
180 #define MII_VCT5_CTRL_ENABLE BIT(15)
181 #define MII_VCT5_CTRL_COMPLETE BIT(14)
182 #define MII_VCT5_CTRL_TX_SAME_CHANNEL (0x0 << 11)
183 #define MII_VCT5_CTRL_TX0_CHANNEL (0x4 << 11)
184 #define MII_VCT5_CTRL_TX1_CHANNEL (0x5 << 11)
185 #define MII_VCT5_CTRL_TX2_CHANNEL (0x6 << 11)
186 #define MII_VCT5_CTRL_TX3_CHANNEL (0x7 << 11)
187 #define MII_VCT5_CTRL_SAMPLES_2 (0x0 << 8)
188 #define MII_VCT5_CTRL_SAMPLES_4 (0x1 << 8)
189 #define MII_VCT5_CTRL_SAMPLES_8 (0x2 << 8)
190 #define MII_VCT5_CTRL_SAMPLES_16 (0x3 << 8)
191 #define MII_VCT5_CTRL_SAMPLES_32 (0x4 << 8)
192 #define MII_VCT5_CTRL_SAMPLES_64 (0x5 << 8)
193 #define MII_VCT5_CTRL_SAMPLES_128 (0x6 << 8)
194 #define MII_VCT5_CTRL_SAMPLES_DEFAULT (0x6 << 8)
195 #define MII_VCT5_CTRL_SAMPLES_256 (0x7 << 8)
196 #define MII_VCT5_CTRL_SAMPLES_SHIFT 8
197 #define MII_VCT5_CTRL_MODE_MAXIMUM_PEEK (0x0 << 6)
198 #define MII_VCT5_CTRL_MODE_FIRST_LAST_PEEK (0x1 << 6)
199 #define MII_VCT5_CTRL_MODE_OFFSET (0x2 << 6)
200 #define MII_VCT5_CTRL_SAMPLE_POINT (0x3 << 6)
201 #define MII_VCT5_CTRL_PEEK_HYST_DEFAULT 3
203 #define MII_VCT5_SAMPLE_POINT_DISTANCE 0x18
204 #define MII_VCT5_SAMPLE_POINT_DISTANCE_MAX 511
205 #define MII_VCT5_TX_PULSE_CTRL 0x1c
206 #define MII_VCT5_TX_PULSE_CTRL_DONT_WAIT_LINK_DOWN BIT(12)
207 #define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS (0x0 << 10)
208 #define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_96nS (0x1 << 10)
209 #define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_64nS (0x2 << 10)
210 #define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS (0x3 << 10)
211 #define MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_SHIFT 10
212 #define MII_VCT5_TX_PULSE_CTRL_PULSE_AMPLITUDE_1000mV (0x0 << 8)
213 #define MII_VCT5_TX_PULSE_CTRL_PULSE_AMPLITUDE_750mV (0x1 << 8)
214 #define MII_VCT5_TX_PULSE_CTRL_PULSE_AMPLITUDE_500mV (0x2 << 8)
215 #define MII_VCT5_TX_PULSE_CTRL_PULSE_AMPLITUDE_250mV (0x3 << 8)
216 #define MII_VCT5_TX_PULSE_CTRL_PULSE_AMPLITUDE_SHIFT 8
217 #define MII_VCT5_TX_PULSE_CTRL_MAX_AMP BIT(7)
218 #define MII_VCT5_TX_PULSE_CTRL_GT_140m_46_86mV (0x6 << 0)
220 /* For TDR measurements less than 11 meters, a short pulse should be
223 #define TDR_SHORT_CABLE_LENGTH 11
225 #define MII_VCT7_PAIR_0_DISTANCE 0x10
226 #define MII_VCT7_PAIR_1_DISTANCE 0x11
227 #define MII_VCT7_PAIR_2_DISTANCE 0x12
228 #define MII_VCT7_PAIR_3_DISTANCE 0x13
230 #define MII_VCT7_RESULTS 0x14
231 #define MII_VCT7_RESULTS_PAIR3_MASK 0xf000
232 #define MII_VCT7_RESULTS_PAIR2_MASK 0x0f00
233 #define MII_VCT7_RESULTS_PAIR1_MASK 0x00f0
234 #define MII_VCT7_RESULTS_PAIR0_MASK 0x000f
235 #define MII_VCT7_RESULTS_PAIR3_SHIFT 12
236 #define MII_VCT7_RESULTS_PAIR2_SHIFT 8
237 #define MII_VCT7_RESULTS_PAIR1_SHIFT 4
238 #define MII_VCT7_RESULTS_PAIR0_SHIFT 0
239 #define MII_VCT7_RESULTS_INVALID 0
240 #define MII_VCT7_RESULTS_OK 1
241 #define MII_VCT7_RESULTS_OPEN 2
242 #define MII_VCT7_RESULTS_SAME_SHORT 3
243 #define MII_VCT7_RESULTS_CROSS_SHORT 4
244 #define MII_VCT7_RESULTS_BUSY 9
246 #define MII_VCT7_CTRL 0x15
247 #define MII_VCT7_CTRL_RUN_NOW BIT(15)
248 #define MII_VCT7_CTRL_RUN_ANEG BIT(14)
249 #define MII_VCT7_CTRL_DISABLE_CROSS BIT(13)
250 #define MII_VCT7_CTRL_RUN_AFTER_BREAK_LINK BIT(12)
251 #define MII_VCT7_CTRL_IN_PROGRESS BIT(11)
252 #define MII_VCT7_CTRL_METERS BIT(10)
253 #define MII_VCT7_CTRL_CENTIMETERS 0
255 #define LPA_PAUSE_FIBER 0x180
256 #define LPA_PAUSE_ASYM_FIBER 0x100
258 #define NB_FIBER_STATS 1
260 MODULE_DESCRIPTION("Marvell PHY driver");
261 MODULE_AUTHOR("Andy Fleming");
262 MODULE_LICENSE("GPL");
264 struct marvell_hw_stat
{
271 static struct marvell_hw_stat marvell_hw_stats
[] = {
272 { "phy_receive_errors_copper", 0, 21, 16},
273 { "phy_idle_errors", 0, 10, 8 },
274 { "phy_receive_errors_fiber", 1, 21, 16},
277 struct marvell_priv
{
278 u64 stats
[ARRAY_SIZE(marvell_hw_stats
)];
280 struct device
*hwmon_dev
;
288 static int marvell_read_page(struct phy_device
*phydev
)
290 return __phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
293 static int marvell_write_page(struct phy_device
*phydev
, int page
)
295 return __phy_write(phydev
, MII_MARVELL_PHY_PAGE
, page
);
298 static int marvell_set_page(struct phy_device
*phydev
, int page
)
300 return phy_write(phydev
, MII_MARVELL_PHY_PAGE
, page
);
303 static int marvell_ack_interrupt(struct phy_device
*phydev
)
307 /* Clear the interrupts by reading the reg */
308 err
= phy_read(phydev
, MII_M1011_IEVENT
);
316 static int marvell_config_intr(struct phy_device
*phydev
)
320 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
321 err
= marvell_ack_interrupt(phydev
);
325 err
= phy_write(phydev
, MII_M1011_IMASK
,
326 MII_M1011_IMASK_INIT
);
328 err
= phy_write(phydev
, MII_M1011_IMASK
,
329 MII_M1011_IMASK_CLEAR
);
333 err
= marvell_ack_interrupt(phydev
);
339 static irqreturn_t
marvell_handle_interrupt(struct phy_device
*phydev
)
343 irq_status
= phy_read(phydev
, MII_M1011_IEVENT
);
344 if (irq_status
< 0) {
349 if (!(irq_status
& MII_M1011_IMASK_INIT
))
352 phy_trigger_machine(phydev
);
357 static int marvell_set_polarity(struct phy_device
*phydev
, int polarity
)
363 /* get the current settings */
364 reg
= phy_read(phydev
, MII_M1011_PHY_SCR
);
369 val
&= ~MII_M1011_PHY_SCR_AUTO_CROSS
;
372 val
|= MII_M1011_PHY_SCR_MDI
;
375 val
|= MII_M1011_PHY_SCR_MDI_X
;
377 case ETH_TP_MDI_AUTO
:
378 case ETH_TP_MDI_INVALID
:
380 val
|= MII_M1011_PHY_SCR_AUTO_CROSS
;
385 /* Set the new polarity value in the register */
386 err
= phy_write(phydev
, MII_M1011_PHY_SCR
, val
);
394 static int marvell_config_aneg(struct phy_device
*phydev
)
399 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
405 err
= phy_write(phydev
, MII_M1111_PHY_LED_CONTROL
,
406 MII_M1111_PHY_LED_DIRECT
);
410 err
= genphy_config_aneg(phydev
);
414 if (phydev
->autoneg
!= AUTONEG_ENABLE
|| changed
) {
415 /* A write to speed/duplex bits (that is performed by
416 * genphy_config_aneg() call above) must be followed by
417 * a software reset. Otherwise, the write has no effect.
419 err
= genphy_soft_reset(phydev
);
427 static int m88e1101_config_aneg(struct phy_device
*phydev
)
431 /* This Marvell PHY has an errata which requires
432 * that certain registers get written in order
433 * to restart autonegotiation
435 err
= genphy_soft_reset(phydev
);
439 err
= phy_write(phydev
, 0x1d, 0x1f);
443 err
= phy_write(phydev
, 0x1e, 0x200c);
447 err
= phy_write(phydev
, 0x1d, 0x5);
451 err
= phy_write(phydev
, 0x1e, 0);
455 err
= phy_write(phydev
, 0x1e, 0x100);
459 return marvell_config_aneg(phydev
);
462 #if IS_ENABLED(CONFIG_OF_MDIO)
463 /* Set and/or override some configuration registers based on the
464 * marvell,reg-init property stored in the of_node for the phydev.
466 * marvell,reg-init = <reg-page reg mask value>,...;
468 * There may be one or more sets of <reg-page reg mask value>:
470 * reg-page: which register bank to use.
472 * mask: if non-zero, ANDed with existing register value.
473 * value: ORed with the masked value and written to the regiser.
476 static int marvell_of_reg_init(struct phy_device
*phydev
)
479 int len
, i
, saved_page
, current_page
, ret
= 0;
481 if (!phydev
->mdio
.dev
.of_node
)
484 paddr
= of_get_property(phydev
->mdio
.dev
.of_node
,
485 "marvell,reg-init", &len
);
486 if (!paddr
|| len
< (4 * sizeof(*paddr
)))
489 saved_page
= phy_save_page(phydev
);
492 current_page
= saved_page
;
494 len
/= sizeof(*paddr
);
495 for (i
= 0; i
< len
- 3; i
+= 4) {
496 u16 page
= be32_to_cpup(paddr
+ i
);
497 u16 reg
= be32_to_cpup(paddr
+ i
+ 1);
498 u16 mask
= be32_to_cpup(paddr
+ i
+ 2);
499 u16 val_bits
= be32_to_cpup(paddr
+ i
+ 3);
502 if (page
!= current_page
) {
504 ret
= marvell_write_page(phydev
, page
);
511 val
= __phy_read(phydev
, reg
);
520 ret
= __phy_write(phydev
, reg
, val
);
525 return phy_restore_page(phydev
, saved_page
, ret
);
528 static int marvell_of_reg_init(struct phy_device
*phydev
)
532 #endif /* CONFIG_OF_MDIO */
534 static int m88e1121_config_aneg_rgmii_delays(struct phy_device
*phydev
)
538 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
)
539 mscr
= MII_88E1121_PHY_MSCR_RX_DELAY
|
540 MII_88E1121_PHY_MSCR_TX_DELAY
;
541 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
)
542 mscr
= MII_88E1121_PHY_MSCR_RX_DELAY
;
543 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
)
544 mscr
= MII_88E1121_PHY_MSCR_TX_DELAY
;
548 return phy_modify_paged(phydev
, MII_MARVELL_MSCR_PAGE
,
549 MII_88E1121_PHY_MSCR_REG
,
550 MII_88E1121_PHY_MSCR_DELAY_MASK
, mscr
);
553 static int m88e1121_config_aneg(struct phy_device
*phydev
)
558 if (phy_interface_is_rgmii(phydev
)) {
559 err
= m88e1121_config_aneg_rgmii_delays(phydev
);
564 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
570 err
= genphy_config_aneg(phydev
);
574 if (phydev
->autoneg
!= AUTONEG_ENABLE
|| changed
) {
575 /* A software reset is used to ensure a "commit" of the
578 err
= genphy_soft_reset(phydev
);
586 static int m88e1318_config_aneg(struct phy_device
*phydev
)
590 err
= phy_modify_paged(phydev
, MII_MARVELL_MSCR_PAGE
,
591 MII_88E1318S_PHY_MSCR1_REG
,
592 0, MII_88E1318S_PHY_MSCR1_PAD_ODD
);
596 return m88e1121_config_aneg(phydev
);
600 * linkmode_adv_to_fiber_adv_t
601 * @advertise: the linkmode advertisement settings
603 * A small helper function that translates linkmode advertisement
604 * settings to phy autonegotiation advertisements for the MII_ADV
605 * register for fiber link.
607 static inline u32
linkmode_adv_to_fiber_adv_t(unsigned long *advertise
)
611 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT
, advertise
))
612 result
|= ADVERTISE_1000XHALF
;
613 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT
, advertise
))
614 result
|= ADVERTISE_1000XFULL
;
616 if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT
, advertise
) &&
617 linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT
, advertise
))
618 result
|= ADVERTISE_1000XPSE_ASYM
;
619 else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT
, advertise
))
620 result
|= ADVERTISE_1000XPAUSE
;
626 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
627 * @phydev: target phy_device struct
629 * Description: If auto-negotiation is enabled, we configure the
630 * advertising, and then restart auto-negotiation. If it is not
631 * enabled, then we write the BMCR. Adapted for fiber link in
632 * some Marvell's devices.
634 static int marvell_config_aneg_fiber(struct phy_device
*phydev
)
640 if (phydev
->autoneg
!= AUTONEG_ENABLE
)
641 return genphy_setup_forced(phydev
);
643 /* Only allow advertising what this PHY supports */
644 linkmode_and(phydev
->advertising
, phydev
->advertising
,
647 adv
= linkmode_adv_to_fiber_adv_t(phydev
->advertising
);
649 /* Setup fiber advertisement */
650 err
= phy_modify_changed(phydev
, MII_ADVERTISE
,
651 ADVERTISE_1000XHALF
| ADVERTISE_1000XFULL
|
652 ADVERTISE_1000XPAUSE
| ADVERTISE_1000XPSE_ASYM
,
659 return genphy_check_and_restart_aneg(phydev
, changed
);
662 static int m88e1111_config_aneg(struct phy_device
*phydev
)
664 int extsr
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
670 /* If not using SGMII or copper 1000BaseX modes, use normal process.
671 * Steps below are only required for these modes.
673 if (phydev
->interface
!= PHY_INTERFACE_MODE_SGMII
&&
674 (extsr
& MII_M1111_HWCFG_MODE_MASK
) !=
675 MII_M1111_HWCFG_MODE_COPPER_1000X_AN
)
676 return marvell_config_aneg(phydev
);
678 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
682 /* Configure the copper link first */
683 err
= marvell_config_aneg(phydev
);
687 /* Do not touch the fiber page if we're in copper->sgmii mode */
688 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
)
691 /* Then the fiber link */
692 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
696 err
= marvell_config_aneg_fiber(phydev
);
700 return marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
703 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
707 static int m88e1510_config_aneg(struct phy_device
*phydev
)
711 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
715 /* Configure the copper link first */
716 err
= m88e1318_config_aneg(phydev
);
720 /* Do not touch the fiber page if we're in copper->sgmii mode */
721 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
)
724 /* Then the fiber link */
725 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
729 err
= marvell_config_aneg_fiber(phydev
);
733 return marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
736 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
740 static void marvell_config_led(struct phy_device
*phydev
)
745 switch (MARVELL_PHY_FAMILY_ID(phydev
->phy_id
)) {
746 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
747 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R
):
748 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S
):
749 def_config
= MII_88E1121_PHY_LED_DEF
;
751 /* Default PHY LED config:
752 * LED[0] .. 1000Mbps Link
753 * LED[1] .. 100Mbps Link
754 * LED[2] .. Blink, Activity
756 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510
):
757 if (phydev
->dev_flags
& MARVELL_PHY_LED0_LINK_LED1_ACTIVE
)
758 def_config
= MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE
;
760 def_config
= MII_88E1510_PHY_LED_DEF
;
766 err
= phy_write_paged(phydev
, MII_MARVELL_LED_PAGE
, MII_PHY_LED_CTRL
,
769 phydev_warn(phydev
, "Fail to config marvell phy LED.\n");
772 static int marvell_config_init(struct phy_device
*phydev
)
774 /* Set default LED */
775 marvell_config_led(phydev
);
777 /* Set registers from marvell,reg-init DT property */
778 return marvell_of_reg_init(phydev
);
781 static int m88e3016_config_init(struct phy_device
*phydev
)
785 /* Enable Scrambler and Auto-Crossover */
786 ret
= phy_modify(phydev
, MII_88E3016_PHY_SPEC_CTRL
,
787 MII_88E3016_DISABLE_SCRAMBLER
,
788 MII_88E3016_AUTO_MDIX_CROSSOVER
);
792 return marvell_config_init(phydev
);
795 static int m88e1111_config_init_hwcfg_mode(struct phy_device
*phydev
,
797 int fibre_copper_auto
)
799 if (fibre_copper_auto
)
800 mode
|= MII_M1111_HWCFG_FIBER_COPPER_AUTO
;
802 return phy_modify(phydev
, MII_M1111_PHY_EXT_SR
,
803 MII_M1111_HWCFG_MODE_MASK
|
804 MII_M1111_HWCFG_FIBER_COPPER_AUTO
|
805 MII_M1111_HWCFG_FIBER_COPPER_RES
,
809 static int m88e1111_config_init_rgmii_delays(struct phy_device
*phydev
)
813 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
814 delay
= MII_M1111_RGMII_RX_DELAY
| MII_M1111_RGMII_TX_DELAY
;
815 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
) {
816 delay
= MII_M1111_RGMII_RX_DELAY
;
817 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
) {
818 delay
= MII_M1111_RGMII_TX_DELAY
;
823 return phy_modify(phydev
, MII_M1111_PHY_EXT_CR
,
824 MII_M1111_RGMII_RX_DELAY
| MII_M1111_RGMII_TX_DELAY
,
828 static int m88e1111_config_init_rgmii(struct phy_device
*phydev
)
833 err
= m88e1111_config_init_rgmii_delays(phydev
);
837 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
841 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
);
843 if (temp
& MII_M1111_HWCFG_FIBER_COPPER_RES
)
844 temp
|= MII_M1111_HWCFG_MODE_FIBER_RGMII
;
846 temp
|= MII_M1111_HWCFG_MODE_COPPER_RGMII
;
848 return phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
851 static int m88e1111_config_init_sgmii(struct phy_device
*phydev
)
855 err
= m88e1111_config_init_hwcfg_mode(
857 MII_M1111_HWCFG_MODE_SGMII_NO_CLK
,
858 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
862 /* make sure copper is selected */
863 return marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
866 static int m88e1111_config_init_rtbi(struct phy_device
*phydev
)
870 err
= m88e1111_config_init_rgmii_delays(phydev
);
874 err
= m88e1111_config_init_hwcfg_mode(
876 MII_M1111_HWCFG_MODE_RTBI
,
877 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
882 err
= genphy_soft_reset(phydev
);
886 return m88e1111_config_init_hwcfg_mode(
888 MII_M1111_HWCFG_MODE_RTBI
,
889 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
892 static int m88e1111_config_init_1000basex(struct phy_device
*phydev
)
894 int extsr
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
900 /* If using copper mode, ensure 1000BaseX auto-negotiation is enabled */
901 mode
= extsr
& MII_M1111_HWCFG_MODE_MASK
;
902 if (mode
== MII_M1111_HWCFG_MODE_COPPER_1000X_NOAN
) {
903 err
= phy_modify(phydev
, MII_M1111_PHY_EXT_SR
,
904 MII_M1111_HWCFG_MODE_MASK
|
905 MII_M1111_HWCFG_SERIAL_AN_BYPASS
,
906 MII_M1111_HWCFG_MODE_COPPER_1000X_AN
|
907 MII_M1111_HWCFG_SERIAL_AN_BYPASS
);
914 static int m88e1111_config_init(struct phy_device
*phydev
)
918 if (phy_interface_is_rgmii(phydev
)) {
919 err
= m88e1111_config_init_rgmii(phydev
);
924 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
925 err
= m88e1111_config_init_sgmii(phydev
);
930 if (phydev
->interface
== PHY_INTERFACE_MODE_RTBI
) {
931 err
= m88e1111_config_init_rtbi(phydev
);
936 if (phydev
->interface
== PHY_INTERFACE_MODE_1000BASEX
) {
937 err
= m88e1111_config_init_1000basex(phydev
);
942 err
= marvell_of_reg_init(phydev
);
946 return genphy_soft_reset(phydev
);
949 static int m88e1111_get_downshift(struct phy_device
*phydev
, u8
*data
)
951 int val
, cnt
, enable
;
953 val
= phy_read(phydev
, MII_M1111_PHY_EXT_CR
);
957 enable
= FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
, val
);
958 cnt
= FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
, val
) + 1;
960 *data
= enable
? cnt
: DOWNSHIFT_DEV_DISABLE
;
965 static int m88e1111_set_downshift(struct phy_device
*phydev
, u8 cnt
)
969 if (cnt
> MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX
)
973 return phy_clear_bits(phydev
, MII_M1111_PHY_EXT_CR
,
974 MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
);
976 val
= MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
;
977 val
|= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
, cnt
- 1);
979 return phy_modify(phydev
, MII_M1111_PHY_EXT_CR
,
980 MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
|
981 MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
,
985 static int m88e1111_get_tunable(struct phy_device
*phydev
,
986 struct ethtool_tunable
*tuna
, void *data
)
989 case ETHTOOL_PHY_DOWNSHIFT
:
990 return m88e1111_get_downshift(phydev
, data
);
996 static int m88e1111_set_tunable(struct phy_device
*phydev
,
997 struct ethtool_tunable
*tuna
, const void *data
)
1000 case ETHTOOL_PHY_DOWNSHIFT
:
1001 return m88e1111_set_downshift(phydev
, *(const u8
*)data
);
1007 static int m88e1011_get_downshift(struct phy_device
*phydev
, u8
*data
)
1009 int val
, cnt
, enable
;
1011 val
= phy_read(phydev
, MII_M1011_PHY_SCR
);
1015 enable
= FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN
, val
);
1016 cnt
= FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK
, val
) + 1;
1018 *data
= enable
? cnt
: DOWNSHIFT_DEV_DISABLE
;
1023 static int m88e1011_set_downshift(struct phy_device
*phydev
, u8 cnt
)
1027 if (cnt
> MII_M1011_PHY_SCR_DOWNSHIFT_MAX
)
1031 return phy_clear_bits(phydev
, MII_M1011_PHY_SCR
,
1032 MII_M1011_PHY_SCR_DOWNSHIFT_EN
);
1034 val
= MII_M1011_PHY_SCR_DOWNSHIFT_EN
;
1035 val
|= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK
, cnt
- 1);
1037 return phy_modify(phydev
, MII_M1011_PHY_SCR
,
1038 MII_M1011_PHY_SCR_DOWNSHIFT_EN
|
1039 MII_M1011_PHY_SCR_DOWNSHIFT_MASK
,
1043 static int m88e1011_get_tunable(struct phy_device
*phydev
,
1044 struct ethtool_tunable
*tuna
, void *data
)
1047 case ETHTOOL_PHY_DOWNSHIFT
:
1048 return m88e1011_get_downshift(phydev
, data
);
1054 static int m88e1011_set_tunable(struct phy_device
*phydev
,
1055 struct ethtool_tunable
*tuna
, const void *data
)
1058 case ETHTOOL_PHY_DOWNSHIFT
:
1059 return m88e1011_set_downshift(phydev
, *(const u8
*)data
);
1065 static int m88e1116r_config_init(struct phy_device
*phydev
)
1069 err
= genphy_soft_reset(phydev
);
1075 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1079 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
1083 err
= m88e1011_set_downshift(phydev
, 8);
1087 if (phy_interface_is_rgmii(phydev
)) {
1088 err
= m88e1121_config_aneg_rgmii_delays(phydev
);
1093 err
= genphy_soft_reset(phydev
);
1097 return marvell_config_init(phydev
);
1100 static int m88e1318_config_init(struct phy_device
*phydev
)
1102 if (phy_interrupt_is_valid(phydev
)) {
1103 int err
= phy_modify_paged(
1104 phydev
, MII_MARVELL_LED_PAGE
,
1105 MII_88E1318S_PHY_LED_TCR
,
1106 MII_88E1318S_PHY_LED_TCR_FORCE_INT
,
1107 MII_88E1318S_PHY_LED_TCR_INTn_ENABLE
|
1108 MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW
);
1113 return marvell_config_init(phydev
);
1116 static int m88e1510_config_init(struct phy_device
*phydev
)
1120 /* SGMII-to-Copper mode initialization */
1121 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
1122 /* Select page 18 */
1123 err
= marvell_set_page(phydev
, 18);
1127 /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
1128 err
= phy_modify(phydev
, MII_88E1510_GEN_CTRL_REG_1
,
1129 MII_88E1510_GEN_CTRL_REG_1_MODE_MASK
,
1130 MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII
);
1134 /* PHY reset is necessary after changing MODE[2:0] */
1135 err
= phy_set_bits(phydev
, MII_88E1510_GEN_CTRL_REG_1
,
1136 MII_88E1510_GEN_CTRL_REG_1_RESET
);
1140 /* Reset page selection */
1141 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1146 return m88e1318_config_init(phydev
);
1149 static int m88e1118_config_aneg(struct phy_device
*phydev
)
1153 err
= genphy_soft_reset(phydev
);
1157 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
1161 err
= genphy_config_aneg(phydev
);
1165 static int m88e1118_config_init(struct phy_device
*phydev
)
1169 /* Change address */
1170 err
= marvell_set_page(phydev
, MII_MARVELL_MSCR_PAGE
);
1174 /* Enable 1000 Mbit */
1175 err
= phy_write(phydev
, 0x15, 0x1070);
1179 /* Change address */
1180 err
= marvell_set_page(phydev
, MII_MARVELL_LED_PAGE
);
1184 /* Adjust LED Control */
1185 if (phydev
->dev_flags
& MARVELL_PHY_M1118_DNS323_LEDS
)
1186 err
= phy_write(phydev
, 0x10, 0x1100);
1188 err
= phy_write(phydev
, 0x10, 0x021e);
1192 err
= marvell_of_reg_init(phydev
);
1197 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1201 return genphy_soft_reset(phydev
);
1204 static int m88e1149_config_init(struct phy_device
*phydev
)
1208 /* Change address */
1209 err
= marvell_set_page(phydev
, MII_MARVELL_MSCR_PAGE
);
1213 /* Enable 1000 Mbit */
1214 err
= phy_write(phydev
, 0x15, 0x1048);
1218 err
= marvell_of_reg_init(phydev
);
1223 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1227 return genphy_soft_reset(phydev
);
1230 static int m88e1145_config_init_rgmii(struct phy_device
*phydev
)
1234 err
= m88e1111_config_init_rgmii_delays(phydev
);
1238 if (phydev
->dev_flags
& MARVELL_PHY_M1145_FLAGS_RESISTANCE
) {
1239 err
= phy_write(phydev
, 0x1d, 0x0012);
1243 err
= phy_modify(phydev
, 0x1e, 0x0fc0,
1244 2 << 9 | /* 36 ohm */
1245 2 << 6); /* 39 ohm */
1249 err
= phy_write(phydev
, 0x1d, 0x3);
1253 err
= phy_write(phydev
, 0x1e, 0x8000);
1258 static int m88e1145_config_init_sgmii(struct phy_device
*phydev
)
1260 return m88e1111_config_init_hwcfg_mode(
1261 phydev
, MII_M1111_HWCFG_MODE_SGMII_NO_CLK
,
1262 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
1265 static int m88e1145_config_init(struct phy_device
*phydev
)
1269 /* Take care of errata E0 & E1 */
1270 err
= phy_write(phydev
, 0x1d, 0x001b);
1274 err
= phy_write(phydev
, 0x1e, 0x418f);
1278 err
= phy_write(phydev
, 0x1d, 0x0016);
1282 err
= phy_write(phydev
, 0x1e, 0xa2da);
1286 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
1287 err
= m88e1145_config_init_rgmii(phydev
);
1292 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
1293 err
= m88e1145_config_init_sgmii(phydev
);
1298 err
= marvell_of_reg_init(phydev
);
1305 static int m88e1540_get_fld(struct phy_device
*phydev
, u8
*msecs
)
1309 val
= phy_read(phydev
, MII_88E1540_COPPER_CTRL3
);
1313 if (!(val
& MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
)) {
1314 *msecs
= ETHTOOL_PHY_FAST_LINK_DOWN_OFF
;
1318 val
= FIELD_GET(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1321 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS
:
1324 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS
:
1327 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS
:
1330 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS
:
1340 static int m88e1540_set_fld(struct phy_device
*phydev
, const u8
*msecs
)
1342 struct ethtool_eee eee
;
1345 if (*msecs
== ETHTOOL_PHY_FAST_LINK_DOWN_OFF
)
1346 return phy_clear_bits(phydev
, MII_88E1540_COPPER_CTRL3
,
1347 MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
);
1349 /* According to the Marvell data sheet EEE must be disabled for
1350 * Fast Link Down detection to work properly
1352 ret
= phy_ethtool_get_eee(phydev
, &eee
);
1353 if (!ret
&& eee
.eee_enabled
) {
1354 phydev_warn(phydev
, "Fast Link Down detection requires EEE to be disabled!\n");
1359 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS
;
1360 else if (*msecs
<= 15)
1361 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS
;
1362 else if (*msecs
<= 30)
1363 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS
;
1365 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS
;
1367 val
= FIELD_PREP(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1369 ret
= phy_modify(phydev
, MII_88E1540_COPPER_CTRL3
,
1370 MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1374 return phy_set_bits(phydev
, MII_88E1540_COPPER_CTRL3
,
1375 MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
);
1378 static int m88e1540_get_tunable(struct phy_device
*phydev
,
1379 struct ethtool_tunable
*tuna
, void *data
)
1382 case ETHTOOL_PHY_FAST_LINK_DOWN
:
1383 return m88e1540_get_fld(phydev
, data
);
1384 case ETHTOOL_PHY_DOWNSHIFT
:
1385 return m88e1011_get_downshift(phydev
, data
);
1391 static int m88e1540_set_tunable(struct phy_device
*phydev
,
1392 struct ethtool_tunable
*tuna
, const void *data
)
1395 case ETHTOOL_PHY_FAST_LINK_DOWN
:
1396 return m88e1540_set_fld(phydev
, data
);
1397 case ETHTOOL_PHY_DOWNSHIFT
:
1398 return m88e1011_set_downshift(phydev
, *(const u8
*)data
);
1404 /* The VOD can be out of specification on link up. Poke an
1405 * undocumented register, in an undocumented page, with a magic value
1408 static int m88e6390_errata(struct phy_device
*phydev
)
1412 err
= phy_write(phydev
, MII_BMCR
,
1413 BMCR_ANENABLE
| BMCR_SPEED1000
| BMCR_FULLDPLX
);
1417 usleep_range(300, 400);
1419 err
= phy_write_paged(phydev
, 0xf8, 0x08, 0x36);
1423 return genphy_soft_reset(phydev
);
1426 static int m88e6390_config_aneg(struct phy_device
*phydev
)
1430 err
= m88e6390_errata(phydev
);
1434 return m88e1510_config_aneg(phydev
);
1438 * fiber_lpa_mod_linkmode_lpa_t
1439 * @advertising: the linkmode advertisement settings
1440 * @lpa: value of the MII_LPA register for fiber link
1442 * A small helper function that translates MII_LPA bits to linkmode LP
1443 * advertisement settings. Other bits in advertising are left
1446 static void fiber_lpa_mod_linkmode_lpa_t(unsigned long *advertising
, u32 lpa
)
1448 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT
,
1449 advertising
, lpa
& LPA_1000XHALF
);
1451 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT
,
1452 advertising
, lpa
& LPA_1000XFULL
);
1455 static int marvell_read_status_page_an(struct phy_device
*phydev
,
1456 int fiber
, int status
)
1461 if (!(status
& MII_M1011_PHY_STATUS_RESOLVED
)) {
1466 if (status
& MII_M1011_PHY_STATUS_FULLDUPLEX
)
1467 phydev
->duplex
= DUPLEX_FULL
;
1469 phydev
->duplex
= DUPLEX_HALF
;
1471 switch (status
& MII_M1011_PHY_STATUS_SPD_MASK
) {
1472 case MII_M1011_PHY_STATUS_1000
:
1473 phydev
->speed
= SPEED_1000
;
1476 case MII_M1011_PHY_STATUS_100
:
1477 phydev
->speed
= SPEED_100
;
1481 phydev
->speed
= SPEED_10
;
1486 err
= genphy_read_lpa(phydev
);
1490 phy_resolve_aneg_pause(phydev
);
1492 lpa
= phy_read(phydev
, MII_LPA
);
1496 /* The fiber link is only 1000M capable */
1497 fiber_lpa_mod_linkmode_lpa_t(phydev
->lp_advertising
, lpa
);
1499 if (phydev
->duplex
== DUPLEX_FULL
) {
1500 if (!(lpa
& LPA_PAUSE_FIBER
)) {
1502 phydev
->asym_pause
= 0;
1503 } else if ((lpa
& LPA_PAUSE_ASYM_FIBER
)) {
1505 phydev
->asym_pause
= 1;
1508 phydev
->asym_pause
= 0;
1516 /* marvell_read_status_page
1519 * Check the link, then figure out the current state
1520 * by comparing what we advertise with what the link partner
1521 * advertises. Start by checking the gigabit possibilities,
1522 * then move on to 10/100.
1524 static int marvell_read_status_page(struct phy_device
*phydev
, int page
)
1530 status
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1534 /* Use the generic register for copper link status,
1535 * and the PHY status register for fiber link status.
1537 if (page
== MII_MARVELL_FIBER_PAGE
) {
1538 phydev
->link
= !!(status
& MII_M1011_PHY_STATUS_LINK
);
1540 err
= genphy_update_link(phydev
);
1545 if (page
== MII_MARVELL_FIBER_PAGE
)
1550 linkmode_zero(phydev
->lp_advertising
);
1552 phydev
->asym_pause
= 0;
1553 phydev
->speed
= SPEED_UNKNOWN
;
1554 phydev
->duplex
= DUPLEX_UNKNOWN
;
1556 if (phydev
->autoneg
== AUTONEG_ENABLE
)
1557 err
= marvell_read_status_page_an(phydev
, fiber
, status
);
1559 err
= genphy_read_status_fixed(phydev
);
1564 /* marvell_read_status
1566 * Some Marvell's phys have two modes: fiber and copper.
1567 * Both need status checked.
1569 * First, check the fiber link and status.
1570 * If the fiber link is down, check the copper link and status which
1571 * will be the default value if both link are down.
1573 static int marvell_read_status(struct phy_device
*phydev
)
1577 /* Check the fiber mode first */
1578 if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1579 phydev
->supported
) &&
1580 phydev
->interface
!= PHY_INTERFACE_MODE_SGMII
) {
1581 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1585 err
= marvell_read_status_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1589 /* If the fiber link is up, it is the selected and
1590 * used link. In this case, we need to stay in the
1591 * fiber page. Please to be careful about that, avoid
1592 * to restore Copper page in other functions which
1593 * could break the behaviour for some fiber phy like
1599 /* If fiber link is down, check and save copper mode state */
1600 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1605 return marvell_read_status_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1608 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1614 * Some Marvell's phys have two modes: fiber and copper.
1615 * Both need to be suspended
1617 static int marvell_suspend(struct phy_device
*phydev
)
1621 /* Suspend the fiber mode first */
1622 if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1623 phydev
->supported
)) {
1624 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1628 /* With the page set, use the generic suspend */
1629 err
= genphy_suspend(phydev
);
1633 /* Then, the copper link */
1634 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1639 /* With the page set, use the generic suspend */
1640 return genphy_suspend(phydev
);
1643 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1649 * Some Marvell's phys have two modes: fiber and copper.
1650 * Both need to be resumed
1652 static int marvell_resume(struct phy_device
*phydev
)
1656 /* Resume the fiber mode first */
1657 if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1658 phydev
->supported
)) {
1659 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1663 /* With the page set, use the generic resume */
1664 err
= genphy_resume(phydev
);
1668 /* Then, the copper link */
1669 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1674 /* With the page set, use the generic resume */
1675 return genphy_resume(phydev
);
1678 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1682 static int marvell_aneg_done(struct phy_device
*phydev
)
1684 int retval
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1686 return (retval
< 0) ? retval
: (retval
& MII_M1011_PHY_STATUS_RESOLVED
);
1689 static void m88e1318_get_wol(struct phy_device
*phydev
,
1690 struct ethtool_wolinfo
*wol
)
1694 wol
->supported
= WAKE_MAGIC
;
1697 ret
= phy_read_paged(phydev
, MII_MARVELL_WOL_PAGE
,
1698 MII_88E1318S_PHY_WOL_CTRL
);
1699 if (ret
>= 0 && ret
& MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
)
1700 wol
->wolopts
|= WAKE_MAGIC
;
1703 static int m88e1318_set_wol(struct phy_device
*phydev
,
1704 struct ethtool_wolinfo
*wol
)
1706 int err
= 0, oldpage
;
1708 oldpage
= phy_save_page(phydev
);
1712 if (wol
->wolopts
& WAKE_MAGIC
) {
1713 /* Explicitly switch to page 0x00, just to be sure */
1714 err
= marvell_write_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1718 /* If WOL event happened once, the LED[2] interrupt pin
1719 * will not be cleared unless we reading the interrupt status
1720 * register. If interrupts are in use, the normal interrupt
1721 * handling will clear the WOL event. Clear the WOL event
1722 * before enabling it if !phy_interrupt_is_valid()
1724 if (!phy_interrupt_is_valid(phydev
))
1725 __phy_read(phydev
, MII_M1011_IEVENT
);
1727 /* Enable the WOL interrupt */
1728 err
= __phy_set_bits(phydev
, MII_88E1318S_PHY_CSIER
,
1729 MII_88E1318S_PHY_CSIER_WOL_EIE
);
1733 err
= marvell_write_page(phydev
, MII_MARVELL_LED_PAGE
);
1737 /* Setup LED[2] as interrupt pin (active low) */
1738 err
= __phy_modify(phydev
, MII_88E1318S_PHY_LED_TCR
,
1739 MII_88E1318S_PHY_LED_TCR_FORCE_INT
,
1740 MII_88E1318S_PHY_LED_TCR_INTn_ENABLE
|
1741 MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW
);
1745 err
= marvell_write_page(phydev
, MII_MARVELL_WOL_PAGE
);
1749 /* Store the device address for the magic packet */
1750 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD2
,
1751 ((phydev
->attached_dev
->dev_addr
[5] << 8) |
1752 phydev
->attached_dev
->dev_addr
[4]));
1755 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD1
,
1756 ((phydev
->attached_dev
->dev_addr
[3] << 8) |
1757 phydev
->attached_dev
->dev_addr
[2]));
1760 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD0
,
1761 ((phydev
->attached_dev
->dev_addr
[1] << 8) |
1762 phydev
->attached_dev
->dev_addr
[0]));
1766 /* Clear WOL status and enable magic packet matching */
1767 err
= __phy_set_bits(phydev
, MII_88E1318S_PHY_WOL_CTRL
,
1768 MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
|
1769 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
);
1773 err
= marvell_write_page(phydev
, MII_MARVELL_WOL_PAGE
);
1777 /* Clear WOL status and disable magic packet matching */
1778 err
= __phy_modify(phydev
, MII_88E1318S_PHY_WOL_CTRL
,
1779 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
,
1780 MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
);
1786 return phy_restore_page(phydev
, oldpage
, err
);
1789 static int marvell_get_sset_count(struct phy_device
*phydev
)
1791 if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1793 return ARRAY_SIZE(marvell_hw_stats
);
1795 return ARRAY_SIZE(marvell_hw_stats
) - NB_FIBER_STATS
;
1798 static void marvell_get_strings(struct phy_device
*phydev
, u8
*data
)
1800 int count
= marvell_get_sset_count(phydev
);
1803 for (i
= 0; i
< count
; i
++) {
1804 strlcpy(data
+ i
* ETH_GSTRING_LEN
,
1805 marvell_hw_stats
[i
].string
, ETH_GSTRING_LEN
);
1809 static u64
marvell_get_stat(struct phy_device
*phydev
, int i
)
1811 struct marvell_hw_stat stat
= marvell_hw_stats
[i
];
1812 struct marvell_priv
*priv
= phydev
->priv
;
1816 val
= phy_read_paged(phydev
, stat
.page
, stat
.reg
);
1820 val
= val
& ((1 << stat
.bits
) - 1);
1821 priv
->stats
[i
] += val
;
1822 ret
= priv
->stats
[i
];
1828 static void marvell_get_stats(struct phy_device
*phydev
,
1829 struct ethtool_stats
*stats
, u64
*data
)
1831 int count
= marvell_get_sset_count(phydev
);
1834 for (i
= 0; i
< count
; i
++)
1835 data
[i
] = marvell_get_stat(phydev
, i
);
1838 static int marvell_vct5_wait_complete(struct phy_device
*phydev
)
1843 for (i
= 0; i
< 32; i
++) {
1844 val
= __phy_read(phydev
, MII_VCT5_CTRL
);
1848 if (val
& MII_VCT5_CTRL_COMPLETE
)
1852 phydev_err(phydev
, "Timeout while waiting for cable test to finish\n");
1856 static int marvell_vct5_amplitude(struct phy_device
*phydev
, int pair
)
1862 reg
= MII_VCT5_TX_RX_MDI0_COUPLING
+ pair
;
1863 val
= __phy_read(phydev
, reg
);
1868 amplitude
= (val
& MII_VCT5_TX_RX_AMPLITUDE_MASK
) >>
1869 MII_VCT5_TX_RX_AMPLITUDE_SHIFT
;
1871 if (!(val
& MII_VCT5_TX_RX_COUPLING_POSITIVE_REFLECTION
))
1872 amplitude
= -amplitude
;
1874 return 1000 * amplitude
/ 128;
1877 static u32
marvell_vct5_distance2cm(int distance
)
1879 return distance
* 805 / 10;
1882 static u32
marvell_vct5_cm2distance(int cm
)
1884 return cm
* 10 / 805;
1887 static int marvell_vct5_amplitude_distance(struct phy_device
*phydev
,
1888 int distance
, int pair
)
1895 err
= __phy_write(phydev
, MII_VCT5_SAMPLE_POINT_DISTANCE
,
1900 reg
= MII_VCT5_CTRL_ENABLE
|
1901 MII_VCT5_CTRL_TX_SAME_CHANNEL
|
1902 MII_VCT5_CTRL_SAMPLES_DEFAULT
|
1903 MII_VCT5_CTRL_SAMPLE_POINT
|
1904 MII_VCT5_CTRL_PEEK_HYST_DEFAULT
;
1905 err
= __phy_write(phydev
, MII_VCT5_CTRL
, reg
);
1909 err
= marvell_vct5_wait_complete(phydev
);
1913 for (i
= 0; i
< 4; i
++) {
1914 if (pair
!= PHY_PAIR_ALL
&& i
!= pair
)
1917 mV
= marvell_vct5_amplitude(phydev
, i
);
1918 ethnl_cable_test_amplitude(phydev
, i
, mV
);
1924 static int marvell_vct5_amplitude_graph(struct phy_device
*phydev
)
1926 struct marvell_priv
*priv
= phydev
->priv
;
1933 if (priv
->first
<= TDR_SHORT_CABLE_LENGTH
)
1934 width
= MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS
;
1936 width
= MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS
;
1938 reg
= MII_VCT5_TX_PULSE_CTRL_GT_140m_46_86mV
|
1939 MII_VCT5_TX_PULSE_CTRL_DONT_WAIT_LINK_DOWN
|
1940 MII_VCT5_TX_PULSE_CTRL_MAX_AMP
| width
;
1942 err
= phy_write_paged(phydev
, MII_MARVELL_VCT5_PAGE
,
1943 MII_VCT5_TX_PULSE_CTRL
, reg
);
1947 /* Reading the TDR data is very MDIO heavy. We need to optimize
1948 * access to keep the time to a minimum. So lock the bus once,
1949 * and don't release it until complete. We can then avoid having
1950 * to change the page for every access, greatly speeding things
1953 page
= phy_select_page(phydev
, MII_MARVELL_VCT5_PAGE
);
1957 for (distance
= priv
->first
;
1958 distance
<= priv
->last
;
1959 distance
+= priv
->step
) {
1960 err
= marvell_vct5_amplitude_distance(phydev
, distance
,
1965 if (distance
> TDR_SHORT_CABLE_LENGTH
&&
1966 width
== MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_32nS
) {
1967 width
= MII_VCT5_TX_PULSE_CTRL_PULSE_WIDTH_128nS
;
1968 reg
= MII_VCT5_TX_PULSE_CTRL_GT_140m_46_86mV
|
1969 MII_VCT5_TX_PULSE_CTRL_DONT_WAIT_LINK_DOWN
|
1970 MII_VCT5_TX_PULSE_CTRL_MAX_AMP
| width
;
1971 err
= __phy_write(phydev
, MII_VCT5_TX_PULSE_CTRL
, reg
);
1978 return phy_restore_page(phydev
, page
, err
);
1981 static int marvell_cable_test_start_common(struct phy_device
*phydev
)
1983 int bmcr
, bmsr
, ret
;
1985 /* If auto-negotiation is enabled, but not complete, the cable
1986 * test never completes. So disable auto-neg.
1988 bmcr
= phy_read(phydev
, MII_BMCR
);
1992 bmsr
= phy_read(phydev
, MII_BMSR
);
1997 if (bmcr
& BMCR_ANENABLE
) {
1998 ret
= phy_clear_bits(phydev
, MII_BMCR
, BMCR_ANENABLE
);
2001 ret
= genphy_soft_reset(phydev
);
2006 /* If the link is up, allow it some time to go down */
2007 if (bmsr
& BMSR_LSTATUS
)
2013 static int marvell_vct7_cable_test_start(struct phy_device
*phydev
)
2015 struct marvell_priv
*priv
= phydev
->priv
;
2018 ret
= marvell_cable_test_start_common(phydev
);
2022 priv
->cable_test_tdr
= false;
2024 /* Reset the VCT5 API control to defaults, otherwise
2025 * VCT7 does not work correctly.
2027 ret
= phy_write_paged(phydev
, MII_MARVELL_VCT5_PAGE
,
2029 MII_VCT5_CTRL_TX_SAME_CHANNEL
|
2030 MII_VCT5_CTRL_SAMPLES_DEFAULT
|
2031 MII_VCT5_CTRL_MODE_MAXIMUM_PEEK
|
2032 MII_VCT5_CTRL_PEEK_HYST_DEFAULT
);
2036 ret
= phy_write_paged(phydev
, MII_MARVELL_VCT5_PAGE
,
2037 MII_VCT5_SAMPLE_POINT_DISTANCE
, 0);
2041 return phy_write_paged(phydev
, MII_MARVELL_VCT7_PAGE
,
2043 MII_VCT7_CTRL_RUN_NOW
|
2044 MII_VCT7_CTRL_CENTIMETERS
);
2047 static int marvell_vct5_cable_test_tdr_start(struct phy_device
*phydev
,
2048 const struct phy_tdr_config
*cfg
)
2050 struct marvell_priv
*priv
= phydev
->priv
;
2053 priv
->cable_test_tdr
= true;
2054 priv
->first
= marvell_vct5_cm2distance(cfg
->first
);
2055 priv
->last
= marvell_vct5_cm2distance(cfg
->last
);
2056 priv
->step
= marvell_vct5_cm2distance(cfg
->step
);
2057 priv
->pair
= cfg
->pair
;
2059 if (priv
->first
> MII_VCT5_SAMPLE_POINT_DISTANCE_MAX
)
2062 if (priv
->last
> MII_VCT5_SAMPLE_POINT_DISTANCE_MAX
)
2066 ret
= phy_write_paged(phydev
, MII_MARVELL_VCT7_PAGE
,
2071 ret
= marvell_cable_test_start_common(phydev
);
2075 ret
= ethnl_cable_test_pulse(phydev
, 1000);
2079 return ethnl_cable_test_step(phydev
,
2080 marvell_vct5_distance2cm(priv
->first
),
2081 marvell_vct5_distance2cm(priv
->last
),
2082 marvell_vct5_distance2cm(priv
->step
));
2085 static int marvell_vct7_distance_to_length(int distance
, bool meter
)
2093 static bool marvell_vct7_distance_valid(int result
)
2096 case MII_VCT7_RESULTS_OPEN
:
2097 case MII_VCT7_RESULTS_SAME_SHORT
:
2098 case MII_VCT7_RESULTS_CROSS_SHORT
:
2104 static int marvell_vct7_report_length(struct phy_device
*phydev
,
2105 int pair
, bool meter
)
2110 ret
= phy_read_paged(phydev
, MII_MARVELL_VCT7_PAGE
,
2111 MII_VCT7_PAIR_0_DISTANCE
+ pair
);
2115 length
= marvell_vct7_distance_to_length(ret
, meter
);
2117 ethnl_cable_test_fault_length(phydev
, pair
, length
);
2122 static int marvell_vct7_cable_test_report_trans(int result
)
2125 case MII_VCT7_RESULTS_OK
:
2126 return ETHTOOL_A_CABLE_RESULT_CODE_OK
;
2127 case MII_VCT7_RESULTS_OPEN
:
2128 return ETHTOOL_A_CABLE_RESULT_CODE_OPEN
;
2129 case MII_VCT7_RESULTS_SAME_SHORT
:
2130 return ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT
;
2131 case MII_VCT7_RESULTS_CROSS_SHORT
:
2132 return ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT
;
2134 return ETHTOOL_A_CABLE_RESULT_CODE_UNSPEC
;
2138 static int marvell_vct7_cable_test_report(struct phy_device
*phydev
)
2140 int pair0
, pair1
, pair2
, pair3
;
2144 ret
= phy_read_paged(phydev
, MII_MARVELL_VCT7_PAGE
,
2149 pair3
= (ret
& MII_VCT7_RESULTS_PAIR3_MASK
) >>
2150 MII_VCT7_RESULTS_PAIR3_SHIFT
;
2151 pair2
= (ret
& MII_VCT7_RESULTS_PAIR2_MASK
) >>
2152 MII_VCT7_RESULTS_PAIR2_SHIFT
;
2153 pair1
= (ret
& MII_VCT7_RESULTS_PAIR1_MASK
) >>
2154 MII_VCT7_RESULTS_PAIR1_SHIFT
;
2155 pair0
= (ret
& MII_VCT7_RESULTS_PAIR0_MASK
) >>
2156 MII_VCT7_RESULTS_PAIR0_SHIFT
;
2158 ethnl_cable_test_result(phydev
, ETHTOOL_A_CABLE_PAIR_A
,
2159 marvell_vct7_cable_test_report_trans(pair0
));
2160 ethnl_cable_test_result(phydev
, ETHTOOL_A_CABLE_PAIR_B
,
2161 marvell_vct7_cable_test_report_trans(pair1
));
2162 ethnl_cable_test_result(phydev
, ETHTOOL_A_CABLE_PAIR_C
,
2163 marvell_vct7_cable_test_report_trans(pair2
));
2164 ethnl_cable_test_result(phydev
, ETHTOOL_A_CABLE_PAIR_D
,
2165 marvell_vct7_cable_test_report_trans(pair3
));
2167 ret
= phy_read_paged(phydev
, MII_MARVELL_VCT7_PAGE
, MII_VCT7_CTRL
);
2171 meter
= ret
& MII_VCT7_CTRL_METERS
;
2173 if (marvell_vct7_distance_valid(pair0
))
2174 marvell_vct7_report_length(phydev
, 0, meter
);
2175 if (marvell_vct7_distance_valid(pair1
))
2176 marvell_vct7_report_length(phydev
, 1, meter
);
2177 if (marvell_vct7_distance_valid(pair2
))
2178 marvell_vct7_report_length(phydev
, 2, meter
);
2179 if (marvell_vct7_distance_valid(pair3
))
2180 marvell_vct7_report_length(phydev
, 3, meter
);
2185 static int marvell_vct7_cable_test_get_status(struct phy_device
*phydev
,
2188 struct marvell_priv
*priv
= phydev
->priv
;
2191 if (priv
->cable_test_tdr
) {
2192 ret
= marvell_vct5_amplitude_graph(phydev
);
2199 ret
= phy_read_paged(phydev
, MII_MARVELL_VCT7_PAGE
,
2205 if (!(ret
& MII_VCT7_CTRL_IN_PROGRESS
)) {
2208 return marvell_vct7_cable_test_report(phydev
);
2215 static int m88e1121_get_temp(struct phy_device
*phydev
, long *temp
)
2223 oldpage
= phy_select_page(phydev
, MII_MARVELL_MISC_TEST_PAGE
);
2227 /* Enable temperature sensor */
2228 ret
= __phy_read(phydev
, MII_88E1121_MISC_TEST
);
2232 ret
= __phy_write(phydev
, MII_88E1121_MISC_TEST
,
2233 ret
| MII_88E1121_MISC_TEST_TEMP_SENSOR_EN
);
2237 /* Wait for temperature to stabilize */
2238 usleep_range(10000, 12000);
2240 val
= __phy_read(phydev
, MII_88E1121_MISC_TEST
);
2246 /* Disable temperature sensor */
2247 ret
= __phy_write(phydev
, MII_88E1121_MISC_TEST
,
2248 ret
& ~MII_88E1121_MISC_TEST_TEMP_SENSOR_EN
);
2252 *temp
= ((val
& MII_88E1121_MISC_TEST_TEMP_MASK
) - 5) * 5000;
2255 return phy_restore_page(phydev
, oldpage
, ret
);
2258 static int m88e1121_hwmon_read(struct device
*dev
,
2259 enum hwmon_sensor_types type
,
2260 u32 attr
, int channel
, long *temp
)
2262 struct phy_device
*phydev
= dev_get_drvdata(dev
);
2266 case hwmon_temp_input
:
2267 err
= m88e1121_get_temp(phydev
, temp
);
2276 static umode_t
m88e1121_hwmon_is_visible(const void *data
,
2277 enum hwmon_sensor_types type
,
2278 u32 attr
, int channel
)
2280 if (type
!= hwmon_temp
)
2284 case hwmon_temp_input
:
2291 static u32 m88e1121_hwmon_chip_config
[] = {
2292 HWMON_C_REGISTER_TZ
,
2296 static const struct hwmon_channel_info m88e1121_hwmon_chip
= {
2298 .config
= m88e1121_hwmon_chip_config
,
2301 static u32 m88e1121_hwmon_temp_config
[] = {
2306 static const struct hwmon_channel_info m88e1121_hwmon_temp
= {
2308 .config
= m88e1121_hwmon_temp_config
,
2311 static const struct hwmon_channel_info
*m88e1121_hwmon_info
[] = {
2312 &m88e1121_hwmon_chip
,
2313 &m88e1121_hwmon_temp
,
2317 static const struct hwmon_ops m88e1121_hwmon_hwmon_ops
= {
2318 .is_visible
= m88e1121_hwmon_is_visible
,
2319 .read
= m88e1121_hwmon_read
,
2322 static const struct hwmon_chip_info m88e1121_hwmon_chip_info
= {
2323 .ops
= &m88e1121_hwmon_hwmon_ops
,
2324 .info
= m88e1121_hwmon_info
,
2327 static int m88e1510_get_temp(struct phy_device
*phydev
, long *temp
)
2333 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
2334 MII_88E1510_TEMP_SENSOR
);
2338 *temp
= ((ret
& MII_88E1510_TEMP_SENSOR_MASK
) - 25) * 1000;
2343 static int m88e1510_get_temp_critical(struct phy_device
*phydev
, long *temp
)
2349 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
2350 MII_88E1121_MISC_TEST
);
2354 *temp
= (((ret
& MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK
) >>
2355 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT
) * 5) - 25;
2362 static int m88e1510_set_temp_critical(struct phy_device
*phydev
, long temp
)
2365 temp
= clamp_val(DIV_ROUND_CLOSEST(temp
, 5) + 5, 0, 0x1f);
2367 return phy_modify_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
2368 MII_88E1121_MISC_TEST
,
2369 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK
,
2370 temp
<< MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT
);
2373 static int m88e1510_get_temp_alarm(struct phy_device
*phydev
, long *alarm
)
2379 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
2380 MII_88E1121_MISC_TEST
);
2384 *alarm
= !!(ret
& MII_88E1510_MISC_TEST_TEMP_IRQ
);
2389 static int m88e1510_hwmon_read(struct device
*dev
,
2390 enum hwmon_sensor_types type
,
2391 u32 attr
, int channel
, long *temp
)
2393 struct phy_device
*phydev
= dev_get_drvdata(dev
);
2397 case hwmon_temp_input
:
2398 err
= m88e1510_get_temp(phydev
, temp
);
2400 case hwmon_temp_crit
:
2401 err
= m88e1510_get_temp_critical(phydev
, temp
);
2403 case hwmon_temp_max_alarm
:
2404 err
= m88e1510_get_temp_alarm(phydev
, temp
);
2413 static int m88e1510_hwmon_write(struct device
*dev
,
2414 enum hwmon_sensor_types type
,
2415 u32 attr
, int channel
, long temp
)
2417 struct phy_device
*phydev
= dev_get_drvdata(dev
);
2421 case hwmon_temp_crit
:
2422 err
= m88e1510_set_temp_critical(phydev
, temp
);
2430 static umode_t
m88e1510_hwmon_is_visible(const void *data
,
2431 enum hwmon_sensor_types type
,
2432 u32 attr
, int channel
)
2434 if (type
!= hwmon_temp
)
2438 case hwmon_temp_input
:
2439 case hwmon_temp_max_alarm
:
2441 case hwmon_temp_crit
:
2448 static u32 m88e1510_hwmon_temp_config
[] = {
2449 HWMON_T_INPUT
| HWMON_T_CRIT
| HWMON_T_MAX_ALARM
,
2453 static const struct hwmon_channel_info m88e1510_hwmon_temp
= {
2455 .config
= m88e1510_hwmon_temp_config
,
2458 static const struct hwmon_channel_info
*m88e1510_hwmon_info
[] = {
2459 &m88e1121_hwmon_chip
,
2460 &m88e1510_hwmon_temp
,
2464 static const struct hwmon_ops m88e1510_hwmon_hwmon_ops
= {
2465 .is_visible
= m88e1510_hwmon_is_visible
,
2466 .read
= m88e1510_hwmon_read
,
2467 .write
= m88e1510_hwmon_write
,
2470 static const struct hwmon_chip_info m88e1510_hwmon_chip_info
= {
2471 .ops
= &m88e1510_hwmon_hwmon_ops
,
2472 .info
= m88e1510_hwmon_info
,
2475 static int m88e6390_get_temp(struct phy_device
*phydev
, long *temp
)
2484 oldpage
= phy_select_page(phydev
, MII_MARVELL_MISC_TEST_PAGE
);
2488 /* Enable temperature sensor */
2489 ret
= __phy_read(phydev
, MII_88E6390_MISC_TEST
);
2493 ret
= ret
& ~MII_88E6390_MISC_TEST_SAMPLE_MASK
;
2494 ret
|= MII_88E6390_MISC_TEST_SAMPLE_ENABLE
|
2495 MII_88E6390_MISC_TEST_SAMPLE_1S
;
2497 ret
= __phy_write(phydev
, MII_88E6390_MISC_TEST
, ret
);
2501 /* Wait for temperature to stabilize */
2502 usleep_range(10000, 12000);
2504 /* Reading the temperature sense has an errata. You need to read
2505 * a number of times and take an average.
2507 for (i
= 0; i
< MII_88E6390_TEMP_SENSOR_SAMPLES
; i
++) {
2508 ret
= __phy_read(phydev
, MII_88E6390_TEMP_SENSOR
);
2511 sum
+= ret
& MII_88E6390_TEMP_SENSOR_MASK
;
2514 sum
/= MII_88E6390_TEMP_SENSOR_SAMPLES
;
2515 *temp
= (sum
- 75) * 1000;
2517 /* Disable temperature sensor */
2518 ret
= __phy_read(phydev
, MII_88E6390_MISC_TEST
);
2522 ret
= ret
& ~MII_88E6390_MISC_TEST_SAMPLE_MASK
;
2523 ret
|= MII_88E6390_MISC_TEST_SAMPLE_DISABLE
;
2525 ret
= __phy_write(phydev
, MII_88E6390_MISC_TEST
, ret
);
2528 phy_restore_page(phydev
, oldpage
, ret
);
2533 static int m88e6390_hwmon_read(struct device
*dev
,
2534 enum hwmon_sensor_types type
,
2535 u32 attr
, int channel
, long *temp
)
2537 struct phy_device
*phydev
= dev_get_drvdata(dev
);
2541 case hwmon_temp_input
:
2542 err
= m88e6390_get_temp(phydev
, temp
);
2551 static umode_t
m88e6390_hwmon_is_visible(const void *data
,
2552 enum hwmon_sensor_types type
,
2553 u32 attr
, int channel
)
2555 if (type
!= hwmon_temp
)
2559 case hwmon_temp_input
:
2566 static u32 m88e6390_hwmon_temp_config
[] = {
2571 static const struct hwmon_channel_info m88e6390_hwmon_temp
= {
2573 .config
= m88e6390_hwmon_temp_config
,
2576 static const struct hwmon_channel_info
*m88e6390_hwmon_info
[] = {
2577 &m88e1121_hwmon_chip
,
2578 &m88e6390_hwmon_temp
,
2582 static const struct hwmon_ops m88e6390_hwmon_hwmon_ops
= {
2583 .is_visible
= m88e6390_hwmon_is_visible
,
2584 .read
= m88e6390_hwmon_read
,
2587 static const struct hwmon_chip_info m88e6390_hwmon_chip_info
= {
2588 .ops
= &m88e6390_hwmon_hwmon_ops
,
2589 .info
= m88e6390_hwmon_info
,
2592 static int marvell_hwmon_name(struct phy_device
*phydev
)
2594 struct marvell_priv
*priv
= phydev
->priv
;
2595 struct device
*dev
= &phydev
->mdio
.dev
;
2596 const char *devname
= dev_name(dev
);
2597 size_t len
= strlen(devname
);
2600 priv
->hwmon_name
= devm_kzalloc(dev
, len
, GFP_KERNEL
);
2601 if (!priv
->hwmon_name
)
2604 for (i
= j
= 0; i
< len
&& devname
[i
]; i
++) {
2605 if (isalnum(devname
[i
]))
2606 priv
->hwmon_name
[j
++] = devname
[i
];
2612 static int marvell_hwmon_probe(struct phy_device
*phydev
,
2613 const struct hwmon_chip_info
*chip
)
2615 struct marvell_priv
*priv
= phydev
->priv
;
2616 struct device
*dev
= &phydev
->mdio
.dev
;
2619 err
= marvell_hwmon_name(phydev
);
2623 priv
->hwmon_dev
= devm_hwmon_device_register_with_info(
2624 dev
, priv
->hwmon_name
, phydev
, chip
, NULL
);
2626 return PTR_ERR_OR_ZERO(priv
->hwmon_dev
);
2629 static int m88e1121_hwmon_probe(struct phy_device
*phydev
)
2631 return marvell_hwmon_probe(phydev
, &m88e1121_hwmon_chip_info
);
2634 static int m88e1510_hwmon_probe(struct phy_device
*phydev
)
2636 return marvell_hwmon_probe(phydev
, &m88e1510_hwmon_chip_info
);
2639 static int m88e6390_hwmon_probe(struct phy_device
*phydev
)
2641 return marvell_hwmon_probe(phydev
, &m88e6390_hwmon_chip_info
);
2644 static int m88e1121_hwmon_probe(struct phy_device
*phydev
)
2649 static int m88e1510_hwmon_probe(struct phy_device
*phydev
)
2654 static int m88e6390_hwmon_probe(struct phy_device
*phydev
)
2660 static int marvell_probe(struct phy_device
*phydev
)
2662 struct marvell_priv
*priv
;
2664 priv
= devm_kzalloc(&phydev
->mdio
.dev
, sizeof(*priv
), GFP_KERNEL
);
2668 phydev
->priv
= priv
;
2673 static int m88e1121_probe(struct phy_device
*phydev
)
2677 err
= marvell_probe(phydev
);
2681 return m88e1121_hwmon_probe(phydev
);
2684 static int m88e1510_probe(struct phy_device
*phydev
)
2688 err
= marvell_probe(phydev
);
2692 return m88e1510_hwmon_probe(phydev
);
2695 static int m88e6390_probe(struct phy_device
*phydev
)
2699 err
= marvell_probe(phydev
);
2703 return m88e6390_hwmon_probe(phydev
);
2706 static struct phy_driver marvell_drivers
[] = {
2708 .phy_id
= MARVELL_PHY_ID_88E1101
,
2709 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2710 .name
= "Marvell 88E1101",
2711 /* PHY_GBIT_FEATURES */
2712 .probe
= marvell_probe
,
2713 .config_init
= marvell_config_init
,
2714 .config_aneg
= m88e1101_config_aneg
,
2715 .config_intr
= marvell_config_intr
,
2716 .handle_interrupt
= marvell_handle_interrupt
,
2717 .resume
= genphy_resume
,
2718 .suspend
= genphy_suspend
,
2719 .read_page
= marvell_read_page
,
2720 .write_page
= marvell_write_page
,
2721 .get_sset_count
= marvell_get_sset_count
,
2722 .get_strings
= marvell_get_strings
,
2723 .get_stats
= marvell_get_stats
,
2726 .phy_id
= MARVELL_PHY_ID_88E1112
,
2727 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2728 .name
= "Marvell 88E1112",
2729 /* PHY_GBIT_FEATURES */
2730 .probe
= marvell_probe
,
2731 .config_init
= m88e1111_config_init
,
2732 .config_aneg
= marvell_config_aneg
,
2733 .config_intr
= marvell_config_intr
,
2734 .handle_interrupt
= marvell_handle_interrupt
,
2735 .resume
= genphy_resume
,
2736 .suspend
= genphy_suspend
,
2737 .read_page
= marvell_read_page
,
2738 .write_page
= marvell_write_page
,
2739 .get_sset_count
= marvell_get_sset_count
,
2740 .get_strings
= marvell_get_strings
,
2741 .get_stats
= marvell_get_stats
,
2742 .get_tunable
= m88e1011_get_tunable
,
2743 .set_tunable
= m88e1011_set_tunable
,
2746 .phy_id
= MARVELL_PHY_ID_88E1111
,
2747 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2748 .name
= "Marvell 88E1111",
2749 /* PHY_GBIT_FEATURES */
2750 .probe
= marvell_probe
,
2751 .config_init
= m88e1111_config_init
,
2752 .config_aneg
= m88e1111_config_aneg
,
2753 .read_status
= marvell_read_status
,
2754 .config_intr
= marvell_config_intr
,
2755 .handle_interrupt
= marvell_handle_interrupt
,
2756 .resume
= genphy_resume
,
2757 .suspend
= genphy_suspend
,
2758 .read_page
= marvell_read_page
,
2759 .write_page
= marvell_write_page
,
2760 .get_sset_count
= marvell_get_sset_count
,
2761 .get_strings
= marvell_get_strings
,
2762 .get_stats
= marvell_get_stats
,
2763 .get_tunable
= m88e1111_get_tunable
,
2764 .set_tunable
= m88e1111_set_tunable
,
2767 .phy_id
= MARVELL_PHY_ID_88E1111_FINISAR
,
2768 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2769 .name
= "Marvell 88E1111 (Finisar)",
2770 /* PHY_GBIT_FEATURES */
2771 .probe
= marvell_probe
,
2772 .config_init
= m88e1111_config_init
,
2773 .config_aneg
= m88e1111_config_aneg
,
2774 .read_status
= marvell_read_status
,
2775 .config_intr
= marvell_config_intr
,
2776 .handle_interrupt
= marvell_handle_interrupt
,
2777 .resume
= genphy_resume
,
2778 .suspend
= genphy_suspend
,
2779 .read_page
= marvell_read_page
,
2780 .write_page
= marvell_write_page
,
2781 .get_sset_count
= marvell_get_sset_count
,
2782 .get_strings
= marvell_get_strings
,
2783 .get_stats
= marvell_get_stats
,
2784 .get_tunable
= m88e1111_get_tunable
,
2785 .set_tunable
= m88e1111_set_tunable
,
2788 .phy_id
= MARVELL_PHY_ID_88E1118
,
2789 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2790 .name
= "Marvell 88E1118",
2791 /* PHY_GBIT_FEATURES */
2792 .probe
= marvell_probe
,
2793 .config_init
= m88e1118_config_init
,
2794 .config_aneg
= m88e1118_config_aneg
,
2795 .config_intr
= marvell_config_intr
,
2796 .handle_interrupt
= marvell_handle_interrupt
,
2797 .resume
= genphy_resume
,
2798 .suspend
= genphy_suspend
,
2799 .read_page
= marvell_read_page
,
2800 .write_page
= marvell_write_page
,
2801 .get_sset_count
= marvell_get_sset_count
,
2802 .get_strings
= marvell_get_strings
,
2803 .get_stats
= marvell_get_stats
,
2806 .phy_id
= MARVELL_PHY_ID_88E1121R
,
2807 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2808 .name
= "Marvell 88E1121R",
2809 /* PHY_GBIT_FEATURES */
2810 .probe
= m88e1121_probe
,
2811 .config_init
= marvell_config_init
,
2812 .config_aneg
= m88e1121_config_aneg
,
2813 .read_status
= marvell_read_status
,
2814 .config_intr
= marvell_config_intr
,
2815 .handle_interrupt
= marvell_handle_interrupt
,
2816 .resume
= genphy_resume
,
2817 .suspend
= genphy_suspend
,
2818 .read_page
= marvell_read_page
,
2819 .write_page
= marvell_write_page
,
2820 .get_sset_count
= marvell_get_sset_count
,
2821 .get_strings
= marvell_get_strings
,
2822 .get_stats
= marvell_get_stats
,
2823 .get_tunable
= m88e1011_get_tunable
,
2824 .set_tunable
= m88e1011_set_tunable
,
2827 .phy_id
= MARVELL_PHY_ID_88E1318S
,
2828 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2829 .name
= "Marvell 88E1318S",
2830 /* PHY_GBIT_FEATURES */
2831 .probe
= marvell_probe
,
2832 .config_init
= m88e1318_config_init
,
2833 .config_aneg
= m88e1318_config_aneg
,
2834 .read_status
= marvell_read_status
,
2835 .config_intr
= marvell_config_intr
,
2836 .handle_interrupt
= marvell_handle_interrupt
,
2837 .get_wol
= m88e1318_get_wol
,
2838 .set_wol
= m88e1318_set_wol
,
2839 .resume
= genphy_resume
,
2840 .suspend
= genphy_suspend
,
2841 .read_page
= marvell_read_page
,
2842 .write_page
= marvell_write_page
,
2843 .get_sset_count
= marvell_get_sset_count
,
2844 .get_strings
= marvell_get_strings
,
2845 .get_stats
= marvell_get_stats
,
2848 .phy_id
= MARVELL_PHY_ID_88E1145
,
2849 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2850 .name
= "Marvell 88E1145",
2851 /* PHY_GBIT_FEATURES */
2852 .probe
= marvell_probe
,
2853 .config_init
= m88e1145_config_init
,
2854 .config_aneg
= m88e1101_config_aneg
,
2855 .read_status
= genphy_read_status
,
2856 .config_intr
= marvell_config_intr
,
2857 .handle_interrupt
= marvell_handle_interrupt
,
2858 .resume
= genphy_resume
,
2859 .suspend
= genphy_suspend
,
2860 .read_page
= marvell_read_page
,
2861 .write_page
= marvell_write_page
,
2862 .get_sset_count
= marvell_get_sset_count
,
2863 .get_strings
= marvell_get_strings
,
2864 .get_stats
= marvell_get_stats
,
2865 .get_tunable
= m88e1111_get_tunable
,
2866 .set_tunable
= m88e1111_set_tunable
,
2869 .phy_id
= MARVELL_PHY_ID_88E1149R
,
2870 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2871 .name
= "Marvell 88E1149R",
2872 /* PHY_GBIT_FEATURES */
2873 .probe
= marvell_probe
,
2874 .config_init
= m88e1149_config_init
,
2875 .config_aneg
= m88e1118_config_aneg
,
2876 .config_intr
= marvell_config_intr
,
2877 .handle_interrupt
= marvell_handle_interrupt
,
2878 .resume
= genphy_resume
,
2879 .suspend
= genphy_suspend
,
2880 .read_page
= marvell_read_page
,
2881 .write_page
= marvell_write_page
,
2882 .get_sset_count
= marvell_get_sset_count
,
2883 .get_strings
= marvell_get_strings
,
2884 .get_stats
= marvell_get_stats
,
2887 .phy_id
= MARVELL_PHY_ID_88E1240
,
2888 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2889 .name
= "Marvell 88E1240",
2890 /* PHY_GBIT_FEATURES */
2891 .probe
= marvell_probe
,
2892 .config_init
= m88e1111_config_init
,
2893 .config_aneg
= marvell_config_aneg
,
2894 .config_intr
= marvell_config_intr
,
2895 .handle_interrupt
= marvell_handle_interrupt
,
2896 .resume
= genphy_resume
,
2897 .suspend
= genphy_suspend
,
2898 .read_page
= marvell_read_page
,
2899 .write_page
= marvell_write_page
,
2900 .get_sset_count
= marvell_get_sset_count
,
2901 .get_strings
= marvell_get_strings
,
2902 .get_stats
= marvell_get_stats
,
2905 .phy_id
= MARVELL_PHY_ID_88E1116R
,
2906 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2907 .name
= "Marvell 88E1116R",
2908 /* PHY_GBIT_FEATURES */
2909 .probe
= marvell_probe
,
2910 .config_init
= m88e1116r_config_init
,
2911 .config_intr
= marvell_config_intr
,
2912 .handle_interrupt
= marvell_handle_interrupt
,
2913 .resume
= genphy_resume
,
2914 .suspend
= genphy_suspend
,
2915 .read_page
= marvell_read_page
,
2916 .write_page
= marvell_write_page
,
2917 .get_sset_count
= marvell_get_sset_count
,
2918 .get_strings
= marvell_get_strings
,
2919 .get_stats
= marvell_get_stats
,
2920 .get_tunable
= m88e1011_get_tunable
,
2921 .set_tunable
= m88e1011_set_tunable
,
2924 .phy_id
= MARVELL_PHY_ID_88E1510
,
2925 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2926 .name
= "Marvell 88E1510",
2927 .features
= PHY_GBIT_FIBRE_FEATURES
,
2928 .flags
= PHY_POLL_CABLE_TEST
,
2929 .probe
= m88e1510_probe
,
2930 .config_init
= m88e1510_config_init
,
2931 .config_aneg
= m88e1510_config_aneg
,
2932 .read_status
= marvell_read_status
,
2933 .config_intr
= marvell_config_intr
,
2934 .handle_interrupt
= marvell_handle_interrupt
,
2935 .get_wol
= m88e1318_get_wol
,
2936 .set_wol
= m88e1318_set_wol
,
2937 .resume
= marvell_resume
,
2938 .suspend
= marvell_suspend
,
2939 .read_page
= marvell_read_page
,
2940 .write_page
= marvell_write_page
,
2941 .get_sset_count
= marvell_get_sset_count
,
2942 .get_strings
= marvell_get_strings
,
2943 .get_stats
= marvell_get_stats
,
2944 .set_loopback
= genphy_loopback
,
2945 .get_tunable
= m88e1011_get_tunable
,
2946 .set_tunable
= m88e1011_set_tunable
,
2947 .cable_test_start
= marvell_vct7_cable_test_start
,
2948 .cable_test_tdr_start
= marvell_vct5_cable_test_tdr_start
,
2949 .cable_test_get_status
= marvell_vct7_cable_test_get_status
,
2952 .phy_id
= MARVELL_PHY_ID_88E1540
,
2953 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2954 .name
= "Marvell 88E1540",
2955 /* PHY_GBIT_FEATURES */
2956 .flags
= PHY_POLL_CABLE_TEST
,
2957 .probe
= m88e1510_probe
,
2958 .config_init
= marvell_config_init
,
2959 .config_aneg
= m88e1510_config_aneg
,
2960 .read_status
= marvell_read_status
,
2961 .config_intr
= marvell_config_intr
,
2962 .handle_interrupt
= marvell_handle_interrupt
,
2963 .resume
= genphy_resume
,
2964 .suspend
= genphy_suspend
,
2965 .read_page
= marvell_read_page
,
2966 .write_page
= marvell_write_page
,
2967 .get_sset_count
= marvell_get_sset_count
,
2968 .get_strings
= marvell_get_strings
,
2969 .get_stats
= marvell_get_stats
,
2970 .get_tunable
= m88e1540_get_tunable
,
2971 .set_tunable
= m88e1540_set_tunable
,
2972 .cable_test_start
= marvell_vct7_cable_test_start
,
2973 .cable_test_tdr_start
= marvell_vct5_cable_test_tdr_start
,
2974 .cable_test_get_status
= marvell_vct7_cable_test_get_status
,
2977 .phy_id
= MARVELL_PHY_ID_88E1545
,
2978 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2979 .name
= "Marvell 88E1545",
2980 .probe
= m88e1510_probe
,
2981 /* PHY_GBIT_FEATURES */
2982 .flags
= PHY_POLL_CABLE_TEST
,
2983 .config_init
= marvell_config_init
,
2984 .config_aneg
= m88e1510_config_aneg
,
2985 .read_status
= marvell_read_status
,
2986 .config_intr
= marvell_config_intr
,
2987 .handle_interrupt
= marvell_handle_interrupt
,
2988 .resume
= genphy_resume
,
2989 .suspend
= genphy_suspend
,
2990 .read_page
= marvell_read_page
,
2991 .write_page
= marvell_write_page
,
2992 .get_sset_count
= marvell_get_sset_count
,
2993 .get_strings
= marvell_get_strings
,
2994 .get_stats
= marvell_get_stats
,
2995 .get_tunable
= m88e1540_get_tunable
,
2996 .set_tunable
= m88e1540_set_tunable
,
2997 .cable_test_start
= marvell_vct7_cable_test_start
,
2998 .cable_test_tdr_start
= marvell_vct5_cable_test_tdr_start
,
2999 .cable_test_get_status
= marvell_vct7_cable_test_get_status
,
3002 .phy_id
= MARVELL_PHY_ID_88E3016
,
3003 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
3004 .name
= "Marvell 88E3016",
3005 /* PHY_BASIC_FEATURES */
3006 .probe
= marvell_probe
,
3007 .config_init
= m88e3016_config_init
,
3008 .aneg_done
= marvell_aneg_done
,
3009 .read_status
= marvell_read_status
,
3010 .config_intr
= marvell_config_intr
,
3011 .handle_interrupt
= marvell_handle_interrupt
,
3012 .resume
= genphy_resume
,
3013 .suspend
= genphy_suspend
,
3014 .read_page
= marvell_read_page
,
3015 .write_page
= marvell_write_page
,
3016 .get_sset_count
= marvell_get_sset_count
,
3017 .get_strings
= marvell_get_strings
,
3018 .get_stats
= marvell_get_stats
,
3021 .phy_id
= MARVELL_PHY_ID_88E6390
,
3022 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
3023 .name
= "Marvell 88E6390",
3024 /* PHY_GBIT_FEATURES */
3025 .flags
= PHY_POLL_CABLE_TEST
,
3026 .probe
= m88e6390_probe
,
3027 .config_init
= marvell_config_init
,
3028 .config_aneg
= m88e6390_config_aneg
,
3029 .read_status
= marvell_read_status
,
3030 .config_intr
= marvell_config_intr
,
3031 .handle_interrupt
= marvell_handle_interrupt
,
3032 .resume
= genphy_resume
,
3033 .suspend
= genphy_suspend
,
3034 .read_page
= marvell_read_page
,
3035 .write_page
= marvell_write_page
,
3036 .get_sset_count
= marvell_get_sset_count
,
3037 .get_strings
= marvell_get_strings
,
3038 .get_stats
= marvell_get_stats
,
3039 .get_tunable
= m88e1540_get_tunable
,
3040 .set_tunable
= m88e1540_set_tunable
,
3041 .cable_test_start
= marvell_vct7_cable_test_start
,
3042 .cable_test_tdr_start
= marvell_vct5_cable_test_tdr_start
,
3043 .cable_test_get_status
= marvell_vct7_cable_test_get_status
,
3046 .phy_id
= MARVELL_PHY_ID_88E1340S
,
3047 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
3048 .name
= "Marvell 88E1340S",
3049 .probe
= m88e1510_probe
,
3050 /* PHY_GBIT_FEATURES */
3051 .config_init
= marvell_config_init
,
3052 .config_aneg
= m88e1510_config_aneg
,
3053 .read_status
= marvell_read_status
,
3054 .config_intr
= marvell_config_intr
,
3055 .handle_interrupt
= marvell_handle_interrupt
,
3056 .resume
= genphy_resume
,
3057 .suspend
= genphy_suspend
,
3058 .read_page
= marvell_read_page
,
3059 .write_page
= marvell_write_page
,
3060 .get_sset_count
= marvell_get_sset_count
,
3061 .get_strings
= marvell_get_strings
,
3062 .get_stats
= marvell_get_stats
,
3063 .get_tunable
= m88e1540_get_tunable
,
3064 .set_tunable
= m88e1540_set_tunable
,
3067 .phy_id
= MARVELL_PHY_ID_88E1548P
,
3068 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
3069 .name
= "Marvell 88E1548P",
3070 .probe
= m88e1510_probe
,
3071 .features
= PHY_GBIT_FIBRE_FEATURES
,
3072 .config_init
= marvell_config_init
,
3073 .config_aneg
= m88e1510_config_aneg
,
3074 .read_status
= marvell_read_status
,
3075 .config_intr
= marvell_config_intr
,
3076 .handle_interrupt
= marvell_handle_interrupt
,
3077 .resume
= genphy_resume
,
3078 .suspend
= genphy_suspend
,
3079 .read_page
= marvell_read_page
,
3080 .write_page
= marvell_write_page
,
3081 .get_sset_count
= marvell_get_sset_count
,
3082 .get_strings
= marvell_get_strings
,
3083 .get_stats
= marvell_get_stats
,
3084 .get_tunable
= m88e1540_get_tunable
,
3085 .set_tunable
= m88e1540_set_tunable
,
3089 module_phy_driver(marvell_drivers
);
3091 static struct mdio_device_id __maybe_unused marvell_tbl
[] = {
3092 { MARVELL_PHY_ID_88E1101
, MARVELL_PHY_ID_MASK
},
3093 { MARVELL_PHY_ID_88E1112
, MARVELL_PHY_ID_MASK
},
3094 { MARVELL_PHY_ID_88E1111
, MARVELL_PHY_ID_MASK
},
3095 { MARVELL_PHY_ID_88E1111_FINISAR
, MARVELL_PHY_ID_MASK
},
3096 { MARVELL_PHY_ID_88E1118
, MARVELL_PHY_ID_MASK
},
3097 { MARVELL_PHY_ID_88E1121R
, MARVELL_PHY_ID_MASK
},
3098 { MARVELL_PHY_ID_88E1145
, MARVELL_PHY_ID_MASK
},
3099 { MARVELL_PHY_ID_88E1149R
, MARVELL_PHY_ID_MASK
},
3100 { MARVELL_PHY_ID_88E1240
, MARVELL_PHY_ID_MASK
},
3101 { MARVELL_PHY_ID_88E1318S
, MARVELL_PHY_ID_MASK
},
3102 { MARVELL_PHY_ID_88E1116R
, MARVELL_PHY_ID_MASK
},
3103 { MARVELL_PHY_ID_88E1510
, MARVELL_PHY_ID_MASK
},
3104 { MARVELL_PHY_ID_88E1540
, MARVELL_PHY_ID_MASK
},
3105 { MARVELL_PHY_ID_88E1545
, MARVELL_PHY_ID_MASK
},
3106 { MARVELL_PHY_ID_88E3016
, MARVELL_PHY_ID_MASK
},
3107 { MARVELL_PHY_ID_88E6390
, MARVELL_PHY_ID_MASK
},
3108 { MARVELL_PHY_ID_88E1340S
, MARVELL_PHY_ID_MASK
},
3109 { MARVELL_PHY_ID_88E1548P
, MARVELL_PHY_ID_MASK
},
3113 MODULE_DEVICE_TABLE(mdio
, marvell_tbl
);