1a2443fd1SAndrew Lunn // SPDX-License-Identifier: GPL-2.0+ 220b2af32SRussell King /* 320b2af32SRussell King * Marvell 10G 88x3310 PHY driver 420b2af32SRussell King * 520b2af32SRussell King * Based upon the ID registers, this PHY appears to be a mixture of IPs 620b2af32SRussell King * from two different companies. 720b2af32SRussell King * 820b2af32SRussell King * There appears to be several different data paths through the PHY which 920b2af32SRussell King * are automatically managed by the PHY. The following has been determined 1005ca1b32SRussell King * via observation and experimentation for a setup using single-lane Serdes: 1120b2af32SRussell King * 1220b2af32SRussell King * SGMII PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for <= 1G) 1320b2af32SRussell King * 10GBASE-KR PHYXS -- BASE-T PCS -- 10G PMA -- AN -- Copper (for 10G) 1420b2af32SRussell King * 10GBASE-KR PHYXS -- BASE-R PCS -- Fiber 1520b2af32SRussell King * 1605ca1b32SRussell King * With XAUI, observation shows: 1705ca1b32SRussell King * 1805ca1b32SRussell King * XAUI PHYXS -- <appropriate PCS as above> 1905ca1b32SRussell King * 2005ca1b32SRussell King * and no switching of the host interface mode occurs. 2105ca1b32SRussell King * 2220b2af32SRussell King * If both the fiber and copper ports are connected, the first to gain 2320b2af32SRussell King * link takes priority and the other port is completely locked out. 2420b2af32SRussell King */ 254075a6a0SRussell King #include <linux/bitfield.h> 260d3ad854SRussell King #include <linux/ctype.h> 278d8963c3SRussell King #include <linux/delay.h> 280d3ad854SRussell King #include <linux/hwmon.h> 29952b6b3bSAntoine Tenart #include <linux/marvell_phy.h> 300d3ad854SRussell King #include <linux/phy.h> 3136023da1SRussell King #include <linux/sfp.h> 3208041a9aSVoon Weifeng #include <linux/netdevice.h> 3320b2af32SRussell King 34c47455f9SMaxime Chevallier #define MV_PHY_ALASKA_NBT_QUIRK_MASK 0xfffffffe 35c47455f9SMaxime Chevallier #define MV_PHY_ALASKA_NBT_QUIRK_REV (MARVELL_PHY_ID_88X3310 | 0xa) 36c47455f9SMaxime Chevallier 374075a6a0SRussell King #define MV_VERSION(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) 384075a6a0SRussell King 3920b2af32SRussell King enum { 40dd649b4fSRussell King MV_PMA_FW_VER0 = 0xc011, 41dd649b4fSRussell King MV_PMA_FW_VER1 = 0xc012, 429ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL = 0xc04a, 439ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_SWRST = BIT(15), 449ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK = 0x7, 459ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII = 0x0, 469ab0fbd0SMarek Behún MV_PMA_2180_PORT_CTRL_MACTYPE_DXGMII = 0x1, 479ab0fbd0SMarek Behún MV_PMA_2180_PORT_CTRL_MACTYPE_QXGMII = 0x2, 489ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER = 0x4, 499ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN = 0x5, 509ab0fbd0SMarek Behún MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH = 0x6, 513d3ced2eSRussell King MV_PMA_BOOT = 0xc050, 523d3ced2eSRussell King MV_PMA_BOOT_FATAL = BIT(0), 533d3ced2eSRussell King 5420b2af32SRussell King MV_PCS_BASE_T = 0x0000, 5520b2af32SRussell King MV_PCS_BASE_R = 0x1000, 5620b2af32SRussell King MV_PCS_1000BASEX = 0x2000, 5720b2af32SRussell King 588d8963c3SRussell King MV_PCS_CSCR1 = 0x8000, 59a585c03eSRussell King MV_PCS_CSCR1_ED_MASK = 0x0300, 60a585c03eSRussell King MV_PCS_CSCR1_ED_OFF = 0x0000, 61a585c03eSRussell King MV_PCS_CSCR1_ED_RX = 0x0200, 62a585c03eSRussell King MV_PCS_CSCR1_ED_NLP = 0x0300, 638d8963c3SRussell King MV_PCS_CSCR1_MDIX_MASK = 0x0060, 648d8963c3SRussell King MV_PCS_CSCR1_MDIX_MDI = 0x0000, 658d8963c3SRussell King MV_PCS_CSCR1_MDIX_MDIX = 0x0020, 668d8963c3SRussell King MV_PCS_CSCR1_MDIX_AUTO = 0x0060, 678d8963c3SRussell King 684075a6a0SRussell King MV_PCS_DSC1 = 0x8003, 694075a6a0SRussell King MV_PCS_DSC1_ENABLE = BIT(9), 704075a6a0SRussell King MV_PCS_DSC1_10GBT = 0x01c0, 714075a6a0SRussell King MV_PCS_DSC1_1GBR = 0x0038, 724075a6a0SRussell King MV_PCS_DSC1_100BTX = 0x0007, 734075a6a0SRussell King MV_PCS_DSC2 = 0x8004, 744075a6a0SRussell King MV_PCS_DSC2_2P5G = 0xf000, 754075a6a0SRussell King MV_PCS_DSC2_5G = 0x0f00, 764075a6a0SRussell King 77c84786faSRussell King MV_PCS_CSSR1 = 0x8008, 78c84786faSRussell King MV_PCS_CSSR1_SPD1_MASK = 0xc000, 79c84786faSRussell King MV_PCS_CSSR1_SPD1_SPD2 = 0xc000, 80c84786faSRussell King MV_PCS_CSSR1_SPD1_1000 = 0x8000, 81c84786faSRussell King MV_PCS_CSSR1_SPD1_100 = 0x4000, 82c84786faSRussell King MV_PCS_CSSR1_SPD1_10 = 0x0000, 83c84786faSRussell King MV_PCS_CSSR1_DUPLEX_FULL= BIT(13), 84c84786faSRussell King MV_PCS_CSSR1_RESOLVED = BIT(11), 85c84786faSRussell King MV_PCS_CSSR1_MDIX = BIT(6), 86c84786faSRussell King MV_PCS_CSSR1_SPD2_MASK = 0x000c, 87c84786faSRussell King MV_PCS_CSSR1_SPD2_5000 = 0x0008, 88c84786faSRussell King MV_PCS_CSSR1_SPD2_2500 = 0x0004, 89c84786faSRussell King MV_PCS_CSSR1_SPD2_10000 = 0x0000, 90ea4efe25SRussell King 91c3e302edSBaruch Siach /* Temperature read register (88E2110 only) */ 92c3e302edSBaruch Siach MV_PCS_TEMP = 0x8042, 93c3e302edSBaruch Siach 94a5de4be0SMarek Behún /* Number of ports on the device */ 95a5de4be0SMarek Behún MV_PCS_PORT_INFO = 0xd00d, 96a5de4be0SMarek Behún MV_PCS_PORT_INFO_NPORTS_MASK = 0x0380, 97a5de4be0SMarek Behún MV_PCS_PORT_INFO_NPORTS_SHIFT = 7, 98a5de4be0SMarek Behún 99d6d29292SRussell King /* SerDes reinitialization 88E21X0 */ 100d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2 = 0x800f, 101d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_AUTO_INIT_DIS = BIT(13), 102d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_RUN_INIT = BIT(15), 103d6d29292SRussell King 10420b2af32SRussell King /* These registers appear at 0x800X and 0xa00X - the 0xa00X control 10520b2af32SRussell King * registers appear to set themselves to the 0x800X when AN is 10620b2af32SRussell King * restarted, but status registers appear readable from either. 10720b2af32SRussell King */ 10820b2af32SRussell King MV_AN_CTRL1000 = 0x8000, /* 1000base-T control register */ 10920b2af32SRussell King MV_AN_STAT1000 = 0x8001, /* 1000base-T status register */ 1100d3ad854SRussell King 1110d3ad854SRussell King /* Vendor2 MMD registers */ 112af3e28cbSAntoine Tenart MV_V2_PORT_CTRL = 0xf001, 1138f48c2acSRussell King MV_V2_PORT_CTRL_PWRDOWN = BIT(11), 1149893f316SMarek Behún MV_V2_33X0_PORT_CTRL_SWRST = BIT(15), 1159893f316SMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_MASK = 0x7, 116f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI = 0x0, 117f8ee45fcSMarek Behún MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH = 0x1, 118f8ee45fcSMarek Behún MV_V2_3340_PORT_CTRL_MACTYPE_RXAUI_NO_SGMII_AN = 0x1, 119f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH = 0x2, 120f8ee45fcSMarek Behún MV_V2_3310_PORT_CTRL_MACTYPE_XAUI = 0x3, 121f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER = 0x4, 122f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN = 0x5, 123f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH = 0x6, 124f8ee45fcSMarek Behún MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII = 0x7, 12508041a9aSVoon Weifeng MV_V2_PORT_INTR_STS = 0xf040, 12608041a9aSVoon Weifeng MV_V2_PORT_INTR_MASK = 0xf043, 12708041a9aSVoon Weifeng MV_V2_PORT_INTR_STS_WOL_EN = BIT(8), 12808041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD0 = 0xf06b, 12908041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD1 = 0xf06c, 13008041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD2 = 0xf06d, 13108041a9aSVoon Weifeng /* Wake on LAN registers */ 13208041a9aSVoon Weifeng MV_V2_WOL_CTRL = 0xf06e, 13308041a9aSVoon Weifeng MV_V2_WOL_CTRL_CLEAR_STS = BIT(15), 13408041a9aSVoon Weifeng MV_V2_WOL_CTRL_MAGIC_PKT_EN = BIT(0), 135c3e302edSBaruch Siach /* Temperature control/read registers (88X3310 only) */ 1360d3ad854SRussell King MV_V2_TEMP_CTRL = 0xf08a, 1370d3ad854SRussell King MV_V2_TEMP_CTRL_MASK = 0xc000, 1380d3ad854SRussell King MV_V2_TEMP_CTRL_SAMPLE = 0x0000, 1390d3ad854SRussell King MV_V2_TEMP_CTRL_DISABLE = 0xc000, 1400d3ad854SRussell King MV_V2_TEMP = 0xf08c, 1410d3ad854SRussell King MV_V2_TEMP_UNKNOWN = 0x9600, /* unknown function */ 1420d3ad854SRussell King }; 1430d3ad854SRussell King 1442cb6d63bSRussell King (Oracle) struct mv3310_mactype { 1452cb6d63bSRussell King (Oracle) bool valid; 1462cb6d63bSRussell King (Oracle) bool fixed_interface; 1472cb6d63bSRussell King (Oracle) phy_interface_t interface_10g; 1482cb6d63bSRussell King (Oracle) }; 1492cb6d63bSRussell King (Oracle) 15097bbe3bdSMarek Behún struct mv3310_chip { 1514075a6a0SRussell King bool (*has_downshift)(struct phy_device *phydev); 152261a74c6SMarek Behún void (*init_supported_interfaces)(unsigned long *mask); 15397bbe3bdSMarek Behún int (*get_mactype)(struct phy_device *phydev); 154d6d29292SRussell King int (*set_mactype)(struct phy_device *phydev, int mactype); 155d6d29292SRussell King int (*select_mactype)(unsigned long *interfaces); 1562cb6d63bSRussell King (Oracle) 1572cb6d63bSRussell King (Oracle) const struct mv3310_mactype *mactypes; 1582cb6d63bSRussell King (Oracle) size_t n_mactypes; 159884d9a67SMarek Behún 160884d9a67SMarek Behún #ifdef CONFIG_HWMON 161884d9a67SMarek Behún int (*hwmon_read_temp_reg)(struct phy_device *phydev); 162884d9a67SMarek Behún #endif 16397bbe3bdSMarek Behún }; 16497bbe3bdSMarek Behún 1650d3ad854SRussell King struct mv3310_priv { 166261a74c6SMarek Behún DECLARE_BITMAP(supported_interfaces, PHY_INTERFACE_MODE_MAX); 1672cb6d63bSRussell King (Oracle) const struct mv3310_mactype *mactype; 168261a74c6SMarek Behún 169dd649b4fSRussell King u32 firmware_ver; 1704075a6a0SRussell King bool has_downshift; 171dd649b4fSRussell King 1720d3ad854SRussell King struct device *hwmon_dev; 1730d3ad854SRussell King char *hwmon_name; 17420b2af32SRussell King }; 17520b2af32SRussell King 17697bbe3bdSMarek Behún static const struct mv3310_chip *to_mv3310_chip(struct phy_device *phydev) 17797bbe3bdSMarek Behún { 17897bbe3bdSMarek Behún return phydev->drv->driver_data; 17997bbe3bdSMarek Behún } 18097bbe3bdSMarek Behún 1810d3ad854SRussell King #ifdef CONFIG_HWMON 1820d3ad854SRussell King static umode_t mv3310_hwmon_is_visible(const void *data, 1830d3ad854SRussell King enum hwmon_sensor_types type, 1840d3ad854SRussell King u32 attr, int channel) 1850d3ad854SRussell King { 1860d3ad854SRussell King if (type == hwmon_chip && attr == hwmon_chip_update_interval) 1870d3ad854SRussell King return 0444; 1880d3ad854SRussell King if (type == hwmon_temp && attr == hwmon_temp_input) 1890d3ad854SRussell King return 0444; 1900d3ad854SRussell King return 0; 1910d3ad854SRussell King } 1920d3ad854SRussell King 193c3e302edSBaruch Siach static int mv3310_hwmon_read_temp_reg(struct phy_device *phydev) 194c3e302edSBaruch Siach { 195c3e302edSBaruch Siach return phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP); 196c3e302edSBaruch Siach } 197c3e302edSBaruch Siach 198c3e302edSBaruch Siach static int mv2110_hwmon_read_temp_reg(struct phy_device *phydev) 199c3e302edSBaruch Siach { 200c3e302edSBaruch Siach return phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_TEMP); 201c3e302edSBaruch Siach } 202c3e302edSBaruch Siach 2030d3ad854SRussell King static int mv3310_hwmon_read(struct device *dev, enum hwmon_sensor_types type, 2040d3ad854SRussell King u32 attr, int channel, long *value) 2050d3ad854SRussell King { 2060d3ad854SRussell King struct phy_device *phydev = dev_get_drvdata(dev); 207884d9a67SMarek Behún const struct mv3310_chip *chip = to_mv3310_chip(phydev); 2080d3ad854SRussell King int temp; 2090d3ad854SRussell King 2100d3ad854SRussell King if (type == hwmon_chip && attr == hwmon_chip_update_interval) { 2110d3ad854SRussell King *value = MSEC_PER_SEC; 2120d3ad854SRussell King return 0; 2130d3ad854SRussell King } 2140d3ad854SRussell King 2150d3ad854SRussell King if (type == hwmon_temp && attr == hwmon_temp_input) { 216884d9a67SMarek Behún temp = chip->hwmon_read_temp_reg(phydev); 2170d3ad854SRussell King if (temp < 0) 2180d3ad854SRussell King return temp; 2190d3ad854SRussell King 2200d3ad854SRussell King *value = ((temp & 0xff) - 75) * 1000; 2210d3ad854SRussell King 2220d3ad854SRussell King return 0; 2230d3ad854SRussell King } 2240d3ad854SRussell King 2250d3ad854SRussell King return -EOPNOTSUPP; 2260d3ad854SRussell King } 2270d3ad854SRussell King 2280d3ad854SRussell King static const struct hwmon_ops mv3310_hwmon_ops = { 2290d3ad854SRussell King .is_visible = mv3310_hwmon_is_visible, 2300d3ad854SRussell King .read = mv3310_hwmon_read, 2310d3ad854SRussell King }; 2320d3ad854SRussell King 2330d3ad854SRussell King static u32 mv3310_hwmon_chip_config[] = { 2340d3ad854SRussell King HWMON_C_REGISTER_TZ | HWMON_C_UPDATE_INTERVAL, 2350d3ad854SRussell King 0, 2360d3ad854SRussell King }; 2370d3ad854SRussell King 2380d3ad854SRussell King static const struct hwmon_channel_info mv3310_hwmon_chip = { 2390d3ad854SRussell King .type = hwmon_chip, 2400d3ad854SRussell King .config = mv3310_hwmon_chip_config, 2410d3ad854SRussell King }; 2420d3ad854SRussell King 2430d3ad854SRussell King static u32 mv3310_hwmon_temp_config[] = { 2440d3ad854SRussell King HWMON_T_INPUT, 2450d3ad854SRussell King 0, 2460d3ad854SRussell King }; 2470d3ad854SRussell King 2480d3ad854SRussell King static const struct hwmon_channel_info mv3310_hwmon_temp = { 2490d3ad854SRussell King .type = hwmon_temp, 2500d3ad854SRussell King .config = mv3310_hwmon_temp_config, 2510d3ad854SRussell King }; 2520d3ad854SRussell King 253ff0805e2SKrzysztof Kozlowski static const struct hwmon_channel_info * const mv3310_hwmon_info[] = { 2540d3ad854SRussell King &mv3310_hwmon_chip, 2550d3ad854SRussell King &mv3310_hwmon_temp, 2560d3ad854SRussell King NULL, 2570d3ad854SRussell King }; 2580d3ad854SRussell King 2590d3ad854SRussell King static const struct hwmon_chip_info mv3310_hwmon_chip_info = { 2600d3ad854SRussell King .ops = &mv3310_hwmon_ops, 2610d3ad854SRussell King .info = mv3310_hwmon_info, 2620d3ad854SRussell King }; 2630d3ad854SRussell King 2640d3ad854SRussell King static int mv3310_hwmon_config(struct phy_device *phydev, bool enable) 2650d3ad854SRussell King { 2660d3ad854SRussell King u16 val; 2670d3ad854SRussell King int ret; 2680d3ad854SRussell King 269c3e302edSBaruch Siach if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310) 270c3e302edSBaruch Siach return 0; 271c3e302edSBaruch Siach 2720d3ad854SRussell King ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP, 2730d3ad854SRussell King MV_V2_TEMP_UNKNOWN); 2740d3ad854SRussell King if (ret < 0) 2750d3ad854SRussell King return ret; 2760d3ad854SRussell King 2770d3ad854SRussell King val = enable ? MV_V2_TEMP_CTRL_SAMPLE : MV_V2_TEMP_CTRL_DISABLE; 2780d3ad854SRussell King 279b06d8e5aSHeiner Kallweit return phy_modify_mmd(phydev, MDIO_MMD_VEND2, MV_V2_TEMP_CTRL, 280b06d8e5aSHeiner Kallweit MV_V2_TEMP_CTRL_MASK, val); 2810d3ad854SRussell King } 2820d3ad854SRussell King 2830d3ad854SRussell King static int mv3310_hwmon_probe(struct phy_device *phydev) 2840d3ad854SRussell King { 2850d3ad854SRussell King struct device *dev = &phydev->mdio.dev; 2860d3ad854SRussell King struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 2870d3ad854SRussell King int i, j, ret; 2880d3ad854SRussell King 2890d3ad854SRussell King priv->hwmon_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); 2900d3ad854SRussell King if (!priv->hwmon_name) 2910d3ad854SRussell King return -ENODEV; 2920d3ad854SRussell King 2930d3ad854SRussell King for (i = j = 0; priv->hwmon_name[i]; i++) { 2940d3ad854SRussell King if (isalnum(priv->hwmon_name[i])) { 2950d3ad854SRussell King if (i != j) 2960d3ad854SRussell King priv->hwmon_name[j] = priv->hwmon_name[i]; 2970d3ad854SRussell King j++; 2980d3ad854SRussell King } 2990d3ad854SRussell King } 3000d3ad854SRussell King priv->hwmon_name[j] = '\0'; 3010d3ad854SRussell King 3020d3ad854SRussell King ret = mv3310_hwmon_config(phydev, true); 3030d3ad854SRussell King if (ret) 3040d3ad854SRussell King return ret; 3050d3ad854SRussell King 3060d3ad854SRussell King priv->hwmon_dev = devm_hwmon_device_register_with_info(dev, 3070d3ad854SRussell King priv->hwmon_name, phydev, 3080d3ad854SRussell King &mv3310_hwmon_chip_info, NULL); 3090d3ad854SRussell King 3100d3ad854SRussell King return PTR_ERR_OR_ZERO(priv->hwmon_dev); 3110d3ad854SRussell King } 3120d3ad854SRussell King #else 3130d3ad854SRussell King static inline int mv3310_hwmon_config(struct phy_device *phydev, bool enable) 3140d3ad854SRussell King { 3150d3ad854SRussell King return 0; 3160d3ad854SRussell King } 3170d3ad854SRussell King 3180d3ad854SRussell King static int mv3310_hwmon_probe(struct phy_device *phydev) 3190d3ad854SRussell King { 3200d3ad854SRussell King return 0; 3210d3ad854SRussell King } 3220d3ad854SRussell King #endif 3230d3ad854SRussell King 324c9cc1c81SRussell King static int mv3310_power_down(struct phy_device *phydev) 325c9cc1c81SRussell King { 326c9cc1c81SRussell King return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, 327c9cc1c81SRussell King MV_V2_PORT_CTRL_PWRDOWN); 328c9cc1c81SRussell King } 329c9cc1c81SRussell King 330c9cc1c81SRussell King static int mv3310_power_up(struct phy_device *phydev) 331c9cc1c81SRussell King { 3328f48c2acSRussell King struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 3338f48c2acSRussell King int ret; 3348f48c2acSRussell King 3358f48c2acSRussell King ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, 336c9cc1c81SRussell King MV_V2_PORT_CTRL_PWRDOWN); 3378f48c2acSRussell King 338c7b75beaSJiawen Wu /* Sometimes, the power down bit doesn't clear immediately, and 339c7b75beaSJiawen Wu * a read of this register causes the bit not to clear. Delay 340c7b75beaSJiawen Wu * 100us to allow the PHY to come out of power down mode before 341c7b75beaSJiawen Wu * the next access. 342c7b75beaSJiawen Wu */ 343c7b75beaSJiawen Wu udelay(100); 344c7b75beaSJiawen Wu 345829e7573SBaruch Siach if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310 || 346829e7573SBaruch Siach priv->firmware_ver < 0x00030000) 3478f48c2acSRussell King return ret; 3488f48c2acSRussell King 3498f48c2acSRussell King return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, 3509893f316SMarek Behún MV_V2_33X0_PORT_CTRL_SWRST); 351c9cc1c81SRussell King } 352c9cc1c81SRussell King 3538d8963c3SRussell King static int mv3310_reset(struct phy_device *phydev, u32 unit) 3548d8963c3SRussell King { 3558964a217SDejin Zheng int val, err; 3568d8963c3SRussell King 3578d8963c3SRussell King err = phy_modify_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1, 3588d8963c3SRussell King MDIO_CTRL1_RESET, MDIO_CTRL1_RESET); 3598d8963c3SRussell King if (err < 0) 3608d8963c3SRussell King return err; 3618d8963c3SRussell King 3628964a217SDejin Zheng return phy_read_mmd_poll_timeout(phydev, MDIO_MMD_PCS, 3638964a217SDejin Zheng unit + MDIO_CTRL1, val, 3648964a217SDejin Zheng !(val & MDIO_CTRL1_RESET), 3658964a217SDejin Zheng 5000, 100000, true); 3668d8963c3SRussell King } 3678d8963c3SRussell King 3684075a6a0SRussell King static int mv3310_get_downshift(struct phy_device *phydev, u8 *ds) 3694075a6a0SRussell King { 3704075a6a0SRussell King struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 3714075a6a0SRussell King int val; 3724075a6a0SRussell King 3734075a6a0SRussell King if (!priv->has_downshift) 3744075a6a0SRussell King return -EOPNOTSUPP; 3754075a6a0SRussell King 3764075a6a0SRussell King val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_DSC1); 3774075a6a0SRussell King if (val < 0) 3784075a6a0SRussell King return val; 3794075a6a0SRussell King 3804075a6a0SRussell King if (val & MV_PCS_DSC1_ENABLE) 3814075a6a0SRussell King /* assume that all fields are the same */ 3824075a6a0SRussell King *ds = 1 + FIELD_GET(MV_PCS_DSC1_10GBT, (u16)val); 3834075a6a0SRussell King else 3844075a6a0SRussell King *ds = DOWNSHIFT_DEV_DISABLE; 3854075a6a0SRussell King 3864075a6a0SRussell King return 0; 3874075a6a0SRussell King } 3884075a6a0SRussell King 3894075a6a0SRussell King static int mv3310_set_downshift(struct phy_device *phydev, u8 ds) 3904075a6a0SRussell King { 3914075a6a0SRussell King struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 3924075a6a0SRussell King u16 val; 3934075a6a0SRussell King int err; 3944075a6a0SRussell King 3954075a6a0SRussell King if (!priv->has_downshift) 3964075a6a0SRussell King return -EOPNOTSUPP; 3974075a6a0SRussell King 3984075a6a0SRussell King if (ds == DOWNSHIFT_DEV_DISABLE) 3994075a6a0SRussell King return phy_clear_bits_mmd(phydev, MDIO_MMD_PCS, MV_PCS_DSC1, 4004075a6a0SRussell King MV_PCS_DSC1_ENABLE); 4014075a6a0SRussell King 4024075a6a0SRussell King /* DOWNSHIFT_DEV_DEFAULT_COUNT is confusing. It looks like it should 4034075a6a0SRussell King * set the default settings for the PHY. However, it is used for 4044075a6a0SRussell King * "ethtool --set-phy-tunable ethN downshift on". The intention is 4054075a6a0SRussell King * to enable downshift at a default number of retries. The default 4064075a6a0SRussell King * settings for 88x3310 are for two retries with downshift disabled. 4074075a6a0SRussell King * So let's use two retries with downshift enabled. 4084075a6a0SRussell King */ 4094075a6a0SRussell King if (ds == DOWNSHIFT_DEV_DEFAULT_COUNT) 4104075a6a0SRussell King ds = 2; 4114075a6a0SRussell King 4124075a6a0SRussell King if (ds > 8) 4134075a6a0SRussell King return -E2BIG; 4144075a6a0SRussell King 4154075a6a0SRussell King ds -= 1; 4164075a6a0SRussell King val = FIELD_PREP(MV_PCS_DSC2_2P5G, ds); 4174075a6a0SRussell King val |= FIELD_PREP(MV_PCS_DSC2_5G, ds); 4184075a6a0SRussell King err = phy_modify_mmd(phydev, MDIO_MMD_PCS, MV_PCS_DSC2, 4194075a6a0SRussell King MV_PCS_DSC2_2P5G | MV_PCS_DSC2_5G, val); 4204075a6a0SRussell King if (err < 0) 4214075a6a0SRussell King return err; 4224075a6a0SRussell King 4234075a6a0SRussell King val = MV_PCS_DSC1_ENABLE; 4244075a6a0SRussell King val |= FIELD_PREP(MV_PCS_DSC1_10GBT, ds); 4254075a6a0SRussell King val |= FIELD_PREP(MV_PCS_DSC1_1GBR, ds); 4264075a6a0SRussell King val |= FIELD_PREP(MV_PCS_DSC1_100BTX, ds); 4274075a6a0SRussell King 4284075a6a0SRussell King return phy_modify_mmd(phydev, MDIO_MMD_PCS, MV_PCS_DSC1, 4294075a6a0SRussell King MV_PCS_DSC1_ENABLE | MV_PCS_DSC1_10GBT | 4304075a6a0SRussell King MV_PCS_DSC1_1GBR | MV_PCS_DSC1_100BTX, val); 4314075a6a0SRussell King } 4324075a6a0SRussell King 433a585c03eSRussell King static int mv3310_get_edpd(struct phy_device *phydev, u16 *edpd) 434a585c03eSRussell King { 435a585c03eSRussell King int val; 436a585c03eSRussell King 437a585c03eSRussell King val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_CSCR1); 438a585c03eSRussell King if (val < 0) 439a585c03eSRussell King return val; 440a585c03eSRussell King 441a585c03eSRussell King switch (val & MV_PCS_CSCR1_ED_MASK) { 442a585c03eSRussell King case MV_PCS_CSCR1_ED_NLP: 443a585c03eSRussell King *edpd = 1000; 444a585c03eSRussell King break; 445a585c03eSRussell King case MV_PCS_CSCR1_ED_RX: 446a585c03eSRussell King *edpd = ETHTOOL_PHY_EDPD_NO_TX; 447a585c03eSRussell King break; 448a585c03eSRussell King default: 449a585c03eSRussell King *edpd = ETHTOOL_PHY_EDPD_DISABLE; 450a585c03eSRussell King break; 451a585c03eSRussell King } 452a585c03eSRussell King return 0; 453a585c03eSRussell King } 454a585c03eSRussell King 455a585c03eSRussell King static int mv3310_set_edpd(struct phy_device *phydev, u16 edpd) 456a585c03eSRussell King { 457a585c03eSRussell King u16 val; 458a585c03eSRussell King int err; 459a585c03eSRussell King 460a585c03eSRussell King switch (edpd) { 461a585c03eSRussell King case 1000: 462a585c03eSRussell King case ETHTOOL_PHY_EDPD_DFLT_TX_MSECS: 463a585c03eSRussell King val = MV_PCS_CSCR1_ED_NLP; 464a585c03eSRussell King break; 465a585c03eSRussell King 466a585c03eSRussell King case ETHTOOL_PHY_EDPD_NO_TX: 467a585c03eSRussell King val = MV_PCS_CSCR1_ED_RX; 468a585c03eSRussell King break; 469a585c03eSRussell King 470a585c03eSRussell King case ETHTOOL_PHY_EDPD_DISABLE: 471a585c03eSRussell King val = MV_PCS_CSCR1_ED_OFF; 472a585c03eSRussell King break; 473a585c03eSRussell King 474a585c03eSRussell King default: 475a585c03eSRussell King return -EINVAL; 476a585c03eSRussell King } 477a585c03eSRussell King 478a585c03eSRussell King err = phy_modify_mmd_changed(phydev, MDIO_MMD_PCS, MV_PCS_CSCR1, 479a585c03eSRussell King MV_PCS_CSCR1_ED_MASK, val); 480a585c03eSRussell King if (err > 0) 481a585c03eSRussell King err = mv3310_reset(phydev, MV_PCS_BASE_T); 482a585c03eSRussell King 483a585c03eSRussell King return err; 484a585c03eSRussell King } 485a585c03eSRussell King 48636023da1SRussell King static int mv3310_sfp_insert(void *upstream, const struct sfp_eeprom_id *id) 48736023da1SRussell King { 48836023da1SRussell King struct phy_device *phydev = upstream; 48936023da1SRussell King __ETHTOOL_DECLARE_LINK_MODE_MASK(support) = { 0, }; 490fd580c98SRussell King DECLARE_PHY_INTERFACE_MASK(interfaces); 49136023da1SRussell King phy_interface_t iface; 49236023da1SRussell King 493fd580c98SRussell King sfp_parse_support(phydev->sfp_bus, id, support, interfaces); 494a4516c70SRussell King iface = sfp_select_interface(phydev->sfp_bus, support); 49536023da1SRussell King 496e0f909bcSRussell King if (iface != PHY_INTERFACE_MODE_10GBASER) { 49736023da1SRussell King dev_err(&phydev->mdio.dev, "incompatible SFP module inserted\n"); 49836023da1SRussell King return -EINVAL; 49936023da1SRussell King } 50036023da1SRussell King return 0; 50136023da1SRussell King } 50236023da1SRussell King 50336023da1SRussell King static const struct sfp_upstream_ops mv3310_sfp_ops = { 50436023da1SRussell King .attach = phy_sfp_attach, 50536023da1SRussell King .detach = phy_sfp_detach, 50636023da1SRussell King .module_insert = mv3310_sfp_insert, 50736023da1SRussell King }; 50836023da1SRussell King 50920b2af32SRussell King static int mv3310_probe(struct phy_device *phydev) 51020b2af32SRussell King { 511261a74c6SMarek Behún const struct mv3310_chip *chip = to_mv3310_chip(phydev); 5120d3ad854SRussell King struct mv3310_priv *priv; 51320b2af32SRussell King u32 mmd_mask = MDIO_DEVS_PMAPMD | MDIO_DEVS_AN; 5140d3ad854SRussell King int ret; 51520b2af32SRussell King 51620b2af32SRussell King if (!phydev->is_c45 || 51720b2af32SRussell King (phydev->c45_ids.devices_in_package & mmd_mask) != mmd_mask) 51820b2af32SRussell King return -ENODEV; 51920b2af32SRussell King 5203d3ced2eSRussell King ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_BOOT); 5213d3ced2eSRussell King if (ret < 0) 5223d3ced2eSRussell King return ret; 5233d3ced2eSRussell King 5243d3ced2eSRussell King if (ret & MV_PMA_BOOT_FATAL) { 5253d3ced2eSRussell King dev_warn(&phydev->mdio.dev, 5263d3ced2eSRussell King "PHY failed to boot firmware, status=%04x\n", ret); 5273d3ced2eSRussell King return -ENODEV; 5283d3ced2eSRussell King } 5293d3ced2eSRussell King 5300d3ad854SRussell King priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); 5310d3ad854SRussell King if (!priv) 5320d3ad854SRussell King return -ENOMEM; 5330d3ad854SRussell King 5340d3ad854SRussell King dev_set_drvdata(&phydev->mdio.dev, priv); 5350d3ad854SRussell King 536dd649b4fSRussell King ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER0); 537dd649b4fSRussell King if (ret < 0) 538dd649b4fSRussell King return ret; 539dd649b4fSRussell King 540dd649b4fSRussell King priv->firmware_ver = ret << 16; 541dd649b4fSRussell King 542dd649b4fSRussell King ret = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_FW_VER1); 543dd649b4fSRussell King if (ret < 0) 544dd649b4fSRussell King return ret; 545dd649b4fSRussell King 546dd649b4fSRussell King priv->firmware_ver |= ret; 547dd649b4fSRussell King 548dd649b4fSRussell King phydev_info(phydev, "Firmware version %u.%u.%u.%u\n", 549dd649b4fSRussell King priv->firmware_ver >> 24, (priv->firmware_ver >> 16) & 255, 550dd649b4fSRussell King (priv->firmware_ver >> 8) & 255, priv->firmware_ver & 255); 551dd649b4fSRussell King 5524075a6a0SRussell King if (chip->has_downshift) 5534075a6a0SRussell King priv->has_downshift = chip->has_downshift(phydev); 5544075a6a0SRussell King 555c9cc1c81SRussell King /* Powering down the port when not in use saves about 600mW */ 556c9cc1c81SRussell King ret = mv3310_power_down(phydev); 557c9cc1c81SRussell King if (ret) 558c9cc1c81SRussell King return ret; 559c9cc1c81SRussell King 5600d3ad854SRussell King ret = mv3310_hwmon_probe(phydev); 5610d3ad854SRussell King if (ret) 5620d3ad854SRussell King return ret; 5630d3ad854SRussell King 564261a74c6SMarek Behún chip->init_supported_interfaces(priv->supported_interfaces); 565261a74c6SMarek Behún 56636023da1SRussell King return phy_sfp_probe(phydev, &mv3310_sfp_ops); 56720b2af32SRussell King } 56820b2af32SRussell King 5691b8ef142SMarek Behún static void mv3310_remove(struct phy_device *phydev) 5701b8ef142SMarek Behún { 5711b8ef142SMarek Behún mv3310_hwmon_config(phydev, false); 5721b8ef142SMarek Behún } 5731b8ef142SMarek Behún 5740d3ad854SRussell King static int mv3310_suspend(struct phy_device *phydev) 5750d3ad854SRussell King { 576c9cc1c81SRussell King return mv3310_power_down(phydev); 5770d3ad854SRussell King } 5780d3ad854SRussell King 5790d3ad854SRussell King static int mv3310_resume(struct phy_device *phydev) 5800d3ad854SRussell King { 581af3e28cbSAntoine Tenart int ret; 582af3e28cbSAntoine Tenart 583c9cc1c81SRussell King ret = mv3310_power_up(phydev); 584af3e28cbSAntoine Tenart if (ret) 585af3e28cbSAntoine Tenart return ret; 586af3e28cbSAntoine Tenart 5870d3ad854SRussell King return mv3310_hwmon_config(phydev, true); 5880d3ad854SRussell King } 5890d3ad854SRussell King 590c47455f9SMaxime Chevallier /* Some PHYs in the Alaska family such as the 88X3310 and the 88E2010 591c47455f9SMaxime Chevallier * don't set bit 14 in PMA Extended Abilities (1.11), although they do 592c47455f9SMaxime Chevallier * support 2.5GBASET and 5GBASET. For these models, we can still read their 593c47455f9SMaxime Chevallier * 2.5G/5G extended abilities register (1.21). We detect these models based on 594c47455f9SMaxime Chevallier * the PMA device identifier, with a mask matching models known to have this 595c47455f9SMaxime Chevallier * issue 596c47455f9SMaxime Chevallier */ 597c47455f9SMaxime Chevallier static bool mv3310_has_pma_ngbaset_quirk(struct phy_device *phydev) 598c47455f9SMaxime Chevallier { 599c47455f9SMaxime Chevallier if (!(phydev->c45_ids.devices_in_package & MDIO_DEVS_PMAPMD)) 600c47455f9SMaxime Chevallier return false; 601c47455f9SMaxime Chevallier 602c47455f9SMaxime Chevallier /* Only some revisions of the 88X3310 family PMA seem to be impacted */ 603c47455f9SMaxime Chevallier return (phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & 604c47455f9SMaxime Chevallier MV_PHY_ALASKA_NBT_QUIRK_MASK) == MV_PHY_ALASKA_NBT_QUIRK_REV; 605c47455f9SMaxime Chevallier } 606c47455f9SMaxime Chevallier 60797bbe3bdSMarek Behún static int mv2110_get_mactype(struct phy_device *phydev) 60897bbe3bdSMarek Behún { 60997bbe3bdSMarek Behún int mactype; 61097bbe3bdSMarek Behún 61197bbe3bdSMarek Behún mactype = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_21X0_PORT_CTRL); 61297bbe3bdSMarek Behún if (mactype < 0) 61397bbe3bdSMarek Behún return mactype; 61497bbe3bdSMarek Behún 61597bbe3bdSMarek Behún return mactype & MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK; 61697bbe3bdSMarek Behún } 61797bbe3bdSMarek Behún 618d6d29292SRussell King static int mv2110_set_mactype(struct phy_device *phydev, int mactype) 619d6d29292SRussell King { 620d6d29292SRussell King int err, val; 621d6d29292SRussell King 622d6d29292SRussell King mactype &= MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK; 623d6d29292SRussell King err = phy_modify_mmd(phydev, MDIO_MMD_PMAPMD, MV_PMA_21X0_PORT_CTRL, 624d6d29292SRussell King MV_PMA_21X0_PORT_CTRL_SWRST | 625d6d29292SRussell King MV_PMA_21X0_PORT_CTRL_MACTYPE_MASK, 626d6d29292SRussell King MV_PMA_21X0_PORT_CTRL_SWRST | mactype); 627d6d29292SRussell King if (err) 628d6d29292SRussell King return err; 629d6d29292SRussell King 630d6d29292SRussell King err = phy_set_bits_mmd(phydev, MDIO_MMD_AN, MV_AN_21X0_SERDES_CTRL2, 631d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_AUTO_INIT_DIS | 632d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_RUN_INIT); 633d6d29292SRussell King if (err) 634d6d29292SRussell King return err; 635d6d29292SRussell King 636d6d29292SRussell King err = phy_read_mmd_poll_timeout(phydev, MDIO_MMD_AN, 637d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2, val, 638d6d29292SRussell King !(val & 639d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_RUN_INIT), 640d6d29292SRussell King 5000, 100000, true); 641d6d29292SRussell King if (err) 642d6d29292SRussell King return err; 643d6d29292SRussell King 644d6d29292SRussell King return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, MV_AN_21X0_SERDES_CTRL2, 645d6d29292SRussell King MV_AN_21X0_SERDES_CTRL2_AUTO_INIT_DIS); 646d6d29292SRussell King } 647d6d29292SRussell King 648d6d29292SRussell King static int mv2110_select_mactype(unsigned long *interfaces) 649d6d29292SRussell King { 650d6d29292SRussell King if (test_bit(PHY_INTERFACE_MODE_USXGMII, interfaces)) 651d6d29292SRussell King return MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII; 652d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces) && 653d6d29292SRussell King !test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) 654d6d29292SRussell King return MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER; 655d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) 656d6d29292SRussell King return MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH; 657d6d29292SRussell King else 658d6d29292SRussell King return -1; 659d6d29292SRussell King } 660d6d29292SRussell King 66197bbe3bdSMarek Behún static int mv3310_get_mactype(struct phy_device *phydev) 66297bbe3bdSMarek Behún { 66397bbe3bdSMarek Behún int mactype; 66497bbe3bdSMarek Behún 66597bbe3bdSMarek Behún mactype = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL); 66697bbe3bdSMarek Behún if (mactype < 0) 66797bbe3bdSMarek Behún return mactype; 66897bbe3bdSMarek Behún 66997bbe3bdSMarek Behún return mactype & MV_V2_33X0_PORT_CTRL_MACTYPE_MASK; 67097bbe3bdSMarek Behún } 67197bbe3bdSMarek Behún 672d6d29292SRussell King static int mv3310_set_mactype(struct phy_device *phydev, int mactype) 673d6d29292SRussell King { 674d6d29292SRussell King int ret; 675d6d29292SRussell King 676d6d29292SRussell King mactype &= MV_V2_33X0_PORT_CTRL_MACTYPE_MASK; 677d6d29292SRussell King ret = phy_modify_mmd_changed(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, 678d6d29292SRussell King MV_V2_33X0_PORT_CTRL_MACTYPE_MASK, 679d6d29292SRussell King mactype); 680d6d29292SRussell King if (ret <= 0) 681d6d29292SRussell King return ret; 682d6d29292SRussell King 683d6d29292SRussell King return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, 684d6d29292SRussell King MV_V2_33X0_PORT_CTRL_SWRST); 685d6d29292SRussell King } 686d6d29292SRussell King 687d6d29292SRussell King static int mv3310_select_mactype(unsigned long *interfaces) 688d6d29292SRussell King { 689d6d29292SRussell King if (test_bit(PHY_INTERFACE_MODE_USXGMII, interfaces)) 690d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII; 691d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces) && 692d6d29292SRussell King test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) 693d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER; 694d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces) && 695d6d29292SRussell King test_bit(PHY_INTERFACE_MODE_RXAUI, interfaces)) 696d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI; 697d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces) && 698d6d29292SRussell King test_bit(PHY_INTERFACE_MODE_XAUI, interfaces)) 699d6d29292SRussell King return MV_V2_3310_PORT_CTRL_MACTYPE_XAUI; 700d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_10GBASER, interfaces)) 701d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH; 702d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_RXAUI, interfaces)) 703d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH; 704d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_XAUI, interfaces)) 705d6d29292SRussell King return MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH; 706d6d29292SRussell King else if (test_bit(PHY_INTERFACE_MODE_SGMII, interfaces)) 707d6d29292SRussell King return MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER; 708d6d29292SRussell King else 709d6d29292SRussell King return -1; 710d6d29292SRussell King } 711d6d29292SRussell King 7122cb6d63bSRussell King (Oracle) static const struct mv3310_mactype mv2110_mactypes[] = { 7132cb6d63bSRussell King (Oracle) [MV_PMA_21X0_PORT_CTRL_MACTYPE_USXGMII] = { 7142cb6d63bSRussell King (Oracle) .valid = true, 7152cb6d63bSRussell King (Oracle) .fixed_interface = true, 7162cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_USXGMII, 7172cb6d63bSRussell King (Oracle) }, 7182cb6d63bSRussell King (Oracle) [MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER] = { 7192cb6d63bSRussell King (Oracle) .valid = true, 7202cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_NA, 7212cb6d63bSRussell King (Oracle) }, 7222cb6d63bSRussell King (Oracle) [MV_PMA_21X0_PORT_CTRL_MACTYPE_5GBASER_NO_SGMII_AN] = { 7232cb6d63bSRussell King (Oracle) .valid = true, 7242cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_NA, 7252cb6d63bSRussell King (Oracle) }, 7262cb6d63bSRussell King (Oracle) [MV_PMA_21X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH] = { 7272cb6d63bSRussell King (Oracle) .valid = true, 7282cb6d63bSRussell King (Oracle) .fixed_interface = true, 7292cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7302cb6d63bSRussell King (Oracle) }, 7312cb6d63bSRussell King (Oracle) }; 73297bbe3bdSMarek Behún 7332cb6d63bSRussell King (Oracle) static const struct mv3310_mactype mv3310_mactypes[] = { 7342cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI] = { 7352cb6d63bSRussell King (Oracle) .valid = true, 7362cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_RXAUI, 7372cb6d63bSRussell King (Oracle) }, 7382cb6d63bSRussell King (Oracle) [MV_V2_3310_PORT_CTRL_MACTYPE_XAUI_RATE_MATCH] = { 7392cb6d63bSRussell King (Oracle) .valid = true, 7402cb6d63bSRussell King (Oracle) .fixed_interface = true, 7412cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_XAUI, 7422cb6d63bSRussell King (Oracle) }, 7432cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH] = { 7442cb6d63bSRussell King (Oracle) .valid = true, 7452cb6d63bSRussell King (Oracle) .fixed_interface = true, 7462cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_RXAUI, 7472cb6d63bSRussell King (Oracle) }, 7482cb6d63bSRussell King (Oracle) [MV_V2_3310_PORT_CTRL_MACTYPE_XAUI] = { 7492cb6d63bSRussell King (Oracle) .valid = true, 7502cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_XAUI, 7512cb6d63bSRussell King (Oracle) }, 7522cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER] = { 7532cb6d63bSRussell King (Oracle) .valid = true, 7542cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7552cb6d63bSRussell King (Oracle) }, 7562cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN] = { 7572cb6d63bSRussell King (Oracle) .valid = true, 7582cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7592cb6d63bSRussell King (Oracle) }, 7602cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH] = { 7612cb6d63bSRussell King (Oracle) .valid = true, 7622cb6d63bSRussell King (Oracle) .fixed_interface = true, 7632cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7642cb6d63bSRussell King (Oracle) }, 7652cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII] = { 7662cb6d63bSRussell King (Oracle) .valid = true, 7672cb6d63bSRussell King (Oracle) .fixed_interface = true, 7682cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_USXGMII, 7692cb6d63bSRussell King (Oracle) }, 7702cb6d63bSRussell King (Oracle) }; 77197bbe3bdSMarek Behún 7722cb6d63bSRussell King (Oracle) static const struct mv3310_mactype mv3340_mactypes[] = { 7732cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI] = { 7742cb6d63bSRussell King (Oracle) .valid = true, 7752cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_RXAUI, 7762cb6d63bSRussell King (Oracle) }, 7772cb6d63bSRussell King (Oracle) [MV_V2_3340_PORT_CTRL_MACTYPE_RXAUI_NO_SGMII_AN] = { 7782cb6d63bSRussell King (Oracle) .valid = true, 7792cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_RXAUI, 7802cb6d63bSRussell King (Oracle) }, 7812cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_RXAUI_RATE_MATCH] = { 7822cb6d63bSRussell King (Oracle) .valid = true, 7832cb6d63bSRussell King (Oracle) .fixed_interface = true, 7842cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_RXAUI, 7852cb6d63bSRussell King (Oracle) }, 7862cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER] = { 7872cb6d63bSRussell King (Oracle) .valid = true, 7882cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7892cb6d63bSRussell King (Oracle) }, 7902cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_NO_SGMII_AN] = { 7912cb6d63bSRussell King (Oracle) .valid = true, 7922cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7932cb6d63bSRussell King (Oracle) }, 7942cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_10GBASER_RATE_MATCH] = { 7952cb6d63bSRussell King (Oracle) .valid = true, 7962cb6d63bSRussell King (Oracle) .fixed_interface = true, 7972cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_10GBASER, 7982cb6d63bSRussell King (Oracle) }, 7992cb6d63bSRussell King (Oracle) [MV_V2_33X0_PORT_CTRL_MACTYPE_USXGMII] = { 8002cb6d63bSRussell King (Oracle) .valid = true, 8012cb6d63bSRussell King (Oracle) .fixed_interface = true, 8022cb6d63bSRussell King (Oracle) .interface_10g = PHY_INTERFACE_MODE_USXGMII, 8032cb6d63bSRussell King (Oracle) }, 8042cb6d63bSRussell King (Oracle) }; 8059885d016SMarek Behún 806*82f2e76bSRussell King (Oracle) static void mv3310_fill_possible_interfaces(struct phy_device *phydev) 807*82f2e76bSRussell King (Oracle) { 808*82f2e76bSRussell King (Oracle) struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 809*82f2e76bSRussell King (Oracle) unsigned long *possible = phydev->possible_interfaces; 810*82f2e76bSRussell King (Oracle) const struct mv3310_mactype *mactype = priv->mactype; 811*82f2e76bSRussell King (Oracle) 812*82f2e76bSRussell King (Oracle) if (mactype->interface_10g != PHY_INTERFACE_MODE_NA) 813*82f2e76bSRussell King (Oracle) __set_bit(priv->mactype->interface_10g, possible); 814*82f2e76bSRussell King (Oracle) 815*82f2e76bSRussell King (Oracle) if (!mactype->fixed_interface) { 816*82f2e76bSRussell King (Oracle) __set_bit(PHY_INTERFACE_MODE_5GBASER, possible); 817*82f2e76bSRussell King (Oracle) __set_bit(PHY_INTERFACE_MODE_2500BASEX, possible); 818*82f2e76bSRussell King (Oracle) __set_bit(PHY_INTERFACE_MODE_SGMII, possible); 819*82f2e76bSRussell King (Oracle) } 820*82f2e76bSRussell King (Oracle) } 821*82f2e76bSRussell King (Oracle) 82297bbe3bdSMarek Behún static int mv3310_config_init(struct phy_device *phydev) 82397bbe3bdSMarek Behún { 824261a74c6SMarek Behún struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 82597bbe3bdSMarek Behún const struct mv3310_chip *chip = to_mv3310_chip(phydev); 82697bbe3bdSMarek Behún int err, mactype; 827c9cc1c81SRussell King 82820b2af32SRussell King /* Check that the PHY interface type is compatible */ 829261a74c6SMarek Behún if (!test_bit(phydev->interface, priv->supported_interfaces)) 83020b2af32SRussell King return -ENODEV; 83120b2af32SRussell King 8328d8963c3SRussell King phydev->mdix_ctrl = ETH_TP_MDI_AUTO; 8338d8963c3SRussell King 834c9cc1c81SRussell King /* Power up so reset works */ 835c9cc1c81SRussell King err = mv3310_power_up(phydev); 836c9cc1c81SRussell King if (err) 837c9cc1c81SRussell King return err; 838c9cc1c81SRussell King 839d6d29292SRussell King /* If host provided host supported interface modes, try to select the 840d6d29292SRussell King * best one 841d6d29292SRussell King */ 842d6d29292SRussell King if (!phy_interface_empty(phydev->host_interfaces)) { 843d6d29292SRussell King mactype = chip->select_mactype(phydev->host_interfaces); 844d6d29292SRussell King if (mactype >= 0) { 845d6d29292SRussell King phydev_info(phydev, "Changing MACTYPE to %i\n", 846d6d29292SRussell King mactype); 847d6d29292SRussell King err = chip->set_mactype(phydev, mactype); 848d6d29292SRussell King if (err) 849d6d29292SRussell King return err; 850d6d29292SRussell King } 851d6d29292SRussell King } 852d6d29292SRussell King 85397bbe3bdSMarek Behún mactype = chip->get_mactype(phydev); 85497bbe3bdSMarek Behún if (mactype < 0) 85597bbe3bdSMarek Behún return mactype; 85697bbe3bdSMarek Behún 8572cb6d63bSRussell King (Oracle) if (mactype >= chip->n_mactypes || !chip->mactypes[mactype].valid) { 858ccbf2891SMarek Behún phydev_err(phydev, "MACTYPE configuration invalid\n"); 8592cb6d63bSRussell King (Oracle) return -EINVAL; 860ccbf2891SMarek Behún } 861e1170333SBaruch Siach 8622cb6d63bSRussell King (Oracle) priv->mactype = &chip->mactypes[mactype]; 8632cb6d63bSRussell King (Oracle) 864*82f2e76bSRussell King (Oracle) mv3310_fill_possible_interfaces(phydev); 865*82f2e76bSRussell King (Oracle) 866a585c03eSRussell King /* Enable EDPD mode - saving 600mW */ 8674075a6a0SRussell King err = mv3310_set_edpd(phydev, ETHTOOL_PHY_EDPD_DFLT_TX_MSECS); 8684075a6a0SRussell King if (err) 8694075a6a0SRussell King return err; 8704075a6a0SRussell King 8714075a6a0SRussell King /* Allow downshift */ 8724075a6a0SRussell King err = mv3310_set_downshift(phydev, DOWNSHIFT_DEV_DEFAULT_COUNT); 8734075a6a0SRussell King if (err && err != -EOPNOTSUPP) 8744075a6a0SRussell King return err; 8754075a6a0SRussell King 8764075a6a0SRussell King return 0; 87774145424SMaxime Chevallier } 87874145424SMaxime Chevallier 87974145424SMaxime Chevallier static int mv3310_get_features(struct phy_device *phydev) 88074145424SMaxime Chevallier { 88174145424SMaxime Chevallier int ret, val; 88274145424SMaxime Chevallier 883ac3f5533SMaxime Chevallier ret = genphy_c45_pma_read_abilities(phydev); 884ac3f5533SMaxime Chevallier if (ret) 885ac3f5533SMaxime Chevallier return ret; 88620b2af32SRussell King 887c47455f9SMaxime Chevallier if (mv3310_has_pma_ngbaset_quirk(phydev)) { 888c47455f9SMaxime Chevallier val = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, 889c47455f9SMaxime Chevallier MDIO_PMA_NG_EXTABLE); 890c47455f9SMaxime Chevallier if (val < 0) 891c47455f9SMaxime Chevallier return val; 892c47455f9SMaxime Chevallier 893c47455f9SMaxime Chevallier linkmode_mod_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, 894c47455f9SMaxime Chevallier phydev->supported, 895c47455f9SMaxime Chevallier val & MDIO_PMA_NG_EXTABLE_2_5GBT); 896c47455f9SMaxime Chevallier 897c47455f9SMaxime Chevallier linkmode_mod_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, 898c47455f9SMaxime Chevallier phydev->supported, 899c47455f9SMaxime Chevallier val & MDIO_PMA_NG_EXTABLE_5GBT); 900c47455f9SMaxime Chevallier } 901c47455f9SMaxime Chevallier 90220b2af32SRussell King return 0; 90320b2af32SRussell King } 90420b2af32SRussell King 9058d8963c3SRussell King static int mv3310_config_mdix(struct phy_device *phydev) 9068d8963c3SRussell King { 9078d8963c3SRussell King u16 val; 9088d8963c3SRussell King int err; 9098d8963c3SRussell King 9108d8963c3SRussell King switch (phydev->mdix_ctrl) { 9118d8963c3SRussell King case ETH_TP_MDI_AUTO: 9128d8963c3SRussell King val = MV_PCS_CSCR1_MDIX_AUTO; 9138d8963c3SRussell King break; 9148d8963c3SRussell King case ETH_TP_MDI_X: 9158d8963c3SRussell King val = MV_PCS_CSCR1_MDIX_MDIX; 9168d8963c3SRussell King break; 9178d8963c3SRussell King case ETH_TP_MDI: 9188d8963c3SRussell King val = MV_PCS_CSCR1_MDIX_MDI; 9198d8963c3SRussell King break; 9208d8963c3SRussell King default: 9218d8963c3SRussell King return -EINVAL; 9228d8963c3SRussell King } 9238d8963c3SRussell King 9248d8963c3SRussell King err = phy_modify_mmd_changed(phydev, MDIO_MMD_PCS, MV_PCS_CSCR1, 9258d8963c3SRussell King MV_PCS_CSCR1_MDIX_MASK, val); 9268d8963c3SRussell King if (err > 0) 9278d8963c3SRussell King err = mv3310_reset(phydev, MV_PCS_BASE_T); 9288d8963c3SRussell King 9298d8963c3SRussell King return err; 9308d8963c3SRussell King } 9318d8963c3SRussell King 93220b2af32SRussell King static int mv3310_config_aneg(struct phy_device *phydev) 93320b2af32SRussell King { 93420b2af32SRussell King bool changed = false; 9353c1bcc86SAndrew Lunn u16 reg; 93620b2af32SRussell King int ret; 93720b2af32SRussell King 9388d8963c3SRussell King ret = mv3310_config_mdix(phydev); 9398d8963c3SRussell King if (ret < 0) 9408d8963c3SRussell King return ret; 941ea4efe25SRussell King 94230de65c3SHeiner Kallweit if (phydev->autoneg == AUTONEG_DISABLE) 94330de65c3SHeiner Kallweit return genphy_c45_pma_setup_forced(phydev); 94420b2af32SRussell King 9453de97f3cSAndrew Lunn ret = genphy_c45_an_config_aneg(phydev); 94620b2af32SRussell King if (ret < 0) 94720b2af32SRussell King return ret; 94820b2af32SRussell King if (ret > 0) 94920b2af32SRussell King changed = true; 95020b2af32SRussell King 9513de97f3cSAndrew Lunn /* Clause 45 has no standardized support for 1000BaseT, therefore 9523de97f3cSAndrew Lunn * use vendor registers for this mode. 9533de97f3cSAndrew Lunn */ 9543c1bcc86SAndrew Lunn reg = linkmode_adv_to_mii_ctrl1000_t(phydev->advertising); 955b06d8e5aSHeiner Kallweit ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MV_AN_CTRL1000, 9563c1bcc86SAndrew Lunn ADVERTISE_1000FULL | ADVERTISE_1000HALF, reg); 95720b2af32SRussell King if (ret < 0) 95820b2af32SRussell King return ret; 95920b2af32SRussell King if (ret > 0) 96020b2af32SRussell King changed = true; 96120b2af32SRussell King 9626b4cb6cbSHeiner Kallweit return genphy_c45_check_and_restart_aneg(phydev, changed); 96320b2af32SRussell King } 96420b2af32SRussell King 96520b2af32SRussell King static int mv3310_aneg_done(struct phy_device *phydev) 96620b2af32SRussell King { 96720b2af32SRussell King int val; 96820b2af32SRussell King 96920b2af32SRussell King val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1); 97020b2af32SRussell King if (val < 0) 97120b2af32SRussell King return val; 97220b2af32SRussell King 97320b2af32SRussell King if (val & MDIO_STAT1_LSTATUS) 97420b2af32SRussell King return 1; 97520b2af32SRussell King 97620b2af32SRussell King return genphy_c45_aneg_done(phydev); 97720b2af32SRussell King } 97820b2af32SRussell King 97936c4449aSRussell King static void mv3310_update_interface(struct phy_device *phydev) 98036c4449aSRussell King { 981e1170333SBaruch Siach struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 982e1170333SBaruch Siach 983ccbf2891SMarek Behún if (!phydev->link) 984ccbf2891SMarek Behún return; 985ccbf2891SMarek Behún 98697bbe3bdSMarek Behún /* In all of the "* with Rate Matching" modes the PHY interface is fixed 98797bbe3bdSMarek Behún * at 10Gb. The PHY adapts the rate to actual wire speed with help of 988e1170333SBaruch Siach * internal 16KB buffer. 989ccbf2891SMarek Behún * 990ccbf2891SMarek Behún * In USXGMII mode the PHY interface mode is also fixed. 991e1170333SBaruch Siach */ 9922cb6d63bSRussell King (Oracle) if (priv->mactype->fixed_interface) { 9932cb6d63bSRussell King (Oracle) phydev->interface = priv->mactype->interface_10g; 994e1170333SBaruch Siach return; 995e1170333SBaruch Siach } 996e1170333SBaruch Siach 997ccbf2891SMarek Behún /* The PHY automatically switches its serdes interface (and active PHYXS 998ccbf2891SMarek Behún * instance) between Cisco SGMII, 2500BaseX, 5GBase-R and 10GBase-R / 999ccbf2891SMarek Behún * xaui / rxaui modes according to the speed. 1000ccbf2891SMarek Behún * Florian suggests setting phydev->interface to communicate this to the 1001ccbf2891SMarek Behún * MAC. Only do this if we are already in one of the above modes. 100236c4449aSRussell King */ 1003e555e5b1SMaxime Chevallier switch (phydev->speed) { 1004e555e5b1SMaxime Chevallier case SPEED_10000: 10052cb6d63bSRussell King (Oracle) phydev->interface = priv->mactype->interface_10g; 1006e555e5b1SMaxime Chevallier break; 10070d375542SMarek Behún case SPEED_5000: 10080d375542SMarek Behún phydev->interface = PHY_INTERFACE_MODE_5GBASER; 10090d375542SMarek Behún break; 1010e555e5b1SMaxime Chevallier case SPEED_2500: 1011e555e5b1SMaxime Chevallier phydev->interface = PHY_INTERFACE_MODE_2500BASEX; 1012e555e5b1SMaxime Chevallier break; 1013e555e5b1SMaxime Chevallier case SPEED_1000: 1014e555e5b1SMaxime Chevallier case SPEED_100: 1015e555e5b1SMaxime Chevallier case SPEED_10: 101636c4449aSRussell King phydev->interface = PHY_INTERFACE_MODE_SGMII; 1017e555e5b1SMaxime Chevallier break; 1018e555e5b1SMaxime Chevallier default: 1019e555e5b1SMaxime Chevallier break; 1020e555e5b1SMaxime Chevallier } 102136c4449aSRussell King } 102236c4449aSRussell King 102320b2af32SRussell King /* 10GBASE-ER,LR,LRM,SR do not support autonegotiation. */ 1024c84786faSRussell King static int mv3310_read_status_10gbaser(struct phy_device *phydev) 102520b2af32SRussell King { 102620b2af32SRussell King phydev->link = 1; 102720b2af32SRussell King phydev->speed = SPEED_10000; 102820b2af32SRussell King phydev->duplex = DUPLEX_FULL; 10294217a64eSMichael Walle phydev->port = PORT_FIBRE; 103020b2af32SRussell King 103120b2af32SRussell King return 0; 103220b2af32SRussell King } 103320b2af32SRussell King 1034c84786faSRussell King static int mv3310_read_status_copper(struct phy_device *phydev) 103520b2af32SRussell King { 1036c84786faSRussell King int cssr1, speed, val; 103720b2af32SRussell King 1038998a8a83SHeiner Kallweit val = genphy_c45_read_link(phydev); 103920b2af32SRussell King if (val < 0) 104020b2af32SRussell King return val; 104120b2af32SRussell King 104220b2af32SRussell King val = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1); 104320b2af32SRussell King if (val < 0) 104420b2af32SRussell King return val; 104520b2af32SRussell King 1046c84786faSRussell King cssr1 = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_CSSR1); 1047c84786faSRussell King if (cssr1 < 0) 10480ed9704bSBaruch Siach return cssr1; 1049c84786faSRussell King 1050c84786faSRussell King /* If the link settings are not resolved, mark the link down */ 1051c84786faSRussell King if (!(cssr1 & MV_PCS_CSSR1_RESOLVED)) { 1052c84786faSRussell King phydev->link = 0; 1053c84786faSRussell King return 0; 1054c84786faSRussell King } 1055c84786faSRussell King 1056c84786faSRussell King /* Read the copper link settings */ 1057c84786faSRussell King speed = cssr1 & MV_PCS_CSSR1_SPD1_MASK; 1058c84786faSRussell King if (speed == MV_PCS_CSSR1_SPD1_SPD2) 1059c84786faSRussell King speed |= cssr1 & MV_PCS_CSSR1_SPD2_MASK; 1060c84786faSRussell King 1061c84786faSRussell King switch (speed) { 1062c84786faSRussell King case MV_PCS_CSSR1_SPD1_SPD2 | MV_PCS_CSSR1_SPD2_10000: 1063c84786faSRussell King phydev->speed = SPEED_10000; 1064c84786faSRussell King break; 1065c84786faSRussell King 1066c84786faSRussell King case MV_PCS_CSSR1_SPD1_SPD2 | MV_PCS_CSSR1_SPD2_5000: 1067c84786faSRussell King phydev->speed = SPEED_5000; 1068c84786faSRussell King break; 1069c84786faSRussell King 1070c84786faSRussell King case MV_PCS_CSSR1_SPD1_SPD2 | MV_PCS_CSSR1_SPD2_2500: 1071c84786faSRussell King phydev->speed = SPEED_2500; 1072c84786faSRussell King break; 1073c84786faSRussell King 1074c84786faSRussell King case MV_PCS_CSSR1_SPD1_1000: 1075c84786faSRussell King phydev->speed = SPEED_1000; 1076c84786faSRussell King break; 1077c84786faSRussell King 1078c84786faSRussell King case MV_PCS_CSSR1_SPD1_100: 1079c84786faSRussell King phydev->speed = SPEED_100; 1080c84786faSRussell King break; 1081c84786faSRussell King 1082c84786faSRussell King case MV_PCS_CSSR1_SPD1_10: 1083c84786faSRussell King phydev->speed = SPEED_10; 1084c84786faSRussell King break; 1085c84786faSRussell King } 1086c84786faSRussell King 1087c84786faSRussell King phydev->duplex = cssr1 & MV_PCS_CSSR1_DUPLEX_FULL ? 1088c84786faSRussell King DUPLEX_FULL : DUPLEX_HALF; 10894217a64eSMichael Walle phydev->port = PORT_TP; 1090c84786faSRussell King phydev->mdix = cssr1 & MV_PCS_CSSR1_MDIX ? 1091c84786faSRussell King ETH_TP_MDI_X : ETH_TP_MDI; 1092c84786faSRussell King 109320b2af32SRussell King if (val & MDIO_AN_STAT1_COMPLETE) { 109420b2af32SRussell King val = genphy_c45_read_lpa(phydev); 109520b2af32SRussell King if (val < 0) 109620b2af32SRussell King return val; 109720b2af32SRussell King 1098cc1122b0SColin Ian King /* Read the link partner's 1G advertisement */ 109920b2af32SRussell King val = phy_read_mmd(phydev, MDIO_MMD_AN, MV_AN_STAT1000); 110020b2af32SRussell King if (val < 0) 110120b2af32SRussell King return val; 110220b2af32SRussell King 110378a24df3SAndrew Lunn mii_stat1000_mod_linkmode_lpa_t(phydev->lp_advertising, val); 110420b2af32SRussell King 1105c84786faSRussell King /* Update the pause status */ 1106c84786faSRussell King phy_resolve_aneg_pause(phydev); 110720b2af32SRussell King } 110820b2af32SRussell King 1109c84786faSRussell King return 0; 111020b2af32SRussell King } 111120b2af32SRussell King 1112c84786faSRussell King static int mv3310_read_status(struct phy_device *phydev) 1113c84786faSRussell King { 1114c84786faSRussell King int err, val; 1115ea4efe25SRussell King 1116c84786faSRussell King phydev->speed = SPEED_UNKNOWN; 1117c84786faSRussell King phydev->duplex = DUPLEX_UNKNOWN; 1118c84786faSRussell King linkmode_zero(phydev->lp_advertising); 1119c84786faSRussell King phydev->link = 0; 1120c84786faSRussell King phydev->pause = 0; 1121c84786faSRussell King phydev->asym_pause = 0; 1122ea4efe25SRussell King phydev->mdix = ETH_TP_MDI_INVALID; 1123ea4efe25SRussell King 1124c84786faSRussell King val = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_BASE_R + MDIO_STAT1); 1125c84786faSRussell King if (val < 0) 1126c84786faSRussell King return val; 1127c84786faSRussell King 1128c84786faSRussell King if (val & MDIO_STAT1_LSTATUS) 1129c84786faSRussell King err = mv3310_read_status_10gbaser(phydev); 1130c84786faSRussell King else 1131c84786faSRussell King err = mv3310_read_status_copper(phydev); 1132c84786faSRussell King if (err < 0) 1133c84786faSRussell King return err; 1134c84786faSRussell King 1135c84786faSRussell King if (phydev->link) 113636c4449aSRussell King mv3310_update_interface(phydev); 113720b2af32SRussell King 113820b2af32SRussell King return 0; 113920b2af32SRussell King } 114020b2af32SRussell King 1141a585c03eSRussell King static int mv3310_get_tunable(struct phy_device *phydev, 1142a585c03eSRussell King struct ethtool_tunable *tuna, void *data) 1143a585c03eSRussell King { 1144a585c03eSRussell King switch (tuna->id) { 11454075a6a0SRussell King case ETHTOOL_PHY_DOWNSHIFT: 11464075a6a0SRussell King return mv3310_get_downshift(phydev, data); 1147a585c03eSRussell King case ETHTOOL_PHY_EDPD: 1148a585c03eSRussell King return mv3310_get_edpd(phydev, data); 1149a585c03eSRussell King default: 1150a585c03eSRussell King return -EOPNOTSUPP; 1151a585c03eSRussell King } 1152a585c03eSRussell King } 1153a585c03eSRussell King 1154a585c03eSRussell King static int mv3310_set_tunable(struct phy_device *phydev, 1155a585c03eSRussell King struct ethtool_tunable *tuna, const void *data) 1156a585c03eSRussell King { 1157a585c03eSRussell King switch (tuna->id) { 11584075a6a0SRussell King case ETHTOOL_PHY_DOWNSHIFT: 11594075a6a0SRussell King return mv3310_set_downshift(phydev, *(u8 *)data); 1160a585c03eSRussell King case ETHTOOL_PHY_EDPD: 1161a585c03eSRussell King return mv3310_set_edpd(phydev, *(u16 *)data); 1162a585c03eSRussell King default: 1163a585c03eSRussell King return -EOPNOTSUPP; 1164a585c03eSRussell King } 1165a585c03eSRussell King } 1166a585c03eSRussell King 11674075a6a0SRussell King static bool mv3310_has_downshift(struct phy_device *phydev) 11684075a6a0SRussell King { 11694075a6a0SRussell King struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev); 11704075a6a0SRussell King 11714075a6a0SRussell King /* Fails to downshift with firmware older than v0.3.5.0 */ 11724075a6a0SRussell King return priv->firmware_ver >= MV_VERSION(0,3,5,0); 11734075a6a0SRussell King } 11744075a6a0SRussell King 1175261a74c6SMarek Behún static void mv3310_init_supported_interfaces(unsigned long *mask) 1176261a74c6SMarek Behún { 1177261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_SGMII, mask); 1178261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_2500BASEX, mask); 1179261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_5GBASER, mask); 1180261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_XAUI, mask); 1181261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_RXAUI, mask); 1182261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_10GBASER, mask); 1183261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_USXGMII, mask); 1184261a74c6SMarek Behún } 1185261a74c6SMarek Behún 11869885d016SMarek Behún static void mv3340_init_supported_interfaces(unsigned long *mask) 11879885d016SMarek Behún { 11889885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_SGMII, mask); 11899885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_2500BASEX, mask); 11909885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_5GBASER, mask); 11919885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_RXAUI, mask); 11929885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_10GBASER, mask); 11939885d016SMarek Behún __set_bit(PHY_INTERFACE_MODE_USXGMII, mask); 11949885d016SMarek Behún } 11959885d016SMarek Behún 1196261a74c6SMarek Behún static void mv2110_init_supported_interfaces(unsigned long *mask) 1197261a74c6SMarek Behún { 1198261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_SGMII, mask); 1199261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_2500BASEX, mask); 1200261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_5GBASER, mask); 1201261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_10GBASER, mask); 1202261a74c6SMarek Behún __set_bit(PHY_INTERFACE_MODE_USXGMII, mask); 1203261a74c6SMarek Behún } 1204261a74c6SMarek Behún 12050fca947cSMarek Behún static void mv2111_init_supported_interfaces(unsigned long *mask) 12060fca947cSMarek Behún { 12070fca947cSMarek Behún __set_bit(PHY_INTERFACE_MODE_SGMII, mask); 12080fca947cSMarek Behún __set_bit(PHY_INTERFACE_MODE_2500BASEX, mask); 12090fca947cSMarek Behún __set_bit(PHY_INTERFACE_MODE_10GBASER, mask); 12100fca947cSMarek Behún __set_bit(PHY_INTERFACE_MODE_USXGMII, mask); 12110fca947cSMarek Behún } 12120fca947cSMarek Behún 121397bbe3bdSMarek Behún static const struct mv3310_chip mv3310_type = { 12144075a6a0SRussell King .has_downshift = mv3310_has_downshift, 1215261a74c6SMarek Behún .init_supported_interfaces = mv3310_init_supported_interfaces, 121697bbe3bdSMarek Behún .get_mactype = mv3310_get_mactype, 1217d6d29292SRussell King .set_mactype = mv3310_set_mactype, 1218d6d29292SRussell King .select_mactype = mv3310_select_mactype, 12192cb6d63bSRussell King (Oracle) 12202cb6d63bSRussell King (Oracle) .mactypes = mv3310_mactypes, 12212cb6d63bSRussell King (Oracle) .n_mactypes = ARRAY_SIZE(mv3310_mactypes), 1222884d9a67SMarek Behún 1223884d9a67SMarek Behún #ifdef CONFIG_HWMON 1224884d9a67SMarek Behún .hwmon_read_temp_reg = mv3310_hwmon_read_temp_reg, 1225884d9a67SMarek Behún #endif 122697bbe3bdSMarek Behún }; 122797bbe3bdSMarek Behún 12289885d016SMarek Behún static const struct mv3310_chip mv3340_type = { 12294075a6a0SRussell King .has_downshift = mv3310_has_downshift, 12309885d016SMarek Behún .init_supported_interfaces = mv3340_init_supported_interfaces, 12319885d016SMarek Behún .get_mactype = mv3310_get_mactype, 1232d6d29292SRussell King .set_mactype = mv3310_set_mactype, 1233d6d29292SRussell King .select_mactype = mv3310_select_mactype, 12342cb6d63bSRussell King (Oracle) 12352cb6d63bSRussell King (Oracle) .mactypes = mv3340_mactypes, 12362cb6d63bSRussell King (Oracle) .n_mactypes = ARRAY_SIZE(mv3340_mactypes), 12379885d016SMarek Behún 12389885d016SMarek Behún #ifdef CONFIG_HWMON 12399885d016SMarek Behún .hwmon_read_temp_reg = mv3310_hwmon_read_temp_reg, 12409885d016SMarek Behún #endif 12419885d016SMarek Behún }; 12429885d016SMarek Behún 124397bbe3bdSMarek Behún static const struct mv3310_chip mv2110_type = { 1244261a74c6SMarek Behún .init_supported_interfaces = mv2110_init_supported_interfaces, 124597bbe3bdSMarek Behún .get_mactype = mv2110_get_mactype, 1246d6d29292SRussell King .set_mactype = mv2110_set_mactype, 1247d6d29292SRussell King .select_mactype = mv2110_select_mactype, 12482cb6d63bSRussell King (Oracle) 12492cb6d63bSRussell King (Oracle) .mactypes = mv2110_mactypes, 12502cb6d63bSRussell King (Oracle) .n_mactypes = ARRAY_SIZE(mv2110_mactypes), 1251884d9a67SMarek Behún 1252884d9a67SMarek Behún #ifdef CONFIG_HWMON 1253884d9a67SMarek Behún .hwmon_read_temp_reg = mv2110_hwmon_read_temp_reg, 1254884d9a67SMarek Behún #endif 125597bbe3bdSMarek Behún }; 125697bbe3bdSMarek Behún 12570fca947cSMarek Behún static const struct mv3310_chip mv2111_type = { 12580fca947cSMarek Behún .init_supported_interfaces = mv2111_init_supported_interfaces, 12590fca947cSMarek Behún .get_mactype = mv2110_get_mactype, 1260d6d29292SRussell King .set_mactype = mv2110_set_mactype, 1261d6d29292SRussell King .select_mactype = mv2110_select_mactype, 12622cb6d63bSRussell King (Oracle) 12632cb6d63bSRussell King (Oracle) .mactypes = mv2110_mactypes, 12642cb6d63bSRussell King (Oracle) .n_mactypes = ARRAY_SIZE(mv2110_mactypes), 12650fca947cSMarek Behún 12660fca947cSMarek Behún #ifdef CONFIG_HWMON 12670fca947cSMarek Behún .hwmon_read_temp_reg = mv2110_hwmon_read_temp_reg, 12680fca947cSMarek Behún #endif 12690fca947cSMarek Behún }; 12700fca947cSMarek Behún 1271a5de4be0SMarek Behún static int mv3310_get_number_of_ports(struct phy_device *phydev) 1272a5de4be0SMarek Behún { 1273a5de4be0SMarek Behún int ret; 1274a5de4be0SMarek Behún 1275a5de4be0SMarek Behún ret = phy_read_mmd(phydev, MDIO_MMD_PCS, MV_PCS_PORT_INFO); 1276a5de4be0SMarek Behún if (ret < 0) 1277a5de4be0SMarek Behún return ret; 1278a5de4be0SMarek Behún 1279a5de4be0SMarek Behún ret &= MV_PCS_PORT_INFO_NPORTS_MASK; 1280a5de4be0SMarek Behún ret >>= MV_PCS_PORT_INFO_NPORTS_SHIFT; 1281a5de4be0SMarek Behún 1282a5de4be0SMarek Behún return ret + 1; 1283a5de4be0SMarek Behún } 1284a5de4be0SMarek Behún 1285a5de4be0SMarek Behún static int mv3310_match_phy_device(struct phy_device *phydev) 1286a5de4be0SMarek Behún { 12870d55649dSVladimir Oltean if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & 12880d55649dSVladimir Oltean MARVELL_PHY_ID_MASK) != MARVELL_PHY_ID_88X3310) 12890d55649dSVladimir Oltean return 0; 12900d55649dSVladimir Oltean 1291a5de4be0SMarek Behún return mv3310_get_number_of_ports(phydev) == 1; 1292a5de4be0SMarek Behún } 1293a5de4be0SMarek Behún 1294a5de4be0SMarek Behún static int mv3340_match_phy_device(struct phy_device *phydev) 1295a5de4be0SMarek Behún { 12960d55649dSVladimir Oltean if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & 12970d55649dSVladimir Oltean MARVELL_PHY_ID_MASK) != MARVELL_PHY_ID_88X3310) 12980d55649dSVladimir Oltean return 0; 12990d55649dSVladimir Oltean 1300a5de4be0SMarek Behún return mv3310_get_number_of_ports(phydev) == 4; 1301a5de4be0SMarek Behún } 1302a5de4be0SMarek Behún 13030fca947cSMarek Behún static int mv211x_match_phy_device(struct phy_device *phydev, bool has_5g) 13040fca947cSMarek Behún { 13050fca947cSMarek Behún int val; 13060fca947cSMarek Behún 13070fca947cSMarek Behún if ((phydev->c45_ids.device_ids[MDIO_MMD_PMAPMD] & 13080fca947cSMarek Behún MARVELL_PHY_ID_MASK) != MARVELL_PHY_ID_88E2110) 13090fca947cSMarek Behún return 0; 13100fca947cSMarek Behún 13110fca947cSMarek Behún val = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_SPEED); 13120fca947cSMarek Behún if (val < 0) 13130fca947cSMarek Behún return val; 13140fca947cSMarek Behún 13150fca947cSMarek Behún return !!(val & MDIO_PCS_SPEED_5G) == has_5g; 13160fca947cSMarek Behún } 13170fca947cSMarek Behún 13180fca947cSMarek Behún static int mv2110_match_phy_device(struct phy_device *phydev) 13190fca947cSMarek Behún { 13200fca947cSMarek Behún return mv211x_match_phy_device(phydev, true); 13210fca947cSMarek Behún } 13220fca947cSMarek Behún 13230fca947cSMarek Behún static int mv2111_match_phy_device(struct phy_device *phydev) 13240fca947cSMarek Behún { 13250fca947cSMarek Behún return mv211x_match_phy_device(phydev, false); 13260fca947cSMarek Behún } 13270fca947cSMarek Behún 132808041a9aSVoon Weifeng static void mv3110_get_wol(struct phy_device *phydev, 132908041a9aSVoon Weifeng struct ethtool_wolinfo *wol) 133008041a9aSVoon Weifeng { 133108041a9aSVoon Weifeng int ret; 133208041a9aSVoon Weifeng 133308041a9aSVoon Weifeng wol->supported = WAKE_MAGIC; 133408041a9aSVoon Weifeng wol->wolopts = 0; 133508041a9aSVoon Weifeng 133608041a9aSVoon Weifeng ret = phy_read_mmd(phydev, MDIO_MMD_VEND2, MV_V2_WOL_CTRL); 133708041a9aSVoon Weifeng if (ret < 0) 133808041a9aSVoon Weifeng return; 133908041a9aSVoon Weifeng 134008041a9aSVoon Weifeng if (ret & MV_V2_WOL_CTRL_MAGIC_PKT_EN) 134108041a9aSVoon Weifeng wol->wolopts |= WAKE_MAGIC; 134208041a9aSVoon Weifeng } 134308041a9aSVoon Weifeng 134408041a9aSVoon Weifeng static int mv3110_set_wol(struct phy_device *phydev, 134508041a9aSVoon Weifeng struct ethtool_wolinfo *wol) 134608041a9aSVoon Weifeng { 134708041a9aSVoon Weifeng int ret; 134808041a9aSVoon Weifeng 134908041a9aSVoon Weifeng if (wol->wolopts & WAKE_MAGIC) { 135008041a9aSVoon Weifeng /* Enable the WOL interrupt */ 135108041a9aSVoon Weifeng ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, 135208041a9aSVoon Weifeng MV_V2_PORT_INTR_MASK, 135308041a9aSVoon Weifeng MV_V2_PORT_INTR_STS_WOL_EN); 135408041a9aSVoon Weifeng if (ret < 0) 135508041a9aSVoon Weifeng return ret; 135608041a9aSVoon Weifeng 135708041a9aSVoon Weifeng /* Store the device address for the magic packet */ 135808041a9aSVoon Weifeng ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, 135908041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD2, 136008041a9aSVoon Weifeng ((phydev->attached_dev->dev_addr[5] << 8) | 136108041a9aSVoon Weifeng phydev->attached_dev->dev_addr[4])); 136208041a9aSVoon Weifeng if (ret < 0) 136308041a9aSVoon Weifeng return ret; 136408041a9aSVoon Weifeng 136508041a9aSVoon Weifeng ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, 136608041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD1, 136708041a9aSVoon Weifeng ((phydev->attached_dev->dev_addr[3] << 8) | 136808041a9aSVoon Weifeng phydev->attached_dev->dev_addr[2])); 136908041a9aSVoon Weifeng if (ret < 0) 137008041a9aSVoon Weifeng return ret; 137108041a9aSVoon Weifeng 137208041a9aSVoon Weifeng ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, 137308041a9aSVoon Weifeng MV_V2_MAGIC_PKT_WORD0, 137408041a9aSVoon Weifeng ((phydev->attached_dev->dev_addr[1] << 8) | 137508041a9aSVoon Weifeng phydev->attached_dev->dev_addr[0])); 137608041a9aSVoon Weifeng if (ret < 0) 137708041a9aSVoon Weifeng return ret; 137808041a9aSVoon Weifeng 137908041a9aSVoon Weifeng /* Clear WOL status and enable magic packet matching */ 138008041a9aSVoon Weifeng ret = phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, 138108041a9aSVoon Weifeng MV_V2_WOL_CTRL, 138208041a9aSVoon Weifeng MV_V2_WOL_CTRL_MAGIC_PKT_EN | 138308041a9aSVoon Weifeng MV_V2_WOL_CTRL_CLEAR_STS); 138408041a9aSVoon Weifeng if (ret < 0) 138508041a9aSVoon Weifeng return ret; 138608041a9aSVoon Weifeng } else { 138708041a9aSVoon Weifeng /* Disable magic packet matching & reset WOL status bit */ 138808041a9aSVoon Weifeng ret = phy_modify_mmd(phydev, MDIO_MMD_VEND2, 138908041a9aSVoon Weifeng MV_V2_WOL_CTRL, 139008041a9aSVoon Weifeng MV_V2_WOL_CTRL_MAGIC_PKT_EN, 139108041a9aSVoon Weifeng MV_V2_WOL_CTRL_CLEAR_STS); 139208041a9aSVoon Weifeng if (ret < 0) 139308041a9aSVoon Weifeng return ret; 139408041a9aSVoon Weifeng } 139508041a9aSVoon Weifeng 139608041a9aSVoon Weifeng /* Reset the clear WOL status bit as it does not self-clear */ 139708041a9aSVoon Weifeng return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, 139808041a9aSVoon Weifeng MV_V2_WOL_CTRL, 139908041a9aSVoon Weifeng MV_V2_WOL_CTRL_CLEAR_STS); 140008041a9aSVoon Weifeng } 140108041a9aSVoon Weifeng 140220b2af32SRussell King static struct phy_driver mv3310_drivers[] = { 140320b2af32SRussell King { 1404631ba906SMaxime Chevallier .phy_id = MARVELL_PHY_ID_88X3310, 1405a5de4be0SMarek Behún .phy_id_mask = MARVELL_PHY_ID_MASK, 1406a5de4be0SMarek Behún .match_phy_device = mv3310_match_phy_device, 140720b2af32SRussell King .name = "mv88x3310", 140897bbe3bdSMarek Behún .driver_data = &mv3310_type, 140974145424SMaxime Chevallier .get_features = mv3310_get_features, 141020b2af32SRussell King .config_init = mv3310_config_init, 14110d3ad854SRussell King .probe = mv3310_probe, 14120d3ad854SRussell King .suspend = mv3310_suspend, 14130d3ad854SRussell King .resume = mv3310_resume, 141420b2af32SRussell King .config_aneg = mv3310_config_aneg, 141520b2af32SRussell King .aneg_done = mv3310_aneg_done, 141620b2af32SRussell King .read_status = mv3310_read_status, 1417a585c03eSRussell King .get_tunable = mv3310_get_tunable, 1418a585c03eSRussell King .set_tunable = mv3310_set_tunable, 14191b8ef142SMarek Behún .remove = mv3310_remove, 1420d137c70dSWong Vee Khee .set_loopback = genphy_c45_loopback, 142108041a9aSVoon Weifeng .get_wol = mv3110_get_wol, 142208041a9aSVoon Weifeng .set_wol = mv3110_set_wol, 142320b2af32SRussell King }, 142462d01535SMaxime Chevallier { 1425a5de4be0SMarek Behún .phy_id = MARVELL_PHY_ID_88X3310, 1426a5de4be0SMarek Behún .phy_id_mask = MARVELL_PHY_ID_MASK, 1427a5de4be0SMarek Behún .match_phy_device = mv3340_match_phy_device, 14289885d016SMarek Behún .name = "mv88x3340", 14299885d016SMarek Behún .driver_data = &mv3340_type, 14309885d016SMarek Behún .get_features = mv3310_get_features, 14319885d016SMarek Behún .config_init = mv3310_config_init, 14329885d016SMarek Behún .probe = mv3310_probe, 14339885d016SMarek Behún .suspend = mv3310_suspend, 14349885d016SMarek Behún .resume = mv3310_resume, 14359885d016SMarek Behún .config_aneg = mv3310_config_aneg, 14369885d016SMarek Behún .aneg_done = mv3310_aneg_done, 14379885d016SMarek Behún .read_status = mv3310_read_status, 14389885d016SMarek Behún .get_tunable = mv3310_get_tunable, 14399885d016SMarek Behún .set_tunable = mv3310_set_tunable, 14409885d016SMarek Behún .remove = mv3310_remove, 14419885d016SMarek Behún .set_loopback = genphy_c45_loopback, 14429885d016SMarek Behún }, 14439885d016SMarek Behún { 144462d01535SMaxime Chevallier .phy_id = MARVELL_PHY_ID_88E2110, 144562d01535SMaxime Chevallier .phy_id_mask = MARVELL_PHY_ID_MASK, 14460fca947cSMarek Behún .match_phy_device = mv2110_match_phy_device, 1447c89f27d4SMarek Behún .name = "mv88e2110", 144897bbe3bdSMarek Behún .driver_data = &mv2110_type, 144962d01535SMaxime Chevallier .probe = mv3310_probe, 1450e02c4a9dSAntoine Tenart .suspend = mv3310_suspend, 1451e02c4a9dSAntoine Tenart .resume = mv3310_resume, 145262d01535SMaxime Chevallier .config_init = mv3310_config_init, 145362d01535SMaxime Chevallier .config_aneg = mv3310_config_aneg, 145462d01535SMaxime Chevallier .aneg_done = mv3310_aneg_done, 145562d01535SMaxime Chevallier .read_status = mv3310_read_status, 1456a585c03eSRussell King .get_tunable = mv3310_get_tunable, 1457a585c03eSRussell King .set_tunable = mv3310_set_tunable, 14581b8ef142SMarek Behún .remove = mv3310_remove, 1459d137c70dSWong Vee Khee .set_loopback = genphy_c45_loopback, 146008041a9aSVoon Weifeng .get_wol = mv3110_get_wol, 146108041a9aSVoon Weifeng .set_wol = mv3110_set_wol, 146262d01535SMaxime Chevallier }, 14630fca947cSMarek Behún { 14640fca947cSMarek Behún .phy_id = MARVELL_PHY_ID_88E2110, 14650fca947cSMarek Behún .phy_id_mask = MARVELL_PHY_ID_MASK, 14660fca947cSMarek Behún .match_phy_device = mv2111_match_phy_device, 14670fca947cSMarek Behún .name = "mv88e2111", 14680fca947cSMarek Behún .driver_data = &mv2111_type, 14690fca947cSMarek Behún .probe = mv3310_probe, 14700fca947cSMarek Behún .suspend = mv3310_suspend, 14710fca947cSMarek Behún .resume = mv3310_resume, 14720fca947cSMarek Behún .config_init = mv3310_config_init, 14730fca947cSMarek Behún .config_aneg = mv3310_config_aneg, 14740fca947cSMarek Behún .aneg_done = mv3310_aneg_done, 14750fca947cSMarek Behún .read_status = mv3310_read_status, 14760fca947cSMarek Behún .get_tunable = mv3310_get_tunable, 14770fca947cSMarek Behún .set_tunable = mv3310_set_tunable, 14780fca947cSMarek Behún .remove = mv3310_remove, 14790fca947cSMarek Behún .set_loopback = genphy_c45_loopback, 14800fca947cSMarek Behún }, 148120b2af32SRussell King }; 148220b2af32SRussell King 148320b2af32SRussell King module_phy_driver(mv3310_drivers); 148420b2af32SRussell King 148520b2af32SRussell King static struct mdio_device_id __maybe_unused mv3310_tbl[] = { 1486a5de4be0SMarek Behún { MARVELL_PHY_ID_88X3310, MARVELL_PHY_ID_MASK }, 148762d01535SMaxime Chevallier { MARVELL_PHY_ID_88E2110, MARVELL_PHY_ID_MASK }, 148820b2af32SRussell King { }, 148920b2af32SRussell King }; 149020b2af32SRussell King MODULE_DEVICE_TABLE(mdio, mv3310_tbl); 1491c7dce05eSMarek Behún MODULE_DESCRIPTION("Marvell Alaska X/M multi-gigabit Ethernet PHY driver"); 149220b2af32SRussell King MODULE_LICENSE("GPL"); 1493