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 = 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 ret = -ENOMEM; in ingenic_mac_probe()
254 data = of_device_get_match_data(&pdev->dev); in ingenic_mac_probe()
256 dev_err(&pdev->dev, "No of match data provided\n"); in ingenic_mac_probe()
257 ret = -EINVAL; in ingenic_mac_probe()
261 /* Get MAC PHY control register */ in ingenic_mac_probe()
262 mac->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "mode-reg"); in ingenic_mac_probe()
263 if (IS_ERR(mac->regmap)) { in ingenic_mac_probe()
264 dev_err(&pdev->dev, "%s: Failed to get syscon regmap\n", __func__); in ingenic_mac_probe()
265 ret = PTR_ERR(mac->regmap); in ingenic_mac_probe()
269 if (!of_property_read_u32(pdev->dev.of_node, "tx-clk-delay-ps", &tx_delay_ps)) { in ingenic_mac_probe()
272 mac->tx_delay = tx_delay_ps * 1000; in ingenic_mac_probe()
274 dev_err(&pdev->dev, "Invalid TX clock delay: %dps\n", tx_delay_ps); in ingenic_mac_probe()
275 ret = -EINVAL; in ingenic_mac_probe()
280 if (!of_property_read_u32(pdev->dev.of_node, "rx-clk-delay-ps", &rx_delay_ps)) { in ingenic_mac_probe()
283 mac->rx_delay = rx_delay_ps * 1000; in ingenic_mac_probe()
285 dev_err(&pdev->dev, "Invalid RX clock delay: %dps\n", rx_delay_ps); in ingenic_mac_probe()
286 ret = -EINVAL; in ingenic_mac_probe()
291 mac->soc_info = data; in ingenic_mac_probe()
292 mac->dev = &pdev->dev; in ingenic_mac_probe()
294 plat_dat->bsp_priv = mac; in ingenic_mac_probe()
300 ret = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); in ingenic_mac_probe()
328 ret = ingenic_mac_init(priv->plat); in ingenic_mac_resume()
377 { .compatible = "ingenic,jz4775-mac", .data = &jz4775_soc_info },
378 { .compatible = "ingenic,x1000-mac", .data = &x1000_soc_info },
379 { .compatible = "ingenic,x1600-mac", .data = &x1600_soc_info },
380 { .compatible = "ingenic,x1830-mac", .data = &x1830_soc_info },
381 { .compatible = "ingenic,x2000-mac", .data = &x2000_soc_info },
390 .name = "ingenic-mac",