1 // SPDX-License-Identifier: GPL-2.0+
5 * Rockchip GMAC ethernet IP driver for U-Boot
16 #include <asm/arch-rockchip/periph.h>
17 #include <asm/arch-rockchip/clock.h>
18 #include <asm/arch-rockchip/hardware.h>
19 #include <asm/arch-rockchip/grf_px30.h>
20 #include <asm/arch-rockchip/grf_rk322x.h>
21 #include <asm/arch-rockchip/grf_rk3288.h>
22 #include <asm/arch-rk3308/grf_rk3308.h>
23 #include <asm/arch-rockchip/grf_rk3328.h>
24 #include <asm/arch-rockchip/grf_rk3368.h>
25 #include <asm/arch-rockchip/grf_rk3399.h>
26 #include <asm/arch-rockchip/grf_rv1108.h>
27 #include <dm/pinctrl.h>
28 #include <dt-bindings/clock/rk3288-cru.h>
29 #include "designware.h"
31 DECLARE_GLOBAL_DATA_PTR;
32 #define DELAY_ENABLE(soc, tx, rx) \
33 (((tx) ? soc##_TXCLK_DLY_ENA_GMAC_ENABLE : soc##_TXCLK_DLY_ENA_GMAC_DISABLE) | \
34 ((rx) ? soc##_RXCLK_DLY_ENA_GMAC_ENABLE : soc##_RXCLK_DLY_ENA_GMAC_DISABLE))
37 * Platform data for the gmac
39 * dw_eth_pdata: Required platform data for designware driver (must be first)
41 struct gmac_rockchip_platdata {
42 struct dw_eth_pdata dw_eth_pdata;
49 int (*fix_mac_speed)(struct dw_eth_dev *priv);
50 void (*set_to_rmii)(struct gmac_rockchip_platdata *pdata);
51 void (*set_to_rgmii)(struct gmac_rockchip_platdata *pdata);
55 static int gmac_rockchip_ofdata_to_platdata(struct udevice *dev)
57 struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
60 string = dev_read_string(dev, "clock_in_out");
61 if (!strcmp(string, "input"))
62 pdata->clock_input = true;
64 pdata->clock_input = false;
66 /* Check the new naming-style first... */
67 pdata->tx_delay = dev_read_u32_default(dev, "tx_delay", -ENOENT);
68 pdata->rx_delay = dev_read_u32_default(dev, "rx_delay", -ENOENT);
70 /* ... and fall back to the old naming style or default, if necessary */
71 if (pdata->tx_delay == -ENOENT)
72 pdata->tx_delay = dev_read_u32_default(dev, "tx-delay", 0x30);
73 if (pdata->rx_delay == -ENOENT)
74 pdata->rx_delay = dev_read_u32_default(dev, "rx-delay", 0x10);
76 return designware_eth_ofdata_to_platdata(dev);
79 static int px30_gmac_fix_mac_speed(struct dw_eth_dev *priv)
85 PX30_GMAC_SPEED_SHIFT = 0x2,
86 PX30_GMAC_SPEED_MASK = BIT(2),
87 PX30_GMAC_SPEED_10M = 0,
88 PX30_GMAC_SPEED_100M = BIT(2),
91 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
96 switch (priv->phydev->speed) {
98 speed = PX30_GMAC_SPEED_10M;
99 ret = clk_set_rate(&clk_speed, 2500000);
104 speed = PX30_GMAC_SPEED_100M;
105 ret = clk_set_rate(&clk_speed, 25000000);
110 debug("Unknown phy speed: %d\n", priv->phydev->speed);
114 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
115 rk_clrsetreg(&grf->mac_con1, PX30_GMAC_SPEED_MASK, speed);
120 static int rk3228_gmac_fix_mac_speed(struct dw_eth_dev *priv)
122 struct rk322x_grf *grf;
125 RK3228_GMAC_CLK_SEL_SHIFT = 8,
126 RK3228_GMAC_CLK_SEL_MASK = GENMASK(9, 8),
127 RK3228_GMAC_CLK_SEL_125M = 0 << 8,
128 RK3228_GMAC_CLK_SEL_25M = 3 << 8,
129 RK3228_GMAC_CLK_SEL_2_5M = 2 << 8,
132 switch (priv->phydev->speed) {
134 clk = RK3228_GMAC_CLK_SEL_2_5M;
137 clk = RK3228_GMAC_CLK_SEL_25M;
140 clk = RK3228_GMAC_CLK_SEL_125M;
143 debug("Unknown phy speed: %d\n", priv->phydev->speed);
147 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
148 rk_clrsetreg(&grf->mac_con[1], RK3228_GMAC_CLK_SEL_MASK, clk);
153 static int rk3288_gmac_fix_mac_speed(struct dw_eth_dev *priv)
155 struct rk3288_grf *grf;
158 switch (priv->phydev->speed) {
160 clk = RK3288_GMAC_CLK_SEL_2_5M;
163 clk = RK3288_GMAC_CLK_SEL_25M;
166 clk = RK3288_GMAC_CLK_SEL_125M;
169 debug("Unknown phy speed: %d\n", priv->phydev->speed);
173 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
174 rk_clrsetreg(&grf->soc_con1, RK3288_GMAC_CLK_SEL_MASK, clk);
179 static int rk3308_gmac_fix_mac_speed(struct dw_eth_dev *priv)
181 struct rk3308_grf *grf;
182 struct clk clk_speed;
185 RK3308_GMAC_SPEED_SHIFT = 0x0,
186 RK3308_GMAC_SPEED_MASK = BIT(0),
187 RK3308_GMAC_SPEED_10M = 0,
188 RK3308_GMAC_SPEED_100M = BIT(0),
191 ret = clk_get_by_name(priv->phydev->dev, "clk_mac_speed",
196 switch (priv->phydev->speed) {
198 speed = RK3308_GMAC_SPEED_10M;
199 ret = clk_set_rate(&clk_speed, 2500000);
204 speed = RK3308_GMAC_SPEED_100M;
205 ret = clk_set_rate(&clk_speed, 25000000);
210 debug("Unknown phy speed: %d\n", priv->phydev->speed);
214 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
215 rk_clrsetreg(&grf->mac_con0, RK3308_GMAC_SPEED_MASK, speed);
220 static int rk3328_gmac_fix_mac_speed(struct dw_eth_dev *priv)
222 struct rk3328_grf_regs *grf;
225 RK3328_GMAC_CLK_SEL_SHIFT = 11,
226 RK3328_GMAC_CLK_SEL_MASK = GENMASK(12, 11),
227 RK3328_GMAC_CLK_SEL_125M = 0 << 11,
228 RK3328_GMAC_CLK_SEL_25M = 3 << 11,
229 RK3328_GMAC_CLK_SEL_2_5M = 2 << 11,
232 switch (priv->phydev->speed) {
234 clk = RK3328_GMAC_CLK_SEL_2_5M;
237 clk = RK3328_GMAC_CLK_SEL_25M;
240 clk = RK3328_GMAC_CLK_SEL_125M;
243 debug("Unknown phy speed: %d\n", priv->phydev->speed);
247 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
248 rk_clrsetreg(&grf->mac_con[1], RK3328_GMAC_CLK_SEL_MASK, clk);
253 static int rk3368_gmac_fix_mac_speed(struct dw_eth_dev *priv)
255 struct rk3368_grf *grf;
258 RK3368_GMAC_CLK_SEL_2_5M = 2 << 4,
259 RK3368_GMAC_CLK_SEL_25M = 3 << 4,
260 RK3368_GMAC_CLK_SEL_125M = 0 << 4,
261 RK3368_GMAC_CLK_SEL_MASK = GENMASK(5, 4),
264 switch (priv->phydev->speed) {
266 clk = RK3368_GMAC_CLK_SEL_2_5M;
269 clk = RK3368_GMAC_CLK_SEL_25M;
272 clk = RK3368_GMAC_CLK_SEL_125M;
275 debug("Unknown phy speed: %d\n", priv->phydev->speed);
279 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
280 rk_clrsetreg(&grf->soc_con15, RK3368_GMAC_CLK_SEL_MASK, clk);
285 static int rk3399_gmac_fix_mac_speed(struct dw_eth_dev *priv)
287 struct rk3399_grf_regs *grf;
290 switch (priv->phydev->speed) {
292 clk = RK3399_GMAC_CLK_SEL_2_5M;
295 clk = RK3399_GMAC_CLK_SEL_25M;
298 clk = RK3399_GMAC_CLK_SEL_125M;
301 debug("Unknown phy speed: %d\n", priv->phydev->speed);
305 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
306 rk_clrsetreg(&grf->soc_con5, RK3399_GMAC_CLK_SEL_MASK, clk);
311 static int rv1108_set_rmii_speed(struct dw_eth_dev *priv)
313 struct rv1108_grf *grf;
316 RV1108_GMAC_SPEED_MASK = BIT(2),
317 RV1108_GMAC_SPEED_10M = 0 << 2,
318 RV1108_GMAC_SPEED_100M = 1 << 2,
319 RV1108_GMAC_CLK_SEL_MASK = BIT(7),
320 RV1108_GMAC_CLK_SEL_2_5M = 0 << 7,
321 RV1108_GMAC_CLK_SEL_25M = 1 << 7,
324 switch (priv->phydev->speed) {
326 clk = RV1108_GMAC_CLK_SEL_2_5M;
327 speed = RV1108_GMAC_SPEED_10M;
330 clk = RV1108_GMAC_CLK_SEL_25M;
331 speed = RV1108_GMAC_SPEED_100M;
334 debug("Unknown phy speed: %d\n", priv->phydev->speed);
338 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
339 rk_clrsetreg(&grf->gmac_con0,
340 RV1108_GMAC_CLK_SEL_MASK | RV1108_GMAC_SPEED_MASK,
346 static void px30_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
348 struct px30_grf *grf;
350 PX30_GMAC_PHY_INTF_SEL_SHIFT = 4,
351 PX30_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 6),
352 PX30_GMAC_PHY_INTF_SEL_RMII = BIT(6),
355 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
357 rk_clrsetreg(&grf->mac_con1,
358 PX30_GMAC_PHY_INTF_SEL_MASK,
359 PX30_GMAC_PHY_INTF_SEL_RMII);
362 static void rk3228_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
364 struct rk322x_grf *grf;
366 RK3228_RMII_MODE_SHIFT = 10,
367 RK3228_RMII_MODE_MASK = BIT(10),
369 RK3228_GMAC_PHY_INTF_SEL_SHIFT = 4,
370 RK3228_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
371 RK3228_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
373 RK3228_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
374 RK3228_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
375 RK3228_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
377 RK3228_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
378 RK3228_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
379 RK3228_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
382 RK3228_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
383 RK3228_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
385 RK3228_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
386 RK3228_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
389 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
390 rk_clrsetreg(&grf->mac_con[1],
391 RK3228_RMII_MODE_MASK |
392 RK3228_GMAC_PHY_INTF_SEL_MASK |
393 RK3228_RXCLK_DLY_ENA_GMAC_MASK |
394 RK3228_TXCLK_DLY_ENA_GMAC_MASK,
395 RK3228_GMAC_PHY_INTF_SEL_RGMII |
396 DELAY_ENABLE(RK3228, pdata->tx_delay, pdata->rx_delay));
398 rk_clrsetreg(&grf->mac_con[0],
399 RK3228_CLK_RX_DL_CFG_GMAC_MASK |
400 RK3228_CLK_TX_DL_CFG_GMAC_MASK,
401 pdata->rx_delay << RK3228_CLK_RX_DL_CFG_GMAC_SHIFT |
402 pdata->tx_delay << RK3228_CLK_TX_DL_CFG_GMAC_SHIFT);
405 static void rk3288_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
407 struct rk3288_grf *grf;
409 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
410 rk_clrsetreg(&grf->soc_con1,
411 RK3288_RMII_MODE_MASK | RK3288_GMAC_PHY_INTF_SEL_MASK,
412 RK3288_GMAC_PHY_INTF_SEL_RGMII);
414 rk_clrsetreg(&grf->soc_con3,
415 RK3288_RXCLK_DLY_ENA_GMAC_MASK |
416 RK3288_TXCLK_DLY_ENA_GMAC_MASK |
417 RK3288_CLK_RX_DL_CFG_GMAC_MASK |
418 RK3288_CLK_TX_DL_CFG_GMAC_MASK,
419 DELAY_ENABLE(RK3288, pdata->rx_delay, pdata->tx_delay) |
420 pdata->rx_delay << RK3288_CLK_RX_DL_CFG_GMAC_SHIFT |
421 pdata->tx_delay << RK3288_CLK_TX_DL_CFG_GMAC_SHIFT);
424 static void rk3308_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
426 struct rk3308_grf *grf;
428 RK3308_GMAC_PHY_INTF_SEL_SHIFT = 2,
429 RK3308_GMAC_PHY_INTF_SEL_MASK = GENMASK(4, 2),
430 RK3308_GMAC_PHY_INTF_SEL_RMII = BIT(4),
433 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
435 rk_clrsetreg(&grf->mac_con0,
436 RK3308_GMAC_PHY_INTF_SEL_MASK,
437 RK3308_GMAC_PHY_INTF_SEL_RMII);
440 static void rk3328_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
442 struct rk3328_grf_regs *grf;
444 RK3328_RMII_MODE_SHIFT = 9,
445 RK3328_RMII_MODE_MASK = BIT(9),
447 RK3328_GMAC_PHY_INTF_SEL_SHIFT = 4,
448 RK3328_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
449 RK3328_GMAC_PHY_INTF_SEL_RGMII = BIT(4),
451 RK3328_RXCLK_DLY_ENA_GMAC_MASK = BIT(1),
452 RK3328_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
453 RK3328_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(1),
455 RK3328_TXCLK_DLY_ENA_GMAC_MASK = BIT(0),
456 RK3328_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
457 RK3328_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(0),
460 RK3328_CLK_RX_DL_CFG_GMAC_SHIFT = 0x7,
461 RK3328_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(13, 7),
463 RK3328_CLK_TX_DL_CFG_GMAC_SHIFT = 0x0,
464 RK3328_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
467 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
468 rk_clrsetreg(&grf->mac_con[1],
469 RK3328_RMII_MODE_MASK |
470 RK3328_GMAC_PHY_INTF_SEL_MASK |
471 RK3328_RXCLK_DLY_ENA_GMAC_MASK |
472 RK3328_TXCLK_DLY_ENA_GMAC_MASK,
473 RK3328_GMAC_PHY_INTF_SEL_RGMII |
474 DELAY_ENABLE(RK3328, pdata->tx_delay, pdata->rx_delay));
476 rk_clrsetreg(&grf->mac_con[0],
477 RK3328_CLK_RX_DL_CFG_GMAC_MASK |
478 RK3328_CLK_TX_DL_CFG_GMAC_MASK,
479 pdata->rx_delay << RK3328_CLK_RX_DL_CFG_GMAC_SHIFT |
480 pdata->tx_delay << RK3328_CLK_TX_DL_CFG_GMAC_SHIFT);
483 static void rk3368_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
485 struct rk3368_grf *grf;
487 RK3368_GMAC_PHY_INTF_SEL_RGMII = 1 << 9,
488 RK3368_GMAC_PHY_INTF_SEL_MASK = GENMASK(11, 9),
489 RK3368_RMII_MODE_MASK = BIT(6),
490 RK3368_RMII_MODE = BIT(6),
493 RK3368_RXCLK_DLY_ENA_GMAC_MASK = BIT(15),
494 RK3368_RXCLK_DLY_ENA_GMAC_DISABLE = 0,
495 RK3368_RXCLK_DLY_ENA_GMAC_ENABLE = BIT(15),
496 RK3368_TXCLK_DLY_ENA_GMAC_MASK = BIT(7),
497 RK3368_TXCLK_DLY_ENA_GMAC_DISABLE = 0,
498 RK3368_TXCLK_DLY_ENA_GMAC_ENABLE = BIT(7),
499 RK3368_CLK_RX_DL_CFG_GMAC_SHIFT = 8,
500 RK3368_CLK_RX_DL_CFG_GMAC_MASK = GENMASK(14, 8),
501 RK3368_CLK_TX_DL_CFG_GMAC_SHIFT = 0,
502 RK3368_CLK_TX_DL_CFG_GMAC_MASK = GENMASK(6, 0),
505 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
506 rk_clrsetreg(&grf->soc_con15,
507 RK3368_RMII_MODE_MASK | RK3368_GMAC_PHY_INTF_SEL_MASK,
508 RK3368_GMAC_PHY_INTF_SEL_RGMII);
510 rk_clrsetreg(&grf->soc_con16,
511 RK3368_RXCLK_DLY_ENA_GMAC_MASK |
512 RK3368_TXCLK_DLY_ENA_GMAC_MASK |
513 RK3368_CLK_RX_DL_CFG_GMAC_MASK |
514 RK3368_CLK_TX_DL_CFG_GMAC_MASK,
515 DELAY_ENABLE(RK3368, pdata->tx_delay, pdata->rx_delay) |
516 pdata->rx_delay << RK3368_CLK_RX_DL_CFG_GMAC_SHIFT |
517 pdata->tx_delay << RK3368_CLK_TX_DL_CFG_GMAC_SHIFT);
520 static void rk3399_gmac_set_to_rgmii(struct gmac_rockchip_platdata *pdata)
522 struct rk3399_grf_regs *grf;
524 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
526 rk_clrsetreg(&grf->soc_con5,
527 RK3399_GMAC_PHY_INTF_SEL_MASK,
528 RK3399_GMAC_PHY_INTF_SEL_RGMII);
530 rk_clrsetreg(&grf->soc_con6,
531 RK3399_RXCLK_DLY_ENA_GMAC_MASK |
532 RK3399_TXCLK_DLY_ENA_GMAC_MASK |
533 RK3399_CLK_RX_DL_CFG_GMAC_MASK |
534 RK3399_CLK_TX_DL_CFG_GMAC_MASK,
535 DELAY_ENABLE(RK3399, pdata->tx_delay, pdata->rx_delay) |
536 pdata->rx_delay << RK3399_CLK_RX_DL_CFG_GMAC_SHIFT |
537 pdata->tx_delay << RK3399_CLK_TX_DL_CFG_GMAC_SHIFT);
540 static void rv1108_gmac_set_to_rmii(struct gmac_rockchip_platdata *pdata)
542 struct rv1108_grf *grf;
545 RV1108_GMAC_PHY_INTF_SEL_MASK = GENMASK(6, 4),
546 RV1108_GMAC_PHY_INTF_SEL_RMII = 4 << 4,
549 grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
550 rk_clrsetreg(&grf->gmac_con0,
551 RV1108_GMAC_PHY_INTF_SEL_MASK,
552 RV1108_GMAC_PHY_INTF_SEL_RMII);
555 static int gmac_rockchip_probe(struct udevice *dev)
557 struct gmac_rockchip_platdata *pdata = dev_get_platdata(dev);
558 struct rk_gmac_ops *ops =
559 (struct rk_gmac_ops *)dev_get_driver_data(dev);
560 struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
561 struct eth_pdata *eth_pdata = &dw_pdata->eth_pdata;
566 ret = clk_set_defaults(dev, 0);
568 debug("%s clk_set_defaults failed %d\n", __func__, ret);
570 ret = clk_get_by_index(dev, 0, &clk);
574 switch (eth_pdata->phy_interface) {
575 case PHY_INTERFACE_MODE_RGMII:
576 /* Set to RGMII mode */
577 if (ops->set_to_rgmii)
578 ops->set_to_rgmii(pdata);
583 * If the gmac clock is from internal pll, need to set and
584 * check the return value for gmac clock at RGMII mode. If
585 * the gmac clock is from external source, the clock rate
586 * is not set, because of it is bypassed.
589 if (!pdata->clock_input) {
590 rate = clk_set_rate(&clk, 125000000);
591 if (rate != 125000000)
596 case PHY_INTERFACE_MODE_RGMII_ID:
597 /* Set to RGMII mode */
598 if (ops->set_to_rgmii) {
601 ops->set_to_rgmii(pdata);
605 if (!pdata->clock_input) {
606 rate = clk_set_rate(&clk, 125000000);
607 if (rate != 125000000)
612 case PHY_INTERFACE_MODE_RMII:
613 /* Set to RMII mode */
614 if (ops->set_to_rmii)
615 ops->set_to_rmii(pdata);
619 if (!pdata->clock_input) {
620 rate = clk_set_rate(&clk, 50000000);
621 if (rate != 50000000)
626 case PHY_INTERFACE_MODE_RGMII_RXID:
627 /* Set to RGMII_RXID mode */
628 if (ops->set_to_rgmii) {
630 ops->set_to_rgmii(pdata);
634 if (!pdata->clock_input) {
635 rate = clk_set_rate(&clk, 125000000);
636 if (rate != 125000000)
641 case PHY_INTERFACE_MODE_RGMII_TXID:
642 /* Set to RGMII_TXID mode */
643 if (ops->set_to_rgmii) {
645 ops->set_to_rgmii(pdata);
649 if (!pdata->clock_input) {
650 rate = clk_set_rate(&clk, 125000000);
651 if (rate != 125000000)
657 debug("NO interface defined!\n");
661 return designware_eth_probe(dev);
664 static int gmac_rockchip_eth_start(struct udevice *dev)
666 struct eth_pdata *pdata = dev_get_platdata(dev);
667 struct dw_eth_dev *priv = dev_get_priv(dev);
668 struct rk_gmac_ops *ops =
669 (struct rk_gmac_ops *)dev_get_driver_data(dev);
672 ret = designware_eth_init(priv, pdata->enetaddr);
675 ret = ops->fix_mac_speed(priv);
678 ret = designware_eth_enable(priv);
685 const struct eth_ops gmac_rockchip_eth_ops = {
686 .start = gmac_rockchip_eth_start,
687 .send = designware_eth_send,
688 .recv = designware_eth_recv,
689 .free_pkt = designware_eth_free_pkt,
690 .stop = designware_eth_stop,
691 .write_hwaddr = designware_eth_write_hwaddr,
694 const struct rk_gmac_ops px30_gmac_ops = {
695 .fix_mac_speed = px30_gmac_fix_mac_speed,
696 .set_to_rmii = px30_gmac_set_to_rmii,
699 const struct rk_gmac_ops rk3228_gmac_ops = {
700 .fix_mac_speed = rk3228_gmac_fix_mac_speed,
701 .set_to_rgmii = rk3228_gmac_set_to_rgmii,
704 const struct rk_gmac_ops rk3288_gmac_ops = {
705 .fix_mac_speed = rk3288_gmac_fix_mac_speed,
706 .set_to_rgmii = rk3288_gmac_set_to_rgmii,
709 const struct rk_gmac_ops rk3308_gmac_ops = {
710 .fix_mac_speed = rk3308_gmac_fix_mac_speed,
711 .set_to_rmii = rk3308_gmac_set_to_rmii,
714 const struct rk_gmac_ops rk3328_gmac_ops = {
715 .fix_mac_speed = rk3328_gmac_fix_mac_speed,
716 .set_to_rgmii = rk3328_gmac_set_to_rgmii,
719 const struct rk_gmac_ops rk3368_gmac_ops = {
720 .fix_mac_speed = rk3368_gmac_fix_mac_speed,
721 .set_to_rgmii = rk3368_gmac_set_to_rgmii,
724 const struct rk_gmac_ops rk3399_gmac_ops = {
725 .fix_mac_speed = rk3399_gmac_fix_mac_speed,
726 .set_to_rgmii = rk3399_gmac_set_to_rgmii,
729 const struct rk_gmac_ops rv1108_gmac_ops = {
730 .fix_mac_speed = rv1108_set_rmii_speed,
731 .set_to_rmii = rv1108_gmac_set_to_rmii,
734 static const struct udevice_id rockchip_gmac_ids[] = {
735 { .compatible = "rockchip,px30-gmac",
736 .data = (ulong)&px30_gmac_ops },
737 { .compatible = "rockchip,rk3228-gmac",
738 .data = (ulong)&rk3228_gmac_ops },
739 { .compatible = "rockchip,rk3288-gmac",
740 .data = (ulong)&rk3288_gmac_ops },
741 { .compatible = "rockchip,rk3308-mac",
742 .data = (ulong)&rk3308_gmac_ops },
743 { .compatible = "rockchip,rk3328-gmac",
744 .data = (ulong)&rk3328_gmac_ops },
745 { .compatible = "rockchip,rk3368-gmac",
746 .data = (ulong)&rk3368_gmac_ops },
747 { .compatible = "rockchip,rk3399-gmac",
748 .data = (ulong)&rk3399_gmac_ops },
749 { .compatible = "rockchip,rv1108-gmac",
750 .data = (ulong)&rv1108_gmac_ops },
754 U_BOOT_DRIVER(eth_gmac_rockchip) = {
755 .name = "gmac_rockchip",
757 .of_match = rockchip_gmac_ids,
758 .ofdata_to_platdata = gmac_rockchip_ofdata_to_platdata,
759 .probe = gmac_rockchip_probe,
760 .ops = &gmac_rockchip_eth_ops,
761 .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
762 .platdata_auto_alloc_size = sizeof(struct gmac_rockchip_platdata),
763 .flags = DM_FLAG_ALLOC_PRIV_DMA,