1
1

ath79: ag71xx: use "builtin-switch" property to set link configuration

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>
This commit is contained in:
Lech Perczak 2022-05-28 22:35:26 +02:00 committed by Hauke Mehrtens
parent e1915674ab
commit c7b04769a7
2 changed files with 11 additions and 2 deletions

View File

@ -160,6 +160,7 @@ struct ag71xx {
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;

View File

@ -868,6 +868,7 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
u32 cfg2;
u32 ifctl;
u32 fifo5;
unsigned int speed;
if (!ag->link && update) {
ag71xx_hw_stop(ag);
@ -883,7 +884,7 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
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);
@ -891,7 +892,11 @@ __ag71xx_link_adjust(struct ag71xx *ag, bool update)
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;
@ -1568,6 +1573,9 @@ static int ag71xx_probe(struct platform_device *pdev)
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)