linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yanhong wang <yanhong.wang@starfivetech.com>
To: Emil Renner Berthing <emil.renner.berthing@canonical.com>
Cc: <linux-riscv@lists.infradead.org>, <netdev@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Emil Renner Berthing <kernel@esmil.dk>,
	Richard Cochran <richardcochran@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Peter Geis <pgwipeout@gmail.com>
Subject: Re: [PATCH v1 5/7] net: stmmac: Add StarFive dwmac supoort
Date: Fri, 9 Dec 2022 10:03:43 +0800	[thread overview]
Message-ID: <42da7b33-d3eb-b546-f262-b4485213c028@starfivetech.com> (raw)
In-Reply-To: <CAJM55Z9bdpxLsKOM8UhE=b5Z2uPzL227N1-x6d8AuvkZHRajqA@mail.gmail.com>



On 2022/12/7 22:16, Emil Renner Berthing wrote:
> Hi Yanhong,
> 
> Thanks for submitting this. Again please don't change the author of
> the commits you cherry-picked from my tree. This is why we have the
> Co-developed-by: tag so you can mark that you added or in this case
> removed code.
> I'd hoped you would still include the support for the JH7100 though.
>

Hi Emil,

  Thank you for your suggestion. If the dwmac-starfive-plat driver supports JH7100 and JH7110, the dt-binding calls "starfive,jh71x0-dwmac.yaml", is this ok?

 
> Also you seem to have changed the name of some of the functions.
> Please at least keep the prefix consistent if you do that. Now it's a
> mix of dwmac_starfive_, starfive_eth_ and starfive_eth_plat.
> 

I will named all the functions with starfive_eth_plat prefix in the next version.

> On Thu, 1 Dec 2022 at 10:07, Yanhong Wang <yanhong.wang@starfivetech.com> wrote:
>>
>> This adds StarFive dwmac driver support on the StarFive JH7110 SoCs.
>>
>> Signed-off-by: Yanhong Wang <yanhong.wang@starfivetech.com>
>> ---
>>  MAINTAINERS                                   |   1 +
>>  drivers/net/ethernet/stmicro/stmmac/Kconfig   |  11 ++
>>  drivers/net/ethernet/stmicro/stmmac/Makefile  |   1 +
>>  .../stmicro/stmmac/dwmac-starfive-plat.c      | 147 ++++++++++++++++++
>>  4 files changed, 160 insertions(+)
>>  create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 7eaaec8d3b96..36cb00cf860b 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -19610,6 +19610,7 @@ STARFIVE DWMAC GLUE LAYER
>>  M:     Yanhong Wang <yanhong.wang@starfivetech.com>
>>  S:     Maintained
>>  F:     Documentation/devicetree/bindings/net/starfive,dwmac-plat.yaml
>> +F:     drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c
>>
>>  STARFIVE PINCTRL DRIVER
>>  M:     Emil Renner Berthing <kernel@esmil.dk>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> index 31ff35174034..1e29cd3770b9 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig
>> @@ -235,6 +235,17 @@ config DWMAC_INTEL_PLAT
>>           the stmmac device driver. This driver is used for the Intel Keem Bay
>>           SoC.
>>
>> +config DWMAC_STARFIVE_PLAT
> 
> Why did you add the _PLAT suffix? None of the other SoC wrappers have this..
> 
>> +       tristate "StarFive dwmac support"
>> +       depends on OF && COMMON_CLK
>> +       depends on STMMAC_ETH
>> +       default SOC_STARFIVE
>> +       help
>> +         Support for ethernet controllers on StarFive RISC-V SoCs
>> +
>> +         This selects the StarFive platform specific glue layer support for
>> +         the stmmac device driver. This driver is used for StarFive RISC-V SoCs.
>> +
>>  config DWMAC_VISCONTI
>>         tristate "Toshiba Visconti DWMAC support"
>>         default ARCH_VISCONTI
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
>> index d4e12e9ace4f..a63ab0ab5071 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/Makefile
>> +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
>> @@ -31,6 +31,7 @@ obj-$(CONFIG_DWMAC_DWC_QOS_ETH)       += dwmac-dwc-qos-eth.o
>>  obj-$(CONFIG_DWMAC_INTEL_PLAT) += dwmac-intel-plat.o
>>  obj-$(CONFIG_DWMAC_GENERIC)    += dwmac-generic.o
>>  obj-$(CONFIG_DWMAC_IMX8)       += dwmac-imx.o
>> +obj-$(CONFIG_DWMAC_STARFIVE_PLAT)      += dwmac-starfive-plat.o
>>  obj-$(CONFIG_DWMAC_VISCONTI)   += dwmac-visconti.o
>>  stmmac-platform-objs:= stmmac_platform.o
>>  dwmac-altr-socfpga-objs := altr_tse_pcs.o dwmac-socfpga.o
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c
>> new file mode 100644
>> index 000000000000..8fbf584d4e19
>> --- /dev/null
>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive-plat.c
>> @@ -0,0 +1,147 @@
>> +// SPDX-License-Identifier: GPL-2.0+
>> +/*
>> + * StarFive DWMAC platform driver
>> + *
>> + * Copyright(C) 2022 StarFive Technology Co., Ltd.
> 
> Hmm.. where did my copyright go?
> 
>> + *
>> + */
>> +
>> +#include <linux/of_device.h>
>> +#include "stmmac_platform.h"
>> +
>> +struct starfive_dwmac {
>> +       struct device *dev;
>> +       struct clk *clk_tx;
>> +       struct clk *clk_gtx;
>> +       struct clk *clk_gtxc;
>> +};
>> +
>> +static void starfive_eth_fix_mac_speed(void *priv, unsigned int speed)
>> +{
>> +       struct starfive_dwmac *dwmac = priv;
>> +       unsigned long rate;
>> +       int err;
>> +
>> +       switch (speed) {
>> +       case SPEED_1000:
>> +               rate = 125000000;
>> +               break;
>> +       case SPEED_100:
>> +               rate = 25000000;
>> +               break;
>> +       case SPEED_10:
>> +               rate = 2500000;
>> +               break;
>> +       default:
>> +               dev_err(dwmac->dev, "invalid speed %u\n", speed);
>> +               return;
>> +       }
>> +
>> +       err = clk_set_rate(dwmac->clk_gtx, rate);
>> +       if (err)
>> +               dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
>> +}
>> +
>> +static void dwmac_starfive_clk_disable(void *clk)
>> +{
>> +       clk_disable_unprepare(clk);
>> +}
>> +
>> +static int starfive_eth_plat_probe(struct platform_device *pdev)
>> +{
>> +       struct plat_stmmacenet_data *plat_dat;
>> +       struct stmmac_resources stmmac_res;
>> +       struct starfive_dwmac *dwmac;
>> +       int err;
>> +
>> +       err = stmmac_get_platform_resources(pdev, &stmmac_res);
>> +       if (err)
>> +               return err;
>> +
>> +       plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
>> +       if (IS_ERR(plat_dat)) {
>> +               dev_err(&pdev->dev, "dt configuration failed\n");
>> +               return PTR_ERR(plat_dat);
>> +       }
>> +
>> +       dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
>> +       if (!dwmac)
>> +               return -ENOMEM;
>> +
>> +       dwmac->clk_tx = devm_clk_get(&pdev->dev, "tx");
>> +       if (IS_ERR(dwmac->clk_tx))
>> +               return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
>> +                                               "error getting tx clock\n");
>> +
>> +       err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable,
>> +                             dwmac->clk_tx);
>> +       if (err)
>> +               return err;
>> +
>> +       err = clk_prepare_enable(dwmac->clk_tx);
>> +       if (err)
>> +               return dev_err_probe(&pdev->dev, err, "error enabling tx clock\n");
>> +
>> +       dwmac->clk_gtx = devm_clk_get(&pdev->dev, "gtx");
>> +       if (IS_ERR(dwmac->clk_gtx))
>> +               return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_gtx),
>> +                                               "error getting gtx clock\n");
>> +
>> +       err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable,
>> +                             dwmac->clk_gtx);
>> +       if (err)
>> +               return err;
>> +
>> +       err = clk_prepare_enable(dwmac->clk_gtx);
>> +       if (err)
>> +               return dev_err_probe(&pdev->dev, err, "error enabling gtx clock\n");
> 
> I think the 3 calls above can be simplified to devm_clk_get_enabled().
> 
>> +       dwmac->clk_gtxc = devm_clk_get(&pdev->dev, "gtxc");
>> +       if (IS_ERR(dwmac->clk_gtxc))
>> +               return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_gtxc),
>> +                                               "error getting gtxc clock\n");
>> +
>> +       err = devm_add_action(&pdev->dev, dwmac_starfive_clk_disable,
>> +                             dwmac->clk_gtxc);
>> +       if (err)
>> +               return err;
>> +
>> +       err = clk_prepare_enable(dwmac->clk_gtxc);
>> +       if (err)
>> +               return dev_err_probe(&pdev->dev, err, "error enabling gtxc clock\n");
> 
> Same here.
> 
>> +
>> +       dwmac->dev = &pdev->dev;
>> +       plat_dat->fix_mac_speed = starfive_eth_fix_mac_speed;
>> +       plat_dat->init = NULL;
>> +       plat_dat->bsp_priv = dwmac;
>> +       plat_dat->dma_cfg->dche = true;
>> +
>> +       err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
>> +       if (err) {
>> +               stmmac_remove_config_dt(pdev, plat_dat);
>> +               return err;
>> +       }
>> +
>> +       return 0;
>> +}
>> +
>> +static const struct of_device_id starfive_eth_plat_match[] = {
>> +       {.compatible = "starfive,dwmac"},
>> +       { }
>> +};
>> +
>> +static struct platform_driver starfive_eth_plat_driver = {
>> +       .probe  = starfive_eth_plat_probe,
>> +       .remove = stmmac_pltfr_remove,
>> +       .driver = {
>> +               .name = "starfive-eth-plat",
>> +               .pm = &stmmac_pltfr_pm_ops,
>> +               .of_match_table = starfive_eth_plat_match,
>> +       },
>> +};
>> +
>> +module_platform_driver(starfive_eth_plat_driver);
>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_DESCRIPTION("StarFive DWMAC platform driver");
> 
> Here you also seem to have removed me.
> 
>> +MODULE_AUTHOR("Yanhong Wang <yanhong.wang@starfivetech.com>");
>> --
>> 2.17.1
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2022-12-09  2:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01  9:02 [PATCH v1 0/7] Add Ethernet driver for StarFive JH7110 SoC Yanhong Wang
2022-12-01  9:02 ` [PATCH v1 1/7] dt-bindings: net: snps,dwmac: Add compatible string for dwmac-5.20 version Yanhong Wang
2022-12-01 16:18   ` Krzysztof Kozlowski
2022-12-02  2:53     ` yanhong wang
2022-12-02  8:01       ` Krzysztof Kozlowski
2022-12-07 13:56         ` Emil Renner Berthing
2022-12-08  1:34           ` yanhong wang
2022-12-01  9:02 ` [PATCH v1 2/7] net: stmmac: platform: Add snps,dwmac-5.20 IP compatible string Yanhong Wang
2022-12-07 13:58   ` Emil Renner Berthing
2022-12-08  1:42     ` yanhong wang
2022-12-09  1:59   ` Ben Dooks
2022-12-09  2:26     ` yanhong wang
2022-12-01  9:02 ` [PATCH v1 3/7] dt-bindings: net: Add bindings for StarFive dwmac Yanhong Wang
2022-12-01 13:36   ` Rob Herring
2022-12-01 16:45     ` Conor Dooley
2022-12-02 10:52       ` Krzysztof Kozlowski
2022-12-01 16:21   ` Krzysztof Kozlowski
2022-12-01 17:35     ` Conor Dooley
2022-12-01 19:32       ` Rob Herring
2022-12-02  7:16       ` yanhong wang
2022-12-02  8:02         ` Krzysztof Kozlowski
2022-12-02  7:07     ` yanhong wang
2022-12-01  9:02 ` [PATCH v1 4/7] net: phy: motorcomm: Add YT8531 phy support Yanhong Wang
2022-12-01 15:40   ` Andrew Lunn
2022-12-06  7:39     ` yanhong wang
2022-12-01  9:02 ` [PATCH v1 5/7] net: stmmac: Add StarFive dwmac supoort Yanhong Wang
2022-12-07 14:16   ` Emil Renner Berthing
2022-12-08  2:22     ` yanhong wang
2022-12-09  2:03     ` yanhong wang [this message]
2022-12-01  9:02 ` [PATCH v1 6/7] riscv: dts: starfive: jh7110: Add ethernet device node Yanhong Wang
2022-12-01 17:45   ` Conor Dooley
2022-12-02  5:53     ` yanhong wang
2022-12-01  9:02 ` [PATCH v1 7/7] riscv: dts: starfive: visionfive-v2: Add phy delay_chain configuration Yanhong Wang
2022-12-01 17:49   ` Conor Dooley
2022-12-01 19:30     ` Conor Dooley
2022-12-01 19:42       ` Andrew Lunn
2022-12-09  1:28       ` yanhong wang
2022-12-09  1:19     ` yanhong wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42da7b33-d3eb-b546-f262-b4485213c028@starfivetech.com \
    --to=yanhong.wang@starfivetech.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=emil.renner.berthing@canonical.com \
    --cc=hkallweit1@gmail.com \
    --cc=kernel@esmil.dk \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pgwipeout@gmail.com \
    --cc=richardcochran@gmail.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).