summaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-3.8/421-BCM63XX-use-port-id-for-deciding-external-phy.patch
blob: c0475019d26f7b6124bb8a3f20ed1dbb866c7a75 (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
From 85e4551e033df7cb043e93042661fc1e58799efa Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jonas.gorski@gmail.com>
Date: Sun, 8 Jul 2012 15:36:23 +0200
Subject: [PATCH 52/84] BCM63XX: use port id for deciding external phy

Ports 0-3 always use the internal phy, while 4+ always need an external
phy to work.
---
 .../include/asm/mach-bcm63xx/bcm63xx_dev_enet.h    |    3 ++-
 drivers/net/ethernet/broadcom/bcm63xx_enet.c       |   15 ++++++++-------
 drivers/net/ethernet/broadcom/bcm63xx_enet.h       |    5 +++++
 3 files changed, 15 insertions(+), 8 deletions(-)

--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
@@ -45,9 +45,10 @@ struct bcm63xx_enet_platform_data {
 #define ENETSW_MAX_PORT	6
 #define ENETSW_PORTS_6368 6 /* 4 FE PHY + 2 RGMII */
 
+#define ENETSW_RGMII_PORT0	4
+
 struct bcm63xx_enetsw_port {
 	int		used;
-	int		external_phy;
 	int		phy_id;
 
 	int		bypass_link;
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -2046,6 +2046,7 @@ static void swphy_poll_timer(unsigned lo
 	for (i = 0; i < priv->num_ports; i++) {
 		struct bcm63xx_enetsw_port *port;
 		int val, j, up, advertise, lpa, lpa2, speed, duplex, media;
+		int external_phy = bcm_enet_port_is_rgmii(i);
 		u8 override;
 
 		port = &priv->used_ports[i];
@@ -2057,7 +2058,7 @@ static void swphy_poll_timer(unsigned lo
 
 		/* dummy read to clear */
 		for (j = 0; j < 2; j++)
-			val = bcmenet_sw_mdio_read(priv, port->external_phy,
+			val = bcmenet_sw_mdio_read(priv, external_phy,
 						   port->phy_id, MII_BMSR);
 
 		if (val == 0xffff)
@@ -2081,14 +2082,14 @@ static void swphy_poll_timer(unsigned lo
 			continue;
 		}
 
-		advertise = bcmenet_sw_mdio_read(priv, port->external_phy,
+		advertise = bcmenet_sw_mdio_read(priv, external_phy,
 						 port->phy_id, MII_ADVERTISE);
 
-		lpa = bcmenet_sw_mdio_read(priv, port->external_phy,
-					   port->phy_id, MII_LPA);
+		lpa = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id,
+					   MII_LPA);
 
-		lpa2 = bcmenet_sw_mdio_read(priv, port->external_phy,
-					   port->phy_id, MII_STAT1000);
+		lpa2 = bcmenet_sw_mdio_read(priv, external_phy, port->phy_id,
+					    MII_STAT1000);
 
 		/* figure out media and duplex from advertise and LPA values */
 		media = mii_nway_result(lpa & advertise);
@@ -2457,7 +2458,7 @@ static int bcm_enetsw_phy_is_external(st
 		if (!priv->used_ports[i].used)
 			continue;
 		if (priv->used_ports[i].phy_id == phy_id)
-			return priv->used_ports[i].external_phy;
+			return bcm_enet_port_is_rgmii(i);
 	}
 
 	printk_once(KERN_WARNING  "bcm63xx_enet: could not find a used port "
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.h
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.h
@@ -337,4 +337,9 @@ struct bcm_enet_priv {
 	spinlock_t enetsw_mdio_lock;
 };
 
+static inline int bcm_enet_port_is_rgmii(int portid)
+{
+	return portid >= ENETSW_RGMII_PORT0;
+}
+
 #endif /* ! BCM63XX_ENET_H_ */