blob: 60020508896cc310ed17964b78a3c02ab3868f75 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Andy Fleming60ca78b2011-04-07 21:56:05 -05002/*
3 * LXT PHY drivers
4 *
Andy Fleming60ca78b2011-04-07 21:56:05 -05005 * Copyright 2010-2011 Freescale Semiconductor, Inc.
6 * author Andy Fleming
Andy Fleming60ca78b2011-04-07 21:56:05 -05007 */
8#include <phy.h>
9
10/* LXT971 Status 2 registers */
11#define MIIM_LXT971_SR2 0x11 /* Status Register 2 */
12#define MIIM_LXT971_SR2_SPEED_MASK 0x4200
13#define MIIM_LXT971_SR2_10HDX 0x0000 /* 10 Mbit half duplex selected */
14#define MIIM_LXT971_SR2_10FDX 0x0200 /* 10 Mbit full duplex selected */
15#define MIIM_LXT971_SR2_100HDX 0x4000 /* 100 Mbit half duplex selected */
16#define MIIM_LXT971_SR2_100FDX 0x4200 /* 100 Mbit full duplex selected */
17
Andy Fleming60ca78b2011-04-07 21:56:05 -050018/* LXT971 */
19static int lxt971_parse_status(struct phy_device *phydev)
20{
21 int mii_reg;
22 int speed;
23
24 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_LXT971_SR2);
25 speed = mii_reg & MIIM_LXT971_SR2_SPEED_MASK;
26
27 switch (speed) {
28 case MIIM_LXT971_SR2_10HDX:
29 phydev->speed = SPEED_10;
30 phydev->duplex = DUPLEX_HALF;
31 break;
32 case MIIM_LXT971_SR2_10FDX:
33 phydev->speed = SPEED_10;
34 phydev->duplex = DUPLEX_FULL;
35 break;
36 case MIIM_LXT971_SR2_100HDX:
37 phydev->speed = SPEED_100;
38 phydev->duplex = DUPLEX_HALF;
39 break;
40 default:
41 phydev->speed = SPEED_100;
42 phydev->duplex = DUPLEX_FULL;
43 }
44
45 return 0;
46}
47
48static int lxt971_startup(struct phy_device *phydev)
49{
Michal Simek5ff89662016-05-18 12:46:12 +020050 int ret;
51
52 ret = genphy_update_link(phydev);
53 if (ret)
54 return ret;
Andy Fleming60ca78b2011-04-07 21:56:05 -050055
Michal Simek5ff89662016-05-18 12:46:12 +020056 return lxt971_parse_status(phydev);
Andy Fleming60ca78b2011-04-07 21:56:05 -050057}
58
Marek Vasut09b32fb2023-03-19 18:02:53 +010059U_BOOT_PHY_DRIVER(lxt971) = {
Andy Fleming60ca78b2011-04-07 21:56:05 -050060 .name = "LXT971",
61 .uid = 0x1378e0,
62 .mask = 0xfffff0,
63 .features = PHY_BASIC_FEATURES,
64 .config = &genphy_config_aneg,
65 .startup = &lxt971_startup,
66 .shutdown = &genphy_shutdown,
67};