Lines Matching +full:mac +full:- +full:clk +full:- +full:tx

1 // SPDX-License-Identifier: GPL-2.0
3 * dwmac-ingenic.c - Ingenic SoCs DWMAC specific glue layer
9 #include <linux/clk.h>
75 struct ingenic_mac *mac = plat_dat->bsp_priv; in ingenic_mac_init() local
78 if (mac->soc_info->set_mode) { in ingenic_mac_init()
79 ret = mac->soc_info->set_mode(plat_dat); in ingenic_mac_init()
89 struct ingenic_mac *mac = plat_dat->bsp_priv; in jz4775_mac_set_mode() local
92 switch (plat_dat->mac_interface) { in jz4775_mac_set_mode()
96 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n"); in jz4775_mac_set_mode()
102 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n"); in jz4775_mac_set_mode()
108 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in jz4775_mac_set_mode()
117 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n"); in jz4775_mac_set_mode()
121 dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface); in jz4775_mac_set_mode()
122 return -EINVAL; in jz4775_mac_set_mode()
125 /* Update MAC PHY control register */ in jz4775_mac_set_mode()
126 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in jz4775_mac_set_mode()
131 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1000_mac_set_mode() local
133 switch (plat_dat->mac_interface) { in x1000_mac_set_mode()
135 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1000_mac_set_mode()
139 dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface); in x1000_mac_set_mode()
140 return -EINVAL; in x1000_mac_set_mode()
143 /* Update MAC PHY control register */ in x1000_mac_set_mode()
144 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, 0); in x1000_mac_set_mode()
149 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1600_mac_set_mode() local
152 switch (plat_dat->mac_interface) { in x1600_mac_set_mode()
155 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1600_mac_set_mode()
159 dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface); in x1600_mac_set_mode()
160 return -EINVAL; in x1600_mac_set_mode()
163 /* Update MAC PHY control register */ in x1600_mac_set_mode()
164 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x1600_mac_set_mode()
169 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1830_mac_set_mode() local
172 switch (plat_dat->mac_interface) { in x1830_mac_set_mode()
176 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1830_mac_set_mode()
180 dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface); in x1830_mac_set_mode()
181 return -EINVAL; in x1830_mac_set_mode()
184 /* Update MAC PHY control register */ in x1830_mac_set_mode()
185 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x1830_mac_set_mode()
190 struct ingenic_mac *mac = plat_dat->bsp_priv; in x2000_mac_set_mode() local
193 switch (plat_dat->mac_interface) { in x2000_mac_set_mode()
198 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x2000_mac_set_mode()
207 if (mac->tx_delay == 0) in x2000_mac_set_mode()
211 FIELD_PREP(MACPHYC_TX_DELAY_MASK, (mac->tx_delay + 9750) / 19500 - 1); in x2000_mac_set_mode()
213 if (mac->rx_delay == 0) in x2000_mac_set_mode()
217 FIELD_PREP(MACPHYC_RX_DELAY_MASK, (mac->rx_delay + 9750) / 19500 - 1); in x2000_mac_set_mode()
219 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n"); in x2000_mac_set_mode()
223 dev_err(mac->dev, "Unsupported interface %d", plat_dat->mac_interface); in x2000_mac_set_mode()
224 return -EINVAL; in x2000_mac_set_mode()
227 /* Update MAC PHY control register */ in x2000_mac_set_mode()
228 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x2000_mac_set_mode()
235 struct ingenic_mac *mac; in ingenic_mac_probe() local
244 plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac); in ingenic_mac_probe()
248 mac = devm_kzalloc(&pdev->dev, sizeof(*mac), GFP_KERNEL); in ingenic_mac_probe()
249 if (!mac) in ingenic_mac_probe()
250 return -ENOMEM; in ingenic_mac_probe()
252 data = of_device_get_match_data(&pdev->dev); in ingenic_mac_probe()
254 dev_err(&pdev->dev, "No of match data provided\n"); in ingenic_mac_probe()
255 return -EINVAL; in ingenic_mac_probe()
258 /* Get MAC PHY control register */ in ingenic_mac_probe()
259 mac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "mode-reg"); in ingenic_mac_probe()
260 if (IS_ERR(mac->regmap)) { in ingenic_mac_probe()
261 dev_err(&pdev->dev, "%s: Failed to get syscon regmap\n", __func__); in ingenic_mac_probe()
262 return PTR_ERR(mac->regmap); in ingenic_mac_probe()
265 if (!of_property_read_u32(pdev->dev.of_node, "tx-clk-delay-ps", &tx_delay_ps)) { in ingenic_mac_probe()
268 mac->tx_delay = tx_delay_ps * 1000; in ingenic_mac_probe()
270 dev_err(&pdev->dev, "Invalid TX clock delay: %dps\n", tx_delay_ps); in ingenic_mac_probe()
271 return -EINVAL; in ingenic_mac_probe()
275 if (!of_property_read_u32(pdev->dev.of_node, "rx-clk-delay-ps", &rx_delay_ps)) { in ingenic_mac_probe()
278 mac->rx_delay = rx_delay_ps * 1000; in ingenic_mac_probe()
280 dev_err(&pdev->dev, "Invalid RX clock delay: %dps\n", rx_delay_ps); in ingenic_mac_probe()
281 return -EINVAL; in ingenic_mac_probe()
285 mac->soc_info = data; in ingenic_mac_probe()
286 mac->dev = &pdev->dev; in ingenic_mac_probe()
288 plat_dat->bsp_priv = mac; in ingenic_mac_probe()
294 return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in ingenic_mac_probe()
313 ret = ingenic_mac_init(priv->plat); in ingenic_mac_resume()
362 { .compatible = "ingenic,jz4775-mac", .data = &jz4775_soc_info },
363 { .compatible = "ingenic,x1000-mac", .data = &x1000_soc_info },
364 { .compatible = "ingenic,x1600-mac", .data = &x1600_soc_info },
365 { .compatible = "ingenic,x1830-mac", .data = &x1830_soc_info },
366 { .compatible = "ingenic,x2000-mac", .data = &x2000_soc_info },
375 .name = "ingenic-mac",