summaryrefslogtreecommitdiff
path: root/target/linux/ramips/patches-3.9/0999-net.patch
blob: 954c747022e63b5fc76519e4ca9e6af4f1930f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
From 194f30e932952d74438fce68006f30f5a180459b Mon Sep 17 00:00:00 2001
From: John Crispin <blogic@openwrt.org>
Date: Sat, 22 Jun 2013 20:36:21 +0200
Subject: [PATCH] net

---
 drivers/net/ethernet/ralink/mdio_rt2880.c    |   48 ++++++++++++++++++++++++--
 drivers/net/ethernet/ralink/mdio_rt2880.h    |    3 +-
 drivers/net/ethernet/ralink/ralink_soc_eth.h |    2 ++
 drivers/net/ethernet/ralink/soc_rt3883.c     |    3 +-
 4 files changed, 51 insertions(+), 5 deletions(-)

Index: linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.c
===================================================================
--- linux-3.9.6.orig/drivers/net/ethernet/ralink/mdio_rt2880.c	2013-06-22 22:46:13.596610936 +0200
+++ linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.c	2013-06-22 23:25:29.536713089 +0200
@@ -32,6 +32,7 @@
 
 #include "ralink_soc_eth.h"
 #include "mdio_rt2880.h"
+#include "mdio.h"
 
 #define FE_MDIO_RETRY	1000
 
@@ -49,7 +50,7 @@
 	return "?";
 }
 
-void rt2880_mdio_link_adjust(struct fe_priv *priv)
+void rt2880_mdio_link_adjust(struct fe_priv *priv, int port)
 {
 	u32 mdio_cfg;
 
@@ -66,10 +67,10 @@
 	if (priv->phy->duplex[0] == DUPLEX_FULL)
 		mdio_cfg |= FE_MDIO_CFG_GP1_DUPLEX;
 
-	if (priv->phy->tx_fc)
+	if (priv->phy->tx_fc[0])
 		mdio_cfg |= FE_MDIO_CFG_GP1_FC_TX;
 
-	if (priv->phy->rx_fc)
+	if (priv->phy->rx_fc[0])
 		mdio_cfg |= FE_MDIO_CFG_GP1_FC_RX;
 
 	switch (priv->phy->speed[0]) {
@@ -161,3 +162,71 @@
 
 	return rt2880_mdio_wait_ready(priv);
 }
+
+void rt2880_port_init(struct fe_priv *priv, struct device_node *np)
+{
+	const __be32 *id = of_get_property(np, "reg", NULL);
+	const __be32 *link;
+	int size;
+	int phy_mode;
+
+	if (!id || (be32_to_cpu(*id) != 0)) {
+		pr_err("%s: invalid port id\n", np->name);
+		return;
+	}
+
+	priv->phy->phy_fixed[0] = of_get_property(np, "ralink,fixed-link", &size);
+	if (priv->phy->phy_fixed[0] && (size != (4 * sizeof(*priv->phy->phy_fixed[0])))) {
+		pr_err("%s: invalid fixed link property\n", np->name);
+		priv->phy->phy_fixed[0] = NULL;
+		return;
+	}
+
+	phy_mode = of_get_phy_mode(np);
+	switch (phy_mode) {
+	case PHY_INTERFACE_MODE_RGMII:
+		break;
+	case PHY_INTERFACE_MODE_MII:
+		break;
+	case PHY_INTERFACE_MODE_RMII:
+		break;
+	default:
+		if (!priv->phy->phy_fixed[0])
+			dev_err(priv->device, "port %d - invalid phy mode\n", priv->phy->speed[0]);
+		break;
+	}
+
+	priv->phy->phy_node[0] = of_parse_phandle(np, "phy-handle", 0);
+	if (!priv->phy->phy_node[0] && !priv->phy->phy_fixed[0])
+		return;
+
+	if (priv->phy->phy_fixed[0]) {
+		link = priv->phy->phy_fixed[0];
+		priv->phy->speed[0] = be32_to_cpup(link++);
+		priv->phy->duplex[0] = be32_to_cpup(link++);
+		priv->phy->tx_fc[0] = be32_to_cpup(link++);
+		priv->phy->rx_fc[0] = be32_to_cpup(link++);
+
+		priv->link[0] = 1;
+		switch (priv->phy->speed[0]) {
+		case SPEED_10:
+			break;
+		case SPEED_100:
+			break;
+		case SPEED_1000:
+			break;
+		default:
+			dev_err(priv->device, "invalid link speed: %d\n", priv->phy->speed[0]);
+			priv->phy->phy_fixed[0] = 0;
+			return;
+		}
+		dev_info(priv->device, "using fixed link parameters\n");
+		rt2880_mdio_link_adjust(priv, 0);
+		return;
+	}
+	if (priv->phy->phy_node[0] && priv->mii_bus->phy_map[0]) {
+		fe_connect_phy_node(priv, priv->phy->phy_node[0]);
+	}
+
+	return;
+}
Index: linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.h
===================================================================
--- linux-3.9.6.orig/drivers/net/ethernet/ralink/mdio_rt2880.h	2013-06-22 22:46:13.600610937 +0200
+++ linux-3.9.6/drivers/net/ethernet/ralink/mdio_rt2880.h	2013-06-22 22:46:13.744610945 +0200
@@ -18,8 +18,9 @@
 #ifndef _RALINK_MDIO_RT2880_H__
 #define _RALINK_MDIO_RT2880_H__
 
-void rt2880_mdio_link_adjust(struct fe_priv *priv);
+void rt2880_mdio_link_adjust(struct fe_priv *priv, int port);
 int rt2880_mdio_read(struct mii_bus *bus, int phy_addr, int phy_reg);
 int rt2880_mdio_write(struct mii_bus *bus, int phy_addr, int phy_reg, u16 val);
+void rt2880_port_init(struct fe_priv *priv, struct device_node *np);
 
 #endif
Index: linux-3.9.6/drivers/net/ethernet/ralink/ralink_soc_eth.h
===================================================================
--- linux-3.9.6.orig/drivers/net/ethernet/ralink/ralink_soc_eth.h	2013-06-22 22:46:13.600610937 +0200
+++ linux-3.9.6/drivers/net/ethernet/ralink/ralink_soc_eth.h	2013-06-22 22:46:13.744610945 +0200
@@ -301,6 +301,8 @@
 	const __be32		*phy_fixed[8];
 	int			duplex[8];
 	int			speed[8];
+	int			tx_fc[8];
+	int			rx_fc[8];
 	spinlock_t		lock;
 
 	int (*connect)(struct fe_priv *priv);
Index: linux-3.9.6/drivers/net/ethernet/ralink/soc_rt3883.c
===================================================================
--- linux-3.9.6.orig/drivers/net/ethernet/ralink/soc_rt3883.c	2013-06-22 22:46:13.600610937 +0200
+++ linux-3.9.6/drivers/net/ethernet/ralink/soc_rt3883.c	2013-06-22 22:46:13.744610945 +0200
@@ -47,7 +47,8 @@
 	.checksum_bit = RX_DMA_L4VALID,
 	.mdio_read = rt2880_mdio_read,
 	.mdio_write = rt2880_mdio_write,
-	.mdio_link_adjust = rt2880_mdio_link_adjust,
+	.mdio_adjust_link = rt2880_mdio_link_adjust,
+	.port_init = rt2880_port_init,
 };
 
 const struct of_device_id of_fe_match[] = {