Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Atheros PHY drivers |
| 4 | * |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 5 | * Copyright 2011, 2013 Freescale Semiconductor, Inc. |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 6 | * author Andy Fleming |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 7 | * Copyright (c) 2019 Michael Walle <michael@walle.cc> |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 8 | */ |
Joe Hershberger | 14b4812 | 2018-07-25 12:59:22 -0500 | [diff] [blame] | 9 | #include <common.h> |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 10 | #include <phy.h> |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 11 | #include <dm/device_compat.h> |
| 12 | #include <linux/bitfield.h> |
| 13 | #include <dt-bindings/net/qca-ar803x.h> |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 14 | |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 15 | #define AR803x_PHY_DEBUG_ADDR_REG 0x1d |
| 16 | #define AR803x_PHY_DEBUG_DATA_REG 0x1e |
| 17 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 18 | /* Debug registers */ |
| 19 | #define AR803x_DEBUG_REG_0 0x0 |
| 20 | #define AR803x_RGMII_RX_CLK_DLY BIT(15) |
| 21 | |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 22 | #define AR803x_DEBUG_REG_5 0x5 |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 23 | #define AR803x_RGMII_TX_CLK_DLY BIT(8) |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 24 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 25 | #define AR803x_DEBUG_REG_1F 0x1f |
| 26 | #define AR803x_PLL_ON BIT(2) |
| 27 | #define AR803x_RGMII_1V8 BIT(3) |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 28 | |
Vladimir Oltean | 3e7330e | 2020-05-07 00:11:50 +0200 | [diff] [blame] | 29 | /* CLK_25M register is at MMD 7, address 0x8016 */ |
| 30 | #define AR803x_CLK_25M_SEL_REG 0x8016 |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 31 | |
| 32 | #define AR803x_CLK_25M_MASK GENMASK(4, 2) |
| 33 | #define AR803x_CLK_25M_25MHZ_XTAL 0 |
| 34 | #define AR803x_CLK_25M_25MHZ_DSP 1 |
| 35 | #define AR803x_CLK_25M_50MHZ_PLL 2 |
| 36 | #define AR803x_CLK_25M_50MHZ_DSP 3 |
| 37 | #define AR803x_CLK_25M_62_5MHZ_PLL 4 |
| 38 | #define AR803x_CLK_25M_62_5MHZ_DSP 5 |
| 39 | #define AR803x_CLK_25M_125MHZ_PLL 6 |
| 40 | #define AR803x_CLK_25M_125MHZ_DSP 7 |
| 41 | |
Vladimir Oltean | 3e7330e | 2020-05-07 00:11:50 +0200 | [diff] [blame] | 42 | /* AR8035: Select frequency on CLK_25M pin through bits 4:3 */ |
| 43 | #define AR8035_CLK_25M_FREQ_25M (0 | 0) |
| 44 | #define AR8035_CLK_25M_FREQ_50M (0 | BIT(3)) |
| 45 | #define AR8035_CLK_25M_FREQ_62M (BIT(4) | 0) |
| 46 | #define AR8035_CLK_25M_FREQ_125M (BIT(4) | BIT(3)) |
| 47 | #define AR8035_CLK_25M_MASK GENMASK(4, 3) |
| 48 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 49 | #define AR803x_CLK_25M_DR_MASK GENMASK(8, 7) |
| 50 | #define AR803x_CLK_25M_DR_FULL 0 |
| 51 | #define AR803x_CLK_25M_DR_HALF 1 |
| 52 | #define AR803x_CLK_25M_DR_QUARTER 2 |
| 53 | |
Michael Walle | 69a107e | 2020-05-07 00:11:54 +0200 | [diff] [blame] | 54 | #define AR8021_PHY_ID 0x004dd040 |
| 55 | #define AR8031_PHY_ID 0x004dd074 |
| 56 | #define AR8035_PHY_ID 0x004dd072 |
| 57 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 58 | struct ar803x_priv { |
| 59 | int flags; |
| 60 | #define AR803x_FLAG_KEEP_PLL_ENABLED BIT(0) /* don't turn off internal PLL */ |
| 61 | #define AR803x_FLAG_RGMII_1V8 BIT(1) /* use 1.8V RGMII I/O voltage */ |
| 62 | u16 clk_25m_reg; |
| 63 | u16 clk_25m_mask; |
| 64 | }; |
| 65 | |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 66 | static int ar803x_debug_reg_read(struct phy_device *phydev, u16 reg) |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 67 | { |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 68 | int ret; |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 69 | |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 70 | ret = phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_ADDR_REG, |
| 71 | reg); |
| 72 | if (ret < 0) |
| 73 | return ret; |
| 74 | |
| 75 | return phy_read(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG); |
| 76 | } |
| 77 | |
| 78 | static int ar803x_debug_reg_mask(struct phy_device *phydev, u16 reg, |
| 79 | u16 clear, u16 set) |
| 80 | { |
| 81 | int val; |
| 82 | |
| 83 | val = ar803x_debug_reg_read(phydev, reg); |
| 84 | if (val < 0) |
| 85 | return val; |
| 86 | |
| 87 | val &= 0xffff; |
| 88 | val &= ~clear; |
| 89 | val |= set; |
| 90 | |
| 91 | return phy_write(phydev, MDIO_DEVAD_NONE, AR803x_PHY_DEBUG_DATA_REG, |
| 92 | val); |
| 93 | } |
| 94 | |
| 95 | static int ar803x_enable_rx_delay(struct phy_device *phydev, bool on) |
| 96 | { |
| 97 | u16 clear = 0, set = 0; |
| 98 | |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 99 | if (on) |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 100 | set = AR803x_RGMII_RX_CLK_DLY; |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 101 | else |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 102 | clear = AR803x_RGMII_RX_CLK_DLY; |
| 103 | |
| 104 | return ar803x_debug_reg_mask(phydev, AR803x_DEBUG_REG_0, clear, set); |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 105 | } |
| 106 | |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 107 | static int ar803x_enable_tx_delay(struct phy_device *phydev, bool on) |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 108 | { |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 109 | u16 clear = 0, set = 0; |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 110 | |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 111 | if (on) |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 112 | set = AR803x_RGMII_TX_CLK_DLY; |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 113 | else |
Michael Walle | fb4a465 | 2020-05-07 00:11:55 +0200 | [diff] [blame] | 114 | clear = AR803x_RGMII_TX_CLK_DLY; |
| 115 | |
| 116 | return ar803x_debug_reg_mask(phydev, AR803x_DEBUG_REG_5, clear, set); |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 117 | } |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 118 | |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 119 | static int ar8021_config(struct phy_device *phydev) |
| 120 | { |
Vladimir Oltean | 1e37f75 | 2020-05-07 00:11:52 +0200 | [diff] [blame] | 121 | phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, |
| 122 | BMCR_ANENABLE | BMCR_ANRESTART); |
| 123 | |
| 124 | ar803x_enable_tx_delay(phydev, true); |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 125 | |
Zhao Qiang | 04f2ba4 | 2013-12-23 15:51:33 +0800 | [diff] [blame] | 126 | phydev->supported = phydev->drv->features; |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 127 | return 0; |
| 128 | } |
| 129 | |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 130 | static int ar803x_delay_config(struct phy_device *phydev) |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 131 | { |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 132 | int ret; |
| 133 | |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 134 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID || |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 135 | phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 136 | ret = ar803x_enable_tx_delay(phydev, true); |
Vladimir Oltean | 3ccbb4b | 2020-05-07 00:11:51 +0200 | [diff] [blame] | 137 | else |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 138 | ret = ar803x_enable_tx_delay(phydev, false); |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 139 | |
| 140 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID || |
Vladimir Oltean | 23d8b89 | 2020-05-07 00:11:49 +0200 | [diff] [blame] | 141 | phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 142 | ret = ar803x_enable_rx_delay(phydev, true); |
Vladimir Oltean | 3ccbb4b | 2020-05-07 00:11:51 +0200 | [diff] [blame] | 143 | else |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 144 | ret = ar803x_enable_rx_delay(phydev, false); |
| 145 | |
| 146 | return ret; |
| 147 | } |
| 148 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 149 | static int ar803x_regs_config(struct phy_device *phydev) |
| 150 | { |
| 151 | struct ar803x_priv *priv = phydev->priv; |
| 152 | u16 set = 0, clear = 0; |
| 153 | int val; |
| 154 | int ret; |
| 155 | |
| 156 | /* no configuration available */ |
| 157 | if (!priv) |
| 158 | return 0; |
| 159 | |
| 160 | /* |
| 161 | * Only supported on the AR8031, AR8035 has strappings for the PLL mode |
| 162 | * as well as the RGMII voltage. |
| 163 | */ |
| 164 | if (phydev->drv->uid == AR8031_PHY_ID) { |
| 165 | if (priv->flags & AR803x_FLAG_KEEP_PLL_ENABLED) |
| 166 | set |= AR803x_PLL_ON; |
| 167 | else |
| 168 | clear |= AR803x_PLL_ON; |
| 169 | |
| 170 | if (priv->flags & AR803x_FLAG_RGMII_1V8) |
| 171 | set |= AR803x_RGMII_1V8; |
| 172 | else |
| 173 | clear |= AR803x_RGMII_1V8; |
| 174 | |
| 175 | ret = ar803x_debug_reg_mask(phydev, AR803x_DEBUG_REG_1F, clear, |
| 176 | set); |
| 177 | if (ret < 0) |
| 178 | return ret; |
| 179 | } |
| 180 | |
| 181 | /* save the write access if the mask is empty */ |
| 182 | if (priv->clk_25m_mask) { |
| 183 | val = phy_read_mmd(phydev, MDIO_MMD_AN, AR803x_CLK_25M_SEL_REG); |
| 184 | if (val < 0) |
| 185 | return val; |
| 186 | val &= ~priv->clk_25m_mask; |
| 187 | val |= priv->clk_25m_reg; |
| 188 | ret = phy_write_mmd(phydev, MDIO_MMD_AN, |
| 189 | AR803x_CLK_25M_SEL_REG, val); |
| 190 | if (ret < 0) |
| 191 | return ret; |
| 192 | } |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | static int ar803x_of_init(struct phy_device *phydev) |
| 198 | { |
| 199 | #if defined(CONFIG_DM_ETH) |
| 200 | struct ar803x_priv *priv; |
| 201 | ofnode node, vddio_reg_node; |
| 202 | u32 strength, freq, min_uV, max_uV; |
| 203 | int sel; |
| 204 | |
| 205 | node = phy_get_ofnode(phydev); |
| 206 | if (!ofnode_valid(node)) |
| 207 | return -EINVAL; |
| 208 | |
| 209 | priv = malloc(sizeof(*priv)); |
| 210 | if (!priv) |
| 211 | return -ENOMEM; |
| 212 | memset(priv, 0, sizeof(*priv)); |
| 213 | |
| 214 | phydev->priv = priv; |
| 215 | |
| 216 | debug("%s: found PHY node: %s\n", __func__, ofnode_get_name(node)); |
| 217 | |
| 218 | if (ofnode_read_bool(node, "qca,keep-pll-enabled")) |
| 219 | priv->flags |= AR803x_FLAG_KEEP_PLL_ENABLED; |
| 220 | |
| 221 | /* |
| 222 | * We can't use the regulator framework because the regulator is |
| 223 | * a subnode of the PHY. So just read the two properties we are |
| 224 | * interested in. |
| 225 | */ |
| 226 | vddio_reg_node = ofnode_find_subnode(node, "vddio-regulator"); |
| 227 | if (ofnode_valid(vddio_reg_node)) { |
| 228 | min_uV = ofnode_read_u32_default(vddio_reg_node, |
| 229 | "regulator-min-microvolt", 0); |
| 230 | max_uV = ofnode_read_u32_default(vddio_reg_node, |
| 231 | "regulator-max-microvolt", 0); |
| 232 | |
| 233 | if (min_uV != max_uV) { |
| 234 | free(priv); |
| 235 | return -EINVAL; |
| 236 | } |
| 237 | |
| 238 | switch (min_uV) { |
| 239 | case 1500000: |
| 240 | break; |
| 241 | case 1800000: |
| 242 | priv->flags |= AR803x_FLAG_RGMII_1V8; |
| 243 | break; |
| 244 | default: |
| 245 | free(priv); |
| 246 | return -EINVAL; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | /* |
| 251 | * Get the CLK_25M frequency from the device tree. Only XTAL and PLL |
| 252 | * sources are supported right now. There is also the possibilty to use |
| 253 | * the DSP as frequency reference, this is used for synchronous |
| 254 | * ethernet. |
| 255 | */ |
| 256 | if (!ofnode_read_u32(node, "qca,clk-out-frequency", &freq)) { |
| 257 | switch (freq) { |
| 258 | case 25000000: |
| 259 | sel = AR803x_CLK_25M_25MHZ_XTAL; |
| 260 | break; |
| 261 | case 50000000: |
| 262 | sel = AR803x_CLK_25M_50MHZ_PLL; |
| 263 | break; |
| 264 | case 62500000: |
| 265 | sel = AR803x_CLK_25M_62_5MHZ_PLL; |
| 266 | break; |
| 267 | case 125000000: |
| 268 | sel = AR803x_CLK_25M_125MHZ_PLL; |
| 269 | break; |
| 270 | default: |
| 271 | dev_err(phydev->dev, |
| 272 | "invalid qca,clk-out-frequency\n"); |
| 273 | free(priv); |
| 274 | return -EINVAL; |
| 275 | } |
| 276 | |
| 277 | priv->clk_25m_mask |= AR803x_CLK_25M_MASK; |
| 278 | priv->clk_25m_reg |= FIELD_PREP(AR803x_CLK_25M_MASK, sel); |
| 279 | /* |
| 280 | * Fixup for the AR8035 which only has two bits. The two |
| 281 | * remaining bits map to the same frequencies. |
| 282 | */ |
| 283 | if (phydev->drv->uid == AR8035_PHY_ID) { |
| 284 | u16 clear = AR803x_CLK_25M_MASK & AR8035_CLK_25M_MASK; |
| 285 | |
| 286 | priv->clk_25m_mask &= ~clear; |
| 287 | priv->clk_25m_reg &= ~clear; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | if (phydev->drv->uid == AR8031_PHY_ID && |
| 292 | !ofnode_read_u32(node, "qca,clk-out-strength", &strength)) { |
| 293 | switch (strength) { |
| 294 | case AR803X_STRENGTH_FULL: |
| 295 | sel = AR803x_CLK_25M_DR_FULL; |
| 296 | break; |
| 297 | case AR803X_STRENGTH_HALF: |
| 298 | sel = AR803x_CLK_25M_DR_HALF; |
| 299 | break; |
| 300 | case AR803X_STRENGTH_QUARTER: |
| 301 | sel = AR803x_CLK_25M_DR_QUARTER; |
| 302 | break; |
| 303 | default: |
| 304 | dev_err(phydev->dev, |
| 305 | "invalid qca,clk-out-strength\n"); |
| 306 | free(priv); |
| 307 | return -EINVAL; |
| 308 | } |
| 309 | priv->clk_25m_mask |= AR803x_CLK_25M_DR_MASK; |
| 310 | priv->clk_25m_reg |= FIELD_PREP(AR803x_CLK_25M_DR_MASK, sel); |
| 311 | } |
| 312 | |
| 313 | debug("%s: flags=%x clk_25m_reg=%04x clk_25m_mask=%04x\n", __func__, |
| 314 | priv->flags, priv->clk_25m_reg, priv->clk_25m_mask); |
| 315 | #endif |
| 316 | |
| 317 | return 0; |
| 318 | } |
| 319 | |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 320 | static int ar8031_config(struct phy_device *phydev) |
| 321 | { |
| 322 | int ret; |
| 323 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 324 | ret = ar803x_of_init(phydev); |
| 325 | if (ret < 0) |
| 326 | return ret; |
| 327 | |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 328 | ret = ar803x_delay_config(phydev); |
| 329 | if (ret < 0) |
| 330 | return ret; |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 331 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 332 | ret = ar803x_regs_config(phydev); |
| 333 | if (ret < 0) |
| 334 | return ret; |
| 335 | |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 336 | phydev->supported = phydev->drv->features; |
| 337 | |
| 338 | genphy_config_aneg(phydev); |
| 339 | genphy_restart_aneg(phydev); |
| 340 | |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 344 | static int ar8035_config(struct phy_device *phydev) |
| 345 | { |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 346 | int ret; |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 347 | int regval; |
| 348 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 349 | ret = ar803x_of_init(phydev); |
| 350 | if (ret < 0) |
| 351 | return ret; |
| 352 | |
Vladimir Oltean | 3e7330e | 2020-05-07 00:11:50 +0200 | [diff] [blame] | 353 | /* Configure CLK_25M output clock at 125 MHz */ |
| 354 | regval = phy_read_mmd(phydev, MDIO_MMD_AN, AR803x_CLK_25M_SEL_REG); |
| 355 | regval &= ~AR8035_CLK_25M_MASK; /* No surprises */ |
| 356 | regval |= AR8035_CLK_25M_FREQ_125M; |
| 357 | phy_write_mmd(phydev, MDIO_MMD_AN, AR803x_CLK_25M_SEL_REG, regval); |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 358 | |
Michael Walle | 376019a | 2020-05-07 00:11:56 +0200 | [diff] [blame] | 359 | ret = ar803x_delay_config(phydev); |
| 360 | if (ret < 0) |
| 361 | return ret; |
Andrea Merello | 1e3e19f | 2016-05-26 18:24:28 +0200 | [diff] [blame] | 362 | |
Michael Walle | 5d0ea11 | 2020-05-07 00:11:57 +0200 | [diff] [blame^] | 363 | ret = ar803x_regs_config(phydev); |
| 364 | if (ret < 0) |
| 365 | return ret; |
| 366 | |
Xiaobo Xie | aa09e68 | 2014-04-11 16:03:11 +0800 | [diff] [blame] | 367 | phydev->supported = phydev->drv->features; |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 368 | |
Alison Wang | 5dc3af8 | 2016-02-19 15:52:28 +0800 | [diff] [blame] | 369 | genphy_config_aneg(phydev); |
| 370 | genphy_restart_aneg(phydev); |
| 371 | |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 372 | return 0; |
| 373 | } |
| 374 | |
Kim Phillips | 40c2c03 | 2012-10-29 13:34:33 +0000 | [diff] [blame] | 375 | static struct phy_driver AR8021_driver = { |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 376 | .name = "AR8021", |
Michael Walle | 69a107e | 2020-05-07 00:11:54 +0200 | [diff] [blame] | 377 | .uid = AR8021_PHY_ID, |
Michael Walle | a5eb659 | 2020-05-07 00:11:53 +0200 | [diff] [blame] | 378 | .mask = 0xfffffff0, |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 379 | .features = PHY_GBIT_FEATURES, |
| 380 | .config = ar8021_config, |
| 381 | .startup = genphy_startup, |
| 382 | .shutdown = genphy_shutdown, |
| 383 | }; |
| 384 | |
Heiko Schocher | 93ac9b8 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 385 | static struct phy_driver AR8031_driver = { |
Shengzhou Liu | 76f57c3 | 2013-08-08 16:33:35 +0800 | [diff] [blame] | 386 | .name = "AR8031/AR8033", |
Michael Walle | 69a107e | 2020-05-07 00:11:54 +0200 | [diff] [blame] | 387 | .uid = AR8031_PHY_ID, |
Fabio Estevam | 2edb606 | 2014-01-03 15:55:59 -0200 | [diff] [blame] | 388 | .mask = 0xffffffef, |
Heiko Schocher | 93ac9b8 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 389 | .features = PHY_GBIT_FEATURES, |
Mugunthan V N | 3e4537d | 2016-10-13 19:33:36 +0530 | [diff] [blame] | 390 | .config = ar8031_config, |
Heiko Schocher | 93ac9b8 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 391 | .startup = genphy_startup, |
| 392 | .shutdown = genphy_shutdown, |
| 393 | }; |
| 394 | |
| 395 | static struct phy_driver AR8035_driver = { |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 396 | .name = "AR8035", |
Michael Walle | 69a107e | 2020-05-07 00:11:54 +0200 | [diff] [blame] | 397 | .uid = AR8035_PHY_ID, |
Fabio Estevam | 2edb606 | 2014-01-03 15:55:59 -0200 | [diff] [blame] | 398 | .mask = 0xffffffef, |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 399 | .features = PHY_GBIT_FEATURES, |
| 400 | .config = ar8035_config, |
| 401 | .startup = genphy_startup, |
| 402 | .shutdown = genphy_shutdown, |
| 403 | }; |
| 404 | |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 405 | int phy_atheros_init(void) |
| 406 | { |
| 407 | phy_register(&AR8021_driver); |
Heiko Schocher | 93ac9b8 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 408 | phy_register(&AR8031_driver); |
Xie Xiaobo | dcc307e | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 409 | phy_register(&AR8035_driver); |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 410 | |
| 411 | return 0; |
| 412 | } |