Skip to content

Commit 9498da4

Browse files
aakoskingregkh
authored andcommitted
staging: octeon-ethernet: fix incorrect PHY mode
When connecting PHY, we set the mode to PHY_INTERFACE_MODE_GMII which is not always correct. Specifically on boards where RGMII_RXID is needed networking now longer works with at803x after commit 6d4cd04 ("net: phy: at803x: disable delay only for RGMII mode"). Fix by passing the correct mode. Tested on EdgeRouter Lite (RGMII_RXID, at803x PHY) and D-Link DSR-500N (RGMII, broadcom PHY). Fixes: 6d4cd04 ("net: phy: at803x: disable delay only for RGMII mode") Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9b9c87c commit 9498da4

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

drivers/staging/octeon/ethernet-mdio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
163163
goto no_phy;
164164

165165
phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
166-
PHY_INTERFACE_MODE_GMII);
166+
priv->phy_mode);
167167
of_node_put(phy_node);
168168

169169
if (!phydev)

drivers/staging/octeon/ethernet.c

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,37 @@ static struct device_node *cvm_oct_node_for_port(struct device_node *pip,
653653
return np;
654654
}
655655

656-
static void cvm_set_rgmii_delay(struct device_node *np, int iface, int port)
656+
static void cvm_set_rgmii_delay(struct octeon_ethernet *priv, int iface,
657+
int port)
657658
{
659+
struct device_node *np = priv->of_node;
658660
u32 delay_value;
661+
bool rx_delay;
662+
bool tx_delay;
659663

660-
if (!of_property_read_u32(np, "rx-delay", &delay_value))
664+
/* By default, both RX/TX delay is enabled in
665+
* __cvmx_helper_rgmii_enable().
666+
*/
667+
rx_delay = true;
668+
tx_delay = true;
669+
670+
if (!of_property_read_u32(np, "rx-delay", &delay_value)) {
661671
cvmx_write_csr(CVMX_ASXX_RX_CLK_SETX(port, iface), delay_value);
662-
if (!of_property_read_u32(np, "tx-delay", &delay_value))
672+
rx_delay = delay_value > 0;
673+
}
674+
if (!of_property_read_u32(np, "tx-delay", &delay_value)) {
663675
cvmx_write_csr(CVMX_ASXX_TX_CLK_SETX(port, iface), delay_value);
676+
tx_delay = delay_value > 0;
677+
}
678+
679+
if (!rx_delay && !tx_delay)
680+
priv->phy_mode = PHY_INTERFACE_MODE_RGMII_ID;
681+
else if (!rx_delay)
682+
priv->phy_mode = PHY_INTERFACE_MODE_RGMII_RXID;
683+
else if (!tx_delay)
684+
priv->phy_mode = PHY_INTERFACE_MODE_RGMII_TXID;
685+
else
686+
priv->phy_mode = PHY_INTERFACE_MODE_RGMII;
664687
}
665688

666689
static int cvm_oct_probe(struct platform_device *pdev)
@@ -825,6 +848,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
825848
priv->port = port;
826849
priv->queue = cvmx_pko_get_base_queue(priv->port);
827850
priv->fau = fau - cvmx_pko_get_num_queues(port) * 4;
851+
priv->phy_mode = PHY_INTERFACE_MODE_NA;
828852
for (qos = 0; qos < 16; qos++)
829853
skb_queue_head_init(&priv->tx_free_list[qos]);
830854
for (qos = 0; qos < cvmx_pko_get_num_queues(port);
@@ -856,6 +880,7 @@ static int cvm_oct_probe(struct platform_device *pdev)
856880
break;
857881

858882
case CVMX_HELPER_INTERFACE_MODE_SGMII:
883+
priv->phy_mode = PHY_INTERFACE_MODE_SGMII;
859884
dev->netdev_ops = &cvm_oct_sgmii_netdev_ops;
860885
strcpy(dev->name, "eth%d");
861886
break;
@@ -865,11 +890,16 @@ static int cvm_oct_probe(struct platform_device *pdev)
865890
strcpy(dev->name, "spi%d");
866891
break;
867892

868-
case CVMX_HELPER_INTERFACE_MODE_RGMII:
869893
case CVMX_HELPER_INTERFACE_MODE_GMII:
894+
priv->phy_mode = PHY_INTERFACE_MODE_GMII;
895+
dev->netdev_ops = &cvm_oct_rgmii_netdev_ops;
896+
strcpy(dev->name, "eth%d");
897+
break;
898+
899+
case CVMX_HELPER_INTERFACE_MODE_RGMII:
870900
dev->netdev_ops = &cvm_oct_rgmii_netdev_ops;
871901
strcpy(dev->name, "eth%d");
872-
cvm_set_rgmii_delay(priv->of_node, interface,
902+
cvm_set_rgmii_delay(priv, interface,
873903
port_index);
874904
break;
875905
}

drivers/staging/octeon/octeon-ethernet.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define OCTEON_ETHERNET_H
1313

1414
#include <linux/of.h>
15-
15+
#include <linux/phy.h>
1616
#include <asm/octeon/cvmx-helper-board.h>
1717

1818
/**
@@ -33,6 +33,8 @@ struct octeon_ethernet {
3333
* cvmx_helper_interface_mode_t
3434
*/
3535
int imode;
36+
/* PHY mode */
37+
phy_interface_t phy_mode;
3638
/* List of outstanding tx buffers per queue */
3739
struct sk_buff_head tx_free_list[16];
3840
unsigned int last_speed;

0 commit comments

Comments
 (0)