Lines Matching +full:rmii +full:- +full:clk +full:- +full:internal

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
18 #include <linux/clk.h>
40 * ------------------------------------------------
43 * ------------------------------------------------
45 *| | clk-125/txclk | txclk |
46 * ------------------------------------------------
48 *| | clk-125/txclk | clkgen |
50 * ------------------------------------------------
51 *| RMII | n/a | 25Mhz |
52 *| | |clkgen/phyclk-in |
53 * ------------------------------------------------
56 *-------------------------------
58 *-------------------------------
60 *-------------------------------
62 *-------------------------------
64 *-------------------------------
66 *-------------------------------
81 * 000-GMII/MII
82 * 001-RGMII
83 * 010-SGMII
84 * 100-RMII
97 struct clk *clk; /* PHY clock */ member
98 u32 ctrl_reg; /* GMAC glue-logic control register */
99 int clk_sel_reg; /* GMAC ext clk selection register */
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()
152 /* On GiGa clk source can be either ext or from clkgen */ 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()
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()
191 struct device *dev = &pdev->dev; in sti_dwmac_parse_data()
192 struct device_node *np = dev->of_node; in sti_dwmac_parse_data()
196 /* clk selection from extra syscfg register */ in sti_dwmac_parse_data()
197 dwmac->clk_sel_reg = -ENXIO; in sti_dwmac_parse_data()
198 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sti-clkconf"); in sti_dwmac_parse_data()
200 dwmac->clk_sel_reg = res->start; in sti_dwmac_parse_data()
203 1, &dwmac->ctrl_reg); in sti_dwmac_parse_data()
207 err = of_get_phy_mode(np, &dwmac->interface); in sti_dwmac_parse_data()
208 if (err && err != -ENODEV) { in sti_dwmac_parse_data()
209 dev_err(dev, "Can't get phy-mode\n"); in sti_dwmac_parse_data()
213 dwmac->regmap = regmap; in sti_dwmac_parse_data()
214 dwmac->gmac_en = of_property_read_bool(np, "st,gmac_en"); in sti_dwmac_parse_data()
215 dwmac->ext_phyclk = of_property_read_bool(np, "st,ext-phyclk"); in sti_dwmac_parse_data()
216 dwmac->tx_retime_src = TX_RETIME_SRC_NA; in sti_dwmac_parse_data()
217 dwmac->speed = SPEED_100; in sti_dwmac_parse_data()
219 if (IS_PHY_IF_MODE_GBIT(dwmac->interface)) { in sti_dwmac_parse_data()
222 dwmac->tx_retime_src = TX_RETIME_SRC_CLKGEN; in sti_dwmac_parse_data()
224 err = of_property_read_string(np, "st,tx-retime-src", &rs); in sti_dwmac_parse_data()
226 dev_warn(dev, "Use internal clock source\n"); in sti_dwmac_parse_data()
229 dwmac->tx_retime_src = TX_RETIME_SRC_CLK_125; in sti_dwmac_parse_data()
231 dwmac->tx_retime_src = TX_RETIME_SRC_TXCLK; in sti_dwmac_parse_data()
233 dwmac->speed = SPEED_1000; in sti_dwmac_parse_data()
236 dwmac->clk = devm_clk_get(dev, "sti-ethclk"); in sti_dwmac_parse_data()
237 if (IS_ERR(dwmac->clk)) { in sti_dwmac_parse_data()
239 dwmac->clk = NULL; in sti_dwmac_parse_data()
253 data = of_device_get_match_data(&pdev->dev); in sti_dwmac_probe()
255 dev_err(&pdev->dev, "No OF match data provided\n"); in sti_dwmac_probe()
256 return -EINVAL; in sti_dwmac_probe()
267 dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL); in sti_dwmac_probe()
269 return -ENOMEM; in sti_dwmac_probe()
273 dev_err(&pdev->dev, "Unable to parse OF data\n"); in sti_dwmac_probe()
277 dwmac->fix_retime_src = data->fix_retime_src; in sti_dwmac_probe()
279 plat_dat->bsp_priv = dwmac; in sti_dwmac_probe()
280 plat_dat->fix_mac_speed = data->fix_retime_src; in sti_dwmac_probe()
282 ret = clk_prepare_enable(dwmac->clk); in sti_dwmac_probe()
290 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in sti_dwmac_probe()
297 clk_disable_unprepare(dwmac->clk); in sti_dwmac_probe()
304 struct sti_dwmac *dwmac = get_stmmac_bsp_priv(&pdev->dev); in sti_dwmac_remove()
306 stmmac_dvr_remove(&pdev->dev); in sti_dwmac_remove()
308 clk_disable_unprepare(dwmac->clk); in sti_dwmac_remove()
316 clk_disable_unprepare(dwmac->clk); in sti_dwmac_suspend()
325 clk_prepare_enable(dwmac->clk); in sti_dwmac_resume()
339 { .compatible = "st,stih407-dwmac", .data = &stih4xx_dwmac_data},
348 .name = "sti-dwmac",