2 * National Semiconductor PHY drivers
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19 * Copyright 2010-2011 Freescale Semiconductor, Inc.
25 /* DP83865 Link and Auto-Neg Status Register */
26 #define MIIM_DP83865_LANR 0x11
27 #define MIIM_DP83865_SPD_MASK 0x0018
28 #define MIIM_DP83865_SPD_1000 0x0010
29 #define MIIM_DP83865_SPD_100 0x0008
30 #define MIIM_DP83865_DPX_FULL 0x0002
34 static int dp83865_config(struct phy_device *phydev)
36 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
37 genphy_config_aneg(phydev);
42 static int dp83865_parse_status(struct phy_device *phydev)
46 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_DP83865_LANR);
48 switch (mii_reg & MIIM_DP83865_SPD_MASK) {
50 case MIIM_DP83865_SPD_1000:
51 phydev->speed = SPEED_1000;
54 case MIIM_DP83865_SPD_100:
55 phydev->speed = SPEED_100;
59 phydev->speed = SPEED_10;
64 if (mii_reg & MIIM_DP83865_DPX_FULL)
65 phydev->duplex = DUPLEX_FULL;
67 phydev->duplex = DUPLEX_HALF;
72 static int dp83865_startup(struct phy_device *phydev)
74 genphy_update_link(phydev);
75 dp83865_parse_status(phydev);
81 static struct phy_driver DP83865_driver = {
82 .name = "NatSemi DP83865",
85 .features = PHY_GBIT_FEATURES,
86 .config = &dp83865_config,
87 .startup = &dp83865_startup,
88 .shutdown = &genphy_shutdown,
91 int phy_natsemi_init(void)
93 phy_register(&DP83865_driver);