aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ramips/patches-4.4/0520-esw-gmac.patch
blob: ae5fa16d666e21c493444bc53ffe4d0060eed4fd (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
--- a/drivers/net/ethernet/mediatek/esw_rt3050.c
+++ b/drivers/net/ethernet/mediatek/esw_rt3050.c
@@ -221,6 +221,8 @@ struct rt305x_esw {
 
 	unsigned char		port_map;
 	unsigned char		port_disable;
+	unsigned int		reg_initval_fct2;
+	unsigned int		reg_initval_fpa2;
 	unsigned int		reg_led_polarity;
 
 	struct switch_dev	swdev;
@@ -452,7 +454,10 @@ static void esw_hw_init(struct rt305x_es
 		      (RT305X_ESW_PORTS_NOCPU << RT305X_ESW_POC2_UNTAG_EN_S)),
 		RT305X_ESW_REG_POC2);
 
-	esw_w32(esw, 0x0002500c, RT305X_ESW_REG_FCT2);
+	if (esw->reg_initval_fct2)
+		esw_w32(esw, esw->reg_initval_fct2, RT305X_ESW_REG_FCT2);
+	else
+		esw_w32(esw, 0x0002500c, RT305X_ESW_REG_FCT2);
 
 	/* 300s aging timer, max packet len 1536, broadcast storm prevention
 	 * disabled, disable collision abort, mac xor48 hash, 10 packet back
@@ -475,7 +480,10 @@ static void esw_hw_init(struct rt305x_es
 	 * port5: disabled
 	 * port6: enabled, gige, full-duplex, rx/tx-flow-control
 	 */
-	esw_w32(esw, 0x3f502b28, RT305X_ESW_REG_FPA2);
+	if (esw->reg_initval_fpa2)
+		esw_w32(esw, esw->reg_initval_fpa2, RT305X_ESW_REG_FPA2);
+	else
+		esw_w32(esw, 0x3f502b28, RT305X_ESW_REG_FPA2);
 	esw_w32(esw, 0x00000000, RT305X_ESW_REG_FPA);
 
 	/* Force Link/Activity on ports */
@@ -1361,6 +1369,14 @@ static int esw_probe(struct platform_dev
 	if (port_disable)
 		esw->port_disable = be32_to_cpu(*port_disable);
 
+	reg_init = of_get_property(np, "ralink,fct2", NULL);
+	if (reg_init)
+		esw->reg_initval_fct2 = be32_to_cpu(*reg_init);
+
+	reg_init = of_get_property(np, "ralink,fpa2", NULL);
+	if (reg_init)
+		esw->reg_initval_fpa2 = be32_to_cpu(*reg_init);
+
 	reg_init = of_get_property(np, "mediatek,led_polarity", NULL);
 	if (reg_init)
 		esw->reg_led_polarity = be32_to_cpu(*reg_init);
@@ -1386,6 +1402,18 @@ static int esw_probe(struct platform_dev
 
 	esw_hw_init(esw);
 
+	reg_init = of_get_property(np, "ralink,rgmii", NULL);
+	if (reg_init && be32_to_cpu(*reg_init) == 1) {
+		/* 
+		 * External switch connected to RGMII interface. 
+		 * Unregister the switch device after initialization. 
+		 */
+		dev_err(&pdev->dev, "RGMII mode, not exporting switch device.\n");
+		unregister_switch(&esw->swdev);
+		platform_set_drvdata(pdev, NULL);
+		return -ENODEV;
+	}
+
 	ret = devm_request_irq(&pdev->dev, esw->irq, esw_interrupt, 0, "esw",
 			       esw);