net: dwc_eth_qos: add support of device tree configuration for reset delay
v3 cover net: dwc_eth_qos: add support of device tree configuration for reset delay
It is the V3 version of [1], rebased and without compilation issue for power PC baord withotu CONFIG_DM_GPIO.
I change the DWC_ETH_QOS STM32 variant by using generic the phy driver.
This driver is updated to use the gpio reset and assert/deassert delay from DT with the generic binding defined in linux:
Documentation/devicetree/bindings/net/ethernet-phy.yaml
or in U-Boot: doc/device-tree-bindings/net/phy.txt
[1] net: dwc_eth_qos: add support of device tree configuration for reset delay
http://patchwork.ozlabs.org/project/uboot/list/?series=240808&state=* http://patchwork.ozlabs.org/project/uboot/list/?series=240807&state=*
Changes in v3:
- allow compilation without DM_GPIO
Changes in v2:
- Update eth-phy driver (NEW)
- use log macro in eth-phy driver (NEW)
- update eth-phy driver to support STM32 binding with a mdio0 subnode (NEW)
- remove unused element in the struct eqos_priv (NEW)
- use generic ethernet phy for stm32 variant, this patch is a REWORK of previous serie: the device parsing is done in eth-phy driver and the gpio support is removed in stm32 variant: eqos_start/stop_resets_stm32 and eqos_probe_resources_stm32.
- cleanup ops by adding a common null ops (NEW)
Patrick Delaunay (6):
net: eth-phy: add support of device tree configuration for gpio reset
net: eth-phy: use dev_dbg and log_notice
net: eth-phy: manage subnode mdio0
net: dwc_eth_qos: remove the field phyaddr of the struct eqos_priv
net: dwc_eth_qos: use generic ethernet phy for stm32 variant
net: dwc: add a common empty ops eqos_null_ops
drivers/net/Kconfig | 1 + drivers/net/dwc_eth_qos.c | 152 +++++------------------------------ drivers/net/eth-phy-uclass.c | 84 ++++++++++++++++--- 3 files changed, 97 insertions(+), 140 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/6 net: eth-phy: add support of device tree configuration for gpio reset
The gpio reset and the assert or deassert delay are defined in generic binding of the ethernet phy in Linux:Documentation/devicetree/bindings/net/ethernet-phy.yaml
reset-gpios:
maxItems: 1
description:
The GPIO phandle and specifier for the PHY reset signal.
reset-assert-us:
description:
Delay after the reset was asserted in microseconds. If this property is missing the delay will be skipped.
reset-deassert-us:
description:
Delay after the reset was deasserted in microseconds. If this property is missing the delay will be skipped.
See also U-Boot: doc/device-tree-bindings/net/phy.txt
This patch adds the parsing of this common DT properties in the u-class "eth_phy_generic", used by default in the associated driver "eth_phy_generic_drv"
This parsing function eth_phy_of_to_plat can be reused by other ethernet phy drivers for this uclass UCLASS_ETH_PHY.
---
Changes in v3:
- allow compilation without DM_GPIO
Changes in v2:
- Update eth-phy driver (NEW)
drivers/net/eth-phy-uclass.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
drivers/net/eth-phy-uclass.c +56 -0
@@ -6,12 +6,17 @@#include <common.h> #include <dm.h> #include <net.h> +#include <asm-generic/gpio.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> #include <dm/lists.h> +#include <linux/delay.h> struct eth_phy_device_priv {struct mii_dev *mdio_bus; +struct gpio_desc reset_gpio; +u32 reset_assert_delay; +u32 reset_deassert_delay; };int eth_phy_binds_nodes (struct udevice *eth_dev)
@@ -110,13 +115,64 @@ int eth_phy_get_addr(struct udevice *dev)return reg; } +/* parsing generic properties of devicetree/bindings/net/ethernet-phy.yaml */ +static int eth_phy_of_to_plat (struct udevice *dev) +{ +struct eth_phy_device_priv *uc_priv =dev_get_uclass_priv (dev); +int ret; + +if (!CONFIG_IS_ENABLED (DM_GPIO )) +return 0 ; + +/* search "reset-gpios" in phy node */ + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , + &uc_priv->reset_gpio, +GPIOD_IS_OUT ); +if (ret != -ENOENT ) +return ret; + + uc_priv->reset_assert_delay =dev_read_u32_default (dev,"reset-assert-us" ,0 ); + uc_priv->reset_deassert_delay =dev_read_u32_default (dev,"reset-deassert-us" ,0 ); + +return 0 ; +} + +void eth_phy_reset (struct udevice *dev,int value) +{ +struct eth_phy_device_priv *uc_priv =dev_get_uclass_priv (dev); +u32 delay; + +if (!CONFIG_IS_ENABLED (DM_GPIO )) +return ; + +if (!dm_gpio_is_valid (&uc_priv->reset_gpio)) +return ; + +dm_gpio_set_value (&uc_priv->reset_gpio, value); + + delay = value ? uc_priv->reset_assert_delay : uc_priv->reset_deassert_delay; +if (delay) +udelay (delay); +} + +static int eth_phy_pre_probe (struct udevice *dev) +{ +/* Assert and deassert the reset signal */ +eth_phy_reset (dev,1 ); +eth_phy_reset (dev,0 ); + +return 0 ; +} +UCLASS_DRIVER (eth_phy_generic) = { .id =UCLASS_ETH_PHY , .name ="eth_phy_generic" , .per_device_auto =sizeof (struct eth_phy_device_priv ), + .pre_probe = eth_phy_pre_probe, };U_BOOT_DRIVER (eth_phy_generic_drv) = { .name ="eth_phy_generic_drv" , .id =UCLASS_ETH_PHY , + .of_to_plat = eth_phy_of_to_plat, };
Signature · 1 line
2.25.1
Re: [PATCH v3 1/6] net: eth-phy: add support of device tree configuration for gpio reset
Quoted 129 lines · Patrick Delaunay
The gpio reset and the assert or deassert delay are defined in generic binding of the ethernet phy in Linux:
Documentation/devicetree/bindings/net/ethernet-phy.yamlreset-gpios:
maxItems: 1
description:
The GPIO phandle and specifier for the PHY reset signal.reset-assert-us:
description:
Delay after the reset was asserted in microseconds. If this property is missing the delay will be skipped.reset-deassert-us:
description:
Delay after the reset was deasserted in microseconds. If this property is missing the delay will be skipped.See also U-Boot:
doc/device-tree-bindings/net/phy.txtThis patch adds the parsing of this common DT properties in the u-class "
eth_phy_generic", used by default in the associated driver "eth_phy_generic_drv"This parsing function
eth_phy_of_to_platcan be reused by other ethernet phy drivers for this uclassUCLASS_ETH_PHY.Signed-off-by Patrick Delaunay <[email protected]>---
Changes in v3:
- allow compilation withoutDM_GPIOChanges in v2:
- Update eth-phy driver (NEW)drivers/net/eth-phy-uclass.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)drivers/net/eth-phy-uclass.c +56
-1@@ -6,12 +6,17 @@#include <common.h> #include <dm.h> #include <net.h> +#include <asm-generic/gpio.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> #include <dm/lists.h> +#include <linux/delay.h> struct eth_phy_device_priv {struct mii_dev *mdio_bus; +struct gpio_desc reset_gpio; +u32 reset_assert_delay; +u32 reset_deassert_delay; };int eth_phy_binds_nodes (struct udevice *eth_dev)@@ -110,13 +115,64 @@ int eth_phy_get_addr(struct udevice *dev)return reg; } +/* parsing generic properties of devicetree/bindings/net/ethernet-phy.yaml */ +static int eth_phy_of_to_plat (struct udevice *dev) +{ +struct eth_phy_device_priv *uc_priv =dev_get_uclass_priv (dev); +int ret; + +if (!CONFIG_IS_ENABLED (DM_GPIO )) +return 0 ; + +/* search "reset-gpios" in phy node */ + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , + &uc_priv->reset_gpio, +GPIOD_IS_OUT ); +if (ret != -ENOENT ) +return ret; + + uc_priv->reset_assert_delay =dev_read_u32_default (dev,"reset-assert-us" ,0 ); + uc_priv->reset_deassert_delay =dev_read_u32_default (dev,"reset-deassert-us" ,0 ); + +return 0 ; +} + +void eth_phy_reset (struct udevice *dev,int value) +{ +struct eth_phy_device_priv *uc_priv =dev_get_uclass_priv (dev); +u32 delay; + +if (!CONFIG_IS_ENABLED (DM_GPIO )) +return ; + +if (!dm_gpio_is_valid (&uc_priv->reset_gpio)) +return ; + +dm_gpio_set_value (&uc_priv->reset_gpio, value); + + delay = value ? uc_priv->reset_assert_delay : uc_priv->reset_deassert_delay; +if (delay) +udelay (delay); +} + +static int eth_phy_pre_probe (struct udevice *dev) +{ +/* Assert and deassert the reset signal */ +eth_phy_reset (dev,1 ); +eth_phy_reset (dev,0 ); + +return 0 ; +} +UCLASS_DRIVER (eth_phy_generic) = { .id =UCLASS_ETH_PHY , .name ="eth_phy_generic" , .per_device_auto =sizeof (struct eth_phy_device_priv ), + .pre_probe = eth_phy_pre_probe, };U_BOOT_DRIVER (eth_phy_generic_drv) = { .name ="eth_phy_generic_drv" , .id =UCLASS_ETH_PHY , + .of_to_plat = eth_phy_of_to_plat, }; --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.
PATCH v3 2/6 net: eth-phy: use dev_dbg and log_notice
In reply to Patrick DelaunayReplace debug trace and printf to log macros:
- debug() replaced by dev_dbg() when device is available, this macro indicate the device name since commit ceb70bb870ac ("dm: Print device name in dev_xxx like Linux")
- printf() replaced by log_notice() to allow dispatch to log backends.
---
(no changes since v2)
Changes in v2:
- use log macro in eth-phy driver (NEW)
drivers/net/eth-phy-uclass.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/net/eth-phy-uclass.c +11 -9
@@ -5,8 +5,10 @@#include <common.h> #include <dm.h> +#include <log.h> #include <net.h> #include <asm-generic/gpio.h> +#include <dm/device_compat.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> #include <dm/lists.h>
@@ -27,25 +29,25 @@ int eth_phy_binds_nodes(struct udevice *eth_dev) mdio_node =dev_read_subnode (eth_dev,"mdio" );if (!ofnode_valid (mdio_node)) { -debug ("%s: %s mdio subnode not found!" , __func__, - eth_dev->name); +dev_dbg (eth_dev,"%s: %s mdio subnode not found!" , __func__, + eth_dev->name);return -ENXIO ; }ofnode_for_each_subnode (phy_node, mdio_node) { node_name =ofnode_get_name (phy_node); -debug ("* Found child node: '%s'\n" , node_name); +dev_dbg (eth_dev,"* Found child node: '%s'\n" , node_name); ret =device_bind_driver_to_node (eth_dev,"eth_phy_generic_drv" , node_name, phy_node,NULL );if (ret) { -debug (" - Eth phy binding error: %d\n" , ret); +dev_dbg (eth_dev," - Eth phy binding error: %d\n" , ret);continue ; } -debug (" - bound phy device: '%s'\n" , node_name); +dev_dbg (eth_dev," - bound phy device: '%s'\n" , node_name); }return 0 ;
@@ -86,14 +88,14 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)*/ uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv (phy_dev));if (uc_priv->mdio_bus) -printf ("Get shared mii bus on %s\n" , eth_dev->name); +log_notice ("Get shared mii bus on %s\n" , eth_dev->name);else -printf ("Can't get shared mii bus on %s\n" , eth_dev->name); +log_notice ("Can't get shared mii bus on %s\n" , eth_dev->name);return uc_priv->mdio_bus; } }else { -printf ("FEC: can't find phy-handle\n" ); +log_notice ("FEC: can't find phy-handle\n" ); }return NULL ;
@@ -106,7 +108,7 @@ int eth_phy_get_addr(struct udevice *dev)if (dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phandle_args)) { -debug ("Failed to find phy-handle" ); +dev_dbg (dev,"Failed to find phy-handle" );return -ENODEV ; }
Signature · 1 line
2.25.1
Re: [PATCH v3 2/6] net: eth-phy: use dev_dbg and log_notice
Quoted 93 lines · Patrick Delaunay
Replace debug trace and printf to log macros:
-debug()replaced bydev_dbg()when device is available, this macro indicate the device name since commitceb70bb870ac("dm: Print device name indev_xxxlike Linux")
-printf()replaced bylog_notice()to allow dispatch to log backends.Reviewed-by Ramon Fried <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
(no changes since v2)
Changes in v2:
- use log macro in eth-phy driver (NEW)drivers/net/eth-phy-uclass.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)drivers/net/eth-phy-uclass.c +11
-10@@ -5,8 +5,10 @@#include <common.h> #include <dm.h> +#include <log.h> #include <net.h> #include <asm-generic/gpio.h> +#include <dm/device_compat.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> #include <dm/lists.h> @@ -27,25 +29,25 @@ int eth_phy_binds_nodes(struct udevice *eth_dev) mdio_node =dev_read_subnode (eth_dev,"mdio" );if (!ofnode_valid (mdio_node)) { -debug ("%s: %s mdio subnode not found!" , __func__, - eth_dev->name); +dev_dbg (eth_dev,"%s: %s mdio subnode not found!" , __func__, + eth_dev->name);return -ENXIO ; }ofnode_for_each_subnode (phy_node, mdio_node) { node_name =ofnode_get_name (phy_node); -debug ("* Found child node: '%s'\n" , node_name); +dev_dbg (eth_dev,"* Found child node: '%s'\n" , node_name); ret =device_bind_driver_to_node (eth_dev,"eth_phy_generic_drv" , node_name, phy_node,NULL );if (ret) { -debug (" - Eth phy binding error: %d\n" , ret); +dev_dbg (eth_dev," - Eth phy binding error: %d\n" , ret);continue ; } -debug (" - bound phy device: '%s'\n" , node_name); +dev_dbg (eth_dev," - bound phy device: '%s'\n" , node_name); }return 0 ;@@ -86,14 +88,14 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev)*/ uc_priv = (struct eth_phy_device_priv *)(dev_get_uclass_priv (phy_dev));if (uc_priv->mdio_bus) -printf ("Get shared mii bus on %s\n" , eth_dev->name); +log_notice ("Get shared mii bus on %s\n" , eth_dev->name);else -printf ("Can't get shared mii bus on %s\n" , eth_dev->name); +log_notice ("Can't get shared mii bus on %s\n" , eth_dev->name);return uc_priv->mdio_bus; } }else { -printf ("FEC: can't find phy-handle\n" ); +log_notice ("FEC: can't find phy-handle\n" ); }return NULL ;@@ -106,7 +108,7 @@ int eth_phy_get_addr(struct udevice *dev)if (dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phandle_args)) { -debug ("Failed to find phy-handle" ); +dev_dbg (dev,"Failed to find phy-handle" );return -ENODEV ; } --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.
PATCH v3 3/6 net: eth-phy: manage subnode mdio0
In reply to Patrick DelaunayBind any subnode with name beginning by mdio, mdio0 for example, and not only the "mdio" as namei of subnode.
---
(no changes since v2)
Changes in v2:
- update eth-phy driver to support STM32 binding with a mdio0 subnode (NEW)
drivers/net/eth-phy-uclass.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/eth-phy-uclass.c +8 -2
@@ -27,12 +27,18 @@ int eth_phy_binds_nodes(struct udevice *eth_dev)const char *node_name;int ret; - mdio_node =dev_read_subnode (eth_dev,"mdio" ); +/* search a subnode named "mdio.*" */ +dev_for_each_subnode (mdio_node, eth_dev) { + node_name =ofnode_get_name (mdio_node); +if (!strncmp (node_name,"mdio" ,4 )) +break ; + }if (!ofnode_valid (mdio_node)) { -dev_dbg (eth_dev,"%s: %s mdio subnode not found!" , __func__, +dev_dbg (eth_dev,"%s: %s mdio subnode not found!\n" , __func__, eth_dev->name);return -ENXIO ; } +dev_dbg (eth_dev,"%s: %s subnode found!\n" , __func__, node_name);ofnode_for_each_subnode (phy_node, mdio_node) { node_name =ofnode_get_name (phy_node);
Signature · 1 line
2.25.1
Re: [PATCH v3 3/6] net: eth-phy: manage subnode mdio0
Quoted 42 lines · Patrick Delaunay
Bind any subnode with name beginning by mdio, mdio0 for example, and not only the "mdio" as namei of subnode.
Reviewed-by Ramon Fried <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
(no changes since v2)
Changes in v2:
- update eth-phy driver to support STM32 binding with a mdio0 subnode (NEW)drivers/net/eth-phy-uclass.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/net/eth-phy-uclass.c +8
-3@@ -27,12 +27,18 @@ int eth_phy_binds_nodes(struct udevice *eth_dev)const char *node_name;int ret; - mdio_node =dev_read_subnode (eth_dev,"mdio" ); +/* search a subnode named "mdio.*" */ +dev_for_each_subnode (mdio_node, eth_dev) { + node_name =ofnode_get_name (mdio_node); +if (!strncmp (node_name,"mdio" ,4 )) +break ; + }if (!ofnode_valid (mdio_node)) { -dev_dbg (eth_dev,"%s: %s mdio subnode not found!" , __func__, +dev_dbg (eth_dev,"%s: %s mdio subnode not found!\n" , __func__, eth_dev->name);return -ENXIO ; } +dev_dbg (eth_dev,"%s: %s subnode found!\n" , __func__, node_name);ofnode_for_each_subnode (phy_node, mdio_node) { node_name =ofnode_get_name (phy_node); --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.
PATCH v3 4/6 net: dwc_eth_qos: remove the field phyaddr of the struct eqos_priv
In reply to Patrick DelaunaySince the commit commit 6a895d039ba7 ("net: Update eQos driver and FEC driver to use eth phy interfaces") the field phyaddr of driver private data struct eqos_priv is no more used in eqos_start() for the phy_connect() parameter.
Now this variable is only initialized in eqos_probe_resources_stm32() it can be removed.
---
(no changes since v2)
Changes in v2:
- remove unused element in the struct eqos_priv (NEW)
drivers/net/dwc_eth_qos.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/dwc_eth_qos.c +0 -5
@@ -307,7 +307,6 @@ struct eqos_priv {struct clk clk_slave_bus;struct mii_dev *mii;struct phy_device *phy; -int phyaddr;u32 max_speed;void *descs;int tx_desc_idx, rx_desc_idx;
@@ -1813,7 +1812,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)pr_warn ("No phy clock provided %d" , ret); - eqos->phyaddr =-1 ; ret =dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phandle_args);if (!ret) {
@@ -1826,9 +1824,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)pr_warn ("gpio_request_by_name(phy reset) not provided %d" , ret); - - eqos->phyaddr =ofnode_read_u32_default (phandle_args.node, -"reg" ,-1 ); }debug ("%s: OK\n" , __func__);
Signature · 1 line
2.25.1
Re: [PATCH v3 4/6] net: dwc_eth_qos: remove the field phyaddr of the struct eqos_priv
Quoted 52 lines · Patrick Delaunay
Since the commit commit
6a895d039ba7("net: Update eQos driver and FEC driver to use eth phy interfaces") the field phyaddr of driver private data structeqos_privis no more used ineqos_start()for thephy_connect()parameter.Now this variable is only initialized in
eqos_probe_resources_stm32()it can be removed.Reviewed-by Ramon Fried <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
(no changes since v2)
Changes in v2:
- remove unused element in the structeqos_priv(NEW)drivers/net/dwc_eth_qos.c | 5 ----- 1 file changed, 5 deletions(-)drivers/net/dwc_eth_qos.c +0
-6@@ -307,7 +307,6 @@ struct eqos_priv {struct clk clk_slave_bus;struct mii_dev *mii;struct phy_device *phy; -int phyaddr;u32 max_speed;void *descs;int tx_desc_idx, rx_desc_idx;@@ -1813,7 +1812,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)pr_warn ("No phy clock provided %d" , ret); - eqos->phyaddr =-1 ; ret =dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , &phandle_args);if (!ret) {@@ -1826,9 +1824,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)pr_warn ("gpio_request_by_name(phy reset) not provided %d" , ret); - - eqos->phyaddr =ofnode_read_u32_default (phandle_args.node, -"reg" ,-1 ); }debug ("%s: OK\n" , __func__); --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.
PATCH v3 5/6 net: dwc_eth_qos: use generic ethernet phy for stm32 variant
In reply to Patrick DelaunayUse the generic ethernet phy which already manages the correct binding for gpio reset, including the assert an deassert delays.
---
(no changes since v2)
Changes in v2:
- use generic ethernet phy for stm32 variant, this patch is a REWORK of previous serie: the device parsing is done in eth-phy driver and the gpio support is removed in stm32 variant: eqos_start/stop_resets_stm32 and eqos_probe_resources_stm32.
drivers/net/Kconfig | 1 + drivers/net/dwc_eth_qos.c | 50 --------------------------------------- 2 files changed, 1 insertion(+), 50 deletions(-)
drivers/net/Kconfig +1 -0
@@ -206,6 +206,7 @@ config DWC_ETH_QOS_IMX config DWC_ETH_QOS_STM32 bool "Synopsys DWC Ethernet QOS device support for STM32" depends on DWC_ETH_QOS + select DM_ETH_PHY default y if ARCH_STM32MP help The Synopsys Designware Ethernet QOS IP block with the specific
drivers/net/dwc_eth_qos.c +0 -50
74 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 5/6] net: dwc_eth_qos: use generic ethernet phy for stm32 variant
Quoted 115 lines · Patrick Delaunay
Use the generic ethernet phy which already manages the correct binding for gpio reset, including the assert an deassert delays.
Reviewed-by Ramon Fried <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
(no changes since v2)
Changes in v2:
- use generic ethernet phy for stm32 variant, this patch is a REWORK of previous serie: the device parsing is done in eth-phy driver and the gpio support is removed in stm32 variant: eqos_start/stop_resets_stm32 andeqos_probe_resources_stm32.drivers/net/Kconfig | 1 + drivers/net/dwc_eth_qos.c | 50 --------------------------------------- 2 files changed, 1 insertion(+), 50 deletions(-)drivers/net/Kconfig +1
-0@@ -206,6 +206,7 @@ config DWC_ETH_QOS_IMX config DWC_ETH_QOS_STM32 bool "Synopsys DWC Ethernet QOS device support for STM32" depends on DWC_ETH_QOS + select DM_ETH_PHY default y if ARCH_STM32MP help The Synopsys Designware Ethernet QOS IP block with the specificdrivers/net/dwc_eth_qos.c +0
-51@@ -696,29 +696,6 @@ static int eqos_start_resets_tegra186(struct udevice *dev)static int eqos_start_resets_stm32 (struct udevice *dev) { -struct eqos_priv *eqos =dev_get_priv (dev); -int ret; - -debug ("%s(dev=%p):\n" , __func__, dev); -if (dm_gpio_is_valid (&eqos->phy_reset_gpio)) { - ret =dm_gpio_set_value (&eqos->phy_reset_gpio,1 ); -if (ret <0 ) { -pr_err ("dm_gpio_set_value(phy_reset, assert) failed: %d" , - ret); -return ret; - } - -udelay (2 ); - - ret =dm_gpio_set_value (&eqos->phy_reset_gpio,0 ); -if (ret <0 ) { -pr_err ("dm_gpio_set_value(phy_reset, deassert) failed: %d" , - ret); -return ret; - } - } -debug ("%s: OK\n" , __func__); -return 0 ; }@@ -739,18 +716,6 @@ static int eqos_stop_resets_tegra186(struct udevice *dev)static int eqos_stop_resets_stm32 (struct udevice *dev) { -struct eqos_priv *eqos =dev_get_priv (dev); -int ret; - -if (dm_gpio_is_valid (&eqos->phy_reset_gpio)) { - ret =dm_gpio_set_value (&eqos->phy_reset_gpio,1 ); -if (ret <0 ) { -pr_err ("dm_gpio_set_value(phy_reset, assert) failed: %d" , - ret); -return ret; - } - } -return 0 ; }@@ -1772,7 +1737,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)struct eqos_priv *eqos =dev_get_priv (dev);int ret;phy_interface_t interface; -struct ofnode_phandle_args phandle_args;debug ("%s(dev=%p):\n" , __func__, dev);@@ -1812,20 +1776,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)pr_warn ("No phy clock provided %d" , ret); - ret =dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , - &phandle_args); -if (!ret) { -/* search "reset-gpios" in phy node */ - ret =gpio_request_by_name_nodev (phandle_args.node, -"reset-gpios" ,0 , - &eqos->phy_reset_gpio, -GPIOD_IS_OUT | -GPIOD_IS_OUT_ACTIVE ); -if (ret) -pr_warn ("gpio_request_by_name(phy reset) not provided %d" , - ret); - } -debug ("%s: OK\n" , __func__);return 0 ; --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.
PATCH v3 6/6 net: dwc: add a common empty ops eqos_null_ops
In reply to Patrick DelaunayAdd a common empty ops: eqos_null_ops() to remove the duplicated empty functions and reduce the driver size for stm32 and imx config.
This patch also aligns the prototype of ops 'eqos_stop_clks' with other eqos ops by adding return value.
---
(no changes since v2)
Changes in v2:
- cleanup ops by adding a common null ops (NEW)
drivers/net/dwc_eth_qos.c | 97 +++++++++------------------------------ 1 file changed, 22 insertions(+), 75 deletions(-)
drivers/net/dwc_eth_qos.c +22 -75
@@ -281,7 +281,7 @@ struct eqos_ops {int (*eqos_remove_resources)(struct udevice *dev);int (*eqos_stop_resets)(struct udevice *dev);int (*eqos_start_resets)(struct udevice *dev); -void (*eqos_stop_clks)(struct udevice *dev); +int (*eqos_stop_clks)(struct udevice *dev);int (*eqos_start_clks)(struct udevice *dev);int (*eqos_calibrate_pads)(struct udevice *dev);int (*eqos_disable_calibration)(struct udevice *dev);
@@ -613,12 +613,7 @@ err:#endif } -static int eqos_start_clks_imx (struct udevice *dev) -{ -return 0 ; -} - -static void eqos_stop_clks_tegra186 (struct udevice *dev) +static int eqos_stop_clks_tegra186 (struct udevice *dev) {#ifdef CONFIG_CLK struct eqos_priv *eqos =dev_get_priv (dev);
@@ -633,9 +628,10 @@ static void eqos_stop_clks_tegra186(struct udevice *dev)#endif debug ("%s: OK\n" , __func__); +return 0 ; } -static void eqos_stop_clks_stm32 (struct udevice *dev) +static int eqos_stop_clks_stm32 (struct udevice *dev) {#ifdef CONFIG_CLK struct eqos_priv *eqos =dev_get_priv (dev);
@@ -648,11 +644,7 @@ static void eqos_stop_clks_stm32(struct udevice *dev)#endif debug ("%s: OK\n" , __func__); -} - -static void eqos_stop_clks_imx (struct udevice *dev) -{ -/* empty */ +return 0 ; }static int eqos_start_resets_tegra186 (struct udevice *dev)
@@ -694,16 +686,6 @@ static int eqos_start_resets_tegra186(struct udevice *dev)return 0 ; } -static int eqos_start_resets_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_start_resets_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_stop_resets_tegra186 (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -714,16 +696,6 @@ static int eqos_stop_resets_tegra186(struct udevice *dev)return 0 ; } -static int eqos_stop_resets_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_stop_resets_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_calibrate_pads_tegra186 (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -812,26 +784,6 @@ static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev)return imx_get_eqos_csr_clk (); } -static int eqos_calibrate_pads_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_calibrate_pads_imx (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_disable_calibration_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_disable_calibration_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_set_full_duplex (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -928,11 +880,6 @@ static int eqos_set_tx_clk_speed_tegra186(struct udevice *dev)return 0 ; } -static int eqos_set_tx_clk_speed_stm32 (struct udevice *dev) -{ -return 0 ; -} -static int eqos_set_tx_clk_speed_imx (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -1881,11 +1828,6 @@ static int eqos_remove_resources_stm32(struct udevice *dev)return 0 ; } -static int eqos_remove_resources_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_probe (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);
@@ -1974,6 +1916,11 @@ static int eqos_remove(struct udevice *dev)return 0 ; } +static int eqos_null_ops (struct udevice *dev) +{ +return 0 ; +} +static const struct eth_ops eqos_ops = { .start = eqos_start, .stop = eqos_stop,
@@ -2019,13 +1966,13 @@ static struct eqos_ops eqos_stm32_ops = { .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_stm32, .eqos_remove_resources = eqos_remove_resources_stm32, - .eqos_stop_resets = eqos_stop_resets_stm32, - .eqos_start_resets = eqos_start_resets_stm32, + .eqos_stop_resets = eqos_null_ops, + .eqos_start_resets = eqos_null_ops, .eqos_stop_clks = eqos_stop_clks_stm32, .eqos_start_clks = eqos_start_clks_stm32, - .eqos_calibrate_pads = eqos_calibrate_pads_stm32, - .eqos_disable_calibration = eqos_disable_calibration_stm32, - .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_stm32, + .eqos_calibrate_pads = eqos_null_ops, + .eqos_disable_calibration = eqos_null_ops, + .eqos_set_tx_clk_speed = eqos_null_ops, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32 };
@@ -2046,13 +1993,13 @@ static struct eqos_ops eqos_imx_ops = { .eqos_inval_buffer = eqos_inval_buffer_generic, .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_imx, - .eqos_remove_resources = eqos_remove_resources_imx, - .eqos_stop_resets = eqos_stop_resets_imx, - .eqos_start_resets = eqos_start_resets_imx, - .eqos_stop_clks = eqos_stop_clks_imx, - .eqos_start_clks = eqos_start_clks_imx, - .eqos_calibrate_pads = eqos_calibrate_pads_imx, - .eqos_disable_calibration = eqos_disable_calibration_imx, + .eqos_remove_resources = eqos_null_ops, + .eqos_stop_resets = eqos_null_ops, + .eqos_start_resets = eqos_null_ops, + .eqos_stop_clks = eqos_null_ops, + .eqos_start_clks = eqos_null_ops, + .eqos_calibrate_pads = eqos_null_ops, + .eqos_disable_calibration = eqos_null_ops, .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx };
Signature · 1 line
2.25.1
Re: [PATCH v3 6/6] net: dwc: add a common empty ops eqos_null_ops
Quoted 209 lines · Patrick Delaunay
Add a common empty ops:
eqos_null_ops()to remove the duplicated empty functions and reduce the driver size for stm32 and imx config.This patch also aligns the prototype of ops '
eqos_stop_clks' with other eqos ops by adding return value.Reviewed-by Ramon Fried <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
(no changes since v2)
Changes in v2:
- cleanup ops by adding a common null ops (NEW)drivers/net/dwc_eth_qos.c | 97 +++++++++------------------------------ 1 file changed, 22 insertions(+), 75 deletions(-)drivers/net/dwc_eth_qos.c +22
-76@@ -281,7 +281,7 @@ struct eqos_ops {int (*eqos_remove_resources)(struct udevice *dev);int (*eqos_stop_resets)(struct udevice *dev);int (*eqos_start_resets)(struct udevice *dev); -void (*eqos_stop_clks)(struct udevice *dev); +int (*eqos_stop_clks)(struct udevice *dev);int (*eqos_start_clks)(struct udevice *dev);int (*eqos_calibrate_pads)(struct udevice *dev);int (*eqos_disable_calibration)(struct udevice *dev);@@ -613,12 +613,7 @@ err:#endif } -static int eqos_start_clks_imx (struct udevice *dev) -{ -return 0 ; -} - -static void eqos_stop_clks_tegra186 (struct udevice *dev) +static int eqos_stop_clks_tegra186 (struct udevice *dev) {#ifdef CONFIG_CLK struct eqos_priv *eqos =dev_get_priv (dev);@@ -633,9 +628,10 @@ static void eqos_stop_clks_tegra186(struct udevice *dev)#endif debug ("%s: OK\n" , __func__); +return 0 ; } -static void eqos_stop_clks_stm32 (struct udevice *dev) +static int eqos_stop_clks_stm32 (struct udevice *dev) {#ifdef CONFIG_CLK struct eqos_priv *eqos =dev_get_priv (dev);@@ -648,11 +644,7 @@ static void eqos_stop_clks_stm32(struct udevice *dev)#endif debug ("%s: OK\n" , __func__); -} - -static void eqos_stop_clks_imx (struct udevice *dev) -{ -/* empty */ +return 0 ; }static int eqos_start_resets_tegra186 (struct udevice *dev)@@ -694,16 +686,6 @@ static int eqos_start_resets_tegra186(struct udevice *dev)return 0 ; } -static int eqos_start_resets_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_start_resets_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_stop_resets_tegra186 (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);@@ -714,16 +696,6 @@ static int eqos_stop_resets_tegra186(struct udevice *dev)return 0 ; } -static int eqos_stop_resets_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_stop_resets_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_calibrate_pads_tegra186 (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);@@ -812,26 +784,6 @@ static ulong eqos_get_tick_clk_rate_imx(struct udevice *dev)return imx_get_eqos_csr_clk (); } -static int eqos_calibrate_pads_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_calibrate_pads_imx (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_disable_calibration_stm32 (struct udevice *dev) -{ -return 0 ; -} - -static int eqos_disable_calibration_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_set_full_duplex (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);@@ -928,11 +880,6 @@ static int eqos_set_tx_clk_speed_tegra186(struct udevice *dev)return 0 ; } -static int eqos_set_tx_clk_speed_stm32 (struct udevice *dev) -{ -return 0 ; -} -static int eqos_set_tx_clk_speed_imx (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);@@ -1881,11 +1828,6 @@ static int eqos_remove_resources_stm32(struct udevice *dev)return 0 ; } -static int eqos_remove_resources_imx (struct udevice *dev) -{ -return 0 ; -} -static int eqos_probe (struct udevice *dev) {struct eqos_priv *eqos =dev_get_priv (dev);@@ -1974,6 +1916,11 @@ static int eqos_remove(struct udevice *dev)return 0 ; } +static int eqos_null_ops (struct udevice *dev) +{ +return 0 ; +} +static const struct eth_ops eqos_ops = { .start = eqos_start, .stop = eqos_stop,@@ -2019,13 +1966,13 @@ static struct eqos_ops eqos_stm32_ops = { .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_stm32, .eqos_remove_resources = eqos_remove_resources_stm32, - .eqos_stop_resets = eqos_stop_resets_stm32, - .eqos_start_resets = eqos_start_resets_stm32, + .eqos_stop_resets = eqos_null_ops, + .eqos_start_resets = eqos_null_ops, .eqos_stop_clks = eqos_stop_clks_stm32, .eqos_start_clks = eqos_start_clks_stm32, - .eqos_calibrate_pads = eqos_calibrate_pads_stm32, - .eqos_disable_calibration = eqos_disable_calibration_stm32, - .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_stm32, + .eqos_calibrate_pads = eqos_null_ops, + .eqos_disable_calibration = eqos_null_ops, + .eqos_set_tx_clk_speed = eqos_null_ops, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_stm32 };@@ -2046,13 +1993,13 @@ static struct eqos_ops eqos_imx_ops = { .eqos_inval_buffer = eqos_inval_buffer_generic, .eqos_flush_buffer = eqos_flush_buffer_generic, .eqos_probe_resources = eqos_probe_resources_imx, - .eqos_remove_resources = eqos_remove_resources_imx, - .eqos_stop_resets = eqos_stop_resets_imx, - .eqos_start_resets = eqos_start_resets_imx, - .eqos_stop_clks = eqos_stop_clks_imx, - .eqos_start_clks = eqos_start_clks_imx, - .eqos_calibrate_pads = eqos_calibrate_pads_imx, - .eqos_disable_calibration = eqos_disable_calibration_imx, + .eqos_remove_resources = eqos_null_ops, + .eqos_stop_resets = eqos_null_ops, + .eqos_start_resets = eqos_null_ops, + .eqos_stop_clks = eqos_null_ops, + .eqos_start_clks = eqos_null_ops, + .eqos_calibrate_pads = eqos_null_ops, + .eqos_disable_calibration = eqos_null_ops, .eqos_set_tx_clk_speed = eqos_set_tx_clk_speed_imx, .eqos_get_tick_clk_rate = eqos_get_tick_clk_rate_imx }; --
Quoted 2 lines
2.25.1
Applied to u-boot-net/network-master
Thanks,
Ramon.