2 * drivers/net/phy/marvell.c
4 * Driver for Marvell PHYs
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 * Copyright (c) 2013 Michael Stapelberg <michael@stapelberg.de>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/kernel.h>
19 #include <linux/string.h>
20 #include <linux/errno.h>
21 #include <linux/unistd.h>
22 #include <linux/interrupt.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/netdevice.h>
26 #include <linux/etherdevice.h>
27 #include <linux/skbuff.h>
28 #include <linux/spinlock.h>
30 #include <linux/module.h>
31 #include <linux/mii.h>
32 #include <linux/ethtool.h>
33 #include <linux/phy.h>
34 #include <linux/marvell_phy.h>
39 #include <linux/uaccess.h>
41 #define MII_MARVELL_PHY_PAGE 22
43 #define MII_M1011_IEVENT 0x13
44 #define MII_M1011_IEVENT_CLEAR 0x0000
46 #define MII_M1011_IMASK 0x12
47 #define MII_M1011_IMASK_INIT 0x6400
48 #define MII_M1011_IMASK_CLEAR 0x0000
50 #define MII_M1011_PHY_SCR 0x10
51 #define MII_M1011_PHY_SCR_MDI 0x0000
52 #define MII_M1011_PHY_SCR_MDI_X 0x0020
53 #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
55 #define MII_M1145_PHY_EXT_ADDR_PAGE 0x16
56 #define MII_M1145_PHY_EXT_SR 0x1b
57 #define MII_M1145_PHY_EXT_CR 0x14
58 #define MII_M1145_RGMII_RX_DELAY 0x0080
59 #define MII_M1145_RGMII_TX_DELAY 0x0002
60 #define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
61 #define MII_M1145_HWCFG_MODE_MASK 0xf
62 #define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
64 #define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
65 #define MII_M1145_HWCFG_MODE_MASK 0xf
66 #define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
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_RX_DELAY 0x80
73 #define MII_M1111_TX_DELAY 0x2
74 #define MII_M1111_PHY_EXT_SR 0x1b
76 #define MII_M1111_HWCFG_MODE_MASK 0xf
77 #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
78 #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
79 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
80 #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
81 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
82 #define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
84 #define MII_M1111_COPPER 0
85 #define MII_M1111_FIBER 1
87 #define MII_88E1121_PHY_MSCR_PAGE 2
88 #define MII_88E1121_PHY_MSCR_REG 21
89 #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
90 #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
91 #define MII_88E1121_PHY_MSCR_DELAY_MASK (~(0x3 << 4))
93 #define MII_88E1318S_PHY_MSCR1_REG 16
94 #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
96 /* Copper Specific Interrupt Enable Register */
97 #define MII_88E1318S_PHY_CSIER 0x12
98 /* WOL Event Interrupt Enable */
99 #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
101 /* LED Timer Control Register */
102 #define MII_88E1318S_PHY_LED_PAGE 0x03
103 #define MII_88E1318S_PHY_LED_TCR 0x12
104 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
105 #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
106 #define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
108 /* Magic Packet MAC address registers */
109 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
110 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
111 #define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
113 #define MII_88E1318S_PHY_WOL_PAGE 0x11
114 #define MII_88E1318S_PHY_WOL_CTRL 0x10
115 #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
116 #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
118 #define MII_88E1121_PHY_LED_CTRL 16
119 #define MII_88E1121_PHY_LED_PAGE 3
120 #define MII_88E1121_PHY_LED_DEF 0x0030
122 #define MII_M1011_PHY_STATUS 0x11
123 #define MII_M1011_PHY_STATUS_1000 0x8000
124 #define MII_M1011_PHY_STATUS_100 0x4000
125 #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
126 #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
127 #define MII_M1011_PHY_STATUS_RESOLVED 0x0800
128 #define MII_M1011_PHY_STATUS_LINK 0x0400
130 #define MII_M1116R_CONTROL_REG_MAC 21
132 #define MII_88E3016_PHY_SPEC_CTRL 0x10
133 #define MII_88E3016_DISABLE_SCRAMBLER 0x0200
134 #define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
136 #define MII_88E1510_GEN_CTRL_REG_1 0x14
137 #define MII_88E1510_GEN_CTRL_REG_1_MODE_MASK 0x7
138 #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII 0x1 /* SGMII to copper */
139 #define MII_88E1510_GEN_CTRL_REG_1_RESET 0x8000 /* Soft reset */
141 #define LPA_FIBER_1000HALF 0x40
142 #define LPA_FIBER_1000FULL 0x20
144 #define LPA_PAUSE_FIBER 0x180
145 #define LPA_PAUSE_ASYM_FIBER 0x100
147 #define ADVERTISE_FIBER_1000HALF 0x40
148 #define ADVERTISE_FIBER_1000FULL 0x20
150 #define ADVERTISE_PAUSE_FIBER 0x180
151 #define ADVERTISE_PAUSE_ASYM_FIBER 0x100
153 #define REGISTER_LINK_STATUS 0x400
154 #define NB_FIBER_STATS 1
156 MODULE_DESCRIPTION("Marvell PHY driver");
157 MODULE_AUTHOR("Andy Fleming");
158 MODULE_LICENSE("GPL");
160 struct marvell_hw_stat
{
167 static struct marvell_hw_stat marvell_hw_stats
[] = {
168 { "phy_receive_errors_copper", 0, 21, 16},
169 { "phy_idle_errors", 0, 10, 8 },
170 { "phy_receive_errors_fiber", 1, 21, 16},
173 struct marvell_priv
{
174 u64 stats
[ARRAY_SIZE(marvell_hw_stats
)];
177 static int marvell_ack_interrupt(struct phy_device
*phydev
)
181 /* Clear the interrupts by reading the reg */
182 err
= phy_read(phydev
, MII_M1011_IEVENT
);
190 static int marvell_config_intr(struct phy_device
*phydev
)
194 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
)
195 err
= phy_write(phydev
, MII_M1011_IMASK
, MII_M1011_IMASK_INIT
);
197 err
= phy_write(phydev
, MII_M1011_IMASK
, MII_M1011_IMASK_CLEAR
);
202 static int marvell_set_polarity(struct phy_device
*phydev
, int polarity
)
208 /* get the current settings */
209 reg
= phy_read(phydev
, MII_M1011_PHY_SCR
);
214 val
&= ~MII_M1011_PHY_SCR_AUTO_CROSS
;
217 val
|= MII_M1011_PHY_SCR_MDI
;
220 val
|= MII_M1011_PHY_SCR_MDI_X
;
222 case ETH_TP_MDI_AUTO
:
223 case ETH_TP_MDI_INVALID
:
225 val
|= MII_M1011_PHY_SCR_AUTO_CROSS
;
230 /* Set the new polarity value in the register */
231 err
= phy_write(phydev
, MII_M1011_PHY_SCR
, val
);
239 static int marvell_config_aneg(struct phy_device
*phydev
)
243 /* The Marvell PHY has an errata which requires
244 * that certain registers get written in order
245 * to restart autonegotiation */
246 err
= phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
251 err
= phy_write(phydev
, 0x1d, 0x1f);
255 err
= phy_write(phydev
, 0x1e, 0x200c);
259 err
= phy_write(phydev
, 0x1d, 0x5);
263 err
= phy_write(phydev
, 0x1e, 0);
267 err
= phy_write(phydev
, 0x1e, 0x100);
271 err
= marvell_set_polarity(phydev
, phydev
->mdix
);
275 err
= phy_write(phydev
, MII_M1111_PHY_LED_CONTROL
,
276 MII_M1111_PHY_LED_DIRECT
);
280 err
= genphy_config_aneg(phydev
);
284 if (phydev
->autoneg
!= AUTONEG_ENABLE
) {
288 * A write to speed/duplex bits (that is performed by
289 * genphy_config_aneg() call above) must be followed by
290 * a software reset. Otherwise, the write has no effect.
292 bmcr
= phy_read(phydev
, MII_BMCR
);
296 err
= phy_write(phydev
, MII_BMCR
, bmcr
| BMCR_RESET
);
304 static int m88e1111_config_aneg(struct phy_device
*phydev
)
308 /* The Marvell PHY has an errata which requires
309 * that certain registers get written in order
310 * to restart autonegotiation
312 err
= phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
314 err
= marvell_set_polarity(phydev
, phydev
->mdix
);
318 err
= phy_write(phydev
, MII_M1111_PHY_LED_CONTROL
,
319 MII_M1111_PHY_LED_DIRECT
);
323 err
= genphy_config_aneg(phydev
);
327 if (phydev
->autoneg
!= AUTONEG_ENABLE
) {
330 /* A write to speed/duplex bits (that is performed by
331 * genphy_config_aneg() call above) must be followed by
332 * a software reset. Otherwise, the write has no effect.
334 bmcr
= phy_read(phydev
, MII_BMCR
);
338 err
= phy_write(phydev
, MII_BMCR
, bmcr
| BMCR_RESET
);
346 #ifdef CONFIG_OF_MDIO
348 * Set and/or override some configuration registers based on the
349 * marvell,reg-init property stored in the of_node for the phydev.
351 * marvell,reg-init = <reg-page reg mask value>,...;
353 * There may be one or more sets of <reg-page reg mask value>:
355 * reg-page: which register bank to use.
357 * mask: if non-zero, ANDed with existing register value.
358 * value: ORed with the masked value and written to the regiser.
361 static int marvell_of_reg_init(struct phy_device
*phydev
)
364 int len
, i
, saved_page
, current_page
, page_changed
, ret
;
366 if (!phydev
->mdio
.dev
.of_node
)
369 paddr
= of_get_property(phydev
->mdio
.dev
.of_node
,
370 "marvell,reg-init", &len
);
371 if (!paddr
|| len
< (4 * sizeof(*paddr
)))
374 saved_page
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
378 current_page
= saved_page
;
381 len
/= sizeof(*paddr
);
382 for (i
= 0; i
< len
- 3; i
+= 4) {
383 u16 reg_page
= be32_to_cpup(paddr
+ i
);
384 u16 reg
= be32_to_cpup(paddr
+ i
+ 1);
385 u16 mask
= be32_to_cpup(paddr
+ i
+ 2);
386 u16 val_bits
= be32_to_cpup(paddr
+ i
+ 3);
389 if (reg_page
!= current_page
) {
390 current_page
= reg_page
;
392 ret
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, reg_page
);
399 val
= phy_read(phydev
, reg
);
408 ret
= phy_write(phydev
, reg
, val
);
415 i
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, saved_page
);
422 static int marvell_of_reg_init(struct phy_device
*phydev
)
426 #endif /* CONFIG_OF_MDIO */
428 static int m88e1121_config_aneg(struct phy_device
*phydev
)
430 int err
, oldpage
, mscr
;
432 oldpage
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
434 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
435 MII_88E1121_PHY_MSCR_PAGE
);
439 if (phy_interface_is_rgmii(phydev
)) {
441 mscr
= phy_read(phydev
, MII_88E1121_PHY_MSCR_REG
) &
442 MII_88E1121_PHY_MSCR_DELAY_MASK
;
444 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
)
445 mscr
|= (MII_88E1121_PHY_MSCR_RX_DELAY
|
446 MII_88E1121_PHY_MSCR_TX_DELAY
);
447 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
)
448 mscr
|= MII_88E1121_PHY_MSCR_RX_DELAY
;
449 else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
)
450 mscr
|= MII_88E1121_PHY_MSCR_TX_DELAY
;
452 err
= phy_write(phydev
, MII_88E1121_PHY_MSCR_REG
, mscr
);
457 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, oldpage
);
459 err
= phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
463 err
= phy_write(phydev
, MII_M1011_PHY_SCR
,
464 MII_M1011_PHY_SCR_AUTO_CROSS
);
468 return genphy_config_aneg(phydev
);
471 static int m88e1318_config_aneg(struct phy_device
*phydev
)
473 int err
, oldpage
, mscr
;
475 oldpage
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
477 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
478 MII_88E1121_PHY_MSCR_PAGE
);
482 mscr
= phy_read(phydev
, MII_88E1318S_PHY_MSCR1_REG
);
483 mscr
|= MII_88E1318S_PHY_MSCR1_PAD_ODD
;
485 err
= phy_write(phydev
, MII_88E1318S_PHY_MSCR1_REG
, mscr
);
489 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, oldpage
);
493 return m88e1121_config_aneg(phydev
);
497 * ethtool_adv_to_fiber_adv_t
498 * @ethadv: the ethtool advertisement settings
500 * A small helper function that translates ethtool advertisement
501 * settings to phy autonegotiation advertisements for the
502 * MII_ADV register for fiber link.
504 static inline u32
ethtool_adv_to_fiber_adv_t(u32 ethadv
)
508 if (ethadv
& ADVERTISED_1000baseT_Half
)
509 result
|= ADVERTISE_FIBER_1000HALF
;
510 if (ethadv
& ADVERTISED_1000baseT_Full
)
511 result
|= ADVERTISE_FIBER_1000FULL
;
513 if ((ethadv
& ADVERTISE_PAUSE_ASYM
) && (ethadv
& ADVERTISE_PAUSE_CAP
))
514 result
|= LPA_PAUSE_ASYM_FIBER
;
515 else if (ethadv
& ADVERTISE_PAUSE_CAP
)
516 result
|= (ADVERTISE_PAUSE_FIBER
517 & (~ADVERTISE_PAUSE_ASYM_FIBER
));
523 * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR
524 * @phydev: target phy_device struct
526 * Description: If auto-negotiation is enabled, we configure the
527 * advertising, and then restart auto-negotiation. If it is not
528 * enabled, then we write the BMCR. Adapted for fiber link in
529 * some Marvell's devices.
531 static int marvell_config_aneg_fiber(struct phy_device
*phydev
)
538 if (phydev
->autoneg
!= AUTONEG_ENABLE
)
539 return genphy_setup_forced(phydev
);
541 /* Only allow advertising what this PHY supports */
542 phydev
->advertising
&= phydev
->supported
;
543 advertise
= phydev
->advertising
;
545 /* Setup fiber advertisement */
546 adv
= phy_read(phydev
, MII_ADVERTISE
);
551 adv
&= ~(ADVERTISE_FIBER_1000HALF
| ADVERTISE_FIBER_1000FULL
553 adv
|= ethtool_adv_to_fiber_adv_t(advertise
);
556 err
= phy_write(phydev
, MII_ADVERTISE
, adv
);
564 /* Advertisement hasn't changed, but maybe aneg was never on to
565 * begin with? Or maybe phy was isolated?
567 int ctl
= phy_read(phydev
, MII_BMCR
);
572 if (!(ctl
& BMCR_ANENABLE
) || (ctl
& BMCR_ISOLATE
))
573 changed
= 1; /* do restart aneg */
576 /* Only restart aneg if we are advertising something different
577 * than we were before.
580 changed
= genphy_restart_aneg(phydev
);
585 static int m88e1510_config_aneg(struct phy_device
*phydev
)
589 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
593 /* Configure the copper link first */
594 err
= m88e1318_config_aneg(phydev
);
598 /* Then the fiber link */
599 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_FIBER
);
603 err
= marvell_config_aneg_fiber(phydev
);
607 return phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
610 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
614 static int marvell_config_init(struct phy_device
*phydev
)
616 /* Set registers from marvell,reg-init DT property */
617 return marvell_of_reg_init(phydev
);
620 static int m88e1116r_config_init(struct phy_device
*phydev
)
625 temp
= phy_read(phydev
, MII_BMCR
);
627 err
= phy_write(phydev
, MII_BMCR
, temp
);
633 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0);
637 temp
= phy_read(phydev
, MII_M1011_PHY_SCR
);
638 temp
|= (7 << 12); /* max number of gigabit attempts */
639 temp
|= (1 << 11); /* enable downshift */
640 temp
|= MII_M1011_PHY_SCR_AUTO_CROSS
;
641 err
= phy_write(phydev
, MII_M1011_PHY_SCR
, temp
);
645 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 2);
648 temp
= phy_read(phydev
, MII_M1116R_CONTROL_REG_MAC
);
651 err
= phy_write(phydev
, MII_M1116R_CONTROL_REG_MAC
, temp
);
654 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0);
658 temp
= phy_read(phydev
, MII_BMCR
);
660 err
= phy_write(phydev
, MII_BMCR
, temp
);
666 return marvell_config_init(phydev
);
669 static int m88e3016_config_init(struct phy_device
*phydev
)
673 /* Enable Scrambler and Auto-Crossover */
674 reg
= phy_read(phydev
, MII_88E3016_PHY_SPEC_CTRL
);
678 reg
&= ~MII_88E3016_DISABLE_SCRAMBLER
;
679 reg
|= MII_88E3016_AUTO_MDIX_CROSSOVER
;
681 reg
= phy_write(phydev
, MII_88E3016_PHY_SPEC_CTRL
, reg
);
685 return marvell_config_init(phydev
);
688 static int m88e1111_config_init(struct phy_device
*phydev
)
693 if (phy_interface_is_rgmii(phydev
)) {
695 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_CR
);
699 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
700 temp
|= (MII_M1111_RX_DELAY
| MII_M1111_TX_DELAY
);
701 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_RXID
) {
702 temp
&= ~MII_M1111_TX_DELAY
;
703 temp
|= MII_M1111_RX_DELAY
;
704 } else if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_TXID
) {
705 temp
&= ~MII_M1111_RX_DELAY
;
706 temp
|= MII_M1111_TX_DELAY
;
709 err
= phy_write(phydev
, MII_M1111_PHY_EXT_CR
, temp
);
713 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
717 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
);
719 if (temp
& MII_M1111_HWCFG_FIBER_COPPER_RES
)
720 temp
|= MII_M1111_HWCFG_MODE_FIBER_RGMII
;
722 temp
|= MII_M1111_HWCFG_MODE_COPPER_RGMII
;
724 err
= phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
729 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
730 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
734 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
);
735 temp
|= MII_M1111_HWCFG_MODE_SGMII_NO_CLK
;
736 temp
|= MII_M1111_HWCFG_FIBER_COPPER_AUTO
;
738 err
= phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
742 /* make sure copper is selected */
743 err
= phy_read(phydev
, MII_M1145_PHY_EXT_ADDR_PAGE
);
747 err
= phy_write(phydev
, MII_M1145_PHY_EXT_ADDR_PAGE
,
753 if (phydev
->interface
== PHY_INTERFACE_MODE_RTBI
) {
754 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_CR
);
757 temp
|= (MII_M1111_RX_DELAY
| MII_M1111_TX_DELAY
);
758 err
= phy_write(phydev
, MII_M1111_PHY_EXT_CR
, temp
);
762 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
765 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
| MII_M1111_HWCFG_FIBER_COPPER_RES
);
766 temp
|= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO
;
767 err
= phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
772 err
= phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
776 temp
= phy_read(phydev
, MII_BMCR
);
777 while (temp
& BMCR_RESET
);
779 temp
= phy_read(phydev
, MII_M1111_PHY_EXT_SR
);
782 temp
&= ~(MII_M1111_HWCFG_MODE_MASK
| MII_M1111_HWCFG_FIBER_COPPER_RES
);
783 temp
|= MII_M1111_HWCFG_MODE_COPPER_RTBI
| MII_M1111_HWCFG_FIBER_COPPER_AUTO
;
784 err
= phy_write(phydev
, MII_M1111_PHY_EXT_SR
, temp
);
789 err
= marvell_of_reg_init(phydev
);
793 return phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
796 static int m88e1121_config_init(struct phy_device
*phydev
)
800 oldpage
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
802 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_88E1121_PHY_LED_PAGE
);
806 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
807 err
= phy_write(phydev
, MII_88E1121_PHY_LED_CTRL
,
808 MII_88E1121_PHY_LED_DEF
);
812 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, oldpage
);
814 /* Set marvell,reg-init configuration from device tree */
815 return marvell_config_init(phydev
);
818 static int m88e1510_config_init(struct phy_device
*phydev
)
823 /* SGMII-to-Copper mode initialization */
824 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
826 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 18);
830 /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
831 temp
= phy_read(phydev
, MII_88E1510_GEN_CTRL_REG_1
);
832 temp
&= ~MII_88E1510_GEN_CTRL_REG_1_MODE_MASK
;
833 temp
|= MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII
;
834 err
= phy_write(phydev
, MII_88E1510_GEN_CTRL_REG_1
, temp
);
838 /* PHY reset is necessary after changing MODE[2:0] */
839 temp
|= MII_88E1510_GEN_CTRL_REG_1_RESET
;
840 err
= phy_write(phydev
, MII_88E1510_GEN_CTRL_REG_1
, temp
);
844 /* Reset page selection */
845 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0);
850 return m88e1121_config_init(phydev
);
853 static int m88e1118_config_aneg(struct phy_device
*phydev
)
857 err
= phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
861 err
= phy_write(phydev
, MII_M1011_PHY_SCR
,
862 MII_M1011_PHY_SCR_AUTO_CROSS
);
866 err
= genphy_config_aneg(phydev
);
870 static int m88e1118_config_init(struct phy_device
*phydev
)
875 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x0002);
879 /* Enable 1000 Mbit */
880 err
= phy_write(phydev
, 0x15, 0x1070);
885 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x0003);
889 /* Adjust LED Control */
890 if (phydev
->dev_flags
& MARVELL_PHY_M1118_DNS323_LEDS
)
891 err
= phy_write(phydev
, 0x10, 0x1100);
893 err
= phy_write(phydev
, 0x10, 0x021e);
897 err
= marvell_of_reg_init(phydev
);
902 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x0);
906 return phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
909 static int m88e1149_config_init(struct phy_device
*phydev
)
914 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x0002);
918 /* Enable 1000 Mbit */
919 err
= phy_write(phydev
, 0x15, 0x1048);
923 err
= marvell_of_reg_init(phydev
);
928 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x0);
932 return phy_write(phydev
, MII_BMCR
, BMCR_RESET
);
935 static int m88e1145_config_init(struct phy_device
*phydev
)
940 /* Take care of errata E0 & E1 */
941 err
= phy_write(phydev
, 0x1d, 0x001b);
945 err
= phy_write(phydev
, 0x1e, 0x418f);
949 err
= phy_write(phydev
, 0x1d, 0x0016);
953 err
= phy_write(phydev
, 0x1e, 0xa2da);
957 if (phydev
->interface
== PHY_INTERFACE_MODE_RGMII_ID
) {
958 int temp
= phy_read(phydev
, MII_M1145_PHY_EXT_CR
);
962 temp
|= (MII_M1145_RGMII_RX_DELAY
| MII_M1145_RGMII_TX_DELAY
);
964 err
= phy_write(phydev
, MII_M1145_PHY_EXT_CR
, temp
);
968 if (phydev
->dev_flags
& MARVELL_PHY_M1145_FLAGS_RESISTANCE
) {
969 err
= phy_write(phydev
, 0x1d, 0x0012);
973 temp
= phy_read(phydev
, 0x1e);
978 temp
|= 2 << 9; /* 36 ohm */
979 temp
|= 2 << 6; /* 39 ohm */
981 err
= phy_write(phydev
, 0x1e, temp
);
985 err
= phy_write(phydev
, 0x1d, 0x3);
989 err
= phy_write(phydev
, 0x1e, 0x8000);
995 if (phydev
->interface
== PHY_INTERFACE_MODE_SGMII
) {
996 temp
= phy_read(phydev
, MII_M1145_PHY_EXT_SR
);
1000 temp
&= ~MII_M1145_HWCFG_MODE_MASK
;
1001 temp
|= MII_M1145_HWCFG_MODE_SGMII_NO_CLK
;
1002 temp
|= MII_M1145_HWCFG_FIBER_COPPER_AUTO
;
1004 err
= phy_write(phydev
, MII_M1145_PHY_EXT_SR
, temp
);
1009 err
= marvell_of_reg_init(phydev
);
1017 * fiber_lpa_to_ethtool_lpa_t
1018 * @lpa: value of the MII_LPA register for fiber link
1020 * A small helper function that translates MII_LPA
1021 * bits to ethtool LP advertisement settings.
1023 static u32
fiber_lpa_to_ethtool_lpa_t(u32 lpa
)
1027 if (lpa
& LPA_FIBER_1000HALF
)
1028 result
|= ADVERTISED_1000baseT_Half
;
1029 if (lpa
& LPA_FIBER_1000FULL
)
1030 result
|= ADVERTISED_1000baseT_Full
;
1036 * marvell_update_link - update link status in real time in @phydev
1037 * @phydev: target phy_device struct
1039 * Description: Update the value in phydev->link to reflect the
1040 * current link value.
1042 static int marvell_update_link(struct phy_device
*phydev
, int fiber
)
1046 /* Use the generic register for copper link, or specific
1047 * register for fiber case */
1049 status
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1053 if ((status
& REGISTER_LINK_STATUS
) == 0)
1058 return genphy_update_link(phydev
);
1064 /* marvell_read_status_page
1067 * Check the link, then figure out the current state
1068 * by comparing what we advertise with what the link partner
1069 * advertises. Start by checking the gigabit possibilities,
1070 * then move on to 10/100.
1072 static int marvell_read_status_page(struct phy_device
*phydev
, int page
)
1081 /* Detect and update the link, but return if there
1083 if (page
== MII_M1111_FIBER
)
1088 err
= marvell_update_link(phydev
, fiber
);
1092 if (AUTONEG_ENABLE
== phydev
->autoneg
) {
1093 status
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1097 lpa
= phy_read(phydev
, MII_LPA
);
1101 lpagb
= phy_read(phydev
, MII_STAT1000
);
1105 adv
= phy_read(phydev
, MII_ADVERTISE
);
1111 if (status
& MII_M1011_PHY_STATUS_FULLDUPLEX
)
1112 phydev
->duplex
= DUPLEX_FULL
;
1114 phydev
->duplex
= DUPLEX_HALF
;
1116 status
= status
& MII_M1011_PHY_STATUS_SPD_MASK
;
1117 phydev
->pause
= phydev
->asym_pause
= 0;
1120 case MII_M1011_PHY_STATUS_1000
:
1121 phydev
->speed
= SPEED_1000
;
1124 case MII_M1011_PHY_STATUS_100
:
1125 phydev
->speed
= SPEED_100
;
1129 phydev
->speed
= SPEED_10
;
1134 phydev
->lp_advertising
= mii_stat1000_to_ethtool_lpa_t(lpagb
) |
1135 mii_lpa_to_ethtool_lpa_t(lpa
);
1137 if (phydev
->duplex
== DUPLEX_FULL
) {
1138 phydev
->pause
= lpa
& LPA_PAUSE_CAP
? 1 : 0;
1139 phydev
->asym_pause
= lpa
& LPA_PAUSE_ASYM
? 1 : 0;
1142 /* The fiber link is only 1000M capable */
1143 phydev
->lp_advertising
= fiber_lpa_to_ethtool_lpa_t(lpa
);
1145 if (phydev
->duplex
== DUPLEX_FULL
) {
1146 if (!(lpa
& LPA_PAUSE_FIBER
)) {
1148 phydev
->asym_pause
= 0;
1149 } else if ((lpa
& LPA_PAUSE_ASYM_FIBER
)) {
1151 phydev
->asym_pause
= 1;
1154 phydev
->asym_pause
= 0;
1159 int bmcr
= phy_read(phydev
, MII_BMCR
);
1164 if (bmcr
& BMCR_FULLDPLX
)
1165 phydev
->duplex
= DUPLEX_FULL
;
1167 phydev
->duplex
= DUPLEX_HALF
;
1169 if (bmcr
& BMCR_SPEED1000
)
1170 phydev
->speed
= SPEED_1000
;
1171 else if (bmcr
& BMCR_SPEED100
)
1172 phydev
->speed
= SPEED_100
;
1174 phydev
->speed
= SPEED_10
;
1176 phydev
->pause
= phydev
->asym_pause
= 0;
1177 phydev
->lp_advertising
= 0;
1183 /* marvell_read_status
1185 * Some Marvell's phys have two modes: fiber and copper.
1186 * Both need status checked.
1188 * First, check the fiber link and status.
1189 * If the fiber link is down, check the copper link and status which
1190 * will be the default value if both link are down.
1192 static int marvell_read_status(struct phy_device
*phydev
)
1196 /* Check the fiber mode first */
1197 if (phydev
->supported
& SUPPORTED_FIBRE
) {
1198 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_FIBER
);
1202 err
= marvell_read_status_page(phydev
, MII_M1111_FIBER
);
1206 /* If the fiber link is up, it is the selected and used link.
1207 * In this case, we need to stay in the fiber page.
1208 * Please to be careful about that, avoid to restore Copper page
1209 * in other functions which could break the behaviour
1210 * for some fiber phy like 88E1512.
1215 /* If fiber link is down, check and save copper mode state */
1216 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1221 return marvell_read_status_page(phydev
, MII_M1111_COPPER
);
1224 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1230 * Some Marvell's phys have two modes: fiber and copper.
1231 * Both need to be suspended
1233 static int marvell_suspend(struct phy_device
*phydev
)
1237 /* Suspend the fiber mode first */
1238 if (!(phydev
->supported
& SUPPORTED_FIBRE
)) {
1239 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_FIBER
);
1243 /* With the page set, use the generic suspend */
1244 err
= genphy_suspend(phydev
);
1248 /* Then, the copper link */
1249 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1254 /* With the page set, use the generic suspend */
1255 return genphy_suspend(phydev
);
1258 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1264 * Some Marvell's phys have two modes: fiber and copper.
1265 * Both need to be resumed
1267 static int marvell_resume(struct phy_device
*phydev
)
1271 /* Resume the fiber mode first */
1272 if (!(phydev
->supported
& SUPPORTED_FIBRE
)) {
1273 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_FIBER
);
1277 /* With the page set, use the generic resume */
1278 err
= genphy_resume(phydev
);
1282 /* Then, the copper link */
1283 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1288 /* With the page set, use the generic resume */
1289 return genphy_resume(phydev
);
1292 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, MII_M1111_COPPER
);
1296 static int marvell_aneg_done(struct phy_device
*phydev
)
1298 int retval
= phy_read(phydev
, MII_M1011_PHY_STATUS
);
1299 return (retval
< 0) ? retval
: (retval
& MII_M1011_PHY_STATUS_RESOLVED
);
1302 static int m88e1121_did_interrupt(struct phy_device
*phydev
)
1306 imask
= phy_read(phydev
, MII_M1011_IEVENT
);
1308 if (imask
& MII_M1011_IMASK_INIT
)
1314 static void m88e1318_get_wol(struct phy_device
*phydev
, struct ethtool_wolinfo
*wol
)
1316 wol
->supported
= WAKE_MAGIC
;
1319 if (phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
1320 MII_88E1318S_PHY_WOL_PAGE
) < 0)
1323 if (phy_read(phydev
, MII_88E1318S_PHY_WOL_CTRL
) &
1324 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
)
1325 wol
->wolopts
|= WAKE_MAGIC
;
1327 if (phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x00) < 0)
1331 static int m88e1318_set_wol(struct phy_device
*phydev
, struct ethtool_wolinfo
*wol
)
1333 int err
, oldpage
, temp
;
1335 oldpage
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
1337 if (wol
->wolopts
& WAKE_MAGIC
) {
1338 /* Explicitly switch to page 0x00, just to be sure */
1339 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, 0x00);
1343 /* Enable the WOL interrupt */
1344 temp
= phy_read(phydev
, MII_88E1318S_PHY_CSIER
);
1345 temp
|= MII_88E1318S_PHY_CSIER_WOL_EIE
;
1346 err
= phy_write(phydev
, MII_88E1318S_PHY_CSIER
, temp
);
1350 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
1351 MII_88E1318S_PHY_LED_PAGE
);
1355 /* Setup LED[2] as interrupt pin (active low) */
1356 temp
= phy_read(phydev
, MII_88E1318S_PHY_LED_TCR
);
1357 temp
&= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT
;
1358 temp
|= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE
;
1359 temp
|= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW
;
1360 err
= phy_write(phydev
, MII_88E1318S_PHY_LED_TCR
, temp
);
1364 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
1365 MII_88E1318S_PHY_WOL_PAGE
);
1369 /* Store the device address for the magic packet */
1370 err
= phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD2
,
1371 ((phydev
->attached_dev
->dev_addr
[5] << 8) |
1372 phydev
->attached_dev
->dev_addr
[4]));
1375 err
= phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD1
,
1376 ((phydev
->attached_dev
->dev_addr
[3] << 8) |
1377 phydev
->attached_dev
->dev_addr
[2]));
1380 err
= phy_write(phydev
, MII_88E1318S_PHY_MAGIC_PACKET_WORD0
,
1381 ((phydev
->attached_dev
->dev_addr
[1] << 8) |
1382 phydev
->attached_dev
->dev_addr
[0]));
1386 /* Clear WOL status and enable magic packet matching */
1387 temp
= phy_read(phydev
, MII_88E1318S_PHY_WOL_CTRL
);
1388 temp
|= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
;
1389 temp
|= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
;
1390 err
= phy_write(phydev
, MII_88E1318S_PHY_WOL_CTRL
, temp
);
1394 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
1395 MII_88E1318S_PHY_WOL_PAGE
);
1399 /* Clear WOL status and disable magic packet matching */
1400 temp
= phy_read(phydev
, MII_88E1318S_PHY_WOL_CTRL
);
1401 temp
|= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS
;
1402 temp
&= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE
;
1403 err
= phy_write(phydev
, MII_88E1318S_PHY_WOL_CTRL
, temp
);
1408 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
, oldpage
);
1415 static int marvell_get_sset_count(struct phy_device
*phydev
)
1417 if (phydev
->supported
& SUPPORTED_FIBRE
)
1418 return ARRAY_SIZE(marvell_hw_stats
);
1420 return ARRAY_SIZE(marvell_hw_stats
) - NB_FIBER_STATS
;
1423 static void marvell_get_strings(struct phy_device
*phydev
, u8
*data
)
1427 for (i
= 0; i
< ARRAY_SIZE(marvell_hw_stats
); i
++) {
1428 memcpy(data
+ i
* ETH_GSTRING_LEN
,
1429 marvell_hw_stats
[i
].string
, ETH_GSTRING_LEN
);
1434 #define UINT64_MAX (u64)(~((u64)0))
1436 static u64
marvell_get_stat(struct phy_device
*phydev
, int i
)
1438 struct marvell_hw_stat stat
= marvell_hw_stats
[i
];
1439 struct marvell_priv
*priv
= phydev
->priv
;
1440 int err
, oldpage
, val
;
1443 oldpage
= phy_read(phydev
, MII_MARVELL_PHY_PAGE
);
1444 err
= phy_write(phydev
, MII_MARVELL_PHY_PAGE
,
1449 val
= phy_read(phydev
, stat
.reg
);
1453 val
= val
& ((1 << stat
.bits
) - 1);
1454 priv
->stats
[i
] += val
;
1455 ret
= priv
->stats
[i
];
1458 phy_write(phydev
, MII_MARVELL_PHY_PAGE
, oldpage
);
1463 static void marvell_get_stats(struct phy_device
*phydev
,
1464 struct ethtool_stats
*stats
, u64
*data
)
1468 for (i
= 0; i
< ARRAY_SIZE(marvell_hw_stats
); i
++)
1469 data
[i
] = marvell_get_stat(phydev
, i
);
1472 static int marvell_probe(struct phy_device
*phydev
)
1474 struct marvell_priv
*priv
;
1476 priv
= devm_kzalloc(&phydev
->mdio
.dev
, sizeof(*priv
), GFP_KERNEL
);
1480 phydev
->priv
= priv
;
1485 static struct phy_driver marvell_drivers
[] = {
1487 .phy_id
= MARVELL_PHY_ID_88E1101
,
1488 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1489 .name
= "Marvell 88E1101",
1490 .features
= PHY_GBIT_FEATURES
,
1491 .probe
= marvell_probe
,
1492 .flags
= PHY_HAS_INTERRUPT
,
1493 .config_init
= &marvell_config_init
,
1494 .config_aneg
= &marvell_config_aneg
,
1495 .read_status
= &genphy_read_status
,
1496 .ack_interrupt
= &marvell_ack_interrupt
,
1497 .config_intr
= &marvell_config_intr
,
1498 .resume
= &genphy_resume
,
1499 .suspend
= &genphy_suspend
,
1500 .get_sset_count
= marvell_get_sset_count
,
1501 .get_strings
= marvell_get_strings
,
1502 .get_stats
= marvell_get_stats
,
1505 .phy_id
= MARVELL_PHY_ID_88E1112
,
1506 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1507 .name
= "Marvell 88E1112",
1508 .features
= PHY_GBIT_FEATURES
,
1509 .flags
= PHY_HAS_INTERRUPT
,
1510 .probe
= marvell_probe
,
1511 .config_init
= &m88e1111_config_init
,
1512 .config_aneg
= &marvell_config_aneg
,
1513 .read_status
= &genphy_read_status
,
1514 .ack_interrupt
= &marvell_ack_interrupt
,
1515 .config_intr
= &marvell_config_intr
,
1516 .resume
= &genphy_resume
,
1517 .suspend
= &genphy_suspend
,
1518 .get_sset_count
= marvell_get_sset_count
,
1519 .get_strings
= marvell_get_strings
,
1520 .get_stats
= marvell_get_stats
,
1523 .phy_id
= MARVELL_PHY_ID_88E1111
,
1524 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1525 .name
= "Marvell 88E1111",
1526 .features
= PHY_GBIT_FEATURES
,
1527 .flags
= PHY_HAS_INTERRUPT
,
1528 .probe
= marvell_probe
,
1529 .config_init
= &m88e1111_config_init
,
1530 .config_aneg
= &m88e1111_config_aneg
,
1531 .read_status
= &marvell_read_status
,
1532 .ack_interrupt
= &marvell_ack_interrupt
,
1533 .config_intr
= &marvell_config_intr
,
1534 .resume
= &genphy_resume
,
1535 .suspend
= &genphy_suspend
,
1536 .get_sset_count
= marvell_get_sset_count
,
1537 .get_strings
= marvell_get_strings
,
1538 .get_stats
= marvell_get_stats
,
1541 .phy_id
= MARVELL_PHY_ID_88E1118
,
1542 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1543 .name
= "Marvell 88E1118",
1544 .features
= PHY_GBIT_FEATURES
,
1545 .flags
= PHY_HAS_INTERRUPT
,
1546 .probe
= marvell_probe
,
1547 .config_init
= &m88e1118_config_init
,
1548 .config_aneg
= &m88e1118_config_aneg
,
1549 .read_status
= &genphy_read_status
,
1550 .ack_interrupt
= &marvell_ack_interrupt
,
1551 .config_intr
= &marvell_config_intr
,
1552 .resume
= &genphy_resume
,
1553 .suspend
= &genphy_suspend
,
1554 .get_sset_count
= marvell_get_sset_count
,
1555 .get_strings
= marvell_get_strings
,
1556 .get_stats
= marvell_get_stats
,
1559 .phy_id
= MARVELL_PHY_ID_88E1121R
,
1560 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1561 .name
= "Marvell 88E1121R",
1562 .features
= PHY_GBIT_FEATURES
,
1563 .flags
= PHY_HAS_INTERRUPT
,
1564 .probe
= marvell_probe
,
1565 .config_init
= &m88e1121_config_init
,
1566 .config_aneg
= &m88e1121_config_aneg
,
1567 .read_status
= &marvell_read_status
,
1568 .ack_interrupt
= &marvell_ack_interrupt
,
1569 .config_intr
= &marvell_config_intr
,
1570 .did_interrupt
= &m88e1121_did_interrupt
,
1571 .resume
= &genphy_resume
,
1572 .suspend
= &genphy_suspend
,
1573 .get_sset_count
= marvell_get_sset_count
,
1574 .get_strings
= marvell_get_strings
,
1575 .get_stats
= marvell_get_stats
,
1578 .phy_id
= MARVELL_PHY_ID_88E1318S
,
1579 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1580 .name
= "Marvell 88E1318S",
1581 .features
= PHY_GBIT_FEATURES
,
1582 .flags
= PHY_HAS_INTERRUPT
,
1583 .probe
= marvell_probe
,
1584 .config_init
= &m88e1121_config_init
,
1585 .config_aneg
= &m88e1318_config_aneg
,
1586 .read_status
= &marvell_read_status
,
1587 .ack_interrupt
= &marvell_ack_interrupt
,
1588 .config_intr
= &marvell_config_intr
,
1589 .did_interrupt
= &m88e1121_did_interrupt
,
1590 .get_wol
= &m88e1318_get_wol
,
1591 .set_wol
= &m88e1318_set_wol
,
1592 .resume
= &genphy_resume
,
1593 .suspend
= &genphy_suspend
,
1594 .get_sset_count
= marvell_get_sset_count
,
1595 .get_strings
= marvell_get_strings
,
1596 .get_stats
= marvell_get_stats
,
1599 .phy_id
= MARVELL_PHY_ID_88E1145
,
1600 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1601 .name
= "Marvell 88E1145",
1602 .features
= PHY_GBIT_FEATURES
,
1603 .flags
= PHY_HAS_INTERRUPT
,
1604 .probe
= marvell_probe
,
1605 .config_init
= &m88e1145_config_init
,
1606 .config_aneg
= &marvell_config_aneg
,
1607 .read_status
= &genphy_read_status
,
1608 .ack_interrupt
= &marvell_ack_interrupt
,
1609 .config_intr
= &marvell_config_intr
,
1610 .resume
= &genphy_resume
,
1611 .suspend
= &genphy_suspend
,
1612 .get_sset_count
= marvell_get_sset_count
,
1613 .get_strings
= marvell_get_strings
,
1614 .get_stats
= marvell_get_stats
,
1617 .phy_id
= MARVELL_PHY_ID_88E1149R
,
1618 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1619 .name
= "Marvell 88E1149R",
1620 .features
= PHY_GBIT_FEATURES
,
1621 .flags
= PHY_HAS_INTERRUPT
,
1622 .probe
= marvell_probe
,
1623 .config_init
= &m88e1149_config_init
,
1624 .config_aneg
= &m88e1118_config_aneg
,
1625 .read_status
= &genphy_read_status
,
1626 .ack_interrupt
= &marvell_ack_interrupt
,
1627 .config_intr
= &marvell_config_intr
,
1628 .resume
= &genphy_resume
,
1629 .suspend
= &genphy_suspend
,
1630 .get_sset_count
= marvell_get_sset_count
,
1631 .get_strings
= marvell_get_strings
,
1632 .get_stats
= marvell_get_stats
,
1635 .phy_id
= MARVELL_PHY_ID_88E1240
,
1636 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1637 .name
= "Marvell 88E1240",
1638 .features
= PHY_GBIT_FEATURES
,
1639 .flags
= PHY_HAS_INTERRUPT
,
1640 .probe
= marvell_probe
,
1641 .config_init
= &m88e1111_config_init
,
1642 .config_aneg
= &marvell_config_aneg
,
1643 .read_status
= &genphy_read_status
,
1644 .ack_interrupt
= &marvell_ack_interrupt
,
1645 .config_intr
= &marvell_config_intr
,
1646 .resume
= &genphy_resume
,
1647 .suspend
= &genphy_suspend
,
1648 .get_sset_count
= marvell_get_sset_count
,
1649 .get_strings
= marvell_get_strings
,
1650 .get_stats
= marvell_get_stats
,
1653 .phy_id
= MARVELL_PHY_ID_88E1116R
,
1654 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1655 .name
= "Marvell 88E1116R",
1656 .features
= PHY_GBIT_FEATURES
,
1657 .flags
= PHY_HAS_INTERRUPT
,
1658 .probe
= marvell_probe
,
1659 .config_init
= &m88e1116r_config_init
,
1660 .config_aneg
= &genphy_config_aneg
,
1661 .read_status
= &genphy_read_status
,
1662 .ack_interrupt
= &marvell_ack_interrupt
,
1663 .config_intr
= &marvell_config_intr
,
1664 .resume
= &genphy_resume
,
1665 .suspend
= &genphy_suspend
,
1666 .get_sset_count
= marvell_get_sset_count
,
1667 .get_strings
= marvell_get_strings
,
1668 .get_stats
= marvell_get_stats
,
1671 .phy_id
= MARVELL_PHY_ID_88E1510
,
1672 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1673 .name
= "Marvell 88E1510",
1674 .features
= PHY_GBIT_FEATURES
| SUPPORTED_FIBRE
,
1675 .flags
= PHY_HAS_INTERRUPT
,
1676 .probe
= marvell_probe
,
1677 .config_init
= &m88e1510_config_init
,
1678 .config_aneg
= &m88e1510_config_aneg
,
1679 .read_status
= &marvell_read_status
,
1680 .ack_interrupt
= &marvell_ack_interrupt
,
1681 .config_intr
= &marvell_config_intr
,
1682 .did_interrupt
= &m88e1121_did_interrupt
,
1683 .resume
= &marvell_resume
,
1684 .suspend
= &marvell_suspend
,
1685 .get_sset_count
= marvell_get_sset_count
,
1686 .get_strings
= marvell_get_strings
,
1687 .get_stats
= marvell_get_stats
,
1690 .phy_id
= MARVELL_PHY_ID_88E1540
,
1691 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1692 .name
= "Marvell 88E1540",
1693 .features
= PHY_GBIT_FEATURES
,
1694 .flags
= PHY_HAS_INTERRUPT
,
1695 .probe
= marvell_probe
,
1696 .config_init
= &marvell_config_init
,
1697 .config_aneg
= &m88e1510_config_aneg
,
1698 .read_status
= &marvell_read_status
,
1699 .ack_interrupt
= &marvell_ack_interrupt
,
1700 .config_intr
= &marvell_config_intr
,
1701 .did_interrupt
= &m88e1121_did_interrupt
,
1702 .resume
= &genphy_resume
,
1703 .suspend
= &genphy_suspend
,
1704 .get_sset_count
= marvell_get_sset_count
,
1705 .get_strings
= marvell_get_strings
,
1706 .get_stats
= marvell_get_stats
,
1709 .phy_id
= MARVELL_PHY_ID_88E3016
,
1710 .phy_id_mask
= MARVELL_PHY_ID_MASK
,
1711 .name
= "Marvell 88E3016",
1712 .features
= PHY_BASIC_FEATURES
,
1713 .flags
= PHY_HAS_INTERRUPT
,
1714 .probe
= marvell_probe
,
1715 .config_aneg
= &genphy_config_aneg
,
1716 .config_init
= &m88e3016_config_init
,
1717 .aneg_done
= &marvell_aneg_done
,
1718 .read_status
= &marvell_read_status
,
1719 .ack_interrupt
= &marvell_ack_interrupt
,
1720 .config_intr
= &marvell_config_intr
,
1721 .did_interrupt
= &m88e1121_did_interrupt
,
1722 .resume
= &genphy_resume
,
1723 .suspend
= &genphy_suspend
,
1724 .get_sset_count
= marvell_get_sset_count
,
1725 .get_strings
= marvell_get_strings
,
1726 .get_stats
= marvell_get_stats
,
1730 module_phy_driver(marvell_drivers
);
1732 static struct mdio_device_id __maybe_unused marvell_tbl
[] = {
1733 { MARVELL_PHY_ID_88E1101
, MARVELL_PHY_ID_MASK
},
1734 { MARVELL_PHY_ID_88E1112
, MARVELL_PHY_ID_MASK
},
1735 { MARVELL_PHY_ID_88E1111
, MARVELL_PHY_ID_MASK
},
1736 { MARVELL_PHY_ID_88E1118
, MARVELL_PHY_ID_MASK
},
1737 { MARVELL_PHY_ID_88E1121R
, MARVELL_PHY_ID_MASK
},
1738 { MARVELL_PHY_ID_88E1145
, MARVELL_PHY_ID_MASK
},
1739 { MARVELL_PHY_ID_88E1149R
, MARVELL_PHY_ID_MASK
},
1740 { MARVELL_PHY_ID_88E1240
, MARVELL_PHY_ID_MASK
},
1741 { MARVELL_PHY_ID_88E1318S
, MARVELL_PHY_ID_MASK
},
1742 { MARVELL_PHY_ID_88E1116R
, MARVELL_PHY_ID_MASK
},
1743 { MARVELL_PHY_ID_88E1510
, MARVELL_PHY_ID_MASK
},
1744 { MARVELL_PHY_ID_88E1540
, MARVELL_PHY_ID_MASK
},
1745 { MARVELL_PHY_ID_88E3016
, MARVELL_PHY_ID_MASK
},
1749 MODULE_DEVICE_TABLE(mdio
, marvell_tbl
);