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)
59 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_set_phy_if() local
62 switch (plat->mac_interface) { in thead_dwmac_set_phy_if()
73 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_set_phy_if()
74 plat->mac_interface); in thead_dwmac_set_phy_if()
75 return -EINVAL; in thead_dwmac_set_phy_if()
78 writel(phyif, dwmac->apb_base + GMAC_INTF_CTRL); in thead_dwmac_set_phy_if()
84 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_set_txclk_dir() local
87 switch (plat->mac_interface) { in thead_dwmac_set_txclk_dir()
98 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_set_txclk_dir()
99 plat->mac_interface); in thead_dwmac_set_txclk_dir()
100 return -EINVAL; in thead_dwmac_set_txclk_dir()
103 writel(txclk_dir, dwmac->apb_base + GMAC_TXCLK_OEN); in thead_dwmac_set_txclk_dir()
110 struct thead_dwmac *dwmac = priv; in thead_dwmac_fix_speed() local
114 plat = dwmac->plat; in thead_dwmac_fix_speed()
116 switch (plat->mac_interface) { in thead_dwmac_fix_speed()
125 rate = clk_get_rate(plat->stmmac_clk); in thead_dwmac_fix_speed()
128 dev_err(dwmac->dev, "invalid gmac rate %ld\n", rate); in thead_dwmac_fix_speed()
132 writel(0, dwmac->apb_base + GMAC_PLLCLK_DIV); in thead_dwmac_fix_speed()
145 dev_err(dwmac->dev, "invalid speed %u\n", speed); in thead_dwmac_fix_speed()
151 writel(reg, dwmac->apb_base + GMAC_PLLCLK_DIV); in thead_dwmac_fix_speed()
154 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_fix_speed()
155 plat->mac_interface); in thead_dwmac_fix_speed()
162 struct thead_dwmac *dwmac = plat->bsp_priv; in thead_dwmac_enable_clk() local
165 switch (plat->mac_interface) { in thead_dwmac_enable_clk()
175 writel(GMAC_GTXCLK_SEL_PLL, dwmac->apb_base + GMAC_GTXCLK_SEL); in thead_dwmac_enable_clk()
181 dev_err(dwmac->dev, "unsupported phy interface %d\n", in thead_dwmac_enable_clk()
182 plat->mac_interface); in thead_dwmac_enable_clk()
183 return -EINVAL; in thead_dwmac_enable_clk()
186 writel(reg, dwmac->apb_base + GMAC_CLK_EN); in thead_dwmac_enable_clk()
192 struct thead_dwmac *dwmac = priv; in thead_dwmac_init() local
196 ret = thead_dwmac_set_phy_if(dwmac->plat); in thead_dwmac_init()
200 ret = thead_dwmac_set_txclk_dir(dwmac->plat); in thead_dwmac_init()
204 reg = readl(dwmac->apb_base + GMAC_RXCLK_DELAY_CTRL); in thead_dwmac_init()
207 writel(reg, dwmac->apb_base + GMAC_RXCLK_DELAY_CTRL); in thead_dwmac_init()
209 reg = readl(dwmac->apb_base + GMAC_TXCLK_DELAY_CTRL); in thead_dwmac_init()
212 writel(reg, dwmac->apb_base + GMAC_TXCLK_DELAY_CTRL); in thead_dwmac_init()
214 return thead_dwmac_enable_clk(dwmac->plat); in thead_dwmac_init()
221 struct thead_dwmac *dwmac; in thead_dwmac_probe() local
227 return dev_err_probe(&pdev->dev, ret, in thead_dwmac_probe()
232 return dev_err_probe(&pdev->dev, PTR_ERR(plat), in thead_dwmac_probe()
235 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in thead_dwmac_probe()
236 if (!dwmac) in thead_dwmac_probe()
237 return -ENOMEM; in thead_dwmac_probe()
241 return dev_err_probe(&pdev->dev, PTR_ERR(apb), in thead_dwmac_probe()
244 dwmac->dev = &pdev->dev; in thead_dwmac_probe()
245 dwmac->plat = plat; in thead_dwmac_probe()
246 dwmac->apb_base = apb; in thead_dwmac_probe()
247 plat->bsp_priv = dwmac; in thead_dwmac_probe()
248 plat->fix_mac_speed = thead_dwmac_fix_speed; in thead_dwmac_probe()
249 plat->init = thead_dwmac_init; in thead_dwmac_probe()
255 { .compatible = "thead,th1520-gmac" },
263 .name = "thead-dwmac",
272 MODULE_DESCRIPTION("T-HEAD DWMAC platform driver");