1 // SPDX-License-Identifier: GPL-2.0+
2 /* drivers/net/phy/realtek.c
4 * Driver for Realtek PHYs
6 * Author: Johnson Leung <r58129@freescale.com>
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 #include <linux/bitops.h>
12 #include <linux/phy.h>
13 #include <linux/module.h>
14 #include <linux/delay.h>
15 #include <linux/clk.h>
17 #define RTL821x_PHYSR 0x11
18 #define RTL821x_PHYSR_DUPLEX BIT(13)
19 #define RTL821x_PHYSR_SPEED GENMASK(15, 14)
21 #define RTL821x_INER 0x12
22 #define RTL8211B_INER_INIT 0x6400
23 #define RTL8211E_INER_LINK_STATUS BIT(10)
24 #define RTL8211F_INER_LINK_STATUS BIT(4)
26 #define RTL821x_INSR 0x13
28 #define RTL821x_EXT_PAGE_SELECT 0x1e
29 #define RTL821x_PAGE_SELECT 0x1f
31 #define RTL8211F_PHYCR1 0x18
32 #define RTL8211F_PHYCR2 0x19
33 #define RTL8211F_INSR 0x1d
35 #define RTL8211F_LEDCR 0x10
36 #define RTL8211F_LEDCR_MODE BIT(15)
37 #define RTL8211F_LEDCR_ACT_TXRX BIT(4)
38 #define RTL8211F_LEDCR_LINK_1000 BIT(3)
39 #define RTL8211F_LEDCR_LINK_100 BIT(1)
40 #define RTL8211F_LEDCR_LINK_10 BIT(0)
41 #define RTL8211F_LEDCR_MASK GENMASK(4, 0)
42 #define RTL8211F_LEDCR_SHIFT 5
44 #define RTL8211F_TX_DELAY BIT(8)
45 #define RTL8211F_RX_DELAY BIT(3)
47 #define RTL8211F_ALDPS_PLL_OFF BIT(1)
48 #define RTL8211F_ALDPS_ENABLE BIT(2)
49 #define RTL8211F_ALDPS_XTAL_OFF BIT(12)
51 #define RTL8211E_CTRL_DELAY BIT(13)
52 #define RTL8211E_TX_DELAY BIT(12)
53 #define RTL8211E_RX_DELAY BIT(11)
55 #define RTL8211F_CLKOUT_EN BIT(0)
57 #define RTL8201F_ISR 0x1e
58 #define RTL8201F_ISR_ANERR BIT(15)
59 #define RTL8201F_ISR_DUPLEX BIT(13)
60 #define RTL8201F_ISR_LINK BIT(11)
61 #define RTL8201F_ISR_MASK (RTL8201F_ISR_ANERR | \
62 RTL8201F_ISR_DUPLEX | \
64 #define RTL8201F_IER 0x13
66 #define RTL822X_VND1_SERDES_OPTION 0x697a
67 #define RTL822X_VND1_SERDES_OPTION_MODE_MASK GENMASK(5, 0)
68 #define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII 0
69 #define RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX 2
71 #define RTL822X_VND1_SERDES_CTRL3 0x7580
72 #define RTL822X_VND1_SERDES_CTRL3_MODE_MASK GENMASK(5, 0)
73 #define RTL822X_VND1_SERDES_CTRL3_MODE_SGMII 0x02
74 #define RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX 0x16
76 /* RTL822X_VND2_XXXXX registers are only accessible when phydev->is_c45
77 * is set, they cannot be accessed by C45-over-C22.
79 #define RTL822X_VND2_GBCR 0xa412
81 #define RTL822X_VND2_GANLPAR 0xa414
83 #define RTL8366RB_POWER_SAVE 0x15
84 #define RTL8366RB_POWER_SAVE_ON BIT(12)
86 #define RTL9000A_GINMR 0x14
87 #define RTL9000A_GINMR_LINK_STATUS BIT(4)
89 #define RTL_VND2_PHYSR 0xa434
90 #define RTL_VND2_PHYSR_DUPLEX BIT(3)
91 #define RTL_VND2_PHYSR_SPEEDL GENMASK(5, 4)
92 #define RTL_VND2_PHYSR_SPEEDH GENMASK(10, 9)
93 #define RTL_VND2_PHYSR_MASTER BIT(11)
94 #define RTL_VND2_PHYSR_SPEED_MASK (RTL_VND2_PHYSR_SPEEDL | RTL_VND2_PHYSR_SPEEDH)
96 #define RTL_GENERIC_PHYID 0x001cc800
97 #define RTL_8211FVD_PHYID 0x001cc878
98 #define RTL_8221B 0x001cc840
99 #define RTL_8221B_VB_CG 0x001cc849
100 #define RTL_8221B_VN_CG 0x001cc84a
101 #define RTL_8251B 0x001cc862
103 #define RTL8211F_LED_COUNT 3
105 MODULE_DESCRIPTION("Realtek PHY driver");
106 MODULE_AUTHOR("Johnson Leung");
107 MODULE_LICENSE("GPL");
109 struct rtl821x_priv
{
116 static int rtl821x_read_page(struct phy_device
*phydev
)
118 return __phy_read(phydev
, RTL821x_PAGE_SELECT
);
121 static int rtl821x_write_page(struct phy_device
*phydev
, int page
)
123 return __phy_write(phydev
, RTL821x_PAGE_SELECT
, page
);
126 static int rtl821x_probe(struct phy_device
*phydev
)
128 struct device
*dev
= &phydev
->mdio
.dev
;
129 struct rtl821x_priv
*priv
;
130 u32 phy_id
= phydev
->drv
->phy_id
;
133 priv
= devm_kzalloc(dev
, sizeof(*priv
), GFP_KERNEL
);
137 priv
->clk
= devm_clk_get_optional_enabled(dev
, NULL
);
138 if (IS_ERR(priv
->clk
))
139 return dev_err_probe(dev
, PTR_ERR(priv
->clk
),
140 "failed to get phy clock\n");
142 ret
= phy_read_paged(phydev
, 0xa43, RTL8211F_PHYCR1
);
146 priv
->phycr1
= ret
& (RTL8211F_ALDPS_PLL_OFF
| RTL8211F_ALDPS_ENABLE
| RTL8211F_ALDPS_XTAL_OFF
);
147 if (of_property_read_bool(dev
->of_node
, "realtek,aldps-enable"))
148 priv
->phycr1
|= RTL8211F_ALDPS_PLL_OFF
| RTL8211F_ALDPS_ENABLE
| RTL8211F_ALDPS_XTAL_OFF
;
150 priv
->has_phycr2
= !(phy_id
== RTL_8211FVD_PHYID
);
151 if (priv
->has_phycr2
) {
152 ret
= phy_read_paged(phydev
, 0xa43, RTL8211F_PHYCR2
);
156 priv
->phycr2
= ret
& RTL8211F_CLKOUT_EN
;
157 if (of_property_read_bool(dev
->of_node
, "realtek,clkout-disable"))
158 priv
->phycr2
&= ~RTL8211F_CLKOUT_EN
;
166 static int rtl8201_ack_interrupt(struct phy_device
*phydev
)
170 err
= phy_read(phydev
, RTL8201F_ISR
);
172 return (err
< 0) ? err
: 0;
175 static int rtl821x_ack_interrupt(struct phy_device
*phydev
)
179 err
= phy_read(phydev
, RTL821x_INSR
);
181 return (err
< 0) ? err
: 0;
184 static int rtl8211f_ack_interrupt(struct phy_device
*phydev
)
188 err
= phy_read_paged(phydev
, 0xa43, RTL8211F_INSR
);
190 return (err
< 0) ? err
: 0;
193 static int rtl8201_config_intr(struct phy_device
*phydev
)
198 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
199 err
= rtl8201_ack_interrupt(phydev
);
203 val
= BIT(13) | BIT(12) | BIT(11);
204 err
= phy_write_paged(phydev
, 0x7, RTL8201F_IER
, val
);
207 err
= phy_write_paged(phydev
, 0x7, RTL8201F_IER
, val
);
211 err
= rtl8201_ack_interrupt(phydev
);
217 static int rtl8211b_config_intr(struct phy_device
*phydev
)
221 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
222 err
= rtl821x_ack_interrupt(phydev
);
226 err
= phy_write(phydev
, RTL821x_INER
,
229 err
= phy_write(phydev
, RTL821x_INER
, 0);
233 err
= rtl821x_ack_interrupt(phydev
);
239 static int rtl8211e_config_intr(struct phy_device
*phydev
)
243 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
244 err
= rtl821x_ack_interrupt(phydev
);
248 err
= phy_write(phydev
, RTL821x_INER
,
249 RTL8211E_INER_LINK_STATUS
);
251 err
= phy_write(phydev
, RTL821x_INER
, 0);
255 err
= rtl821x_ack_interrupt(phydev
);
261 static int rtl8211f_config_intr(struct phy_device
*phydev
)
266 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
267 err
= rtl8211f_ack_interrupt(phydev
);
271 val
= RTL8211F_INER_LINK_STATUS
;
272 err
= phy_write_paged(phydev
, 0xa42, RTL821x_INER
, val
);
275 err
= phy_write_paged(phydev
, 0xa42, RTL821x_INER
, val
);
279 err
= rtl8211f_ack_interrupt(phydev
);
285 static irqreturn_t
rtl8201_handle_interrupt(struct phy_device
*phydev
)
289 irq_status
= phy_read(phydev
, RTL8201F_ISR
);
290 if (irq_status
< 0) {
295 if (!(irq_status
& RTL8201F_ISR_MASK
))
298 phy_trigger_machine(phydev
);
303 static irqreturn_t
rtl821x_handle_interrupt(struct phy_device
*phydev
)
305 int irq_status
, irq_enabled
;
307 irq_status
= phy_read(phydev
, RTL821x_INSR
);
308 if (irq_status
< 0) {
313 irq_enabled
= phy_read(phydev
, RTL821x_INER
);
314 if (irq_enabled
< 0) {
319 if (!(irq_status
& irq_enabled
))
322 phy_trigger_machine(phydev
);
327 static irqreturn_t
rtl8211f_handle_interrupt(struct phy_device
*phydev
)
331 irq_status
= phy_read_paged(phydev
, 0xa43, RTL8211F_INSR
);
332 if (irq_status
< 0) {
337 if (!(irq_status
& RTL8211F_INER_LINK_STATUS
))
340 phy_trigger_machine(phydev
);
345 static int rtl8211_config_aneg(struct phy_device
*phydev
)
349 ret
= genphy_config_aneg(phydev
);
353 /* Quirk was copied from vendor driver. Unfortunately it includes no
354 * description of the magic numbers.
356 if (phydev
->speed
== SPEED_100
&& phydev
->autoneg
== AUTONEG_DISABLE
) {
357 phy_write(phydev
, 0x17, 0x2138);
358 phy_write(phydev
, 0x0e, 0x0260);
360 phy_write(phydev
, 0x17, 0x2108);
361 phy_write(phydev
, 0x0e, 0x0000);
367 static int rtl8211c_config_init(struct phy_device
*phydev
)
369 /* RTL8211C has an issue when operating in Gigabit slave mode */
370 return phy_set_bits(phydev
, MII_CTRL1000
,
371 CTL1000_ENABLE_MASTER
| CTL1000_AS_MASTER
);
374 static int rtl8211f_config_init(struct phy_device
*phydev
)
376 struct rtl821x_priv
*priv
= phydev
->priv
;
377 struct device
*dev
= &phydev
->mdio
.dev
;
378 u16 val_txdly
, val_rxdly
;
381 ret
= phy_modify_paged_changed(phydev
, 0xa43, RTL8211F_PHYCR1
,
382 RTL8211F_ALDPS_PLL_OFF
| RTL8211F_ALDPS_ENABLE
| RTL8211F_ALDPS_XTAL_OFF
,
385 dev_err(dev
, "aldps mode configuration failed: %pe\n",
390 switch (phydev
->interface
) {
391 case PHY_INTERFACE_MODE_RGMII
:
396 case PHY_INTERFACE_MODE_RGMII_RXID
:
398 val_rxdly
= RTL8211F_RX_DELAY
;
401 case PHY_INTERFACE_MODE_RGMII_TXID
:
402 val_txdly
= RTL8211F_TX_DELAY
;
406 case PHY_INTERFACE_MODE_RGMII_ID
:
407 val_txdly
= RTL8211F_TX_DELAY
;
408 val_rxdly
= RTL8211F_RX_DELAY
;
411 default: /* the rest of the modes imply leaving delay as is. */
415 ret
= phy_modify_paged_changed(phydev
, 0xd08, 0x11, RTL8211F_TX_DELAY
,
418 dev_err(dev
, "Failed to update the TX delay register\n");
422 "%s 2ns TX delay (and changing the value from pin-strapping RXD1 or the bootloader)\n",
423 val_txdly
? "Enabling" : "Disabling");
426 "2ns TX delay was already %s (by pin-strapping RXD1 or bootloader configuration)\n",
427 val_txdly
? "enabled" : "disabled");
430 ret
= phy_modify_paged_changed(phydev
, 0xd08, 0x15, RTL8211F_RX_DELAY
,
433 dev_err(dev
, "Failed to update the RX delay register\n");
437 "%s 2ns RX delay (and changing the value from pin-strapping RXD0 or the bootloader)\n",
438 val_rxdly
? "Enabling" : "Disabling");
441 "2ns RX delay was already %s (by pin-strapping RXD0 or bootloader configuration)\n",
442 val_rxdly
? "enabled" : "disabled");
445 if (priv
->has_phycr2
) {
446 ret
= phy_modify_paged(phydev
, 0xa43, RTL8211F_PHYCR2
,
447 RTL8211F_CLKOUT_EN
, priv
->phycr2
);
449 dev_err(dev
, "clkout configuration failed: %pe\n",
454 return genphy_soft_reset(phydev
);
460 static int rtl821x_suspend(struct phy_device
*phydev
)
462 struct rtl821x_priv
*priv
= phydev
->priv
;
465 if (!phydev
->wol_enabled
) {
466 ret
= genphy_suspend(phydev
);
471 clk_disable_unprepare(priv
->clk
);
477 static int rtl821x_resume(struct phy_device
*phydev
)
479 struct rtl821x_priv
*priv
= phydev
->priv
;
482 if (!phydev
->wol_enabled
)
483 clk_prepare_enable(priv
->clk
);
485 ret
= genphy_resume(phydev
);
494 static int rtl8211f_led_hw_is_supported(struct phy_device
*phydev
, u8 index
,
497 const unsigned long mask
= BIT(TRIGGER_NETDEV_LINK_10
) |
498 BIT(TRIGGER_NETDEV_LINK_100
) |
499 BIT(TRIGGER_NETDEV_LINK_1000
) |
500 BIT(TRIGGER_NETDEV_RX
) |
501 BIT(TRIGGER_NETDEV_TX
);
503 /* The RTL8211F PHY supports these LED settings on up to three LEDs:
504 * - Link: Configurable subset of 10/100/1000 link rates
505 * - Active: Blink on activity, RX or TX is not differentiated
506 * The Active option has two modes, A and B:
507 * - A: Link and Active indication at configurable, but matching,
508 * subset of 10/100/1000 link rates
509 * - B: Link indication at configurable subset of 10/100/1000 link
510 * rates and Active indication always at all three 10+100+1000
512 * This code currently uses mode B only.
515 if (index
>= RTL8211F_LED_COUNT
)
518 /* Filter out any other unsupported triggers. */
522 /* RX and TX are not differentiated, either both are set or not set. */
523 if (!(rules
& BIT(TRIGGER_NETDEV_RX
)) ^ !(rules
& BIT(TRIGGER_NETDEV_TX
)))
529 static int rtl8211f_led_hw_control_get(struct phy_device
*phydev
, u8 index
,
530 unsigned long *rules
)
534 if (index
>= RTL8211F_LED_COUNT
)
537 val
= phy_read_paged(phydev
, 0xd04, RTL8211F_LEDCR
);
541 val
>>= RTL8211F_LEDCR_SHIFT
* index
;
542 val
&= RTL8211F_LEDCR_MASK
;
544 if (val
& RTL8211F_LEDCR_LINK_10
)
545 set_bit(TRIGGER_NETDEV_LINK_10
, rules
);
547 if (val
& RTL8211F_LEDCR_LINK_100
)
548 set_bit(TRIGGER_NETDEV_LINK_100
, rules
);
550 if (val
& RTL8211F_LEDCR_LINK_1000
)
551 set_bit(TRIGGER_NETDEV_LINK_1000
, rules
);
553 if (val
& RTL8211F_LEDCR_ACT_TXRX
) {
554 set_bit(TRIGGER_NETDEV_RX
, rules
);
555 set_bit(TRIGGER_NETDEV_TX
, rules
);
561 static int rtl8211f_led_hw_control_set(struct phy_device
*phydev
, u8 index
,
564 const u16 mask
= RTL8211F_LEDCR_MASK
<< (RTL8211F_LEDCR_SHIFT
* index
);
567 if (index
>= RTL8211F_LED_COUNT
)
570 if (test_bit(TRIGGER_NETDEV_LINK_10
, &rules
))
571 reg
|= RTL8211F_LEDCR_LINK_10
;
573 if (test_bit(TRIGGER_NETDEV_LINK_100
, &rules
))
574 reg
|= RTL8211F_LEDCR_LINK_100
;
576 if (test_bit(TRIGGER_NETDEV_LINK_1000
, &rules
))
577 reg
|= RTL8211F_LEDCR_LINK_1000
;
579 if (test_bit(TRIGGER_NETDEV_RX
, &rules
) ||
580 test_bit(TRIGGER_NETDEV_TX
, &rules
)) {
581 reg
|= RTL8211F_LEDCR_ACT_TXRX
;
584 reg
<<= RTL8211F_LEDCR_SHIFT
* index
;
585 reg
|= RTL8211F_LEDCR_MODE
; /* Mode B */
587 return phy_modify_paged(phydev
, 0xd04, RTL8211F_LEDCR
, mask
, reg
);
590 static int rtl8211e_config_init(struct phy_device
*phydev
)
592 int ret
= 0, oldpage
;
595 /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */
596 switch (phydev
->interface
) {
597 case PHY_INTERFACE_MODE_RGMII
:
598 val
= RTL8211E_CTRL_DELAY
| 0;
600 case PHY_INTERFACE_MODE_RGMII_ID
:
601 val
= RTL8211E_CTRL_DELAY
| RTL8211E_TX_DELAY
| RTL8211E_RX_DELAY
;
603 case PHY_INTERFACE_MODE_RGMII_RXID
:
604 val
= RTL8211E_CTRL_DELAY
| RTL8211E_RX_DELAY
;
606 case PHY_INTERFACE_MODE_RGMII_TXID
:
607 val
= RTL8211E_CTRL_DELAY
| RTL8211E_TX_DELAY
;
609 default: /* the rest of the modes imply leaving delays as is. */
613 /* According to a sample driver there is a 0x1c config register on the
614 * 0xa4 extension page (0x7) layout. It can be used to disable/enable
615 * the RX/TX delays otherwise controlled by RXDLY/TXDLY pins.
616 * The configuration register definition:
618 * 13 = Force Tx RX Delay controlled by bit12 bit11,
619 * 12 = RX Delay, 11 = TX Delay
620 * 10:0 = Test && debug settings reserved by realtek
622 oldpage
= phy_select_page(phydev
, 0x7);
624 goto err_restore_page
;
626 ret
= __phy_write(phydev
, RTL821x_EXT_PAGE_SELECT
, 0xa4);
628 goto err_restore_page
;
630 ret
= __phy_modify(phydev
, 0x1c, RTL8211E_CTRL_DELAY
631 | RTL8211E_TX_DELAY
| RTL8211E_RX_DELAY
,
635 return phy_restore_page(phydev
, oldpage
, ret
);
638 static int rtl8211b_suspend(struct phy_device
*phydev
)
640 phy_write(phydev
, MII_MMD_DATA
, BIT(9));
642 return genphy_suspend(phydev
);
645 static int rtl8211b_resume(struct phy_device
*phydev
)
647 phy_write(phydev
, MII_MMD_DATA
, 0);
649 return genphy_resume(phydev
);
652 static int rtl8366rb_config_init(struct phy_device
*phydev
)
656 ret
= phy_set_bits(phydev
, RTL8366RB_POWER_SAVE
,
657 RTL8366RB_POWER_SAVE_ON
);
659 dev_err(&phydev
->mdio
.dev
,
660 "error enabling power management\n");
666 /* get actual speed to cover the downshift case */
667 static void rtlgen_decode_physr(struct phy_device
*phydev
, int val
)
673 if (val
& RTL_VND2_PHYSR_DUPLEX
)
674 phydev
->duplex
= DUPLEX_FULL
;
676 phydev
->duplex
= DUPLEX_HALF
;
678 switch (val
& RTL_VND2_PHYSR_SPEED_MASK
) {
680 phydev
->speed
= SPEED_10
;
683 phydev
->speed
= SPEED_100
;
686 phydev
->speed
= SPEED_1000
;
689 phydev
->speed
= SPEED_10000
;
692 phydev
->speed
= SPEED_2500
;
695 phydev
->speed
= SPEED_5000
;
705 if (phydev
->speed
>= 1000) {
706 if (val
& RTL_VND2_PHYSR_MASTER
)
707 phydev
->master_slave_state
= MASTER_SLAVE_STATE_MASTER
;
709 phydev
->master_slave_state
= MASTER_SLAVE_STATE_SLAVE
;
711 phydev
->master_slave_state
= MASTER_SLAVE_STATE_UNSUPPORTED
;
715 static int rtlgen_read_status(struct phy_device
*phydev
)
719 ret
= genphy_read_status(phydev
);
726 val
= phy_read_paged(phydev
, 0xa43, 0x12);
730 rtlgen_decode_physr(phydev
, val
);
735 static int rtlgen_read_mmd(struct phy_device
*phydev
, int devnum
, u16 regnum
)
739 if (devnum
== MDIO_MMD_PCS
&& regnum
== MDIO_PCS_EEE_ABLE
) {
740 rtl821x_write_page(phydev
, 0xa5c);
741 ret
= __phy_read(phydev
, 0x12);
742 rtl821x_write_page(phydev
, 0);
743 } else if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_ADV
) {
744 rtl821x_write_page(phydev
, 0xa5d);
745 ret
= __phy_read(phydev
, 0x10);
746 rtl821x_write_page(phydev
, 0);
747 } else if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_LPABLE
) {
748 rtl821x_write_page(phydev
, 0xa5d);
749 ret
= __phy_read(phydev
, 0x11);
750 rtl821x_write_page(phydev
, 0);
758 static int rtlgen_write_mmd(struct phy_device
*phydev
, int devnum
, u16 regnum
,
763 if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_ADV
) {
764 rtl821x_write_page(phydev
, 0xa5d);
765 ret
= __phy_write(phydev
, 0x10, val
);
766 rtl821x_write_page(phydev
, 0);
774 static int rtl822x_read_mmd(struct phy_device
*phydev
, int devnum
, u16 regnum
)
776 int ret
= rtlgen_read_mmd(phydev
, devnum
, regnum
);
778 if (ret
!= -EOPNOTSUPP
)
781 if (devnum
== MDIO_MMD_PCS
&& regnum
== MDIO_PCS_EEE_ABLE2
) {
782 rtl821x_write_page(phydev
, 0xa6e);
783 ret
= __phy_read(phydev
, 0x16);
784 rtl821x_write_page(phydev
, 0);
785 } else if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_ADV2
) {
786 rtl821x_write_page(phydev
, 0xa6d);
787 ret
= __phy_read(phydev
, 0x12);
788 rtl821x_write_page(phydev
, 0);
789 } else if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_LPABLE2
) {
790 rtl821x_write_page(phydev
, 0xa6d);
791 ret
= __phy_read(phydev
, 0x10);
792 rtl821x_write_page(phydev
, 0);
798 static int rtl822x_write_mmd(struct phy_device
*phydev
, int devnum
, u16 regnum
,
801 int ret
= rtlgen_write_mmd(phydev
, devnum
, regnum
, val
);
803 if (ret
!= -EOPNOTSUPP
)
806 if (devnum
== MDIO_MMD_AN
&& regnum
== MDIO_AN_EEE_ADV2
) {
807 rtl821x_write_page(phydev
, 0xa6d);
808 ret
= __phy_write(phydev
, 0x12, val
);
809 rtl821x_write_page(phydev
, 0);
815 static int rtl822xb_config_init(struct phy_device
*phydev
)
817 bool has_2500
, has_sgmii
;
821 has_2500
= test_bit(PHY_INTERFACE_MODE_2500BASEX
,
822 phydev
->host_interfaces
) ||
823 phydev
->interface
== PHY_INTERFACE_MODE_2500BASEX
;
825 has_sgmii
= test_bit(PHY_INTERFACE_MODE_SGMII
,
826 phydev
->host_interfaces
) ||
827 phydev
->interface
== PHY_INTERFACE_MODE_SGMII
;
829 /* fill in possible interfaces */
830 __assign_bit(PHY_INTERFACE_MODE_2500BASEX
, phydev
->possible_interfaces
,
832 __assign_bit(PHY_INTERFACE_MODE_SGMII
, phydev
->possible_interfaces
,
835 if (!has_2500
&& !has_sgmii
)
838 /* determine SerDes option mode */
839 if (has_2500
&& !has_sgmii
) {
840 mode
= RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX
;
841 phydev
->rate_matching
= RATE_MATCH_PAUSE
;
843 mode
= RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII
;
844 phydev
->rate_matching
= RATE_MATCH_NONE
;
847 /* the following sequence with magic numbers sets up the SerDes
850 ret
= phy_write_mmd(phydev
, MDIO_MMD_VEND1
, 0x75f3, 0);
854 ret
= phy_modify_mmd_changed(phydev
, MDIO_MMD_VEND1
,
855 RTL822X_VND1_SERDES_OPTION
,
856 RTL822X_VND1_SERDES_OPTION_MODE_MASK
,
861 ret
= phy_write_mmd(phydev
, MDIO_MMD_VEND1
, 0x6a04, 0x0503);
865 ret
= phy_write_mmd(phydev
, MDIO_MMD_VEND1
, 0x6f10, 0xd455);
869 return phy_write_mmd(phydev
, MDIO_MMD_VEND1
, 0x6f11, 0x8020);
872 static int rtl822xb_get_rate_matching(struct phy_device
*phydev
,
873 phy_interface_t iface
)
877 /* Only rate matching at 2500base-x */
878 if (iface
!= PHY_INTERFACE_MODE_2500BASEX
)
879 return RATE_MATCH_NONE
;
881 val
= phy_read_mmd(phydev
, MDIO_MMD_VEND1
, RTL822X_VND1_SERDES_OPTION
);
885 if ((val
& RTL822X_VND1_SERDES_OPTION_MODE_MASK
) ==
886 RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX
)
887 return RATE_MATCH_PAUSE
;
889 /* RTL822X_VND1_SERDES_OPTION_MODE_2500BASEX_SGMII */
890 return RATE_MATCH_NONE
;
893 static int rtl822x_get_features(struct phy_device
*phydev
)
897 val
= phy_read_paged(phydev
, 0xa61, 0x13);
901 linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT
,
902 phydev
->supported
, val
& MDIO_PMA_SPEED_2_5G
);
903 linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT
,
904 phydev
->supported
, val
& MDIO_PMA_SPEED_5G
);
905 linkmode_mod_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT
,
906 phydev
->supported
, val
& MDIO_SPEED_10G
);
908 return genphy_read_abilities(phydev
);
911 static int rtl822x_config_aneg(struct phy_device
*phydev
)
915 if (phydev
->autoneg
== AUTONEG_ENABLE
) {
916 u16 adv
= linkmode_adv_to_mii_10gbt_adv_t(phydev
->advertising
);
918 ret
= phy_modify_paged_changed(phydev
, 0xa5d, 0x12,
919 MDIO_AN_10GBT_CTRL_ADV2_5G
|
920 MDIO_AN_10GBT_CTRL_ADV5G
,
926 return __genphy_config_aneg(phydev
, ret
);
929 static void rtl822xb_update_interface(struct phy_device
*phydev
)
936 /* Change interface according to serdes mode */
937 val
= phy_read_mmd(phydev
, MDIO_MMD_VEND1
, RTL822X_VND1_SERDES_CTRL3
);
941 switch (val
& RTL822X_VND1_SERDES_CTRL3_MODE_MASK
) {
942 case RTL822X_VND1_SERDES_CTRL3_MODE_2500BASEX
:
943 phydev
->interface
= PHY_INTERFACE_MODE_2500BASEX
;
945 case RTL822X_VND1_SERDES_CTRL3_MODE_SGMII
:
946 phydev
->interface
= PHY_INTERFACE_MODE_SGMII
;
951 static int rtl822x_read_status(struct phy_device
*phydev
)
955 ret
= rtlgen_read_status(phydev
);
959 if (phydev
->autoneg
== AUTONEG_DISABLE
||
960 !phydev
->autoneg_complete
) {
961 mii_10gbt_stat_mod_linkmode_lpa_t(phydev
->lp_advertising
, 0);
965 lpadv
= phy_read_paged(phydev
, 0xa5d, 0x13);
969 mii_10gbt_stat_mod_linkmode_lpa_t(phydev
->lp_advertising
, lpadv
);
974 static int rtl822xb_read_status(struct phy_device
*phydev
)
978 ret
= rtl822x_read_status(phydev
);
982 rtl822xb_update_interface(phydev
);
987 static int rtl822x_c45_get_features(struct phy_device
*phydev
)
989 linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT
,
992 return genphy_c45_pma_read_abilities(phydev
);
995 static int rtl822x_c45_config_aneg(struct phy_device
*phydev
)
997 bool changed
= false;
1000 if (phydev
->autoneg
== AUTONEG_DISABLE
)
1001 return genphy_c45_pma_setup_forced(phydev
);
1003 ret
= genphy_c45_an_config_aneg(phydev
);
1009 val
= linkmode_adv_to_mii_ctrl1000_t(phydev
->advertising
);
1011 /* Vendor register as C45 has no standardized support for 1000BaseT */
1012 ret
= phy_modify_mmd_changed(phydev
, MDIO_MMD_VEND2
, RTL822X_VND2_GBCR
,
1013 ADVERTISE_1000FULL
, val
);
1019 return genphy_c45_check_and_restart_aneg(phydev
, changed
);
1022 static int rtl822x_c45_read_status(struct phy_device
*phydev
)
1026 ret
= genphy_c45_read_status(phydev
);
1030 if (phydev
->autoneg
== AUTONEG_DISABLE
||
1031 !genphy_c45_aneg_done(phydev
))
1032 mii_stat1000_mod_linkmode_lpa_t(phydev
->lp_advertising
, 0);
1034 /* Vendor register as C45 has no standardized support for 1000BaseT */
1035 if (phydev
->autoneg
== AUTONEG_ENABLE
) {
1036 val
= phy_read_mmd(phydev
, MDIO_MMD_VEND2
,
1037 RTL822X_VND2_GANLPAR
);
1041 mii_stat1000_mod_linkmode_lpa_t(phydev
->lp_advertising
, val
);
1047 /* Read actual speed from vendor register. */
1048 val
= phy_read_mmd(phydev
, MDIO_MMD_VEND2
, RTL_VND2_PHYSR
);
1052 rtlgen_decode_physr(phydev
, val
);
1057 static int rtl822xb_c45_read_status(struct phy_device
*phydev
)
1061 ret
= rtl822x_c45_read_status(phydev
);
1065 rtl822xb_update_interface(phydev
);
1070 static bool rtlgen_supports_2_5gbps(struct phy_device
*phydev
)
1074 phy_write(phydev
, RTL821x_PAGE_SELECT
, 0xa61);
1075 val
= phy_read(phydev
, 0x13);
1076 phy_write(phydev
, RTL821x_PAGE_SELECT
, 0);
1078 return val
>= 0 && val
& MDIO_PMA_SPEED_2_5G
;
1081 /* On internal PHY's MMD reads over C22 always return 0.
1082 * Check a MMD register which is known to be non-zero.
1084 static bool rtlgen_supports_mmd(struct phy_device
*phydev
)
1088 phy_lock_mdio_bus(phydev
);
1089 __phy_write(phydev
, MII_MMD_CTRL
, MDIO_MMD_PCS
);
1090 __phy_write(phydev
, MII_MMD_DATA
, MDIO_PCS_EEE_ABLE
);
1091 __phy_write(phydev
, MII_MMD_CTRL
, MDIO_MMD_PCS
| MII_MMD_CTRL_NOINCR
);
1092 val
= __phy_read(phydev
, MII_MMD_DATA
);
1093 phy_unlock_mdio_bus(phydev
);
1098 static int rtlgen_match_phy_device(struct phy_device
*phydev
)
1100 return phydev
->phy_id
== RTL_GENERIC_PHYID
&&
1101 !rtlgen_supports_2_5gbps(phydev
);
1104 static int rtl8226_match_phy_device(struct phy_device
*phydev
)
1106 return phydev
->phy_id
== RTL_GENERIC_PHYID
&&
1107 rtlgen_supports_2_5gbps(phydev
) &&
1108 rtlgen_supports_mmd(phydev
);
1111 static int rtlgen_is_c45_match(struct phy_device
*phydev
, unsigned int id
,
1115 return is_c45
&& (id
== phydev
->c45_ids
.device_ids
[1]);
1117 return !is_c45
&& (id
== phydev
->phy_id
);
1120 static int rtl8221b_match_phy_device(struct phy_device
*phydev
)
1122 return phydev
->phy_id
== RTL_8221B
&& rtlgen_supports_mmd(phydev
);
1125 static int rtl8221b_vb_cg_c22_match_phy_device(struct phy_device
*phydev
)
1127 return rtlgen_is_c45_match(phydev
, RTL_8221B_VB_CG
, false);
1130 static int rtl8221b_vb_cg_c45_match_phy_device(struct phy_device
*phydev
)
1132 return rtlgen_is_c45_match(phydev
, RTL_8221B_VB_CG
, true);
1135 static int rtl8221b_vn_cg_c22_match_phy_device(struct phy_device
*phydev
)
1137 return rtlgen_is_c45_match(phydev
, RTL_8221B_VN_CG
, false);
1140 static int rtl8221b_vn_cg_c45_match_phy_device(struct phy_device
*phydev
)
1142 return rtlgen_is_c45_match(phydev
, RTL_8221B_VN_CG
, true);
1145 static int rtl_internal_nbaset_match_phy_device(struct phy_device
*phydev
)
1150 switch (phydev
->phy_id
) {
1151 case RTL_GENERIC_PHYID
:
1160 return rtlgen_supports_2_5gbps(phydev
) && !rtlgen_supports_mmd(phydev
);
1163 static int rtl8251b_c45_match_phy_device(struct phy_device
*phydev
)
1165 return rtlgen_is_c45_match(phydev
, RTL_8251B
, true);
1168 static int rtlgen_resume(struct phy_device
*phydev
)
1170 int ret
= genphy_resume(phydev
);
1172 /* Internal PHY's from RTL8168h up may not be instantly ready */
1178 static int rtlgen_c45_resume(struct phy_device
*phydev
)
1180 int ret
= genphy_c45_pma_resume(phydev
);
1187 static int rtl9000a_config_init(struct phy_device
*phydev
)
1189 phydev
->autoneg
= AUTONEG_DISABLE
;
1190 phydev
->speed
= SPEED_100
;
1191 phydev
->duplex
= DUPLEX_FULL
;
1196 static int rtl9000a_config_aneg(struct phy_device
*phydev
)
1201 switch (phydev
->master_slave_set
) {
1202 case MASTER_SLAVE_CFG_MASTER_FORCE
:
1203 ctl
|= CTL1000_AS_MASTER
;
1205 case MASTER_SLAVE_CFG_SLAVE_FORCE
:
1207 case MASTER_SLAVE_CFG_UNKNOWN
:
1208 case MASTER_SLAVE_CFG_UNSUPPORTED
:
1211 phydev_warn(phydev
, "Unsupported Master/Slave mode\n");
1215 ret
= phy_modify_changed(phydev
, MII_CTRL1000
, CTL1000_AS_MASTER
, ctl
);
1217 ret
= genphy_soft_reset(phydev
);
1222 static int rtl9000a_read_status(struct phy_device
*phydev
)
1226 phydev
->master_slave_get
= MASTER_SLAVE_CFG_UNKNOWN
;
1227 phydev
->master_slave_state
= MASTER_SLAVE_STATE_UNKNOWN
;
1229 ret
= genphy_update_link(phydev
);
1233 ret
= phy_read(phydev
, MII_CTRL1000
);
1236 if (ret
& CTL1000_AS_MASTER
)
1237 phydev
->master_slave_get
= MASTER_SLAVE_CFG_MASTER_FORCE
;
1239 phydev
->master_slave_get
= MASTER_SLAVE_CFG_SLAVE_FORCE
;
1241 ret
= phy_read(phydev
, MII_STAT1000
);
1244 if (ret
& LPA_1000MSRES
)
1245 phydev
->master_slave_state
= MASTER_SLAVE_STATE_MASTER
;
1247 phydev
->master_slave_state
= MASTER_SLAVE_STATE_SLAVE
;
1252 static int rtl9000a_ack_interrupt(struct phy_device
*phydev
)
1256 err
= phy_read(phydev
, RTL8211F_INSR
);
1258 return (err
< 0) ? err
: 0;
1261 static int rtl9000a_config_intr(struct phy_device
*phydev
)
1266 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
) {
1267 err
= rtl9000a_ack_interrupt(phydev
);
1271 val
= (u16
)~RTL9000A_GINMR_LINK_STATUS
;
1272 err
= phy_write_paged(phydev
, 0xa42, RTL9000A_GINMR
, val
);
1275 err
= phy_write_paged(phydev
, 0xa42, RTL9000A_GINMR
, val
);
1279 err
= rtl9000a_ack_interrupt(phydev
);
1282 return phy_write_paged(phydev
, 0xa42, RTL9000A_GINMR
, val
);
1285 static irqreturn_t
rtl9000a_handle_interrupt(struct phy_device
*phydev
)
1289 irq_status
= phy_read(phydev
, RTL8211F_INSR
);
1290 if (irq_status
< 0) {
1295 if (!(irq_status
& RTL8211F_INER_LINK_STATUS
))
1298 phy_trigger_machine(phydev
);
1303 static struct phy_driver realtek_drvs
[] = {
1305 PHY_ID_MATCH_EXACT(0x00008201),
1306 .name
= "RTL8201CP Ethernet",
1307 .read_page
= rtl821x_read_page
,
1308 .write_page
= rtl821x_write_page
,
1310 PHY_ID_MATCH_EXACT(0x001cc816),
1311 .name
= "RTL8201F Fast Ethernet",
1312 .config_intr
= &rtl8201_config_intr
,
1313 .handle_interrupt
= rtl8201_handle_interrupt
,
1314 .suspend
= genphy_suspend
,
1315 .resume
= genphy_resume
,
1316 .read_page
= rtl821x_read_page
,
1317 .write_page
= rtl821x_write_page
,
1319 PHY_ID_MATCH_MODEL(0x001cc880),
1320 .name
= "RTL8208 Fast Ethernet",
1321 .read_mmd
= genphy_read_mmd_unsupported
,
1322 .write_mmd
= genphy_write_mmd_unsupported
,
1323 .suspend
= genphy_suspend
,
1324 .resume
= genphy_resume
,
1325 .read_page
= rtl821x_read_page
,
1326 .write_page
= rtl821x_write_page
,
1328 PHY_ID_MATCH_EXACT(0x001cc910),
1329 .name
= "RTL8211 Gigabit Ethernet",
1330 .config_aneg
= rtl8211_config_aneg
,
1331 .read_mmd
= &genphy_read_mmd_unsupported
,
1332 .write_mmd
= &genphy_write_mmd_unsupported
,
1333 .read_page
= rtl821x_read_page
,
1334 .write_page
= rtl821x_write_page
,
1336 PHY_ID_MATCH_EXACT(0x001cc912),
1337 .name
= "RTL8211B Gigabit Ethernet",
1338 .config_intr
= &rtl8211b_config_intr
,
1339 .handle_interrupt
= rtl821x_handle_interrupt
,
1340 .read_mmd
= &genphy_read_mmd_unsupported
,
1341 .write_mmd
= &genphy_write_mmd_unsupported
,
1342 .suspend
= rtl8211b_suspend
,
1343 .resume
= rtl8211b_resume
,
1344 .read_page
= rtl821x_read_page
,
1345 .write_page
= rtl821x_write_page
,
1347 PHY_ID_MATCH_EXACT(0x001cc913),
1348 .name
= "RTL8211C Gigabit Ethernet",
1349 .config_init
= rtl8211c_config_init
,
1350 .read_mmd
= &genphy_read_mmd_unsupported
,
1351 .write_mmd
= &genphy_write_mmd_unsupported
,
1352 .read_page
= rtl821x_read_page
,
1353 .write_page
= rtl821x_write_page
,
1355 PHY_ID_MATCH_EXACT(0x001cc914),
1356 .name
= "RTL8211DN Gigabit Ethernet",
1357 .config_intr
= rtl8211e_config_intr
,
1358 .handle_interrupt
= rtl821x_handle_interrupt
,
1359 .suspend
= genphy_suspend
,
1360 .resume
= genphy_resume
,
1361 .read_page
= rtl821x_read_page
,
1362 .write_page
= rtl821x_write_page
,
1364 PHY_ID_MATCH_EXACT(0x001cc915),
1365 .name
= "RTL8211E Gigabit Ethernet",
1366 .config_init
= &rtl8211e_config_init
,
1367 .config_intr
= &rtl8211e_config_intr
,
1368 .handle_interrupt
= rtl821x_handle_interrupt
,
1369 .suspend
= genphy_suspend
,
1370 .resume
= genphy_resume
,
1371 .read_page
= rtl821x_read_page
,
1372 .write_page
= rtl821x_write_page
,
1374 PHY_ID_MATCH_EXACT(0x001cc916),
1375 .name
= "RTL8211F Gigabit Ethernet",
1376 .probe
= rtl821x_probe
,
1377 .config_init
= &rtl8211f_config_init
,
1378 .read_status
= rtlgen_read_status
,
1379 .config_intr
= &rtl8211f_config_intr
,
1380 .handle_interrupt
= rtl8211f_handle_interrupt
,
1381 .suspend
= rtl821x_suspend
,
1382 .resume
= rtl821x_resume
,
1383 .read_page
= rtl821x_read_page
,
1384 .write_page
= rtl821x_write_page
,
1385 .flags
= PHY_ALWAYS_CALL_SUSPEND
,
1386 .led_hw_is_supported
= rtl8211f_led_hw_is_supported
,
1387 .led_hw_control_get
= rtl8211f_led_hw_control_get
,
1388 .led_hw_control_set
= rtl8211f_led_hw_control_set
,
1390 PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID
),
1391 .name
= "RTL8211F-VD Gigabit Ethernet",
1392 .probe
= rtl821x_probe
,
1393 .config_init
= &rtl8211f_config_init
,
1394 .read_status
= rtlgen_read_status
,
1395 .config_intr
= &rtl8211f_config_intr
,
1396 .handle_interrupt
= rtl8211f_handle_interrupt
,
1397 .suspend
= rtl821x_suspend
,
1398 .resume
= rtl821x_resume
,
1399 .read_page
= rtl821x_read_page
,
1400 .write_page
= rtl821x_write_page
,
1401 .flags
= PHY_ALWAYS_CALL_SUSPEND
,
1403 .name
= "Generic FE-GE Realtek PHY",
1404 .match_phy_device
= rtlgen_match_phy_device
,
1405 .read_status
= rtlgen_read_status
,
1406 .suspend
= genphy_suspend
,
1407 .resume
= rtlgen_resume
,
1408 .read_page
= rtl821x_read_page
,
1409 .write_page
= rtl821x_write_page
,
1410 .read_mmd
= rtlgen_read_mmd
,
1411 .write_mmd
= rtlgen_write_mmd
,
1413 .name
= "RTL8226 2.5Gbps PHY",
1414 .match_phy_device
= rtl8226_match_phy_device
,
1415 .get_features
= rtl822x_get_features
,
1416 .config_aneg
= rtl822x_config_aneg
,
1417 .read_status
= rtl822x_read_status
,
1418 .suspend
= genphy_suspend
,
1419 .resume
= rtlgen_resume
,
1420 .read_page
= rtl821x_read_page
,
1421 .write_page
= rtl821x_write_page
,
1423 .match_phy_device
= rtl8221b_match_phy_device
,
1424 .name
= "RTL8226B_RTL8221B 2.5Gbps PHY",
1425 .get_features
= rtl822x_get_features
,
1426 .config_aneg
= rtl822x_config_aneg
,
1427 .config_init
= rtl822xb_config_init
,
1428 .get_rate_matching
= rtl822xb_get_rate_matching
,
1429 .read_status
= rtl822xb_read_status
,
1430 .suspend
= genphy_suspend
,
1431 .resume
= rtlgen_resume
,
1432 .read_page
= rtl821x_read_page
,
1433 .write_page
= rtl821x_write_page
,
1435 PHY_ID_MATCH_EXACT(0x001cc838),
1436 .name
= "RTL8226-CG 2.5Gbps PHY",
1437 .get_features
= rtl822x_get_features
,
1438 .config_aneg
= rtl822x_config_aneg
,
1439 .read_status
= rtl822x_read_status
,
1440 .suspend
= genphy_suspend
,
1441 .resume
= rtlgen_resume
,
1442 .read_page
= rtl821x_read_page
,
1443 .write_page
= rtl821x_write_page
,
1445 PHY_ID_MATCH_EXACT(0x001cc848),
1446 .name
= "RTL8226B-CG_RTL8221B-CG 2.5Gbps PHY",
1447 .get_features
= rtl822x_get_features
,
1448 .config_aneg
= rtl822x_config_aneg
,
1449 .config_init
= rtl822xb_config_init
,
1450 .get_rate_matching
= rtl822xb_get_rate_matching
,
1451 .read_status
= rtl822xb_read_status
,
1452 .suspend
= genphy_suspend
,
1453 .resume
= rtlgen_resume
,
1454 .read_page
= rtl821x_read_page
,
1455 .write_page
= rtl821x_write_page
,
1457 .match_phy_device
= rtl8221b_vb_cg_c22_match_phy_device
,
1458 .name
= "RTL8221B-VB-CG 2.5Gbps PHY (C22)",
1459 .get_features
= rtl822x_get_features
,
1460 .config_aneg
= rtl822x_config_aneg
,
1461 .config_init
= rtl822xb_config_init
,
1462 .get_rate_matching
= rtl822xb_get_rate_matching
,
1463 .read_status
= rtl822xb_read_status
,
1464 .suspend
= genphy_suspend
,
1465 .resume
= rtlgen_resume
,
1466 .read_page
= rtl821x_read_page
,
1467 .write_page
= rtl821x_write_page
,
1469 .match_phy_device
= rtl8221b_vb_cg_c45_match_phy_device
,
1470 .name
= "RTL8221B-VB-CG 2.5Gbps PHY (C45)",
1471 .config_init
= rtl822xb_config_init
,
1472 .get_rate_matching
= rtl822xb_get_rate_matching
,
1473 .get_features
= rtl822x_c45_get_features
,
1474 .config_aneg
= rtl822x_c45_config_aneg
,
1475 .read_status
= rtl822xb_c45_read_status
,
1476 .suspend
= genphy_c45_pma_suspend
,
1477 .resume
= rtlgen_c45_resume
,
1479 .match_phy_device
= rtl8221b_vn_cg_c22_match_phy_device
,
1480 .name
= "RTL8221B-VM-CG 2.5Gbps PHY (C22)",
1481 .get_features
= rtl822x_get_features
,
1482 .config_aneg
= rtl822x_config_aneg
,
1483 .config_init
= rtl822xb_config_init
,
1484 .get_rate_matching
= rtl822xb_get_rate_matching
,
1485 .read_status
= rtl822xb_read_status
,
1486 .suspend
= genphy_suspend
,
1487 .resume
= rtlgen_resume
,
1488 .read_page
= rtl821x_read_page
,
1489 .write_page
= rtl821x_write_page
,
1491 .match_phy_device
= rtl8221b_vn_cg_c45_match_phy_device
,
1492 .name
= "RTL8221B-VN-CG 2.5Gbps PHY (C45)",
1493 .config_init
= rtl822xb_config_init
,
1494 .get_rate_matching
= rtl822xb_get_rate_matching
,
1495 .get_features
= rtl822x_c45_get_features
,
1496 .config_aneg
= rtl822x_c45_config_aneg
,
1497 .read_status
= rtl822xb_c45_read_status
,
1498 .suspend
= genphy_c45_pma_suspend
,
1499 .resume
= rtlgen_c45_resume
,
1501 .match_phy_device
= rtl8251b_c45_match_phy_device
,
1502 .name
= "RTL8251B 5Gbps PHY",
1503 .get_features
= rtl822x_get_features
,
1504 .config_aneg
= rtl822x_config_aneg
,
1505 .read_status
= rtl822x_read_status
,
1506 .suspend
= genphy_suspend
,
1507 .resume
= rtlgen_resume
,
1508 .read_page
= rtl821x_read_page
,
1509 .write_page
= rtl821x_write_page
,
1511 .match_phy_device
= rtl_internal_nbaset_match_phy_device
,
1512 .name
= "Realtek Internal NBASE-T PHY",
1513 .flags
= PHY_IS_INTERNAL
,
1514 .get_features
= rtl822x_get_features
,
1515 .config_aneg
= rtl822x_config_aneg
,
1516 .read_status
= rtl822x_read_status
,
1517 .suspend
= genphy_suspend
,
1518 .resume
= rtlgen_resume
,
1519 .read_page
= rtl821x_read_page
,
1520 .write_page
= rtl821x_write_page
,
1521 .read_mmd
= rtl822x_read_mmd
,
1522 .write_mmd
= rtl822x_write_mmd
,
1524 PHY_ID_MATCH_EXACT(0x001ccad0),
1525 .name
= "RTL8224 2.5Gbps PHY",
1526 .get_features
= rtl822x_c45_get_features
,
1527 .config_aneg
= rtl822x_c45_config_aneg
,
1528 .read_status
= rtl822x_c45_read_status
,
1529 .suspend
= genphy_c45_pma_suspend
,
1530 .resume
= rtlgen_c45_resume
,
1532 PHY_ID_MATCH_EXACT(0x001cc961),
1533 .name
= "RTL8366RB Gigabit Ethernet",
1534 .config_init
= &rtl8366rb_config_init
,
1535 /* These interrupts are handled by the irq controller
1536 * embedded inside the RTL8366RB, they get unmasked when the
1537 * irq is requested and ACKed by reading the status register,
1538 * which is done by the irqchip code.
1540 .config_intr
= genphy_no_config_intr
,
1541 .handle_interrupt
= genphy_handle_interrupt_no_ack
,
1542 .suspend
= genphy_suspend
,
1543 .resume
= genphy_resume
,
1545 PHY_ID_MATCH_EXACT(0x001ccb00),
1546 .name
= "RTL9000AA_RTL9000AN Ethernet",
1547 .features
= PHY_BASIC_T1_FEATURES
,
1548 .config_init
= rtl9000a_config_init
,
1549 .config_aneg
= rtl9000a_config_aneg
,
1550 .read_status
= rtl9000a_read_status
,
1551 .config_intr
= rtl9000a_config_intr
,
1552 .handle_interrupt
= rtl9000a_handle_interrupt
,
1553 .suspend
= genphy_suspend
,
1554 .resume
= genphy_resume
,
1555 .read_page
= rtl821x_read_page
,
1556 .write_page
= rtl821x_write_page
,
1558 PHY_ID_MATCH_EXACT(0x001cc942),
1559 .name
= "RTL8365MB-VC Gigabit Ethernet",
1560 /* Interrupt handling analogous to RTL8366RB */
1561 .config_intr
= genphy_no_config_intr
,
1562 .handle_interrupt
= genphy_handle_interrupt_no_ack
,
1563 .suspend
= genphy_suspend
,
1564 .resume
= genphy_resume
,
1566 PHY_ID_MATCH_EXACT(0x001cc960),
1567 .name
= "RTL8366S Gigabit Ethernet",
1568 .suspend
= genphy_suspend
,
1569 .resume
= genphy_resume
,
1570 .read_mmd
= genphy_read_mmd_unsupported
,
1571 .write_mmd
= genphy_write_mmd_unsupported
,
1575 module_phy_driver(realtek_drvs
);
1577 static const struct mdio_device_id __maybe_unused realtek_tbl
[] = {
1578 { PHY_ID_MATCH_VENDOR(0x001cc800) },
1582 MODULE_DEVICE_TABLE(mdio
, realtek_tbl
);