1 From 194f30e932952d74438fce68006f30f5a180459b Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Sat, 22 Jun 2013 20:36:21 +0200
7 drivers/net/ethernet/ralink/mdio_rt2880.c | 48 ++++++++++++++++++++++++--
8 drivers/net/ethernet/ralink/mdio_rt2880.h | 3 +-
9 drivers/net/ethernet/ralink/ralink_soc_eth.h | 2 ++
10 drivers/net/ethernet/ralink/soc_rt3883.c | 3 +-
11 4 files changed, 51 insertions(+), 5 deletions(-)
13 Index: linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.c
14 ===================================================================
15 --- linux-3.9.6.orig/drivers/net/ethernet/ralink/mdio_rt2880.c 2013-06-22 22:46:13.596610936 +0200
16 +++ linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.c 2013-06-22 23:25:29.536713089 +0200
19 #include "ralink_soc_eth.h"
20 #include "mdio_rt2880.h"
23 #define FE_MDIO_RETRY 1000
29 -void rt2880_mdio_link_adjust(struct fe_priv *priv)
30 +void rt2880_mdio_link_adjust(struct fe_priv *priv, int port)
35 if (priv->phy->duplex[0] == DUPLEX_FULL)
36 mdio_cfg |= FE_MDIO_CFG_GP1_DUPLEX;
38 - if (priv->phy->tx_fc)
39 + if (priv->phy->tx_fc[0])
40 mdio_cfg |= FE_MDIO_CFG_GP1_FC_TX;
42 - if (priv->phy->rx_fc)
43 + if (priv->phy->rx_fc[0])
44 mdio_cfg |= FE_MDIO_CFG_GP1_FC_RX;
46 switch (priv->phy->speed[0]) {
49 return rt2880_mdio_wait_ready(priv);
52 +void rt2880_port_init(struct fe_priv *priv, struct device_node *np)
54 + const __be32 *id = of_get_property(np, "reg", NULL);
59 + if (!id || (be32_to_cpu(*id) != 0)) {
60 + pr_err("%s: invalid port id\n", np->name);
64 + priv->phy->phy_fixed[0] = of_get_property(np, "ralink,fixed-link", &size);
65 + if (priv->phy->phy_fixed[0] && (size != (4 * sizeof(*priv->phy->phy_fixed[0])))) {
66 + pr_err("%s: invalid fixed link property\n", np->name);
67 + priv->phy->phy_fixed[0] = NULL;
71 + phy_mode = of_get_phy_mode(np);
73 + case PHY_INTERFACE_MODE_RGMII:
75 + case PHY_INTERFACE_MODE_MII:
77 + case PHY_INTERFACE_MODE_RMII:
80 + if (!priv->phy->phy_fixed[0])
81 + dev_err(priv->device, "port %d - invalid phy mode\n", priv->phy->speed[0]);
85 + priv->phy->phy_node[0] = of_parse_phandle(np, "phy-handle", 0);
86 + if (!priv->phy->phy_node[0] && !priv->phy->phy_fixed[0])
89 + if (priv->phy->phy_fixed[0]) {
90 + link = priv->phy->phy_fixed[0];
91 + priv->phy->speed[0] = be32_to_cpup(link++);
92 + priv->phy->duplex[0] = be32_to_cpup(link++);
93 + priv->phy->tx_fc[0] = be32_to_cpup(link++);
94 + priv->phy->rx_fc[0] = be32_to_cpup(link++);
97 + switch (priv->phy->speed[0]) {
105 + dev_err(priv->device, "invalid link speed: %d\n", priv->phy->speed[0]);
106 + priv->phy->phy_fixed[0] = 0;
109 + dev_info(priv->device, "using fixed link parameters\n");
110 + rt2880_mdio_link_adjust(priv, 0);
113 + if (priv->phy->phy_node[0] && priv->mii_bus->phy_map[0]) {
114 + fe_connect_phy_node(priv, priv->phy->phy_node[0]);
119 Index: linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.h
120 ===================================================================
121 --- linux-3.9.6.orig/drivers/net/ethernet/ralink/mdio_rt2880.h 2013-06-22 22:46:13.600610937 +0200
122 +++ linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.h 2013-06-22 22:46:13.744610945 +0200
124 #ifndef _RALINK_MDIO_RT2880_H__
125 #define _RALINK_MDIO_RT2880_H__
127 -void rt2880_mdio_link_adjust(struct fe_priv *priv);
128 +void rt2880_mdio_link_adjust(struct fe_priv *priv, int port);
129 int rt2880_mdio_read(struct mii_bus *bus, int phy_addr, int phy_reg);
130 int rt2880_mdio_write(struct mii_bus *bus, int phy_addr, int phy_reg, u16 val);
131 +void rt2880_port_init(struct fe_priv *priv, struct device_node *np);
134 Index: linux-3.9.6/drivers/net/ethernet/ralink/ralink_soc_eth.h
135 ===================================================================
136 --- linux-3.9.6.orig/drivers/net/ethernet/ralink/ralink_soc_eth.h 2013-06-22 22:46:13.600610937 +0200
137 +++ linux-3.9.6/drivers/net/ethernet/ralink/ralink_soc_eth.h 2013-06-22 22:46:13.744610945 +0200
139 const __be32 *phy_fixed[8];
146 int (*connect)(struct fe_priv *priv);
147 Index: linux-3.9.6/drivers/net/ethernet/ralink/soc_rt3883.c
148 ===================================================================
149 --- linux-3.9.6.orig/drivers/net/ethernet/ralink/soc_rt3883.c 2013-06-22 22:46:13.600610937 +0200
150 +++ linux-3.9.6/drivers/net/ethernet/ralink/soc_rt3883.c 2013-06-22 22:46:13.744610945 +0200
152 .checksum_bit = RX_DMA_L4VALID,
153 .mdio_read = rt2880_mdio_read,
154 .mdio_write = rt2880_mdio_write,
155 - .mdio_link_adjust = rt2880_mdio_link_adjust,
156 + .mdio_adjust_link = rt2880_mdio_link_adjust,
157 + .port_init = rt2880_port_init,
160 const struct of_device_id of_fe_match[] = {