-
Notifications
You must be signed in to change notification settings - Fork 0
/
chry_phy_lan8720.h
56 lines (47 loc) · 1.34 KB
/
chry_phy_lan8720.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
/*
* Copyright (c) 2024, sakumisu
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "chry_phy.h"
#define LAN8720_PSCSR 31 /* PHY Special Control/Status Register */
#define LAN8720_PSCSR_DUPLEX_STATUS (0x10U)
/*
* SPEED (RO)
*
* HCDSPEED value:
* 01 = 10BASE-T
* 10 = 100BASE-TX
*/
#define LAN8720_PSCSR_SPEED_STATUS (0xCU)
void lan8720_phy_init(struct chry_phy_device *phydev, struct chry_phy_config *config)
{
}
void lan8720_phy_get_status(struct chry_phy_device *phydev, struct chry_phy_status *status)
{
uint16_t regval;
regval = phydev->mdio_read(phydev, phydev->phy_addr, MII_BMSR);
status->link = regval & BMSR_LINKSTATUS;
if (status->link) {
regval = phydev->mdio_read(phydev, phydev->phy_addr, LAN8720_PSCSR);
status->duplex = regval & LAN8720_PSCSR_DUPLEX_STATUS;
switch ((regval & LAN8720_PSCSR_SPEED_STATUS) >> 2) {
case 1:
status->speed = 10;
break;
case 2:
status->speed = 100;
break;
default:
break;
}
}
}
const struct chry_phy_driver lan8720_driver = {
.phy_id = 0x0007C0F0,
.phy_id_mask = 0xFFFFFFF0,
.phy_name = "LAN8720",
.phy_desc = "MICROCHIP LAN8720 Ethernet PHY",
.phy_init = lan8720_phy_init,
.phy_get_status = lan8720_phy_get_status,
};