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