To support reporting link state of PHYs attached to built-in switch,
add a device tree knob which allows to force 1000Mbps/FD mode,
which is the link mode between eth1 MAC and the on-chip switch, even if
no "fixed-link" node is present. Re-use the "builtin-switch" name
already used in respective MDIO nodes.
This way, a phy-handle property can be added to eth1 node, and devices,
which have a single port attached through the built-in switch,
can report proper link state of that to userspace.
To perform that, one needs to delete the 'fixed-link' node and map the
correct swphy node to 'phy-handle' property. One of those is still
required to be present in the eth1 node.
Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/9971
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
u16 rx_buf_size;
u8 rx_buf_offset;
u8 tx_hang_workaround:1;
+ u8 builtin_switch:1;
struct net_device *dev;
struct platform_device *pdev;
u32 cfg2;
u32 ifctl;
u32 fifo5;
+ unsigned int speed;
if (!ag->link && update) {
ag71xx_hw_stop(ag);
cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2);
cfg2 &= ~(MAC_CFG2_IF_1000 | MAC_CFG2_IF_10_100 | MAC_CFG2_FDX);
- cfg2 |= (ag->duplex) ? MAC_CFG2_FDX : 0;
+ cfg2 |= (ag->duplex || ag->builtin_switch) ? MAC_CFG2_FDX : 0;
ifctl = ag71xx_rr(ag, AG71XX_REG_MAC_IFCTL);
ifctl &= ~(MAC_IFCTL_SPEED);
fifo5 = ag71xx_rr(ag, AG71XX_REG_FIFO_CFG5);
fifo5 &= ~FIFO_CFG5_BM;
- switch (ag->speed) {
+ speed = ag->speed;
+ if (ag->builtin_switch)
+ speed = SPEED_1000;
+
+ switch (speed) {
case SPEED_1000:
cfg2 |= MAC_CFG2_IF_1000;
fifo5 |= FIFO_CFG5_BM;
ag->pllregmap = NULL;
}
+ if (of_property_read_bool(np, "builtin-switch"))
+ ag->builtin_switch = 1;
+
ag->mac_base = devm_ioremap(&pdev->dev, res->start,
res->end - res->start + 1);
if (!ag->mac_base)