[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a64eb154-30b9-4321-b3ef-2bcb1e861800@lunn.ch>
Date: Thu, 26 Sep 2024 20:32:00 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Drew Fustini <dfustini@...storrent.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Jose Abreu <joabreu@...opsys.com>,
Jisheng Zhang <jszhang@...nel.org>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Emil Renner Berthing <emil.renner.berthing@...onical.com>,
Drew Fustini <drew@...7.com>, Guo Ren <guoren@...nel.org>,
Fu Wei <wefu@...hat.com>, Conor Dooley <conor@...nel.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org,
linux-riscv@...ts.infradead.org
Subject: Re: [PATCH v2 2/3] net: stmmac: Add glue layer for T-HEAD TH1520 SoC
> +static int thead_dwmac_init(struct platform_device *pdev, void *priv)
> +{
> + struct thead_dwmac *dwmac = priv;
> + int ret;
> +
> + ret = thead_dwmac_set_phy_if(dwmac->plat);
> + if (ret)
> + return ret;
> +
> + ret = thead_dwmac_set_txclk_dir(dwmac->plat);
> + if (ret)
> + return ret;
> +
> + ret = regmap_write(dwmac->apb_regmap, GMAC_RXCLK_DELAY_CTRL,
> + GMAC_RXCLK_DELAY_VAL(dwmac->rx_delay));
> + if (ret)
> + return dev_err_probe(dwmac->dev, ret,
> + "failed to set GMAC RX clock delay\n");
> +
> + ret = regmap_write(dwmac->apb_regmap, GMAC_TXCLK_DELAY_CTRL,
> + GMAC_TXCLK_DELAY_VAL(dwmac->tx_delay));
> + if (ret)
> + return dev_err_probe(dwmac->dev, ret,
> + "failed to set GMAC TX clock delay\n");
> +
> + thead_dwmac_fix_speed(dwmac, SPEED_1000, 0);
Is this needed? I would expect this to be called when the PHY has link
and you know the link speed. So why set it here?
> +
> + return thead_dwmac_enable_clk(dwmac->plat);
> +}
> +
> +static int thead_dwmac_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct stmmac_resources stmmac_res;
> + struct plat_stmmacenet_data *plat;
> + struct thead_dwmac *dwmac;
> + void __iomem *apb;
> + u32 delay;
> + int ret;
> +
> + ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret,
> + "failed to get resources\n");
> +
> + plat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
> + if (IS_ERR(plat))
> + return dev_err_probe(&pdev->dev, PTR_ERR(plat),
> + "dt configuration failed\n");
> +
> + dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
> + if (!dwmac)
> + return -ENOMEM;
> +
> + /* hardware default is 0 for the rx and tx internal clock delay */
> + dwmac->rx_delay = 0;
> + dwmac->tx_delay = 0;
> +
> + /* rx and tx internal delay properties are optional */
> + if (!of_property_read_u32(np, "thead,rx-internal-delay", &delay)) {
> + if (delay > GMAC_RXCLK_DELAY_MASK)
> + dev_warn(&pdev->dev,
> + "thead,rx-internal-delay (%u) exceeds max (%lu)\n",
> + delay, GMAC_RXCLK_DELAY_MASK);
> + else
> + dwmac->rx_delay = delay;
> + }
> +
So you keep going, with an invalid value? It is better to use
dev_err() and return -EINVAL. The DT write will then correct their
error when the device fails to probe.
If you decide to keep this... I'm not sure these properties are
needed.
> +MODULE_AUTHOR("Jisheng Zhang <jszhang@...nel.org>");
Please add a second author, if you have taken over this driver.
Andrew
Powered by blists - more mailing lists