1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2015 Sjoerd Simons <sjoerd.simons@collabora.co.uk>
5 * Rockchip GMAC ethernet IP driver for U-Boot
15 #include <asm/global_data.h>
17 #include <asm/arch-rockchip/periph.h>
18 #include <asm/arch-rockchip/clock.h>
19 #include <asm/arch-rockchip/hardware.h>
20 #include <asm/arch-rockchip/grf_px30.h>
21 #include <asm/arch-rockchip/grf_rk322x.h>
22 #include <asm/arch-rockchip/grf_rk3288.h>
23 #include <asm/arch-rk3308/grf_rk3308.h>
24 #include <asm/arch-rockchip/grf_rk3328.h>
25 #include <asm/arch-rockchip/grf_rk3368.h>
26 #include <asm/arch-rockchip/grf_rk3399.h>
27 #include <asm/arch-rockchip/grf_rv1108.h>
28 #include <dm/pinctrl.h>
29 #include <dt-bindings/clock/rk3288-cru.h>
30 #include <linux/bitops.h>
31 #include "designware.h"
33 DECLARE_GLOBAL_DATA_PTR;
34 #define DELAY_ENABLE(soc, tx, rx) \
35 (((tx) ? soc##_TXCLK_DLY_ENA_GMAC_ENABLE : soc##_TXCLK_DLY_ENA_GMAC_DISABLE) | \
36 ((rx) ? soc##_RXCLK_DLY_ENA_GMAC_ENABLE : soc##_RXCLK_DLY_ENA_GMAC_DISABLE))
39 * Platform data for the gmac
41 * dw_eth_pdata: Required platform data for designware driver (must be first)
43 struct gmac_rockchip_plat {
44 struct dw_eth_pdata dw_eth_pdata;
51 int (*fix_mac_speed)(struct dw_eth_dev *priv);
52 void (*set_to_rmii)(struct gmac_rockchip_plat *pdata);
53 void (*set_to_rgmii)(struct gmac_rockchip_plat *pdata);
57 static int gmac_rockchip_of_to_plat(struct udevice *dev)
59 struct gmac_rockchip_plat *pdata = dev_get_plat(dev);
62 string = dev_read_string(dev, "clock_in_out");
63 if (!strcmp(string, "input"))
64 pdata->clock_input = true;
66 pdata->clock_input = false;
68 /* Check the new naming-style first... */
69 pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT);
70 pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT);
72 /* ... and fall back to the old naming style or default, if necessary */
73 if (pdata->tx_delay == -ENOENT)
74 pdata->tx_delay = dev_read_u32_default(dev, "tx-delay", 0x30);
75 if (pdata->rx_delay == -ENOENT)
76 pdata->rx_delay = dev_read_u32_default(dev, "rx-delay", 0x10);
78 return designware_eth_of_to_plat(dev);
81 static int px30_gmac_fix_mac_speed(struct dw_eth_dev *priv)
87 PX30_GMAC_SPEED_SHIFT = 0x2,
88 PX30_GMAC_SPEED_MASK = BIT(2),
89 PX30_GMAC_SPEED_10M = 0,
90 PX30_GMAC_SPEED_100M = BIT(2),
93 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
98 switch (priv->phydev->speed) {
100 speed = PX30_GMAC_SPEED_10M;
101 ret = clk_set_rate(&clk_speed, 2500000);
106 speed = PX30_GMAC_SPEED_100M;
107 ret = clk_set_rate(&clk_speed, 25000000);
112 debug("Unknown phy speed: %d\n", priv->phydev->speed);
116 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
117 rk_clrsetreg(&grf->mac_con1, PX30_GMAC_SPEED_MASK, speed);
122 static int rk3228_gmac_fix_mac_speed(struct dw_eth_dev *priv)
124 struct rk322x_grf *grf;
127 RK3228_GMAC_CLK_SEL_SHIFT = 8,
128 RK3228_GMAC_CLK_SEL_MASK = GENMASK(9, 8),
129 RK3228_GMAC_CLK_SEL_125M = 0 << 8,
130 RK3228_GMAC_CLK_SEL_25M = 3 << 8,
131 RK3228_GMAC_CLK_SEL_2_5M = 2 << 8,
134 switch (priv->phydev->speed) {
136 clk = RK3228_GMAC_CLK_SEL_2_5M;
139 clk = RK3228_GMAC_CLK_SEL_25M;
142 clk = RK3228_GMAC_CLK_SEL_125M;
145 debug("Unknown phy speed: %d\n", priv->phydev->speed);
149 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
150 rk_clrsetreg(&grf->mac_con[1], RK3228_GMAC_CLK_SEL_MASK, clk);
155 static int rk3288_gmac_fix_mac_speed(struct dw_eth_dev *priv)
157 struct rk3288_grf *grf;
160 switch (priv->phydev->speed) {
162 clk = RK3288_GMAC_CLK_SEL_2_5M;
165 clk = RK3288_GMAC_CLK_SEL_25M;
168 clk = RK3288_GMAC_CLK_SEL_125M;
171 debug("Unknown phy speed: %d\n", priv->phydev->speed);
175 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
176 rk_clrsetreg(&grf->soc_con1, RK3288_GMAC_CLK_SEL_MASK, clk);
181 static int rk3308_gmac_fix_mac_speed(struct dw_eth_dev *priv)
183 struct rk3308_grf *grf;
184 struct clk clk_speed;
187 RK3308_GMAC_SPEED_SHIFT = 0x0,
188 RK3308_GMAC_SPEED_MASK = BIT(0),
189 RK3308_GMAC_SPEED_10M = 0,
190 RK3308_GMAC_SPEED_100M = BIT(0),
193 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
198 switch (priv->phydev->speed) {
200 speed = RK3308_GMAC_SPEED_10M;
201 ret = clk_set_rate(&clk_speed, 2500000);
206 speed = RK3308_GMAC_SPEED_100M;
207 ret = clk_set_rate(&clk_speed, 25000000);
212 debug("Unknown phy speed: %d\n", priv->phydev->speed);
216 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
217 rk_clrsetreg(&grf->mac_con0, RK3308_GMAC_SPEED_MASK, speed);
222 static int rk3328_gmac_fix_mac_speed(struct dw_eth_dev *priv)
224 struct rk3328_grf_regs *grf;
227 RK3328_GMAC_CLK_SEL_SHIFT = 11,
228 RK3328_GMAC_CLK_SEL_MASK = GENMASK(12, 11),
229 RK3328_GMAC_CLK_SEL_125M = 0 << 11,
230 RK3328_GMAC_CLK_SEL_25M = 3 << 11,
231 RK3328_GMAC_CLK_SEL_2_5M = 2 << 11,
234 switch (priv->phydev->speed) {
236 clk = RK3328_GMAC_CLK_SEL_2_5M;
239 clk = RK3328_GMAC_CLK_SEL_25M;
242 clk = RK3328_GMAC_CLK_SEL_125M;
245 debug("Unknown phy speed: %d\n", priv->phydev->speed);
249 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
250 rk_clrsetreg(&grf->mac_con[1], RK3328_GMAC_CLK_SEL_MASK, clk);
255 static int rk3368_gmac_fix_mac_speed(struct dw_eth_dev *priv)
257 struct rk3368_grf *grf;
260 RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
261 RK3368_GMAC_CLK_SEL_25M = 3 << 4,
262 RK3368_GMAC_CLK_SEL_125M = 0 << 4,
263 RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
266 switch (priv->phydev->speed) {
268 clk = RK3368_GMAC_CLK_SEL_2_5M;
271 clk = RK3368_GMAC_CLK_SEL_25M;
274 clk = RK3368_GMAC_CLK_SEL_125M;
277 debug("Unknown phy speed: %d\n", priv->phydev->speed);
281 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
282 rk_clrsetreg(&grf->soc_con15, RK3368_GMAC_CLK_SEL_MASK, clk);
287 static int rk3399_gmac_fix_mac_speed(struct dw_eth_dev *priv)
289 struct rk3399_grf_regs *grf;
292 switch (priv->phydev->speed) {
294 clk = RK3399_GMAC_CLK_SEL_2_5M;
297 clk = RK3399_GMAC_CLK_SEL_25M;
300 clk = RK3399_GMAC_CLK_SEL_125M;
303 debug("Unknown phy speed: %d\n", priv->phydev->speed);
307 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
308 rk_clrsetreg(&grf->soc_con5, RK3399_GMAC_CLK_SEL_MASK, clk);
313 static int rv1108_set_rmii_speed(struct dw_eth_dev *priv)
315 struct rv1108_grf *grf;
318 RV1108_GMAC_SPEED_MASK = BIT(2),
319 RV1108_GMAC_SPEED_10M = 0 << 2,
320 RV1108_GMAC_SPEED_100M = 1 << 2,
321 RV1108_GMAC_CLK_SEL_MASK = BIT(7),
322 RV1108_GMAC_CLK_SEL_2_5M = 0 << 7,
323 RV1108_GMAC_CLK_SEL_25M = 1 << 7,
326 switch (priv->phydev->speed) {
328 clk = RV1108_GMAC_CLK_SEL_2_5M;
329 speed = RV1108_GMAC_SPEED_10M;
332 clk = RV1108_GMAC_CLK_SEL_25M;
333 speed = RV1108_GMAC_SPEED_100M;
336 debug("Unknown phy speed: %d\n", priv->phydev->speed);
340 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
341 rk_clrsetreg(&grf->gmac_con0,
342 RV1108_GMAC_CLK_SEL_MASK | RV1108_GMAC_SPEED_MASK,
348 static void px30_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)
350 struct px30_grf *grf;
352 PX30_GMAC_PHY_INTF_SEL_SHIFT = 4,
353 PX30_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 6),
354 PX30_GMAC_PHY_INTF_SEL_RMII = BIT(6),
357 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
359 rk_clrsetreg(&grf->mac_con1,
360 PX30_GMAC_PHY_INTF_SEL_MASK,
361 PX30_GMAC_PHY_INTF_SEL_RMII);
364 static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata)
366 struct rk322x_grf *grf;
368 RK3228_RMII_MODE_SHIFT = 10,
369 RK3228_RMII_MODE_MASK = BIT(10),
371 RK3228_GMAC_PHY_INTF_SEL_SHIFT = 4,
372 RK3228_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
373 RK3228_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
375 RK3228_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
376 RK3228_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
377 RK3228_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
379 RK3228_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
380 RK3228_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
381 RK3228_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
384 RK3228_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
385 RK3228_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
387 RK3228_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
388 RK3228_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
391 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
392 rk_clrsetreg(&grf->mac_con[1],
393 RK3228_RMII_MODE_MASK |
394 RK3228_GMAC_PHY_INTF_SEL_MASK |
395 RK3228_RXCLK_DLY_ENA_GMAC_MASK |
396 RK3228_TXCLK_DLY_ENA_GMAC_MASK,
397 RK3228_GMAC_PHY_INTF_SEL_RGMII |
398 DELAY_ENABLE(RK3228, pdata->tx_delay, pdata->rx_delay));
400 rk_clrsetreg(&grf->mac_con[0],
401 RK3228_CLK_RX_DL_CFG_GMAC_MASK |
402 RK3228_CLK_TX_DL_CFG_GMAC_MASK,
403 pdata->rx_delay << RK3228_CLK_RX_DL_CFG_GMAC_SHIFT |
404 pdata->tx_delay << RK3228_CLK_TX_DL_CFG_GMAC_SHIFT);
407 static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata)
409 struct rk3288_grf *grf;
411 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
412 rk_clrsetreg(&grf->soc_con1,
413 RK3288_RMII_MODE_MASK | RK3288_GMAC_PHY_INTF_SEL_MASK,
414 RK3288_GMAC_PHY_INTF_SEL_RGMII);
416 rk_clrsetreg(&grf->soc_con3,
417 RK3288_RXCLK_DLY_ENA_GMAC_MASK |
418 RK3288_TXCLK_DLY_ENA_GMAC_MASK |
419 RK3288_CLK_RX_DL_CFG_GMAC_MASK |
420 RK3288_CLK_TX_DL_CFG_GMAC_MASK,
421 DELAY_ENABLE(RK3288, pdata->rx_delay, pdata->tx_delay) |
422 pdata->rx_delay << RK3288_CLK_RX_DL_CFG_GMAC_SHIFT |
423 pdata->tx_delay << RK3288_CLK_TX_DL_CFG_GMAC_SHIFT);
426 static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)
428 struct rk3308_grf *grf;
430 RK3308_GMAC_PHY_INTF_SEL_SHIFT = 2,
431 RK3308_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 2),
432 RK3308_GMAC_PHY_INTF_SEL_RMII = BIT(4),
435 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
437 rk_clrsetreg(&grf->mac_con0,
438 RK3308_GMAC_PHY_INTF_SEL_MASK,
439 RK3308_GMAC_PHY_INTF_SEL_RMII);
442 static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata)
444 struct rk3328_grf_regs *grf;
446 RK3328_RMII_MODE_SHIFT = 9,
447 RK3328_RMII_MODE_MASK = BIT(9),
449 RK3328_GMAC_PHY_INTF_SEL_SHIFT = 4,
450 RK3328_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
451 RK3328_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
453 RK3328_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
454 RK3328_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
455 RK3328_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
457 RK3328_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
458 RK3328_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
459 RK3328_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
462 RK3328_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
463 RK3328_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
465 RK3328_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
466 RK3328_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
469 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
470 rk_clrsetreg(&grf->mac_con[1],
471 RK3328_RMII_MODE_MASK |
472 RK3328_GMAC_PHY_INTF_SEL_MASK |
473 RK3328_RXCLK_DLY_ENA_GMAC_MASK |
474 RK3328_TXCLK_DLY_ENA_GMAC_MASK,
475 RK3328_GMAC_PHY_INTF_SEL_RGMII |
476 DELAY_ENABLE(RK3328, pdata->tx_delay, pdata->rx_delay));
478 rk_clrsetreg(&grf->mac_con[0],
479 RK3328_CLK_RX_DL_CFG_GMAC_MASK |
480 RK3328_CLK_TX_DL_CFG_GMAC_MASK,
481 pdata->rx_delay << RK3328_CLK_RX_DL_CFG_GMAC_SHIFT |
482 pdata->tx_delay << RK3328_CLK_TX_DL_CFG_GMAC_SHIFT);
485 static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata)
487 struct rk3368_grf *grf;
489 RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
490 RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
491 RK3368_RMII_MODE_MASK = BIT(6),
492 RK3368_RMII_MODE = BIT(6),
495 RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
496 RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
497 RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
498 RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
499 RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
500 RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
501 RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
502 RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
503 RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
504 RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
507 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
508 rk_clrsetreg(&grf->soc_con15,
509 RK3368_RMII_MODE_MASK | RK3368_GMAC_PHY_INTF_SEL_MASK,
510 RK3368_GMAC_PHY_INTF_SEL_RGMII);
512 rk_clrsetreg(&grf->soc_con16,
513 RK3368_RXCLK_DLY_ENA_GMAC_MASK |
514 RK3368_TXCLK_DLY_ENA_GMAC_MASK |
515 RK3368_CLK_RX_DL_CFG_GMAC_MASK |
516 RK3368_CLK_TX_DL_CFG_GMAC_MASK,
517 DELAY_ENABLE(RK3368, pdata->tx_delay, pdata->rx_delay) |
518 pdata->rx_delay << RK3368_CLK_RX_DL_CFG_GMAC_SHIFT |
519 pdata->tx_delay << RK3368_CLK_TX_DL_CFG_GMAC_SHIFT);
522 static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_plat *pdata)
524 struct rk3399_grf_regs *grf;
526 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
528 rk_clrsetreg(&grf->soc_con5,
529 RK3399_GMAC_PHY_INTF_SEL_MASK,
530 RK3399_GMAC_PHY_INTF_SEL_RGMII);
532 rk_clrsetreg(&grf->soc_con6,
533 RK3399_RXCLK_DLY_ENA_GMAC_MASK |
534 RK3399_TXCLK_DLY_ENA_GMAC_MASK |
535 RK3399_CLK_RX_DL_CFG_GMAC_MASK |
536 RK3399_CLK_TX_DL_CFG_GMAC_MASK,
537 DELAY_ENABLE(RK3399, pdata->tx_delay, pdata->rx_delay) |
538 pdata->rx_delay << RK3399_CLK_RX_DL_CFG_GMAC_SHIFT |
539 pdata->tx_delay << RK3399_CLK_TX_DL_CFG_GMAC_SHIFT);
542 static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_plat *pdata)
544 struct rv1108_grf *grf;
547 RV1108_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
548 RV1108_GMAC_PHY_INTF_SEL_RMII = 4 << 4,
551 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
552 rk_clrsetreg(&grf->gmac_con0,
553 RV1108_GMAC_PHY_INTF_SEL_MASK,
554 RV1108_GMAC_PHY_INTF_SEL_RMII);
557 static int gmac_rockchip_probe(struct udevice *dev)
559 struct gmac_rockchip_plat *pdata = dev_get_plat(dev);
560 struct rk_gmac_ops *ops =
561 (struct rk_gmac_ops *)dev_get_driver_data(dev);
562 struct dw_eth_pdata *dw_pdata = dev_get_plat(dev);
563 struct eth_pdata *eth_pdata = &dw_pdata->eth_pdata;
568 ret = clk_set_defaults(dev, CLK_DEFAULTS_PRE);
570 debug("%s clk_set_defaults failed %d\n", __func__, ret);
572 ret = clk_get_by_index(dev, 0, &clk);
576 switch (eth_pdata->phy_interface) {
577 case PHY_INTERFACE_MODE_RGMII:
578 /* Set to RGMII mode */
579 if (ops->set_to_rgmii)
580 ops->set_to_rgmii(pdata);
585 * If the gmac clock is from internal pll, need to set and
586 * check the return value for gmac clock at RGMII mode. If
587 * the gmac clock is from external source, the clock rate
588 * is not set, because of it is bypassed.
591 if (!pdata->clock_input) {
592 rate = clk_set_rate(&clk, 125000000);
593 if (rate != 125000000)
598 case PHY_INTERFACE_MODE_RGMII_ID:
599 /* Set to RGMII mode */
600 if (ops->set_to_rgmii) {
603 ops->set_to_rgmii(pdata);
607 if (!pdata->clock_input) {
608 rate = clk_set_rate(&clk, 125000000);
609 if (rate != 125000000)
614 case PHY_INTERFACE_MODE_RMII:
615 /* Set to RMII mode */
616 if (ops->set_to_rmii)
617 ops->set_to_rmii(pdata);
621 if (!pdata->clock_input) {
622 rate = clk_set_rate(&clk, 50000000);
623 if (rate != 50000000)
628 case PHY_INTERFACE_MODE_RGMII_RXID:
629 /* Set to RGMII_RXID mode */
630 if (ops->set_to_rgmii) {
632 ops->set_to_rgmii(pdata);
636 if (!pdata->clock_input) {
637 rate = clk_set_rate(&clk, 125000000);
638 if (rate != 125000000)
643 case PHY_INTERFACE_MODE_RGMII_TXID:
644 /* Set to RGMII_TXID mode */
645 if (ops->set_to_rgmii) {
647 ops->set_to_rgmii(pdata);
651 if (!pdata->clock_input) {
652 rate = clk_set_rate(&clk, 125000000);
653 if (rate != 125000000)
659 debug("NO interface defined!\n");
663 return designware_eth_probe(dev);
666 static int gmac_rockchip_eth_start(struct udevice *dev)
668 struct eth_pdata *pdata = dev_get_plat(dev);
669 struct dw_eth_dev *priv = dev_get_priv(dev);
670 struct rk_gmac_ops *ops =
671 (struct rk_gmac_ops *)dev_get_driver_data(dev);
674 ret = designware_eth_init(priv, pdata->enetaddr);
677 ret = ops->fix_mac_speed(priv);
680 ret = designware_eth_enable(priv);
687 const struct eth_ops gmac_rockchip_eth_ops = {
688 .start = gmac_rockchip_eth_start,
689 .send = designware_eth_send,
690 .recv = designware_eth_recv,
691 .free_pkt = designware_eth_free_pkt,
692 .stop = designware_eth_stop,
693 .write_hwaddr = designware_eth_write_hwaddr,
696 const struct rk_gmac_ops px30_gmac_ops = {
697 .fix_mac_speed = px30_gmac_fix_mac_speed,
698 .set_to_rmii = px30_gmac_set_to_rmii,
701 const struct rk_gmac_ops rk3228_gmac_ops = {
702 .fix_mac_speed = rk3228_gmac_fix_mac_speed,
703 .set_to_rgmii = rk3228_gmac_set_to_rgmii,
706 const struct rk_gmac_ops rk3288_gmac_ops = {
707 .fix_mac_speed = rk3288_gmac_fix_mac_speed,
708 .set_to_rgmii = rk3288_gmac_set_to_rgmii,
711 const struct rk_gmac_ops rk3308_gmac_ops = {
712 .fix_mac_speed = rk3308_gmac_fix_mac_speed,
713 .set_to_rmii = rk3308_gmac_set_to_rmii,
716 const struct rk_gmac_ops rk3328_gmac_ops = {
717 .fix_mac_speed = rk3328_gmac_fix_mac_speed,
718 .set_to_rgmii = rk3328_gmac_set_to_rgmii,
721 const struct rk_gmac_ops rk3368_gmac_ops = {
722 .fix_mac_speed = rk3368_gmac_fix_mac_speed,
723 .set_to_rgmii = rk3368_gmac_set_to_rgmii,
726 const struct rk_gmac_ops rk3399_gmac_ops = {
727 .fix_mac_speed = rk3399_gmac_fix_mac_speed,
728 .set_to_rgmii = rk3399_gmac_set_to_rgmii,
731 const struct rk_gmac_ops rv1108_gmac_ops = {
732 .fix_mac_speed = rv1108_set_rmii_speed,
733 .set_to_rmii = rv1108_gmac_set_to_rmii,
736 static const struct udevice_id rockchip_gmac_ids[] = {
737 { .compatible = "rockchip,px30-gmac",
738 .data = (ulong)&px30_gmac_ops },
739 { .compatible = "rockchip,rk3228-gmac",
740 .data = (ulong)&rk3228_gmac_ops },
741 { .compatible = "rockchip,rk3288-gmac",
742 .data = (ulong)&rk3288_gmac_ops },
743 { .compatible = "rockchip,rk3308-mac",
744 .data = (ulong)&rk3308_gmac_ops },
745 { .compatible = "rockchip,rk3328-gmac",
746 .data = (ulong)&rk3328_gmac_ops },
747 { .compatible = "rockchip,rk3368-gmac",
748 .data = (ulong)&rk3368_gmac_ops },
749 { .compatible = "rockchip,rk3399-gmac",
750 .data = (ulong)&rk3399_gmac_ops },
751 { .compatible = "rockchip,rv1108-gmac",
752 .data = (ulong)&rv1108_gmac_ops },
756 U_BOOT_DRIVER(eth_gmac_rockchip) = {
757 .name = "gmac_rockchip",
759 .of_match = rockchip_gmac_ids,
760 .of_to_plat = gmac_rockchip_of_to_plat,
761 .probe = gmac_rockchip_probe,
762 .ops = &gmac_rockchip_eth_ops,
763 .priv_auto = sizeof(struct dw_eth_dev),
764 .plat_auto = sizeof(struct gmac_rockchip_plat),
765 .flags = DM_FLAG_ALLOC_PRIV_DMA,