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 #define MIIM_DM9161_SCR 0x10
26 #define MIIM_DM9161_SCR_INIT 0x0610
28 /* DM9161 Specified Configuration and Status Register */
29 #define MIIM_DM9161_SCSR 0x11
30 #define MIIM_DM9161_SCSR_100F 0x8000
31 #define MIIM_DM9161_SCSR_100H 0x4000
32 #define MIIM_DM9161_SCSR_10F 0x2000
33 #define MIIM_DM9161_SCSR_10H 0x1000
35 /* DM9161 10BT Configuration/Status */
36 #define MIIM_DM9161_10BTCSR 0x12
37 #define MIIM_DM9161_10BTCSR_INIT 0x7800
41 static int dm9161_config(struct phy_device *phydev)
43 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_ISOLATE);
44 /* Do not bypass the scrambler/descrambler */
45 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_DM9161_SCR,
46 MIIM_DM9161_SCR_INIT);
47 /* Clear 10BTCSR to default */
48 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_DM9161_10BTCSR,
49 MIIM_DM9161_10BTCSR_INIT);
51 genphy_config_aneg(phydev);
56 static int dm9161_parse_status(struct phy_device *phydev)
60 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_DM9161_SCSR);
62 if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_100H))
63 phydev->speed = SPEED_100;
65 phydev->speed = SPEED_10;
67 if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_10F))
68 phydev->duplex = DUPLEX_FULL;
70 phydev->duplex = DUPLEX_HALF;
75 static int dm9161_startup(struct phy_device *phydev)
77 genphy_update_link(phydev);
78 dm9161_parse_status(phydev);
83 static struct phy_driver DM9161_driver = {
84 .name = "Davicom DM9161E",
87 .features = PHY_BASIC_FEATURES,
88 .config = &dm9161_config,
89 .startup = &dm9161_startup,
90 .shutdown = &genphy_shutdown,
93 int phy_davicom_init(void)
95 phy_register(&DM9161_driver);