public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Keguang Zhang <keguang.zhang@gmail.com>
Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
	Lee Jones <lee@kernel.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	Serge Semin <Sergey.Semin@baikalelectronics.ru>
Subject: Re: [PATCH 4/5] net: stmmac: Add glue layer for Loongson-1 SoC
Date: Sun, 13 Aug 2023 20:24:15 +0200	[thread overview]
Message-ID: <ZNkfz1yKD90XmTFL@vergenet.net> (raw)
In-Reply-To: <20230812151135.1028780-5-keguang.zhang@gmail.com>

On Sat, Aug 12, 2023 at 11:11:34PM +0800, Keguang Zhang wrote:
> This glue driver is created based on the arch-code
> implemented earlier with the platform-specific settings.
> 
> Use syscon for SYSCON register access.
> 
> Partialy based on the previous work by Serge Semin.
> 
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>

...

Hi Keguang Zhang,

some minor feedback from my side.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson1.c

...

> +const struct reg_field ls1b_dwmac_syscon_regfields[] = {
> +	[GMAC1_USE_UART1]	= REG_FIELD(LS1X_SYSCON0, 4, 4),
> +	[GMAC1_USE_UART0]	= REG_FIELD(LS1X_SYSCON0, 3, 3),
> +	[GMAC1_SHUT]		= REG_FIELD(LS1X_SYSCON1, 13, 13),
> +	[GMAC0_SHUT]		= REG_FIELD(LS1X_SYSCON1, 12, 12),
> +	[GMAC1_USE_TXCLK]	= REG_FIELD(LS1X_SYSCON1, 3, 3),
> +	[GMAC0_USE_TXCLK]	= REG_FIELD(LS1X_SYSCON1, 2, 2),
> +	[GMAC1_USE_PWM23]	= REG_FIELD(LS1X_SYSCON1, 1, 1),
> +	[GMAC0_USE_PWM01]	= REG_FIELD(LS1X_SYSCON1, 0, 0)
> +};

nit: Perhaps ls1b_dwmac_syscon_regfields should be static.

> +
> +const struct reg_field ls1c_dwmac_syscon_regfields[] = {
> +	[GMAC_SHUT]		= REG_FIELD(LS1X_SYSCON0, 6, 6),
> +	[PHY_INTF_SELI]		= REG_FIELD(LS1X_SYSCON1, 28, 30)
> +};

Likewise, perhaps ls1c_dwmac_syscon_regfields should be static.

...

> +static const struct of_device_id ls1x_dwmac_syscon_match[] = {
> +	{ .compatible = "loongson,ls1b-syscon", .data = &ls1b_dwmac_syscon },
> +	{ .compatible = "loongson,ls1c-syscon", .data = &ls1c_dwmac_syscon },
> +	{ }
> +};o

I am seeing a warning about ls1x_dwmac_syscon_match being unused.
I think this is due to CONFIG_OF being unset.

> +
> +static int ls1x_dwmac_probe(struct platform_device *pdev)
> +{
> +	struct plat_stmmacenet_data *plat_dat;
> +	struct stmmac_resources stmmac_res;
> +	struct device_node *syscon_np;
> +	const struct of_device_id *match;
> +	struct regmap *regmap;
> +	struct ls1x_dwmac *dwmac;
> +	const struct ls1x_dwmac_syscon *syscon;
> +	size_t size;
> +	int ret;
> +
> +	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
> +	if (ret)
> +		return ret;
> +
> +	/* Probe syscon */
> +	syscon_np = of_parse_phandle(pdev->dev.of_node, "syscon", 0);
> +	if (!syscon_np)
> +		return -ENODEV;
> +
> +	match = of_match_node(ls1x_dwmac_syscon_match, syscon_np);
> +	if (!match) {
> +		of_node_put(syscon_np);
> +		return -EINVAL;
> +	}
> +	syscon = (const struct ls1x_dwmac_syscon *)match->data;
> +
> +	regmap = syscon_node_to_regmap(syscon_np);
> +	of_node_put(syscon_np);
> +	if (IS_ERR(regmap)) {
> +		ret = PTR_ERR(regmap);
> +		dev_err(&pdev->dev, "Unable to map syscon: %d\n", ret);
> +		return ret;
> +	}
> +
> +	size = syscon->nr_reg_fields * sizeof(struct regmap_field *);
> +	dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac) + size, GFP_KERNEL);
> +	if (!dwmac)
> +		return -ENOMEM;
> +
> +	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);
> +	}
> +
> +	plat_dat->bsp_priv = dwmac;
> +	plat_dat->init = ls1x_dwmac_init;
> +	dwmac->dev = &pdev->dev;
> +	dwmac->plat_dat = plat_dat;
> +	dwmac->syscon = syscon;
> +	dwmac->regmap = regmap;
> +
> +	ret = stmmac_pltfr_probe(pdev, plat_dat, &stmmac_res);
> +	if (ret)
> +		goto err_remove_config_dt;
> +
> +	return 0;
> +
> +err_remove_config_dt:
> +	if (pdev->dev.of_node)
> +		stmmac_remove_config_dt(pdev, plat_dat);
> +
> +	return ret;
> +}

...

  parent reply	other threads:[~2023-08-13 18:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-12 15:11 [PATCH 0/5] Move Loongson1 MAC arch-code to the driver dir Keguang Zhang
2023-08-12 15:11 ` [PATCH 1/5] MIPS: loongson32: Remove Loongson1 MAC arch-code Keguang Zhang
2023-08-12 15:11 ` [PATCH 2/5] dt-bindings: mfd: syscon: Add compatibles for Loongson-1 syscon Keguang Zhang
2023-08-14 19:06   ` Krzysztof Kozlowski
2023-08-12 15:11 ` [PATCH 3/5] dt-bindings: net: Add Loongson-1 DWMAC glue layer Keguang Zhang
2023-08-14 19:11   ` Krzysztof Kozlowski
2023-08-16 12:54   ` Serge Semin
2023-08-18 10:42     ` Keguang Zhang
2023-08-18 13:48       ` Serge Semin
2023-08-21 13:13         ` Keguang Zhang
2023-08-12 15:11 ` [PATCH 4/5] net: stmmac: Add glue layer for Loongson-1 SoC Keguang Zhang
2023-08-12 21:30   ` kernel test robot
2023-08-13  8:28   ` kernel test robot
2023-08-13 18:24   ` Simon Horman [this message]
2023-08-14 10:50     ` Keguang Zhang
2023-08-16 13:30   ` Serge Semin
2023-08-18 12:37     ` Keguang Zhang
2023-08-18 16:19       ` Serge Semin
2023-08-21 13:24         ` Keguang Zhang
2023-08-21 14:16           ` Serge Semin
2023-08-22  7:58             ` Keguang Zhang
2023-08-22 10:53               ` Serge Semin
2023-08-22 12:09                 ` Keguang Zhang
2023-08-22 14:20                   ` Serge Semin
2023-08-12 15:11 ` [PATCH 5/5] MAINTAINERS: Add entry for Loongson-1 DWMAC Keguang Zhang
2023-08-14 19:16   ` Krzysztof Kozlowski
2023-08-13 15:24 ` [PATCH 0/5] Move Loongson1 MAC arch-code to the driver dir Andrew Lunn
2023-08-14  2:39   ` Keguang Zhang

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=ZNkfz1yKD90XmTFL@vergenet.net \
    --to=horms@kernel.org \
    --cc=Sergey.Semin@baikalelectronics.ru \
    --cc=alexandre.torgue@foss.st.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=joabreu@synopsys.com \
    --cc=keguang.zhang@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=peppe.cavallaro@st.com \
    --cc=robh+dt@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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