net: dwc_eth_qos: implement reset-gpios for stm32
PATCH 1/2 net: dwc_eth_qos: implement reset-gpios for stm32
From: Christophe Roullier <[email protected]>
Add management of property "reset-gpios" in the node identified by "phy-handle" to configure any GPIO used to reset the PHY.
---
drivers/net/dwc_eth_qos.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/net/dwc_eth_qos.c +53 -0
@@ -694,6 +694,29 @@ 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 ; }
@@ -709,6 +732,18 @@ 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 ; }
@@ -1604,6 +1639,7 @@ 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);
@@ -1641,6 +1677,20 @@ 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 ;
@@ -1704,6 +1754,9 @@ static int eqos_remove_resources_stm32(struct udevice *dev)if (clk_valid (&eqos->clk_ck))clk_free (&eqos->clk_ck); +if (dm_gpio_is_valid (&eqos->phy_reset_gpio)) +dm_gpio_free (dev, &eqos->phy_reset_gpio); +debug ("%s: OK\n" , __func__);return 0 ; }
Signature · 1 line
2.17.1
PATCH 2/2 net: dwc_eth_qos: implement phy reg and max-speed for stm32
Add management of property "reg" to configure @ of phy and also "max-speed" property to specify maximum speed in Mbit/s supported by the device
---
drivers/net/dwc_eth_qos.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/net/dwc_eth_qos.c +18 -1
@@ -306,6 +306,8 @@ struct eqos_priv {struct clk clk_slave_bus;struct mii_dev *mii;struct phy_device *phy; +int phyaddr; +u32 max_speed;void *descs;struct eqos_desc *tx_descs;struct eqos_desc *rx_descs;
@@ -1081,12 +1083,21 @@ static int eqos_start(struct udevice *dev)* don't need to reconnect/reconfigure again */ if (!eqos->phy) { - eqos->phy =phy_connect (eqos->mii,-1 , dev, + eqos->phy =phy_connect (eqos->mii, eqos->phyaddr, dev, eqos->config->interface (dev));if (!eqos->phy) {pr_err ("phy_connect() failed" ); goto err_stop_resets; } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + ret =phy_config (eqos->phy);if (ret <0 ) {pr_err ("phy_config() failed: %d" , ret);
@@ -1654,6 +1665,8 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)return -EINVAL ; + eqos->max_speed =dev_read_u32_default (dev,"max-speed" ,0 ); + ret =clk_get_by_name (dev,"stmmaceth" , &eqos->clk_master_bus);if (ret) {pr_err ("clk_get_by_name(master_bus) failed: %d" , ret);
@@ -1677,6 +1690,7 @@ 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) {
@@ -1689,6 +1703,9 @@ 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.17.1
PATCH 2/2 net: dwc_eth_qos: implement phy reg and max-speed for stm32
Hi
Quoted 11 lines · Patrick Delaunay
Add management of property "reg" to configure @ of phy and also "max-speed" property to specify maximum speed in Mbit/s supported by the device
Signed-off-by Christophe Roullier <[email protected]>Reviewed-by Patrick DELAUNAY <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/net/dwc_eth_qos.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
Applied to u-boot-stm/next
Thanks
Patrice
Quoted 64 lines
drivers/net/dwc_eth_qos.c +18
-1@@ -306,6 +306,8 @@ struct eqos_priv {struct clk clk_slave_bus;struct mii_dev *mii;struct phy_device *phy; +int phyaddr; +u32 max_speed;void *descs;struct eqos_desc *tx_descs;struct eqos_desc *rx_descs;@@ -1081,12 +1083,21 @@ static int eqos_start(struct udevice *dev)* don't need to reconnect/reconfigure again */ if (!eqos->phy) { - eqos->phy =phy_connect (eqos->mii,-1 , dev, + eqos->phy =phy_connect (eqos->mii, eqos->phyaddr, dev, eqos->config->interface (dev));if (!eqos->phy) {pr_err ("phy_connect() failed" ); goto err_stop_resets; } + +if (eqos->max_speed) { + ret =phy_set_supported (eqos->phy, eqos->max_speed); +if (ret) { +pr_err ("phy_set_supported() failed: %d" , ret); + goto err_shutdown_phy; + } + } + ret =phy_config (eqos->phy);if (ret <0 ) {pr_err ("phy_config() failed: %d" , ret);@@ -1654,6 +1665,8 @@ static int eqos_probe_resources_stm32(struct udevice *dev)if (ret)return -EINVAL ; + eqos->max_speed =dev_read_u32_default (dev,"max-speed" ,0 ); + ret =clk_get_by_name (dev,"stmmaceth" , &eqos->clk_master_bus);if (ret) {pr_err ("clk_get_by_name(master_bus) failed: %d" , ret);@@ -1677,6 +1690,7 @@ 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) {@@ -1689,6 +1703,9 @@ 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__);
PATCH 1/2 net: dwc_eth_qos: implement reset-gpios for stm32
In reply to Patrick DelaunayHi
Quoted 5 lines · Patrick Delaunay
From: Christophe Roullier <[email protected]>
Add management of property "reset-gpios" in the node identified by "phy-handle" to configure any GPIO used to reset the PHY.
Quoted 8 lines
Signed-off-by Christophe Roullier <[email protected]>Reviewed-by Patrice CHOTARD <[email protected]>Reviewed-by Patrick DELAUNAY <[email protected]>Signed-off-by Patrick Delaunay <[email protected]>---
drivers/net/dwc_eth_qos.c | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
Applied to u-boot-stm/next
Thanks
Patrice
Quoted 93 lines
drivers/net/dwc_eth_qos.c +53
-0@@ -694,6 +694,29 @@ 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 ; }@@ -709,6 +732,18 @@ 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 ; }@@ -1604,6 +1639,7 @@ 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);@@ -1641,6 +1677,20 @@ 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 ;@@ -1704,6 +1754,9 @@ static int eqos_remove_resources_stm32(struct udevice *dev)if (clk_valid (&eqos->clk_ck))clk_free (&eqos->clk_ck); +if (dm_gpio_is_valid (&eqos->phy_reset_gpio)) +dm_gpio_free (dev, &eqos->phy_reset_gpio); +debug ("%s: OK\n" , __func__);return 0 ; }