]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
ath79: ag71xx: use "builtin-switch" property to set link configuration
authorLech Perczak <lech.perczak@gmail.com>
Sat, 28 May 2022 20:35:26 +0000 (22:35 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 25 May 2026 18:24:41 +0000 (20:24 +0200)
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>
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx.h
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c

index da716d94c39eca727e1bef9de1d64eb84f35877b..c90dc2d4cdb283ae60569120dec7ca7ee9255c4e 100644 (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;
index 8e387af27b1f85459c3f43978bd2dfa2191acae8..745a8d9ff4ee1bcb24ad1fab3ffe79fcdea3c062 100644 (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)