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 | * LXT PHY drivers |
| 4 | * |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 5 | * Copyright 2010-2011 Freescale Semiconductor, Inc. |
| 6 | * author Andy Fleming |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 7 | */ |
Joe Hershberger | 14b4812 | 2018-07-25 12:59:22 -0500 | [diff] [blame] | 8 | #include <common.h> |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 9 | #include <phy.h> |
| 10 | |
| 11 | /* LXT971 Status 2 registers */ |
| 12 | #define MIIM_LXT971_SR2 0x11 /* Status Register 2 */ |
| 13 | #define MIIM_LXT971_SR2_SPEED_MASK 0x4200 |
| 14 | #define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */ |
| 15 | #define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */ |
| 16 | #define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */ |
| 17 | #define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */ |
| 18 | |
| 19 | |
| 20 | /* LXT971 */ |
| 21 | static int lxt971_parse_status(struct phy_device *phydev) |
| 22 | { |
| 23 | int mii_reg; |
| 24 | int speed; |
| 25 | |
| 26 | mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_LXT971_SR2); |
| 27 | speed = mii_reg & MIIM_LXT971_SR2_SPEED_MASK; |
| 28 | |
| 29 | switch (speed) { |
| 30 | case MIIM_LXT971_SR2_10HDX: |
| 31 | phydev->speed = SPEED_10; |
| 32 | phydev->duplex = DUPLEX_HALF; |
| 33 | break; |
| 34 | case MIIM_LXT971_SR2_10FDX: |
| 35 | phydev->speed = SPEED_10; |
| 36 | phydev->duplex = DUPLEX_FULL; |
| 37 | break; |
| 38 | case MIIM_LXT971_SR2_100HDX: |
| 39 | phydev->speed = SPEED_100; |
| 40 | phydev->duplex = DUPLEX_HALF; |
| 41 | break; |
| 42 | default: |
| 43 | phydev->speed = SPEED_100; |
| 44 | phydev->duplex = DUPLEX_FULL; |
| 45 | } |
| 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static int lxt971_startup(struct phy_device *phydev) |
| 51 | { |
Michal Simek | 5ff8966 | 2016-05-18 12:46:12 +0200 | [diff] [blame] | 52 | int ret; |
| 53 | |
| 54 | ret = genphy_update_link(phydev); |
| 55 | if (ret) |
| 56 | return ret; |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 57 | |
Michal Simek | 5ff8966 | 2016-05-18 12:46:12 +0200 | [diff] [blame] | 58 | return lxt971_parse_status(phydev); |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 59 | } |
| 60 | |
Marek Vasut | 09b32fb | 2023-03-19 18:02:53 +0100 | [diff] [blame] | 61 | U_BOOT_PHY_DRIVER(lxt971) = { |
Andy Fleming | 60ca78b | 2011-04-07 21:56:05 -0500 | [diff] [blame] | 62 | .name = "LXT971", |
| 63 | .uid = 0x1378e0, |
| 64 | .mask = 0xfffff0, |
| 65 | .features = PHY_BASIC_FEATURES, |
| 66 | .config = &genphy_config_aneg, |
| 67 | .startup = &lxt971_startup, |
| 68 | .shutdown = &genphy_shutdown, |
| 69 | }; |