Andrew Lunn | a2443fd | 2019-01-21 19:05:50 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 2 | /* |
| 3 | * drivers/net/phy/marvell.c |
| 4 | * |
| 5 | * Driver for Marvell PHYs |
| 6 | * |
| 7 | * Author: Andy Fleming |
| 8 | * |
| 9 | * Copyright (c) 2004 Freescale Semiconductor, Inc. |
| 10 | * |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 11 | * Copyright (c) 2013 Michael Stapelberg <michael@stapelberg.de> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 12 | */ |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 13 | #include <linux/kernel.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 14 | #include <linux/string.h> |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 15 | #include <linux/ctype.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 16 | #include <linux/errno.h> |
| 17 | #include <linux/unistd.h> |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 18 | #include <linux/hwmon.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/delay.h> |
| 22 | #include <linux/netdevice.h> |
| 23 | #include <linux/etherdevice.h> |
| 24 | #include <linux/skbuff.h> |
| 25 | #include <linux/spinlock.h> |
| 26 | #include <linux/mm.h> |
| 27 | #include <linux/module.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 28 | #include <linux/mii.h> |
| 29 | #include <linux/ethtool.h> |
| 30 | #include <linux/phy.h> |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 31 | #include <linux/marvell_phy.h> |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 32 | #include <linux/bitfield.h> |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 33 | #include <linux/of.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 34 | |
Avinash Kumar | eea3b20 | 2013-09-30 09:36:44 +0530 | [diff] [blame] | 35 | #include <linux/io.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 36 | #include <asm/irq.h> |
Avinash Kumar | eea3b20 | 2013-09-30 09:36:44 +0530 | [diff] [blame] | 37 | #include <linux/uaccess.h> |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 38 | |
David Daney | 27d916d | 2010-11-19 11:58:52 +0000 | [diff] [blame] | 39 | #define MII_MARVELL_PHY_PAGE 22 |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 40 | #define MII_MARVELL_COPPER_PAGE 0x00 |
| 41 | #define MII_MARVELL_FIBER_PAGE 0x01 |
| 42 | #define MII_MARVELL_MSCR_PAGE 0x02 |
| 43 | #define MII_MARVELL_LED_PAGE 0x03 |
| 44 | #define MII_MARVELL_MISC_TEST_PAGE 0x06 |
| 45 | #define MII_MARVELL_WOL_PAGE 0x11 |
David Daney | 27d916d | 2010-11-19 11:58:52 +0000 | [diff] [blame] | 46 | |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 47 | #define MII_M1011_IEVENT 0x13 |
| 48 | #define MII_M1011_IEVENT_CLEAR 0x0000 |
| 49 | |
| 50 | #define MII_M1011_IMASK 0x12 |
| 51 | #define MII_M1011_IMASK_INIT 0x6400 |
| 52 | #define MII_M1011_IMASK_CLEAR 0x0000 |
| 53 | |
Andrew Lunn | fecd5e9 | 2017-07-30 22:41:49 +0200 | [diff] [blame] | 54 | #define MII_M1011_PHY_SCR 0x10 |
| 55 | #define MII_M1011_PHY_SCR_DOWNSHIFT_EN BIT(11) |
Heiner Kallweit | f8d975b | 2019-10-28 20:52:22 +0100 | [diff] [blame] | 56 | #define MII_M1011_PHY_SCR_DOWNSHIFT_MASK GENMASK(14, 12) |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 57 | #define MII_M1011_PHY_SCR_DOWNSHIFT_MAX 8 |
Andrew Lunn | fecd5e9 | 2017-07-30 22:41:49 +0200 | [diff] [blame] | 58 | #define MII_M1011_PHY_SCR_MDI (0x0 << 5) |
| 59 | #define MII_M1011_PHY_SCR_MDI_X (0x1 << 5) |
| 60 | #define MII_M1011_PHY_SCR_AUTO_CROSS (0x3 << 5) |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 61 | |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 62 | #define MII_M1011_PHY_SSR 0x11 |
| 63 | #define MII_M1011_PHY_SSR_DOWNSHIFT BIT(5) |
| 64 | |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 65 | #define MII_M1111_PHY_LED_CONTROL 0x18 |
| 66 | #define MII_M1111_PHY_LED_DIRECT 0x4100 |
| 67 | #define MII_M1111_PHY_LED_COMBINE 0x411c |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 68 | #define MII_M1111_PHY_EXT_CR 0x14 |
Heiner Kallweit | 5c6bc51 | 2019-10-28 20:53:25 +0100 | [diff] [blame] | 69 | #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK GENMASK(11, 9) |
| 70 | #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX 8 |
| 71 | #define MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN BIT(8) |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 72 | #define MII_M1111_RGMII_RX_DELAY BIT(7) |
| 73 | #define MII_M1111_RGMII_TX_DELAY BIT(1) |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 74 | #define MII_M1111_PHY_EXT_SR 0x1b |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 75 | |
| 76 | #define MII_M1111_HWCFG_MODE_MASK 0xf |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 77 | #define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3 |
Kapil Juneja | 4117b5b | 2007-05-11 18:25:18 -0500 | [diff] [blame] | 78 | #define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4 |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 79 | #define MII_M1111_HWCFG_MODE_RTBI 0x7 |
Liu Yu-B13201 | 5f8cbc1 | 2010-01-13 22:13:19 +0000 | [diff] [blame] | 80 | #define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9 |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 81 | #define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb |
| 82 | #define MII_M1111_HWCFG_FIBER_COPPER_RES BIT(13) |
| 83 | #define MII_M1111_HWCFG_FIBER_COPPER_AUTO BIT(15) |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 84 | |
Cyril Chemparathy | c477d04 | 2010-08-02 09:44:53 +0000 | [diff] [blame] | 85 | #define MII_88E1121_PHY_MSCR_REG 21 |
| 86 | #define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5) |
| 87 | #define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 88 | #define MII_88E1121_PHY_MSCR_DELAY_MASK (BIT(5) | BIT(4)) |
Cyril Chemparathy | c477d04 | 2010-08-02 09:44:53 +0000 | [diff] [blame] | 89 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 90 | #define MII_88E1121_MISC_TEST 0x1a |
| 91 | #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK 0x1f00 |
| 92 | #define MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT 8 |
| 93 | #define MII_88E1510_MISC_TEST_TEMP_IRQ_EN BIT(7) |
| 94 | #define MII_88E1510_MISC_TEST_TEMP_IRQ BIT(6) |
| 95 | #define MII_88E1121_MISC_TEST_TEMP_SENSOR_EN BIT(5) |
| 96 | #define MII_88E1121_MISC_TEST_TEMP_MASK 0x1f |
| 97 | |
| 98 | #define MII_88E1510_TEMP_SENSOR 0x1b |
| 99 | #define MII_88E1510_TEMP_SENSOR_MASK 0xff |
| 100 | |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 101 | #define MII_88E1540_COPPER_CTRL3 0x1a |
| 102 | #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK GENMASK(11, 10) |
| 103 | #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS 0 |
| 104 | #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS 1 |
| 105 | #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS 2 |
| 106 | #define MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS 3 |
| 107 | #define MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN BIT(9) |
| 108 | |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 109 | #define MII_88E6390_MISC_TEST 0x1b |
| 110 | #define MII_88E6390_MISC_TEST_SAMPLE_1S 0 |
| 111 | #define MII_88E6390_MISC_TEST_SAMPLE_10MS BIT(14) |
| 112 | #define MII_88E6390_MISC_TEST_SAMPLE_DISABLE BIT(15) |
| 113 | #define MII_88E6390_MISC_TEST_SAMPLE_ENABLE 0 |
| 114 | #define MII_88E6390_MISC_TEST_SAMPLE_MASK (0x3 << 14) |
| 115 | |
| 116 | #define MII_88E6390_TEMP_SENSOR 0x1c |
| 117 | #define MII_88E6390_TEMP_SENSOR_MASK 0xff |
| 118 | #define MII_88E6390_TEMP_SENSOR_SAMPLES 10 |
| 119 | |
Cyril Chemparathy | 337ac9d | 2010-10-29 13:50:25 -0700 | [diff] [blame] | 120 | #define MII_88E1318S_PHY_MSCR1_REG 16 |
| 121 | #define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6) |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 122 | |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 123 | /* Copper Specific Interrupt Enable Register */ |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 124 | #define MII_88E1318S_PHY_CSIER 0x12 |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 125 | /* WOL Event Interrupt Enable */ |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 126 | #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 127 | |
| 128 | /* LED Timer Control Register */ |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 129 | #define MII_88E1318S_PHY_LED_TCR 0x12 |
| 130 | #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) |
| 131 | #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) |
| 132 | #define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 133 | |
| 134 | /* Magic Packet MAC address registers */ |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 135 | #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17 |
| 136 | #define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18 |
| 137 | #define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19 |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 138 | |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 139 | #define MII_88E1318S_PHY_WOL_CTRL 0x10 |
| 140 | #define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12) |
| 141 | #define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 142 | |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 143 | #define MII_PHY_LED_CTRL 16 |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 144 | #define MII_88E1121_PHY_LED_DEF 0x0030 |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 145 | #define MII_88E1510_PHY_LED_DEF 0x1177 |
Jian Shen | a93f7fe | 2019-04-22 21:52:23 +0800 | [diff] [blame] | 146 | #define MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE 0x1040 |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 147 | |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 148 | #define MII_M1011_PHY_STATUS 0x11 |
| 149 | #define MII_M1011_PHY_STATUS_1000 0x8000 |
| 150 | #define MII_M1011_PHY_STATUS_100 0x4000 |
| 151 | #define MII_M1011_PHY_STATUS_SPD_MASK 0xc000 |
| 152 | #define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000 |
| 153 | #define MII_M1011_PHY_STATUS_RESOLVED 0x0800 |
| 154 | #define MII_M1011_PHY_STATUS_LINK 0x0400 |
| 155 | |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 156 | #define MII_88E3016_PHY_SPEC_CTRL 0x10 |
| 157 | #define MII_88E3016_DISABLE_SCRAMBLER 0x0200 |
| 158 | #define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030 |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 159 | |
Stefan Roese | 930b37e | 2016-02-18 10:59:07 +0100 | [diff] [blame] | 160 | #define MII_88E1510_GEN_CTRL_REG_1 0x14 |
| 161 | #define MII_88E1510_GEN_CTRL_REG_1_MODE_MASK 0x7 |
| 162 | #define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII 0x1 /* SGMII to copper */ |
| 163 | #define MII_88E1510_GEN_CTRL_REG_1_RESET 0x8000 /* Soft reset */ |
| 164 | |
Andrew Lunn | 8cf8b87 | 2017-07-30 22:41:44 +0200 | [diff] [blame] | 165 | #define LPA_PAUSE_FIBER 0x180 |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 166 | #define LPA_PAUSE_ASYM_FIBER 0x100 |
| 167 | |
Charles-Antoine Couret | 2170fef | 2016-07-19 11:13:11 +0200 | [diff] [blame] | 168 | #define NB_FIBER_STATS 1 |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 169 | |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 170 | MODULE_DESCRIPTION("Marvell PHY driver"); |
| 171 | MODULE_AUTHOR("Andy Fleming"); |
| 172 | MODULE_LICENSE("GPL"); |
| 173 | |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 174 | struct marvell_hw_stat { |
| 175 | const char *string; |
| 176 | u8 page; |
| 177 | u8 reg; |
| 178 | u8 bits; |
| 179 | }; |
| 180 | |
| 181 | static struct marvell_hw_stat marvell_hw_stats[] = { |
Charles-Antoine Couret | 2170fef | 2016-07-19 11:13:11 +0200 | [diff] [blame] | 182 | { "phy_receive_errors_copper", 0, 21, 16}, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 183 | { "phy_idle_errors", 0, 10, 8 }, |
Charles-Antoine Couret | 2170fef | 2016-07-19 11:13:11 +0200 | [diff] [blame] | 184 | { "phy_receive_errors_fiber", 1, 21, 16}, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | struct marvell_priv { |
| 188 | u64 stats[ARRAY_SIZE(marvell_hw_stats)]; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 189 | char *hwmon_name; |
| 190 | struct device *hwmon_dev; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 191 | }; |
| 192 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 193 | static int marvell_read_page(struct phy_device *phydev) |
Andrew Lunn | 6427bb2 | 2017-05-17 03:26:03 +0200 | [diff] [blame] | 194 | { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 195 | return __phy_read(phydev, MII_MARVELL_PHY_PAGE); |
| 196 | } |
| 197 | |
| 198 | static int marvell_write_page(struct phy_device *phydev, int page) |
| 199 | { |
| 200 | return __phy_write(phydev, MII_MARVELL_PHY_PAGE, page); |
Andrew Lunn | 6427bb2 | 2017-05-17 03:26:03 +0200 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static int marvell_set_page(struct phy_device *phydev, int page) |
| 204 | { |
| 205 | return phy_write(phydev, MII_MARVELL_PHY_PAGE, page); |
| 206 | } |
| 207 | |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 208 | static int marvell_ack_interrupt(struct phy_device *phydev) |
| 209 | { |
| 210 | int err; |
| 211 | |
| 212 | /* Clear the interrupts by reading the reg */ |
| 213 | err = phy_read(phydev, MII_M1011_IEVENT); |
| 214 | |
| 215 | if (err < 0) |
| 216 | return err; |
| 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | static int marvell_config_intr(struct phy_device *phydev) |
| 222 | { |
| 223 | int err; |
| 224 | |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 225 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) |
Andrew Lunn | 23beb38 | 2017-05-17 03:26:04 +0200 | [diff] [blame] | 226 | err = phy_write(phydev, MII_M1011_IMASK, |
| 227 | MII_M1011_IMASK_INIT); |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 228 | else |
Andrew Lunn | 23beb38 | 2017-05-17 03:26:04 +0200 | [diff] [blame] | 229 | err = phy_write(phydev, MII_M1011_IMASK, |
| 230 | MII_M1011_IMASK_CLEAR); |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 231 | |
| 232 | return err; |
| 233 | } |
| 234 | |
David Thomson | 239aa55 | 2015-07-10 16:28:25 +1200 | [diff] [blame] | 235 | static int marvell_set_polarity(struct phy_device *phydev, int polarity) |
| 236 | { |
| 237 | int reg; |
| 238 | int err; |
| 239 | int val; |
| 240 | |
| 241 | /* get the current settings */ |
| 242 | reg = phy_read(phydev, MII_M1011_PHY_SCR); |
| 243 | if (reg < 0) |
| 244 | return reg; |
| 245 | |
| 246 | val = reg; |
| 247 | val &= ~MII_M1011_PHY_SCR_AUTO_CROSS; |
| 248 | switch (polarity) { |
| 249 | case ETH_TP_MDI: |
| 250 | val |= MII_M1011_PHY_SCR_MDI; |
| 251 | break; |
| 252 | case ETH_TP_MDI_X: |
| 253 | val |= MII_M1011_PHY_SCR_MDI_X; |
| 254 | break; |
| 255 | case ETH_TP_MDI_AUTO: |
| 256 | case ETH_TP_MDI_INVALID: |
| 257 | default: |
| 258 | val |= MII_M1011_PHY_SCR_AUTO_CROSS; |
| 259 | break; |
| 260 | } |
| 261 | |
| 262 | if (val != reg) { |
| 263 | /* Set the new polarity value in the register */ |
| 264 | err = phy_write(phydev, MII_M1011_PHY_SCR, val); |
| 265 | if (err) |
| 266 | return err; |
| 267 | } |
| 268 | |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 269 | return val != reg; |
David Thomson | 239aa55 | 2015-07-10 16:28:25 +1200 | [diff] [blame] | 270 | } |
| 271 | |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 272 | static int marvell_config_aneg(struct phy_device *phydev) |
| 273 | { |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 274 | int changed = 0; |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 275 | int err; |
| 276 | |
Raju Lakkaraju | 4e26c5c | 2016-11-29 15:16:49 +0530 | [diff] [blame] | 277 | err = marvell_set_polarity(phydev, phydev->mdix_ctrl); |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 278 | if (err < 0) |
| 279 | return err; |
| 280 | |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 281 | changed = err; |
| 282 | |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 283 | err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL, |
| 284 | MII_M1111_PHY_LED_DIRECT); |
| 285 | if (err < 0) |
| 286 | return err; |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 287 | |
| 288 | err = genphy_config_aneg(phydev); |
Anton Vorontsov | 8ff4498 | 2009-09-09 16:01:30 +0000 | [diff] [blame] | 289 | if (err < 0) |
| 290 | return err; |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 291 | |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 292 | if (phydev->autoneg != AUTONEG_ENABLE || changed) { |
Andrew Lunn | 0c3439b | 2017-05-17 03:25:59 +0200 | [diff] [blame] | 293 | /* A write to speed/duplex bits (that is performed by |
Anton Vorontsov | 8ff4498 | 2009-09-09 16:01:30 +0000 | [diff] [blame] | 294 | * genphy_config_aneg() call above) must be followed by |
| 295 | * a software reset. Otherwise, the write has no effect. |
| 296 | */ |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 297 | err = genphy_soft_reset(phydev); |
Anton Vorontsov | 8ff4498 | 2009-09-09 16:01:30 +0000 | [diff] [blame] | 298 | if (err < 0) |
| 299 | return err; |
| 300 | } |
| 301 | |
| 302 | return 0; |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 303 | } |
| 304 | |
Andrew Lunn | f289978 | 2017-05-23 17:49:13 +0200 | [diff] [blame] | 305 | static int m88e1101_config_aneg(struct phy_device *phydev) |
| 306 | { |
| 307 | int err; |
| 308 | |
| 309 | /* This Marvell PHY has an errata which requires |
| 310 | * that certain registers get written in order |
| 311 | * to restart autonegotiation |
| 312 | */ |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 313 | err = genphy_soft_reset(phydev); |
Andrew Lunn | f289978 | 2017-05-23 17:49:13 +0200 | [diff] [blame] | 314 | if (err < 0) |
| 315 | return err; |
| 316 | |
| 317 | err = phy_write(phydev, 0x1d, 0x1f); |
| 318 | if (err < 0) |
| 319 | return err; |
| 320 | |
| 321 | err = phy_write(phydev, 0x1e, 0x200c); |
| 322 | if (err < 0) |
| 323 | return err; |
| 324 | |
| 325 | err = phy_write(phydev, 0x1d, 0x5); |
| 326 | if (err < 0) |
| 327 | return err; |
| 328 | |
| 329 | err = phy_write(phydev, 0x1e, 0); |
| 330 | if (err < 0) |
| 331 | return err; |
| 332 | |
| 333 | err = phy_write(phydev, 0x1e, 0x100); |
| 334 | if (err < 0) |
| 335 | return err; |
| 336 | |
| 337 | return marvell_config_aneg(phydev); |
| 338 | } |
| 339 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 340 | #ifdef CONFIG_OF_MDIO |
Andrew Lunn | 0c3439b | 2017-05-17 03:25:59 +0200 | [diff] [blame] | 341 | /* Set and/or override some configuration registers based on the |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 342 | * marvell,reg-init property stored in the of_node for the phydev. |
| 343 | * |
| 344 | * marvell,reg-init = <reg-page reg mask value>,...; |
| 345 | * |
| 346 | * There may be one or more sets of <reg-page reg mask value>: |
| 347 | * |
| 348 | * reg-page: which register bank to use. |
| 349 | * reg: the register. |
| 350 | * mask: if non-zero, ANDed with existing register value. |
| 351 | * value: ORed with the masked value and written to the regiser. |
| 352 | * |
| 353 | */ |
| 354 | static int marvell_of_reg_init(struct phy_device *phydev) |
| 355 | { |
| 356 | const __be32 *paddr; |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 357 | int len, i, saved_page, current_page, ret = 0; |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 358 | |
Andrew Lunn | e5a03bf | 2016-01-06 20:11:16 +0100 | [diff] [blame] | 359 | if (!phydev->mdio.dev.of_node) |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 360 | return 0; |
| 361 | |
Andrew Lunn | e5a03bf | 2016-01-06 20:11:16 +0100 | [diff] [blame] | 362 | paddr = of_get_property(phydev->mdio.dev.of_node, |
| 363 | "marvell,reg-init", &len); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 364 | if (!paddr || len < (4 * sizeof(*paddr))) |
| 365 | return 0; |
| 366 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 367 | saved_page = phy_save_page(phydev); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 368 | if (saved_page < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 369 | goto err; |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 370 | current_page = saved_page; |
| 371 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 372 | len /= sizeof(*paddr); |
| 373 | for (i = 0; i < len - 3; i += 4) { |
Andrew Lunn | 6427bb2 | 2017-05-17 03:26:03 +0200 | [diff] [blame] | 374 | u16 page = be32_to_cpup(paddr + i); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 375 | u16 reg = be32_to_cpup(paddr + i + 1); |
| 376 | u16 mask = be32_to_cpup(paddr + i + 2); |
| 377 | u16 val_bits = be32_to_cpup(paddr + i + 3); |
| 378 | int val; |
| 379 | |
Andrew Lunn | 6427bb2 | 2017-05-17 03:26:03 +0200 | [diff] [blame] | 380 | if (page != current_page) { |
| 381 | current_page = page; |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 382 | ret = marvell_write_page(phydev, page); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 383 | if (ret < 0) |
| 384 | goto err; |
| 385 | } |
| 386 | |
| 387 | val = 0; |
| 388 | if (mask) { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 389 | val = __phy_read(phydev, reg); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 390 | if (val < 0) { |
| 391 | ret = val; |
| 392 | goto err; |
| 393 | } |
| 394 | val &= mask; |
| 395 | } |
| 396 | val |= val_bits; |
| 397 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 398 | ret = __phy_write(phydev, reg, val); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 399 | if (ret < 0) |
| 400 | goto err; |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 401 | } |
| 402 | err: |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 403 | return phy_restore_page(phydev, saved_page, ret); |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 404 | } |
| 405 | #else |
| 406 | static int marvell_of_reg_init(struct phy_device *phydev) |
| 407 | { |
| 408 | return 0; |
| 409 | } |
| 410 | #endif /* CONFIG_OF_MDIO */ |
| 411 | |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 412 | static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev) |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 413 | { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 414 | int mscr; |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 415 | |
| 416 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 417 | mscr = MII_88E1121_PHY_MSCR_RX_DELAY | |
| 418 | MII_88E1121_PHY_MSCR_TX_DELAY; |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 419 | else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 420 | mscr = MII_88E1121_PHY_MSCR_RX_DELAY; |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 421 | else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 422 | mscr = MII_88E1121_PHY_MSCR_TX_DELAY; |
| 423 | else |
| 424 | mscr = 0; |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 425 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 426 | return phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, |
| 427 | MII_88E1121_PHY_MSCR_REG, |
| 428 | MII_88E1121_PHY_MSCR_DELAY_MASK, mscr); |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | static int m88e1121_config_aneg(struct phy_device *phydev) |
| 432 | { |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 433 | int changed = 0; |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 434 | int err = 0; |
| 435 | |
| 436 | if (phy_interface_is_rgmii(phydev)) { |
| 437 | err = m88e1121_config_aneg_rgmii_delays(phydev); |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 438 | if (err < 0) |
Andrew Lunn | 864dc72 | 2017-07-30 22:41:48 +0200 | [diff] [blame] | 439 | return err; |
| 440 | } |
| 441 | |
Andrew Lunn | fecd5e9 | 2017-07-30 22:41:49 +0200 | [diff] [blame] | 442 | err = marvell_set_polarity(phydev, phydev->mdix_ctrl); |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 443 | if (err < 0) |
| 444 | return err; |
| 445 | |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 446 | changed = err; |
| 447 | |
| 448 | err = genphy_config_aneg(phydev); |
| 449 | if (err < 0) |
| 450 | return err; |
| 451 | |
David S. Miller | 4b1bd69 | 2018-09-25 22:41:31 -0700 | [diff] [blame] | 452 | if (phydev->autoneg != AUTONEG_ENABLE || changed) { |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 453 | /* A software reset is used to ensure a "commit" of the |
| 454 | * changes is done. |
| 455 | */ |
| 456 | err = genphy_soft_reset(phydev); |
| 457 | if (err < 0) |
| 458 | return err; |
| 459 | } |
| 460 | |
| 461 | return 0; |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 462 | } |
| 463 | |
Cyril Chemparathy | 337ac9d | 2010-10-29 13:50:25 -0700 | [diff] [blame] | 464 | static int m88e1318_config_aneg(struct phy_device *phydev) |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 465 | { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 466 | int err; |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 467 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 468 | err = phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE, |
| 469 | MII_88E1318S_PHY_MSCR1_REG, |
| 470 | 0, MII_88E1318S_PHY_MSCR1_PAD_ODD); |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 471 | if (err < 0) |
| 472 | return err; |
| 473 | |
| 474 | return m88e1121_config_aneg(phydev); |
| 475 | } |
| 476 | |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 477 | /** |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 478 | * linkmode_adv_to_fiber_adv_t |
| 479 | * @advertise: the linkmode advertisement settings |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 480 | * |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 481 | * A small helper function that translates linkmode advertisement |
| 482 | * settings to phy autonegotiation advertisements for the MII_ADV |
| 483 | * register for fiber link. |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 484 | */ |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 485 | static inline u32 linkmode_adv_to_fiber_adv_t(unsigned long *advertise) |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 486 | { |
| 487 | u32 result = 0; |
| 488 | |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 489 | if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, advertise)) |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 490 | result |= ADVERTISE_1000XHALF; |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 491 | if (linkmode_test_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, advertise)) |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 492 | result |= ADVERTISE_1000XFULL; |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 493 | |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 494 | if (linkmode_test_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, advertise) && |
| 495 | linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertise)) |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 496 | result |= ADVERTISE_1000XPSE_ASYM; |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 497 | else if (linkmode_test_bit(ETHTOOL_LINK_MODE_Pause_BIT, advertise)) |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 498 | result |= ADVERTISE_1000XPAUSE; |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 499 | |
| 500 | return result; |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * marvell_config_aneg_fiber - restart auto-negotiation or write BMCR |
| 505 | * @phydev: target phy_device struct |
| 506 | * |
| 507 | * Description: If auto-negotiation is enabled, we configure the |
| 508 | * advertising, and then restart auto-negotiation. If it is not |
| 509 | * enabled, then we write the BMCR. Adapted for fiber link in |
| 510 | * some Marvell's devices. |
| 511 | */ |
| 512 | static int marvell_config_aneg_fiber(struct phy_device *phydev) |
| 513 | { |
| 514 | int changed = 0; |
| 515 | int err; |
Russell King | 9f4bae7 | 2019-12-17 13:39:47 +0000 | [diff] [blame] | 516 | u16 adv; |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 517 | |
| 518 | if (phydev->autoneg != AUTONEG_ENABLE) |
| 519 | return genphy_setup_forced(phydev); |
| 520 | |
| 521 | /* Only allow advertising what this PHY supports */ |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 522 | linkmode_and(phydev->advertising, phydev->advertising, |
| 523 | phydev->supported); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 524 | |
Russell King | 9f4bae7 | 2019-12-17 13:39:47 +0000 | [diff] [blame] | 525 | adv = linkmode_adv_to_fiber_adv_t(phydev->advertising); |
| 526 | |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 527 | /* Setup fiber advertisement */ |
Russell King | 9f4bae7 | 2019-12-17 13:39:47 +0000 | [diff] [blame] | 528 | err = phy_modify_changed(phydev, MII_ADVERTISE, |
| 529 | ADVERTISE_1000XHALF | ADVERTISE_1000XFULL | |
| 530 | ADVERTISE_1000XPAUSE | ADVERTISE_1000XPSE_ASYM, |
| 531 | adv); |
| 532 | if (err < 0) |
| 533 | return err; |
| 534 | if (err > 0) |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 535 | changed = 1; |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 536 | |
Russell King | b5abac2 | 2019-12-17 13:39:52 +0000 | [diff] [blame] | 537 | return genphy_check_and_restart_aneg(phydev, changed); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 538 | } |
| 539 | |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 540 | static int m88e1510_config_aneg(struct phy_device *phydev) |
| 541 | { |
| 542 | int err; |
| 543 | |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 544 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 545 | if (err < 0) |
| 546 | goto error; |
| 547 | |
| 548 | /* Configure the copper link first */ |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 549 | err = m88e1318_config_aneg(phydev); |
| 550 | if (err < 0) |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 551 | goto error; |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 552 | |
Russell King | de9c4e0 | 2017-12-13 09:22:03 +0000 | [diff] [blame] | 553 | /* Do not touch the fiber page if we're in copper->sgmii mode */ |
| 554 | if (phydev->interface == PHY_INTERFACE_MODE_SGMII) |
| 555 | return 0; |
| 556 | |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 557 | /* Then the fiber link */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 558 | err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 559 | if (err < 0) |
| 560 | goto error; |
| 561 | |
| 562 | err = marvell_config_aneg_fiber(phydev); |
| 563 | if (err < 0) |
| 564 | goto error; |
| 565 | |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 566 | return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 567 | |
| 568 | error: |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 569 | marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 78301eb | 2016-07-19 11:13:12 +0200 | [diff] [blame] | 570 | return err; |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 571 | } |
| 572 | |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 573 | static void marvell_config_led(struct phy_device *phydev) |
| 574 | { |
| 575 | u16 def_config; |
| 576 | int err; |
| 577 | |
| 578 | switch (MARVELL_PHY_FAMILY_ID(phydev->phy_id)) { |
| 579 | /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */ |
| 580 | case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1121R): |
| 581 | case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1318S): |
| 582 | def_config = MII_88E1121_PHY_LED_DEF; |
| 583 | break; |
| 584 | /* Default PHY LED config: |
| 585 | * LED[0] .. 1000Mbps Link |
| 586 | * LED[1] .. 100Mbps Link |
| 587 | * LED[2] .. Blink, Activity |
| 588 | */ |
| 589 | case MARVELL_PHY_FAMILY_ID(MARVELL_PHY_ID_88E1510): |
Jian Shen | a93f7fe | 2019-04-22 21:52:23 +0800 | [diff] [blame] | 590 | if (phydev->dev_flags & MARVELL_PHY_LED0_LINK_LED1_ACTIVE) |
| 591 | def_config = MII_88E1510_PHY_LED0_LINK_LED1_ACTIVE; |
| 592 | else |
| 593 | def_config = MII_88E1510_PHY_LED_DEF; |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 594 | break; |
| 595 | default: |
| 596 | return; |
| 597 | } |
| 598 | |
| 599 | err = phy_write_paged(phydev, MII_MARVELL_LED_PAGE, MII_PHY_LED_CTRL, |
| 600 | def_config); |
| 601 | if (err < 0) |
Andrew Lunn | ab2a605 | 2018-09-29 23:04:10 +0200 | [diff] [blame] | 602 | phydev_warn(phydev, "Fail to config marvell phy LED.\n"); |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 603 | } |
| 604 | |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 605 | static int marvell_config_init(struct phy_device *phydev) |
| 606 | { |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 607 | /* Set defalut LED */ |
| 608 | marvell_config_led(phydev); |
| 609 | |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 610 | /* Set registers from marvell,reg-init DT property */ |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 611 | return marvell_of_reg_init(phydev); |
| 612 | } |
| 613 | |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 614 | static int m88e3016_config_init(struct phy_device *phydev) |
| 615 | { |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 616 | int ret; |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 617 | |
| 618 | /* Enable Scrambler and Auto-Crossover */ |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 619 | ret = phy_modify(phydev, MII_88E3016_PHY_SPEC_CTRL, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 620 | MII_88E3016_DISABLE_SCRAMBLER, |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 621 | MII_88E3016_AUTO_MDIX_CROSSOVER); |
| 622 | if (ret < 0) |
| 623 | return ret; |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 624 | |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 625 | return marvell_config_init(phydev); |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 626 | } |
| 627 | |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 628 | static int m88e1111_config_init_hwcfg_mode(struct phy_device *phydev, |
| 629 | u16 mode, |
| 630 | int fibre_copper_auto) |
| 631 | { |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 632 | if (fibre_copper_auto) |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 633 | mode |= MII_M1111_HWCFG_FIBER_COPPER_AUTO; |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 634 | |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 635 | return phy_modify(phydev, MII_M1111_PHY_EXT_SR, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 636 | MII_M1111_HWCFG_MODE_MASK | |
| 637 | MII_M1111_HWCFG_FIBER_COPPER_AUTO | |
| 638 | MII_M1111_HWCFG_FIBER_COPPER_RES, |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 639 | mode); |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 640 | } |
| 641 | |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 642 | static int m88e1111_config_init_rgmii_delays(struct phy_device *phydev) |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 643 | { |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 644 | int delay; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 645 | |
| 646 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 647 | delay = MII_M1111_RGMII_RX_DELAY | MII_M1111_RGMII_TX_DELAY; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 648 | } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 649 | delay = MII_M1111_RGMII_RX_DELAY; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 650 | } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 651 | delay = MII_M1111_RGMII_TX_DELAY; |
| 652 | } else { |
| 653 | delay = 0; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 654 | } |
| 655 | |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 656 | return phy_modify(phydev, MII_M1111_PHY_EXT_CR, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 657 | MII_M1111_RGMII_RX_DELAY | MII_M1111_RGMII_TX_DELAY, |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 658 | delay); |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | static int m88e1111_config_init_rgmii(struct phy_device *phydev) |
| 662 | { |
| 663 | int temp; |
| 664 | int err; |
| 665 | |
| 666 | err = m88e1111_config_init_rgmii_delays(phydev); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 667 | if (err < 0) |
| 668 | return err; |
| 669 | |
| 670 | temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); |
| 671 | if (temp < 0) |
| 672 | return temp; |
| 673 | |
| 674 | temp &= ~(MII_M1111_HWCFG_MODE_MASK); |
| 675 | |
| 676 | if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES) |
| 677 | temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII; |
| 678 | else |
| 679 | temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII; |
| 680 | |
| 681 | return phy_write(phydev, MII_M1111_PHY_EXT_SR, temp); |
| 682 | } |
| 683 | |
| 684 | static int m88e1111_config_init_sgmii(struct phy_device *phydev) |
| 685 | { |
| 686 | int err; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 687 | |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 688 | err = m88e1111_config_init_hwcfg_mode( |
| 689 | phydev, |
| 690 | MII_M1111_HWCFG_MODE_SGMII_NO_CLK, |
| 691 | MII_M1111_HWCFG_FIBER_COPPER_AUTO); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 692 | if (err < 0) |
| 693 | return err; |
| 694 | |
| 695 | /* make sure copper is selected */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 696 | return marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | static int m88e1111_config_init_rtbi(struct phy_device *phydev) |
| 700 | { |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 701 | int err; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 702 | |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 703 | err = m88e1111_config_init_rgmii_delays(phydev); |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 704 | if (err < 0) |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 705 | return err; |
| 706 | |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 707 | err = m88e1111_config_init_hwcfg_mode( |
| 708 | phydev, |
| 709 | MII_M1111_HWCFG_MODE_RTBI, |
| 710 | MII_M1111_HWCFG_FIBER_COPPER_AUTO); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 711 | if (err < 0) |
| 712 | return err; |
| 713 | |
| 714 | /* soft reset */ |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 715 | err = genphy_soft_reset(phydev); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 716 | if (err < 0) |
| 717 | return err; |
| 718 | |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 719 | return m88e1111_config_init_hwcfg_mode( |
| 720 | phydev, |
| 721 | MII_M1111_HWCFG_MODE_RTBI, |
| 722 | MII_M1111_HWCFG_FIBER_COPPER_AUTO); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 723 | } |
| 724 | |
| 725 | static int m88e1111_config_init(struct phy_device *phydev) |
| 726 | { |
| 727 | int err; |
| 728 | |
Florian Fainelli | 32a6416 | 2015-05-26 12:19:59 -0700 | [diff] [blame] | 729 | if (phy_interface_is_rgmii(phydev)) { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 730 | err = m88e1111_config_init_rgmii(phydev); |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 731 | if (err < 0) |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 732 | return err; |
| 733 | } |
| 734 | |
Kapil Juneja | 4117b5b | 2007-05-11 18:25:18 -0500 | [diff] [blame] | 735 | if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 736 | err = m88e1111_config_init_sgmii(phydev); |
Madalin Bucur | 07151bc | 2015-08-07 17:07:50 +0800 | [diff] [blame] | 737 | if (err < 0) |
| 738 | return err; |
Kapil Juneja | 4117b5b | 2007-05-11 18:25:18 -0500 | [diff] [blame] | 739 | } |
| 740 | |
Liu Yu-B13201 | 5f8cbc1 | 2010-01-13 22:13:19 +0000 | [diff] [blame] | 741 | if (phydev->interface == PHY_INTERFACE_MODE_RTBI) { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 742 | err = m88e1111_config_init_rtbi(phydev); |
Liu Yu-B13201 | 5f8cbc1 | 2010-01-13 22:13:19 +0000 | [diff] [blame] | 743 | if (err < 0) |
| 744 | return err; |
| 745 | } |
| 746 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 747 | err = marvell_of_reg_init(phydev); |
| 748 | if (err < 0) |
| 749 | return err; |
Liu Yu-B13201 | 5f8cbc1 | 2010-01-13 22:13:19 +0000 | [diff] [blame] | 750 | |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 751 | return genphy_soft_reset(phydev); |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 752 | } |
| 753 | |
Heiner Kallweit | 5c6bc51 | 2019-10-28 20:53:25 +0100 | [diff] [blame] | 754 | static int m88e1111_get_downshift(struct phy_device *phydev, u8 *data) |
| 755 | { |
| 756 | int val, cnt, enable; |
| 757 | |
| 758 | val = phy_read(phydev, MII_M1111_PHY_EXT_CR); |
| 759 | if (val < 0) |
| 760 | return val; |
| 761 | |
| 762 | enable = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN, val); |
| 763 | cnt = FIELD_GET(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, val) + 1; |
| 764 | |
| 765 | *data = enable ? cnt : DOWNSHIFT_DEV_DISABLE; |
| 766 | |
| 767 | return 0; |
| 768 | } |
| 769 | |
| 770 | static int m88e1111_set_downshift(struct phy_device *phydev, u8 cnt) |
| 771 | { |
| 772 | int val; |
| 773 | |
| 774 | if (cnt > MII_M1111_PHY_EXT_CR_DOWNSHIFT_MAX) |
| 775 | return -E2BIG; |
| 776 | |
| 777 | if (!cnt) |
| 778 | return phy_clear_bits(phydev, MII_M1111_PHY_EXT_CR, |
| 779 | MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN); |
| 780 | |
| 781 | val = MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN; |
| 782 | val |= FIELD_PREP(MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, cnt - 1); |
| 783 | |
| 784 | return phy_modify(phydev, MII_M1111_PHY_EXT_CR, |
| 785 | MII_M1111_PHY_EXT_CR_DOWNSHIFT_EN | |
| 786 | MII_M1111_PHY_EXT_CR_DOWNSHIFT_MASK, |
| 787 | val); |
| 788 | } |
| 789 | |
| 790 | static int m88e1111_get_tunable(struct phy_device *phydev, |
| 791 | struct ethtool_tunable *tuna, void *data) |
| 792 | { |
| 793 | switch (tuna->id) { |
| 794 | case ETHTOOL_PHY_DOWNSHIFT: |
| 795 | return m88e1111_get_downshift(phydev, data); |
| 796 | default: |
| 797 | return -EOPNOTSUPP; |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | static int m88e1111_set_tunable(struct phy_device *phydev, |
| 802 | struct ethtool_tunable *tuna, const void *data) |
| 803 | { |
| 804 | switch (tuna->id) { |
| 805 | case ETHTOOL_PHY_DOWNSHIFT: |
| 806 | return m88e1111_set_downshift(phydev, *(const u8 *)data); |
| 807 | default: |
| 808 | return -EOPNOTSUPP; |
| 809 | } |
| 810 | } |
| 811 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 812 | static int m88e1011_get_downshift(struct phy_device *phydev, u8 *data) |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 813 | { |
| 814 | int val, cnt, enable; |
| 815 | |
| 816 | val = phy_read(phydev, MII_M1011_PHY_SCR); |
| 817 | if (val < 0) |
| 818 | return val; |
| 819 | |
| 820 | enable = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_EN, val); |
Heiner Kallweit | f8d975b | 2019-10-28 20:52:22 +0100 | [diff] [blame] | 821 | cnt = FIELD_GET(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, val) + 1; |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 822 | |
| 823 | *data = enable ? cnt : DOWNSHIFT_DEV_DISABLE; |
| 824 | |
| 825 | return 0; |
| 826 | } |
| 827 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 828 | static int m88e1011_set_downshift(struct phy_device *phydev, u8 cnt) |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 829 | { |
| 830 | int val; |
| 831 | |
| 832 | if (cnt > MII_M1011_PHY_SCR_DOWNSHIFT_MAX) |
| 833 | return -E2BIG; |
| 834 | |
| 835 | if (!cnt) |
| 836 | return phy_clear_bits(phydev, MII_M1011_PHY_SCR, |
| 837 | MII_M1011_PHY_SCR_DOWNSHIFT_EN); |
| 838 | |
| 839 | val = MII_M1011_PHY_SCR_DOWNSHIFT_EN; |
Heiner Kallweit | f8d975b | 2019-10-28 20:52:22 +0100 | [diff] [blame] | 840 | val |= FIELD_PREP(MII_M1011_PHY_SCR_DOWNSHIFT_MASK, cnt - 1); |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 841 | |
| 842 | return phy_modify(phydev, MII_M1011_PHY_SCR, |
| 843 | MII_M1011_PHY_SCR_DOWNSHIFT_EN | |
Heiner Kallweit | f8d975b | 2019-10-28 20:52:22 +0100 | [diff] [blame] | 844 | MII_M1011_PHY_SCR_DOWNSHIFT_MASK, |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 845 | val); |
| 846 | } |
| 847 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 848 | static int m88e1011_get_tunable(struct phy_device *phydev, |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 849 | struct ethtool_tunable *tuna, void *data) |
| 850 | { |
| 851 | switch (tuna->id) { |
| 852 | case ETHTOOL_PHY_DOWNSHIFT: |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 853 | return m88e1011_get_downshift(phydev, data); |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 854 | default: |
| 855 | return -EOPNOTSUPP; |
| 856 | } |
| 857 | } |
| 858 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 859 | static int m88e1011_set_tunable(struct phy_device *phydev, |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 860 | struct ethtool_tunable *tuna, const void *data) |
| 861 | { |
| 862 | switch (tuna->id) { |
| 863 | case ETHTOOL_PHY_DOWNSHIFT: |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 864 | return m88e1011_set_downshift(phydev, *(const u8 *)data); |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 865 | default: |
| 866 | return -EOPNOTSUPP; |
| 867 | } |
| 868 | } |
| 869 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 870 | static void m88e1011_link_change_notify(struct phy_device *phydev) |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 871 | { |
| 872 | int status; |
| 873 | |
| 874 | if (phydev->state != PHY_RUNNING) |
| 875 | return; |
| 876 | |
| 877 | /* we may be on fiber page currently */ |
| 878 | status = phy_read_paged(phydev, MII_MARVELL_COPPER_PAGE, |
| 879 | MII_M1011_PHY_SSR); |
| 880 | |
| 881 | if (status > 0 && status & MII_M1011_PHY_SSR_DOWNSHIFT) |
| 882 | phydev_warn(phydev, "Downshift occurred! Cabling may be defective.\n"); |
| 883 | } |
| 884 | |
Heiner Kallweit | e2d861c | 2019-10-19 15:58:19 +0200 | [diff] [blame] | 885 | static int m88e1116r_config_init(struct phy_device *phydev) |
| 886 | { |
| 887 | int err; |
| 888 | |
| 889 | err = genphy_soft_reset(phydev); |
| 890 | if (err < 0) |
| 891 | return err; |
| 892 | |
| 893 | msleep(500); |
| 894 | |
| 895 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
| 896 | if (err < 0) |
| 897 | return err; |
| 898 | |
| 899 | err = marvell_set_polarity(phydev, phydev->mdix_ctrl); |
| 900 | if (err < 0) |
| 901 | return err; |
| 902 | |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 903 | err = m88e1011_set_downshift(phydev, 8); |
Heiner Kallweit | e2d861c | 2019-10-19 15:58:19 +0200 | [diff] [blame] | 904 | if (err < 0) |
| 905 | return err; |
| 906 | |
| 907 | if (phy_interface_is_rgmii(phydev)) { |
| 908 | err = m88e1121_config_aneg_rgmii_delays(phydev); |
| 909 | if (err < 0) |
| 910 | return err; |
| 911 | } |
| 912 | |
| 913 | err = genphy_soft_reset(phydev); |
| 914 | if (err < 0) |
| 915 | return err; |
| 916 | |
| 917 | return marvell_config_init(phydev); |
| 918 | } |
| 919 | |
Esben Haabendal | dd9a122 | 2018-04-05 22:40:29 +0200 | [diff] [blame] | 920 | static int m88e1318_config_init(struct phy_device *phydev) |
| 921 | { |
| 922 | if (phy_interrupt_is_valid(phydev)) { |
| 923 | int err = phy_modify_paged( |
| 924 | phydev, MII_MARVELL_LED_PAGE, |
| 925 | MII_88E1318S_PHY_LED_TCR, |
| 926 | MII_88E1318S_PHY_LED_TCR_FORCE_INT, |
| 927 | MII_88E1318S_PHY_LED_TCR_INTn_ENABLE | |
| 928 | MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW); |
| 929 | if (err < 0) |
| 930 | return err; |
| 931 | } |
| 932 | |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 933 | return marvell_config_init(phydev); |
Esben Haabendal | dd9a122 | 2018-04-05 22:40:29 +0200 | [diff] [blame] | 934 | } |
| 935 | |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 936 | static int m88e1510_config_init(struct phy_device *phydev) |
| 937 | { |
| 938 | int err; |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 939 | |
| 940 | /* SGMII-to-Copper mode initialization */ |
| 941 | if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { |
| 942 | /* Select page 18 */ |
Andrew Lunn | 6427bb2 | 2017-05-17 03:26:03 +0200 | [diff] [blame] | 943 | err = marvell_set_page(phydev, 18); |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 944 | if (err < 0) |
| 945 | return err; |
| 946 | |
| 947 | /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */ |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 948 | err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 949 | MII_88E1510_GEN_CTRL_REG_1_MODE_MASK, |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 950 | MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII); |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 951 | if (err < 0) |
| 952 | return err; |
| 953 | |
| 954 | /* PHY reset is necessary after changing MODE[2:0] */ |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 955 | err = phy_modify(phydev, MII_88E1510_GEN_CTRL_REG_1, 0, |
| 956 | MII_88E1510_GEN_CTRL_REG_1_RESET); |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 957 | if (err < 0) |
| 958 | return err; |
| 959 | |
| 960 | /* Reset page selection */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 961 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 962 | if (err < 0) |
| 963 | return err; |
| 964 | } |
| 965 | |
Esben Haabendal | dd9a122 | 2018-04-05 22:40:29 +0200 | [diff] [blame] | 966 | return m88e1318_config_init(phydev); |
Clemens Gruber | 407353e | 2016-02-23 20:16:58 +0100 | [diff] [blame] | 967 | } |
| 968 | |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 969 | static int m88e1118_config_aneg(struct phy_device *phydev) |
| 970 | { |
| 971 | int err; |
| 972 | |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 973 | err = genphy_soft_reset(phydev); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 974 | if (err < 0) |
| 975 | return err; |
| 976 | |
Andrew Lunn | fecd5e9 | 2017-07-30 22:41:49 +0200 | [diff] [blame] | 977 | err = marvell_set_polarity(phydev, phydev->mdix_ctrl); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 978 | if (err < 0) |
| 979 | return err; |
| 980 | |
| 981 | err = genphy_config_aneg(phydev); |
| 982 | return 0; |
| 983 | } |
| 984 | |
| 985 | static int m88e1118_config_init(struct phy_device *phydev) |
| 986 | { |
| 987 | int err; |
| 988 | |
| 989 | /* Change address */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 990 | err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 991 | if (err < 0) |
| 992 | return err; |
| 993 | |
| 994 | /* Enable 1000 Mbit */ |
| 995 | err = phy_write(phydev, 0x15, 0x1070); |
| 996 | if (err < 0) |
| 997 | return err; |
| 998 | |
| 999 | /* Change address */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1000 | err = marvell_set_page(phydev, MII_MARVELL_LED_PAGE); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 1001 | if (err < 0) |
| 1002 | return err; |
| 1003 | |
| 1004 | /* Adjust LED Control */ |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 1005 | if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS) |
| 1006 | err = phy_write(phydev, 0x10, 0x1100); |
| 1007 | else |
| 1008 | err = phy_write(phydev, 0x10, 0x021e); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 1009 | if (err < 0) |
| 1010 | return err; |
| 1011 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 1012 | err = marvell_of_reg_init(phydev); |
| 1013 | if (err < 0) |
| 1014 | return err; |
| 1015 | |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 1016 | /* Reset address */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1017 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 1018 | if (err < 0) |
| 1019 | return err; |
| 1020 | |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 1021 | return genphy_soft_reset(phydev); |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 1022 | } |
| 1023 | |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 1024 | static int m88e1149_config_init(struct phy_device *phydev) |
| 1025 | { |
| 1026 | int err; |
| 1027 | |
| 1028 | /* Change address */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1029 | err = marvell_set_page(phydev, MII_MARVELL_MSCR_PAGE); |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 1030 | if (err < 0) |
| 1031 | return err; |
| 1032 | |
| 1033 | /* Enable 1000 Mbit */ |
| 1034 | err = phy_write(phydev, 0x15, 0x1048); |
| 1035 | if (err < 0) |
| 1036 | return err; |
| 1037 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 1038 | err = marvell_of_reg_init(phydev); |
| 1039 | if (err < 0) |
| 1040 | return err; |
| 1041 | |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 1042 | /* Reset address */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1043 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 1044 | if (err < 0) |
| 1045 | return err; |
| 1046 | |
Andrew Lunn | 3438634 | 2017-07-30 22:41:45 +0200 | [diff] [blame] | 1047 | return genphy_soft_reset(phydev); |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 1048 | } |
| 1049 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1050 | static int m88e1145_config_init_rgmii(struct phy_device *phydev) |
| 1051 | { |
| 1052 | int err; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1053 | |
Andrew Lunn | 6111159 | 2017-07-30 22:41:46 +0200 | [diff] [blame] | 1054 | err = m88e1111_config_init_rgmii_delays(phydev); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1055 | if (err < 0) |
| 1056 | return err; |
| 1057 | |
| 1058 | if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) { |
| 1059 | err = phy_write(phydev, 0x1d, 0x0012); |
| 1060 | if (err < 0) |
| 1061 | return err; |
| 1062 | |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 1063 | err = phy_modify(phydev, 0x1e, 0x0fc0, |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 1064 | 2 << 9 | /* 36 ohm */ |
| 1065 | 2 << 6); /* 39 ohm */ |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1066 | if (err < 0) |
| 1067 | return err; |
| 1068 | |
| 1069 | err = phy_write(phydev, 0x1d, 0x3); |
| 1070 | if (err < 0) |
| 1071 | return err; |
| 1072 | |
| 1073 | err = phy_write(phydev, 0x1e, 0x8000); |
| 1074 | } |
| 1075 | return err; |
| 1076 | } |
| 1077 | |
| 1078 | static int m88e1145_config_init_sgmii(struct phy_device *phydev) |
| 1079 | { |
Andrew Lunn | 865b813a | 2017-07-30 22:41:47 +0200 | [diff] [blame] | 1080 | return m88e1111_config_init_hwcfg_mode( |
| 1081 | phydev, MII_M1111_HWCFG_MODE_SGMII_NO_CLK, |
| 1082 | MII_M1111_HWCFG_FIBER_COPPER_AUTO); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1083 | } |
| 1084 | |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 1085 | static int m88e1145_config_init(struct phy_device *phydev) |
| 1086 | { |
| 1087 | int err; |
| 1088 | |
| 1089 | /* Take care of errata E0 & E1 */ |
| 1090 | err = phy_write(phydev, 0x1d, 0x001b); |
| 1091 | if (err < 0) |
| 1092 | return err; |
| 1093 | |
| 1094 | err = phy_write(phydev, 0x1e, 0x418f); |
| 1095 | if (err < 0) |
| 1096 | return err; |
| 1097 | |
| 1098 | err = phy_write(phydev, 0x1d, 0x0016); |
| 1099 | if (err < 0) |
| 1100 | return err; |
| 1101 | |
| 1102 | err = phy_write(phydev, 0x1e, 0xa2da); |
| 1103 | if (err < 0) |
| 1104 | return err; |
| 1105 | |
Kim Phillips | 895ee68 | 2007-06-05 18:46:47 +0800 | [diff] [blame] | 1106 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1107 | err = m88e1145_config_init_rgmii(phydev); |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 1108 | if (err < 0) |
| 1109 | return err; |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 1110 | } |
| 1111 | |
Viet Nga Dao | b022417 | 2014-10-23 19:41:53 -0700 | [diff] [blame] | 1112 | if (phydev->interface == PHY_INTERFACE_MODE_SGMII) { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1113 | err = m88e1145_config_init_sgmii(phydev); |
Viet Nga Dao | b022417 | 2014-10-23 19:41:53 -0700 | [diff] [blame] | 1114 | if (err < 0) |
| 1115 | return err; |
| 1116 | } |
| 1117 | |
David Daney | cf41a51 | 2010-11-19 12:13:18 +0000 | [diff] [blame] | 1118 | err = marvell_of_reg_init(phydev); |
| 1119 | if (err < 0) |
| 1120 | return err; |
| 1121 | |
Andy Fleming | 7688467 | 2007-02-09 18:13:58 -0600 | [diff] [blame] | 1122 | return 0; |
| 1123 | } |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 1124 | |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 1125 | static int m88e1540_get_fld(struct phy_device *phydev, u8 *msecs) |
| 1126 | { |
| 1127 | int val; |
| 1128 | |
| 1129 | val = phy_read(phydev, MII_88E1540_COPPER_CTRL3); |
| 1130 | if (val < 0) |
| 1131 | return val; |
| 1132 | |
| 1133 | if (!(val & MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN)) { |
| 1134 | *msecs = ETHTOOL_PHY_FAST_LINK_DOWN_OFF; |
| 1135 | return 0; |
| 1136 | } |
| 1137 | |
| 1138 | val = FIELD_GET(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK, val); |
| 1139 | |
| 1140 | switch (val) { |
| 1141 | case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS: |
| 1142 | *msecs = 0; |
| 1143 | break; |
| 1144 | case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS: |
| 1145 | *msecs = 10; |
| 1146 | break; |
| 1147 | case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS: |
| 1148 | *msecs = 20; |
| 1149 | break; |
| 1150 | case MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS: |
| 1151 | *msecs = 40; |
| 1152 | break; |
| 1153 | default: |
| 1154 | return -EINVAL; |
| 1155 | } |
| 1156 | |
| 1157 | return 0; |
| 1158 | } |
| 1159 | |
| 1160 | static int m88e1540_set_fld(struct phy_device *phydev, const u8 *msecs) |
| 1161 | { |
| 1162 | struct ethtool_eee eee; |
| 1163 | int val, ret; |
| 1164 | |
| 1165 | if (*msecs == ETHTOOL_PHY_FAST_LINK_DOWN_OFF) |
| 1166 | return phy_clear_bits(phydev, MII_88E1540_COPPER_CTRL3, |
| 1167 | MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN); |
| 1168 | |
| 1169 | /* According to the Marvell data sheet EEE must be disabled for |
| 1170 | * Fast Link Down detection to work properly |
| 1171 | */ |
| 1172 | ret = phy_ethtool_get_eee(phydev, &eee); |
| 1173 | if (!ret && eee.eee_enabled) { |
| 1174 | phydev_warn(phydev, "Fast Link Down detection requires EEE to be disabled!\n"); |
| 1175 | return -EBUSY; |
| 1176 | } |
| 1177 | |
| 1178 | if (*msecs <= 5) |
| 1179 | val = MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_00MS; |
| 1180 | else if (*msecs <= 15) |
| 1181 | val = MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_10MS; |
| 1182 | else if (*msecs <= 30) |
| 1183 | val = MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_20MS; |
| 1184 | else |
| 1185 | val = MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_40MS; |
| 1186 | |
| 1187 | val = FIELD_PREP(MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK, val); |
| 1188 | |
| 1189 | ret = phy_modify(phydev, MII_88E1540_COPPER_CTRL3, |
| 1190 | MII_88E1540_COPPER_CTRL3_LINK_DOWN_DELAY_MASK, val); |
| 1191 | if (ret) |
| 1192 | return ret; |
| 1193 | |
| 1194 | return phy_set_bits(phydev, MII_88E1540_COPPER_CTRL3, |
| 1195 | MII_88E1540_COPPER_CTRL3_FAST_LINK_DOWN); |
| 1196 | } |
| 1197 | |
| 1198 | static int m88e1540_get_tunable(struct phy_device *phydev, |
| 1199 | struct ethtool_tunable *tuna, void *data) |
| 1200 | { |
| 1201 | switch (tuna->id) { |
| 1202 | case ETHTOOL_PHY_FAST_LINK_DOWN: |
| 1203 | return m88e1540_get_fld(phydev, data); |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 1204 | case ETHTOOL_PHY_DOWNSHIFT: |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 1205 | return m88e1011_get_downshift(phydev, data); |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 1206 | default: |
| 1207 | return -EOPNOTSUPP; |
| 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | static int m88e1540_set_tunable(struct phy_device *phydev, |
| 1212 | struct ethtool_tunable *tuna, const void *data) |
| 1213 | { |
| 1214 | switch (tuna->id) { |
| 1215 | case ETHTOOL_PHY_FAST_LINK_DOWN: |
| 1216 | return m88e1540_set_fld(phydev, data); |
Heiner Kallweit | a3bdfce | 2019-10-19 15:57:33 +0200 | [diff] [blame] | 1217 | case ETHTOOL_PHY_DOWNSHIFT: |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 1218 | return m88e1011_set_downshift(phydev, *(const u8 *)data); |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 1219 | default: |
| 1220 | return -EOPNOTSUPP; |
| 1221 | } |
| 1222 | } |
| 1223 | |
Andrew Lunn | 8cbcdc1 | 2019-01-10 22:48:36 +0100 | [diff] [blame] | 1224 | /* The VOD can be out of specification on link up. Poke an |
| 1225 | * undocumented register, in an undocumented page, with a magic value |
| 1226 | * to fix this. |
| 1227 | */ |
| 1228 | static int m88e6390_errata(struct phy_device *phydev) |
| 1229 | { |
| 1230 | int err; |
| 1231 | |
| 1232 | err = phy_write(phydev, MII_BMCR, |
| 1233 | BMCR_ANENABLE | BMCR_SPEED1000 | BMCR_FULLDPLX); |
| 1234 | if (err) |
| 1235 | return err; |
| 1236 | |
| 1237 | usleep_range(300, 400); |
| 1238 | |
| 1239 | err = phy_write_paged(phydev, 0xf8, 0x08, 0x36); |
| 1240 | if (err) |
| 1241 | return err; |
| 1242 | |
| 1243 | return genphy_soft_reset(phydev); |
| 1244 | } |
| 1245 | |
| 1246 | static int m88e6390_config_aneg(struct phy_device *phydev) |
| 1247 | { |
| 1248 | int err; |
| 1249 | |
| 1250 | err = m88e6390_errata(phydev); |
| 1251 | if (err) |
| 1252 | return err; |
| 1253 | |
| 1254 | return m88e1510_config_aneg(phydev); |
| 1255 | } |
| 1256 | |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1257 | /** |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1258 | * fiber_lpa_mod_linkmode_lpa_t |
Andrew Lunn | c0ec3c2 | 2018-11-10 23:43:34 +0100 | [diff] [blame] | 1259 | * @advertising: the linkmode advertisement settings |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1260 | * @lpa: value of the MII_LPA register for fiber link |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1261 | * |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1262 | * A small helper function that translates MII_LPA bits to linkmode LP |
| 1263 | * advertisement settings. Other bits in advertising are left |
| 1264 | * unchanged. |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1265 | */ |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1266 | static void fiber_lpa_mod_linkmode_lpa_t(unsigned long *advertising, u32 lpa) |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1267 | { |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1268 | linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 1269 | advertising, lpa & LPA_1000XHALF); |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1270 | |
| 1271 | linkmode_mod_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, |
Russell King | 20ecf42 | 2019-12-17 13:39:42 +0000 | [diff] [blame] | 1272 | advertising, lpa & LPA_1000XFULL); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1273 | } |
| 1274 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1275 | static int marvell_read_status_page_an(struct phy_device *phydev, |
Russell King | d2004e2 | 2019-12-17 13:39:36 +0000 | [diff] [blame] | 1276 | int fiber, int status) |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1277 | { |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1278 | int lpa; |
Russell King | fcf1f59 | 2019-12-17 13:39:21 +0000 | [diff] [blame] | 1279 | int err; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1280 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1281 | if (!fiber) { |
Russell King | fcf1f59 | 2019-12-17 13:39:21 +0000 | [diff] [blame] | 1282 | err = genphy_read_lpa(phydev); |
| 1283 | if (err < 0) |
| 1284 | return err; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1285 | |
Russell King | af00624 | 2019-12-17 13:39:06 +0000 | [diff] [blame] | 1286 | phy_resolve_aneg_pause(phydev); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1287 | } else { |
Russell King | fcf1f59 | 2019-12-17 13:39:21 +0000 | [diff] [blame] | 1288 | lpa = phy_read(phydev, MII_LPA); |
| 1289 | if (lpa < 0) |
| 1290 | return lpa; |
| 1291 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1292 | /* The fiber link is only 1000M capable */ |
Andrew Lunn | ab9cb72 | 2018-12-05 21:49:42 +0100 | [diff] [blame] | 1293 | fiber_lpa_mod_linkmode_lpa_t(phydev->lp_advertising, lpa); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1294 | |
| 1295 | if (phydev->duplex == DUPLEX_FULL) { |
| 1296 | if (!(lpa & LPA_PAUSE_FIBER)) { |
| 1297 | phydev->pause = 0; |
| 1298 | phydev->asym_pause = 0; |
| 1299 | } else if ((lpa & LPA_PAUSE_ASYM_FIBER)) { |
| 1300 | phydev->pause = 1; |
| 1301 | phydev->asym_pause = 1; |
| 1302 | } else { |
| 1303 | phydev->pause = 1; |
| 1304 | phydev->asym_pause = 0; |
| 1305 | } |
| 1306 | } |
| 1307 | } |
Russell King | fcf1f59 | 2019-12-17 13:39:21 +0000 | [diff] [blame] | 1308 | |
Russell King | b82cf17 | 2020-02-27 09:44:49 +0000 | [diff] [blame^] | 1309 | if (!(status & MII_M1011_PHY_STATUS_RESOLVED)) |
| 1310 | return 0; |
| 1311 | |
Russell King | fcf1f59 | 2019-12-17 13:39:21 +0000 | [diff] [blame] | 1312 | if (status & MII_M1011_PHY_STATUS_FULLDUPLEX) |
| 1313 | phydev->duplex = DUPLEX_FULL; |
| 1314 | else |
| 1315 | phydev->duplex = DUPLEX_HALF; |
| 1316 | |
| 1317 | switch (status & MII_M1011_PHY_STATUS_SPD_MASK) { |
| 1318 | case MII_M1011_PHY_STATUS_1000: |
| 1319 | phydev->speed = SPEED_1000; |
| 1320 | break; |
| 1321 | |
| 1322 | case MII_M1011_PHY_STATUS_100: |
| 1323 | phydev->speed = SPEED_100; |
| 1324 | break; |
| 1325 | |
| 1326 | default: |
| 1327 | phydev->speed = SPEED_10; |
| 1328 | break; |
| 1329 | } |
| 1330 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1331 | return 0; |
| 1332 | } |
| 1333 | |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1334 | /* marvell_read_status_page |
| 1335 | * |
Jeff Garzik | f0c88f9 | 2008-03-25 23:53:24 -0400 | [diff] [blame] | 1336 | * Description: |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1337 | * Check the link, then figure out the current state |
| 1338 | * by comparing what we advertise with what the link partner |
| 1339 | * advertises. Start by checking the gigabit possibilities, |
| 1340 | * then move on to 10/100. |
| 1341 | */ |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1342 | static int marvell_read_status_page(struct phy_device *phydev, int page) |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1343 | { |
Russell King | d2004e2 | 2019-12-17 13:39:36 +0000 | [diff] [blame] | 1344 | int status; |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1345 | int fiber; |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1346 | int err; |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1347 | |
Russell King | d2004e2 | 2019-12-17 13:39:36 +0000 | [diff] [blame] | 1348 | status = phy_read(phydev, MII_M1011_PHY_STATUS); |
| 1349 | if (status < 0) |
| 1350 | return status; |
| 1351 | |
| 1352 | /* Use the generic register for copper link status, |
| 1353 | * and the PHY status register for fiber link status. |
Andrew Lunn | 0c3439b | 2017-05-17 03:25:59 +0200 | [diff] [blame] | 1354 | */ |
Russell King | d2004e2 | 2019-12-17 13:39:36 +0000 | [diff] [blame] | 1355 | if (page == MII_MARVELL_FIBER_PAGE) { |
| 1356 | phydev->link = !!(status & MII_M1011_PHY_STATUS_LINK); |
| 1357 | } else { |
| 1358 | err = genphy_update_link(phydev); |
| 1359 | if (err) |
| 1360 | return err; |
| 1361 | } |
| 1362 | |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1363 | if (page == MII_MARVELL_FIBER_PAGE) |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1364 | fiber = 1; |
| 1365 | else |
| 1366 | fiber = 0; |
| 1367 | |
Russell King | 98f9283 | 2019-12-17 13:39:26 +0000 | [diff] [blame] | 1368 | linkmode_zero(phydev->lp_advertising); |
| 1369 | phydev->pause = 0; |
| 1370 | phydev->asym_pause = 0; |
Russell King | b82cf17 | 2020-02-27 09:44:49 +0000 | [diff] [blame^] | 1371 | phydev->speed = SPEED_UNKNOWN; |
| 1372 | phydev->duplex = DUPLEX_UNKNOWN; |
Russell King | 98f9283 | 2019-12-17 13:39:26 +0000 | [diff] [blame] | 1373 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1374 | if (phydev->autoneg == AUTONEG_ENABLE) |
Russell King | d2004e2 | 2019-12-17 13:39:36 +0000 | [diff] [blame] | 1375 | err = marvell_read_status_page_an(phydev, fiber, status); |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1376 | else |
Russell King | 98f9283 | 2019-12-17 13:39:26 +0000 | [diff] [blame] | 1377 | err = genphy_read_status_fixed(phydev); |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1378 | |
Andrew Lunn | e1dde8d | 2017-05-17 03:26:02 +0200 | [diff] [blame] | 1379 | return err; |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 1380 | } |
| 1381 | |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1382 | /* marvell_read_status |
| 1383 | * |
| 1384 | * Some Marvell's phys have two modes: fiber and copper. |
| 1385 | * Both need status checked. |
| 1386 | * Description: |
| 1387 | * First, check the fiber link and status. |
| 1388 | * If the fiber link is down, check the copper link and status which |
| 1389 | * will be the default value if both link are down. |
| 1390 | */ |
| 1391 | static int marvell_read_status(struct phy_device *phydev) |
| 1392 | { |
| 1393 | int err; |
| 1394 | |
| 1395 | /* Check the fiber mode first */ |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 1396 | if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, |
| 1397 | phydev->supported) && |
Russell King | a13c0652 | 2017-01-10 23:13:45 +0000 | [diff] [blame] | 1398 | phydev->interface != PHY_INTERFACE_MODE_SGMII) { |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1399 | err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1400 | if (err < 0) |
| 1401 | goto error; |
| 1402 | |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1403 | err = marvell_read_status_page(phydev, MII_MARVELL_FIBER_PAGE); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1404 | if (err < 0) |
| 1405 | goto error; |
| 1406 | |
Andrew Lunn | 0c3439b | 2017-05-17 03:25:59 +0200 | [diff] [blame] | 1407 | /* If the fiber link is up, it is the selected and |
| 1408 | * used link. In this case, we need to stay in the |
| 1409 | * fiber page. Please to be careful about that, avoid |
| 1410 | * to restore Copper page in other functions which |
| 1411 | * could break the behaviour for some fiber phy like |
| 1412 | * 88E1512. |
| 1413 | */ |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1414 | if (phydev->link) |
| 1415 | return 0; |
| 1416 | |
| 1417 | /* If fiber link is down, check and save copper mode state */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1418 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1419 | if (err < 0) |
| 1420 | goto error; |
| 1421 | } |
| 1422 | |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1423 | return marvell_read_status_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1424 | |
| 1425 | error: |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1426 | marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 6cfb3bc | 2016-07-19 11:13:10 +0200 | [diff] [blame] | 1427 | return err; |
| 1428 | } |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1429 | |
| 1430 | /* marvell_suspend |
| 1431 | * |
| 1432 | * Some Marvell's phys have two modes: fiber and copper. |
| 1433 | * Both need to be suspended |
| 1434 | */ |
| 1435 | static int marvell_suspend(struct phy_device *phydev) |
| 1436 | { |
| 1437 | int err; |
| 1438 | |
| 1439 | /* Suspend the fiber mode first */ |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 1440 | if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, |
| 1441 | phydev->supported)) { |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1442 | err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1443 | if (err < 0) |
| 1444 | goto error; |
| 1445 | |
| 1446 | /* With the page set, use the generic suspend */ |
| 1447 | err = genphy_suspend(phydev); |
| 1448 | if (err < 0) |
| 1449 | goto error; |
| 1450 | |
| 1451 | /* Then, the copper link */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1452 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1453 | if (err < 0) |
| 1454 | goto error; |
| 1455 | } |
| 1456 | |
| 1457 | /* With the page set, use the generic suspend */ |
| 1458 | return genphy_suspend(phydev); |
| 1459 | |
| 1460 | error: |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1461 | marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1462 | return err; |
| 1463 | } |
| 1464 | |
| 1465 | /* marvell_resume |
| 1466 | * |
| 1467 | * Some Marvell's phys have two modes: fiber and copper. |
| 1468 | * Both need to be resumed |
| 1469 | */ |
| 1470 | static int marvell_resume(struct phy_device *phydev) |
| 1471 | { |
| 1472 | int err; |
| 1473 | |
| 1474 | /* Resume the fiber mode first */ |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 1475 | if (!linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, |
| 1476 | phydev->supported)) { |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1477 | err = marvell_set_page(phydev, MII_MARVELL_FIBER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1478 | if (err < 0) |
| 1479 | goto error; |
| 1480 | |
| 1481 | /* With the page set, use the generic resume */ |
| 1482 | err = genphy_resume(phydev); |
| 1483 | if (err < 0) |
| 1484 | goto error; |
| 1485 | |
| 1486 | /* Then, the copper link */ |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1487 | err = marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1488 | if (err < 0) |
| 1489 | goto error; |
| 1490 | } |
| 1491 | |
| 1492 | /* With the page set, use the generic resume */ |
| 1493 | return genphy_resume(phydev); |
| 1494 | |
| 1495 | error: |
Andrew Lunn | 5229566 | 2017-05-25 21:42:08 +0200 | [diff] [blame] | 1496 | marvell_set_page(phydev, MII_MARVELL_COPPER_PAGE); |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 1497 | return err; |
| 1498 | } |
| 1499 | |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 1500 | static int marvell_aneg_done(struct phy_device *phydev) |
| 1501 | { |
| 1502 | int retval = phy_read(phydev, MII_M1011_PHY_STATUS); |
Andrew Lunn | e69d9ed | 2017-05-17 03:26:00 +0200 | [diff] [blame] | 1503 | |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 1504 | return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED); |
| 1505 | } |
| 1506 | |
Anatolij Gustschin | dcd07be | 2009-04-07 02:01:43 +0000 | [diff] [blame] | 1507 | static int m88e1121_did_interrupt(struct phy_device *phydev) |
| 1508 | { |
| 1509 | int imask; |
| 1510 | |
| 1511 | imask = phy_read(phydev, MII_M1011_IEVENT); |
| 1512 | |
| 1513 | if (imask & MII_M1011_IMASK_INIT) |
| 1514 | return 1; |
| 1515 | |
| 1516 | return 0; |
| 1517 | } |
| 1518 | |
Andrew Lunn | 23beb38 | 2017-05-17 03:26:04 +0200 | [diff] [blame] | 1519 | static void m88e1318_get_wol(struct phy_device *phydev, |
| 1520 | struct ethtool_wolinfo *wol) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1521 | { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1522 | int oldpage, ret = 0; |
| 1523 | |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1524 | wol->supported = WAKE_MAGIC; |
| 1525 | wol->wolopts = 0; |
| 1526 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1527 | oldpage = phy_select_page(phydev, MII_MARVELL_WOL_PAGE); |
| 1528 | if (oldpage < 0) |
| 1529 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1530 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1531 | ret = __phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL); |
| 1532 | if (ret & MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1533 | wol->wolopts |= WAKE_MAGIC; |
| 1534 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1535 | error: |
| 1536 | phy_restore_page(phydev, oldpage, ret); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1537 | } |
| 1538 | |
Andrew Lunn | 23beb38 | 2017-05-17 03:26:04 +0200 | [diff] [blame] | 1539 | static int m88e1318_set_wol(struct phy_device *phydev, |
| 1540 | struct ethtool_wolinfo *wol) |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1541 | { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1542 | int err = 0, oldpage; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1543 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1544 | oldpage = phy_save_page(phydev); |
| 1545 | if (oldpage < 0) |
| 1546 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1547 | |
| 1548 | if (wol->wolopts & WAKE_MAGIC) { |
| 1549 | /* Explicitly switch to page 0x00, just to be sure */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1550 | err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1551 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1552 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1553 | |
Jingju Hou | b6a930f | 2018-04-23 15:22:49 +0800 | [diff] [blame] | 1554 | /* If WOL event happened once, the LED[2] interrupt pin |
| 1555 | * will not be cleared unless we reading the interrupt status |
| 1556 | * register. If interrupts are in use, the normal interrupt |
| 1557 | * handling will clear the WOL event. Clear the WOL event |
| 1558 | * before enabling it if !phy_interrupt_is_valid() |
| 1559 | */ |
| 1560 | if (!phy_interrupt_is_valid(phydev)) |
Andrew Lunn | e0a7328 | 2019-01-11 00:15:21 +0100 | [diff] [blame] | 1561 | __phy_read(phydev, MII_M1011_IEVENT); |
Jingju Hou | b6a930f | 2018-04-23 15:22:49 +0800 | [diff] [blame] | 1562 | |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1563 | /* Enable the WOL interrupt */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1564 | err = __phy_modify(phydev, MII_88E1318S_PHY_CSIER, 0, |
| 1565 | MII_88E1318S_PHY_CSIER_WOL_EIE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1566 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1567 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1568 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1569 | err = marvell_write_page(phydev, MII_MARVELL_LED_PAGE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1570 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1571 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1572 | |
| 1573 | /* Setup LED[2] as interrupt pin (active low) */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1574 | err = __phy_modify(phydev, MII_88E1318S_PHY_LED_TCR, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 1575 | MII_88E1318S_PHY_LED_TCR_FORCE_INT, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1576 | MII_88E1318S_PHY_LED_TCR_INTn_ENABLE | |
| 1577 | MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1578 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1579 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1580 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1581 | err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1582 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1583 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1584 | |
| 1585 | /* Store the device address for the magic packet */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1586 | err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2, |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1587 | ((phydev->attached_dev->dev_addr[5] << 8) | |
| 1588 | phydev->attached_dev->dev_addr[4])); |
| 1589 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1590 | goto error; |
| 1591 | err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1, |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1592 | ((phydev->attached_dev->dev_addr[3] << 8) | |
| 1593 | phydev->attached_dev->dev_addr[2])); |
| 1594 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1595 | goto error; |
| 1596 | err = __phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0, |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1597 | ((phydev->attached_dev->dev_addr[1] << 8) | |
| 1598 | phydev->attached_dev->dev_addr[0])); |
| 1599 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1600 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1601 | |
| 1602 | /* Clear WOL status and enable magic packet matching */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1603 | err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0, |
| 1604 | MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS | |
| 1605 | MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1606 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1607 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1608 | } else { |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1609 | err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1610 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1611 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1612 | |
| 1613 | /* Clear WOL status and disable magic packet matching */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1614 | err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 1615 | MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1616 | MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1617 | if (err < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1618 | goto error; |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1619 | } |
| 1620 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1621 | error: |
| 1622 | return phy_restore_page(phydev, oldpage, err); |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 1623 | } |
| 1624 | |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1625 | static int marvell_get_sset_count(struct phy_device *phydev) |
| 1626 | { |
Andrew Lunn | 3c1bcc8 | 2018-11-10 23:43:33 +0100 | [diff] [blame] | 1627 | if (linkmode_test_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, |
| 1628 | phydev->supported)) |
Charles-Antoine Couret | 2170fef | 2016-07-19 11:13:11 +0200 | [diff] [blame] | 1629 | return ARRAY_SIZE(marvell_hw_stats); |
| 1630 | else |
| 1631 | return ARRAY_SIZE(marvell_hw_stats) - NB_FIBER_STATS; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1632 | } |
| 1633 | |
| 1634 | static void marvell_get_strings(struct phy_device *phydev, u8 *data) |
| 1635 | { |
Andrew Lunn | fdfdf86 | 2019-04-25 00:33:00 +0200 | [diff] [blame] | 1636 | int count = marvell_get_sset_count(phydev); |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1637 | int i; |
| 1638 | |
Andrew Lunn | fdfdf86 | 2019-04-25 00:33:00 +0200 | [diff] [blame] | 1639 | for (i = 0; i < count; i++) { |
Florian Fainelli | 98409b2 | 2018-03-02 15:08:37 -0800 | [diff] [blame] | 1640 | strlcpy(data + i * ETH_GSTRING_LEN, |
| 1641 | marvell_hw_stats[i].string, ETH_GSTRING_LEN); |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1642 | } |
| 1643 | } |
| 1644 | |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1645 | static u64 marvell_get_stat(struct phy_device *phydev, int i) |
| 1646 | { |
| 1647 | struct marvell_hw_stat stat = marvell_hw_stats[i]; |
| 1648 | struct marvell_priv *priv = phydev->priv; |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1649 | int val; |
Andrew Lunn | 321b4d4 | 2016-02-20 00:35:29 +0100 | [diff] [blame] | 1650 | u64 ret; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1651 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1652 | val = phy_read_paged(phydev, stat.page, stat.reg); |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1653 | if (val < 0) { |
Jisheng Zhang | 6c3442f | 2018-04-27 16:18:58 +0800 | [diff] [blame] | 1654 | ret = U64_MAX; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1655 | } else { |
| 1656 | val = val & ((1 << stat.bits) - 1); |
| 1657 | priv->stats[i] += val; |
Andrew Lunn | 321b4d4 | 2016-02-20 00:35:29 +0100 | [diff] [blame] | 1658 | ret = priv->stats[i]; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1659 | } |
| 1660 | |
Andrew Lunn | 321b4d4 | 2016-02-20 00:35:29 +0100 | [diff] [blame] | 1661 | return ret; |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | static void marvell_get_stats(struct phy_device *phydev, |
| 1665 | struct ethtool_stats *stats, u64 *data) |
| 1666 | { |
Andrew Lunn | fdfdf86 | 2019-04-25 00:33:00 +0200 | [diff] [blame] | 1667 | int count = marvell_get_sset_count(phydev); |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1668 | int i; |
| 1669 | |
Andrew Lunn | fdfdf86 | 2019-04-25 00:33:00 +0200 | [diff] [blame] | 1670 | for (i = 0; i < count; i++) |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 1671 | data[i] = marvell_get_stat(phydev, i); |
| 1672 | } |
| 1673 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1674 | #ifdef CONFIG_HWMON |
| 1675 | static int m88e1121_get_temp(struct phy_device *phydev, long *temp) |
| 1676 | { |
Andrew Lunn | 975b388 | 2017-05-25 21:42:06 +0200 | [diff] [blame] | 1677 | int oldpage; |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1678 | int ret = 0; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1679 | int val; |
| 1680 | |
| 1681 | *temp = 0; |
| 1682 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1683 | oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); |
| 1684 | if (oldpage < 0) |
| 1685 | goto error; |
Andrew Lunn | 975b388 | 2017-05-25 21:42:06 +0200 | [diff] [blame] | 1686 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1687 | /* Enable temperature sensor */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1688 | ret = __phy_read(phydev, MII_88E1121_MISC_TEST); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1689 | if (ret < 0) |
| 1690 | goto error; |
| 1691 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1692 | ret = __phy_write(phydev, MII_88E1121_MISC_TEST, |
| 1693 | ret | MII_88E1121_MISC_TEST_TEMP_SENSOR_EN); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1694 | if (ret < 0) |
| 1695 | goto error; |
| 1696 | |
| 1697 | /* Wait for temperature to stabilize */ |
| 1698 | usleep_range(10000, 12000); |
| 1699 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1700 | val = __phy_read(phydev, MII_88E1121_MISC_TEST); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1701 | if (val < 0) { |
| 1702 | ret = val; |
| 1703 | goto error; |
| 1704 | } |
| 1705 | |
| 1706 | /* Disable temperature sensor */ |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1707 | ret = __phy_write(phydev, MII_88E1121_MISC_TEST, |
| 1708 | ret & ~MII_88E1121_MISC_TEST_TEMP_SENSOR_EN); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1709 | if (ret < 0) |
| 1710 | goto error; |
| 1711 | |
| 1712 | *temp = ((val & MII_88E1121_MISC_TEST_TEMP_MASK) - 5) * 5000; |
| 1713 | |
| 1714 | error: |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1715 | return phy_restore_page(phydev, oldpage, ret); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1716 | } |
| 1717 | |
| 1718 | static int m88e1121_hwmon_read(struct device *dev, |
| 1719 | enum hwmon_sensor_types type, |
| 1720 | u32 attr, int channel, long *temp) |
| 1721 | { |
| 1722 | struct phy_device *phydev = dev_get_drvdata(dev); |
| 1723 | int err; |
| 1724 | |
| 1725 | switch (attr) { |
| 1726 | case hwmon_temp_input: |
| 1727 | err = m88e1121_get_temp(phydev, temp); |
| 1728 | break; |
| 1729 | default: |
| 1730 | return -EOPNOTSUPP; |
| 1731 | } |
| 1732 | |
| 1733 | return err; |
| 1734 | } |
| 1735 | |
| 1736 | static umode_t m88e1121_hwmon_is_visible(const void *data, |
| 1737 | enum hwmon_sensor_types type, |
| 1738 | u32 attr, int channel) |
| 1739 | { |
| 1740 | if (type != hwmon_temp) |
| 1741 | return 0; |
| 1742 | |
| 1743 | switch (attr) { |
| 1744 | case hwmon_temp_input: |
| 1745 | return 0444; |
| 1746 | default: |
| 1747 | return 0; |
| 1748 | } |
| 1749 | } |
| 1750 | |
| 1751 | static u32 m88e1121_hwmon_chip_config[] = { |
| 1752 | HWMON_C_REGISTER_TZ, |
| 1753 | 0 |
| 1754 | }; |
| 1755 | |
| 1756 | static const struct hwmon_channel_info m88e1121_hwmon_chip = { |
| 1757 | .type = hwmon_chip, |
| 1758 | .config = m88e1121_hwmon_chip_config, |
| 1759 | }; |
| 1760 | |
| 1761 | static u32 m88e1121_hwmon_temp_config[] = { |
| 1762 | HWMON_T_INPUT, |
| 1763 | 0 |
| 1764 | }; |
| 1765 | |
| 1766 | static const struct hwmon_channel_info m88e1121_hwmon_temp = { |
| 1767 | .type = hwmon_temp, |
| 1768 | .config = m88e1121_hwmon_temp_config, |
| 1769 | }; |
| 1770 | |
| 1771 | static const struct hwmon_channel_info *m88e1121_hwmon_info[] = { |
| 1772 | &m88e1121_hwmon_chip, |
| 1773 | &m88e1121_hwmon_temp, |
| 1774 | NULL |
| 1775 | }; |
| 1776 | |
| 1777 | static const struct hwmon_ops m88e1121_hwmon_hwmon_ops = { |
| 1778 | .is_visible = m88e1121_hwmon_is_visible, |
| 1779 | .read = m88e1121_hwmon_read, |
| 1780 | }; |
| 1781 | |
| 1782 | static const struct hwmon_chip_info m88e1121_hwmon_chip_info = { |
| 1783 | .ops = &m88e1121_hwmon_hwmon_ops, |
| 1784 | .info = m88e1121_hwmon_info, |
| 1785 | }; |
| 1786 | |
| 1787 | static int m88e1510_get_temp(struct phy_device *phydev, long *temp) |
| 1788 | { |
| 1789 | int ret; |
| 1790 | |
| 1791 | *temp = 0; |
| 1792 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1793 | ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, |
| 1794 | MII_88E1510_TEMP_SENSOR); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1795 | if (ret < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1796 | return ret; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1797 | |
| 1798 | *temp = ((ret & MII_88E1510_TEMP_SENSOR_MASK) - 25) * 1000; |
| 1799 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1800 | return 0; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1801 | } |
| 1802 | |
Colin Ian King | f0a4581 | 2017-06-02 15:13:34 +0100 | [diff] [blame] | 1803 | static int m88e1510_get_temp_critical(struct phy_device *phydev, long *temp) |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1804 | { |
| 1805 | int ret; |
| 1806 | |
| 1807 | *temp = 0; |
| 1808 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1809 | ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, |
| 1810 | MII_88E1121_MISC_TEST); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1811 | if (ret < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1812 | return ret; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1813 | |
| 1814 | *temp = (((ret & MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK) >> |
| 1815 | MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT) * 5) - 25; |
| 1816 | /* convert to mC */ |
| 1817 | *temp *= 1000; |
| 1818 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1819 | return 0; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1820 | } |
| 1821 | |
Colin Ian King | f0a4581 | 2017-06-02 15:13:34 +0100 | [diff] [blame] | 1822 | static int m88e1510_set_temp_critical(struct phy_device *phydev, long temp) |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1823 | { |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1824 | temp = temp / 1000; |
| 1825 | temp = clamp_val(DIV_ROUND_CLOSEST(temp, 5) + 5, 0, 0x1f); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1826 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1827 | return phy_modify_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, |
| 1828 | MII_88E1121_MISC_TEST, |
| 1829 | MII_88E1510_MISC_TEST_TEMP_THRESHOLD_MASK, |
| 1830 | temp << MII_88E1510_MISC_TEST_TEMP_THRESHOLD_SHIFT); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1831 | } |
| 1832 | |
Colin Ian King | f0a4581 | 2017-06-02 15:13:34 +0100 | [diff] [blame] | 1833 | static int m88e1510_get_temp_alarm(struct phy_device *phydev, long *alarm) |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1834 | { |
| 1835 | int ret; |
| 1836 | |
| 1837 | *alarm = false; |
| 1838 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1839 | ret = phy_read_paged(phydev, MII_MARVELL_MISC_TEST_PAGE, |
| 1840 | MII_88E1121_MISC_TEST); |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1841 | if (ret < 0) |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1842 | return ret; |
| 1843 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1844 | *alarm = !!(ret & MII_88E1510_MISC_TEST_TEMP_IRQ); |
| 1845 | |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 1846 | return 0; |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 1847 | } |
| 1848 | |
| 1849 | static int m88e1510_hwmon_read(struct device *dev, |
| 1850 | enum hwmon_sensor_types type, |
| 1851 | u32 attr, int channel, long *temp) |
| 1852 | { |
| 1853 | struct phy_device *phydev = dev_get_drvdata(dev); |
| 1854 | int err; |
| 1855 | |
| 1856 | switch (attr) { |
| 1857 | case hwmon_temp_input: |
| 1858 | err = m88e1510_get_temp(phydev, temp); |
| 1859 | break; |
| 1860 | case hwmon_temp_crit: |
| 1861 | err = m88e1510_get_temp_critical(phydev, temp); |
| 1862 | break; |
| 1863 | case hwmon_temp_max_alarm: |
| 1864 | err = m88e1510_get_temp_alarm(phydev, temp); |
| 1865 | break; |
| 1866 | default: |
| 1867 | return -EOPNOTSUPP; |
| 1868 | } |
| 1869 | |
| 1870 | return err; |
| 1871 | } |
| 1872 | |
| 1873 | static int m88e1510_hwmon_write(struct device *dev, |
| 1874 | enum hwmon_sensor_types type, |
| 1875 | u32 attr, int channel, long temp) |
| 1876 | { |
| 1877 | struct phy_device *phydev = dev_get_drvdata(dev); |
| 1878 | int err; |
| 1879 | |
| 1880 | switch (attr) { |
| 1881 | case hwmon_temp_crit: |
| 1882 | err = m88e1510_set_temp_critical(phydev, temp); |
| 1883 | break; |
| 1884 | default: |
| 1885 | return -EOPNOTSUPP; |
| 1886 | } |
| 1887 | return err; |
| 1888 | } |
| 1889 | |
| 1890 | static umode_t m88e1510_hwmon_is_visible(const void *data, |
| 1891 | enum hwmon_sensor_types type, |
| 1892 | u32 attr, int channel) |
| 1893 | { |
| 1894 | if (type != hwmon_temp) |
| 1895 | return 0; |
| 1896 | |
| 1897 | switch (attr) { |
| 1898 | case hwmon_temp_input: |
| 1899 | case hwmon_temp_max_alarm: |
| 1900 | return 0444; |
| 1901 | case hwmon_temp_crit: |
| 1902 | return 0644; |
| 1903 | default: |
| 1904 | return 0; |
| 1905 | } |
| 1906 | } |
| 1907 | |
| 1908 | static u32 m88e1510_hwmon_temp_config[] = { |
| 1909 | HWMON_T_INPUT | HWMON_T_CRIT | HWMON_T_MAX_ALARM, |
| 1910 | 0 |
| 1911 | }; |
| 1912 | |
| 1913 | static const struct hwmon_channel_info m88e1510_hwmon_temp = { |
| 1914 | .type = hwmon_temp, |
| 1915 | .config = m88e1510_hwmon_temp_config, |
| 1916 | }; |
| 1917 | |
| 1918 | static const struct hwmon_channel_info *m88e1510_hwmon_info[] = { |
| 1919 | &m88e1121_hwmon_chip, |
| 1920 | &m88e1510_hwmon_temp, |
| 1921 | NULL |
| 1922 | }; |
| 1923 | |
| 1924 | static const struct hwmon_ops m88e1510_hwmon_hwmon_ops = { |
| 1925 | .is_visible = m88e1510_hwmon_is_visible, |
| 1926 | .read = m88e1510_hwmon_read, |
| 1927 | .write = m88e1510_hwmon_write, |
| 1928 | }; |
| 1929 | |
| 1930 | static const struct hwmon_chip_info m88e1510_hwmon_chip_info = { |
| 1931 | .ops = &m88e1510_hwmon_hwmon_ops, |
| 1932 | .info = m88e1510_hwmon_info, |
| 1933 | }; |
| 1934 | |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 1935 | static int m88e6390_get_temp(struct phy_device *phydev, long *temp) |
| 1936 | { |
| 1937 | int sum = 0; |
| 1938 | int oldpage; |
| 1939 | int ret = 0; |
| 1940 | int i; |
| 1941 | |
| 1942 | *temp = 0; |
| 1943 | |
| 1944 | oldpage = phy_select_page(phydev, MII_MARVELL_MISC_TEST_PAGE); |
| 1945 | if (oldpage < 0) |
| 1946 | goto error; |
| 1947 | |
| 1948 | /* Enable temperature sensor */ |
| 1949 | ret = __phy_read(phydev, MII_88E6390_MISC_TEST); |
| 1950 | if (ret < 0) |
| 1951 | goto error; |
| 1952 | |
| 1953 | ret = ret & ~MII_88E6390_MISC_TEST_SAMPLE_MASK; |
| 1954 | ret |= MII_88E6390_MISC_TEST_SAMPLE_ENABLE | |
| 1955 | MII_88E6390_MISC_TEST_SAMPLE_1S; |
| 1956 | |
| 1957 | ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); |
| 1958 | if (ret < 0) |
| 1959 | goto error; |
| 1960 | |
| 1961 | /* Wait for temperature to stabilize */ |
| 1962 | usleep_range(10000, 12000); |
| 1963 | |
| 1964 | /* Reading the temperature sense has an errata. You need to read |
| 1965 | * a number of times and take an average. |
| 1966 | */ |
| 1967 | for (i = 0; i < MII_88E6390_TEMP_SENSOR_SAMPLES; i++) { |
| 1968 | ret = __phy_read(phydev, MII_88E6390_TEMP_SENSOR); |
| 1969 | if (ret < 0) |
| 1970 | goto error; |
| 1971 | sum += ret & MII_88E6390_TEMP_SENSOR_MASK; |
| 1972 | } |
| 1973 | |
| 1974 | sum /= MII_88E6390_TEMP_SENSOR_SAMPLES; |
| 1975 | *temp = (sum - 75) * 1000; |
| 1976 | |
| 1977 | /* Disable temperature sensor */ |
| 1978 | ret = __phy_read(phydev, MII_88E6390_MISC_TEST); |
| 1979 | if (ret < 0) |
| 1980 | goto error; |
| 1981 | |
| 1982 | ret = ret & ~MII_88E6390_MISC_TEST_SAMPLE_MASK; |
| 1983 | ret |= MII_88E6390_MISC_TEST_SAMPLE_DISABLE; |
| 1984 | |
| 1985 | ret = __phy_write(phydev, MII_88E6390_MISC_TEST, ret); |
| 1986 | |
| 1987 | error: |
| 1988 | phy_restore_page(phydev, oldpage, ret); |
| 1989 | |
| 1990 | return ret; |
| 1991 | } |
| 1992 | |
| 1993 | static int m88e6390_hwmon_read(struct device *dev, |
| 1994 | enum hwmon_sensor_types type, |
| 1995 | u32 attr, int channel, long *temp) |
| 1996 | { |
| 1997 | struct phy_device *phydev = dev_get_drvdata(dev); |
| 1998 | int err; |
| 1999 | |
| 2000 | switch (attr) { |
| 2001 | case hwmon_temp_input: |
| 2002 | err = m88e6390_get_temp(phydev, temp); |
| 2003 | break; |
| 2004 | default: |
| 2005 | return -EOPNOTSUPP; |
| 2006 | } |
| 2007 | |
| 2008 | return err; |
| 2009 | } |
| 2010 | |
| 2011 | static umode_t m88e6390_hwmon_is_visible(const void *data, |
| 2012 | enum hwmon_sensor_types type, |
| 2013 | u32 attr, int channel) |
| 2014 | { |
| 2015 | if (type != hwmon_temp) |
| 2016 | return 0; |
| 2017 | |
| 2018 | switch (attr) { |
| 2019 | case hwmon_temp_input: |
| 2020 | return 0444; |
| 2021 | default: |
| 2022 | return 0; |
| 2023 | } |
| 2024 | } |
| 2025 | |
| 2026 | static u32 m88e6390_hwmon_temp_config[] = { |
| 2027 | HWMON_T_INPUT, |
| 2028 | 0 |
| 2029 | }; |
| 2030 | |
| 2031 | static const struct hwmon_channel_info m88e6390_hwmon_temp = { |
| 2032 | .type = hwmon_temp, |
| 2033 | .config = m88e6390_hwmon_temp_config, |
| 2034 | }; |
| 2035 | |
| 2036 | static const struct hwmon_channel_info *m88e6390_hwmon_info[] = { |
| 2037 | &m88e1121_hwmon_chip, |
| 2038 | &m88e6390_hwmon_temp, |
| 2039 | NULL |
| 2040 | }; |
| 2041 | |
| 2042 | static const struct hwmon_ops m88e6390_hwmon_hwmon_ops = { |
| 2043 | .is_visible = m88e6390_hwmon_is_visible, |
| 2044 | .read = m88e6390_hwmon_read, |
| 2045 | }; |
| 2046 | |
| 2047 | static const struct hwmon_chip_info m88e6390_hwmon_chip_info = { |
| 2048 | .ops = &m88e6390_hwmon_hwmon_ops, |
| 2049 | .info = m88e6390_hwmon_info, |
| 2050 | }; |
| 2051 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 2052 | static int marvell_hwmon_name(struct phy_device *phydev) |
| 2053 | { |
| 2054 | struct marvell_priv *priv = phydev->priv; |
| 2055 | struct device *dev = &phydev->mdio.dev; |
| 2056 | const char *devname = dev_name(dev); |
| 2057 | size_t len = strlen(devname); |
| 2058 | int i, j; |
| 2059 | |
| 2060 | priv->hwmon_name = devm_kzalloc(dev, len, GFP_KERNEL); |
| 2061 | if (!priv->hwmon_name) |
| 2062 | return -ENOMEM; |
| 2063 | |
| 2064 | for (i = j = 0; i < len && devname[i]; i++) { |
| 2065 | if (isalnum(devname[i])) |
| 2066 | priv->hwmon_name[j++] = devname[i]; |
| 2067 | } |
| 2068 | |
| 2069 | return 0; |
| 2070 | } |
| 2071 | |
| 2072 | static int marvell_hwmon_probe(struct phy_device *phydev, |
| 2073 | const struct hwmon_chip_info *chip) |
| 2074 | { |
| 2075 | struct marvell_priv *priv = phydev->priv; |
| 2076 | struct device *dev = &phydev->mdio.dev; |
| 2077 | int err; |
| 2078 | |
| 2079 | err = marvell_hwmon_name(phydev); |
| 2080 | if (err) |
| 2081 | return err; |
| 2082 | |
| 2083 | priv->hwmon_dev = devm_hwmon_device_register_with_info( |
| 2084 | dev, priv->hwmon_name, phydev, chip, NULL); |
| 2085 | |
| 2086 | return PTR_ERR_OR_ZERO(priv->hwmon_dev); |
| 2087 | } |
| 2088 | |
| 2089 | static int m88e1121_hwmon_probe(struct phy_device *phydev) |
| 2090 | { |
| 2091 | return marvell_hwmon_probe(phydev, &m88e1121_hwmon_chip_info); |
| 2092 | } |
| 2093 | |
| 2094 | static int m88e1510_hwmon_probe(struct phy_device *phydev) |
| 2095 | { |
| 2096 | return marvell_hwmon_probe(phydev, &m88e1510_hwmon_chip_info); |
| 2097 | } |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 2098 | |
| 2099 | static int m88e6390_hwmon_probe(struct phy_device *phydev) |
| 2100 | { |
| 2101 | return marvell_hwmon_probe(phydev, &m88e6390_hwmon_chip_info); |
| 2102 | } |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 2103 | #else |
| 2104 | static int m88e1121_hwmon_probe(struct phy_device *phydev) |
| 2105 | { |
| 2106 | return 0; |
| 2107 | } |
| 2108 | |
| 2109 | static int m88e1510_hwmon_probe(struct phy_device *phydev) |
| 2110 | { |
| 2111 | return 0; |
| 2112 | } |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 2113 | |
| 2114 | static int m88e6390_hwmon_probe(struct phy_device *phydev) |
| 2115 | { |
| 2116 | return 0; |
| 2117 | } |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 2118 | #endif |
| 2119 | |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2120 | static int marvell_probe(struct phy_device *phydev) |
| 2121 | { |
| 2122 | struct marvell_priv *priv; |
| 2123 | |
Andrew Lunn | e5a03bf | 2016-01-06 20:11:16 +0100 | [diff] [blame] | 2124 | priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2125 | if (!priv) |
| 2126 | return -ENOMEM; |
| 2127 | |
| 2128 | phydev->priv = priv; |
| 2129 | |
| 2130 | return 0; |
| 2131 | } |
| 2132 | |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 2133 | static int m88e1121_probe(struct phy_device *phydev) |
| 2134 | { |
| 2135 | int err; |
| 2136 | |
| 2137 | err = marvell_probe(phydev); |
| 2138 | if (err) |
| 2139 | return err; |
| 2140 | |
| 2141 | return m88e1121_hwmon_probe(phydev); |
| 2142 | } |
| 2143 | |
| 2144 | static int m88e1510_probe(struct phy_device *phydev) |
| 2145 | { |
| 2146 | int err; |
| 2147 | |
| 2148 | err = marvell_probe(phydev); |
| 2149 | if (err) |
| 2150 | return err; |
| 2151 | |
| 2152 | return m88e1510_hwmon_probe(phydev); |
| 2153 | } |
| 2154 | |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 2155 | static int m88e6390_probe(struct phy_device *phydev) |
| 2156 | { |
| 2157 | int err; |
| 2158 | |
| 2159 | err = marvell_probe(phydev); |
| 2160 | if (err) |
| 2161 | return err; |
| 2162 | |
| 2163 | return m88e6390_hwmon_probe(phydev); |
| 2164 | } |
| 2165 | |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2166 | static struct phy_driver marvell_drivers[] = { |
| 2167 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2168 | .phy_id = MARVELL_PHY_ID_88E1101, |
| 2169 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2170 | .name = "Marvell 88E1101", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2171 | /* PHY_GBIT_FEATURES */ |
Arnd Bergmann | 1870241 | 2017-01-23 13:18:41 +0100 | [diff] [blame] | 2172 | .probe = marvell_probe, |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 2173 | .config_init = &marvell_config_init, |
Andrew Lunn | f289978 | 2017-05-23 17:49:13 +0200 | [diff] [blame] | 2174 | .config_aneg = &m88e1101_config_aneg, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2175 | .ack_interrupt = &marvell_ack_interrupt, |
| 2176 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2177 | .resume = &genphy_resume, |
| 2178 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2179 | .read_page = marvell_read_page, |
| 2180 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2181 | .get_sset_count = marvell_get_sset_count, |
| 2182 | .get_strings = marvell_get_strings, |
| 2183 | .get_stats = marvell_get_stats, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2184 | }, |
| 2185 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2186 | .phy_id = MARVELL_PHY_ID_88E1112, |
| 2187 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Olof Johansson | 85cfb53 | 2007-07-03 16:24:32 -0500 | [diff] [blame] | 2188 | .name = "Marvell 88E1112", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2189 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2190 | .probe = marvell_probe, |
Olof Johansson | 85cfb53 | 2007-07-03 16:24:32 -0500 | [diff] [blame] | 2191 | .config_init = &m88e1111_config_init, |
| 2192 | .config_aneg = &marvell_config_aneg, |
Olof Johansson | 85cfb53 | 2007-07-03 16:24:32 -0500 | [diff] [blame] | 2193 | .ack_interrupt = &marvell_ack_interrupt, |
| 2194 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2195 | .resume = &genphy_resume, |
| 2196 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2197 | .read_page = marvell_read_page, |
| 2198 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2199 | .get_sset_count = marvell_get_sset_count, |
| 2200 | .get_strings = marvell_get_strings, |
| 2201 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 262caf4 | 2019-10-28 20:54:17 +0100 | [diff] [blame] | 2202 | .get_tunable = m88e1011_get_tunable, |
| 2203 | .set_tunable = m88e1011_set_tunable, |
| 2204 | .link_change_notify = m88e1011_link_change_notify, |
Olof Johansson | 85cfb53 | 2007-07-03 16:24:32 -0500 | [diff] [blame] | 2205 | }, |
| 2206 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2207 | .phy_id = MARVELL_PHY_ID_88E1111, |
| 2208 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2209 | .name = "Marvell 88E1111", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2210 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2211 | .probe = marvell_probe, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2212 | .config_init = &m88e1111_config_init, |
Florian Fainelli | d6ab933 | 2018-09-25 11:28:46 -0700 | [diff] [blame] | 2213 | .config_aneg = &marvell_config_aneg, |
Alexandr Smirnov | be937f1 | 2008-03-19 00:37:24 +0300 | [diff] [blame] | 2214 | .read_status = &marvell_read_status, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2215 | .ack_interrupt = &marvell_ack_interrupt, |
| 2216 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2217 | .resume = &genphy_resume, |
| 2218 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2219 | .read_page = marvell_read_page, |
| 2220 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2221 | .get_sset_count = marvell_get_sset_count, |
| 2222 | .get_strings = marvell_get_strings, |
| 2223 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 5c6bc51 | 2019-10-28 20:53:25 +0100 | [diff] [blame] | 2224 | .get_tunable = m88e1111_get_tunable, |
| 2225 | .set_tunable = m88e1111_set_tunable, |
| 2226 | .link_change_notify = m88e1011_link_change_notify, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2227 | }, |
| 2228 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2229 | .phy_id = MARVELL_PHY_ID_88E1118, |
| 2230 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 2231 | .name = "Marvell 88E1118", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2232 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2233 | .probe = marvell_probe, |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 2234 | .config_init = &m88e1118_config_init, |
| 2235 | .config_aneg = &m88e1118_config_aneg, |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 2236 | .ack_interrupt = &marvell_ack_interrupt, |
| 2237 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2238 | .resume = &genphy_resume, |
| 2239 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2240 | .read_page = marvell_read_page, |
| 2241 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2242 | .get_sset_count = marvell_get_sset_count, |
| 2243 | .get_strings = marvell_get_strings, |
| 2244 | .get_stats = marvell_get_stats, |
Ron Madrid | 605f196 | 2008-11-06 09:05:26 +0000 | [diff] [blame] | 2245 | }, |
| 2246 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2247 | .phy_id = MARVELL_PHY_ID_88E1121R, |
| 2248 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 2249 | .name = "Marvell 88E1121R", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2250 | /* PHY_GBIT_FEATURES */ |
Arnd Bergmann | 1870241 | 2017-01-23 13:18:41 +0100 | [diff] [blame] | 2251 | .probe = &m88e1121_probe, |
Wang Dongsheng | 0777724 | 2018-07-01 23:15:46 -0700 | [diff] [blame] | 2252 | .config_init = &marvell_config_init, |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 2253 | .config_aneg = &m88e1121_config_aneg, |
| 2254 | .read_status = &marvell_read_status, |
| 2255 | .ack_interrupt = &marvell_ack_interrupt, |
| 2256 | .config_intr = &marvell_config_intr, |
Anatolij Gustschin | dcd07be | 2009-04-07 02:01:43 +0000 | [diff] [blame] | 2257 | .did_interrupt = &m88e1121_did_interrupt, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2258 | .resume = &genphy_resume, |
| 2259 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2260 | .read_page = marvell_read_page, |
| 2261 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2262 | .get_sset_count = marvell_get_sset_count, |
| 2263 | .get_strings = marvell_get_strings, |
| 2264 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 2265 | .get_tunable = m88e1011_get_tunable, |
| 2266 | .set_tunable = m88e1011_set_tunable, |
| 2267 | .link_change_notify = m88e1011_link_change_notify, |
Sergei Poselenov | 140bc92 | 2009-04-07 02:01:41 +0000 | [diff] [blame] | 2268 | }, |
| 2269 | { |
Cyril Chemparathy | 337ac9d | 2010-10-29 13:50:25 -0700 | [diff] [blame] | 2270 | .phy_id = MARVELL_PHY_ID_88E1318S, |
Linus Torvalds | 6ba7401 | 2010-08-04 11:47:58 -0700 | [diff] [blame] | 2271 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Cyril Chemparathy | 337ac9d | 2010-10-29 13:50:25 -0700 | [diff] [blame] | 2272 | .name = "Marvell 88E1318S", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2273 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2274 | .probe = marvell_probe, |
Esben Haabendal | dd9a122 | 2018-04-05 22:40:29 +0200 | [diff] [blame] | 2275 | .config_init = &m88e1318_config_init, |
Cyril Chemparathy | 337ac9d | 2010-10-29 13:50:25 -0700 | [diff] [blame] | 2276 | .config_aneg = &m88e1318_config_aneg, |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 2277 | .read_status = &marvell_read_status, |
| 2278 | .ack_interrupt = &marvell_ack_interrupt, |
| 2279 | .config_intr = &marvell_config_intr, |
| 2280 | .did_interrupt = &m88e1121_did_interrupt, |
Michael Stapelberg | 3871c38 | 2013-03-11 13:56:45 +0000 | [diff] [blame] | 2281 | .get_wol = &m88e1318_get_wol, |
| 2282 | .set_wol = &m88e1318_set_wol, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2283 | .resume = &genphy_resume, |
| 2284 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2285 | .read_page = marvell_read_page, |
| 2286 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2287 | .get_sset_count = marvell_get_sset_count, |
| 2288 | .get_strings = marvell_get_strings, |
| 2289 | .get_stats = marvell_get_stats, |
Cyril Chemparathy | 3ff1c25 | 2010-08-03 19:36:06 -0700 | [diff] [blame] | 2290 | }, |
| 2291 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2292 | .phy_id = MARVELL_PHY_ID_88E1145, |
| 2293 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2294 | .name = "Marvell 88E1145", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2295 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2296 | .probe = marvell_probe, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2297 | .config_init = &m88e1145_config_init, |
Zhao Qiang | c505873 | 2017-12-18 10:26:43 +0800 | [diff] [blame] | 2298 | .config_aneg = &m88e1101_config_aneg, |
Olof Johansson | e547923 | 2007-07-03 16:23:46 -0500 | [diff] [blame] | 2299 | .read_status = &genphy_read_status, |
| 2300 | .ack_interrupt = &marvell_ack_interrupt, |
| 2301 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2302 | .resume = &genphy_resume, |
| 2303 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2304 | .read_page = marvell_read_page, |
| 2305 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2306 | .get_sset_count = marvell_get_sset_count, |
| 2307 | .get_strings = marvell_get_strings, |
| 2308 | .get_stats = marvell_get_stats, |
Heiner Kallweit | a319fb5 | 2019-10-29 20:25:26 +0100 | [diff] [blame] | 2309 | .get_tunable = m88e1111_get_tunable, |
| 2310 | .set_tunable = m88e1111_set_tunable, |
| 2311 | .link_change_notify = m88e1011_link_change_notify, |
Olof Johansson | ac8c635 | 2007-11-04 16:08:51 -0600 | [diff] [blame] | 2312 | }, |
| 2313 | { |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 2314 | .phy_id = MARVELL_PHY_ID_88E1149R, |
| 2315 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2316 | .name = "Marvell 88E1149R", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2317 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2318 | .probe = marvell_probe, |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 2319 | .config_init = &m88e1149_config_init, |
| 2320 | .config_aneg = &m88e1118_config_aneg, |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 2321 | .ack_interrupt = &marvell_ack_interrupt, |
| 2322 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2323 | .resume = &genphy_resume, |
| 2324 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2325 | .read_page = marvell_read_page, |
| 2326 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2327 | .get_sset_count = marvell_get_sset_count, |
| 2328 | .get_strings = marvell_get_strings, |
| 2329 | .get_stats = marvell_get_stats, |
David Daney | 9060073 | 2010-11-19 11:58:53 +0000 | [diff] [blame] | 2330 | }, |
| 2331 | { |
Benjamin Herrenschmidt | 2f495c3 | 2010-06-21 13:20:46 +1000 | [diff] [blame] | 2332 | .phy_id = MARVELL_PHY_ID_88E1240, |
| 2333 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
Olof Johansson | ac8c635 | 2007-11-04 16:08:51 -0600 | [diff] [blame] | 2334 | .name = "Marvell 88E1240", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2335 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2336 | .probe = marvell_probe, |
Olof Johansson | ac8c635 | 2007-11-04 16:08:51 -0600 | [diff] [blame] | 2337 | .config_init = &m88e1111_config_init, |
| 2338 | .config_aneg = &marvell_config_aneg, |
Olof Johansson | ac8c635 | 2007-11-04 16:08:51 -0600 | [diff] [blame] | 2339 | .ack_interrupt = &marvell_ack_interrupt, |
| 2340 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2341 | .resume = &genphy_resume, |
| 2342 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2343 | .read_page = marvell_read_page, |
| 2344 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2345 | .get_sset_count = marvell_get_sset_count, |
| 2346 | .get_strings = marvell_get_strings, |
| 2347 | .get_stats = marvell_get_stats, |
Olof Johansson | ac8c635 | 2007-11-04 16:08:51 -0600 | [diff] [blame] | 2348 | }, |
Michal Simek | 3da09a5 | 2013-05-30 20:08:26 +0000 | [diff] [blame] | 2349 | { |
| 2350 | .phy_id = MARVELL_PHY_ID_88E1116R, |
| 2351 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2352 | .name = "Marvell 88E1116R", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2353 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2354 | .probe = marvell_probe, |
Michal Simek | 3da09a5 | 2013-05-30 20:08:26 +0000 | [diff] [blame] | 2355 | .config_init = &m88e1116r_config_init, |
Michal Simek | 3da09a5 | 2013-05-30 20:08:26 +0000 | [diff] [blame] | 2356 | .ack_interrupt = &marvell_ack_interrupt, |
| 2357 | .config_intr = &marvell_config_intr, |
Sebastian Hesselbarth | 0898b44 | 2013-12-13 10:20:26 +0100 | [diff] [blame] | 2358 | .resume = &genphy_resume, |
| 2359 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2360 | .read_page = marvell_read_page, |
| 2361 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2362 | .get_sset_count = marvell_get_sset_count, |
| 2363 | .get_strings = marvell_get_strings, |
| 2364 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 262caf4 | 2019-10-28 20:54:17 +0100 | [diff] [blame] | 2365 | .get_tunable = m88e1011_get_tunable, |
| 2366 | .set_tunable = m88e1011_set_tunable, |
| 2367 | .link_change_notify = m88e1011_link_change_notify, |
Michal Simek | 3da09a5 | 2013-05-30 20:08:26 +0000 | [diff] [blame] | 2368 | }, |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 2369 | { |
| 2370 | .phy_id = MARVELL_PHY_ID_88E1510, |
| 2371 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2372 | .name = "Marvell 88E1510", |
Andrew Lunn | 719655a | 2018-09-29 23:04:16 +0200 | [diff] [blame] | 2373 | .features = PHY_GBIT_FIBRE_FEATURES, |
Andrew Lunn | 0b04680 | 2017-01-20 01:37:49 +0100 | [diff] [blame] | 2374 | .probe = &m88e1510_probe, |
Stefan Roese | 930b37e | 2016-02-18 10:59:07 +0100 | [diff] [blame] | 2375 | .config_init = &m88e1510_config_init, |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 2376 | .config_aneg = &m88e1510_config_aneg, |
| 2377 | .read_status = &marvell_read_status, |
| 2378 | .ack_interrupt = &marvell_ack_interrupt, |
| 2379 | .config_intr = &marvell_config_intr, |
| 2380 | .did_interrupt = &m88e1121_did_interrupt, |
Jingju Hou | f39aac7 | 2017-01-22 18:20:56 +0800 | [diff] [blame] | 2381 | .get_wol = &m88e1318_get_wol, |
| 2382 | .set_wol = &m88e1318_set_wol, |
Charles-Antoine Couret | 3758be3 | 2016-07-19 11:13:13 +0200 | [diff] [blame] | 2383 | .resume = &marvell_resume, |
| 2384 | .suspend = &marvell_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2385 | .read_page = marvell_read_page, |
| 2386 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2387 | .get_sset_count = marvell_get_sset_count, |
| 2388 | .get_strings = marvell_get_strings, |
| 2389 | .get_stats = marvell_get_stats, |
Lin Yun Sheng | f0f9b4e | 2017-06-30 17:44:15 +0800 | [diff] [blame] | 2390 | .set_loopback = genphy_loopback, |
Heiner Kallweit | 262caf4 | 2019-10-28 20:54:17 +0100 | [diff] [blame] | 2391 | .get_tunable = m88e1011_get_tunable, |
| 2392 | .set_tunable = m88e1011_set_tunable, |
| 2393 | .link_change_notify = m88e1011_link_change_notify, |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 2394 | }, |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 2395 | { |
Andrew Lunn | 819ec8e | 2015-11-16 23:34:41 +0100 | [diff] [blame] | 2396 | .phy_id = MARVELL_PHY_ID_88E1540, |
| 2397 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2398 | .name = "Marvell 88E1540", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2399 | /* PHY_GBIT_FEATURES */ |
Arnd Bergmann | 1870241 | 2017-01-23 13:18:41 +0100 | [diff] [blame] | 2400 | .probe = m88e1510_probe, |
Clemens Gruber | 79be1a1 | 2016-02-15 23:46:45 +0100 | [diff] [blame] | 2401 | .config_init = &marvell_config_init, |
Andrew Lunn | 819ec8e | 2015-11-16 23:34:41 +0100 | [diff] [blame] | 2402 | .config_aneg = &m88e1510_config_aneg, |
| 2403 | .read_status = &marvell_read_status, |
| 2404 | .ack_interrupt = &marvell_ack_interrupt, |
| 2405 | .config_intr = &marvell_config_intr, |
| 2406 | .did_interrupt = &m88e1121_did_interrupt, |
| 2407 | .resume = &genphy_resume, |
| 2408 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2409 | .read_page = marvell_read_page, |
| 2410 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2411 | .get_sset_count = marvell_get_sset_count, |
| 2412 | .get_strings = marvell_get_strings, |
| 2413 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 2414 | .get_tunable = m88e1540_get_tunable, |
| 2415 | .set_tunable = m88e1540_set_tunable, |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 2416 | .link_change_notify = m88e1011_link_change_notify, |
Andrew Lunn | 819ec8e | 2015-11-16 23:34:41 +0100 | [diff] [blame] | 2417 | }, |
| 2418 | { |
Andrew Lunn | 60f06fd | 2017-02-02 00:35:03 +0100 | [diff] [blame] | 2419 | .phy_id = MARVELL_PHY_ID_88E1545, |
| 2420 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2421 | .name = "Marvell 88E1545", |
| 2422 | .probe = m88e1510_probe, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2423 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | 60f06fd | 2017-02-02 00:35:03 +0100 | [diff] [blame] | 2424 | .config_init = &marvell_config_init, |
| 2425 | .config_aneg = &m88e1510_config_aneg, |
| 2426 | .read_status = &marvell_read_status, |
| 2427 | .ack_interrupt = &marvell_ack_interrupt, |
| 2428 | .config_intr = &marvell_config_intr, |
| 2429 | .did_interrupt = &m88e1121_did_interrupt, |
| 2430 | .resume = &genphy_resume, |
| 2431 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2432 | .read_page = marvell_read_page, |
| 2433 | .write_page = marvell_write_page, |
Andrew Lunn | 60f06fd | 2017-02-02 00:35:03 +0100 | [diff] [blame] | 2434 | .get_sset_count = marvell_get_sset_count, |
| 2435 | .get_strings = marvell_get_strings, |
| 2436 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 262caf4 | 2019-10-28 20:54:17 +0100 | [diff] [blame] | 2437 | .get_tunable = m88e1540_get_tunable, |
| 2438 | .set_tunable = m88e1540_set_tunable, |
| 2439 | .link_change_notify = m88e1011_link_change_notify, |
Andrew Lunn | 60f06fd | 2017-02-02 00:35:03 +0100 | [diff] [blame] | 2440 | }, |
| 2441 | { |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 2442 | .phy_id = MARVELL_PHY_ID_88E3016, |
| 2443 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2444 | .name = "Marvell 88E3016", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2445 | /* PHY_BASIC_FEATURES */ |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2446 | .probe = marvell_probe, |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 2447 | .config_init = &m88e3016_config_init, |
| 2448 | .aneg_done = &marvell_aneg_done, |
| 2449 | .read_status = &marvell_read_status, |
| 2450 | .ack_interrupt = &marvell_ack_interrupt, |
| 2451 | .config_intr = &marvell_config_intr, |
| 2452 | .did_interrupt = &m88e1121_did_interrupt, |
| 2453 | .resume = &genphy_resume, |
| 2454 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2455 | .read_page = marvell_read_page, |
| 2456 | .write_page = marvell_write_page, |
Andrew Lunn | d2fa47d | 2015-12-30 16:28:26 +0100 | [diff] [blame] | 2457 | .get_sset_count = marvell_get_sset_count, |
| 2458 | .get_strings = marvell_get_strings, |
| 2459 | .get_stats = marvell_get_stats, |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 2460 | }, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2461 | { |
| 2462 | .phy_id = MARVELL_PHY_ID_88E6390, |
| 2463 | .phy_id_mask = MARVELL_PHY_ID_MASK, |
| 2464 | .name = "Marvell 88E6390", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 2465 | /* PHY_GBIT_FEATURES */ |
Andrew Lunn | fee2d54 | 2018-01-09 22:42:09 +0100 | [diff] [blame] | 2466 | .probe = m88e6390_probe, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2467 | .config_init = &marvell_config_init, |
Andrew Lunn | 8cbcdc1 | 2019-01-10 22:48:36 +0100 | [diff] [blame] | 2468 | .config_aneg = &m88e6390_config_aneg, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2469 | .read_status = &marvell_read_status, |
| 2470 | .ack_interrupt = &marvell_ack_interrupt, |
| 2471 | .config_intr = &marvell_config_intr, |
| 2472 | .did_interrupt = &m88e1121_did_interrupt, |
| 2473 | .resume = &genphy_resume, |
| 2474 | .suspend = &genphy_suspend, |
Russell King | 424ca4c | 2018-01-02 10:58:48 +0000 | [diff] [blame] | 2475 | .read_page = marvell_read_page, |
| 2476 | .write_page = marvell_write_page, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2477 | .get_sset_count = marvell_get_sset_count, |
| 2478 | .get_strings = marvell_get_strings, |
| 2479 | .get_stats = marvell_get_stats, |
Heiner Kallweit | 69f42be | 2019-03-25 19:35:41 +0100 | [diff] [blame] | 2480 | .get_tunable = m88e1540_get_tunable, |
| 2481 | .set_tunable = m88e1540_set_tunable, |
Heiner Kallweit | 911af5e | 2019-10-28 20:52:55 +0100 | [diff] [blame] | 2482 | .link_change_notify = m88e1011_link_change_notify, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2483 | }, |
Andy Fleming | 00db818 | 2005-07-30 19:31:23 -0400 | [diff] [blame] | 2484 | }; |
| 2485 | |
Johan Hovold | 50fd715 | 2014-11-11 19:45:59 +0100 | [diff] [blame] | 2486 | module_phy_driver(marvell_drivers); |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 2487 | |
Uwe Kleine-König | cf93c94 | 2010-10-03 23:43:32 +0000 | [diff] [blame] | 2488 | static struct mdio_device_id __maybe_unused marvell_tbl[] = { |
Michal Simek | f5e1cab | 2013-05-30 20:08:25 +0000 | [diff] [blame] | 2489 | { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK }, |
| 2490 | { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK }, |
| 2491 | { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK }, |
| 2492 | { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK }, |
| 2493 | { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK }, |
| 2494 | { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK }, |
| 2495 | { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK }, |
| 2496 | { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK }, |
| 2497 | { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK }, |
Michal Simek | 3da09a5 | 2013-05-30 20:08:26 +0000 | [diff] [blame] | 2498 | { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK }, |
Michal Simek | 10e24caa | 2013-05-30 20:08:27 +0000 | [diff] [blame] | 2499 | { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK }, |
Andrew Lunn | 819ec8e | 2015-11-16 23:34:41 +0100 | [diff] [blame] | 2500 | { MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK }, |
Andrew Lunn | 60f06fd | 2017-02-02 00:35:03 +0100 | [diff] [blame] | 2501 | { MARVELL_PHY_ID_88E1545, MARVELL_PHY_ID_MASK }, |
Sebastian Hesselbarth | 6b358ae | 2014-10-22 20:26:44 +0200 | [diff] [blame] | 2502 | { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK }, |
Andrew Lunn | e4cf8a3 | 2017-02-01 03:40:06 +0100 | [diff] [blame] | 2503 | { MARVELL_PHY_ID_88E6390, MARVELL_PHY_ID_MASK }, |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 2504 | { } |
| 2505 | }; |
| 2506 | |
| 2507 | MODULE_DEVICE_TABLE(mdio, marvell_tbl); |