[PATCH v2 4/4] net: stmmac: Add glue layer for Sophgo SG2044 SoC
Inochi Amaoto
inochiama at gmail.com
Fri Oct 25 16:27:54 PDT 2024
On Fri, Oct 25, 2024 at 04:53:07PM +0200, Alexander Lobakin wrote:
> From: Inochi Amaoto <inochiama at gmail.com>
> Date: Fri, 25 Oct 2024 09:10:00 +0800
>
> > Adds Sophgo dwmac driver support on the Sophgo SG2044 SoC.
> >
> > Signed-off-by: Inochi Amaoto <inochiama at gmail.com>
> > ---
> > drivers/net/ethernet/stmicro/stmmac/Kconfig | 11 ++
> > drivers/net/ethernet/stmicro/stmmac/Makefile | 1 +
> > .../ethernet/stmicro/stmmac/dwmac-sophgo.c | 109 ++++++++++++++++++
> > 3 files changed, 121 insertions(+)
> > create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
>
> [...]
>
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> > new file mode 100644
> > index 000000000000..8f37bcf86a73
> > --- /dev/null
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sophgo.c
> > @@ -0,0 +1,109 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Sophgo DWMAC platform driver
> > + *
> > + * Copyright (C) 2024 Inochi Amaoto <inochiama at gmail.com>
> > + *
>
> This empty line is redundant I guess?
>
> > + */
> > +
> > +#include <linux/bits.h>
> > +#include <linux/mod_devicetable.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/property.h>
> > +#include <linux/mfd/syscon.h>
> > +#include <linux/phy.h>
> > +#include <linux/regmap.h>
>
> Here should be alphabetical order.
>
Thanks, I forgot to reorder it when adding new include.
> > +
> > +#include "stmmac_platform.h"
> > +
> > +struct sophgo_dwmac {
> > + struct device *dev;
> > + struct clk *clk_tx;
> > +};
> > +
> > +static void sophgo_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
> > +{
> > + struct sophgo_dwmac *dwmac = priv;
> > + long rate;
> > + int ret;
> > +
> > + rate = rgmii_clock(speed);
> > + if (ret < 0) {
>
> Did you mean `if (rate < 0)`?
>
Yeah, it seems I forgot to modify it.
> > + dev_err(dwmac->dev, "invalid speed %u\n", speed);
> > + return;
> > + }
> > +
> > + ret = clk_set_rate(dwmac->clk_tx, rate);
> > + if (ret)
> > + dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
>
> Don't you want to print the error code here?
>
> "failed to set tx rate %lu: %pe\n", rate, ERR_PTR(ret));
>
Thanks, it is more clear now.
> > +}
> > +
> > +static int sophgo_sg2044_dwmac_init(struct platform_device *pdev,
> > + struct plat_stmmacenet_data *plat_dat,
> > + struct stmmac_resources *stmmac_res)
> > +{
> > + struct sophgo_dwmac *dwmac;
> > + int ret;
>
> Unused var.
>
> > +
> > + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> > + if (!dwmac)
> > + return -ENOMEM;
> > +
> > + dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
> > + if (IS_ERR(dwmac->clk_tx))
> > + return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
> > + "failed to get tx clock\n");
> > +
> > + dwmac->dev = &pdev->dev;
> > + plat_dat->bsp_priv = dwmac;
> > + plat_dat->flags |= STMMAC_FLAG_SPH_DISABLE;
> > + plat_dat->fix_mac_speed = sophgo_dwmac_fix_mac_speed;
> > + plat_dat->multicast_filter_bins = 0;
> > + plat_dat->unicast_filter_entries = 1;
> > +
> > + return 0;
> > +}
>
> [...]
>
> + see the build bot report.
>
> Thanks,
> Olek
Thanks, I will fix it.
Regards,
Inochi
More information about the linux-riscv
mailing list