netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: platform: use generic device api
@ 2020-01-16  0:56 Ajay Gupta
  2020-01-17  3:33 ` Chen-Yu Tsai
  2020-01-17  8:29 ` Jose Abreu
  0 siblings, 2 replies; 5+ messages in thread
From: Ajay Gupta @ 2020-01-16  0:56 UTC (permalink / raw)
  To: davem; +Cc: netdev, treding, Ajay Gupta

From: Ajay Gupta <ajayg@nvidia.com>

Use generic device api to allow reading more configuration
parameter from both DT or ACPI based devices.

Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
---
ACPI support related changes for dwc were reently queued [1]
This patch is required to read more configuration parameter
through ACPI table.

[1] https://marc.info/?l=linux-netdev&m=157661974305024&w=2

 .../ethernet/stmicro/stmmac/stmmac_platform.c | 49 +++++++++++--------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 4775f49d7f3b..0532e7258064 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -398,6 +398,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	struct device_node *np = pdev->dev.of_node;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_dma_cfg *dma_cfg;
+	struct device *dev = &pdev->dev;
 	int rc;
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
@@ -412,9 +413,9 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		*mac = NULL;
 	}
 
-	rc = of_get_phy_mode(np, &plat->phy_interface);
-	if (rc)
-		return ERR_PTR(rc);
+	plat->phy_interface = device_get_phy_mode(dev);
+	if (plat->phy_interface < 0)
+		return ERR_PTR(plat->phy_interface);
 
 	plat->interface = stmmac_of_get_mac_mode(np);
 	if (plat->interface < 0)
@@ -428,7 +429,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	plat->phylink_node = np;
 
 	/* Get max speed of operation from device tree */
-	if (of_property_read_u32(np, "max-speed", &plat->max_speed))
+	if (device_property_read_u32(dev, "max-speed", &plat->max_speed))
 		plat->max_speed = -1;
 
 	plat->bus_id = of_alias_get_id(np, "ethernet");
@@ -442,12 +443,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	 * or get clk_csr from device tree.
 	 */
 	plat->clk_csr = -1;
-	of_property_read_u32(np, "clk_csr", &plat->clk_csr);
+	device_property_read_u32(dev, "clk_csr", &plat->clk_csr);
 
 	/* "snps,phy-addr" is not a standard property. Mark it as deprecated
 	 * and warn of its use. Remove this when phy node support is added.
 	 */
-	if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
+	if (device_property_read_u32(dev, "snps,phy-addr", &plat->phy_addr)
+			== 0)
 		dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
 
 	/* To Configure PHY by using all device-tree supported properties */
@@ -455,15 +457,15 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	if (rc)
 		return ERR_PTR(rc);
 
-	of_property_read_u32(np, "tx-fifo-depth", &plat->tx_fifo_size);
+	device_property_read_u32(dev, "tx-fifo-depth", &plat->tx_fifo_size);
 
-	of_property_read_u32(np, "rx-fifo-depth", &plat->rx_fifo_size);
+	device_property_read_u32(dev, "rx-fifo-depth", &plat->rx_fifo_size);
 
 	plat->force_sf_dma_mode =
-		of_property_read_bool(np, "snps,force_sf_dma_mode");
+		device_property_read_bool(dev, "snps,force_sf_dma_mode");
 
 	plat->en_tx_lpi_clockgating =
-		of_property_read_bool(np, "snps,en-tx-lpi-clockgating");
+		device_property_read_bool(dev, "snps,en-tx-lpi-clockgating");
 
 	/* Set the maxmtu to a default of JUMBO_LEN in case the
 	 * parameter is not present in the device tree.
@@ -535,25 +537,30 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	}
 	plat->dma_cfg = dma_cfg;
 
-	of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl);
+	device_property_read_u32(dev, "snps,pbl", &dma_cfg->pbl);
 	if (!dma_cfg->pbl)
 		dma_cfg->pbl = DEFAULT_DMA_PBL;
-	of_property_read_u32(np, "snps,txpbl", &dma_cfg->txpbl);
-	of_property_read_u32(np, "snps,rxpbl", &dma_cfg->rxpbl);
-	dma_cfg->pblx8 = !of_property_read_bool(np, "snps,no-pbl-x8");
-
-	dma_cfg->aal = of_property_read_bool(np, "snps,aal");
-	dma_cfg->fixed_burst = of_property_read_bool(np, "snps,fixed-burst");
-	dma_cfg->mixed_burst = of_property_read_bool(np, "snps,mixed-burst");
-
-	plat->force_thresh_dma_mode = of_property_read_bool(np, "snps,force_thresh_dma_mode");
+	device_property_read_u32(dev, "snps,txpbl", &dma_cfg->txpbl);
+	device_property_read_u32(dev, "snps,rxpbl", &dma_cfg->rxpbl);
+	dma_cfg->pblx8 = !device_property_read_bool(dev, "snps,no-pbl-x8");
+
+	dma_cfg->aal = device_property_read_bool(dev, "snps,aal");
+	dma_cfg->fixed_burst = device_property_read_bool(dev,
+							 "snps,fixed-burst");
+	dma_cfg->mixed_burst = device_property_read_bool(dev,
+							 "snps,mixed-burst");
+
+	plat->force_thresh_dma_mode =
+			device_property_read_bool(dev,
+						  "snps,force_thresh_dma_mode");
 	if (plat->force_thresh_dma_mode) {
 		plat->force_sf_dma_mode = 0;
 		dev_warn(&pdev->dev,
 			 "force_sf_dma_mode is ignored if force_thresh_dma_mode is set.\n");
 	}
 
-	of_property_read_u32(np, "snps,ps-speed", &plat->mac_port_sel_speed);
+	device_property_read_u32(dev, "snps,ps-speed",
+				 &plat->mac_port_sel_speed);
 
 	plat->axi = stmmac_axi_setup(pdev);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] net: stmmac: platform: use generic device api
  2020-01-16  0:56 [PATCH] net: stmmac: platform: use generic device api Ajay Gupta
@ 2020-01-17  3:33 ` Chen-Yu Tsai
  2020-01-17 18:28   ` Ajay Gupta
  2020-01-17  8:29 ` Jose Abreu
  1 sibling, 1 reply; 5+ messages in thread
From: Chen-Yu Tsai @ 2020-01-17  3:33 UTC (permalink / raw)
  To: Ajay Gupta; +Cc: David Miller, netdev, Thierry Reding, Ajay Gupta

Hi,

On Fri, Jan 17, 2020 at 2:21 AM Ajay Gupta <ajaykuee@gmail.com> wrote:
>
> From: Ajay Gupta <ajayg@nvidia.com>
>
> Use generic device api to allow reading more configuration
> parameter from both DT or ACPI based devices.
>
> Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
> ---
> ACPI support related changes for dwc were reently queued [1]
> This patch is required to read more configuration parameter
> through ACPI table.
>
> [1] https://marc.info/?l=linux-netdev&m=157661974305024&w=2
>
>  .../ethernet/stmicro/stmmac/stmmac_platform.c | 49 +++++++++++--------

Even after your changes, there's still a lot of DT specific code in
there, such as the MDIO device node parsing. Plus the whole thing
is wrapped in "#ifdef CONFIG_OF".

Maybe it would make more sense to split out the generic device API
parts into a separate function?

Regards
ChenYu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] net: stmmac: platform: use generic device api
  2020-01-16  0:56 [PATCH] net: stmmac: platform: use generic device api Ajay Gupta
  2020-01-17  3:33 ` Chen-Yu Tsai
@ 2020-01-17  8:29 ` Jose Abreu
  2020-01-17 18:28   ` Ajay Gupta
  1 sibling, 1 reply; 5+ messages in thread
From: Jose Abreu @ 2020-01-17  8:29 UTC (permalink / raw)
  To: Ajay Gupta, davem; +Cc: netdev, treding, Ajay Gupta

Please cc' your patches according to "scripts/get_maintainer.pl" output.

---
Thanks,
Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] net: stmmac: platform: use generic device api
  2020-01-17  3:33 ` Chen-Yu Tsai
@ 2020-01-17 18:28   ` Ajay Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Ajay Gupta @ 2020-01-17 18:28 UTC (permalink / raw)
  To: Chen-Yu Tsai, Ajay Gupta
  Cc: David Miller, netdev, Thierry Reding, peppe.cavallaro,
	alexandre.torgue, joabreu, mcoquelin.stm32, p.zabel

Hi ChenYu

> -----Original Message-----
> From: Chen-Yu Tsai <wens@kernel.org>
> Sent: Thursday, January 16, 2020 7:34 PM
> To: Ajay Gupta <ajaykuee@gmail.com>
> Cc: David Miller <davem@davemloft.net>; netdev <netdev@vger.kernel.org>;
> Thierry Reding <treding@nvidia.com>; Ajay Gupta <ajayg@nvidia.com>
> Subject: Re: [PATCH] net: stmmac: platform: use generic device api
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi,
> 
> On Fri, Jan 17, 2020 at 2:21 AM Ajay Gupta <ajaykuee@gmail.com> wrote:
> >
> > From: Ajay Gupta <ajayg@nvidia.com>
> >
> > Use generic device api to allow reading more configuration parameter
> > from both DT or ACPI based devices.
> >
> > Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
> > ---
> > ACPI support related changes for dwc were reently queued [1] This
> > patch is required to read more configuration parameter through ACPI
> > table.
> >
> > [1] https://marc.info/?l=linux-netdev&m=157661974305024&w=2
> >
> >  .../ethernet/stmicro/stmmac/stmmac_platform.c | 49
> > +++++++++++--------
> 
> Even after your changes, there's still a lot of DT specific code in there, such as
> the MDIO device node parsing. Plus the whole thing is wrapped in "#ifdef
> CONFIG_OF".
> 
> Maybe it would make more sense to split out the generic device API parts into
> a separate function?
I am testing ACPI based device for dwmac-dwc-qos-eth controller. Also found
that " phy_node " structure used across other controllers (dwmac-rk, dwmac-sun8i)
plat->phy_node = of_parse_phandle(np, "phy-handle", 0);

It will require changes in other drivers  and testing them. I don't have hardware
for other controllers. 
I am trying to add minimal change what can be tested in context of dwmac-dwc-qos-eth.

Thanks
Ajay
>nvpublic
> 
> Regards
> ChenYu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] net: stmmac: platform: use generic device api
  2020-01-17  8:29 ` Jose Abreu
@ 2020-01-17 18:28   ` Ajay Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Ajay Gupta @ 2020-01-17 18:28 UTC (permalink / raw)
  To: Jose Abreu, Ajay Gupta, davem; +Cc: netdev, Thierry Reding

Hi Jose

> -----Original Message-----
> From: Jose Abreu <Jose.Abreu@synopsys.com>
> Sent: Friday, January 17, 2020 12:29 AM
> To: Ajay Gupta <ajaykuee@gmail.com>; davem@davemloft.net
> Cc: netdev@vger.kernel.org; Thierry Reding <treding@nvidia.com>; Ajay
> Gupta <ajayg@nvidia.com>
> Subject: RE: [PATCH] net: stmmac: platform: use generic device api
> 
> External email: Use caution opening links or attachments
> 
> 
> Please cc' your patches according to "scripts/get_maintainer.pl" output.
Sure, will do that.
>  nvpublic
> ---
> Thanks,
> Jose Miguel Abreu

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-17 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16  0:56 [PATCH] net: stmmac: platform: use generic device api Ajay Gupta
2020-01-17  3:33 ` Chen-Yu Tsai
2020-01-17 18:28   ` Ajay Gupta
2020-01-17  8:29 ` Jose Abreu
2020-01-17 18:28   ` Ajay Gupta

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).