hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
....@@ -1,14 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Synopsys DWC Ethernet Quality-of-Service v4.10a linux driver
34 *
45 * Copyright (C) 2016 Joao Pinto <jpinto@synopsys.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * You should have received a copy of the GNU General Public License
11
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
126 */
137
148 #include <linux/clk.h>
....@@ -46,7 +40,7 @@
4640 static int dwc_eth_dwmac_config_dt(struct platform_device *pdev,
4741 struct plat_stmmacenet_data *plat_dat)
4842 {
49
- struct device_node *np = pdev->dev.of_node;
43
+ struct device *dev = &pdev->dev;
5044 u32 burst_map = 0;
5145 u32 bit_index = 0;
5246 u32 a_index = 0;
....@@ -58,9 +52,10 @@
5852 return -ENOMEM;
5953 }
6054
61
- plat_dat->axi->axi_lpi_en = of_property_read_bool(np, "snps,en-lpi");
62
- if (of_property_read_u32(np, "snps,write-requests",
63
- &plat_dat->axi->axi_wr_osr_lmt)) {
55
+ plat_dat->axi->axi_lpi_en = device_property_read_bool(dev,
56
+ "snps,en-lpi");
57
+ if (device_property_read_u32(dev, "snps,write-requests",
58
+ &plat_dat->axi->axi_wr_osr_lmt)) {
6459 /**
6560 * Since the register has a reset value of 1, if property
6661 * is missing, default to 1.
....@@ -74,8 +69,8 @@
7469 plat_dat->axi->axi_wr_osr_lmt--;
7570 }
7671
77
- if (of_property_read_u32(np, "snps,read-requests",
78
- &plat_dat->axi->axi_rd_osr_lmt)) {
72
+ if (device_property_read_u32(dev, "snps,read-requests",
73
+ &plat_dat->axi->axi_rd_osr_lmt)) {
7974 /**
8075 * Since the register has a reset value of 1, if property
8176 * is missing, default to 1.
....@@ -88,7 +83,7 @@
8883 */
8984 plat_dat->axi->axi_rd_osr_lmt--;
9085 }
91
- of_property_read_u32(np, "snps,burst-map", &burst_map);
86
+ device_property_read_u32(dev, "snps,burst-map", &burst_map);
9287
9388 /* converts burst-map bitmask to burst array */
9489 for (bit_index = 0; bit_index < 7; bit_index++) {
....@@ -276,6 +271,7 @@
276271 struct plat_stmmacenet_data *data,
277272 struct stmmac_resources *res)
278273 {
274
+ struct device *dev = &pdev->dev;
279275 struct tegra_eqos *eqos;
280276 int err;
281277
....@@ -287,6 +283,9 @@
287283
288284 eqos->dev = &pdev->dev;
289285 eqos->regs = res->addr;
286
+
287
+ if (!is_of_node(dev->fwnode))
288
+ goto bypass_clk_reset_gpio;
290289
291290 eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus");
292291 if (IS_ERR(eqos->clk_master)) {
....@@ -339,6 +338,9 @@
339338 usleep_range(2000, 4000);
340339 gpiod_set_value(eqos->reset, 0);
341340
341
+ /* MDIO bus was already reset just above */
342
+ data->mdio_bus_data->needs_reset = false;
343
+
342344 eqos->rst = devm_reset_control_get(&pdev->dev, "eqos");
343345 if (IS_ERR(eqos->rst)) {
344346 err = PTR_ERR(eqos->rst);
....@@ -357,9 +359,11 @@
357359
358360 usleep_range(2000, 4000);
359361
362
+bypass_clk_reset_gpio:
360363 data->fix_mac_speed = tegra_eqos_fix_speed;
361364 data->init = tegra_eqos_init;
362365 data->bsp_priv = eqos;
366
+ data->sph_disable = 1;
363367
364368 err = tegra_eqos_init(pdev, eqos);
365369 if (err < 0)
....@@ -421,11 +425,10 @@
421425 const struct dwc_eth_dwmac_data *data;
422426 struct plat_stmmacenet_data *plat_dat;
423427 struct stmmac_resources stmmac_res;
424
- struct resource *res;
425428 void *priv;
426429 int ret;
427430
428
- data = of_device_get_match_data(&pdev->dev);
431
+ data = device_get_match_data(&pdev->dev);
429432
430433 memset(&stmmac_res, 0, sizeof(struct stmmac_resources));
431434
....@@ -434,17 +437,11 @@
434437 * resource initialization is done in the glue logic.
435438 */
436439 stmmac_res.irq = platform_get_irq(pdev, 0);
437
- if (stmmac_res.irq < 0) {
438
- if (stmmac_res.irq != -EPROBE_DEFER)
439
- dev_err(&pdev->dev,
440
- "IRQ configuration information not found\n");
441
-
440
+ if (stmmac_res.irq < 0)
442441 return stmmac_res.irq;
443
- }
444442 stmmac_res.wol_irq = stmmac_res.irq;
445443
446
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
447
- stmmac_res.addr = devm_ioremap_resource(&pdev->dev, res);
444
+ stmmac_res.addr = devm_platform_ioremap_resource(pdev, 0);
448445 if (IS_ERR(stmmac_res.addr))
449446 return PTR_ERR(stmmac_res.addr);
450447
....@@ -455,7 +452,11 @@
455452 priv = data->probe(pdev, plat_dat, &stmmac_res);
456453 if (IS_ERR(priv)) {
457454 ret = PTR_ERR(priv);
458
- dev_err(&pdev->dev, "failed to probe subdriver: %d\n", ret);
455
+
456
+ if (ret != -EPROBE_DEFER)
457
+ dev_err(&pdev->dev, "failed to probe subdriver: %d\n",
458
+ ret);
459
+
459460 goto remove_config;
460461 }
461462
....@@ -484,7 +485,7 @@
484485 const struct dwc_eth_dwmac_data *data;
485486 int err;
486487
487
- data = of_device_get_match_data(&pdev->dev);
488
+ data = device_get_match_data(&pdev->dev);
488489
489490 err = stmmac_dvr_remove(&pdev->dev);
490491 if (err < 0)