Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Atheros PHY drivers |
| 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 5 | * |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 6 | * Copyright 2011, 2013 Freescale Semiconductor, Inc. |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 7 | * author Andy Fleming |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 8 | */ |
| 9 | #include <phy.h> |
| 10 | |
| 11 | static int ar8021_config(struct phy_device *phydev) |
| 12 | { |
| 13 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 14 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x3D47); |
| 15 | |
Zhao Qiang | e0d8096 | 2013-12-23 15:51:33 +0800 | [diff] [blame] | 16 | phydev->supported = phydev->drv->features; |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 17 | return 0; |
| 18 | } |
| 19 | |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 20 | static int ar8035_config(struct phy_device *phydev) |
| 21 | { |
| 22 | int regval; |
| 23 | |
| 24 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x0007); |
| 25 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016); |
| 26 | phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007); |
| 27 | regval = phy_read(phydev, MDIO_DEVAD_NONE, 0xe); |
| 28 | phy_write(phydev, MDIO_DEVAD_NONE, 0xe, (regval|0x0018)); |
| 29 | |
| 30 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05); |
| 31 | regval = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e); |
| 32 | phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, (regval|0x0100)); |
| 33 | |
Xiaobo Xie | 02aa4c5 | 2014-04-11 16:03:11 +0800 | [diff] [blame] | 34 | phydev->supported = phydev->drv->features; |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 35 | |
Alison Wang | 903d384 | 2016-02-19 15:52:28 +0800 | [diff] [blame] | 36 | genphy_config_aneg(phydev); |
| 37 | genphy_restart_aneg(phydev); |
| 38 | |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 39 | return 0; |
| 40 | } |
| 41 | |
Kim Phillips | 0637059 | 2012-10-29 13:34:33 +0000 | [diff] [blame] | 42 | static struct phy_driver AR8021_driver = { |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 43 | .name = "AR8021", |
| 44 | .uid = 0x4dd040, |
Haijun.Zhang | dc116bd | 2014-03-04 15:56:12 +0800 | [diff] [blame] | 45 | .mask = 0x4ffff0, |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 46 | .features = PHY_GBIT_FEATURES, |
| 47 | .config = ar8021_config, |
| 48 | .startup = genphy_startup, |
| 49 | .shutdown = genphy_shutdown, |
| 50 | }; |
| 51 | |
Heiko Schocher | 433a2c5 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 52 | static struct phy_driver AR8031_driver = { |
Shengzhou Liu | 626ee1e | 2013-08-08 16:33:35 +0800 | [diff] [blame] | 53 | .name = "AR8031/AR8033", |
Heiko Schocher | 433a2c5 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 54 | .uid = 0x4dd074, |
Fabio Estevam | f66e3de | 2014-01-03 15:55:59 -0200 | [diff] [blame] | 55 | .mask = 0xffffffef, |
Heiko Schocher | 433a2c5 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 56 | .features = PHY_GBIT_FEATURES, |
Fabio Estevam | d584c68 | 2016-01-05 17:02:52 -0200 | [diff] [blame] | 57 | .config = ar8035_config, |
Heiko Schocher | 433a2c5 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 58 | .startup = genphy_startup, |
| 59 | .shutdown = genphy_shutdown, |
| 60 | }; |
| 61 | |
| 62 | static struct phy_driver AR8035_driver = { |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 63 | .name = "AR8035", |
| 64 | .uid = 0x4dd072, |
Fabio Estevam | f66e3de | 2014-01-03 15:55:59 -0200 | [diff] [blame] | 65 | .mask = 0xffffffef, |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 66 | .features = PHY_GBIT_FEATURES, |
| 67 | .config = ar8035_config, |
| 68 | .startup = genphy_startup, |
| 69 | .shutdown = genphy_shutdown, |
| 70 | }; |
| 71 | |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 72 | int phy_atheros_init(void) |
| 73 | { |
| 74 | phy_register(&AR8021_driver); |
Heiko Schocher | 433a2c5 | 2013-06-04 10:58:00 +0200 | [diff] [blame] | 75 | phy_register(&AR8031_driver); |
Xie Xiaobo | 6027384 | 2013-04-10 16:23:39 +0800 | [diff] [blame] | 76 | phy_register(&AR8035_driver); |
Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 77 | |
| 78 | return 0; |
| 79 | } |