-
Notifications
You must be signed in to change notification settings - Fork 0
/
chry_phy_rtl8211.h
60 lines (50 loc) · 1.42 KB
/
chry_phy_rtl8211.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) 2024, sakumisu
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "chry_phy.h"
#define RTL8211_PHYSR 17 /* PHY Specific Status Register */
#define RTL8211_PHYSTS_LINK_STATUS (0x400U)
/*
* SPEED (RO)
*
* Link Speed.
* 11: Reserved 10: 1000Mbps
* 01: 100Mbps 00: 10Mbps
*/
#define RTL8211_PHYSTS_SPEED_STATUS (0xC000U)
#define RTL8211_PHYSTS_DUPLEX_STATUS (0x2000U)
void rtl8211_phy_init(struct chry_phy_device *phydev, struct chry_phy_config *config)
{
}
void rtl8211_phy_get_status(struct chry_phy_device *phydev, struct chry_phy_status *status)
{
uint16_t regval;
regval = phydev->mdio_read(phydev, phydev->phy_addr, RTL8211_PHYSR);
status->link = regval & RTL8211_PHYSTS_LINK_STATUS;
if (status->link) {
status->duplex = regval & RTL8211_PHYSTS_DUPLEX_STATUS;
switch ((regval & RTL8211_PHYSTS_SPEED_STATUS) >> 14) {
case 0:
status->speed = 10;
break;
case 1:
status->speed = 100;
break;
case 2:
status->speed = 1000;
break;
default:
break;
}
}
}
const struct chry_phy_driver rtl8211_driver = {
.phy_id = 0x001CC910,
.phy_id_mask = 0xFFFFFFF0,
.phy_name = "RTL8211",
.phy_desc = "REALTEK RTL8211 Ethernet PHY",
.phy_init = rtl8211_phy_init,
.phy_get_status = rtl8211_phy_get_status,
};