[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200116005645.14026-1-ajayg@nvidia.com>
Date: Wed, 15 Jan 2020 16:56:45 -0800
From: Ajay Gupta <ajaykuee@...il.com>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, treding@...dia.com,
Ajay Gupta <ajayg@...dia.com>
Subject: [PATCH] net: stmmac: platform: use generic device api
From: Ajay Gupta <ajayg@...dia.com>
Use generic device api to allow reading more configuration
parameter from both DT or ACPI based devices.
Signed-off-by: Ajay Gupta <ajayg@...dia.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
Powered by blists - more mailing lists