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/phy.h>
31 #include <linux/marvell_phy.h>
32 #include <linux/bitfield.h>
37 #include <linux/uaccess.h>
39 #define MII_MARVELL_PHY_PAGE 22
40 #define MII_MARVELL_COPPER_PAGE 0x00
41 #define MII_MARVELL_FIBER_PAGE 0x01
42 #define MII_MARVELL_MSCR_PAGE 0x02
43 #define MII_MARVELL_LED_PAGE 0x03
44 #define MII_MARVELL_MISC_TEST_PAGE 0x06
45 #define MII_MARVELL_WOL_PAGE 0x11
47 #define MII_M1011_IEVENT 0x13
48 #define MII_M1011_IEVENT_CLEAR 0x0000
50 #define MII_M1011_IMASK 0x12
51 #define MII_M1011_IMASK_INIT 0x6400
52 #define MII_M1011_IMASK_CLEAR 0x0000
54 #define MII_M1011_PHY_SCR 0x10
55 #define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11)
56 #define MII_M1011_PHY_SCR_DOWNSHIFT_MASK GENMASK(14, 12)
57 #define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8
58 #define MII_M1011_PHY_SCR_MDI (0x0 << 5)
59 #define MII_M1011_PHY_SCR_MDI_X (0x1 << 5)
60 #define MII_M1011_PHY_SCR_AUTO_CROSS (0x3 << 5)
62 #define MII_M1011_PHY_SSR 0x11
63 #define MII_M1011_PHY_SSR_DOWNSHIFT BIT(5)
65 #define MII_M1111_PHY_LED_CONTROL 0x18
66 #define MII_M1111_PHY_LED_DIRECT 0x4100
67 #define MII_M1111_PHY_LED_COMBINE 0x411c
68 #define MII_M1111_PHY_EXT_CR 0x14
69 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK GENMASK(11, 9)
70 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX 8
71 #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN BIT(8)
72 #define MII_M1111_RGMII_RX_DELAY BIT(7)
73 #define MII_M1111_RGMII_TX_DELAY BIT(1)
74 #define MII_M1111_PHY_EXT_SR 0x1b
76 #define MII_M1111_HWCFG_MODE_MASK 0xf
77 #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
78 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
79 #define MII_M1111_HWCFG_MODE_RTBI 0x7
80 #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
81 #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
82 #define MII_M1111_HWCFG_FIBER_COPPER_RES BIT(13)
83 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO BIT(15)
85 #define MII_88E1121_PHY_MSCR_REG 21
86 #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
87 #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
88 #define MII_88E1121_PHY_MSCR_DELAY_MASK (BIT(5) | BIT(4))
90 #define MII_88E1121_MISC_TEST 0x1a
91 #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK 0x1f00
92 #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT 8
93 #define MII_88E1510_MISC_TEST_TEMP_IRQ_EN BIT(7)
94 #define MII_88E1510_MISC_TEST_TEMP_IRQ BIT(6)
95 #define MII_88E1121_MISC_TEST_TEMP_SENSOR_EN BIT(5)
96 #define MII_88E1121_MISC_TEST_TEMP_MASK 0x1f
98 #define MII_88E1510_TEMP_SENSOR 0x1b
99 #define MII_88E1510_TEMP_SENSOR_MASK 0xff
101 #define MII_88E1540_COPPER_CTRL3 0x1a
102 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK GENMASK(11, 10)
103 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS 0
104 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS 1
105 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS 2
106 #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS 3
107 #define MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN BIT(9)
109 #define MII_88E6390_MISC_TEST 0x1b
110 #define MII_88E6390_MISC_TEST_SAMPLE_1S 0
111 #define MII_88E6390_MISC_TEST_SAMPLE_10MS BIT(14)
112 #define MII_88E6390_MISC_TEST_SAMPLE_DISABLE BIT(15)
113 #define MII_88E6390_MISC_TEST_SAMPLE_ENABLE 0
114 #define MII_88E6390_MISC_TEST_SAMPLE_MASK (0x3 << 14)
116 #define MII_88E6390_TEMP_SENSOR 0x1c
117 #define MII_88E6390_TEMP_SENSOR_MASK 0xff
118 #define MII_88E6390_TEMP_SENSOR_SAMPLES 10
120 #define MII_88E1318S_PHY_MSCR1_REG 16
121 #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
123 /* Copper Specific Interrupt Enable Register */
124 #define MII_88E1318S_PHY_CSIER 0x12
125 /* WOL Event Interrupt Enable */
126 #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
128 /* LED Timer Control Register */
129 #define MII_88E1318S_PHY_LED_TCR 0x12
130 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
131 #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
132 #define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
134 /* Magic Packet MAC address registers */
135 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
136 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
137 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
139 #define MII_88E1318S_PHY_WOL_CTRL 0x10
140 #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
141 #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
143 #define MII_PHY_LED_CTRL 16
144 #define MII_88E1121_PHY_LED_DEF 0x0030
145 #define MII_88E1510_PHY_LED_DEF 0x1177
146 #define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE 0x1040
148 #define MII_M1011_PHY_STATUS 0x11
149 #define MII_M1011_PHY_STATUS_1000 0x8000
150 #define MII_M1011_PHY_STATUS_100 0x4000
151 #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
152 #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
153 #define MII_M1011_PHY_STATUS_RESOLVED 0x0800
154 #define MII_M1011_PHY_STATUS_LINK 0x0400
156 #define MII_88E3016_PHY_SPEC_CTRL 0x10
157 #define MII_88E3016_DISABLE_SCRAMBLER 0x0200
158 #define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
160 #define MII_88E1510_GEN_CTRL_REG_1 0x14
161 #define MII_88E1510_GEN_CTRL_REG_1_MODE_MASK 0x7
162 #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII 0x1 /* SGMII to copper */
163 #define MII_88E1510_GEN_CTRL_REG_1_RESET 0x8000 /* Soft reset */
165 #define LPA_PAUSE_FIBER 0x180
166 #define LPA_PAUSE_ASYM_FIBER 0x100
168 #define NB_FIBER_STATS 1
170 MODULE_DESCRIPTION("Marvell PHY driver");
171 MODULE_AUTHOR("Andy Fleming");
172 MODULE_LICENSE("GPL");
174 struct marvell_hw_stat
{
181 static struct marvell_hw_stat marvell_hw_stats
[] = {
182 { "phy_receive_errors_copper", 0, 21, 16},
183 { "phy_idle_errors", 0, 10, 8 },
184 { "phy_receive_errors_fiber", 1, 21, 16},
187 struct marvell_priv
{
188 u64 stats
[ARRAY_SIZE(marvell_hw_stats
)];
190 struct device
*hwmon_dev
;
193 static int marvell_read_page(struct phy_device
*phydev
)
195 return __phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
198 static int marvell_write_page(struct phy_device
*phydev
, int page
)
200 return __phy_write(phydev
, MII_MARVELL_PHY_PAGE
, page
);
203 static int marvell_set_page(struct phy_device
*phydev
, int page
)
205 return phy_write(phydev
, MII_MARVELL_PHY_PAGE
, page
);
208 static int marvell_ack_interrupt(struct phy_device
*phydev
)
212 /* Clear the interrupts by reading the reg */
213 err
= phy_read(phydev
, MII_M1011_IEVENT
);
221 static int marvell_config_intr(struct phy_device
*phydev
)
225 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
)
226 err
= phy_write(phydev
, MII_M1011_IMASK
,
227 MII_M1011_IMASK_INIT
);
229 err
= phy_write(phydev
, MII_M1011_IMASK
,
230 MII_M1011_IMASK_CLEAR
);
235 static int marvell_set_polarity(struct phy_device
*phydev
, int polarity
)
241 /* get the current settings */
242 reg
= phy_read(phydev
, MII_M1011_PHY_SCR
);
247 val
&= ~MII_M1011_PHY_SCR_AUTO_CROSS
;
250 val
|= MII_M1011_PHY_SCR_MDI
;
253 val
|= MII_M1011_PHY_SCR_MDI_X
;
255 case ETH_TP_MDI_AUTO
:
256 case ETH_TP_MDI_INVALID
:
258 val
|= MII_M1011_PHY_SCR_AUTO_CROSS
;
263 /* Set the new polarity value in the register */
264 err
= phy_write(phydev
, MII_M1011_PHY_SCR
, val
);
272 static int marvell_config_aneg(struct phy_device
*phydev
)
277 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
283 err
= phy_write(phydev
, MII_M1111_PHY_LED_CONTROL
,
284 MII_M1111_PHY_LED_DIRECT
);
288 err
= genphy_config_aneg(phydev
);
292 if (phydev
->autoneg
!= AUTONEG_ENABLE
|| changed
) {
293 /* A write to speed/duplex bits (that is performed by
294 * genphy_config_aneg() call above) must be followed by
295 * a software reset. Otherwise, the write has no effect.
297 err
= genphy_soft_reset(phydev
);
305 static int m88e1101_config_aneg(struct phy_device
*phydev
)
309 /* This Marvell PHY has an errata which requires
310 * that certain registers get written in order
311 * to restart autonegotiation
313 err
= genphy_soft_reset(phydev
);
317 err
= phy_write(phydev
, 0x1d, 0x1f);
321 err
= phy_write(phydev
, 0x1e, 0x200c);
325 err
= phy_write(phydev
, 0x1d, 0x5);
329 err
= phy_write(phydev
, 0x1e, 0);
333 err
= phy_write(phydev
, 0x1e, 0x100);
337 return marvell_config_aneg(phydev
);
340 #ifdef CONFIG_OF_MDIO
341 /* Set and/or override some configuration registers based on the
342 * marvell,reg-init property stored in the of_node for the phydev.
344 * marvell,reg-init = <reg-page reg mask value>,...;
346 * There may be one or more sets of <reg-page reg mask value>:
348 * reg-page: which register bank to use.
350 * mask: if non-zero, ANDed with existing register value.
351 * value: ORed with the masked value and written to the regiser.
354 static int marvell_of_reg_init(struct phy_device
*phydev
)
357 int len
, i
, saved_page
, current_page
, ret
= 0;
359 if (!phydev
->mdio
.dev
.of_node
)
362 paddr
= of_get_property(phydev
->mdio
.dev
.of_node
,
363 "marvell,reg-init", &len
);
364 if (!paddr
|| len
< (4 * sizeof(*paddr
)))
367 saved_page
= phy_save_page(phydev
);
370 current_page
= saved_page
;
372 len
/= sizeof(*paddr
);
373 for (i
= 0; i
< len
- 3; i
+= 4) {
374 u16 page
= be32_to_cpup(paddr
+ i
);
375 u16 reg
= be32_to_cpup(paddr
+ i
+ 1);
376 u16 mask
= be32_to_cpup(paddr
+ i
+ 2);
377 u16 val_bits
= be32_to_cpup(paddr
+ i
+ 3);
380 if (page
!= current_page
) {
382 ret
= marvell_write_page(phydev
, page
);
389 val
= __phy_read(phydev
, reg
);
398 ret
= __phy_write(phydev
, reg
, val
);
403 return phy_restore_page(phydev
, saved_page
, ret
);
406 static int marvell_of_reg_init(struct phy_device
*phydev
)
410 #endif /* CONFIG_OF_MDIO */
412 static int m88e1121_config_aneg_rgmii_delays(struct phy_device
*phydev
)
416 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
)
417 mscr
= MII_88E1121_PHY_MSCR_RX_DELAY
|
418 MII_88E1121_PHY_MSCR_TX_DELAY
;
419 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
)
420 mscr
= MII_88E1121_PHY_MSCR_RX_DELAY
;
421 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
)
422 mscr
= MII_88E1121_PHY_MSCR_TX_DELAY
;
426 return phy_modify_paged(phydev
, MII_MARVELL_MSCR_PAGE
,
427 MII_88E1121_PHY_MSCR_REG
,
428 MII_88E1121_PHY_MSCR_DELAY_MASK
, mscr
);
431 static int m88e1121_config_aneg(struct phy_device
*phydev
)
436 if (phy_interface_is_rgmii(phydev
)) {
437 err
= m88e1121_config_aneg_rgmii_delays(phydev
);
442 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
448 err
= genphy_config_aneg(phydev
);
452 if (phydev
->autoneg
!= AUTONEG_ENABLE
|| changed
) {
453 /* A software reset is used to ensure a "commit" of the
456 err
= genphy_soft_reset(phydev
);
464 static int m88e1318_config_aneg(struct phy_device
*phydev
)
468 err
= phy_modify_paged(phydev
, MII_MARVELL_MSCR_PAGE
,
469 MII_88E1318S_PHY_MSCR1_REG
,
470 0, MII_88E1318S_PHY_MSCR1_PAD_ODD
);
474 return m88e1121_config_aneg(phydev
);
478 * linkmode_adv_to_fiber_adv_t
479 * @advertise: the linkmode advertisement settings
481 * A small helper function that translates linkmode advertisement
482 * settings to phy autonegotiation advertisements for the MII_ADV
483 * register for fiber link.
485 static inline u32
linkmode_adv_to_fiber_adv_t(unsigned long *advertise
)
489 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT
, advertise
))
490 result
|= ADVERTISE_1000XHALF
;
491 if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT
, advertise
))
492 result
|= ADVERTISE_1000XFULL
;
494 if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT
, advertise
) &&
495 linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT
, advertise
))
496 result
|= ADVERTISE_1000XPSE_ASYM
;
497 else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT
, advertise
))
498 result
|= ADVERTISE_1000XPAUSE
;
504 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
505 * @phydev: target phy_device struct
507 * Description: If auto-negotiation is enabled, we configure the
508 * advertising, and then restart auto-negotiation. If it is not
509 * enabled, then we write the BMCR. Adapted for fiber link in
510 * some Marvell's devices.
512 static int marvell_config_aneg_fiber(struct phy_device
*phydev
)
518 if (phydev
->autoneg
!= AUTONEG_ENABLE
)
519 return genphy_setup_forced(phydev
);
521 /* Only allow advertising what this PHY supports */
522 linkmode_and(phydev
->advertising
, phydev
->advertising
,
525 adv
= linkmode_adv_to_fiber_adv_t(phydev
->advertising
);
527 /* Setup fiber advertisement */
528 err
= phy_modify_changed(phydev
, MII_ADVERTISE
,
529 ADVERTISE_1000XHALF
| ADVERTISE_1000XFULL
|
530 ADVERTISE_1000XPAUSE
| ADVERTISE_1000XPSE_ASYM
,
537 return genphy_check_and_restart_aneg(phydev
, changed
);
540 static int m88e1510_config_aneg(struct phy_device
*phydev
)
544 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
548 /* Configure the copper link first */
549 err
= m88e1318_config_aneg(phydev
);
553 /* Do not touch the fiber page if we're in copper->sgmii mode */
554 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
)
557 /* Then the fiber link */
558 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
562 err
= marvell_config_aneg_fiber(phydev
);
566 return marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
569 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
573 static void marvell_config_led(struct phy_device
*phydev
)
578 switch (MARVELL_PHY_FAMILY_ID(phydev
->phy_id
)) {
579 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
580 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R
):
581 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S
):
582 def_config
= MII_88E1121_PHY_LED_DEF
;
584 /* Default PHY LED config:
585 * LED[0] .. 1000Mbps Link
586 * LED[1] .. 100Mbps Link
587 * LED[2] .. Blink, Activity
589 case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510
):
590 if (phydev
->dev_flags
& MARVELL_PHY_LED0_LINK_LED1_ACTIVE
)
591 def_config
= MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE
;
593 def_config
= MII_88E1510_PHY_LED_DEF
;
599 err
= phy_write_paged(phydev
, MII_MARVELL_LED_PAGE
, MII_PHY_LED_CTRL
,
602 phydev_warn(phydev
, "Fail to config marvell phy LED.\n");
605 static int marvell_config_init(struct phy_device
*phydev
)
607 /* Set defalut LED */
608 marvell_config_led(phydev
);
610 /* Set registers from marvell,reg-init DT property */
611 return marvell_of_reg_init(phydev
);
614 static int m88e3016_config_init(struct phy_device
*phydev
)
618 /* Enable Scrambler and Auto-Crossover */
619 ret
= phy_modify(phydev
, MII_88E3016_PHY_SPEC_CTRL
,
620 MII_88E3016_DISABLE_SCRAMBLER
,
621 MII_88E3016_AUTO_MDIX_CROSSOVER
);
625 return marvell_config_init(phydev
);
628 static int m88e1111_config_init_hwcfg_mode(struct phy_device
*phydev
,
630 int fibre_copper_auto
)
632 if (fibre_copper_auto
)
633 mode
|= MII_M1111_HWCFG_FIBER_COPPER_AUTO
;
635 return phy_modify(phydev
, MII_M1111_PHY_EXT_SR
,
636 MII_M1111_HWCFG_MODE_MASK
|
637 MII_M1111_HWCFG_FIBER_COPPER_AUTO
|
638 MII_M1111_HWCFG_FIBER_COPPER_RES
,
642 static int m88e1111_config_init_rgmii_delays(struct phy_device
*phydev
)
646 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
647 delay
= MII_M1111_RGMII_RX_DELAY
| MII_M1111_RGMII_TX_DELAY
;
648 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
) {
649 delay
= MII_M1111_RGMII_RX_DELAY
;
650 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
) {
651 delay
= MII_M1111_RGMII_TX_DELAY
;
656 return phy_modify(phydev
, MII_M1111_PHY_EXT_CR
,
657 MII_M1111_RGMII_RX_DELAY
| MII_M1111_RGMII_TX_DELAY
,
661 static int m88e1111_config_init_rgmii(struct phy_device
*phydev
)
666 err
= m88e1111_config_init_rgmii_delays(phydev
);
670 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
674 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
);
676 if (temp
& MII_M1111_HWCFG_FIBER_COPPER_RES
)
677 temp
|= MII_M1111_HWCFG_MODE_FIBER_RGMII
;
679 temp
|= MII_M1111_HWCFG_MODE_COPPER_RGMII
;
681 return phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
684 static int m88e1111_config_init_sgmii(struct phy_device
*phydev
)
688 err
= m88e1111_config_init_hwcfg_mode(
690 MII_M1111_HWCFG_MODE_SGMII_NO_CLK
,
691 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
695 /* make sure copper is selected */
696 return marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
699 static int m88e1111_config_init_rtbi(struct phy_device
*phydev
)
703 err
= m88e1111_config_init_rgmii_delays(phydev
);
707 err
= m88e1111_config_init_hwcfg_mode(
709 MII_M1111_HWCFG_MODE_RTBI
,
710 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
715 err
= genphy_soft_reset(phydev
);
719 return m88e1111_config_init_hwcfg_mode(
721 MII_M1111_HWCFG_MODE_RTBI
,
722 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
725 static int m88e1111_config_init(struct phy_device
*phydev
)
729 if (phy_interface_is_rgmii(phydev
)) {
730 err
= m88e1111_config_init_rgmii(phydev
);
735 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
736 err
= m88e1111_config_init_sgmii(phydev
);
741 if (phydev
->interface
== PHY_INTERFACE_MODE_RTBI
) {
742 err
= m88e1111_config_init_rtbi(phydev
);
747 err
= marvell_of_reg_init(phydev
);
751 return genphy_soft_reset(phydev
);
754 static int m88e1111_get_downshift(struct phy_device
*phydev
, u8
*data
)
756 int val
, cnt
, enable
;
758 val
= phy_read(phydev
, MII_M1111_PHY_EXT_CR
);
762 enable
= FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
, val
);
763 cnt
= FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
, val
) + 1;
765 *data
= enable
? cnt
: DOWNSHIFT_DEV_DISABLE
;
770 static int m88e1111_set_downshift(struct phy_device
*phydev
, u8 cnt
)
774 if (cnt
> MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX
)
778 return phy_clear_bits(phydev
, MII_M1111_PHY_EXT_CR
,
779 MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
);
781 val
= MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
;
782 val
|= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
, cnt
- 1);
784 return phy_modify(phydev
, MII_M1111_PHY_EXT_CR
,
785 MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN
|
786 MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK
,
790 static int m88e1111_get_tunable(struct phy_device
*phydev
,
791 struct ethtool_tunable
*tuna
, void *data
)
794 case ETHTOOL_PHY_DOWNSHIFT
:
795 return m88e1111_get_downshift(phydev
, data
);
801 static int m88e1111_set_tunable(struct phy_device
*phydev
,
802 struct ethtool_tunable
*tuna
, const void *data
)
805 case ETHTOOL_PHY_DOWNSHIFT
:
806 return m88e1111_set_downshift(phydev
, *(const u8
*)data
);
812 static int m88e1011_get_downshift(struct phy_device
*phydev
, u8
*data
)
814 int val
, cnt
, enable
;
816 val
= phy_read(phydev
, MII_M1011_PHY_SCR
);
820 enable
= FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN
, val
);
821 cnt
= FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK
, val
) + 1;
823 *data
= enable
? cnt
: DOWNSHIFT_DEV_DISABLE
;
828 static int m88e1011_set_downshift(struct phy_device
*phydev
, u8 cnt
)
832 if (cnt
> MII_M1011_PHY_SCR_DOWNSHIFT_MAX
)
836 return phy_clear_bits(phydev
, MII_M1011_PHY_SCR
,
837 MII_M1011_PHY_SCR_DOWNSHIFT_EN
);
839 val
= MII_M1011_PHY_SCR_DOWNSHIFT_EN
;
840 val
|= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK
, cnt
- 1);
842 return phy_modify(phydev
, MII_M1011_PHY_SCR
,
843 MII_M1011_PHY_SCR_DOWNSHIFT_EN
|
844 MII_M1011_PHY_SCR_DOWNSHIFT_MASK
,
848 static int m88e1011_get_tunable(struct phy_device
*phydev
,
849 struct ethtool_tunable
*tuna
, void *data
)
852 case ETHTOOL_PHY_DOWNSHIFT
:
853 return m88e1011_get_downshift(phydev
, data
);
859 static int m88e1011_set_tunable(struct phy_device
*phydev
,
860 struct ethtool_tunable
*tuna
, const void *data
)
863 case ETHTOOL_PHY_DOWNSHIFT
:
864 return m88e1011_set_downshift(phydev
, *(const u8
*)data
);
870 static void m88e1011_link_change_notify(struct phy_device
*phydev
)
874 if (phydev
->state
!= PHY_RUNNING
)
877 /* we may be on fiber page currently */
878 status
= phy_read_paged(phydev
, MII_MARVELL_COPPER_PAGE
,
881 if (status
> 0 && status
& MII_M1011_PHY_SSR_DOWNSHIFT
)
882 phydev_warn(phydev
, "Downshift occurred! Cabling may be defective.\n");
885 static int m88e1116r_config_init(struct phy_device
*phydev
)
889 err
= genphy_soft_reset(phydev
);
895 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
899 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
903 err
= m88e1011_set_downshift(phydev
, 8);
907 if (phy_interface_is_rgmii(phydev
)) {
908 err
= m88e1121_config_aneg_rgmii_delays(phydev
);
913 err
= genphy_soft_reset(phydev
);
917 return marvell_config_init(phydev
);
920 static int m88e1318_config_init(struct phy_device
*phydev
)
922 if (phy_interrupt_is_valid(phydev
)) {
923 int err
= phy_modify_paged(
924 phydev
, MII_MARVELL_LED_PAGE
,
925 MII_88E1318S_PHY_LED_TCR
,
926 MII_88E1318S_PHY_LED_TCR_FORCE_INT
,
927 MII_88E1318S_PHY_LED_TCR_INTn_ENABLE
|
928 MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW
);
933 return marvell_config_init(phydev
);
936 static int m88e1510_config_init(struct phy_device
*phydev
)
940 /* SGMII-to-Copper mode initialization */
941 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
943 err
= marvell_set_page(phydev
, 18);
947 /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
948 err
= phy_modify(phydev
, MII_88E1510_GEN_CTRL_REG_1
,
949 MII_88E1510_GEN_CTRL_REG_1_MODE_MASK
,
950 MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII
);
954 /* PHY reset is necessary after changing MODE[2:0] */
955 err
= phy_modify(phydev
, MII_88E1510_GEN_CTRL_REG_1
, 0,
956 MII_88E1510_GEN_CTRL_REG_1_RESET
);
960 /* Reset page selection */
961 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
966 return m88e1318_config_init(phydev
);
969 static int m88e1118_config_aneg(struct phy_device
*phydev
)
973 err
= genphy_soft_reset(phydev
);
977 err
= marvell_set_polarity(phydev
, phydev
->mdix_ctrl
);
981 err
= genphy_config_aneg(phydev
);
985 static int m88e1118_config_init(struct phy_device
*phydev
)
990 err
= marvell_set_page(phydev
, MII_MARVELL_MSCR_PAGE
);
994 /* Enable 1000 Mbit */
995 err
= phy_write(phydev
, 0x15, 0x1070);
1000 err
= marvell_set_page(phydev
, MII_MARVELL_LED_PAGE
);
1004 /* Adjust LED Control */
1005 if (phydev
->dev_flags
& MARVELL_PHY_M1118_DNS323_LEDS
)
1006 err
= phy_write(phydev
, 0x10, 0x1100);
1008 err
= phy_write(phydev
, 0x10, 0x021e);
1012 err
= marvell_of_reg_init(phydev
);
1017 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1021 return genphy_soft_reset(phydev
);
1024 static int m88e1149_config_init(struct phy_device
*phydev
)
1028 /* Change address */
1029 err
= marvell_set_page(phydev
, MII_MARVELL_MSCR_PAGE
);
1033 /* Enable 1000 Mbit */
1034 err
= phy_write(phydev
, 0x15, 0x1048);
1038 err
= marvell_of_reg_init(phydev
);
1043 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1047 return genphy_soft_reset(phydev
);
1050 static int m88e1145_config_init_rgmii(struct phy_device
*phydev
)
1054 err
= m88e1111_config_init_rgmii_delays(phydev
);
1058 if (phydev
->dev_flags
& MARVELL_PHY_M1145_FLAGS_RESISTANCE
) {
1059 err
= phy_write(phydev
, 0x1d, 0x0012);
1063 err
= phy_modify(phydev
, 0x1e, 0x0fc0,
1064 2 << 9 | /* 36 ohm */
1065 2 << 6); /* 39 ohm */
1069 err
= phy_write(phydev
, 0x1d, 0x3);
1073 err
= phy_write(phydev
, 0x1e, 0x8000);
1078 static int m88e1145_config_init_sgmii(struct phy_device
*phydev
)
1080 return m88e1111_config_init_hwcfg_mode(
1081 phydev
, MII_M1111_HWCFG_MODE_SGMII_NO_CLK
,
1082 MII_M1111_HWCFG_FIBER_COPPER_AUTO
);
1085 static int m88e1145_config_init(struct phy_device
*phydev
)
1089 /* Take care of errata E0 & E1 */
1090 err
= phy_write(phydev
, 0x1d, 0x001b);
1094 err
= phy_write(phydev
, 0x1e, 0x418f);
1098 err
= phy_write(phydev
, 0x1d, 0x0016);
1102 err
= phy_write(phydev
, 0x1e, 0xa2da);
1106 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
1107 err
= m88e1145_config_init_rgmii(phydev
);
1112 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
1113 err
= m88e1145_config_init_sgmii(phydev
);
1118 err
= marvell_of_reg_init(phydev
);
1125 static int m88e1540_get_fld(struct phy_device
*phydev
, u8
*msecs
)
1129 val
= phy_read(phydev
, MII_88E1540_COPPER_CTRL3
);
1133 if (!(val
& MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
)) {
1134 *msecs
= ETHTOOL_PHY_FAST_LINK_DOWN_OFF
;
1138 val
= FIELD_GET(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1141 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS
:
1144 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS
:
1147 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS
:
1150 case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS
:
1160 static int m88e1540_set_fld(struct phy_device
*phydev
, const u8
*msecs
)
1162 struct ethtool_eee eee
;
1165 if (*msecs
== ETHTOOL_PHY_FAST_LINK_DOWN_OFF
)
1166 return phy_clear_bits(phydev
, MII_88E1540_COPPER_CTRL3
,
1167 MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
);
1169 /* According to the Marvell data sheet EEE must be disabled for
1170 * Fast Link Down detection to work properly
1172 ret
= phy_ethtool_get_eee(phydev
, &eee
);
1173 if (!ret
&& eee
.eee_enabled
) {
1174 phydev_warn(phydev
, "Fast Link Down detection requires EEE to be disabled!\n");
1179 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS
;
1180 else if (*msecs
<= 15)
1181 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS
;
1182 else if (*msecs
<= 30)
1183 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS
;
1185 val
= MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS
;
1187 val
= FIELD_PREP(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1189 ret
= phy_modify(phydev
, MII_88E1540_COPPER_CTRL3
,
1190 MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK
, val
);
1194 return phy_set_bits(phydev
, MII_88E1540_COPPER_CTRL3
,
1195 MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN
);
1198 static int m88e1540_get_tunable(struct phy_device
*phydev
,
1199 struct ethtool_tunable
*tuna
, void *data
)
1202 case ETHTOOL_PHY_FAST_LINK_DOWN
:
1203 return m88e1540_get_fld(phydev
, data
);
1204 case ETHTOOL_PHY_DOWNSHIFT
:
1205 return m88e1011_get_downshift(phydev
, data
);
1211 static int m88e1540_set_tunable(struct phy_device
*phydev
,
1212 struct ethtool_tunable
*tuna
, const void *data
)
1215 case ETHTOOL_PHY_FAST_LINK_DOWN
:
1216 return m88e1540_set_fld(phydev
, data
);
1217 case ETHTOOL_PHY_DOWNSHIFT
:
1218 return m88e1011_set_downshift(phydev
, *(const u8
*)data
);
1224 /* The VOD can be out of specification on link up. Poke an
1225 * undocumented register, in an undocumented page, with a magic value
1228 static int m88e6390_errata(struct phy_device
*phydev
)
1232 err
= phy_write(phydev
, MII_BMCR
,
1233 BMCR_ANENABLE
| BMCR_SPEED1000
| BMCR_FULLDPLX
);
1237 usleep_range(300, 400);
1239 err
= phy_write_paged(phydev
, 0xf8, 0x08, 0x36);
1243 return genphy_soft_reset(phydev
);
1246 static int m88e6390_config_aneg(struct phy_device
*phydev
)
1250 err
= m88e6390_errata(phydev
);
1254 return m88e1510_config_aneg(phydev
);
1258 * fiber_lpa_mod_linkmode_lpa_t
1259 * @advertising: the linkmode advertisement settings
1260 * @lpa: value of the MII_LPA register for fiber link
1262 * A small helper function that translates MII_LPA bits to linkmode LP
1263 * advertisement settings. Other bits in advertising are left
1266 static void fiber_lpa_mod_linkmode_lpa_t(unsigned long *advertising
, u32 lpa
)
1268 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT
,
1269 advertising
, lpa
& LPA_1000XHALF
);
1271 linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT
,
1272 advertising
, lpa
& LPA_1000XFULL
);
1275 static int marvell_read_status_page_an(struct phy_device
*phydev
,
1276 int fiber
, int status
)
1282 err
= genphy_read_lpa(phydev
);
1286 phy_resolve_aneg_pause(phydev
);
1288 lpa
= phy_read(phydev
, MII_LPA
);
1292 /* The fiber link is only 1000M capable */
1293 fiber_lpa_mod_linkmode_lpa_t(phydev
->lp_advertising
, lpa
);
1295 if (phydev
->duplex
== DUPLEX_FULL
) {
1296 if (!(lpa
& LPA_PAUSE_FIBER
)) {
1298 phydev
->asym_pause
= 0;
1299 } else if ((lpa
& LPA_PAUSE_ASYM_FIBER
)) {
1301 phydev
->asym_pause
= 1;
1304 phydev
->asym_pause
= 0;
1309 if (status
& MII_M1011_PHY_STATUS_FULLDUPLEX
)
1310 phydev
->duplex
= DUPLEX_FULL
;
1312 phydev
->duplex
= DUPLEX_HALF
;
1314 switch (status
& MII_M1011_PHY_STATUS_SPD_MASK
) {
1315 case MII_M1011_PHY_STATUS_1000
:
1316 phydev
->speed
= SPEED_1000
;
1319 case MII_M1011_PHY_STATUS_100
:
1320 phydev
->speed
= SPEED_100
;
1324 phydev
->speed
= SPEED_10
;
1331 /* marvell_read_status_page
1334 * Check the link, then figure out the current state
1335 * by comparing what we advertise with what the link partner
1336 * advertises. Start by checking the gigabit possibilities,
1337 * then move on to 10/100.
1339 static int marvell_read_status_page(struct phy_device
*phydev
, int page
)
1345 status
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1349 /* Use the generic register for copper link status,
1350 * and the PHY status register for fiber link status.
1352 if (page
== MII_MARVELL_FIBER_PAGE
) {
1353 phydev
->link
= !!(status
& MII_M1011_PHY_STATUS_LINK
);
1355 err
= genphy_update_link(phydev
);
1360 if (page
== MII_MARVELL_FIBER_PAGE
)
1365 linkmode_zero(phydev
->lp_advertising
);
1367 phydev
->asym_pause
= 0;
1369 if (phydev
->autoneg
== AUTONEG_ENABLE
)
1370 err
= marvell_read_status_page_an(phydev
, fiber
, status
);
1372 err
= genphy_read_status_fixed(phydev
);
1377 /* marvell_read_status
1379 * Some Marvell's phys have two modes: fiber and copper.
1380 * Both need status checked.
1382 * First, check the fiber link and status.
1383 * If the fiber link is down, check the copper link and status which
1384 * will be the default value if both link are down.
1386 static int marvell_read_status(struct phy_device
*phydev
)
1390 /* Check the fiber mode first */
1391 if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1392 phydev
->supported
) &&
1393 phydev
->interface
!= PHY_INTERFACE_MODE_SGMII
) {
1394 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1398 err
= marvell_read_status_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1402 /* If the fiber link is up, it is the selected and
1403 * used link. In this case, we need to stay in the
1404 * fiber page. Please to be careful about that, avoid
1405 * to restore Copper page in other functions which
1406 * could break the behaviour for some fiber phy like
1412 /* If fiber link is down, check and save copper mode state */
1413 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1418 return marvell_read_status_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1421 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1427 * Some Marvell's phys have two modes: fiber and copper.
1428 * Both need to be suspended
1430 static int marvell_suspend(struct phy_device
*phydev
)
1434 /* Suspend the fiber mode first */
1435 if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1436 phydev
->supported
)) {
1437 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1441 /* With the page set, use the generic suspend */
1442 err
= genphy_suspend(phydev
);
1446 /* Then, the copper link */
1447 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1452 /* With the page set, use the generic suspend */
1453 return genphy_suspend(phydev
);
1456 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1462 * Some Marvell's phys have two modes: fiber and copper.
1463 * Both need to be resumed
1465 static int marvell_resume(struct phy_device
*phydev
)
1469 /* Resume the fiber mode first */
1470 if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1471 phydev
->supported
)) {
1472 err
= marvell_set_page(phydev
, MII_MARVELL_FIBER_PAGE
);
1476 /* With the page set, use the generic resume */
1477 err
= genphy_resume(phydev
);
1481 /* Then, the copper link */
1482 err
= marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1487 /* With the page set, use the generic resume */
1488 return genphy_resume(phydev
);
1491 marvell_set_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1495 static int marvell_aneg_done(struct phy_device
*phydev
)
1497 int retval
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1499 return (retval
< 0) ? retval
: (retval
& MII_M1011_PHY_STATUS_RESOLVED
);
1502 static int m88e1121_did_interrupt(struct phy_device
*phydev
)
1506 imask
= phy_read(phydev
, MII_M1011_IEVENT
);
1508 if (imask
& MII_M1011_IMASK_INIT
)
1514 static void m88e1318_get_wol(struct phy_device
*phydev
,
1515 struct ethtool_wolinfo
*wol
)
1517 int oldpage
, ret
= 0;
1519 wol
->supported
= WAKE_MAGIC
;
1522 oldpage
= phy_select_page(phydev
, MII_MARVELL_WOL_PAGE
);
1526 ret
= __phy_read(phydev
, MII_88E1318S_PHY_WOL_CTRL
);
1527 if (ret
& MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
)
1528 wol
->wolopts
|= WAKE_MAGIC
;
1531 phy_restore_page(phydev
, oldpage
, ret
);
1534 static int m88e1318_set_wol(struct phy_device
*phydev
,
1535 struct ethtool_wolinfo
*wol
)
1537 int err
= 0, oldpage
;
1539 oldpage
= phy_save_page(phydev
);
1543 if (wol
->wolopts
& WAKE_MAGIC
) {
1544 /* Explicitly switch to page 0x00, just to be sure */
1545 err
= marvell_write_page(phydev
, MII_MARVELL_COPPER_PAGE
);
1549 /* If WOL event happened once, the LED[2] interrupt pin
1550 * will not be cleared unless we reading the interrupt status
1551 * register. If interrupts are in use, the normal interrupt
1552 * handling will clear the WOL event. Clear the WOL event
1553 * before enabling it if !phy_interrupt_is_valid()
1555 if (!phy_interrupt_is_valid(phydev
))
1556 __phy_read(phydev
, MII_M1011_IEVENT
);
1558 /* Enable the WOL interrupt */
1559 err
= __phy_modify(phydev
, MII_88E1318S_PHY_CSIER
, 0,
1560 MII_88E1318S_PHY_CSIER_WOL_EIE
);
1564 err
= marvell_write_page(phydev
, MII_MARVELL_LED_PAGE
);
1568 /* Setup LED[2] as interrupt pin (active low) */
1569 err
= __phy_modify(phydev
, MII_88E1318S_PHY_LED_TCR
,
1570 MII_88E1318S_PHY_LED_TCR_FORCE_INT
,
1571 MII_88E1318S_PHY_LED_TCR_INTn_ENABLE
|
1572 MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW
);
1576 err
= marvell_write_page(phydev
, MII_MARVELL_WOL_PAGE
);
1580 /* Store the device address for the magic packet */
1581 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD2
,
1582 ((phydev
->attached_dev
->dev_addr
[5] << 8) |
1583 phydev
->attached_dev
->dev_addr
[4]));
1586 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD1
,
1587 ((phydev
->attached_dev
->dev_addr
[3] << 8) |
1588 phydev
->attached_dev
->dev_addr
[2]));
1591 err
= __phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD0
,
1592 ((phydev
->attached_dev
->dev_addr
[1] << 8) |
1593 phydev
->attached_dev
->dev_addr
[0]));
1597 /* Clear WOL status and enable magic packet matching */
1598 err
= __phy_modify(phydev
, MII_88E1318S_PHY_WOL_CTRL
, 0,
1599 MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
|
1600 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
);
1604 err
= marvell_write_page(phydev
, MII_MARVELL_WOL_PAGE
);
1608 /* Clear WOL status and disable magic packet matching */
1609 err
= __phy_modify(phydev
, MII_88E1318S_PHY_WOL_CTRL
,
1610 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
,
1611 MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
);
1617 return phy_restore_page(phydev
, oldpage
, err
);
1620 static int marvell_get_sset_count(struct phy_device
*phydev
)
1622 if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT
,
1624 return ARRAY_SIZE(marvell_hw_stats
);
1626 return ARRAY_SIZE(marvell_hw_stats
) - NB_FIBER_STATS
;
1629 static void marvell_get_strings(struct phy_device
*phydev
, u8
*data
)
1631 int count
= marvell_get_sset_count(phydev
);
1634 for (i
= 0; i
< count
; i
++) {
1635 strlcpy(data
+ i
* ETH_GSTRING_LEN
,
1636 marvell_hw_stats
[i
].string
, ETH_GSTRING_LEN
);
1640 static u64
marvell_get_stat(struct phy_device
*phydev
, int i
)
1642 struct marvell_hw_stat stat
= marvell_hw_stats
[i
];
1643 struct marvell_priv
*priv
= phydev
->priv
;
1647 val
= phy_read_paged(phydev
, stat
.page
, stat
.reg
);
1651 val
= val
& ((1 << stat
.bits
) - 1);
1652 priv
->stats
[i
] += val
;
1653 ret
= priv
->stats
[i
];
1659 static void marvell_get_stats(struct phy_device
*phydev
,
1660 struct ethtool_stats
*stats
, u64
*data
)
1662 int count
= marvell_get_sset_count(phydev
);
1665 for (i
= 0; i
< count
; i
++)
1666 data
[i
] = marvell_get_stat(phydev
, i
);
1670 static int m88e1121_get_temp(struct phy_device
*phydev
, long *temp
)
1678 oldpage
= phy_select_page(phydev
, MII_MARVELL_MISC_TEST_PAGE
);
1682 /* Enable temperature sensor */
1683 ret
= __phy_read(phydev
, MII_88E1121_MISC_TEST
);
1687 ret
= __phy_write(phydev
, MII_88E1121_MISC_TEST
,
1688 ret
| MII_88E1121_MISC_TEST_TEMP_SENSOR_EN
);
1692 /* Wait for temperature to stabilize */
1693 usleep_range(10000, 12000);
1695 val
= __phy_read(phydev
, MII_88E1121_MISC_TEST
);
1701 /* Disable temperature sensor */
1702 ret
= __phy_write(phydev
, MII_88E1121_MISC_TEST
,
1703 ret
& ~MII_88E1121_MISC_TEST_TEMP_SENSOR_EN
);
1707 *temp
= ((val
& MII_88E1121_MISC_TEST_TEMP_MASK
) - 5) * 5000;
1710 return phy_restore_page(phydev
, oldpage
, ret
);
1713 static int m88e1121_hwmon_read(struct device
*dev
,
1714 enum hwmon_sensor_types type
,
1715 u32 attr
, int channel
, long *temp
)
1717 struct phy_device
*phydev
= dev_get_drvdata(dev
);
1721 case hwmon_temp_input
:
1722 err
= m88e1121_get_temp(phydev
, temp
);
1731 static umode_t
m88e1121_hwmon_is_visible(const void *data
,
1732 enum hwmon_sensor_types type
,
1733 u32 attr
, int channel
)
1735 if (type
!= hwmon_temp
)
1739 case hwmon_temp_input
:
1746 static u32 m88e1121_hwmon_chip_config
[] = {
1747 HWMON_C_REGISTER_TZ
,
1751 static const struct hwmon_channel_info m88e1121_hwmon_chip
= {
1753 .config
= m88e1121_hwmon_chip_config
,
1756 static u32 m88e1121_hwmon_temp_config
[] = {
1761 static const struct hwmon_channel_info m88e1121_hwmon_temp
= {
1763 .config
= m88e1121_hwmon_temp_config
,
1766 static const struct hwmon_channel_info
*m88e1121_hwmon_info
[] = {
1767 &m88e1121_hwmon_chip
,
1768 &m88e1121_hwmon_temp
,
1772 static const struct hwmon_ops m88e1121_hwmon_hwmon_ops
= {
1773 .is_visible
= m88e1121_hwmon_is_visible
,
1774 .read
= m88e1121_hwmon_read
,
1777 static const struct hwmon_chip_info m88e1121_hwmon_chip_info
= {
1778 .ops
= &m88e1121_hwmon_hwmon_ops
,
1779 .info
= m88e1121_hwmon_info
,
1782 static int m88e1510_get_temp(struct phy_device
*phydev
, long *temp
)
1788 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
1789 MII_88E1510_TEMP_SENSOR
);
1793 *temp
= ((ret
& MII_88E1510_TEMP_SENSOR_MASK
) - 25) * 1000;
1798 static int m88e1510_get_temp_critical(struct phy_device
*phydev
, long *temp
)
1804 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
1805 MII_88E1121_MISC_TEST
);
1809 *temp
= (((ret
& MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK
) >>
1810 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT
) * 5) - 25;
1817 static int m88e1510_set_temp_critical(struct phy_device
*phydev
, long temp
)
1820 temp
= clamp_val(DIV_ROUND_CLOSEST(temp
, 5) + 5, 0, 0x1f);
1822 return phy_modify_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
1823 MII_88E1121_MISC_TEST
,
1824 MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK
,
1825 temp
<< MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT
);
1828 static int m88e1510_get_temp_alarm(struct phy_device
*phydev
, long *alarm
)
1834 ret
= phy_read_paged(phydev
, MII_MARVELL_MISC_TEST_PAGE
,
1835 MII_88E1121_MISC_TEST
);
1839 *alarm
= !!(ret
& MII_88E1510_MISC_TEST_TEMP_IRQ
);
1844 static int m88e1510_hwmon_read(struct device
*dev
,
1845 enum hwmon_sensor_types type
,
1846 u32 attr
, int channel
, long *temp
)
1848 struct phy_device
*phydev
= dev_get_drvdata(dev
);
1852 case hwmon_temp_input
:
1853 err
= m88e1510_get_temp(phydev
, temp
);
1855 case hwmon_temp_crit
:
1856 err
= m88e1510_get_temp_critical(phydev
, temp
);
1858 case hwmon_temp_max_alarm
:
1859 err
= m88e1510_get_temp_alarm(phydev
, temp
);
1868 static int m88e1510_hwmon_write(struct device
*dev
,
1869 enum hwmon_sensor_types type
,
1870 u32 attr
, int channel
, long temp
)
1872 struct phy_device
*phydev
= dev_get_drvdata(dev
);
1876 case hwmon_temp_crit
:
1877 err
= m88e1510_set_temp_critical(phydev
, temp
);
1885 static umode_t
m88e1510_hwmon_is_visible(const void *data
,
1886 enum hwmon_sensor_types type
,
1887 u32 attr
, int channel
)
1889 if (type
!= hwmon_temp
)
1893 case hwmon_temp_input
:
1894 case hwmon_temp_max_alarm
:
1896 case hwmon_temp_crit
:
1903 static u32 m88e1510_hwmon_temp_config
[] = {
1904 HWMON_T_INPUT
| HWMON_T_CRIT
| HWMON_T_MAX_ALARM
,
1908 static const struct hwmon_channel_info m88e1510_hwmon_temp
= {
1910 .config
= m88e1510_hwmon_temp_config
,
1913 static const struct hwmon_channel_info
*m88e1510_hwmon_info
[] = {
1914 &m88e1121_hwmon_chip
,
1915 &m88e1510_hwmon_temp
,
1919 static const struct hwmon_ops m88e1510_hwmon_hwmon_ops
= {
1920 .is_visible
= m88e1510_hwmon_is_visible
,
1921 .read
= m88e1510_hwmon_read
,
1922 .write
= m88e1510_hwmon_write
,
1925 static const struct hwmon_chip_info m88e1510_hwmon_chip_info
= {
1926 .ops
= &m88e1510_hwmon_hwmon_ops
,
1927 .info
= m88e1510_hwmon_info
,
1930 static int m88e6390_get_temp(struct phy_device
*phydev
, long *temp
)
1939 oldpage
= phy_select_page(phydev
, MII_MARVELL_MISC_TEST_PAGE
);
1943 /* Enable temperature sensor */
1944 ret
= __phy_read(phydev
, MII_88E6390_MISC_TEST
);
1948 ret
= ret
& ~MII_88E6390_MISC_TEST_SAMPLE_MASK
;
1949 ret
|= MII_88E6390_MISC_TEST_SAMPLE_ENABLE
|
1950 MII_88E6390_MISC_TEST_SAMPLE_1S
;
1952 ret
= __phy_write(phydev
, MII_88E6390_MISC_TEST
, ret
);
1956 /* Wait for temperature to stabilize */
1957 usleep_range(10000, 12000);
1959 /* Reading the temperature sense has an errata. You need to read
1960 * a number of times and take an average.
1962 for (i
= 0; i
< MII_88E6390_TEMP_SENSOR_SAMPLES
; i
++) {
1963 ret
= __phy_read(phydev
, MII_88E6390_TEMP_SENSOR
);
1966 sum
+= ret
& MII_88E6390_TEMP_SENSOR_MASK
;
1969 sum
/= MII_88E6390_TEMP_SENSOR_SAMPLES
;
1970 *temp
= (sum
- 75) * 1000;
1972 /* Disable temperature sensor */
1973 ret
= __phy_read(phydev
, MII_88E6390_MISC_TEST
);
1977 ret
= ret
& ~MII_88E6390_MISC_TEST_SAMPLE_MASK
;
1978 ret
|= MII_88E6390_MISC_TEST_SAMPLE_DISABLE
;
1980 ret
= __phy_write(phydev
, MII_88E6390_MISC_TEST
, ret
);
1983 phy_restore_page(phydev
, oldpage
, ret
);
1988 static int m88e6390_hwmon_read(struct device
*dev
,
1989 enum hwmon_sensor_types type
,
1990 u32 attr
, int channel
, long *temp
)
1992 struct phy_device
*phydev
= dev_get_drvdata(dev
);
1996 case hwmon_temp_input
:
1997 err
= m88e6390_get_temp(phydev
, temp
);
2006 static umode_t
m88e6390_hwmon_is_visible(const void *data
,
2007 enum hwmon_sensor_types type
,
2008 u32 attr
, int channel
)
2010 if (type
!= hwmon_temp
)
2014 case hwmon_temp_input
:
2021 static u32 m88e6390_hwmon_temp_config
[] = {
2026 static const struct hwmon_channel_info m88e6390_hwmon_temp
= {
2028 .config
= m88e6390_hwmon_temp_config
,
2031 static const struct hwmon_channel_info
*m88e6390_hwmon_info
[] = {
2032 &m88e1121_hwmon_chip
,
2033 &m88e6390_hwmon_temp
,
2037 static const struct hwmon_ops m88e6390_hwmon_hwmon_ops
= {
2038 .is_visible
= m88e6390_hwmon_is_visible
,
2039 .read
= m88e6390_hwmon_read
,
2042 static const struct hwmon_chip_info m88e6390_hwmon_chip_info
= {
2043 .ops
= &m88e6390_hwmon_hwmon_ops
,
2044 .info
= m88e6390_hwmon_info
,
2047 static int marvell_hwmon_name(struct phy_device
*phydev
)
2049 struct marvell_priv
*priv
= phydev
->priv
;
2050 struct device
*dev
= &phydev
->mdio
.dev
;
2051 const char *devname
= dev_name(dev
);
2052 size_t len
= strlen(devname
);
2055 priv
->hwmon_name
= devm_kzalloc(dev
, len
, GFP_KERNEL
);
2056 if (!priv
->hwmon_name
)
2059 for (i
= j
= 0; i
< len
&& devname
[i
]; i
++) {
2060 if (isalnum(devname
[i
]))
2061 priv
->hwmon_name
[j
++] = devname
[i
];
2067 static int marvell_hwmon_probe(struct phy_device
*phydev
,
2068 const struct hwmon_chip_info
*chip
)
2070 struct marvell_priv
*priv
= phydev
->priv
;
2071 struct device
*dev
= &phydev
->mdio
.dev
;
2074 err
= marvell_hwmon_name(phydev
);
2078 priv
->hwmon_dev
= devm_hwmon_device_register_with_info(
2079 dev
, priv
->hwmon_name
, phydev
, chip
, NULL
);
2081 return PTR_ERR_OR_ZERO(priv
->hwmon_dev
);
2084 static int m88e1121_hwmon_probe(struct phy_device
*phydev
)
2086 return marvell_hwmon_probe(phydev
, &m88e1121_hwmon_chip_info
);
2089 static int m88e1510_hwmon_probe(struct phy_device
*phydev
)
2091 return marvell_hwmon_probe(phydev
, &m88e1510_hwmon_chip_info
);
2094 static int m88e6390_hwmon_probe(struct phy_device
*phydev
)
2096 return marvell_hwmon_probe(phydev
, &m88e6390_hwmon_chip_info
);
2099 static int m88e1121_hwmon_probe(struct phy_device
*phydev
)
2104 static int m88e1510_hwmon_probe(struct phy_device
*phydev
)
2109 static int m88e6390_hwmon_probe(struct phy_device
*phydev
)
2115 static int marvell_probe(struct phy_device
*phydev
)
2117 struct marvell_priv
*priv
;
2119 priv
= devm_kzalloc(&phydev
->mdio
.dev
, sizeof(*priv
), GFP_KERNEL
);
2123 phydev
->priv
= priv
;
2128 static int m88e1121_probe(struct phy_device
*phydev
)
2132 err
= marvell_probe(phydev
);
2136 return m88e1121_hwmon_probe(phydev
);
2139 static int m88e1510_probe(struct phy_device
*phydev
)
2143 err
= marvell_probe(phydev
);
2147 return m88e1510_hwmon_probe(phydev
);
2150 static int m88e6390_probe(struct phy_device
*phydev
)
2154 err
= marvell_probe(phydev
);
2158 return m88e6390_hwmon_probe(phydev
);
2161 static struct phy_driver marvell_drivers
[] = {
2163 .phy_id
= MARVELL_PHY_ID_88E1101
,
2164 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2165 .name
= "Marvell 88E1101",
2166 /* PHY_GBIT_FEATURES */
2167 .probe
= marvell_probe
,
2168 .config_init
= &marvell_config_init
,
2169 .config_aneg
= &m88e1101_config_aneg
,
2170 .ack_interrupt
= &marvell_ack_interrupt
,
2171 .config_intr
= &marvell_config_intr
,
2172 .resume
= &genphy_resume
,
2173 .suspend
= &genphy_suspend
,
2174 .read_page
= marvell_read_page
,
2175 .write_page
= marvell_write_page
,
2176 .get_sset_count
= marvell_get_sset_count
,
2177 .get_strings
= marvell_get_strings
,
2178 .get_stats
= marvell_get_stats
,
2181 .phy_id
= MARVELL_PHY_ID_88E1112
,
2182 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2183 .name
= "Marvell 88E1112",
2184 /* PHY_GBIT_FEATURES */
2185 .probe
= marvell_probe
,
2186 .config_init
= &m88e1111_config_init
,
2187 .config_aneg
= &marvell_config_aneg
,
2188 .ack_interrupt
= &marvell_ack_interrupt
,
2189 .config_intr
= &marvell_config_intr
,
2190 .resume
= &genphy_resume
,
2191 .suspend
= &genphy_suspend
,
2192 .read_page
= marvell_read_page
,
2193 .write_page
= marvell_write_page
,
2194 .get_sset_count
= marvell_get_sset_count
,
2195 .get_strings
= marvell_get_strings
,
2196 .get_stats
= marvell_get_stats
,
2197 .get_tunable
= m88e1011_get_tunable
,
2198 .set_tunable
= m88e1011_set_tunable
,
2199 .link_change_notify
= m88e1011_link_change_notify
,
2202 .phy_id
= MARVELL_PHY_ID_88E1111
,
2203 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2204 .name
= "Marvell 88E1111",
2205 /* PHY_GBIT_FEATURES */
2206 .probe
= marvell_probe
,
2207 .config_init
= &m88e1111_config_init
,
2208 .config_aneg
= &marvell_config_aneg
,
2209 .read_status
= &marvell_read_status
,
2210 .ack_interrupt
= &marvell_ack_interrupt
,
2211 .config_intr
= &marvell_config_intr
,
2212 .resume
= &genphy_resume
,
2213 .suspend
= &genphy_suspend
,
2214 .read_page
= marvell_read_page
,
2215 .write_page
= marvell_write_page
,
2216 .get_sset_count
= marvell_get_sset_count
,
2217 .get_strings
= marvell_get_strings
,
2218 .get_stats
= marvell_get_stats
,
2219 .get_tunable
= m88e1111_get_tunable
,
2220 .set_tunable
= m88e1111_set_tunable
,
2221 .link_change_notify
= m88e1011_link_change_notify
,
2224 .phy_id
= MARVELL_PHY_ID_88E1118
,
2225 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2226 .name
= "Marvell 88E1118",
2227 /* PHY_GBIT_FEATURES */
2228 .probe
= marvell_probe
,
2229 .config_init
= &m88e1118_config_init
,
2230 .config_aneg
= &m88e1118_config_aneg
,
2231 .ack_interrupt
= &marvell_ack_interrupt
,
2232 .config_intr
= &marvell_config_intr
,
2233 .resume
= &genphy_resume
,
2234 .suspend
= &genphy_suspend
,
2235 .read_page
= marvell_read_page
,
2236 .write_page
= marvell_write_page
,
2237 .get_sset_count
= marvell_get_sset_count
,
2238 .get_strings
= marvell_get_strings
,
2239 .get_stats
= marvell_get_stats
,
2242 .phy_id
= MARVELL_PHY_ID_88E1121R
,
2243 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2244 .name
= "Marvell 88E1121R",
2245 /* PHY_GBIT_FEATURES */
2246 .probe
= &m88e1121_probe
,
2247 .config_init
= &marvell_config_init
,
2248 .config_aneg
= &m88e1121_config_aneg
,
2249 .read_status
= &marvell_read_status
,
2250 .ack_interrupt
= &marvell_ack_interrupt
,
2251 .config_intr
= &marvell_config_intr
,
2252 .did_interrupt
= &m88e1121_did_interrupt
,
2253 .resume
= &genphy_resume
,
2254 .suspend
= &genphy_suspend
,
2255 .read_page
= marvell_read_page
,
2256 .write_page
= marvell_write_page
,
2257 .get_sset_count
= marvell_get_sset_count
,
2258 .get_strings
= marvell_get_strings
,
2259 .get_stats
= marvell_get_stats
,
2260 .get_tunable
= m88e1011_get_tunable
,
2261 .set_tunable
= m88e1011_set_tunable
,
2262 .link_change_notify
= m88e1011_link_change_notify
,
2265 .phy_id
= MARVELL_PHY_ID_88E1318S
,
2266 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2267 .name
= "Marvell 88E1318S",
2268 /* PHY_GBIT_FEATURES */
2269 .probe
= marvell_probe
,
2270 .config_init
= &m88e1318_config_init
,
2271 .config_aneg
= &m88e1318_config_aneg
,
2272 .read_status
= &marvell_read_status
,
2273 .ack_interrupt
= &marvell_ack_interrupt
,
2274 .config_intr
= &marvell_config_intr
,
2275 .did_interrupt
= &m88e1121_did_interrupt
,
2276 .get_wol
= &m88e1318_get_wol
,
2277 .set_wol
= &m88e1318_set_wol
,
2278 .resume
= &genphy_resume
,
2279 .suspend
= &genphy_suspend
,
2280 .read_page
= marvell_read_page
,
2281 .write_page
= marvell_write_page
,
2282 .get_sset_count
= marvell_get_sset_count
,
2283 .get_strings
= marvell_get_strings
,
2284 .get_stats
= marvell_get_stats
,
2287 .phy_id
= MARVELL_PHY_ID_88E1145
,
2288 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2289 .name
= "Marvell 88E1145",
2290 /* PHY_GBIT_FEATURES */
2291 .probe
= marvell_probe
,
2292 .config_init
= &m88e1145_config_init
,
2293 .config_aneg
= &m88e1101_config_aneg
,
2294 .read_status
= &genphy_read_status
,
2295 .ack_interrupt
= &marvell_ack_interrupt
,
2296 .config_intr
= &marvell_config_intr
,
2297 .resume
= &genphy_resume
,
2298 .suspend
= &genphy_suspend
,
2299 .read_page
= marvell_read_page
,
2300 .write_page
= marvell_write_page
,
2301 .get_sset_count
= marvell_get_sset_count
,
2302 .get_strings
= marvell_get_strings
,
2303 .get_stats
= marvell_get_stats
,
2304 .get_tunable
= m88e1111_get_tunable
,
2305 .set_tunable
= m88e1111_set_tunable
,
2306 .link_change_notify
= m88e1011_link_change_notify
,
2309 .phy_id
= MARVELL_PHY_ID_88E1149R
,
2310 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2311 .name
= "Marvell 88E1149R",
2312 /* PHY_GBIT_FEATURES */
2313 .probe
= marvell_probe
,
2314 .config_init
= &m88e1149_config_init
,
2315 .config_aneg
= &m88e1118_config_aneg
,
2316 .ack_interrupt
= &marvell_ack_interrupt
,
2317 .config_intr
= &marvell_config_intr
,
2318 .resume
= &genphy_resume
,
2319 .suspend
= &genphy_suspend
,
2320 .read_page
= marvell_read_page
,
2321 .write_page
= marvell_write_page
,
2322 .get_sset_count
= marvell_get_sset_count
,
2323 .get_strings
= marvell_get_strings
,
2324 .get_stats
= marvell_get_stats
,
2327 .phy_id
= MARVELL_PHY_ID_88E1240
,
2328 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2329 .name
= "Marvell 88E1240",
2330 /* PHY_GBIT_FEATURES */
2331 .probe
= marvell_probe
,
2332 .config_init
= &m88e1111_config_init
,
2333 .config_aneg
= &marvell_config_aneg
,
2334 .ack_interrupt
= &marvell_ack_interrupt
,
2335 .config_intr
= &marvell_config_intr
,
2336 .resume
= &genphy_resume
,
2337 .suspend
= &genphy_suspend
,
2338 .read_page
= marvell_read_page
,
2339 .write_page
= marvell_write_page
,
2340 .get_sset_count
= marvell_get_sset_count
,
2341 .get_strings
= marvell_get_strings
,
2342 .get_stats
= marvell_get_stats
,
2345 .phy_id
= MARVELL_PHY_ID_88E1116R
,
2346 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2347 .name
= "Marvell 88E1116R",
2348 /* PHY_GBIT_FEATURES */
2349 .probe
= marvell_probe
,
2350 .config_init
= &m88e1116r_config_init
,
2351 .ack_interrupt
= &marvell_ack_interrupt
,
2352 .config_intr
= &marvell_config_intr
,
2353 .resume
= &genphy_resume
,
2354 .suspend
= &genphy_suspend
,
2355 .read_page
= marvell_read_page
,
2356 .write_page
= marvell_write_page
,
2357 .get_sset_count
= marvell_get_sset_count
,
2358 .get_strings
= marvell_get_strings
,
2359 .get_stats
= marvell_get_stats
,
2360 .get_tunable
= m88e1011_get_tunable
,
2361 .set_tunable
= m88e1011_set_tunable
,
2362 .link_change_notify
= m88e1011_link_change_notify
,
2365 .phy_id
= MARVELL_PHY_ID_88E1510
,
2366 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2367 .name
= "Marvell 88E1510",
2368 .features
= PHY_GBIT_FIBRE_FEATURES
,
2369 .probe
= &m88e1510_probe
,
2370 .config_init
= &m88e1510_config_init
,
2371 .config_aneg
= &m88e1510_config_aneg
,
2372 .read_status
= &marvell_read_status
,
2373 .ack_interrupt
= &marvell_ack_interrupt
,
2374 .config_intr
= &marvell_config_intr
,
2375 .did_interrupt
= &m88e1121_did_interrupt
,
2376 .get_wol
= &m88e1318_get_wol
,
2377 .set_wol
= &m88e1318_set_wol
,
2378 .resume
= &marvell_resume
,
2379 .suspend
= &marvell_suspend
,
2380 .read_page
= marvell_read_page
,
2381 .write_page
= marvell_write_page
,
2382 .get_sset_count
= marvell_get_sset_count
,
2383 .get_strings
= marvell_get_strings
,
2384 .get_stats
= marvell_get_stats
,
2385 .set_loopback
= genphy_loopback
,
2386 .get_tunable
= m88e1011_get_tunable
,
2387 .set_tunable
= m88e1011_set_tunable
,
2388 .link_change_notify
= m88e1011_link_change_notify
,
2391 .phy_id
= MARVELL_PHY_ID_88E1540
,
2392 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2393 .name
= "Marvell 88E1540",
2394 /* PHY_GBIT_FEATURES */
2395 .probe
= m88e1510_probe
,
2396 .config_init
= &marvell_config_init
,
2397 .config_aneg
= &m88e1510_config_aneg
,
2398 .read_status
= &marvell_read_status
,
2399 .ack_interrupt
= &marvell_ack_interrupt
,
2400 .config_intr
= &marvell_config_intr
,
2401 .did_interrupt
= &m88e1121_did_interrupt
,
2402 .resume
= &genphy_resume
,
2403 .suspend
= &genphy_suspend
,
2404 .read_page
= marvell_read_page
,
2405 .write_page
= marvell_write_page
,
2406 .get_sset_count
= marvell_get_sset_count
,
2407 .get_strings
= marvell_get_strings
,
2408 .get_stats
= marvell_get_stats
,
2409 .get_tunable
= m88e1540_get_tunable
,
2410 .set_tunable
= m88e1540_set_tunable
,
2411 .link_change_notify
= m88e1011_link_change_notify
,
2414 .phy_id
= MARVELL_PHY_ID_88E1545
,
2415 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2416 .name
= "Marvell 88E1545",
2417 .probe
= m88e1510_probe
,
2418 /* PHY_GBIT_FEATURES */
2419 .config_init
= &marvell_config_init
,
2420 .config_aneg
= &m88e1510_config_aneg
,
2421 .read_status
= &marvell_read_status
,
2422 .ack_interrupt
= &marvell_ack_interrupt
,
2423 .config_intr
= &marvell_config_intr
,
2424 .did_interrupt
= &m88e1121_did_interrupt
,
2425 .resume
= &genphy_resume
,
2426 .suspend
= &genphy_suspend
,
2427 .read_page
= marvell_read_page
,
2428 .write_page
= marvell_write_page
,
2429 .get_sset_count
= marvell_get_sset_count
,
2430 .get_strings
= marvell_get_strings
,
2431 .get_stats
= marvell_get_stats
,
2432 .get_tunable
= m88e1540_get_tunable
,
2433 .set_tunable
= m88e1540_set_tunable
,
2434 .link_change_notify
= m88e1011_link_change_notify
,
2437 .phy_id
= MARVELL_PHY_ID_88E3016
,
2438 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2439 .name
= "Marvell 88E3016",
2440 /* PHY_BASIC_FEATURES */
2441 .probe
= marvell_probe
,
2442 .config_init
= &m88e3016_config_init
,
2443 .aneg_done
= &marvell_aneg_done
,
2444 .read_status
= &marvell_read_status
,
2445 .ack_interrupt
= &marvell_ack_interrupt
,
2446 .config_intr
= &marvell_config_intr
,
2447 .did_interrupt
= &m88e1121_did_interrupt
,
2448 .resume
= &genphy_resume
,
2449 .suspend
= &genphy_suspend
,
2450 .read_page
= marvell_read_page
,
2451 .write_page
= marvell_write_page
,
2452 .get_sset_count
= marvell_get_sset_count
,
2453 .get_strings
= marvell_get_strings
,
2454 .get_stats
= marvell_get_stats
,
2457 .phy_id
= MARVELL_PHY_ID_88E6390
,
2458 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
2459 .name
= "Marvell 88E6390",
2460 /* PHY_GBIT_FEATURES */
2461 .probe
= m88e6390_probe
,
2462 .config_init
= &marvell_config_init
,
2463 .config_aneg
= &m88e6390_config_aneg
,
2464 .read_status
= &marvell_read_status
,
2465 .ack_interrupt
= &marvell_ack_interrupt
,
2466 .config_intr
= &marvell_config_intr
,
2467 .did_interrupt
= &m88e1121_did_interrupt
,
2468 .resume
= &genphy_resume
,
2469 .suspend
= &genphy_suspend
,
2470 .read_page
= marvell_read_page
,
2471 .write_page
= marvell_write_page
,
2472 .get_sset_count
= marvell_get_sset_count
,
2473 .get_strings
= marvell_get_strings
,
2474 .get_stats
= marvell_get_stats
,
2475 .get_tunable
= m88e1540_get_tunable
,
2476 .set_tunable
= m88e1540_set_tunable
,
2477 .link_change_notify
= m88e1011_link_change_notify
,
2481 module_phy_driver(marvell_drivers
);
2483 static struct mdio_device_id __maybe_unused marvell_tbl
[] = {
2484 { MARVELL_PHY_ID_88E1101
, MARVELL_PHY_ID_MASK
},
2485 { MARVELL_PHY_ID_88E1112
, MARVELL_PHY_ID_MASK
},
2486 { MARVELL_PHY_ID_88E1111
, MARVELL_PHY_ID_MASK
},
2487 { MARVELL_PHY_ID_88E1118
, MARVELL_PHY_ID_MASK
},
2488 { MARVELL_PHY_ID_88E1121R
, MARVELL_PHY_ID_MASK
},
2489 { MARVELL_PHY_ID_88E1145
, MARVELL_PHY_ID_MASK
},
2490 { MARVELL_PHY_ID_88E1149R
, MARVELL_PHY_ID_MASK
},
2491 { MARVELL_PHY_ID_88E1240
, MARVELL_PHY_ID_MASK
},
2492 { MARVELL_PHY_ID_88E1318S
, MARVELL_PHY_ID_MASK
},
2493 { MARVELL_PHY_ID_88E1116R
, MARVELL_PHY_ID_MASK
},
2494 { MARVELL_PHY_ID_88E1510
, MARVELL_PHY_ID_MASK
},
2495 { MARVELL_PHY_ID_88E1540
, MARVELL_PHY_ID_MASK
},
2496 { MARVELL_PHY_ID_88E1545
, MARVELL_PHY_ID_MASK
},
2497 { MARVELL_PHY_ID_88E3016
, MARVELL_PHY_ID_MASK
},
2498 { MARVELL_PHY_ID_88E6390
, MARVELL_PHY_ID_MASK
},
2502 MODULE_DEVICE_TABLE(mdio
, marvell_tbl
);