designware.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. /*
  2. * (C) Copyright 2010
  3. * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /*
  8. * Designware ethernet IP driver for U-Boot
  9. */
  10. #include <common.h>
  11. #include <dm.h>
  12. #include <errno.h>
  13. #include <miiphy.h>
  14. #include <malloc.h>
  15. #include <linux/compiler.h>
  16. #include <linux/err.h>
  17. #include <asm/io.h>
  18. #include "designware.h"
  19. DECLARE_GLOBAL_DATA_PTR;
  20. #if !defined(CONFIG_PHYLIB)
  21. # error "DesignWare Ether MAC requires PHYLIB - missing CONFIG_PHYLIB"
  22. #endif
  23. static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg)
  24. {
  25. struct eth_mac_regs *mac_p = bus->priv;
  26. ulong start;
  27. u16 miiaddr;
  28. int timeout = CONFIG_MDIO_TIMEOUT;
  29. miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) |
  30. ((reg << MIIREGSHIFT) & MII_REGMSK);
  31. writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr);
  32. start = get_timer(0);
  33. while (get_timer(start) < timeout) {
  34. if (!(readl(&mac_p->miiaddr) & MII_BUSY))
  35. return readl(&mac_p->miidata);
  36. udelay(10);
  37. };
  38. return -ETIMEDOUT;
  39. }
  40. static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg,
  41. u16 val)
  42. {
  43. struct eth_mac_regs *mac_p = bus->priv;
  44. ulong start;
  45. u16 miiaddr;
  46. int ret = -ETIMEDOUT, timeout = CONFIG_MDIO_TIMEOUT;
  47. writel(val, &mac_p->miidata);
  48. miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) |
  49. ((reg << MIIREGSHIFT) & MII_REGMSK) | MII_WRITE;
  50. writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr);
  51. start = get_timer(0);
  52. while (get_timer(start) < timeout) {
  53. if (!(readl(&mac_p->miiaddr) & MII_BUSY)) {
  54. ret = 0;
  55. break;
  56. }
  57. udelay(10);
  58. };
  59. return ret;
  60. }
  61. static int dw_mdio_init(const char *name, struct eth_mac_regs *mac_regs_p)
  62. {
  63. struct mii_dev *bus = mdio_alloc();
  64. if (!bus) {
  65. printf("Failed to allocate MDIO bus\n");
  66. return -ENOMEM;
  67. }
  68. bus->read = dw_mdio_read;
  69. bus->write = dw_mdio_write;
  70. snprintf(bus->name, sizeof(bus->name), name);
  71. bus->priv = (void *)mac_regs_p;
  72. return mdio_register(bus);
  73. }
  74. static void tx_descs_init(struct dw_eth_dev *priv)
  75. {
  76. struct eth_dma_regs *dma_p = priv->dma_regs_p;
  77. struct dmamacdescr *desc_table_p = &priv->tx_mac_descrtable[0];
  78. char *txbuffs = &priv->txbuffs[0];
  79. struct dmamacdescr *desc_p;
  80. u32 idx;
  81. for (idx = 0; idx < CONFIG_TX_DESCR_NUM; idx++) {
  82. desc_p = &desc_table_p[idx];
  83. desc_p->dmamac_addr = &txbuffs[idx * CONFIG_ETH_BUFSIZE];
  84. desc_p->dmamac_next = &desc_table_p[idx + 1];
  85. #if defined(CONFIG_DW_ALTDESCRIPTOR)
  86. desc_p->txrx_status &= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST |
  87. DESC_TXSTS_TXFIRST | DESC_TXSTS_TXCRCDIS | \
  88. DESC_TXSTS_TXCHECKINSCTRL | \
  89. DESC_TXSTS_TXRINGEND | DESC_TXSTS_TXPADDIS);
  90. desc_p->txrx_status |= DESC_TXSTS_TXCHAIN;
  91. desc_p->dmamac_cntl = 0;
  92. desc_p->txrx_status &= ~(DESC_TXSTS_MSK | DESC_TXSTS_OWNBYDMA);
  93. #else
  94. desc_p->dmamac_cntl = DESC_TXCTRL_TXCHAIN;
  95. desc_p->txrx_status = 0;
  96. #endif
  97. }
  98. /* Correcting the last pointer of the chain */
  99. desc_p->dmamac_next = &desc_table_p[0];
  100. /* Flush all Tx buffer descriptors at once */
  101. flush_dcache_range((unsigned int)priv->tx_mac_descrtable,
  102. (unsigned int)priv->tx_mac_descrtable +
  103. sizeof(priv->tx_mac_descrtable));
  104. writel((ulong)&desc_table_p[0], &dma_p->txdesclistaddr);
  105. priv->tx_currdescnum = 0;
  106. }
  107. static void rx_descs_init(struct dw_eth_dev *priv)
  108. {
  109. struct eth_dma_regs *dma_p = priv->dma_regs_p;
  110. struct dmamacdescr *desc_table_p = &priv->rx_mac_descrtable[0];
  111. char *rxbuffs = &priv->rxbuffs[0];
  112. struct dmamacdescr *desc_p;
  113. u32 idx;
  114. /* Before passing buffers to GMAC we need to make sure zeros
  115. * written there right after "priv" structure allocation were
  116. * flushed into RAM.
  117. * Otherwise there's a chance to get some of them flushed in RAM when
  118. * GMAC is already pushing data to RAM via DMA. This way incoming from
  119. * GMAC data will be corrupted. */
  120. flush_dcache_range((unsigned int)rxbuffs, (unsigned int)rxbuffs +
  121. RX_TOTAL_BUFSIZE);
  122. for (idx = 0; idx < CONFIG_RX_DESCR_NUM; idx++) {
  123. desc_p = &desc_table_p[idx];
  124. desc_p->dmamac_addr = &rxbuffs[idx * CONFIG_ETH_BUFSIZE];
  125. desc_p->dmamac_next = &desc_table_p[idx + 1];
  126. desc_p->dmamac_cntl =
  127. (MAC_MAX_FRAME_SZ & DESC_RXCTRL_SIZE1MASK) | \
  128. DESC_RXCTRL_RXCHAIN;
  129. desc_p->txrx_status = DESC_RXSTS_OWNBYDMA;
  130. }
  131. /* Correcting the last pointer of the chain */
  132. desc_p->dmamac_next = &desc_table_p[0];
  133. /* Flush all Rx buffer descriptors at once */
  134. flush_dcache_range((unsigned int)priv->rx_mac_descrtable,
  135. (unsigned int)priv->rx_mac_descrtable +
  136. sizeof(priv->rx_mac_descrtable));
  137. writel((ulong)&desc_table_p[0], &dma_p->rxdesclistaddr);
  138. priv->rx_currdescnum = 0;
  139. }
  140. static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id)
  141. {
  142. struct eth_mac_regs *mac_p = priv->mac_regs_p;
  143. u32 macid_lo, macid_hi;
  144. macid_lo = mac_id[0] + (mac_id[1] << 8) + (mac_id[2] << 16) +
  145. (mac_id[3] << 24);
  146. macid_hi = mac_id[4] + (mac_id[5] << 8);
  147. writel(macid_hi, &mac_p->macaddr0hi);
  148. writel(macid_lo, &mac_p->macaddr0lo);
  149. return 0;
  150. }
  151. static void dw_adjust_link(struct eth_mac_regs *mac_p,
  152. struct phy_device *phydev)
  153. {
  154. u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN;
  155. if (!phydev->link) {
  156. printf("%s: No link.\n", phydev->dev->name);
  157. return;
  158. }
  159. if (phydev->speed != 1000)
  160. conf |= MII_PORTSELECT;
  161. if (phydev->speed == 100)
  162. conf |= FES_100;
  163. if (phydev->duplex)
  164. conf |= FULLDPLXMODE;
  165. writel(conf, &mac_p->conf);
  166. printf("Speed: %d, %s duplex%s\n", phydev->speed,
  167. (phydev->duplex) ? "full" : "half",
  168. (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
  169. }
  170. static void _dw_eth_halt(struct dw_eth_dev *priv)
  171. {
  172. struct eth_mac_regs *mac_p = priv->mac_regs_p;
  173. struct eth_dma_regs *dma_p = priv->dma_regs_p;
  174. writel(readl(&mac_p->conf) & ~(RXENABLE | TXENABLE), &mac_p->conf);
  175. writel(readl(&dma_p->opmode) & ~(RXSTART | TXSTART), &dma_p->opmode);
  176. phy_shutdown(priv->phydev);
  177. }
  178. static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
  179. {
  180. struct eth_mac_regs *mac_p = priv->mac_regs_p;
  181. struct eth_dma_regs *dma_p = priv->dma_regs_p;
  182. unsigned int start;
  183. int ret;
  184. writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
  185. start = get_timer(0);
  186. while (readl(&dma_p->busmode) & DMAMAC_SRST) {
  187. if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT) {
  188. printf("DMA reset timeout\n");
  189. return -ETIMEDOUT;
  190. }
  191. mdelay(100);
  192. };
  193. /*
  194. * Soft reset above clears HW address registers.
  195. * So we have to set it here once again.
  196. */
  197. _dw_write_hwaddr(priv, enetaddr);
  198. rx_descs_init(priv);
  199. tx_descs_init(priv);
  200. writel(FIXEDBURST | PRIORXTX_41 | DMA_PBL, &dma_p->busmode);
  201. #ifndef CONFIG_DW_MAC_FORCE_THRESHOLD_MODE
  202. writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD,
  203. &dma_p->opmode);
  204. #else
  205. writel(readl(&dma_p->opmode) | FLUSHTXFIFO,
  206. &dma_p->opmode);
  207. #endif
  208. writel(readl(&dma_p->opmode) | RXSTART | TXSTART, &dma_p->opmode);
  209. #ifdef CONFIG_DW_AXI_BURST_LEN
  210. writel((CONFIG_DW_AXI_BURST_LEN & 0x1FF >> 1), &dma_p->axibus);
  211. #endif
  212. /* Start up the PHY */
  213. ret = phy_startup(priv->phydev);
  214. if (ret) {
  215. printf("Could not initialize PHY %s\n",
  216. priv->phydev->dev->name);
  217. return ret;
  218. }
  219. dw_adjust_link(mac_p, priv->phydev);
  220. if (!priv->phydev->link)
  221. return -EIO;
  222. writel(readl(&mac_p->conf) | RXENABLE | TXENABLE, &mac_p->conf);
  223. return 0;
  224. }
  225. static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
  226. {
  227. struct eth_dma_regs *dma_p = priv->dma_regs_p;
  228. u32 desc_num = priv->tx_currdescnum;
  229. struct dmamacdescr *desc_p = &priv->tx_mac_descrtable[desc_num];
  230. uint32_t desc_start = (uint32_t)desc_p;
  231. uint32_t desc_end = desc_start +
  232. roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
  233. uint32_t data_start = (uint32_t)desc_p->dmamac_addr;
  234. uint32_t data_end = data_start +
  235. roundup(length, ARCH_DMA_MINALIGN);
  236. /*
  237. * Strictly we only need to invalidate the "txrx_status" field
  238. * for the following check, but on some platforms we cannot
  239. * invalidate only 4 bytes, so we flush the entire descriptor,
  240. * which is 16 bytes in total. This is safe because the
  241. * individual descriptors in the array are each aligned to
  242. * ARCH_DMA_MINALIGN and padded appropriately.
  243. */
  244. invalidate_dcache_range(desc_start, desc_end);
  245. /* Check if the descriptor is owned by CPU */
  246. if (desc_p->txrx_status & DESC_TXSTS_OWNBYDMA) {
  247. printf("CPU not owner of tx frame\n");
  248. return -EPERM;
  249. }
  250. memcpy(desc_p->dmamac_addr, packet, length);
  251. /* Flush data to be sent */
  252. flush_dcache_range(data_start, data_end);
  253. #if defined(CONFIG_DW_ALTDESCRIPTOR)
  254. desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST;
  255. desc_p->dmamac_cntl |= (length << DESC_TXCTRL_SIZE1SHFT) & \
  256. DESC_TXCTRL_SIZE1MASK;
  257. desc_p->txrx_status &= ~(DESC_TXSTS_MSK);
  258. desc_p->txrx_status |= DESC_TXSTS_OWNBYDMA;
  259. #else
  260. desc_p->dmamac_cntl |= ((length << DESC_TXCTRL_SIZE1SHFT) & \
  261. DESC_TXCTRL_SIZE1MASK) | DESC_TXCTRL_TXLAST | \
  262. DESC_TXCTRL_TXFIRST;
  263. desc_p->txrx_status = DESC_TXSTS_OWNBYDMA;
  264. #endif
  265. /* Flush modified buffer descriptor */
  266. flush_dcache_range(desc_start, desc_end);
  267. /* Test the wrap-around condition. */
  268. if (++desc_num >= CONFIG_TX_DESCR_NUM)
  269. desc_num = 0;
  270. priv->tx_currdescnum = desc_num;
  271. /* Start the transmission */
  272. writel(POLL_DATA, &dma_p->txpolldemand);
  273. return 0;
  274. }
  275. static int _dw_eth_recv(struct dw_eth_dev *priv, uchar **packetp)
  276. {
  277. u32 status, desc_num = priv->rx_currdescnum;
  278. struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
  279. int length = -EAGAIN;
  280. uint32_t desc_start = (uint32_t)desc_p;
  281. uint32_t desc_end = desc_start +
  282. roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
  283. uint32_t data_start = (uint32_t)desc_p->dmamac_addr;
  284. uint32_t data_end;
  285. /* Invalidate entire buffer descriptor */
  286. invalidate_dcache_range(desc_start, desc_end);
  287. status = desc_p->txrx_status;
  288. /* Check if the owner is the CPU */
  289. if (!(status & DESC_RXSTS_OWNBYDMA)) {
  290. length = (status & DESC_RXSTS_FRMLENMSK) >> \
  291. DESC_RXSTS_FRMLENSHFT;
  292. /* Invalidate received data */
  293. data_end = data_start + roundup(length, ARCH_DMA_MINALIGN);
  294. invalidate_dcache_range(data_start, data_end);
  295. *packetp = desc_p->dmamac_addr;
  296. }
  297. return length;
  298. }
  299. static int _dw_free_pkt(struct dw_eth_dev *priv)
  300. {
  301. u32 desc_num = priv->rx_currdescnum;
  302. struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
  303. uint32_t desc_start = (uint32_t)desc_p;
  304. uint32_t desc_end = desc_start +
  305. roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
  306. /*
  307. * Make the current descriptor valid again and go to
  308. * the next one
  309. */
  310. desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
  311. /* Flush only status field - others weren't changed */
  312. flush_dcache_range(desc_start, desc_end);
  313. /* Test the wrap-around condition. */
  314. if (++desc_num >= CONFIG_RX_DESCR_NUM)
  315. desc_num = 0;
  316. priv->rx_currdescnum = desc_num;
  317. return 0;
  318. }
  319. static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
  320. {
  321. struct phy_device *phydev;
  322. int mask = 0xffffffff;
  323. #ifdef CONFIG_PHY_ADDR
  324. mask = 1 << CONFIG_PHY_ADDR;
  325. #endif
  326. phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
  327. if (!phydev)
  328. return -ENODEV;
  329. phy_connect_dev(phydev, dev);
  330. phydev->supported &= PHY_GBIT_FEATURES;
  331. phydev->advertising = phydev->supported;
  332. priv->phydev = phydev;
  333. phy_config(phydev);
  334. return 0;
  335. }
  336. #ifndef CONFIG_DM_ETH
  337. static int dw_eth_init(struct eth_device *dev, bd_t *bis)
  338. {
  339. return _dw_eth_init(dev->priv, dev->enetaddr);
  340. }
  341. static int dw_eth_send(struct eth_device *dev, void *packet, int length)
  342. {
  343. return _dw_eth_send(dev->priv, packet, length);
  344. }
  345. static int dw_eth_recv(struct eth_device *dev)
  346. {
  347. uchar *packet;
  348. int length;
  349. length = _dw_eth_recv(dev->priv, &packet);
  350. if (length == -EAGAIN)
  351. return 0;
  352. net_process_received_packet(packet, length);
  353. _dw_free_pkt(dev->priv);
  354. return 0;
  355. }
  356. static void dw_eth_halt(struct eth_device *dev)
  357. {
  358. return _dw_eth_halt(dev->priv);
  359. }
  360. static int dw_write_hwaddr(struct eth_device *dev)
  361. {
  362. return _dw_write_hwaddr(dev->priv, dev->enetaddr);
  363. }
  364. int designware_initialize(ulong base_addr, u32 interface)
  365. {
  366. struct eth_device *dev;
  367. struct dw_eth_dev *priv;
  368. dev = (struct eth_device *) malloc(sizeof(struct eth_device));
  369. if (!dev)
  370. return -ENOMEM;
  371. /*
  372. * Since the priv structure contains the descriptors which need a strict
  373. * buswidth alignment, memalign is used to allocate memory
  374. */
  375. priv = (struct dw_eth_dev *) memalign(ARCH_DMA_MINALIGN,
  376. sizeof(struct dw_eth_dev));
  377. if (!priv) {
  378. free(dev);
  379. return -ENOMEM;
  380. }
  381. memset(dev, 0, sizeof(struct eth_device));
  382. memset(priv, 0, sizeof(struct dw_eth_dev));
  383. sprintf(dev->name, "dwmac.%lx", base_addr);
  384. dev->iobase = (int)base_addr;
  385. dev->priv = priv;
  386. priv->dev = dev;
  387. priv->mac_regs_p = (struct eth_mac_regs *)base_addr;
  388. priv->dma_regs_p = (struct eth_dma_regs *)(base_addr +
  389. DW_DMA_BASE_OFFSET);
  390. dev->init = dw_eth_init;
  391. dev->send = dw_eth_send;
  392. dev->recv = dw_eth_recv;
  393. dev->halt = dw_eth_halt;
  394. dev->write_hwaddr = dw_write_hwaddr;
  395. eth_register(dev);
  396. priv->interface = interface;
  397. dw_mdio_init(dev->name, priv->mac_regs_p);
  398. priv->bus = miiphy_get_dev_by_name(dev->name);
  399. return dw_phy_init(priv, dev);
  400. }
  401. #endif
  402. #ifdef CONFIG_DM_ETH
  403. static int designware_eth_start(struct udevice *dev)
  404. {
  405. struct eth_pdata *pdata = dev_get_platdata(dev);
  406. return _dw_eth_init(dev->priv, pdata->enetaddr);
  407. }
  408. static int designware_eth_send(struct udevice *dev, void *packet, int length)
  409. {
  410. struct dw_eth_dev *priv = dev_get_priv(dev);
  411. return _dw_eth_send(priv, packet, length);
  412. }
  413. static int designware_eth_recv(struct udevice *dev, uchar **packetp)
  414. {
  415. struct dw_eth_dev *priv = dev_get_priv(dev);
  416. return _dw_eth_recv(priv, packetp);
  417. }
  418. static int designware_eth_free_pkt(struct udevice *dev, uchar *packet,
  419. int length)
  420. {
  421. struct dw_eth_dev *priv = dev_get_priv(dev);
  422. return _dw_free_pkt(priv);
  423. }
  424. static void designware_eth_stop(struct udevice *dev)
  425. {
  426. struct dw_eth_dev *priv = dev_get_priv(dev);
  427. return _dw_eth_halt(priv);
  428. }
  429. static int designware_eth_write_hwaddr(struct udevice *dev)
  430. {
  431. struct eth_pdata *pdata = dev_get_platdata(dev);
  432. struct dw_eth_dev *priv = dev_get_priv(dev);
  433. return _dw_write_hwaddr(priv, pdata->enetaddr);
  434. }
  435. static int designware_eth_probe(struct udevice *dev)
  436. {
  437. struct eth_pdata *pdata = dev_get_platdata(dev);
  438. struct dw_eth_dev *priv = dev_get_priv(dev);
  439. int ret;
  440. debug("%s, iobase=%lx, priv=%p\n", __func__, pdata->iobase, priv);
  441. priv->mac_regs_p = (struct eth_mac_regs *)pdata->iobase;
  442. priv->dma_regs_p = (struct eth_dma_regs *)(pdata->iobase +
  443. DW_DMA_BASE_OFFSET);
  444. priv->interface = pdata->phy_interface;
  445. dw_mdio_init(dev->name, priv->mac_regs_p);
  446. priv->bus = miiphy_get_dev_by_name(dev->name);
  447. ret = dw_phy_init(priv, dev);
  448. debug("%s, ret=%d\n", __func__, ret);
  449. return ret;
  450. }
  451. static const struct eth_ops designware_eth_ops = {
  452. .start = designware_eth_start,
  453. .send = designware_eth_send,
  454. .recv = designware_eth_recv,
  455. .free_pkt = designware_eth_free_pkt,
  456. .stop = designware_eth_stop,
  457. .write_hwaddr = designware_eth_write_hwaddr,
  458. };
  459. static int designware_eth_ofdata_to_platdata(struct udevice *dev)
  460. {
  461. struct eth_pdata *pdata = dev_get_platdata(dev);
  462. const char *phy_mode;
  463. pdata->iobase = dev_get_addr(dev);
  464. pdata->phy_interface = -1;
  465. phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL);
  466. if (phy_mode)
  467. pdata->phy_interface = phy_get_interface_by_name(phy_mode);
  468. if (pdata->phy_interface == -1) {
  469. debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
  470. return -EINVAL;
  471. }
  472. return 0;
  473. }
  474. static const struct udevice_id designware_eth_ids[] = {
  475. { .compatible = "allwinner,sun7i-a20-gmac" },
  476. { }
  477. };
  478. U_BOOT_DRIVER(eth_sandbox) = {
  479. .name = "eth_designware",
  480. .id = UCLASS_ETH,
  481. .of_match = designware_eth_ids,
  482. .ofdata_to_platdata = designware_eth_ofdata_to_platdata,
  483. .probe = designware_eth_probe,
  484. .ops = &designware_eth_ops,
  485. .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
  486. .platdata_auto_alloc_size = sizeof(struct eth_pdata),
  487. .flags = DM_FLAG_ALLOC_PRIV_DMA,
  488. };
  489. #endif