Lines Matching +full:dwmac +full:- +full:3

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
40 * ------------------------------------------------
43 * ------------------------------------------------
45 *| | clk-125/txclk | txclk |
46 * ------------------------------------------------
48 *| | clk-125/txclk | clkgen |
50 * ------------------------------------------------
52 *| | |clkgen/phyclk-in |
53 * ------------------------------------------------
56 *-------------------------------
58 *-------------------------------
60 *-------------------------------
62 *-------------------------------
64 *-------------------------------
66 *-------------------------------
80 * 3 bits [4:2]
81 * 000-GMII/MII
82 * 001-RGMII
83 * 010-SGMII
84 * 100-RMII
88 #define ETH_PHY_SEL_SGMII BIT(3)
98 u32 ctrl_reg; /* GMAC glue-logic control register */
137 struct sti_dwmac *dwmac = priv; in stih4xx_fix_retime_src() local
138 u32 src = dwmac->tx_retime_src; in stih4xx_fix_retime_src()
139 u32 reg = dwmac->ctrl_reg; in stih4xx_fix_retime_src()
142 if (dwmac->interface == PHY_INTERFACE_MODE_MII) { in stih4xx_fix_retime_src()
144 } else if (dwmac->interface == PHY_INTERFACE_MODE_RMII) { in stih4xx_fix_retime_src()
145 if (dwmac->ext_phyclk) { in stih4xx_fix_retime_src()
151 } else if (IS_PHY_IF_MODE_RGMII(dwmac->interface)) { in stih4xx_fix_retime_src()
161 clk_set_rate(dwmac->clk, freq); in stih4xx_fix_retime_src()
163 regmap_update_bits(dwmac->regmap, reg, STIH4XX_RETIME_SRC_MASK, in stih4xx_fix_retime_src()
167 static int sti_dwmac_set_mode(struct sti_dwmac *dwmac) in sti_dwmac_set_mode() argument
169 struct regmap *regmap = dwmac->regmap; in sti_dwmac_set_mode()
170 int iface = dwmac->interface; in sti_dwmac_set_mode()
171 u32 reg = dwmac->ctrl_reg; in sti_dwmac_set_mode()
174 if (dwmac->gmac_en) in sti_dwmac_set_mode()
182 dwmac->fix_retime_src(dwmac, dwmac->speed, 0); in sti_dwmac_set_mode()
187 static int sti_dwmac_parse_data(struct sti_dwmac *dwmac, in sti_dwmac_parse_data() argument
192 struct device *dev = &pdev->dev; in sti_dwmac_parse_data()
193 struct device_node *np = dev->of_node; in sti_dwmac_parse_data()
198 dwmac->clk_sel_reg = -ENXIO; in sti_dwmac_parse_data()
199 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf"); in sti_dwmac_parse_data()
201 dwmac->clk_sel_reg = res->start; in sti_dwmac_parse_data()
204 1, &dwmac->ctrl_reg); in sti_dwmac_parse_data()
208 dwmac->interface = plat_dat->phy_interface; in sti_dwmac_parse_data()
209 dwmac->regmap = regmap; in sti_dwmac_parse_data()
210 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); in sti_dwmac_parse_data()
211 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in sti_dwmac_parse_data()
212 dwmac->tx_retime_src = TX_RETIME_SRC_NA; in sti_dwmac_parse_data()
213 dwmac->speed = SPEED_100; in sti_dwmac_parse_data()
215 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { in sti_dwmac_parse_data()
218 dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; in sti_dwmac_parse_data()
220 err = of_property_read_string(np, "st,tx-retime-src", &rs); in sti_dwmac_parse_data()
225 dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; in sti_dwmac_parse_data()
227 dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; in sti_dwmac_parse_data()
229 dwmac->speed = SPEED_1000; in sti_dwmac_parse_data()
232 dwmac->clk = devm_clk_get(dev, "sti-ethclk"); in sti_dwmac_parse_data()
233 if (IS_ERR(dwmac->clk)) { in sti_dwmac_parse_data()
235 dwmac->clk = NULL; in sti_dwmac_parse_data()
246 struct sti_dwmac *dwmac; in sti_dwmac_probe() local
249 data = of_device_get_match_data(&pdev->dev); in sti_dwmac_probe()
251 dev_err(&pdev->dev, "No OF match data provided\n"); in sti_dwmac_probe()
252 return -EINVAL; in sti_dwmac_probe()
263 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in sti_dwmac_probe()
264 if (!dwmac) in sti_dwmac_probe()
265 return -ENOMEM; in sti_dwmac_probe()
267 ret = sti_dwmac_parse_data(dwmac, pdev, plat_dat); in sti_dwmac_probe()
269 dev_err(&pdev->dev, "Unable to parse OF data\n"); in sti_dwmac_probe()
273 dwmac->fix_retime_src = data->fix_retime_src; in sti_dwmac_probe()
275 plat_dat->bsp_priv = dwmac; in sti_dwmac_probe()
276 plat_dat->fix_mac_speed = data->fix_retime_src; in sti_dwmac_probe()
278 ret = clk_prepare_enable(dwmac->clk); in sti_dwmac_probe()
282 ret = sti_dwmac_set_mode(dwmac); in sti_dwmac_probe()
286 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in sti_dwmac_probe()
293 clk_disable_unprepare(dwmac->clk); in sti_dwmac_probe()
300 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); in sti_dwmac_remove() local
302 stmmac_dvr_remove(&pdev->dev); in sti_dwmac_remove()
304 clk_disable_unprepare(dwmac->clk); in sti_dwmac_remove()
309 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_suspend() local
312 clk_disable_unprepare(dwmac->clk); in sti_dwmac_suspend()
319 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(dev); in sti_dwmac_resume() local
321 clk_prepare_enable(dwmac->clk); in sti_dwmac_resume()
322 sti_dwmac_set_mode(dwmac); in sti_dwmac_resume()
335 { .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
344 .name = "sti-dwmac",
352 MODULE_DESCRIPTION("STMicroelectronics DWMAC Specific Glue layer");