[PATCH v1 3/9] net: add DSA framework to support basic switch functionality

Oleksij Rempel linux at rempel-privat.de
Fri Mar 25 02:37:29 PDT 2022


Am 21.03.22 um 10:26 schrieb Oleksij Rempel:
> Add DSA based port multiplexing functionality for barebox. With this
> framework we will be able to use different ports of as switch
> separately.
>
> Signed-off-by: Oleksij Rempel <o.rempel at pengutronix.de>
> ---
>   drivers/net/Kconfig  |   3 +
>   drivers/net/Makefile |   1 +
>   drivers/net/dsa.c    | 385 +++++++++++++++++++++++++++++++++++++++++++
>   include/dsa.h        |  94 +++++++++++
>   4 files changed, 483 insertions(+)
>   create mode 100644 drivers/net/dsa.c
>   create mode 100644 include/dsa.h
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index b583299a44..419f8c515d 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -17,6 +17,9 @@ config HAS_MACB
>   config PHYLIB
>   	bool
>
> +config DSA
> +	bool
> +
>   menu "Network drivers"
>   	depends on NET
>
> diff --git a/drivers/net/Makefile b/drivers/net/Makefile
> index 563dfdfd9e..ef3513a6b0 100644
> --- a/drivers/net/Makefile
> +++ b/drivers/net/Makefile
> @@ -1,4 +1,5 @@
>   # SPDX-License-Identifier: GPL-2.0-only
> +obj-$(CONFIG_DSA)			+= dsa.o
>   obj-$(CONFIG_PHYLIB)			+= phy/
>   obj-$(CONFIG_NET_USB)			+= usb/
>
> diff --git a/drivers/net/dsa.c b/drivers/net/dsa.c
> new file mode 100644
> index 0000000000..a9e3563b9b
> --- /dev/null
> +++ b/drivers/net/dsa.c
> @@ -0,0 +1,385 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +
> +#include <common.h>
> +#include <dma.h>
> +#include <dsa.h>
> +#include <of_net.h>
> +
> +static int dsa_port_probe(struct eth_device *edev)
> +{
> +	struct dsa_port *dp = edev->priv;
> +	struct dsa_switch *ds = dp->ds;
> +	const struct dsa_ops *ops = ds->ops;
> +	phy_interface_t interface;
> +	int ret;
> +
> +	interface = of_get_phy_mode(dp->dev.device_node);
> +	ret = phy_device_connect(edev, NULL, 0, NULL, 0, interface);
> +	if (ret)
> +		return ret;
> +
> +	if (ops->port_probe) {
> +		ret = ops->port_probe(dp, dp->index, dp->edev.phydev);
> +		if (ret)
> +			return ret;
> +	}

The probe part should be reworked to enable CLK for RMII PHYs early.

--
Regards,
Oleksij



More information about the barebox mailing list