blob: 5942664f1c39f3396459f2c23d90d354f3d18fea [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
18
19/* LXT971 */
20static int lxt971_parse_status(struct phy_device *phydev)
21{
22 int mii_reg;
23 int speed;
24
25 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_LXT971_SR2);
26 speed = mii_reg & MIIM_LXT971_SR2_SPEED_MASK;
27
28 switch (speed) {
29 case MIIM_LXT971_SR2_10HDX:
30 phydev->speed = SPEED_10;
31 phydev->duplex = DUPLEX_HALF;
32 break;
33 case MIIM_LXT971_SR2_10FDX:
34 phydev->speed = SPEED_10;
35 phydev->duplex = DUPLEX_FULL;
36 break;
37 case MIIM_LXT971_SR2_100HDX:
38 phydev->speed = SPEED_100;
39 phydev->duplex = DUPLEX_HALF;
40 break;
41 default:
42 phydev->speed = SPEED_100;
43 phydev->duplex = DUPLEX_FULL;
44 }
45
46 return 0;
47}
48
49static int lxt971_startup(struct phy_device *phydev)
50{
Michal Simek5ff89662016-05-18 12:46:12 +020051 int ret;
52
53 ret = genphy_update_link(phydev);
54 if (ret)
55 return ret;
Andy Fleming60ca78b2011-04-07 21:56:05 -050056
Michal Simek5ff89662016-05-18 12:46:12 +020057 return lxt971_parse_status(phydev);
Andy Fleming60ca78b2011-04-07 21:56:05 -050058}
59
60static struct phy_driver LXT971_driver = {
61 .name = "LXT971",
62 .uid = 0x1378e0,
63 .mask = 0xfffff0,
64 .features = PHY_BASIC_FEATURES,
65 .config = &genphy_config_aneg,
66 .startup = &lxt971_startup,
67 .shutdown = &genphy_shutdown,
68};
69
70int phy_lxt_init(void)
71{
72 phy_register(&LXT971_driver);
73
74 return 0;
75}