Andrew Lunn | a2443fd | 2019-01-21 19:05:50 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 2 | /* |
| 3 | * drivers/net/phy/at803x.c |
| 4 | * |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 5 | * Driver for Qualcomm Atheros AR803x PHY |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 6 | * |
| 7 | * Author: Matus Ujhelyi <ujhelyi.m@gmail.com> |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/phy.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/string.h> |
| 13 | #include <linux/netdevice.h> |
| 14 | #include <linux/etherdevice.h> |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 15 | #include <linux/of_gpio.h> |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 16 | #include <linux/bitfield.h> |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 17 | #include <linux/gpio/consumer.h> |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 18 | #include <linux/regulator/of_regulator.h> |
| 19 | #include <linux/regulator/driver.h> |
| 20 | #include <linux/regulator/consumer.h> |
| 21 | #include <dt-bindings/net/qca-ar803x.h> |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 22 | |
Russell King | 06d5f34 | 2019-10-04 17:06:14 +0100 | [diff] [blame] | 23 | #define AT803X_SPECIFIC_STATUS 0x11 |
| 24 | #define AT803X_SS_SPEED_MASK (3 << 14) |
| 25 | #define AT803X_SS_SPEED_1000 (2 << 14) |
| 26 | #define AT803X_SS_SPEED_100 (1 << 14) |
| 27 | #define AT803X_SS_SPEED_10 (0 << 14) |
| 28 | #define AT803X_SS_DUPLEX BIT(13) |
| 29 | #define AT803X_SS_SPEED_DUPLEX_RESOLVED BIT(11) |
| 30 | #define AT803X_SS_MDIX BIT(6) |
| 31 | |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 32 | #define AT803X_INTR_ENABLE 0x12 |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 33 | #define AT803X_INTR_ENABLE_AUTONEG_ERR BIT(15) |
| 34 | #define AT803X_INTR_ENABLE_SPEED_CHANGED BIT(14) |
| 35 | #define AT803X_INTR_ENABLE_DUPLEX_CHANGED BIT(13) |
| 36 | #define AT803X_INTR_ENABLE_PAGE_RECEIVED BIT(12) |
| 37 | #define AT803X_INTR_ENABLE_LINK_FAIL BIT(11) |
| 38 | #define AT803X_INTR_ENABLE_LINK_SUCCESS BIT(10) |
| 39 | #define AT803X_INTR_ENABLE_WIRESPEED_DOWNGRADE BIT(5) |
| 40 | #define AT803X_INTR_ENABLE_POLARITY_CHANGED BIT(1) |
| 41 | #define AT803X_INTR_ENABLE_WOL BIT(0) |
| 42 | |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 43 | #define AT803X_INTR_STATUS 0x13 |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 44 | |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 45 | #define AT803X_SMART_SPEED 0x14 |
| 46 | #define AT803X_LED_CONTROL 0x18 |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 47 | |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 48 | #define AT803X_DEVICE_ADDR 0x03 |
| 49 | #define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C |
| 50 | #define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B |
| 51 | #define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A |
Zefir Kurtisi | f62265b | 2016-10-24 12:40:54 +0200 | [diff] [blame] | 52 | #define AT803X_REG_CHIP_CONFIG 0x1f |
| 53 | #define AT803X_BT_BX_REG_SEL 0x8000 |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 54 | |
Mugunthan V N | 1ca6d1b | 2013-06-03 20:10:06 +0000 | [diff] [blame] | 55 | #define AT803X_DEBUG_ADDR 0x1D |
| 56 | #define AT803X_DEBUG_DATA 0x1E |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 57 | |
Zefir Kurtisi | f62265b | 2016-10-24 12:40:54 +0200 | [diff] [blame] | 58 | #define AT803X_MODE_CFG_MASK 0x0F |
| 59 | #define AT803X_MODE_CFG_SGMII 0x01 |
| 60 | |
| 61 | #define AT803X_PSSR 0x11 /*PHY-Specific Status Register*/ |
| 62 | #define AT803X_PSSR_MR_AN_COMPLETE 0x0200 |
| 63 | |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 64 | #define AT803X_DEBUG_REG_0 0x00 |
| 65 | #define AT803X_DEBUG_RX_CLK_DLY_EN BIT(15) |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 66 | |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 67 | #define AT803X_DEBUG_REG_5 0x05 |
| 68 | #define AT803X_DEBUG_TX_CLK_DLY_EN BIT(8) |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 69 | |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 70 | #define AT803X_DEBUG_REG_1F 0x1F |
| 71 | #define AT803X_DEBUG_PLL_ON BIT(2) |
| 72 | #define AT803X_DEBUG_RGMII_1V8 BIT(3) |
| 73 | |
| 74 | /* AT803x supports either the XTAL input pad, an internal PLL or the |
| 75 | * DSP as clock reference for the clock output pad. The XTAL reference |
| 76 | * is only used for 25 MHz output, all other frequencies need the PLL. |
| 77 | * The DSP as a clock reference is used in synchronous ethernet |
| 78 | * applications. |
| 79 | * |
| 80 | * By default the PLL is only enabled if there is a link. Otherwise |
| 81 | * the PHY will go into low power state and disabled the PLL. You can |
| 82 | * set the PLL_ON bit (see debug register 0x1f) to keep the PLL always |
| 83 | * enabled. |
| 84 | */ |
| 85 | #define AT803X_MMD7_CLK25M 0x8016 |
| 86 | #define AT803X_CLK_OUT_MASK GENMASK(4, 2) |
| 87 | #define AT803X_CLK_OUT_25MHZ_XTAL 0 |
| 88 | #define AT803X_CLK_OUT_25MHZ_DSP 1 |
| 89 | #define AT803X_CLK_OUT_50MHZ_PLL 2 |
| 90 | #define AT803X_CLK_OUT_50MHZ_DSP 3 |
| 91 | #define AT803X_CLK_OUT_62_5MHZ_PLL 4 |
| 92 | #define AT803X_CLK_OUT_62_5MHZ_DSP 5 |
| 93 | #define AT803X_CLK_OUT_125MHZ_PLL 6 |
| 94 | #define AT803X_CLK_OUT_125MHZ_DSP 7 |
| 95 | |
Michael Walle | 428061f | 2019-11-06 23:36:15 +0100 | [diff] [blame] | 96 | /* The AR8035 has another mask which is compatible with the AR8031/AR8033 mask |
| 97 | * but doesn't support choosing between XTAL/PLL and DSP. |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 98 | */ |
| 99 | #define AT8035_CLK_OUT_MASK GENMASK(4, 3) |
| 100 | |
| 101 | #define AT803X_CLK_OUT_STRENGTH_MASK GENMASK(8, 7) |
| 102 | #define AT803X_CLK_OUT_STRENGTH_FULL 0 |
| 103 | #define AT803X_CLK_OUT_STRENGTH_HALF 1 |
| 104 | #define AT803X_CLK_OUT_STRENGTH_QUARTER 2 |
| 105 | |
Oleksij Rempel | 7908d2c | 2019-10-03 10:21:12 +0200 | [diff] [blame] | 106 | #define ATH9331_PHY_ID 0x004dd041 |
Daniel Mack | bd8ca17 | 2014-06-18 11:01:42 +0200 | [diff] [blame] | 107 | #define ATH8030_PHY_ID 0x004dd076 |
| 108 | #define ATH8031_PHY_ID 0x004dd074 |
| 109 | #define ATH8035_PHY_ID 0x004dd072 |
Fabio Estevam | 58effd7 | 2016-10-26 14:03:54 -0200 | [diff] [blame] | 110 | #define AT803X_PHY_ID_MASK 0xffffffef |
Daniel Mack | bd8ca17 | 2014-06-18 11:01:42 +0200 | [diff] [blame] | 111 | |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 112 | MODULE_DESCRIPTION("Qualcomm Atheros AR803x PHY driver"); |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 113 | MODULE_AUTHOR("Matus Ujhelyi"); |
| 114 | MODULE_LICENSE("GPL"); |
| 115 | |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 116 | struct at803x_priv { |
| 117 | int flags; |
| 118 | #define AT803X_KEEP_PLL_ENABLED BIT(0) /* don't turn off internal PLL */ |
| 119 | u16 clk_25m_reg; |
| 120 | u16 clk_25m_mask; |
| 121 | struct regulator_dev *vddio_rdev; |
| 122 | struct regulator_dev *vddh_rdev; |
| 123 | struct regulator *vddio; |
| 124 | }; |
| 125 | |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 126 | struct at803x_context { |
| 127 | u16 bmcr; |
| 128 | u16 advertise; |
| 129 | u16 control1000; |
| 130 | u16 int_enable; |
| 131 | u16 smart_speed; |
| 132 | u16 led_control; |
| 133 | }; |
| 134 | |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 135 | static int at803x_debug_reg_read(struct phy_device *phydev, u16 reg) |
| 136 | { |
| 137 | int ret; |
| 138 | |
| 139 | ret = phy_write(phydev, AT803X_DEBUG_ADDR, reg); |
| 140 | if (ret < 0) |
| 141 | return ret; |
| 142 | |
| 143 | return phy_read(phydev, AT803X_DEBUG_DATA); |
| 144 | } |
| 145 | |
| 146 | static int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg, |
| 147 | u16 clear, u16 set) |
| 148 | { |
| 149 | u16 val; |
| 150 | int ret; |
| 151 | |
| 152 | ret = at803x_debug_reg_read(phydev, reg); |
| 153 | if (ret < 0) |
| 154 | return ret; |
| 155 | |
| 156 | val = ret & 0xffff; |
| 157 | val &= ~clear; |
| 158 | val |= set; |
| 159 | |
| 160 | return phy_write(phydev, AT803X_DEBUG_DATA, val); |
| 161 | } |
| 162 | |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 163 | static int at803x_enable_rx_delay(struct phy_device *phydev) |
| 164 | { |
| 165 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, 0, |
| 166 | AT803X_DEBUG_RX_CLK_DLY_EN); |
| 167 | } |
| 168 | |
| 169 | static int at803x_enable_tx_delay(struct phy_device *phydev) |
| 170 | { |
| 171 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, 0, |
| 172 | AT803X_DEBUG_TX_CLK_DLY_EN); |
| 173 | } |
| 174 | |
Vinod Koul | 43f2ebd | 2019-02-21 15:53:14 +0530 | [diff] [blame] | 175 | static int at803x_disable_rx_delay(struct phy_device *phydev) |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 176 | { |
Vinod Koul | cd28d1d | 2019-01-21 14:43:17 +0530 | [diff] [blame] | 177 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_0, |
| 178 | AT803X_DEBUG_RX_CLK_DLY_EN, 0); |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 179 | } |
| 180 | |
Vinod Koul | 43f2ebd | 2019-02-21 15:53:14 +0530 | [diff] [blame] | 181 | static int at803x_disable_tx_delay(struct phy_device *phydev) |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 182 | { |
Vinod Koul | cd28d1d | 2019-01-21 14:43:17 +0530 | [diff] [blame] | 183 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_5, |
| 184 | AT803X_DEBUG_TX_CLK_DLY_EN, 0); |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 187 | /* save relevant PHY registers to private copy */ |
| 188 | static void at803x_context_save(struct phy_device *phydev, |
| 189 | struct at803x_context *context) |
| 190 | { |
| 191 | context->bmcr = phy_read(phydev, MII_BMCR); |
| 192 | context->advertise = phy_read(phydev, MII_ADVERTISE); |
| 193 | context->control1000 = phy_read(phydev, MII_CTRL1000); |
| 194 | context->int_enable = phy_read(phydev, AT803X_INTR_ENABLE); |
| 195 | context->smart_speed = phy_read(phydev, AT803X_SMART_SPEED); |
| 196 | context->led_control = phy_read(phydev, AT803X_LED_CONTROL); |
| 197 | } |
| 198 | |
| 199 | /* restore relevant PHY registers from private copy */ |
| 200 | static void at803x_context_restore(struct phy_device *phydev, |
| 201 | const struct at803x_context *context) |
| 202 | { |
| 203 | phy_write(phydev, MII_BMCR, context->bmcr); |
| 204 | phy_write(phydev, MII_ADVERTISE, context->advertise); |
| 205 | phy_write(phydev, MII_CTRL1000, context->control1000); |
| 206 | phy_write(phydev, AT803X_INTR_ENABLE, context->int_enable); |
| 207 | phy_write(phydev, AT803X_SMART_SPEED, context->smart_speed); |
| 208 | phy_write(phydev, AT803X_LED_CONTROL, context->led_control); |
| 209 | } |
| 210 | |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 211 | static int at803x_set_wol(struct phy_device *phydev, |
| 212 | struct ethtool_wolinfo *wol) |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 213 | { |
| 214 | struct net_device *ndev = phydev->attached_dev; |
| 215 | const u8 *mac; |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 216 | int ret; |
| 217 | u32 value; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 218 | unsigned int i, offsets[] = { |
| 219 | AT803X_LOC_MAC_ADDR_32_47_OFFSET, |
| 220 | AT803X_LOC_MAC_ADDR_16_31_OFFSET, |
| 221 | AT803X_LOC_MAC_ADDR_0_15_OFFSET, |
| 222 | }; |
| 223 | |
| 224 | if (!ndev) |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 225 | return -ENODEV; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 226 | |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 227 | if (wol->wolopts & WAKE_MAGIC) { |
| 228 | mac = (const u8 *) ndev->dev_addr; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 229 | |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 230 | if (!is_valid_ether_addr(mac)) |
Dan Murphy | fc75568 | 2017-10-10 12:42:56 -0500 | [diff] [blame] | 231 | return -EINVAL; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 232 | |
Carlo Caione | 0e02139 | 2019-01-25 12:35:10 +0000 | [diff] [blame] | 233 | for (i = 0; i < 3; i++) |
| 234 | phy_write_mmd(phydev, AT803X_DEVICE_ADDR, offsets[i], |
| 235 | mac[(i * 2) + 1] | (mac[(i * 2)] << 8)); |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 236 | |
| 237 | value = phy_read(phydev, AT803X_INTR_ENABLE); |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 238 | value |= AT803X_INTR_ENABLE_WOL; |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 239 | ret = phy_write(phydev, AT803X_INTR_ENABLE, value); |
| 240 | if (ret) |
| 241 | return ret; |
| 242 | value = phy_read(phydev, AT803X_INTR_STATUS); |
| 243 | } else { |
| 244 | value = phy_read(phydev, AT803X_INTR_ENABLE); |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 245 | value &= (~AT803X_INTR_ENABLE_WOL); |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 246 | ret = phy_write(phydev, AT803X_INTR_ENABLE, value); |
| 247 | if (ret) |
| 248 | return ret; |
| 249 | value = phy_read(phydev, AT803X_INTR_STATUS); |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 250 | } |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 251 | |
| 252 | return ret; |
| 253 | } |
| 254 | |
| 255 | static void at803x_get_wol(struct phy_device *phydev, |
| 256 | struct ethtool_wolinfo *wol) |
| 257 | { |
| 258 | u32 value; |
| 259 | |
| 260 | wol->supported = WAKE_MAGIC; |
| 261 | wol->wolopts = 0; |
| 262 | |
| 263 | value = phy_read(phydev, AT803X_INTR_ENABLE); |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 264 | if (value & AT803X_INTR_ENABLE_WOL) |
Mugunthan V N | ea13c9e | 2013-06-03 20:10:05 +0000 | [diff] [blame] | 265 | wol->wolopts |= WAKE_MAGIC; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 266 | } |
| 267 | |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 268 | static int at803x_suspend(struct phy_device *phydev) |
| 269 | { |
| 270 | int value; |
| 271 | int wol_enabled; |
| 272 | |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 273 | value = phy_read(phydev, AT803X_INTR_ENABLE); |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 274 | wol_enabled = value & AT803X_INTR_ENABLE_WOL; |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 275 | |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 276 | if (wol_enabled) |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 277 | value = BMCR_ISOLATE; |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 278 | else |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 279 | value = BMCR_PDOWN; |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 280 | |
Russell King | fea23fb | 2018-01-02 10:58:58 +0000 | [diff] [blame] | 281 | phy_modify(phydev, MII_BMCR, 0, value); |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | static int at803x_resume(struct phy_device *phydev) |
| 287 | { |
Russell King | f102852 | 2018-01-05 16:07:10 +0000 | [diff] [blame] | 288 | return phy_modify(phydev, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 0); |
Daniel Mack | 6229ed1 | 2013-09-21 16:53:02 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 291 | static int at803x_rgmii_reg_set_voltage_sel(struct regulator_dev *rdev, |
| 292 | unsigned int selector) |
| 293 | { |
| 294 | struct phy_device *phydev = rdev_get_drvdata(rdev); |
| 295 | |
| 296 | if (selector) |
| 297 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, |
| 298 | 0, AT803X_DEBUG_RGMII_1V8); |
| 299 | else |
| 300 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, |
| 301 | AT803X_DEBUG_RGMII_1V8, 0); |
| 302 | } |
| 303 | |
| 304 | static int at803x_rgmii_reg_get_voltage_sel(struct regulator_dev *rdev) |
| 305 | { |
| 306 | struct phy_device *phydev = rdev_get_drvdata(rdev); |
| 307 | int val; |
| 308 | |
| 309 | val = at803x_debug_reg_read(phydev, AT803X_DEBUG_REG_1F); |
| 310 | if (val < 0) |
| 311 | return val; |
| 312 | |
| 313 | return (val & AT803X_DEBUG_RGMII_1V8) ? 1 : 0; |
| 314 | } |
| 315 | |
| 316 | static struct regulator_ops vddio_regulator_ops = { |
| 317 | .list_voltage = regulator_list_voltage_table, |
| 318 | .set_voltage_sel = at803x_rgmii_reg_set_voltage_sel, |
| 319 | .get_voltage_sel = at803x_rgmii_reg_get_voltage_sel, |
| 320 | }; |
| 321 | |
| 322 | static const unsigned int vddio_voltage_table[] = { |
| 323 | 1500000, |
| 324 | 1800000, |
| 325 | }; |
| 326 | |
| 327 | static const struct regulator_desc vddio_desc = { |
| 328 | .name = "vddio", |
| 329 | .of_match = of_match_ptr("vddio-regulator"), |
| 330 | .n_voltages = ARRAY_SIZE(vddio_voltage_table), |
| 331 | .volt_table = vddio_voltage_table, |
| 332 | .ops = &vddio_regulator_ops, |
| 333 | .type = REGULATOR_VOLTAGE, |
| 334 | .owner = THIS_MODULE, |
| 335 | }; |
| 336 | |
| 337 | static struct regulator_ops vddh_regulator_ops = { |
| 338 | }; |
| 339 | |
| 340 | static const struct regulator_desc vddh_desc = { |
| 341 | .name = "vddh", |
| 342 | .of_match = of_match_ptr("vddh-regulator"), |
| 343 | .n_voltages = 1, |
| 344 | .fixed_uV = 2500000, |
| 345 | .ops = &vddh_regulator_ops, |
| 346 | .type = REGULATOR_VOLTAGE, |
| 347 | .owner = THIS_MODULE, |
| 348 | }; |
| 349 | |
| 350 | static int at8031_register_regulators(struct phy_device *phydev) |
| 351 | { |
| 352 | struct at803x_priv *priv = phydev->priv; |
| 353 | struct device *dev = &phydev->mdio.dev; |
| 354 | struct regulator_config config = { }; |
| 355 | |
| 356 | config.dev = dev; |
| 357 | config.driver_data = phydev; |
| 358 | |
| 359 | priv->vddio_rdev = devm_regulator_register(dev, &vddio_desc, &config); |
| 360 | if (IS_ERR(priv->vddio_rdev)) { |
| 361 | phydev_err(phydev, "failed to register VDDIO regulator\n"); |
| 362 | return PTR_ERR(priv->vddio_rdev); |
| 363 | } |
| 364 | |
| 365 | priv->vddh_rdev = devm_regulator_register(dev, &vddh_desc, &config); |
| 366 | if (IS_ERR(priv->vddh_rdev)) { |
| 367 | phydev_err(phydev, "failed to register VDDH regulator\n"); |
| 368 | return PTR_ERR(priv->vddh_rdev); |
| 369 | } |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | static bool at803x_match_phy_id(struct phy_device *phydev, u32 phy_id) |
| 375 | { |
| 376 | return (phydev->phy_id & phydev->drv->phy_id_mask) |
| 377 | == (phy_id & phydev->drv->phy_id_mask); |
| 378 | } |
| 379 | |
| 380 | static int at803x_parse_dt(struct phy_device *phydev) |
| 381 | { |
| 382 | struct device_node *node = phydev->mdio.dev.of_node; |
| 383 | struct at803x_priv *priv = phydev->priv; |
| 384 | unsigned int sel, mask; |
| 385 | u32 freq, strength; |
| 386 | int ret; |
| 387 | |
| 388 | if (!IS_ENABLED(CONFIG_OF_MDIO)) |
| 389 | return 0; |
| 390 | |
| 391 | ret = of_property_read_u32(node, "qca,clk-out-frequency", &freq); |
| 392 | if (!ret) { |
| 393 | mask = AT803X_CLK_OUT_MASK; |
| 394 | switch (freq) { |
| 395 | case 25000000: |
| 396 | sel = AT803X_CLK_OUT_25MHZ_XTAL; |
| 397 | break; |
| 398 | case 50000000: |
| 399 | sel = AT803X_CLK_OUT_50MHZ_PLL; |
| 400 | break; |
| 401 | case 62500000: |
| 402 | sel = AT803X_CLK_OUT_62_5MHZ_PLL; |
| 403 | break; |
| 404 | case 125000000: |
| 405 | sel = AT803X_CLK_OUT_125MHZ_PLL; |
| 406 | break; |
| 407 | default: |
| 408 | phydev_err(phydev, "invalid qca,clk-out-frequency\n"); |
| 409 | return -EINVAL; |
| 410 | } |
| 411 | |
| 412 | priv->clk_25m_reg |= FIELD_PREP(mask, sel); |
| 413 | priv->clk_25m_mask |= mask; |
| 414 | |
| 415 | /* Fixup for the AR8030/AR8035. This chip has another mask and |
| 416 | * doesn't support the DSP reference. Eg. the lowest bit of the |
| 417 | * mask. The upper two bits select the same frequencies. Mask |
| 418 | * the lowest bit here. |
| 419 | * |
| 420 | * Warning: |
| 421 | * There was no datasheet for the AR8030 available so this is |
| 422 | * just a guess. But the AR8035 is listed as pin compatible |
| 423 | * to the AR8030 so there might be a good chance it works on |
| 424 | * the AR8030 too. |
| 425 | */ |
| 426 | if (at803x_match_phy_id(phydev, ATH8030_PHY_ID) || |
| 427 | at803x_match_phy_id(phydev, ATH8035_PHY_ID)) { |
| 428 | priv->clk_25m_reg &= ~AT8035_CLK_OUT_MASK; |
| 429 | priv->clk_25m_mask &= ~AT8035_CLK_OUT_MASK; |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | ret = of_property_read_u32(node, "qca,clk-out-strength", &strength); |
| 434 | if (!ret) { |
| 435 | priv->clk_25m_mask |= AT803X_CLK_OUT_STRENGTH_MASK; |
| 436 | switch (strength) { |
| 437 | case AR803X_STRENGTH_FULL: |
| 438 | priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_FULL; |
| 439 | break; |
| 440 | case AR803X_STRENGTH_HALF: |
| 441 | priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_HALF; |
| 442 | break; |
| 443 | case AR803X_STRENGTH_QUARTER: |
| 444 | priv->clk_25m_reg |= AT803X_CLK_OUT_STRENGTH_QUARTER; |
| 445 | break; |
| 446 | default: |
| 447 | phydev_err(phydev, "invalid qca,clk-out-strength\n"); |
| 448 | return -EINVAL; |
| 449 | } |
| 450 | } |
| 451 | |
Michael Walle | 428061f | 2019-11-06 23:36:15 +0100 | [diff] [blame] | 452 | /* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping |
| 453 | * options. |
| 454 | */ |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 455 | if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { |
| 456 | if (of_property_read_bool(node, "qca,keep-pll-enabled")) |
| 457 | priv->flags |= AT803X_KEEP_PLL_ENABLED; |
| 458 | |
| 459 | ret = at8031_register_regulators(phydev); |
| 460 | if (ret < 0) |
| 461 | return ret; |
| 462 | |
| 463 | priv->vddio = devm_regulator_get_optional(&phydev->mdio.dev, |
| 464 | "vddio"); |
| 465 | if (IS_ERR(priv->vddio)) { |
| 466 | phydev_err(phydev, "failed to get VDDIO regulator\n"); |
| 467 | return PTR_ERR(priv->vddio); |
| 468 | } |
| 469 | |
| 470 | ret = regulator_enable(priv->vddio); |
| 471 | if (ret < 0) |
| 472 | return ret; |
| 473 | } |
| 474 | |
| 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | static int at803x_probe(struct phy_device *phydev) |
| 479 | { |
| 480 | struct device *dev = &phydev->mdio.dev; |
| 481 | struct at803x_priv *priv; |
| 482 | |
| 483 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 484 | if (!priv) |
| 485 | return -ENOMEM; |
| 486 | |
| 487 | phydev->priv = priv; |
| 488 | |
| 489 | return at803x_parse_dt(phydev); |
| 490 | } |
| 491 | |
Michael Walle | 2318ca8 | 2020-01-30 18:54:02 +0100 | [diff] [blame] | 492 | static void at803x_remove(struct phy_device *phydev) |
| 493 | { |
| 494 | struct at803x_priv *priv = phydev->priv; |
| 495 | |
| 496 | if (priv->vddio) |
| 497 | regulator_disable(priv->vddio); |
| 498 | } |
| 499 | |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 500 | static int at803x_clk_out_config(struct phy_device *phydev) |
| 501 | { |
| 502 | struct at803x_priv *priv = phydev->priv; |
| 503 | int val; |
| 504 | |
| 505 | if (!priv->clk_25m_mask) |
| 506 | return 0; |
| 507 | |
| 508 | val = phy_read_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M); |
| 509 | if (val < 0) |
| 510 | return val; |
| 511 | |
| 512 | val &= ~priv->clk_25m_mask; |
| 513 | val |= priv->clk_25m_reg; |
| 514 | |
| 515 | return phy_write_mmd(phydev, MDIO_MMD_AN, AT803X_MMD7_CLK25M, val); |
| 516 | } |
| 517 | |
| 518 | static int at8031_pll_config(struct phy_device *phydev) |
| 519 | { |
| 520 | struct at803x_priv *priv = phydev->priv; |
| 521 | |
| 522 | /* The default after hardware reset is PLL OFF. After a soft reset, the |
| 523 | * values are retained. |
| 524 | */ |
| 525 | if (priv->flags & AT803X_KEEP_PLL_ENABLED) |
| 526 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, |
| 527 | 0, AT803X_DEBUG_PLL_ON); |
| 528 | else |
| 529 | return at803x_debug_reg_mask(phydev, AT803X_DEBUG_REG_1F, |
| 530 | AT803X_DEBUG_PLL_ON, 0); |
| 531 | } |
| 532 | |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 533 | static int at803x_config_init(struct phy_device *phydev) |
| 534 | { |
Mugunthan V N | 1ca6d1b | 2013-06-03 20:10:06 +0000 | [diff] [blame] | 535 | int ret; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 536 | |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 537 | /* The RX and TX delay default is: |
| 538 | * after HW reset: RX delay enabled and TX delay disabled |
| 539 | * after SW reset: RX delay enabled, while TX delay retains the |
| 540 | * value before reset. |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 541 | */ |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 542 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
André Draszik | bb0ce4c | 2019-08-09 12:20:25 +0100 | [diff] [blame] | 543 | phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 544 | ret = at803x_enable_rx_delay(phydev); |
André Draszik | bb0ce4c | 2019-08-09 12:20:25 +0100 | [diff] [blame] | 545 | else |
| 546 | ret = at803x_disable_rx_delay(phydev); |
| 547 | if (ret < 0) |
| 548 | return ret; |
Martin Blumenstingl | 2e5f9f2 | 2016-01-15 01:55:22 +0100 | [diff] [blame] | 549 | |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 550 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
André Draszik | bb0ce4c | 2019-08-09 12:20:25 +0100 | [diff] [blame] | 551 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) |
Vinod Koul | 6d4cd04 | 2019-02-21 15:53:15 +0530 | [diff] [blame] | 552 | ret = at803x_enable_tx_delay(phydev); |
André Draszik | bb0ce4c | 2019-08-09 12:20:25 +0100 | [diff] [blame] | 553 | else |
| 554 | ret = at803x_disable_tx_delay(phydev); |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 555 | if (ret < 0) |
| 556 | return ret; |
Mugunthan V N | 1ca6d1b | 2013-06-03 20:10:06 +0000 | [diff] [blame] | 557 | |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 558 | ret = at803x_clk_out_config(phydev); |
| 559 | if (ret < 0) |
| 560 | return ret; |
| 561 | |
| 562 | if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { |
| 563 | ret = at8031_pll_config(phydev); |
| 564 | if (ret < 0) |
| 565 | return ret; |
| 566 | } |
| 567 | |
| 568 | return 0; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Zhao Qiang | 77a9939 | 2014-03-28 15:39:41 +0800 | [diff] [blame] | 571 | static int at803x_ack_interrupt(struct phy_device *phydev) |
| 572 | { |
| 573 | int err; |
| 574 | |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 575 | err = phy_read(phydev, AT803X_INTR_STATUS); |
Zhao Qiang | 77a9939 | 2014-03-28 15:39:41 +0800 | [diff] [blame] | 576 | |
| 577 | return (err < 0) ? err : 0; |
| 578 | } |
| 579 | |
| 580 | static int at803x_config_intr(struct phy_device *phydev) |
| 581 | { |
| 582 | int err; |
| 583 | int value; |
| 584 | |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 585 | value = phy_read(phydev, AT803X_INTR_ENABLE); |
Zhao Qiang | 77a9939 | 2014-03-28 15:39:41 +0800 | [diff] [blame] | 586 | |
Martin Blumenstingl | e6e4a55 | 2016-01-15 01:55:24 +0100 | [diff] [blame] | 587 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { |
| 588 | value |= AT803X_INTR_ENABLE_AUTONEG_ERR; |
| 589 | value |= AT803X_INTR_ENABLE_SPEED_CHANGED; |
| 590 | value |= AT803X_INTR_ENABLE_DUPLEX_CHANGED; |
| 591 | value |= AT803X_INTR_ENABLE_LINK_FAIL; |
| 592 | value |= AT803X_INTR_ENABLE_LINK_SUCCESS; |
| 593 | |
| 594 | err = phy_write(phydev, AT803X_INTR_ENABLE, value); |
| 595 | } |
Zhao Qiang | 77a9939 | 2014-03-28 15:39:41 +0800 | [diff] [blame] | 596 | else |
Martin Blumenstingl | a46bd63 | 2016-01-15 01:55:23 +0100 | [diff] [blame] | 597 | err = phy_write(phydev, AT803X_INTR_ENABLE, 0); |
Zhao Qiang | 77a9939 | 2014-03-28 15:39:41 +0800 | [diff] [blame] | 598 | |
| 599 | return err; |
| 600 | } |
| 601 | |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 602 | static void at803x_link_change_notify(struct phy_device *phydev) |
| 603 | { |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 604 | /* |
| 605 | * Conduct a hardware reset for AT8030 every time a link loss is |
| 606 | * signalled. This is necessary to circumvent a hardware bug that |
| 607 | * occurs when the cable is unplugged while TX packets are pending |
| 608 | * in the FIFO. In such cases, the FIFO enters an error mode it |
| 609 | * cannot recover from by software. |
| 610 | */ |
David Bauer | 6110ed2 | 2019-04-17 23:59:22 +0200 | [diff] [blame] | 611 | if (phydev->state == PHY_NOLINK && phydev->mdio.reset_gpio) { |
Heiner Kallweit | 5c5f626 | 2019-03-19 19:56:51 +0100 | [diff] [blame] | 612 | struct at803x_context context; |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 613 | |
Heiner Kallweit | 5c5f626 | 2019-03-19 19:56:51 +0100 | [diff] [blame] | 614 | at803x_context_save(phydev, &context); |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 615 | |
Heiner Kallweit | 5c5f626 | 2019-03-19 19:56:51 +0100 | [diff] [blame] | 616 | phy_device_reset(phydev, 1); |
| 617 | msleep(1); |
| 618 | phy_device_reset(phydev, 0); |
| 619 | msleep(1); |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 620 | |
Heiner Kallweit | 5c5f626 | 2019-03-19 19:56:51 +0100 | [diff] [blame] | 621 | at803x_context_restore(phydev, &context); |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 622 | |
Heiner Kallweit | 5c5f626 | 2019-03-19 19:56:51 +0100 | [diff] [blame] | 623 | phydev_dbg(phydev, "%s(): phy was reset\n", __func__); |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 624 | } |
| 625 | } |
| 626 | |
Zefir Kurtisi | f62265b | 2016-10-24 12:40:54 +0200 | [diff] [blame] | 627 | static int at803x_aneg_done(struct phy_device *phydev) |
| 628 | { |
| 629 | int ccr; |
| 630 | |
| 631 | int aneg_done = genphy_aneg_done(phydev); |
| 632 | if (aneg_done != BMSR_ANEGCOMPLETE) |
| 633 | return aneg_done; |
| 634 | |
| 635 | /* |
| 636 | * in SGMII mode, if copper side autoneg is successful, |
| 637 | * also check SGMII side autoneg result |
| 638 | */ |
| 639 | ccr = phy_read(phydev, AT803X_REG_CHIP_CONFIG); |
| 640 | if ((ccr & AT803X_MODE_CFG_MASK) != AT803X_MODE_CFG_SGMII) |
| 641 | return aneg_done; |
| 642 | |
| 643 | /* switch to SGMII/fiber page */ |
| 644 | phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr & ~AT803X_BT_BX_REG_SEL); |
| 645 | |
| 646 | /* check if the SGMII link is OK. */ |
| 647 | if (!(phy_read(phydev, AT803X_PSSR) & AT803X_PSSR_MR_AN_COMPLETE)) { |
Andrew Lunn | ab2a605 | 2018-09-29 23:04:10 +0200 | [diff] [blame] | 648 | phydev_warn(phydev, "803x_aneg_done: SGMII link is not ok\n"); |
Zefir Kurtisi | f62265b | 2016-10-24 12:40:54 +0200 | [diff] [blame] | 649 | aneg_done = 0; |
| 650 | } |
| 651 | /* switch back to copper page */ |
| 652 | phy_write(phydev, AT803X_REG_CHIP_CONFIG, ccr | AT803X_BT_BX_REG_SEL); |
| 653 | |
| 654 | return aneg_done; |
| 655 | } |
| 656 | |
Russell King | 06d5f34 | 2019-10-04 17:06:14 +0100 | [diff] [blame] | 657 | static int at803x_read_status(struct phy_device *phydev) |
| 658 | { |
| 659 | int ss, err, old_link = phydev->link; |
| 660 | |
| 661 | /* Update the link, but return if there was an error */ |
| 662 | err = genphy_update_link(phydev); |
| 663 | if (err) |
| 664 | return err; |
| 665 | |
| 666 | /* why bother the PHY if nothing can have changed */ |
| 667 | if (phydev->autoneg == AUTONEG_ENABLE && old_link && phydev->link) |
| 668 | return 0; |
| 669 | |
| 670 | phydev->speed = SPEED_UNKNOWN; |
| 671 | phydev->duplex = DUPLEX_UNKNOWN; |
| 672 | phydev->pause = 0; |
| 673 | phydev->asym_pause = 0; |
| 674 | |
| 675 | err = genphy_read_lpa(phydev); |
| 676 | if (err < 0) |
| 677 | return err; |
| 678 | |
| 679 | /* Read the AT8035 PHY-Specific Status register, which indicates the |
| 680 | * speed and duplex that the PHY is actually using, irrespective of |
| 681 | * whether we are in autoneg mode or not. |
| 682 | */ |
| 683 | ss = phy_read(phydev, AT803X_SPECIFIC_STATUS); |
| 684 | if (ss < 0) |
| 685 | return ss; |
| 686 | |
| 687 | if (ss & AT803X_SS_SPEED_DUPLEX_RESOLVED) { |
| 688 | switch (ss & AT803X_SS_SPEED_MASK) { |
| 689 | case AT803X_SS_SPEED_10: |
| 690 | phydev->speed = SPEED_10; |
| 691 | break; |
| 692 | case AT803X_SS_SPEED_100: |
| 693 | phydev->speed = SPEED_100; |
| 694 | break; |
| 695 | case AT803X_SS_SPEED_1000: |
| 696 | phydev->speed = SPEED_1000; |
| 697 | break; |
| 698 | } |
| 699 | if (ss & AT803X_SS_DUPLEX) |
| 700 | phydev->duplex = DUPLEX_FULL; |
| 701 | else |
| 702 | phydev->duplex = DUPLEX_HALF; |
| 703 | if (ss & AT803X_SS_MDIX) |
| 704 | phydev->mdix = ETH_TP_MDI_X; |
| 705 | else |
| 706 | phydev->mdix = ETH_TP_MDI; |
| 707 | } |
| 708 | |
| 709 | if (phydev->autoneg == AUTONEG_ENABLE && phydev->autoneg_complete) |
| 710 | phy_resolve_aneg_pause(phydev); |
| 711 | |
| 712 | return 0; |
| 713 | } |
| 714 | |
Mugunthan V N | 317420a | 2013-06-03 20:10:04 +0000 | [diff] [blame] | 715 | static struct phy_driver at803x_driver[] = { |
| 716 | { |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 717 | /* Qualcomm Atheros AR8035 */ |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 718 | .phy_id = ATH8035_PHY_ID, |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 719 | .name = "Qualcomm Atheros AR8035", |
Fabio Estevam | 58effd7 | 2016-10-26 14:03:54 -0200 | [diff] [blame] | 720 | .phy_id_mask = AT803X_PHY_ID_MASK, |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 721 | .probe = at803x_probe, |
Michael Walle | 2318ca8 | 2020-01-30 18:54:02 +0100 | [diff] [blame] | 722 | .remove = at803x_remove, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 723 | .config_init = at803x_config_init, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 724 | .set_wol = at803x_set_wol, |
| 725 | .get_wol = at803x_get_wol, |
| 726 | .suspend = at803x_suspend, |
| 727 | .resume = at803x_resume, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 728 | /* PHY_GBIT_FEATURES */ |
Russell King | 06d5f34 | 2019-10-04 17:06:14 +0100 | [diff] [blame] | 729 | .read_status = at803x_read_status, |
Måns Rullgård | 0eae598 | 2015-11-12 17:40:20 +0000 | [diff] [blame] | 730 | .ack_interrupt = at803x_ack_interrupt, |
| 731 | .config_intr = at803x_config_intr, |
Mugunthan V N | 317420a | 2013-06-03 20:10:04 +0000 | [diff] [blame] | 732 | }, { |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 733 | /* Qualcomm Atheros AR8030 */ |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 734 | .phy_id = ATH8030_PHY_ID, |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 735 | .name = "Qualcomm Atheros AR8030", |
Fabio Estevam | 58effd7 | 2016-10-26 14:03:54 -0200 | [diff] [blame] | 736 | .phy_id_mask = AT803X_PHY_ID_MASK, |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 737 | .probe = at803x_probe, |
Michael Walle | 2318ca8 | 2020-01-30 18:54:02 +0100 | [diff] [blame] | 738 | .remove = at803x_remove, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 739 | .config_init = at803x_config_init, |
| 740 | .link_change_notify = at803x_link_change_notify, |
| 741 | .set_wol = at803x_set_wol, |
| 742 | .get_wol = at803x_get_wol, |
| 743 | .suspend = at803x_suspend, |
| 744 | .resume = at803x_resume, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 745 | /* PHY_BASIC_FEATURES */ |
Måns Rullgård | 0eae598 | 2015-11-12 17:40:20 +0000 | [diff] [blame] | 746 | .ack_interrupt = at803x_ack_interrupt, |
| 747 | .config_intr = at803x_config_intr, |
Mugunthan V N | 05d7cce | 2013-06-03 20:10:07 +0000 | [diff] [blame] | 748 | }, { |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 749 | /* Qualcomm Atheros AR8031/AR8033 */ |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 750 | .phy_id = ATH8031_PHY_ID, |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 751 | .name = "Qualcomm Atheros AR8031/AR8033", |
Fabio Estevam | 58effd7 | 2016-10-26 14:03:54 -0200 | [diff] [blame] | 752 | .phy_id_mask = AT803X_PHY_ID_MASK, |
Michael Walle | 2f66482 | 2019-11-06 23:36:14 +0100 | [diff] [blame] | 753 | .probe = at803x_probe, |
Michael Walle | 2318ca8 | 2020-01-30 18:54:02 +0100 | [diff] [blame] | 754 | .remove = at803x_remove, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 755 | .config_init = at803x_config_init, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 756 | .set_wol = at803x_set_wol, |
| 757 | .get_wol = at803x_get_wol, |
| 758 | .suspend = at803x_suspend, |
| 759 | .resume = at803x_resume, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 760 | /* PHY_GBIT_FEATURES */ |
Russell King | 06d5f34 | 2019-10-04 17:06:14 +0100 | [diff] [blame] | 761 | .read_status = at803x_read_status, |
Zefir Kurtisi | f62265b | 2016-10-24 12:40:54 +0200 | [diff] [blame] | 762 | .aneg_done = at803x_aneg_done, |
Daniel Mack | 13a56b4 | 2014-06-18 11:01:43 +0200 | [diff] [blame] | 763 | .ack_interrupt = &at803x_ack_interrupt, |
| 764 | .config_intr = &at803x_config_intr, |
Oleksij Rempel | 7908d2c | 2019-10-03 10:21:12 +0200 | [diff] [blame] | 765 | }, { |
| 766 | /* ATHEROS AR9331 */ |
| 767 | PHY_ID_MATCH_EXACT(ATH9331_PHY_ID), |
Michael Walle | 96c3671 | 2019-11-06 23:36:16 +0100 | [diff] [blame] | 768 | .name = "Qualcomm Atheros AR9331 built-in PHY", |
Oleksij Rempel | 7908d2c | 2019-10-03 10:21:12 +0200 | [diff] [blame] | 769 | .suspend = at803x_suspend, |
| 770 | .resume = at803x_resume, |
| 771 | /* PHY_BASIC_FEATURES */ |
| 772 | .ack_interrupt = &at803x_ack_interrupt, |
| 773 | .config_intr = &at803x_config_intr, |
Mugunthan V N | 317420a | 2013-06-03 20:10:04 +0000 | [diff] [blame] | 774 | } }; |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 775 | |
Johan Hovold | 50fd715 | 2014-11-11 19:45:59 +0100 | [diff] [blame] | 776 | module_phy_driver(at803x_driver); |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 777 | |
| 778 | static struct mdio_device_id __maybe_unused atheros_tbl[] = { |
Fabio Estevam | 58effd7 | 2016-10-26 14:03:54 -0200 | [diff] [blame] | 779 | { ATH8030_PHY_ID, AT803X_PHY_ID_MASK }, |
| 780 | { ATH8031_PHY_ID, AT803X_PHY_ID_MASK }, |
| 781 | { ATH8035_PHY_ID, AT803X_PHY_ID_MASK }, |
Oleksij Rempel | 7908d2c | 2019-10-03 10:21:12 +0200 | [diff] [blame] | 782 | { PHY_ID_MATCH_EXACT(ATH9331_PHY_ID) }, |
Matus Ujhelyi | 0ca7111 | 2012-10-14 19:07:16 +0000 | [diff] [blame] | 783 | { } |
| 784 | }; |
| 785 | |
| 786 | MODULE_DEVICE_TABLE(mdio, atheros_tbl); |