summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSushil Singh <sushilkumars@nvidia.com>2020-11-18 05:15:53 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2021-05-12 21:43:36 -0400
commit38cd360781ca67b686829d8dd3d8023d0d7c13dc (patch)
tree8f15fe24af09608abf30faf9581c207cda7fa502
parent397f8bd575cad792b2f6835bc7ab6eedce0a15eb (diff)
eqos: use phy reset low power mode from DT
Issue: Some ethernet PHY consume low power only when they are put in reset mode otherwise power consumption is high. Fix: Add DT flag which can be set for the PHYs which consume low power when they are in reset. Driver puts those phy chip to reset mode for low power consumption state if the corresponding dt flag is set, else use supported low power mode operation for the selected phy. Default operation is to use phy reset mode for low power consumption. Bug 200627703 Change-Id: If86c37b43c8f737c332c46188ab2e91ae9c72343 Signed-off-by: Sushil Singh <sushilkumars@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvidia/+/2447746 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Bhadram Varka <vbhadram@nvidia.com> Reviewed-by: Nagaraj Annaiah <nannaiah@nvidia.com> Reviewed-by: Srinivas Ramachandran <srinivasra@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit Tested-by: Aaron Tian <atian@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--Documentation/devicetree/bindings/platform/tegra/tegra-eqos.txt2
-rw-r--r--drivers/net/ethernet/nvidia/eqos/drv.c4
-rw-r--r--drivers/net/ethernet/nvidia/eqos/init.c21
-rw-r--r--drivers/net/ethernet/nvidia/eqos/yheader.h3
4 files changed, 24 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/platform/tegra/tegra-eqos.txt b/Documentation/devicetree/bindings/platform/tegra/tegra-eqos.txt
index c3d710ad3..cf30d6adf 100644
--- a/Documentation/devicetree/bindings/platform/tegra/tegra-eqos.txt
+++ b/Documentation/devicetree/bindings/platform/tegra/tegra-eqos.txt
@@ -133,6 +133,8 @@ Optional properties:
133- nvidia,rx_riwt: Specifies the RX wathcdog interrupt timeout in usec 133- nvidia,rx_riwt: Specifies the RX wathcdog interrupt timeout in usec
134 for an Rx descriptor for which IOC bit is not set. 134 for an Rx descriptor for which IOC bit is not set.
135 The RIWT field is programmed as (<val> * 256) / 62.5 135 The RIWT field is programmed as (<val> * 256) / 62.5
136- phy_rst_lp_mode Specifies that the phy should be put in reset for low
137 power mode when it is set.
136 138
137Example: 139Example:
138 140
diff --git a/drivers/net/ethernet/nvidia/eqos/drv.c b/drivers/net/ethernet/nvidia/eqos/drv.c
index ff46b675e..b9f19fdeb 100644
--- a/drivers/net/ethernet/nvidia/eqos/drv.c
+++ b/drivers/net/ethernet/nvidia/eqos/drv.c
@@ -29,7 +29,7 @@
29 * DAMAGE. 29 * DAMAGE.
30 * ========================================================================= */ 30 * ========================================================================= */
31/* 31/*
32 * Copyright (c) 2015-2020, NVIDIA CORPORATION. All rights reserved. 32 * Copyright (c) 2015-2021, NVIDIA CORPORATION. All rights reserved.
33 * 33 *
34 * This program is free software; you can redistribute it and/or modify it 34 * This program is free software; you can redistribute it and/or modify it
35 * under the terms and conditions of the GNU General Public License, 35 * under the terms and conditions of the GNU General Public License,
@@ -1219,7 +1219,7 @@ static int eqos_close(struct net_device *dev)
1219 phy_stop(pdata->phydev); 1219 phy_stop(pdata->phydev);
1220 phy_disconnect(pdata->phydev); 1220 phy_disconnect(pdata->phydev);
1221 if (gpio_is_valid(pdata->phy_reset_gpio) && 1221 if (gpio_is_valid(pdata->phy_reset_gpio) &&
1222 (pdata->mac_ver > EQOS_MAC_CORE_4_10)) 1222 (pdata->dt_cfg.phyrst_lpmode == 1U))
1223 gpio_set_value(pdata->phy_reset_gpio, 0); 1223 gpio_set_value(pdata->phy_reset_gpio, 0);
1224 pdata->phydev = NULL; 1224 pdata->phydev = NULL;
1225 } 1225 }
diff --git a/drivers/net/ethernet/nvidia/eqos/init.c b/drivers/net/ethernet/nvidia/eqos/init.c
index b77e651d3..c01456856 100644
--- a/drivers/net/ethernet/nvidia/eqos/init.c
+++ b/drivers/net/ethernet/nvidia/eqos/init.c
@@ -1036,6 +1036,7 @@ int eqos_probe(struct platform_device *pdev)
1036 u8 mac_addr[6]; 1036 u8 mac_addr[6];
1037 struct eqos_cfg *pdt_cfg; 1037 struct eqos_cfg *pdt_cfg;
1038 bool use_multi_q; 1038 bool use_multi_q;
1039 uint phyrst_lp_mode;
1039 uint num_chans, chan; 1040 uint num_chans, chan;
1040 1041
1041 pr_debug("-->%s()\n", __func__); 1042 pr_debug("-->%s()\n", __func__);
@@ -1370,6 +1371,20 @@ int eqos_probe(struct platform_device *pdev)
1370 pdata->phy_node = of_node_get(node); 1371 pdata->phy_node = of_node_get(node);
1371 } 1372 }
1372 1373
1374 /* Read the supported phy low power mode for the attached phy.
1375 * Default is to put phy in reset mode, if not set then use the
1376 * low power mode supported by the particular phy chip.
1377 */
1378 ret = of_property_read_u32(pdata->phy_node, "phy_rst_lp_mode",
1379 &phyrst_lp_mode);
1380 if (ret < 0) {
1381 pr_info("Using default phy reset low power mode\n");
1382 pdata->dt_cfg.phyrst_lpmode = 1U;
1383 } else {
1384 pr_info("Using phyrst_lpmode = %d from DT\n", phyrst_lp_mode);
1385 pdata->dt_cfg.phyrst_lpmode = phyrst_lp_mode ? 1U : 0U;
1386 }
1387
1373 if (pdata->mdio_node) { 1388 if (pdata->mdio_node) {
1374 ret = eqos_mdio_register(ndev); 1389 ret = eqos_mdio_register(ndev);
1375 if (ret < 0) { 1390 if (ret < 0) {
@@ -1492,7 +1507,7 @@ int eqos_probe(struct platform_device *pdev)
1492 1507
1493 /* put Ethernet PHY in reset for power save */ 1508 /* put Ethernet PHY in reset for power save */
1494 if (gpio_is_valid(pdata->phy_reset_gpio) && 1509 if (gpio_is_valid(pdata->phy_reset_gpio) &&
1495 (pdata->mac_ver > EQOS_MAC_CORE_4_10)) 1510 (pdata->dt_cfg.phyrst_lpmode == 1U))
1496 gpio_set_value(pdata->phy_reset_gpio, 0); 1511 gpio_set_value(pdata->phy_reset_gpio, 0);
1497 1512
1498 return 0; 1513 return 0;
@@ -1655,8 +1670,8 @@ static int eqos_suspend_noirq(struct device *dev)
1655 enable_irq_wake(pdata->phydev->irq); 1670 enable_irq_wake(pdata->phydev->irq);
1656 } else { 1671 } else {
1657 phy_stop(pdata->phydev); 1672 phy_stop(pdata->phydev);
1658 if ((gpio_is_valid(pdata->phy_reset_gpio) && 1673 if (gpio_is_valid(pdata->phy_reset_gpio) &&
1659 (pdata->mac_ver > EQOS_MAC_CORE_4_10))) { 1674 (pdata->dt_cfg.phyrst_lpmode == 1U)) {
1660 gpio_set_value(pdata->phy_reset_gpio, 0); 1675 gpio_set_value(pdata->phy_reset_gpio, 0);
1661 usleep_range(pdata->phy_reset_duration, 1676 usleep_range(pdata->phy_reset_duration,
1662 pdata->phy_reset_duration + 1); 1677 pdata->phy_reset_duration + 1);
diff --git a/drivers/net/ethernet/nvidia/eqos/yheader.h b/drivers/net/ethernet/nvidia/eqos/yheader.h
index e12e30eef..f6e1794b2 100644
--- a/drivers/net/ethernet/nvidia/eqos/yheader.h
+++ b/drivers/net/ethernet/nvidia/eqos/yheader.h
@@ -29,7 +29,7 @@
29 * DAMAGE. 29 * DAMAGE.
30 * ========================================================================= */ 30 * ========================================================================= */
31/* 31/*
32 * Copyright (c) 2015-2020, NVIDIA CORPORATION. All rights reserved. 32 * Copyright (c) 2015-2021, NVIDIA CORPORATION. All rights reserved.
33 * 33 *
34 * This program is free software; you can redistribute it and/or modify it 34 * This program is free software; you can redistribute it and/or modify it
35 * under the terms and conditions of the GNU General Public License, 35 * under the terms and conditions of the GNU General Public License,
@@ -1360,6 +1360,7 @@ struct eqos_cfg {
1360 uint eth_iso_enable; 1360 uint eth_iso_enable;
1361 bool phy_apd_mode; /* Represents PHY AUTO POWER DOWN mode */ 1361 bool phy_apd_mode; /* Represents PHY AUTO POWER DOWN mode */
1362 uint reg_auto_cal_config_0_val; /* EQOS_AUTO_CAL_CONFIG_0 REG */ 1362 uint reg_auto_cal_config_0_val; /* EQOS_AUTO_CAL_CONFIG_0 REG */
1363 u8 phyrst_lpmode; /* Phy in rst for low power mode */
1363 u32 slot_intvl_val; /* Slot Interval Value*/ 1364 u32 slot_intvl_val; /* Slot Interval Value*/
1364}; 1365};
1365 1366