[U-Boot] [PATCH 2/2] net: dwc_et_qos: update weak function board_interface_eth_init

Ramon Fried rfried.dev at gmail.com
Sat Aug 3 21:08:03 UTC 2019


On Thu, Aug 1, 2019 at 12:32 PM Patrick Delaunay
<patrick.delaunay at st.com> wrote:
>
> Align the board and driver prototype for board_interface_eth_init
> to avoid execution issue (the interface_type parameter is defined
> as int or phy_interface_t).
>
> To have a generic weak function (it should be reused by other driver)
> I change the prototype to use directly udevice.
>
> This prototype is added in netdev.h to allow compilation check
> and avoid warning when compiling with W=1 on file
> board/st/stm32mp1/stm32mp1.c
>
> warning: no previous prototype for 'board_interface_eth_init'\
> [-Wmissing-prototypes]
>      int board_interface_eth_init(int interface_type, ....
>          ^~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> ---
>
>  board/st/stm32mp1/stm32mp1.c | 17 +++++++++++++----
>  drivers/net/dwc_eth_qos.c    | 16 +++-------------
>  include/netdev.h             |  3 +++
>  3 files changed, 19 insertions(+), 17 deletions(-)
>
> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
> index b99c6c0..2365dd1 100644
> --- a/board/st/stm32mp1/stm32mp1.c
> +++ b/board/st/stm32mp1/stm32mp1.c
> @@ -16,6 +16,7 @@
>  #include <misc.h>
>  #include <mtd.h>
>  #include <mtd_node.h>
> +#include <netdev.h>
>  #include <phy.h>
>  #include <reset.h>
>  #include <syscon.h>
> @@ -560,13 +561,21 @@ void board_quiesce_devices(void)
>         setup_led(LEDST_OFF);
>  }
>
> -/* board interface eth init */
> -/* this is a weak define that we are overriding */
> -int board_interface_eth_init(phy_interface_t interface_type,
> -                            bool eth_clk_sel_reg, bool eth_ref_clk_sel_reg)
> +/* eth init function : weak called in eqos driver */
> +int board_interface_eth_init(struct udevice *dev,
> +                            phy_interface_t interface_type)
>  {
>         u8 *syscfg;
>         u32 value;
> +       bool eth_clk_sel_reg = false;
> +       bool eth_ref_clk_sel_reg = false;
> +
> +       /* Gigabit Ethernet 125MHz clock selection. */
> +       eth_clk_sel_reg = dev_read_bool(dev, "st,eth_clk_sel");
> +
> +       /* Ethernet 50Mhz RMII clock selection */
> +       eth_ref_clk_sel_reg =
> +               dev_read_bool(dev, "st,eth_ref_clk_sel");
>
>         syscfg = (u8 *)syscon_get_first_range(STM32MP_SYSCON_SYSCFG);
>
> diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c
> index 6df9956..4557093 100644
> --- a/drivers/net/dwc_eth_qos.c
> +++ b/drivers/net/dwc_eth_qos.c
> @@ -1591,8 +1591,8 @@ err_free_reset_eqos:
>  }
>
>  /* board-specific Ethernet Interface initializations. */
> -__weak int board_interface_eth_init(int interface_type, bool eth_clk_sel_reg,
> -                                   bool eth_ref_clk_sel_reg)
> +__weak int board_interface_eth_init(struct udevice *dev,
> +                                   phy_interface_t interface_type)
>  {
>         return 0;
>  }
> @@ -1602,8 +1602,6 @@ static int eqos_probe_resources_stm32(struct udevice *dev)
>         struct eqos_priv *eqos = dev_get_priv(dev);
>         int ret;
>         phy_interface_t interface;
> -       bool eth_clk_sel_reg = false;
> -       bool eth_ref_clk_sel_reg = false;
>
>         debug("%s(dev=%p):\n", __func__, dev);
>
> @@ -1614,15 +1612,7 @@ static int eqos_probe_resources_stm32(struct udevice *dev)
>                 return -EINVAL;
>         }
>
> -       /* Gigabit Ethernet 125MHz clock selection. */
> -       eth_clk_sel_reg = dev_read_bool(dev, "st,eth_clk_sel");
> -
> -       /* Ethernet 50Mhz RMII clock selection */
> -       eth_ref_clk_sel_reg =
> -               dev_read_bool(dev, "st,eth_ref_clk_sel");
> -
> -       ret = board_interface_eth_init(interface, eth_clk_sel_reg,
> -                                      eth_ref_clk_sel_reg);
> +       ret = board_interface_eth_init(dev, interface);
>         if (ret)
>                 return -EINVAL;
>
> diff --git a/include/netdev.h b/include/netdev.h
> index a40c4ad..68a3fce 100644
> --- a/include/netdev.h
> +++ b/include/netdev.h
> @@ -10,6 +10,7 @@
>
>  #ifndef _NETDEV_H_
>  #define _NETDEV_H_
> +#include <phy_interface.h>
>
>  /*
>   * Board and CPU-specific initialization functions
> @@ -21,6 +22,8 @@
>   */
>
>  int board_eth_init(bd_t *bis);
> +int board_interface_eth_init(struct udevice *dev,
> +                            phy_interface_t interface_type);
>  int cpu_eth_init(bd_t *bis);
>
>  /* Driver initialization prototypes */
> --
> 2.7.4
>

why can you just write a phy driver specific to this board and hook it
to the eth
driver in the dts ?


More information about the U-Boot mailing list