Lines Matching +full:mac +full:- +full:clk +full:- +full:rx
1 // SPDX-License-Identifier: GPL-2.0
3 * dwmac-ingenic.c - Ingenic SoCs DWMAC specific glue layer
9 #include <linux/clk.h>
76 struct ingenic_mac *mac = plat_dat->bsp_priv; in ingenic_mac_init() local
79 if (mac->soc_info->set_mode) { in ingenic_mac_init()
80 ret = mac->soc_info->set_mode(plat_dat); in ingenic_mac_init()
90 struct ingenic_mac *mac = plat_dat->bsp_priv; in jz4775_mac_set_mode() local
93 switch (plat_dat->interface) { in jz4775_mac_set_mode()
97 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_MII\n"); in jz4775_mac_set_mode()
103 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_GMII\n"); in jz4775_mac_set_mode()
109 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in jz4775_mac_set_mode()
118 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n"); in jz4775_mac_set_mode()
122 dev_err(mac->dev, "Unsupported interface %d", plat_dat->interface); in jz4775_mac_set_mode()
123 return -EINVAL; in jz4775_mac_set_mode()
126 /* Update MAC PHY control register */ in jz4775_mac_set_mode()
127 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in jz4775_mac_set_mode()
132 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1000_mac_set_mode() local
134 switch (plat_dat->interface) { in x1000_mac_set_mode()
136 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1000_mac_set_mode()
140 dev_err(mac->dev, "Unsupported interface %d", plat_dat->interface); in x1000_mac_set_mode()
141 return -EINVAL; in x1000_mac_set_mode()
144 /* Update MAC PHY control register */ in x1000_mac_set_mode()
145 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, 0); in x1000_mac_set_mode()
150 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1600_mac_set_mode() local
153 switch (plat_dat->interface) { in x1600_mac_set_mode()
156 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1600_mac_set_mode()
160 dev_err(mac->dev, "Unsupported interface %d", plat_dat->interface); in x1600_mac_set_mode()
161 return -EINVAL; in x1600_mac_set_mode()
164 /* Update MAC PHY control register */ in x1600_mac_set_mode()
165 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x1600_mac_set_mode()
170 struct ingenic_mac *mac = plat_dat->bsp_priv; in x1830_mac_set_mode() local
173 switch (plat_dat->interface) { in x1830_mac_set_mode()
177 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x1830_mac_set_mode()
181 dev_err(mac->dev, "Unsupported interface %d", plat_dat->interface); in x1830_mac_set_mode()
182 return -EINVAL; in x1830_mac_set_mode()
185 /* Update MAC PHY control register */ in x1830_mac_set_mode()
186 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x1830_mac_set_mode()
191 struct ingenic_mac *mac = plat_dat->bsp_priv; in x2000_mac_set_mode() local
194 switch (plat_dat->interface) { in x2000_mac_set_mode()
199 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RMII\n"); in x2000_mac_set_mode()
208 if (mac->tx_delay == 0) in x2000_mac_set_mode()
212 FIELD_PREP(MACPHYC_TX_DELAY_MASK, (mac->tx_delay + 9750) / 19500 - 1); in x2000_mac_set_mode()
214 if (mac->rx_delay == 0) in x2000_mac_set_mode()
218 FIELD_PREP(MACPHYC_RX_DELAY_MASK, (mac->rx_delay + 9750) / 19500 - 1); in x2000_mac_set_mode()
220 dev_dbg(mac->dev, "MAC PHY Control Register: PHY_INTERFACE_MODE_RGMII\n"); in x2000_mac_set_mode()
224 dev_err(mac->dev, "Unsupported interface %d", plat_dat->interface); in x2000_mac_set_mode()
225 return -EINVAL; in x2000_mac_set_mode()
228 /* Update MAC PHY control register */ in x2000_mac_set_mode()
229 return regmap_update_bits(mac->regmap, 0, mac->soc_info->mask, val); in x2000_mac_set_mode()
236 struct ingenic_mac *mac; in ingenic_mac_probe() local
245 plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac); in ingenic_mac_probe()
249 mac = devm_kzalloc(&pdev->dev, sizeof(*mac), GFP_KERNEL); in ingenic_mac_probe()
250 if (!mac) { in ingenic_mac_probe()
251 ret = -ENOMEM; in ingenic_mac_probe()
255 data = of_device_get_match_data(&pdev->dev); in ingenic_mac_probe()
257 dev_err(&pdev->dev, "No of match data provided\n"); in ingenic_mac_probe()
258 ret = -EINVAL; in ingenic_mac_probe()
262 /* Get MAC PHY control register */ in ingenic_mac_probe()
263 mac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "mode-reg"); in ingenic_mac_probe()
264 if (IS_ERR(mac->regmap)) { in ingenic_mac_probe()
265 dev_err(&pdev->dev, "%s: Failed to get syscon regmap\n", __func__); in ingenic_mac_probe()
266 ret = PTR_ERR(mac->regmap); in ingenic_mac_probe()
270 if (!of_property_read_u32(pdev->dev.of_node, "tx-clk-delay-ps", &tx_delay_ps)) { in ingenic_mac_probe()
273 mac->tx_delay = tx_delay_ps * 1000; in ingenic_mac_probe()
275 dev_err(&pdev->dev, "Invalid TX clock delay: %dps\n", tx_delay_ps); in ingenic_mac_probe()
276 ret = -EINVAL; in ingenic_mac_probe()
281 if (!of_property_read_u32(pdev->dev.of_node, "rx-clk-delay-ps", &rx_delay_ps)) { in ingenic_mac_probe()
284 mac->rx_delay = rx_delay_ps * 1000; in ingenic_mac_probe()
286 dev_err(&pdev->dev, "Invalid RX clock delay: %dps\n", rx_delay_ps); in ingenic_mac_probe()
287 ret = -EINVAL; in ingenic_mac_probe()
292 mac->soc_info = data; in ingenic_mac_probe()
293 mac->dev = &pdev->dev; in ingenic_mac_probe()
295 plat_dat->bsp_priv = mac; in ingenic_mac_probe()
301 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in ingenic_mac_probe()
329 ret = ingenic_mac_init(priv->plat); in ingenic_mac_resume()
378 { .compatible = "ingenic,jz4775-mac", .data = &jz4775_soc_info },
379 { .compatible = "ingenic,x1000-mac", .data = &x1000_soc_info },
380 { .compatible = "ingenic,x1600-mac", .data = &x1600_soc_info },
381 { .compatible = "ingenic,x1830-mac", .data = &x1830_soc_info },
382 { .compatible = "ingenic,x2000-mac", .data = &x2000_soc_info },
391 .name = "ingenic-mac",