#19085: nanostation m5 loco xw "loses" interface
------------------------+------------------------
Reporter: anonymous | Owner: developers
Type: defect | Status: new
Priority: normal | Milestone:
Component: kernel | Version: Trunk
Resolution: | Keywords:
------------------------+------------------------
Comment (by jow):
Copy of the paste contents as it expires on the 20th.
{{{
As our driver is not GPL but we can give an idea how to detect and reset
PHY in GPL ar71xx ethernet driver:
#define GPIO_OE_ADDRESS 0x18040000
#define GPIO_OUT 0x18040008
#define GPIO_SET 0x1804000C
#define GPIO_CLEAR 0x18040010
#define AR8032_EXPECTED_ID1 0x4d
#define ATHR_PHY_ID1 2
static int ar803x_phy_reset(void* arg) {
if ((athr_reg_rd(GPIO_OUT) & (1 << 0)) == 0) {
// Set GPIO0 to 1 (not in reset)
printk("Setting GPIO0 high (AR803x out of reset)\n");
athr_reg_wr(GPIO_SET,(1<<0));
}
if (athr_reg_rd(GPIO_OE_ADDRESS) & (1 << 0)) {
// Set GPIO0 as output
printk("Configuring GPIO0 as Output.\n");
athr_reg_rmw_clear(GPIO_OE_ADDRESS, (1 << 0));
}
athr_reg_wr(GPIO_CLEAR,(1<<0));
mdelay(2);
athr_reg_wr(GPIO_SET,(1<<0));
mdelay(2);
return 0;
}
static int ar803x_check_reset(void* arg)
int retries, ret = 0;
athr_gmac_t *mac = (athr_gmac_t *)arg;
uint16_t phy_id = phy_reg_read(mac->mac_unit, mac->phy->address,
ATHR_PHY_ID1);
if (phy_id == AR8032_EXPECTED_ID1)
{
//No PHY hang detected
return 0;
}
printk("AR803x Hang WAR - PHY Reset...\n");
ar803x_phy_reset(mac);
retries = 102; //To be sure last try > 10ms after reset
while ((phy_reg_read(mac->mac_unit, mac->phy->address,
ATHR_PHY_ID1) = AR8032_EXPECTED_ID1) && --retries) {
udelay(100);
}
if (retries) {
printk("AR803x Hang WAR - Complete.\n");
return 1;
}
return -1;
}
As we are polling phy state (link status) in our driver we periodically
call ar803x_check_reset() to check and reset PHY if there is not right ID
read via MDIO.
BTW: "AR8032 Hang WAR - Fast Reset" tries MAC layer reset. It is not
included in the sample.
-Edmundas
}}}
--
Ticket URL: <https://dev.openwrt.org/ticket/19085#comment:9>
OpenWrt <http://openwrt.org>
Opensource Wireless Router Technology
_______________________________________________
openwrt-tickets mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-tickets