Andy Fleming | 9082eea | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 1 | /* |
| 2 | * LXT PHY drivers |
| 3 | * |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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, |
| 17 | * MA 02111-1307 USA |
| 18 | * |
| 19 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
| 20 | * author Andy Fleming |
| 21 | * |
| 22 | */ |
| 23 | #include <phy.h> |
| 24 | |
| 25 | /* LXT971 Status 2 registers */ |
| 26 | #define MIIM_LXT971_SR2 0x11 /* Status Register 2 */ |
| 27 | #define MIIM_LXT971_SR2_SPEED_MASK 0x4200 |
| 28 | #define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */ |
| 29 | #define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */ |
| 30 | #define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */ |
| 31 | #define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */ |
| 32 | |
| 33 | |
| 34 | /* LXT971 */ |
| 35 | static int lxt971_parse_status(struct phy_device *phydev) |
| 36 | { |
| 37 | int mii_reg; |
| 38 | int speed; |
| 39 | |
| 40 | mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_LXT971_SR2); |
| 41 | speed = mii_reg & MIIM_LXT971_SR2_SPEED_MASK; |
| 42 | |
| 43 | switch (speed) { |
| 44 | case MIIM_LXT971_SR2_10HDX: |
| 45 | phydev->speed = SPEED_10; |
| 46 | phydev->duplex = DUPLEX_HALF; |
| 47 | break; |
| 48 | case MIIM_LXT971_SR2_10FDX: |
| 49 | phydev->speed = SPEED_10; |
| 50 | phydev->duplex = DUPLEX_FULL; |
| 51 | break; |
| 52 | case MIIM_LXT971_SR2_100HDX: |
| 53 | phydev->speed = SPEED_100; |
| 54 | phydev->duplex = DUPLEX_HALF; |
| 55 | break; |
| 56 | default: |
| 57 | phydev->speed = SPEED_100; |
| 58 | phydev->duplex = DUPLEX_FULL; |
| 59 | } |
| 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | static int lxt971_startup(struct phy_device *phydev) |
| 65 | { |
| 66 | genphy_update_link(phydev); |
| 67 | lxt971_parse_status(phydev); |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | static struct phy_driver LXT971_driver = { |
| 73 | .name = "LXT971", |
| 74 | .uid = 0x1378e0, |
| 75 | .mask = 0xfffff0, |
| 76 | .features = PHY_BASIC_FEATURES, |
| 77 | .config = &genphy_config_aneg, |
| 78 | .startup = &lxt971_startup, |
| 79 | .shutdown = &genphy_shutdown, |
| 80 | }; |
| 81 | |
| 82 | int phy_lxt_init(void) |
| 83 | { |
| 84 | phy_register(&LXT971_driver); |
| 85 | |
| 86 | return 0; |
| 87 | } |