1 // SPDX-License-Identifier: GPL-2.0+
5 * Rockchip GMAC ethernet IP driver for U-Boot
15 #include <asm/arch-rockchip/periph.h>
16 #include <asm/arch-rockchip/clock.h>
17 #include <asm/arch-rockchip/hardware.h>
18 #include <asm/arch-rockchip/grf_px30.h>
19 #include <asm/arch-rockchip/grf_rk322x.h>
20 #include <asm/arch-rockchip/grf_rk3288.h>
21 #include <asm/arch-rk3308/grf_rk3308.h>
22 #include <asm/arch-rockchip/grf_rk3328.h>
23 #include <asm/arch-rockchip/grf_rk3368.h>
24 #include <asm/arch-rockchip/grf_rk3399.h>
25 #include <asm/arch-rockchip/grf_rv1108.h>
26 #include <dm/pinctrl.h>
27 #include <dt-bindings/clock/rk3288-cru.h>
28 #include "designware.h"
30 DECLARE_GLOBAL_DATA_PTR;
31 #define DELAY_ENABLE(soc, tx, rx) \
32 (((tx) ? soc##_TXCLK_DLY_ENA_GMAC_ENABLE : soc##_TXCLK_DLY_ENA_GMAC_DISABLE) | \
33 ((rx) ? soc##_RXCLK_DLY_ENA_GMAC_ENABLE : soc##_RXCLK_DLY_ENA_GMAC_DISABLE))
36 * Platform data for the gmac
38 * dw_eth_pdata: Required platform data for designware driver (must be first)
40 struct gmac_rockchip_platdata {
41 struct dw_eth_pdata dw_eth_pdata;
48 int (*fix_mac_speed)(struct dw_eth_dev *priv);
49 void (*set_to_rmii)(struct gmac_rockchip_platdata *pdata);
50 void (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata);
54 static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev)
56 struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
59 string = dev_read_string(dev, "clock_in_out");
60 if (!strcmp(string, "input"))
61 pdata->clock_input = true;
63 pdata->clock_input = false;
65 /* Check the new naming-style first... */
66 pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT);
67 pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT);
69 /* ... and fall back to the old naming style or default, if necessary */
70 if (pdata->tx_delay == -ENOENT)
71 pdata->tx_delay = dev_read_u32_default(dev, "tx-delay", 0x30);
72 if (pdata->rx_delay == -ENOENT)
73 pdata->rx_delay = dev_read_u32_default(dev, "rx-delay", 0x10);
75 return designware_eth_ofdata_to_platdata(dev);
78 static int px30_gmac_fix_mac_speed(struct dw_eth_dev *priv)
84 PX30_GMAC_SPEED_SHIFT = 0x2,
85 PX30_GMAC_SPEED_MASK = BIT(2),
86 PX30_GMAC_SPEED_10M = 0,
87 PX30_GMAC_SPEED_100M = BIT(2),
90 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
95 switch (priv->phydev->speed) {
97 speed = PX30_GMAC_SPEED_10M;
98 ret = clk_set_rate(&clk_speed, 2500000);
103 speed = PX30_GMAC_SPEED_100M;
104 ret = clk_set_rate(&clk_speed, 25000000);
109 debug("Unknown phy speed: %d\n", priv->phydev->speed);
113 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
114 rk_clrsetreg(&grf->mac_con1, PX30_GMAC_SPEED_MASK, speed);
119 static int rk3228_gmac_fix_mac_speed(struct dw_eth_dev *priv)
121 struct rk322x_grf *grf;
124 RK3228_GMAC_CLK_SEL_SHIFT = 8,
125 RK3228_GMAC_CLK_SEL_MASK = GENMASK(9, 8),
126 RK3228_GMAC_CLK_SEL_125M = 0 << 8,
127 RK3228_GMAC_CLK_SEL_25M = 3 << 8,
128 RK3228_GMAC_CLK_SEL_2_5M = 2 << 8,
131 switch (priv->phydev->speed) {
133 clk = RK3228_GMAC_CLK_SEL_2_5M;
136 clk = RK3228_GMAC_CLK_SEL_25M;
139 clk = RK3228_GMAC_CLK_SEL_125M;
142 debug("Unknown phy speed: %d\n", priv->phydev->speed);
146 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
147 rk_clrsetreg(&grf->mac_con[1], RK3228_GMAC_CLK_SEL_MASK, clk);
152 static int rk3288_gmac_fix_mac_speed(struct dw_eth_dev *priv)
154 struct rk3288_grf *grf;
157 switch (priv->phydev->speed) {
159 clk = RK3288_GMAC_CLK_SEL_2_5M;
162 clk = RK3288_GMAC_CLK_SEL_25M;
165 clk = RK3288_GMAC_CLK_SEL_125M;
168 debug("Unknown phy speed: %d\n", priv->phydev->speed);
172 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
173 rk_clrsetreg(&grf->soc_con1, RK3288_GMAC_CLK_SEL_MASK, clk);
178 static int rk3308_gmac_fix_mac_speed(struct dw_eth_dev *priv)
180 struct rk3308_grf *grf;
181 struct clk clk_speed;
184 RK3308_GMAC_SPEED_SHIFT = 0x0,
185 RK3308_GMAC_SPEED_MASK = BIT(0),
186 RK3308_GMAC_SPEED_10M = 0,
187 RK3308_GMAC_SPEED_100M = BIT(0),
190 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
195 switch (priv->phydev->speed) {
197 speed = RK3308_GMAC_SPEED_10M;
198 ret = clk_set_rate(&clk_speed, 2500000);
203 speed = RK3308_GMAC_SPEED_100M;
204 ret = clk_set_rate(&clk_speed, 25000000);
209 debug("Unknown phy speed: %d\n", priv->phydev->speed);
213 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
214 rk_clrsetreg(&grf->mac_con0, RK3308_GMAC_SPEED_MASK, speed);
219 static int rk3328_gmac_fix_mac_speed(struct dw_eth_dev *priv)
221 struct rk3328_grf_regs *grf;
224 RK3328_GMAC_CLK_SEL_SHIFT = 11,
225 RK3328_GMAC_CLK_SEL_MASK = GENMASK(12, 11),
226 RK3328_GMAC_CLK_SEL_125M = 0 << 11,
227 RK3328_GMAC_CLK_SEL_25M = 3 << 11,
228 RK3328_GMAC_CLK_SEL_2_5M = 2 << 11,
231 switch (priv->phydev->speed) {
233 clk = RK3328_GMAC_CLK_SEL_2_5M;
236 clk = RK3328_GMAC_CLK_SEL_25M;
239 clk = RK3328_GMAC_CLK_SEL_125M;
242 debug("Unknown phy speed: %d\n", priv->phydev->speed);
246 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
247 rk_clrsetreg(&grf->mac_con[1], RK3328_GMAC_CLK_SEL_MASK, clk);
252 static int rk3368_gmac_fix_mac_speed(struct dw_eth_dev *priv)
254 struct rk3368_grf *grf;
257 RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
258 RK3368_GMAC_CLK_SEL_25M = 3 << 4,
259 RK3368_GMAC_CLK_SEL_125M = 0 << 4,
260 RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
263 switch (priv->phydev->speed) {
265 clk = RK3368_GMAC_CLK_SEL_2_5M;
268 clk = RK3368_GMAC_CLK_SEL_25M;
271 clk = RK3368_GMAC_CLK_SEL_125M;
274 debug("Unknown phy speed: %d\n", priv->phydev->speed);
278 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
279 rk_clrsetreg(&grf->soc_con15, RK3368_GMAC_CLK_SEL_MASK, clk);
284 static int rk3399_gmac_fix_mac_speed(struct dw_eth_dev *priv)
286 struct rk3399_grf_regs *grf;
289 switch (priv->phydev->speed) {
291 clk = RK3399_GMAC_CLK_SEL_2_5M;
294 clk = RK3399_GMAC_CLK_SEL_25M;
297 clk = RK3399_GMAC_CLK_SEL_125M;
300 debug("Unknown phy speed: %d\n", priv->phydev->speed);
304 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
305 rk_clrsetreg(&grf->soc_con5, RK3399_GMAC_CLK_SEL_MASK, clk);
310 static int rv1108_set_rmii_speed(struct dw_eth_dev *priv)
312 struct rv1108_grf *grf;
315 RV1108_GMAC_SPEED_MASK = BIT(2),
316 RV1108_GMAC_SPEED_10M = 0 << 2,
317 RV1108_GMAC_SPEED_100M = 1 << 2,
318 RV1108_GMAC_CLK_SEL_MASK = BIT(7),
319 RV1108_GMAC_CLK_SEL_2_5M = 0 << 7,
320 RV1108_GMAC_CLK_SEL_25M = 1 << 7,
323 switch (priv->phydev->speed) {
325 clk = RV1108_GMAC_CLK_SEL_2_5M;
326 speed = RV1108_GMAC_SPEED_10M;
329 clk = RV1108_GMAC_CLK_SEL_25M;
330 speed = RV1108_GMAC_SPEED_100M;
333 debug("Unknown phy speed: %d\n", priv->phydev->speed);
337 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
338 rk_clrsetreg(&grf->gmac_con0,
339 RV1108_GMAC_CLK_SEL_MASK | RV1108_GMAC_SPEED_MASK,
345 static void px30_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
347 struct px30_grf *grf;
349 PX30_GMAC_PHY_INTF_SEL_SHIFT = 4,
350 PX30_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 6),
351 PX30_GMAC_PHY_INTF_SEL_RMII = BIT(6),
354 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
356 rk_clrsetreg(&grf->mac_con1,
357 PX30_GMAC_PHY_INTF_SEL_MASK,
358 PX30_GMAC_PHY_INTF_SEL_RMII);
361 static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
363 struct rk322x_grf *grf;
365 RK3228_RMII_MODE_SHIFT = 10,
366 RK3228_RMII_MODE_MASK = BIT(10),
368 RK3228_GMAC_PHY_INTF_SEL_SHIFT = 4,
369 RK3228_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
370 RK3228_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
372 RK3228_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
373 RK3228_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
374 RK3228_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
376 RK3228_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
377 RK3228_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
378 RK3228_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
381 RK3228_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
382 RK3228_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
384 RK3228_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
385 RK3228_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
388 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
389 rk_clrsetreg(&grf->mac_con[1],
390 RK3228_RMII_MODE_MASK |
391 RK3228_GMAC_PHY_INTF_SEL_MASK |
392 RK3228_RXCLK_DLY_ENA_GMAC_MASK |
393 RK3228_TXCLK_DLY_ENA_GMAC_MASK,
394 RK3228_GMAC_PHY_INTF_SEL_RGMII |
395 DELAY_ENABLE(RK3228, pdata->tx_delay, pdata->rx_delay));
397 rk_clrsetreg(&grf->mac_con[0],
398 RK3228_CLK_RX_DL_CFG_GMAC_MASK |
399 RK3228_CLK_TX_DL_CFG_GMAC_MASK,
400 pdata->rx_delay << RK3228_CLK_RX_DL_CFG_GMAC_SHIFT |
401 pdata->tx_delay << RK3228_CLK_TX_DL_CFG_GMAC_SHIFT);
404 static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
406 struct rk3288_grf *grf;
408 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
409 rk_clrsetreg(&grf->soc_con1,
410 RK3288_RMII_MODE_MASK | RK3288_GMAC_PHY_INTF_SEL_MASK,
411 RK3288_GMAC_PHY_INTF_SEL_RGMII);
413 rk_clrsetreg(&grf->soc_con3,
414 RK3288_RXCLK_DLY_ENA_GMAC_MASK |
415 RK3288_TXCLK_DLY_ENA_GMAC_MASK |
416 RK3288_CLK_RX_DL_CFG_GMAC_MASK |
417 RK3288_CLK_TX_DL_CFG_GMAC_MASK,
418 DELAY_ENABLE(RK3288, pdata->rx_delay, pdata->tx_delay) |
419 pdata->rx_delay << RK3288_CLK_RX_DL_CFG_GMAC_SHIFT |
420 pdata->tx_delay << RK3288_CLK_TX_DL_CFG_GMAC_SHIFT);
423 static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
425 struct rk3308_grf *grf;
427 RK3308_GMAC_PHY_INTF_SEL_SHIFT = 2,
428 RK3308_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 2),
429 RK3308_GMAC_PHY_INTF_SEL_RMII = BIT(4),
432 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
434 rk_clrsetreg(&grf->mac_con0,
435 RK3308_GMAC_PHY_INTF_SEL_MASK,
436 RK3308_GMAC_PHY_INTF_SEL_RMII);
439 static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
441 struct rk3328_grf_regs *grf;
443 RK3328_RMII_MODE_SHIFT = 9,
444 RK3328_RMII_MODE_MASK = BIT(9),
446 RK3328_GMAC_PHY_INTF_SEL_SHIFT = 4,
447 RK3328_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
448 RK3328_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
450 RK3328_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
451 RK3328_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
452 RK3328_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
454 RK3328_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
455 RK3328_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
456 RK3328_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
459 RK3328_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
460 RK3328_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
462 RK3328_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
463 RK3328_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
466 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
467 rk_clrsetreg(&grf->mac_con[1],
468 RK3328_RMII_MODE_MASK |
469 RK3328_GMAC_PHY_INTF_SEL_MASK |
470 RK3328_RXCLK_DLY_ENA_GMAC_MASK |
471 RK3328_TXCLK_DLY_ENA_GMAC_MASK,
472 RK3328_GMAC_PHY_INTF_SEL_RGMII |
473 DELAY_ENABLE(RK3328, pdata->tx_delay, pdata->rx_delay));
475 rk_clrsetreg(&grf->mac_con[0],
476 RK3328_CLK_RX_DL_CFG_GMAC_MASK |
477 RK3328_CLK_TX_DL_CFG_GMAC_MASK,
478 pdata->rx_delay << RK3328_CLK_RX_DL_CFG_GMAC_SHIFT |
479 pdata->tx_delay << RK3328_CLK_TX_DL_CFG_GMAC_SHIFT);
482 static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
484 struct rk3368_grf *grf;
486 RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
487 RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
488 RK3368_RMII_MODE_MASK = BIT(6),
489 RK3368_RMII_MODE = BIT(6),
492 RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
493 RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
494 RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
495 RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
496 RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
497 RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
498 RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
499 RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
500 RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
501 RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
504 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
505 rk_clrsetreg(&grf->soc_con15,
506 RK3368_RMII_MODE_MASK | RK3368_GMAC_PHY_INTF_SEL_MASK,
507 RK3368_GMAC_PHY_INTF_SEL_RGMII);
509 rk_clrsetreg(&grf->soc_con16,
510 RK3368_RXCLK_DLY_ENA_GMAC_MASK |
511 RK3368_TXCLK_DLY_ENA_GMAC_MASK |
512 RK3368_CLK_RX_DL_CFG_GMAC_MASK |
513 RK3368_CLK_TX_DL_CFG_GMAC_MASK,
514 DELAY_ENABLE(RK3368, pdata->tx_delay, pdata->rx_delay) |
515 pdata->rx_delay << RK3368_CLK_RX_DL_CFG_GMAC_SHIFT |
516 pdata->tx_delay << RK3368_CLK_TX_DL_CFG_GMAC_SHIFT);
519 static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
521 struct rk3399_grf_regs *grf;
523 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
525 rk_clrsetreg(&grf->soc_con5,
526 RK3399_GMAC_PHY_INTF_SEL_MASK,
527 RK3399_GMAC_PHY_INTF_SEL_RGMII);
529 rk_clrsetreg(&grf->soc_con6,
530 RK3399_RXCLK_DLY_ENA_GMAC_MASK |
531 RK3399_TXCLK_DLY_ENA_GMAC_MASK |
532 RK3399_CLK_RX_DL_CFG_GMAC_MASK |
533 RK3399_CLK_TX_DL_CFG_GMAC_MASK,
534 DELAY_ENABLE(RK3399, pdata->tx_delay, pdata->rx_delay) |
535 pdata->rx_delay << RK3399_CLK_RX_DL_CFG_GMAC_SHIFT |
536 pdata->tx_delay << RK3399_CLK_TX_DL_CFG_GMAC_SHIFT);
539 static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
541 struct rv1108_grf *grf;
544 RV1108_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
545 RV1108_GMAC_PHY_INTF_SEL_RMII = 4 << 4,
548 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
549 rk_clrsetreg(&grf->gmac_con0,
550 RV1108_GMAC_PHY_INTF_SEL_MASK,
551 RV1108_GMAC_PHY_INTF_SEL_RMII);
554 static int gmac_rockchip_probe(struct udevice *dev)
556 struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
557 struct rk_gmac_ops *ops =
558 (struct rk_gmac_ops *)dev_get_driver_data(dev);
559 struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
560 struct eth_pdata *eth_pdata = &dw_pdata->eth_pdata;
565 ret = clk_set_defaults(dev, 0);
567 debug("%s clk_set_defaults failed %d\n", __func__, ret);
569 ret = clk_get_by_index(dev, 0, &clk);
573 switch (eth_pdata->phy_interface) {
574 case PHY_INTERFACE_MODE_RGMII:
575 /* Set to RGMII mode */
576 if (ops->set_to_rgmii)
577 ops->set_to_rgmii(pdata);
582 * If the gmac clock is from internal pll, need to set and
583 * check the return value for gmac clock at RGMII mode. If
584 * the gmac clock is from external source, the clock rate
585 * is not set, because of it is bypassed.
588 if (!pdata->clock_input) {
589 rate = clk_set_rate(&clk, 125000000);
590 if (rate != 125000000)
595 case PHY_INTERFACE_MODE_RGMII_ID:
596 /* Set to RGMII mode */
597 if (ops->set_to_rgmii) {
600 ops->set_to_rgmii(pdata);
604 if (!pdata->clock_input) {
605 rate = clk_set_rate(&clk, 125000000);
606 if (rate != 125000000)
611 case PHY_INTERFACE_MODE_RMII:
612 /* Set to RMII mode */
613 if (ops->set_to_rmii)
614 ops->set_to_rmii(pdata);
618 if (!pdata->clock_input) {
619 rate = clk_set_rate(&clk, 50000000);
620 if (rate != 50000000)
625 case PHY_INTERFACE_MODE_RGMII_RXID:
626 /* Set to RGMII_RXID mode */
627 if (ops->set_to_rgmii) {
629 ops->set_to_rgmii(pdata);
633 if (!pdata->clock_input) {
634 rate = clk_set_rate(&clk, 125000000);
635 if (rate != 125000000)
640 case PHY_INTERFACE_MODE_RGMII_TXID:
641 /* Set to RGMII_TXID mode */
642 if (ops->set_to_rgmii) {
644 ops->set_to_rgmii(pdata);
648 if (!pdata->clock_input) {
649 rate = clk_set_rate(&clk, 125000000);
650 if (rate != 125000000)
656 debug("NO interface defined!\n");
660 return designware_eth_probe(dev);
663 static int gmac_rockchip_eth_start(struct udevice *dev)
665 struct eth_pdata *pdata = dev_get_platdata(dev);
666 struct dw_eth_dev *priv = dev_get_priv(dev);
667 struct rk_gmac_ops *ops =
668 (struct rk_gmac_ops *)dev_get_driver_data(dev);
671 ret = designware_eth_init(priv, pdata->enetaddr);
674 ret = ops->fix_mac_speed(priv);
677 ret = designware_eth_enable(priv);
684 const struct eth_ops gmac_rockchip_eth_ops = {
685 .start = gmac_rockchip_eth_start,
686 .send = designware_eth_send,
687 .recv = designware_eth_recv,
688 .free_pkt = designware_eth_free_pkt,
689 .stop = designware_eth_stop,
690 .write_hwaddr = designware_eth_write_hwaddr,
693 const struct rk_gmac_ops px30_gmac_ops = {
694 .fix_mac_speed = px30_gmac_fix_mac_speed,
695 .set_to_rmii = px30_gmac_set_to_rmii,
698 const struct rk_gmac_ops rk3228_gmac_ops = {
699 .fix_mac_speed = rk3228_gmac_fix_mac_speed,
700 .set_to_rgmii = rk3228_gmac_set_to_rgmii,
703 const struct rk_gmac_ops rk3288_gmac_ops = {
704 .fix_mac_speed = rk3288_gmac_fix_mac_speed,
705 .set_to_rgmii = rk3288_gmac_set_to_rgmii,
708 const struct rk_gmac_ops rk3308_gmac_ops = {
709 .fix_mac_speed = rk3308_gmac_fix_mac_speed,
710 .set_to_rmii = rk3308_gmac_set_to_rmii,
713 const struct rk_gmac_ops rk3328_gmac_ops = {
714 .fix_mac_speed = rk3328_gmac_fix_mac_speed,
715 .set_to_rgmii = rk3328_gmac_set_to_rgmii,
718 const struct rk_gmac_ops rk3368_gmac_ops = {
719 .fix_mac_speed = rk3368_gmac_fix_mac_speed,
720 .set_to_rgmii = rk3368_gmac_set_to_rgmii,
723 const struct rk_gmac_ops rk3399_gmac_ops = {
724 .fix_mac_speed = rk3399_gmac_fix_mac_speed,
725 .set_to_rgmii = rk3399_gmac_set_to_rgmii,
728 const struct rk_gmac_ops rv1108_gmac_ops = {
729 .fix_mac_speed = rv1108_set_rmii_speed,
730 .set_to_rmii = rv1108_gmac_set_to_rmii,
733 static const struct udevice_id rockchip_gmac_ids[] = {
734 { .compatible = "rockchip,px30-gmac",
735 .data = (ulong)&px30_gmac_ops },
736 { .compatible = "rockchip,rk3228-gmac",
737 .data = (ulong)&rk3228_gmac_ops },
738 { .compatible = "rockchip,rk3288-gmac",
739 .data = (ulong)&rk3288_gmac_ops },
740 { .compatible = "rockchip,rk3308-mac",
741 .data = (ulong)&rk3308_gmac_ops },
742 { .compatible = "rockchip,rk3328-gmac",
743 .data = (ulong)&rk3328_gmac_ops },
744 { .compatible = "rockchip,rk3368-gmac",
745 .data = (ulong)&rk3368_gmac_ops },
746 { .compatible = "rockchip,rk3399-gmac",
747 .data = (ulong)&rk3399_gmac_ops },
748 { .compatible = "rockchip,rv1108-gmac",
749 .data = (ulong)&rv1108_gmac_ops },
753 U_BOOT_DRIVER(eth_gmac_rockchip) = {
754 .name = "gmac_rockchip",
756 .of_match = rockchip_gmac_ids,
757 .ofdata_to_platdata = gmac_rockchip_ofdata_to_platdata,
758 .probe = gmac_rockchip_probe,
759 .ops = &gmac_rockchip_eth_ops,
760 .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
761 .platdata_auto_alloc_size = sizeof(struct gmac_rockchip_platdata),
762 .flags = DM_FLAG_ALLOC_PRIV_DMA,