From: Ajay Gupta <ajaykuee@gmail.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, treding@nvidia.com,
Ajay Gupta <ajayg@nvidia.com>
Subject: [PATCH] net: stmmac: platform: use generic device api
Date: Wed, 15 Jan 2020 16:56:45 -0800 [thread overview]
Message-ID: <20200116005645.14026-1-ajayg@nvidia.com> (raw)
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
next reply other threads:[~2020-01-16 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 0:56 Ajay Gupta [this message]
2020-01-17 3:33 ` [PATCH] net: stmmac: platform: use generic device api Chen-Yu Tsai
2020-01-17 18:28 ` Ajay Gupta
2020-01-17 8:29 ` Jose Abreu
2020-01-17 18:28 ` Ajay Gupta
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=20200116005645.14026-1-ajayg@nvidia.com \
--to=ajaykuee@gmail.com \
--cc=ajayg@nvidia.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=treding@nvidia.com \
/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).