Lines Matching +full:tegra186 +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Synopsys DWC Ethernet Quality-of-Service v4.10a linux driver
9 #include <linux/clk-provider.h>
11 #include <linux/gpio/consumer.h>
43 struct device *dev = &pdev->dev; in dwc_eth_dwmac_config_dt()
48 if (!plat_dat->axi) { in dwc_eth_dwmac_config_dt()
49 plat_dat->axi = kzalloc(sizeof(struct stmmac_axi), GFP_KERNEL); in dwc_eth_dwmac_config_dt()
51 if (!plat_dat->axi) in dwc_eth_dwmac_config_dt()
52 return -ENOMEM; in dwc_eth_dwmac_config_dt()
55 plat_dat->axi->axi_lpi_en = device_property_read_bool(dev, in dwc_eth_dwmac_config_dt()
56 "snps,en-lpi"); in dwc_eth_dwmac_config_dt()
57 if (device_property_read_u32(dev, "snps,write-requests", in dwc_eth_dwmac_config_dt()
58 &plat_dat->axi->axi_wr_osr_lmt)) { in dwc_eth_dwmac_config_dt()
63 plat_dat->axi->axi_wr_osr_lmt = 1; in dwc_eth_dwmac_config_dt()
69 plat_dat->axi->axi_wr_osr_lmt--; in dwc_eth_dwmac_config_dt()
72 if (device_property_read_u32(dev, "snps,read-requests", in dwc_eth_dwmac_config_dt()
73 &plat_dat->axi->axi_rd_osr_lmt)) { in dwc_eth_dwmac_config_dt()
78 plat_dat->axi->axi_rd_osr_lmt = 1; in dwc_eth_dwmac_config_dt()
84 plat_dat->axi->axi_rd_osr_lmt--; in dwc_eth_dwmac_config_dt()
86 device_property_read_u32(dev, "snps,burst-map", &burst_map); in dwc_eth_dwmac_config_dt()
88 /* converts burst-map bitmask to burst array */ in dwc_eth_dwmac_config_dt()
93 plat_dat->axi->axi_blen[a_index] = 4; break; in dwc_eth_dwmac_config_dt()
95 plat_dat->axi->axi_blen[a_index] = 8; break; in dwc_eth_dwmac_config_dt()
97 plat_dat->axi->axi_blen[a_index] = 16; break; in dwc_eth_dwmac_config_dt()
99 plat_dat->axi->axi_blen[a_index] = 32; break; in dwc_eth_dwmac_config_dt()
101 plat_dat->axi->axi_blen[a_index] = 64; break; in dwc_eth_dwmac_config_dt()
103 plat_dat->axi->axi_blen[a_index] = 128; break; in dwc_eth_dwmac_config_dt()
105 plat_dat->axi->axi_blen[a_index] = 256; break; in dwc_eth_dwmac_config_dt()
113 /* dwc-qos needs GMAC4, AAL, TSO and PMT */ in dwc_eth_dwmac_config_dt()
114 plat_dat->has_gmac4 = 1; in dwc_eth_dwmac_config_dt()
115 plat_dat->dma_cfg->aal = 1; in dwc_eth_dwmac_config_dt()
116 plat_dat->tso_en = 1; in dwc_eth_dwmac_config_dt()
117 plat_dat->pmt = 1; in dwc_eth_dwmac_config_dt()
128 plat_dat->stmmac_clk = devm_clk_get(&pdev->dev, "apb_pclk"); in dwc_qos_probe()
129 if (IS_ERR(plat_dat->stmmac_clk)) { in dwc_qos_probe()
130 dev_err(&pdev->dev, "apb_pclk clock not found.\n"); in dwc_qos_probe()
131 return PTR_ERR(plat_dat->stmmac_clk); in dwc_qos_probe()
134 err = clk_prepare_enable(plat_dat->stmmac_clk); in dwc_qos_probe()
136 dev_err(&pdev->dev, "failed to enable apb_pclk clock: %d\n", in dwc_qos_probe()
141 plat_dat->pclk = devm_clk_get(&pdev->dev, "phy_ref_clk"); in dwc_qos_probe()
142 if (IS_ERR(plat_dat->pclk)) { in dwc_qos_probe()
143 dev_err(&pdev->dev, "phy_ref_clk clock not found.\n"); in dwc_qos_probe()
144 err = PTR_ERR(plat_dat->pclk); in dwc_qos_probe()
148 err = clk_prepare_enable(plat_dat->pclk); in dwc_qos_probe()
150 dev_err(&pdev->dev, "failed to enable phy_ref clock: %d\n", in dwc_qos_probe()
158 clk_disable_unprepare(plat_dat->stmmac_clk); in dwc_qos_probe()
167 clk_disable_unprepare(priv->plat->pclk); in dwc_qos_remove()
168 clk_disable_unprepare(priv->plat->stmmac_clk); in dwc_qos_remove()
207 dev_err(eqos->dev, "invalid speed %u\n", speed); in tegra_eqos_fix_speed()
213 value = readl(eqos->regs + SDMEMCOMPPADCTRL); in tegra_eqos_fix_speed()
215 writel(value, eqos->regs + SDMEMCOMPPADCTRL); in tegra_eqos_fix_speed()
219 value = readl(eqos->regs + AUTO_CAL_CONFIG); in tegra_eqos_fix_speed()
221 writel(value, eqos->regs + AUTO_CAL_CONFIG); in tegra_eqos_fix_speed()
223 err = readl_poll_timeout_atomic(eqos->regs + AUTO_CAL_STATUS, in tegra_eqos_fix_speed()
228 dev_err(eqos->dev, "calibration did not start\n"); in tegra_eqos_fix_speed()
232 err = readl_poll_timeout_atomic(eqos->regs + AUTO_CAL_STATUS, in tegra_eqos_fix_speed()
237 dev_err(eqos->dev, "calibration didn't finish\n"); in tegra_eqos_fix_speed()
242 value = readl(eqos->regs + SDMEMCOMPPADCTRL); in tegra_eqos_fix_speed()
244 writel(value, eqos->regs + SDMEMCOMPPADCTRL); in tegra_eqos_fix_speed()
246 value = readl(eqos->regs + AUTO_CAL_CONFIG); in tegra_eqos_fix_speed()
248 writel(value, eqos->regs + AUTO_CAL_CONFIG); in tegra_eqos_fix_speed()
251 err = clk_set_rate(eqos->clk_tx, rate); in tegra_eqos_fix_speed()
253 dev_err(eqos->dev, "failed to set TX rate: %d\n", err); in tegra_eqos_fix_speed()
262 rate = clk_get_rate(eqos->clk_slave); in tegra_eqos_init()
264 value = (rate / 1000000) - 1; in tegra_eqos_init()
265 writel(value, eqos->regs + GMAC_1US_TIC_COUNTER); in tegra_eqos_init()
274 struct device *dev = &pdev->dev; in tegra_eqos_probe()
278 eqos = devm_kzalloc(&pdev->dev, sizeof(*eqos), GFP_KERNEL); in tegra_eqos_probe()
280 return -ENOMEM; in tegra_eqos_probe()
282 eqos->dev = &pdev->dev; in tegra_eqos_probe()
283 eqos->regs = res->addr; in tegra_eqos_probe()
285 if (!is_of_node(dev->fwnode)) in tegra_eqos_probe()
288 eqos->clk_master = devm_clk_get(&pdev->dev, "master_bus"); in tegra_eqos_probe()
289 if (IS_ERR(eqos->clk_master)) { in tegra_eqos_probe()
290 err = PTR_ERR(eqos->clk_master); in tegra_eqos_probe()
294 err = clk_prepare_enable(eqos->clk_master); in tegra_eqos_probe()
298 eqos->clk_slave = devm_clk_get(&pdev->dev, "slave_bus"); in tegra_eqos_probe()
299 if (IS_ERR(eqos->clk_slave)) { in tegra_eqos_probe()
300 err = PTR_ERR(eqos->clk_slave); in tegra_eqos_probe()
304 data->stmmac_clk = eqos->clk_slave; in tegra_eqos_probe()
306 err = clk_prepare_enable(eqos->clk_slave); in tegra_eqos_probe()
310 eqos->clk_rx = devm_clk_get(&pdev->dev, "rx"); in tegra_eqos_probe()
311 if (IS_ERR(eqos->clk_rx)) { in tegra_eqos_probe()
312 err = PTR_ERR(eqos->clk_rx); in tegra_eqos_probe()
316 err = clk_prepare_enable(eqos->clk_rx); in tegra_eqos_probe()
320 eqos->clk_tx = devm_clk_get(&pdev->dev, "tx"); in tegra_eqos_probe()
321 if (IS_ERR(eqos->clk_tx)) { in tegra_eqos_probe()
322 err = PTR_ERR(eqos->clk_tx); in tegra_eqos_probe()
326 err = clk_prepare_enable(eqos->clk_tx); in tegra_eqos_probe()
330 eqos->reset = devm_gpiod_get(&pdev->dev, "phy-reset", GPIOD_OUT_HIGH); in tegra_eqos_probe()
331 if (IS_ERR(eqos->reset)) { in tegra_eqos_probe()
332 err = PTR_ERR(eqos->reset); in tegra_eqos_probe()
337 gpiod_set_value(eqos->reset, 0); in tegra_eqos_probe()
340 data->mdio_bus_data->needs_reset = false; in tegra_eqos_probe()
342 eqos->rst = devm_reset_control_get(&pdev->dev, "eqos"); in tegra_eqos_probe()
343 if (IS_ERR(eqos->rst)) { in tegra_eqos_probe()
344 err = PTR_ERR(eqos->rst); in tegra_eqos_probe()
348 err = reset_control_assert(eqos->rst); in tegra_eqos_probe()
354 err = reset_control_deassert(eqos->rst); in tegra_eqos_probe()
361 data->fix_mac_speed = tegra_eqos_fix_speed; in tegra_eqos_probe()
362 data->init = tegra_eqos_init; in tegra_eqos_probe()
363 data->bsp_priv = eqos; in tegra_eqos_probe()
364 data->sph_disable = 1; in tegra_eqos_probe()
372 reset_control_assert(eqos->rst); in tegra_eqos_probe()
374 gpiod_set_value(eqos->reset, 1); in tegra_eqos_probe()
376 clk_disable_unprepare(eqos->clk_tx); in tegra_eqos_probe()
378 clk_disable_unprepare(eqos->clk_rx); in tegra_eqos_probe()
380 clk_disable_unprepare(eqos->clk_slave); in tegra_eqos_probe()
382 clk_disable_unprepare(eqos->clk_master); in tegra_eqos_probe()
389 struct tegra_eqos *eqos = get_stmmac_bsp_priv(&pdev->dev); in tegra_eqos_remove()
391 reset_control_assert(eqos->rst); in tegra_eqos_remove()
392 gpiod_set_value(eqos->reset, 1); in tegra_eqos_remove()
393 clk_disable_unprepare(eqos->clk_tx); in tegra_eqos_remove()
394 clk_disable_unprepare(eqos->clk_rx); in tegra_eqos_remove()
395 clk_disable_unprepare(eqos->clk_slave); in tegra_eqos_remove()
396 clk_disable_unprepare(eqos->clk_master); in tegra_eqos_remove()
425 data = device_get_match_data(&pdev->dev); in dwc_eth_dwmac_probe()
446 ret = data->probe(pdev, plat_dat, &stmmac_res); in dwc_eth_dwmac_probe()
448 dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n"); in dwc_eth_dwmac_probe()
457 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in dwc_eth_dwmac_probe()
464 data->remove(pdev); in dwc_eth_dwmac_probe()
478 data = device_get_match_data(&pdev->dev); in dwc_eth_dwmac_remove()
480 err = stmmac_dvr_remove(&pdev->dev); in dwc_eth_dwmac_remove()
482 dev_err(&pdev->dev, "failed to remove platform: %d\n", err); in dwc_eth_dwmac_remove()
484 err = data->remove(pdev); in dwc_eth_dwmac_remove()
486 dev_err(&pdev->dev, "failed to remove subdriver: %d\n", err); in dwc_eth_dwmac_remove()
488 stmmac_remove_config_dt(pdev, priv->plat); in dwc_eth_dwmac_remove()
494 { .compatible = "snps,dwc-qos-ethernet-4.10", .data = &dwc_qos_data },
495 { .compatible = "nvidia,tegra186-eqos", .data = &tegra_eqos_data },
504 .name = "dwc-eth-dwmac",
512 MODULE_DESCRIPTION("Synopsys DWC Ethernet Quality-of-Service v4.10a driver");