diff options
author | John Crispin <blogic@openwrt.org> | 2016-01-03 18:03:17 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2016-01-03 18:03:17 +0000 |
commit | f92804f323d613e1c7809fe250e260b1279c2e11 (patch) | |
tree | 4d50ad78bc1d8346dbbb46efc9ce465a849e08dc /target | |
parent | cc665dc23abcc1eaf7d5c69f911150851c0b131b (diff) | |
download | upstream-f92804f323d613e1c7809fe250e260b1279c2e11.tar.gz upstream-f92804f323d613e1c7809fe250e260b1279c2e11.tar.bz2 upstream-f92804f323d613e1c7809fe250e260b1279c2e11.zip |
ramips: Get rt3052 ethernet ports to be disabled from the device tree.
This patch allows configuring ports to be disabled in the device tree; this
saves power, since disabling ports here actually disables power to ethernet
PHYs.
Line 461 enables all ethernet ports, so line 508 is 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. Because of this, the code will still read
the switch configuration and OR it to the device tree setting.
Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
git-svn-id: svn://svn.openwrt.org/openwrt/branches/chaos_calmer@48096 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
-rw-r--r-- | target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3052.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3052.c b/target/linux/ramips/files/drivers/net/ethernet/ralink/esw_rt3052.c index b2d0f0b4f4..ef13d2321b 100644 --- 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; @@ -504,8 +505,14 @@ 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 */ + port_disable = esw->port_disable; + + /* Disable nonexistent ports by reading the switch config + * after having enabled all possible ports above + */ + port_disable |= esw_get_port_disable(esw); + for (i = 0; i < 6; i++) esw->ports[i].disable = (port_disable & (1 << i)) != 0; @@ -1373,7 +1380,7 @@ static int esw_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; const struct rt305x_esw_platform_data *pdata; - const __be32 *port_map, *reg_init; + const __be32 *port_map, *port_disable, *reg_init; struct rt305x_esw *esw; struct switch_dev *swdev; struct resource *res, *irq; @@ -1420,6 +1427,10 @@ static int esw_probe(struct platform_device *pdev) if (port_map) esw->port_map = be32_to_cpu(*port_map); + port_disable = of_get_property(np, "ralink,portdisable", NULL); + 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); |