iperf: Drop single-threaded variant
[openwrt/openwrt.git] / target / linux / ramips / patches-4.4 / 0518-net-mediatek-get-rt3050-ethernet-ports-to-be-disable.patch
1 From: Vittorio Gambaletta <openwrt@vittgam.net>
2 Date: Fri, 01 Jan 2016 00:00:02 +0100
3 Subject: [PATCH 3/3] net: mediatek: Get rt3050 ethernet ports to be disabled from the device tree.
4
5 This patch allows configuring ports to be disabled in the device tree; this
6 saves power, since disabling ports here actually disables power to ethernet
7 PHYs.
8
9 Line 444 enables all ethernet ports, so line 487 is getting zero ports to be
10 disabled, except for port 5 in SoCs where this is not implemented as it will
11 be sticky disabled in register POC0. Because of this, the code will still read
12 the switch configuration and OR it to the device tree setting.
13
14 Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
15 ---
16
17 --- a/drivers/net/ethernet/mediatek/esw_rt3050.c
18 +++ b/drivers/net/ethernet/mediatek/esw_rt3050.c
19 @@ -10,6 +10,7 @@
20 * Copyright (C) 2009-2015 John Crispin <blogic@openwrt.org>
21 * Copyright (C) 2009-2015 Felix Fietkau <nbd@openwrt.org>
22 * Copyright (C) 2013-2015 Michael Lee <igvtee@gmail.com>
23 + * Copyright (C) 2016 Vittorio Gambaletta <openwrt@vittgam.net>
24 */
25
26 #include <linux/module.h>
27 @@ -219,6 +220,7 @@ struct rt305x_esw {
28 spinlock_t reg_rw_lock;
29
30 unsigned char port_map;
31 + unsigned char port_disable;
32 unsigned int reg_led_polarity;
33
34 struct switch_dev swdev;
35 @@ -483,8 +485,14 @@ static void esw_hw_init(struct rt305x_es
36 esw_w32(esw, 0x00000005, RT305X_ESW_REG_P3LED);
37 esw_w32(esw, 0x00000005, RT305X_ESW_REG_P4LED);
38
39 - /* Copy disabled port configuration from bootloader setup */
40 - port_disable = esw_get_port_disable(esw);
41 + /* Copy disabled port configuration from device tree setup */
42 + port_disable = esw->port_disable;
43 +
44 + /* Disable nonexistent ports by reading the switch config
45 + * after having enabled all possible ports above
46 + */
47 + port_disable |= esw_get_port_disable(esw);
48 +
49 for (i = 0; i < 6; i++)
50 esw->ports[i].disable = (port_disable & (1 << i)) != 0;
51
52 @@ -1330,7 +1338,7 @@ static int esw_probe(struct platform_dev
53 {
54 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
55 struct device_node *np = pdev->dev.of_node;
56 - const __be32 *port_map, *reg_init;
57 + const __be32 *port_map, *port_disable, *reg_init;
58 struct switch_dev *swdev;
59 struct rt305x_esw *esw;
60 int ret;
61 @@ -1349,6 +1357,10 @@ static int esw_probe(struct platform_dev
62 if (port_map)
63 esw->port_map = be32_to_cpu(*port_map);
64
65 + port_disable = of_get_property(np, "mediatek,portdisable", NULL);
66 + if (port_disable)
67 + esw->port_disable = be32_to_cpu(*port_disable);
68 +
69 reg_init = of_get_property(np, "mediatek,led_polarity", NULL);
70 if (reg_init)
71 esw->reg_led_polarity = be32_to_cpu(*reg_init);
72 --- a/Documentation/devicetree/bindings/net/ralink,rt3050-esw.txt
73 +++ b/Documentation/devicetree/bindings/net/ralink,rt3050-esw.txt
74 @@ -16,6 +16,7 @@ Required properties:
75 Optional properties:
76 - mediatek,portmap: can be used to choose if the default switch setup is
77 llllw or wllll
78 +- mediatek,portdisable: disable unused ethernet PHYs to save power
79 - mediatek,led_polarity: override the active high/low settings of the leds
80
81 Example: