ralink: update patches
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.9 / 0999-net.patch
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
4 Subject: [PATCH] net
5
6 ---
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(-)
12
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
17 @@ -32,6 +32,7 @@
18
19 #include "ralink_soc_eth.h"
20 #include "mdio_rt2880.h"
21 +#include "mdio.h"
22
23 #define FE_MDIO_RETRY 1000
24
25 @@ -49,7 +50,7 @@
26 return "?";
27 }
28
29 -void rt2880_mdio_link_adjust(struct fe_priv *priv)
30 +void rt2880_mdio_link_adjust(struct fe_priv *priv, int port)
31 {
32 u32 mdio_cfg;
33
34 @@ -66,10 +67,10 @@
35 if (priv->phy->duplex[0] == DUPLEX_FULL)
36 mdio_cfg |= FE_MDIO_CFG_GP1_DUPLEX;
37
38 - if (priv->phy->tx_fc)
39 + if (priv->phy->tx_fc[0])
40 mdio_cfg |= FE_MDIO_CFG_GP1_FC_TX;
41
42 - if (priv->phy->rx_fc)
43 + if (priv->phy->rx_fc[0])
44 mdio_cfg |= FE_MDIO_CFG_GP1_FC_RX;
45
46 switch (priv->phy->speed[0]) {
47 @@ -161,3 +162,71 @@
48
49 return rt2880_mdio_wait_ready(priv);
50 }
51 +
52 +void rt2880_port_init(struct fe_priv *priv, struct device_node *np)
53 +{
54 + const __be32 *id = of_get_property(np, "reg", NULL);
55 + const __be32 *link;
56 + int size;
57 + int phy_mode;
58 +
59 + if (!id || (be32_to_cpu(*id) != 0)) {
60 + pr_err("%s: invalid port id\n", np->name);
61 + return;
62 + }
63 +
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;
68 + return;
69 + }
70 +
71 + phy_mode = of_get_phy_mode(np);
72 + switch (phy_mode) {
73 + case PHY_INTERFACE_MODE_RGMII:
74 + break;
75 + case PHY_INTERFACE_MODE_MII:
76 + break;
77 + case PHY_INTERFACE_MODE_RMII:
78 + break;
79 + default:
80 + if (!priv->phy->phy_fixed[0])
81 + dev_err(priv->device, "port %d - invalid phy mode\n", priv->phy->speed[0]);
82 + break;
83 + }
84 +
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])
87 + return;
88 +
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++);
95 +
96 + priv->link[0] = 1;
97 + switch (priv->phy->speed[0]) {
98 + case SPEED_10:
99 + break;
100 + case SPEED_100:
101 + break;
102 + case SPEED_1000:
103 + break;
104 + default:
105 + dev_err(priv->device, "invalid link speed: %d\n", priv->phy->speed[0]);
106 + priv->phy->phy_fixed[0] = 0;
107 + return;
108 + }
109 + dev_info(priv->device, "using fixed link parameters\n");
110 + rt2880_mdio_link_adjust(priv, 0);
111 + return;
112 + }
113 + if (priv->phy->phy_node[0] && priv->mii_bus->phy_map[0]) {
114 + fe_connect_phy_node(priv, priv->phy->phy_node[0]);
115 + }
116 +
117 + return;
118 +}
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
123 @@ -18,8 +18,9 @@
124 #ifndef _RALINK_MDIO_RT2880_H__
125 #define _RALINK_MDIO_RT2880_H__
126
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);
132
133 #endif
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
138 @@ -301,6 +301,8 @@
139 const __be32 *phy_fixed[8];
140 int duplex[8];
141 int speed[8];
142 + int tx_fc[8];
143 + int rx_fc[8];
144 spinlock_t lock;
145
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
151 @@ -47,7 +47,8 @@
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,
158 };
159
160 const struct of_device_id of_fe_match[] = {