nmhw21: improve support for tja1102 dual phy

- install filter driver for mdio read funtion
- remove ghost phy at address 0
- report phy type also for 2nd port

BugzId: 55131
This commit is contained in:
Rene Straub 2019-01-11 12:12:48 +01:00
parent fe1a692af7
commit d53bbfbc77
1 changed files with 37 additions and 0 deletions

View File

@ -172,6 +172,8 @@ static struct module_pin_mux spi1_pin_mux[] = {
#endif
};
static struct mii_dev olddev; /* Backup of PHY driver structure for read function override */
#endif
@ -1084,6 +1086,38 @@ static void set_mac_address(int index, uchar mac[6])
}
}
static int read_tja1102(struct mii_dev *bus, int phy_id, int dev_addr, int phy_reg)
{
/* Remove TJA1102 mirror(s) at address 0 from bus */
if (phy_id == 0) {
return -1;
}
/*
* Also report ID registers 2&3 for 2nd PHY in TJA1102
* Take values from 1st PHY (ID 2)
*/
if (phy_id == 3 && (phy_reg == 2 || phy_reg == 3)) {
phy_id = 2;
}
return olddev.read(bus, phy_id, dev_addr, phy_reg);
}
static void register_phy_hook(void)
{
struct mii_dev* dev;
dev = miiphy_get_dev_by_name("cpsw");
if (dev != NULL) {
/* Remember original structure (read pointer) */
memcpy(&olddev, dev, sizeof(olddev));
/* Override read method with SJA1002 wrapper */
dev->read = read_tja1102;
}
}
/* TODO: Update doc */
/*
* This function will:
@ -1137,8 +1171,11 @@ int board_eth_init(bd_t *bis)
}
}
#endif
register_phy_hook();
/* Enable BroadR PHYs, set to slave mode */
configure_broadr_phys();
return n;
}
#endif