Lines Matching +full:dwmac +full:- +full:4

1 // SPDX-License-Identifier: GPL-2.0
3 * T-HEAD DWMAC platform driver
23 #define GMAC_RX_CLK_EN BIT(4)
29 #define GMAC_RXCLK_DELAY GENMASK(4, 0)
33 #define GMAC_TXCLK_DELAY GENMASK(4, 0)
56 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_set_phy_if() local
59 switch (plat->mac_interface) { in thead_dwmac_set_phy_if()
70 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_set_phy_if()
71 plat->mac_interface); in thead_dwmac_set_phy_if()
72 return -EINVAL; in thead_dwmac_set_phy_if()
75 writel(phyif, dwmac->apb_base + GMAC_INTF_CTRL); in thead_dwmac_set_phy_if()
81 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_set_txclk_dir() local
84 switch (plat->mac_interface) { in thead_dwmac_set_txclk_dir()
95 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_set_txclk_dir()
96 plat->mac_interface); in thead_dwmac_set_txclk_dir()
97 return -EINVAL; in thead_dwmac_set_txclk_dir()
100 writel(txclk_dir, dwmac->apb_base + GMAC_TXCLK_OEN); in thead_dwmac_set_txclk_dir()
107 struct thead_dwmac *dwmac = bsp_priv; in thead_set_clk_tx_rate() local
113 plat = dwmac->plat; in thead_set_clk_tx_rate()
115 switch (plat->mac_interface) { in thead_set_clk_tx_rate()
124 rate = clk_get_rate(plat->stmmac_clk); in thead_set_clk_tx_rate()
126 writel(0, dwmac->apb_base + GMAC_PLLCLK_DIV); in thead_set_clk_tx_rate()
130 dev_err(dwmac->dev, "invalid speed %d\n", speed); in thead_set_clk_tx_rate()
136 dev_err(dwmac->dev, "invalid gmac rate %lu\n", rate); in thead_set_clk_tx_rate()
137 return -EINVAL; in thead_set_clk_tx_rate()
142 writel(reg, dwmac->apb_base + GMAC_PLLCLK_DIV); in thead_set_clk_tx_rate()
146 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_set_clk_tx_rate()
147 plat->mac_interface); in thead_set_clk_tx_rate()
148 return -EINVAL; in thead_set_clk_tx_rate()
154 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_enable_clk() local
157 switch (plat->mac_interface) { in thead_dwmac_enable_clk()
167 writel(GMAC_GTXCLK_SEL_PLL, dwmac->apb_base + GMAC_GTXCLK_SEL); in thead_dwmac_enable_clk()
173 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_enable_clk()
174 plat->mac_interface); in thead_dwmac_enable_clk()
175 return -EINVAL; in thead_dwmac_enable_clk()
178 writel(reg, dwmac->apb_base + GMAC_CLK_EN); in thead_dwmac_enable_clk()
184 struct thead_dwmac *dwmac = priv; in thead_dwmac_init() local
188 ret = thead_dwmac_set_phy_if(dwmac->plat); in thead_dwmac_init()
192 ret = thead_dwmac_set_txclk_dir(dwmac->plat); in thead_dwmac_init()
196 reg = readl(dwmac->apb_base + GMAC_RXCLK_DELAY_CTRL); in thead_dwmac_init()
199 writel(reg, dwmac->apb_base + GMAC_RXCLK_DELAY_CTRL); in thead_dwmac_init()
201 reg = readl(dwmac->apb_base + GMAC_TXCLK_DELAY_CTRL); in thead_dwmac_init()
204 writel(reg, dwmac->apb_base + GMAC_TXCLK_DELAY_CTRL); in thead_dwmac_init()
206 return thead_dwmac_enable_clk(dwmac->plat); in thead_dwmac_init()
213 struct thead_dwmac *dwmac; in thead_dwmac_probe() local
219 return dev_err_probe(&pdev->dev, ret, in thead_dwmac_probe()
224 return dev_err_probe(&pdev->dev, PTR_ERR(plat), in thead_dwmac_probe()
227 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in thead_dwmac_probe()
228 if (!dwmac) in thead_dwmac_probe()
229 return -ENOMEM; in thead_dwmac_probe()
233 return dev_err_probe(&pdev->dev, PTR_ERR(apb), in thead_dwmac_probe()
236 dwmac->dev = &pdev->dev; in thead_dwmac_probe()
237 dwmac->plat = plat; in thead_dwmac_probe()
238 dwmac->apb_base = apb; in thead_dwmac_probe()
239 plat->bsp_priv = dwmac; in thead_dwmac_probe()
240 plat->set_clk_tx_rate = thead_set_clk_tx_rate; in thead_dwmac_probe()
241 plat->init = thead_dwmac_init; in thead_dwmac_probe()
247 { .compatible = "thead,th1520-gmac" },
255 .name = "thead-dwmac",
264 MODULE_DESCRIPTION("T-HEAD DWMAC platform driver");