bigmac: fix/improve PHY interface.

This commit is contained in:
Maxim Poliakovski 2023-09-20 00:44:08 +02:00
parent 0ebcd15a3d
commit 6eb6a5892d
2 changed files with 12 additions and 0 deletions

View File

@ -124,6 +124,9 @@ void BigMac::mii_rcv_bit() {
this->mii_reset();
}
break;
case MII_FRAME_SM::Stop:
this->mii_reset();
break;
default:
LOG_F(ERROR, "%s: unhandled state %d in mii_rcv_bit", this->name.c_str(),
this->mii_state);
@ -245,6 +248,10 @@ void BigMac::phy_reset() {
uint16_t BigMac::phy_reg_read(uint8_t reg_num) {
switch(reg_num) {
case PHY_BMCR:
return this->phy_bmcr;
case PHY_BMSR:
return 0x7809; // value from LXT970 datasheet
case PHY_ID1:
return (this->phy_oui >> 6) & 0xFFFFU;
case PHY_ID2:
@ -261,6 +268,10 @@ uint16_t BigMac::phy_reg_read(uint8_t reg_num) {
void BigMac::phy_reg_write(uint8_t reg_num, uint16_t value) {
switch(reg_num) {
case PHY_BMCR:
if (value & 0x8000) {
LOG_F(INFO, "PHY reset requested");
value &= ~0x8000; // Reset bit is self-clearing
}
this->phy_bmcr = value;
break;
case PHY_ANAR:

View File

@ -84,6 +84,7 @@ enum MII_FRAME_SM {
/* PHY control/status registers. */
enum {
PHY_BMCR = 0,
PHY_BMSR = 1,
PHY_ID1 = 2,
PHY_ID2 = 3,
PHY_ANAR = 4,