Lines Matching +full:dwmac +full:- +full:5
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * dwmac-sti.c - STMicroelectronics DWMAC Specific Glue layer
5 * Copyright (C) 2003-2014 STMicroelectronics (R&D) Limited
43 * ------------------------------------------------
46 * ------------------------------------------------
48 *| | clk-125/txclk | txclk |
49 * ------------------------------------------------
51 *| | clk-125/txclk | clkgen |
53 * ------------------------------------------------
55 *| | |clkgen/phyclk-in |
56 * ------------------------------------------------
59 *-------------------------------
61 *-------------------------------
63 *-------------------------------
65 *-------------------------------
67 *-------------------------------
69 *-------------------------------
77 #define ENMII_MASK GENMASK(5, 5)
78 #define ENMII BIT(5)
84 * 000-GMII/MII
85 * 001-RGMII
86 * 010-SGMII
87 * 100-RMII
101 u32 ctrl_reg; /* GMAC glue-logic control register */
140 struct sti_dwmac *dwmac = priv; in stih4xx_fix_retime_src() local
141 u32 src = dwmac->tx_retime_src; in stih4xx_fix_retime_src()
142 u32 reg = dwmac->ctrl_reg; in stih4xx_fix_retime_src()
145 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { in stih4xx_fix_retime_src()
147 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { in stih4xx_fix_retime_src()
148 if (dwmac->ext_phyclk) { in stih4xx_fix_retime_src()
154 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { in stih4xx_fix_retime_src()
169 clk_set_rate(dwmac->clk, freq); in stih4xx_fix_retime_src()
171 regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, in stih4xx_fix_retime_src()
175 static int sti_dwmac_set_mode(struct sti_dwmac *dwmac) in sti_dwmac_set_mode() argument
177 struct regmap *regmap = dwmac->regmap; in sti_dwmac_set_mode()
178 int iface = dwmac->interface; in sti_dwmac_set_mode()
179 u32 reg = dwmac->ctrl_reg; in sti_dwmac_set_mode()
182 if (dwmac->gmac_en) in sti_dwmac_set_mode()
190 dwmac->fix_retime_src(dwmac, dwmac->speed, 0); in sti_dwmac_set_mode()
195 static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, in sti_dwmac_parse_data() argument
199 struct device *dev = &pdev->dev; in sti_dwmac_parse_data()
200 struct device_node *np = dev->of_node; in sti_dwmac_parse_data()
205 dwmac->clk_sel_reg = -ENXIO; in sti_dwmac_parse_data()
206 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf"); in sti_dwmac_parse_data()
208 dwmac->clk_sel_reg = res->start; in sti_dwmac_parse_data()
214 err = of_property_read_u32_index(np, "st,syscon", 1, &dwmac->ctrl_reg); in sti_dwmac_parse_data()
220 err = of_get_phy_mode(np, &dwmac->interface); in sti_dwmac_parse_data()
221 if (err && err != -ENODEV) { in sti_dwmac_parse_data()
222 dev_err(dev, "Can't get phy-mode\n"); in sti_dwmac_parse_data()
226 dwmac->regmap = regmap; in sti_dwmac_parse_data()
227 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); in sti_dwmac_parse_data()
228 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in sti_dwmac_parse_data()
229 dwmac->tx_retime_src = TX_RETIME_SRC_NA; in sti_dwmac_parse_data()
230 dwmac->speed = SPEED_100; in sti_dwmac_parse_data()
232 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { in sti_dwmac_parse_data()
235 dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; in sti_dwmac_parse_data()
237 err = of_property_read_string(np, "st,tx-retime-src", &rs); in sti_dwmac_parse_data()
242 dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; in sti_dwmac_parse_data()
244 dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; in sti_dwmac_parse_data()
246 dwmac->speed = SPEED_1000; in sti_dwmac_parse_data()
249 dwmac->clk = devm_clk_get(dev, "sti-ethclk"); in sti_dwmac_parse_data()
250 if (IS_ERR(dwmac->clk)) { in sti_dwmac_parse_data()
252 dwmac->clk = NULL; in sti_dwmac_parse_data()
263 struct sti_dwmac *dwmac; in sti_dwmac_probe() local
266 data = of_device_get_match_data(&pdev->dev); in sti_dwmac_probe()
268 dev_err(&pdev->dev, "No OF match data provided\n"); in sti_dwmac_probe()
269 return -EINVAL; in sti_dwmac_probe()
280 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in sti_dwmac_probe()
281 if (!dwmac) in sti_dwmac_probe()
282 return -ENOMEM; in sti_dwmac_probe()
284 ret = sti_dwmac_parse_data(dwmac, pdev); in sti_dwmac_probe()
286 dev_err(&pdev->dev, "Unable to parse OF data\n"); in sti_dwmac_probe()
290 dwmac->fix_retime_src = data->fix_retime_src; in sti_dwmac_probe()
292 plat_dat->bsp_priv = dwmac; in sti_dwmac_probe()
293 plat_dat->fix_mac_speed = data->fix_retime_src; in sti_dwmac_probe()
295 ret = clk_prepare_enable(dwmac->clk); in sti_dwmac_probe()
299 ret = sti_dwmac_set_mode(dwmac); in sti_dwmac_probe()
303 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in sti_dwmac_probe()
310 clk_disable_unprepare(dwmac->clk); in sti_dwmac_probe()
317 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); in sti_dwmac_remove() local
319 stmmac_dvr_remove(&pdev->dev); in sti_dwmac_remove()
321 clk_disable_unprepare(dwmac->clk); in sti_dwmac_remove()
327 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_suspend() local
330 clk_disable_unprepare(dwmac->clk); in sti_dwmac_suspend()
337 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_resume() local
339 clk_prepare_enable(dwmac->clk); in sti_dwmac_resume()
340 sti_dwmac_set_mode(dwmac); in sti_dwmac_resume()
354 { .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
363 .name = "sti-dwmac",
371 MODULE_DESCRIPTION("STMicroelectronics DWMAC Specific Glue layer");