16 #include <linux/kernel.h>
17 #include <linux/string.h>
18 #include <linux/errno.h>
23 #include <linux/netdevice.h>
28 #include <linux/module.h>
29 #include <linux/mii.h>
30 #include <linux/ethtool.h>
37 #include <asm/uaccess.h>
39 #define MII_MARVELL_PHY_PAGE 22
41 #define MII_M1011_IEVENT 0x13
42 #define MII_M1011_IEVENT_CLEAR 0x0000
44 #define MII_M1011_IMASK 0x12
45 #define MII_M1011_IMASK_INIT 0x6400
46 #define MII_M1011_IMASK_CLEAR 0x0000
48 #define MII_M1011_PHY_SCR 0x10
49 #define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
51 #define MII_M1145_PHY_EXT_CR 0x14
52 #define MII_M1145_RGMII_RX_DELAY 0x0080
53 #define MII_M1145_RGMII_TX_DELAY 0x0002
55 #define MII_M1111_PHY_LED_CONTROL 0x18
56 #define MII_M1111_PHY_LED_DIRECT 0x4100
57 #define MII_M1111_PHY_LED_COMBINE 0x411c
58 #define MII_M1111_PHY_EXT_CR 0x14
59 #define MII_M1111_RX_DELAY 0x80
60 #define MII_M1111_TX_DELAY 0x2
61 #define MII_M1111_PHY_EXT_SR 0x1b
63 #define MII_M1111_HWCFG_MODE_MASK 0xf
64 #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
65 #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
66 #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
67 #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
68 #define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
69 #define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
71 #define MII_M1111_COPPER 0
72 #define MII_M1111_FIBER 1
74 #define MII_88E1121_PHY_MSCR_PAGE 2
75 #define MII_88E1121_PHY_MSCR_REG 21
76 #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
77 #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
78 #define MII_88E1121_PHY_MSCR_DELAY_MASK (~(0x3 << 4))
80 #define MII_88E1318S_PHY_MSCR1_REG 16
81 #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
83 #define MII_88E1121_PHY_LED_CTRL 16
84 #define MII_88E1121_PHY_LED_PAGE 3
85 #define MII_88E1121_PHY_LED_DEF 0x0030
87 #define MII_M1011_PHY_STATUS 0x11
88 #define MII_M1011_PHY_STATUS_1000 0x8000
89 #define MII_M1011_PHY_STATUS_100 0x4000
90 #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
91 #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
92 #define MII_M1011_PHY_STATUS_RESOLVED 0x0800
93 #define MII_M1011_PHY_STATUS_LINK 0x0400
100 static int marvell_ack_interrupt(
struct phy_device *phydev)
113 static int marvell_config_intr(
struct phy_device *phydev)
125 static int marvell_config_aneg(
struct phy_device *phydev)
191 #ifdef CONFIG_OF_MDIO
206 static int marvell_of_reg_init(
struct phy_device *phydev)
209 int len,
i, saved_page, current_page, page_changed,
ret;
211 if (!phydev->
dev.of_node)
215 if (!paddr || len < (4 *
sizeof(*paddr)))
222 current_page = saved_page;
225 len /=
sizeof(*paddr);
226 for (i = 0; i < len - 3; i += 4) {
233 if (reg_page != current_page) {
234 current_page = reg_page;
266 static int marvell_of_reg_init(
struct phy_device *phydev)
272 static int m88e1121_config_aneg(
struct phy_device *phydev)
274 int err, oldpage, mscr;
326 static int m88e1318_config_aneg(
struct phy_device *phydev)
328 int err, oldpage, mscr;
348 return m88e1121_config_aneg(phydev);
351 static int m88e1111_config_init(
struct phy_device *phydev)
454 err = marvell_of_reg_init(phydev);
461 static int m88e1118_config_aneg(
struct phy_device *phydev)
478 static int m88e1118_config_init(
struct phy_device *phydev)
505 err = marvell_of_reg_init(phydev);
517 static int m88e1149_config_init(
struct phy_device *phydev)
531 err = marvell_of_reg_init(phydev);
543 static int m88e1145_config_init(
struct phy_device *phydev)
602 err = marvell_of_reg_init(phydev);
618 static int marvell_read_status(
struct phy_device *phydev)
696 static int m88e1121_did_interrupt(
struct phy_device *phydev)
708 static struct phy_driver marvell_drivers[] = {
712 .name =
"Marvell 88E1101",
715 .config_aneg = &marvell_config_aneg,
717 .ack_interrupt = &marvell_ack_interrupt,
718 .config_intr = &marvell_config_intr,
724 .name =
"Marvell 88E1112",
727 .config_init = &m88e1111_config_init,
728 .config_aneg = &marvell_config_aneg,
730 .ack_interrupt = &marvell_ack_interrupt,
731 .config_intr = &marvell_config_intr,
737 .name =
"Marvell 88E1111",
740 .config_init = &m88e1111_config_init,
741 .config_aneg = &marvell_config_aneg,
742 .read_status = &marvell_read_status,
743 .ack_interrupt = &marvell_ack_interrupt,
744 .config_intr = &marvell_config_intr,
750 .name =
"Marvell 88E1118",
753 .config_init = &m88e1118_config_init,
754 .config_aneg = &m88e1118_config_aneg,
756 .ack_interrupt = &marvell_ack_interrupt,
757 .config_intr = &marvell_config_intr,
763 .name =
"Marvell 88E1121R",
766 .config_aneg = &m88e1121_config_aneg,
767 .read_status = &marvell_read_status,
768 .ack_interrupt = &marvell_ack_interrupt,
769 .config_intr = &marvell_config_intr,
770 .did_interrupt = &m88e1121_did_interrupt,
776 .name =
"Marvell 88E1318S",
779 .config_aneg = &m88e1318_config_aneg,
780 .read_status = &marvell_read_status,
781 .ack_interrupt = &marvell_ack_interrupt,
782 .config_intr = &marvell_config_intr,
783 .did_interrupt = &m88e1121_did_interrupt,
789 .name =
"Marvell 88E1145",
792 .config_init = &m88e1145_config_init,
793 .config_aneg = &marvell_config_aneg,
795 .ack_interrupt = &marvell_ack_interrupt,
796 .config_intr = &marvell_config_intr,
802 .name =
"Marvell 88E1149R",
805 .config_init = &m88e1149_config_init,
806 .config_aneg = &m88e1118_config_aneg,
808 .ack_interrupt = &marvell_ack_interrupt,
809 .config_intr = &marvell_config_intr,
815 .name =
"Marvell 88E1240",
818 .config_init = &m88e1111_config_init,
819 .config_aneg = &marvell_config_aneg,
821 .ack_interrupt = &marvell_ack_interrupt,
822 .config_intr = &marvell_config_intr,
827 static int __init marvell_init(
void)
833 static void __exit marvell_exit(
void)
843 { 0x01410c60, 0xfffffff0 },
844 { 0x01410c90, 0xfffffff0 },
845 { 0x01410cc0, 0xfffffff0 },
846 { 0x01410e10, 0xfffffff0 },
847 { 0x01410cb0, 0xfffffff0 },
848 { 0x01410cd0, 0xfffffff0 },
849 { 0x01410e50, 0xfffffff0 },
850 { 0x01410e30, 0xfffffff0 },
851 { 0x01410e90, 0xfffffff0 },