diff mbox

[OpenWrt-Devel,2/3] ramips: Get ethernet ports to be disabled from the device tree.

Message ID owrt-patch-20151205-2@vittgam.net
State Superseded, archived
Headers show

Commit Message

Vittorio Gambaletta Dec. 5, 2015, 11:03 a.m. UTC
Line 461 is actually enabling all switch ports, so line 508 is always getting
zero ports to be disabled (except for port 5 in SoCs where this is not implemented,
as it will be sticky disabled in register POC0).

Also, the bootloader on some routers sets all ports to disabled (which is
also the default for at least RT5350).

So, this patch allows configuring ports to be disabled in the device tree.

Power can be saved too this way, since disabling ports here actually disables
power to ethernet PHYs.

Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>

---

Please apply to both trunk and CC.
diff mbox

Patch

--- a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3052.c
+++ b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3052.c
@@ -233,6 +233,7 @@  struct rt305x_esw {
 	spinlock_t		reg_rw_lock;
 
 	unsigned char		port_map;
+	unsigned char		port_disable;
 	unsigned int		reg_initval_fct2;
 	unsigned int		reg_initval_fpa2;
 	unsigned int		reg_led_polarity;
@@ -457,7 +458,7 @@  static void esw_hw_init(struct rt305x_esw *esw)
 		      (RT305X_ESW_PORTS_ALL << RT305X_ESW_PFC1_EN_VLAN_S),
 		      RT305X_ESW_REG_PFC1);
 
-	/* Enable Back Pressure, and Flow Control */
+	/* Enable all ports; enable Back Pressure and Flow Control */
 	esw_w32(esw,
 		      ((RT305X_ESW_PORTS_ALL << RT305X_ESW_POC0_EN_BP_S) |
 		       (RT305X_ESW_PORTS_ALL << RT305X_ESW_POC0_EN_FC_S)),
@@ -504,8 +505,9 @@  static void esw_hw_init(struct rt305x_esw *esw)
 	esw_w32(esw, 0x00000005, RT305X_ESW_REG_P3LED);
 	esw_w32(esw, 0x00000005, RT305X_ESW_REG_P4LED);
 
-	/* Copy disabled port configuration from bootloader setup */
-	port_disable = esw_get_port_disable(esw);
+	/* Copy disabled port configuration from device tree setup */
+	if (esw->port_disable)
+		port_disable = esw->port_disable;
 	for (i = 0; i < 6; i++)
 		esw->ports[i].disable = (port_disable & (1 << i)) != 0;
 
@@ -1419,6 +1421,10 @@  static int esw_probe(struct platform_device *pdev)
 	reg_init = of_get_property(np, "ralink,portmap", NULL);
 	if (reg_init)
 		esw->port_map = be32_to_cpu(*reg_init);
+
+	reg_init = of_get_property(np, "ralink,portdisable", NULL);
+	if (reg_init)
+		esw->port_disable = be32_to_cpu(*reg_init);
 
 	reg_init = of_get_property(np, "ralink,fct2", NULL);
 	if (reg_init)