Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 |
| 3 | * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | /* |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 9 | * Designware ethernet IP driver for U-Boot |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 14 | #include <errno.h> |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 15 | #include <miiphy.h> |
| 16 | #include <malloc.h> |
Bin Meng | 8b7ee66 | 2015-09-11 03:24:35 -0700 | [diff] [blame^] | 17 | #include <pci.h> |
Stefan Roese | ef76025 | 2012-05-07 12:04:25 +0200 | [diff] [blame] | 18 | #include <linux/compiler.h> |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 19 | #include <linux/err.h> |
| 20 | #include <asm/io.h> |
| 21 | #include "designware.h" |
| 22 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 25 | #if !defined(CONFIG_PHYLIB) |
| 26 | # error "DesignWare Ether MAC requires PHYLIB - missing CONFIG_PHYLIB" |
| 27 | #endif |
| 28 | |
| 29 | static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) |
| 30 | { |
| 31 | struct eth_mac_regs *mac_p = bus->priv; |
| 32 | ulong start; |
| 33 | u16 miiaddr; |
| 34 | int timeout = CONFIG_MDIO_TIMEOUT; |
| 35 | |
| 36 | miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) | |
| 37 | ((reg << MIIREGSHIFT) & MII_REGMSK); |
| 38 | |
| 39 | writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr); |
| 40 | |
| 41 | start = get_timer(0); |
| 42 | while (get_timer(start) < timeout) { |
| 43 | if (!(readl(&mac_p->miiaddr) & MII_BUSY)) |
| 44 | return readl(&mac_p->miidata); |
| 45 | udelay(10); |
| 46 | }; |
| 47 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 48 | return -ETIMEDOUT; |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, |
| 52 | u16 val) |
| 53 | { |
| 54 | struct eth_mac_regs *mac_p = bus->priv; |
| 55 | ulong start; |
| 56 | u16 miiaddr; |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 57 | int ret = -ETIMEDOUT, timeout = CONFIG_MDIO_TIMEOUT; |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 58 | |
| 59 | writel(val, &mac_p->miidata); |
| 60 | miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) | |
| 61 | ((reg << MIIREGSHIFT) & MII_REGMSK) | MII_WRITE; |
| 62 | |
| 63 | writel(miiaddr | MII_CLKRANGE_150_250M | MII_BUSY, &mac_p->miiaddr); |
| 64 | |
| 65 | start = get_timer(0); |
| 66 | while (get_timer(start) < timeout) { |
| 67 | if (!(readl(&mac_p->miiaddr) & MII_BUSY)) { |
| 68 | ret = 0; |
| 69 | break; |
| 70 | } |
| 71 | udelay(10); |
| 72 | }; |
| 73 | |
| 74 | return ret; |
| 75 | } |
| 76 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 77 | static int dw_mdio_init(const char *name, struct eth_mac_regs *mac_regs_p) |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 78 | { |
| 79 | struct mii_dev *bus = mdio_alloc(); |
| 80 | |
| 81 | if (!bus) { |
| 82 | printf("Failed to allocate MDIO bus\n"); |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 83 | return -ENOMEM; |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | bus->read = dw_mdio_read; |
| 87 | bus->write = dw_mdio_write; |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 88 | snprintf(bus->name, sizeof(bus->name), name); |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 89 | |
| 90 | bus->priv = (void *)mac_regs_p; |
| 91 | |
| 92 | return mdio_register(bus); |
| 93 | } |
Vipin Kumar | 13edd17 | 2012-03-26 00:09:56 +0000 | [diff] [blame] | 94 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 95 | static void tx_descs_init(struct dw_eth_dev *priv) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 96 | { |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 97 | struct eth_dma_regs *dma_p = priv->dma_regs_p; |
| 98 | struct dmamacdescr *desc_table_p = &priv->tx_mac_descrtable[0]; |
| 99 | char *txbuffs = &priv->txbuffs[0]; |
| 100 | struct dmamacdescr *desc_p; |
| 101 | u32 idx; |
| 102 | |
| 103 | for (idx = 0; idx < CONFIG_TX_DESCR_NUM; idx++) { |
| 104 | desc_p = &desc_table_p[idx]; |
| 105 | desc_p->dmamac_addr = &txbuffs[idx * CONFIG_ETH_BUFSIZE]; |
| 106 | desc_p->dmamac_next = &desc_table_p[idx + 1]; |
| 107 | |
| 108 | #if defined(CONFIG_DW_ALTDESCRIPTOR) |
| 109 | desc_p->txrx_status &= ~(DESC_TXSTS_TXINT | DESC_TXSTS_TXLAST | |
| 110 | DESC_TXSTS_TXFIRST | DESC_TXSTS_TXCRCDIS | \ |
| 111 | DESC_TXSTS_TXCHECKINSCTRL | \ |
| 112 | DESC_TXSTS_TXRINGEND | DESC_TXSTS_TXPADDIS); |
| 113 | |
| 114 | desc_p->txrx_status |= DESC_TXSTS_TXCHAIN; |
| 115 | desc_p->dmamac_cntl = 0; |
| 116 | desc_p->txrx_status &= ~(DESC_TXSTS_MSK | DESC_TXSTS_OWNBYDMA); |
| 117 | #else |
| 118 | desc_p->dmamac_cntl = DESC_TXCTRL_TXCHAIN; |
| 119 | desc_p->txrx_status = 0; |
| 120 | #endif |
| 121 | } |
| 122 | |
| 123 | /* Correcting the last pointer of the chain */ |
| 124 | desc_p->dmamac_next = &desc_table_p[0]; |
| 125 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 126 | /* Flush all Tx buffer descriptors at once */ |
| 127 | flush_dcache_range((unsigned int)priv->tx_mac_descrtable, |
| 128 | (unsigned int)priv->tx_mac_descrtable + |
| 129 | sizeof(priv->tx_mac_descrtable)); |
| 130 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 131 | writel((ulong)&desc_table_p[0], &dma_p->txdesclistaddr); |
Alexey Brodkin | 74cb708 | 2014-01-13 13:28:38 +0400 | [diff] [blame] | 132 | priv->tx_currdescnum = 0; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 133 | } |
| 134 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 135 | static void rx_descs_init(struct dw_eth_dev *priv) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 136 | { |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 137 | struct eth_dma_regs *dma_p = priv->dma_regs_p; |
| 138 | struct dmamacdescr *desc_table_p = &priv->rx_mac_descrtable[0]; |
| 139 | char *rxbuffs = &priv->rxbuffs[0]; |
| 140 | struct dmamacdescr *desc_p; |
| 141 | u32 idx; |
| 142 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 143 | /* Before passing buffers to GMAC we need to make sure zeros |
| 144 | * written there right after "priv" structure allocation were |
| 145 | * flushed into RAM. |
| 146 | * Otherwise there's a chance to get some of them flushed in RAM when |
| 147 | * GMAC is already pushing data to RAM via DMA. This way incoming from |
| 148 | * GMAC data will be corrupted. */ |
| 149 | flush_dcache_range((unsigned int)rxbuffs, (unsigned int)rxbuffs + |
| 150 | RX_TOTAL_BUFSIZE); |
| 151 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 152 | for (idx = 0; idx < CONFIG_RX_DESCR_NUM; idx++) { |
| 153 | desc_p = &desc_table_p[idx]; |
| 154 | desc_p->dmamac_addr = &rxbuffs[idx * CONFIG_ETH_BUFSIZE]; |
| 155 | desc_p->dmamac_next = &desc_table_p[idx + 1]; |
| 156 | |
| 157 | desc_p->dmamac_cntl = |
| 158 | (MAC_MAX_FRAME_SZ & DESC_RXCTRL_SIZE1MASK) | \ |
| 159 | DESC_RXCTRL_RXCHAIN; |
| 160 | |
| 161 | desc_p->txrx_status = DESC_RXSTS_OWNBYDMA; |
| 162 | } |
| 163 | |
| 164 | /* Correcting the last pointer of the chain */ |
| 165 | desc_p->dmamac_next = &desc_table_p[0]; |
| 166 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 167 | /* Flush all Rx buffer descriptors at once */ |
| 168 | flush_dcache_range((unsigned int)priv->rx_mac_descrtable, |
| 169 | (unsigned int)priv->rx_mac_descrtable + |
| 170 | sizeof(priv->rx_mac_descrtable)); |
| 171 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 172 | writel((ulong)&desc_table_p[0], &dma_p->rxdesclistaddr); |
Alexey Brodkin | 74cb708 | 2014-01-13 13:28:38 +0400 | [diff] [blame] | 173 | priv->rx_currdescnum = 0; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 174 | } |
| 175 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 176 | static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 177 | { |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 178 | struct eth_mac_regs *mac_p = priv->mac_regs_p; |
| 179 | u32 macid_lo, macid_hi; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 180 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 181 | macid_lo = mac_id[0] + (mac_id[1] << 8) + (mac_id[2] << 16) + |
| 182 | (mac_id[3] << 24); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 183 | macid_hi = mac_id[4] + (mac_id[5] << 8); |
| 184 | |
| 185 | writel(macid_hi, &mac_p->macaddr0hi); |
| 186 | writel(macid_lo, &mac_p->macaddr0lo); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 191 | static void dw_adjust_link(struct eth_mac_regs *mac_p, |
| 192 | struct phy_device *phydev) |
| 193 | { |
| 194 | u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN; |
| 195 | |
| 196 | if (!phydev->link) { |
| 197 | printf("%s: No link.\n", phydev->dev->name); |
| 198 | return; |
| 199 | } |
| 200 | |
| 201 | if (phydev->speed != 1000) |
| 202 | conf |= MII_PORTSELECT; |
| 203 | |
| 204 | if (phydev->speed == 100) |
| 205 | conf |= FES_100; |
| 206 | |
| 207 | if (phydev->duplex) |
| 208 | conf |= FULLDPLXMODE; |
| 209 | |
| 210 | writel(conf, &mac_p->conf); |
| 211 | |
| 212 | printf("Speed: %d, %s duplex%s\n", phydev->speed, |
| 213 | (phydev->duplex) ? "full" : "half", |
| 214 | (phydev->port == PORT_FIBRE) ? ", fiber mode" : ""); |
| 215 | } |
| 216 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 217 | static void _dw_eth_halt(struct dw_eth_dev *priv) |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 218 | { |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 219 | struct eth_mac_regs *mac_p = priv->mac_regs_p; |
| 220 | struct eth_dma_regs *dma_p = priv->dma_regs_p; |
| 221 | |
| 222 | writel(readl(&mac_p->conf) & ~(RXENABLE | TXENABLE), &mac_p->conf); |
| 223 | writel(readl(&dma_p->opmode) & ~(RXSTART | TXSTART), &dma_p->opmode); |
| 224 | |
| 225 | phy_shutdown(priv->phydev); |
| 226 | } |
| 227 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 228 | static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 229 | { |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 230 | struct eth_mac_regs *mac_p = priv->mac_regs_p; |
| 231 | struct eth_dma_regs *dma_p = priv->dma_regs_p; |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 232 | unsigned int start; |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 233 | int ret; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 234 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 235 | writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode); |
Vipin Kumar | 13edd17 | 2012-03-26 00:09:56 +0000 | [diff] [blame] | 236 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 237 | start = get_timer(0); |
| 238 | while (readl(&dma_p->busmode) & DMAMAC_SRST) { |
Alexey Brodkin | 875143f | 2015-01-13 17:10:24 +0300 | [diff] [blame] | 239 | if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT) { |
| 240 | printf("DMA reset timeout\n"); |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 241 | return -ETIMEDOUT; |
Alexey Brodkin | 875143f | 2015-01-13 17:10:24 +0300 | [diff] [blame] | 242 | } |
Stefan Roese | ef76025 | 2012-05-07 12:04:25 +0200 | [diff] [blame] | 243 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 244 | mdelay(100); |
| 245 | }; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 246 | |
Bin Meng | f3edfd3 | 2015-06-15 18:40:19 +0800 | [diff] [blame] | 247 | /* |
| 248 | * Soft reset above clears HW address registers. |
| 249 | * So we have to set it here once again. |
| 250 | */ |
| 251 | _dw_write_hwaddr(priv, enetaddr); |
| 252 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 253 | rx_descs_init(priv); |
| 254 | tx_descs_init(priv); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 255 | |
Ian Campbell | 49692c5 | 2014-05-08 22:26:35 +0100 | [diff] [blame] | 256 | writel(FIXEDBURST | PRIORXTX_41 | DMA_PBL, &dma_p->busmode); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 257 | |
Sonic Zhang | d227922 | 2015-01-29 14:38:50 +0800 | [diff] [blame] | 258 | #ifndef CONFIG_DW_MAC_FORCE_THRESHOLD_MODE |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 259 | writel(readl(&dma_p->opmode) | FLUSHTXFIFO | STOREFORWARD, |
| 260 | &dma_p->opmode); |
Sonic Zhang | d227922 | 2015-01-29 14:38:50 +0800 | [diff] [blame] | 261 | #else |
| 262 | writel(readl(&dma_p->opmode) | FLUSHTXFIFO, |
| 263 | &dma_p->opmode); |
| 264 | #endif |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 265 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 266 | writel(readl(&dma_p->opmode) | RXSTART | TXSTART, &dma_p->opmode); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 267 | |
Sonic Zhang | 2ddaf13 | 2015-01-29 13:37:31 +0800 | [diff] [blame] | 268 | #ifdef CONFIG_DW_AXI_BURST_LEN |
| 269 | writel((CONFIG_DW_AXI_BURST_LEN & 0x1FF >> 1), &dma_p->axibus); |
| 270 | #endif |
| 271 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 272 | /* Start up the PHY */ |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 273 | ret = phy_startup(priv->phydev); |
| 274 | if (ret) { |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 275 | printf("Could not initialize PHY %s\n", |
| 276 | priv->phydev->dev->name); |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 277 | return ret; |
Vipin Kumar | 9afc1af | 2012-05-07 13:06:44 +0530 | [diff] [blame] | 278 | } |
| 279 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 280 | dw_adjust_link(mac_p, priv->phydev); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 281 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 282 | if (!priv->phydev->link) |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 283 | return -EIO; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 284 | |
Armando Visconti | aa51005 | 2012-03-26 00:09:55 +0000 | [diff] [blame] | 285 | writel(readl(&mac_p->conf) | RXENABLE | TXENABLE, &mac_p->conf); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 286 | |
| 287 | return 0; |
| 288 | } |
| 289 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 290 | static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 291 | { |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 292 | struct eth_dma_regs *dma_p = priv->dma_regs_p; |
| 293 | u32 desc_num = priv->tx_currdescnum; |
| 294 | struct dmamacdescr *desc_p = &priv->tx_mac_descrtable[desc_num]; |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 295 | uint32_t desc_start = (uint32_t)desc_p; |
| 296 | uint32_t desc_end = desc_start + |
| 297 | roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN); |
| 298 | uint32_t data_start = (uint32_t)desc_p->dmamac_addr; |
| 299 | uint32_t data_end = data_start + |
| 300 | roundup(length, ARCH_DMA_MINALIGN); |
Ian Campbell | 964ea7c | 2014-05-08 22:26:33 +0100 | [diff] [blame] | 301 | /* |
| 302 | * Strictly we only need to invalidate the "txrx_status" field |
| 303 | * for the following check, but on some platforms we cannot |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 304 | * invalidate only 4 bytes, so we flush the entire descriptor, |
| 305 | * which is 16 bytes in total. This is safe because the |
| 306 | * individual descriptors in the array are each aligned to |
| 307 | * ARCH_DMA_MINALIGN and padded appropriately. |
Ian Campbell | 964ea7c | 2014-05-08 22:26:33 +0100 | [diff] [blame] | 308 | */ |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 309 | invalidate_dcache_range(desc_start, desc_end); |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 310 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 311 | /* Check if the descriptor is owned by CPU */ |
| 312 | if (desc_p->txrx_status & DESC_TXSTS_OWNBYDMA) { |
| 313 | printf("CPU not owner of tx frame\n"); |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 314 | return -EPERM; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 315 | } |
| 316 | |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 317 | memcpy(desc_p->dmamac_addr, packet, length); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 318 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 319 | /* Flush data to be sent */ |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 320 | flush_dcache_range(data_start, data_end); |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 321 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 322 | #if defined(CONFIG_DW_ALTDESCRIPTOR) |
| 323 | desc_p->txrx_status |= DESC_TXSTS_TXFIRST | DESC_TXSTS_TXLAST; |
| 324 | desc_p->dmamac_cntl |= (length << DESC_TXCTRL_SIZE1SHFT) & \ |
| 325 | DESC_TXCTRL_SIZE1MASK; |
| 326 | |
| 327 | desc_p->txrx_status &= ~(DESC_TXSTS_MSK); |
| 328 | desc_p->txrx_status |= DESC_TXSTS_OWNBYDMA; |
| 329 | #else |
| 330 | desc_p->dmamac_cntl |= ((length << DESC_TXCTRL_SIZE1SHFT) & \ |
| 331 | DESC_TXCTRL_SIZE1MASK) | DESC_TXCTRL_TXLAST | \ |
| 332 | DESC_TXCTRL_TXFIRST; |
| 333 | |
| 334 | desc_p->txrx_status = DESC_TXSTS_OWNBYDMA; |
| 335 | #endif |
| 336 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 337 | /* Flush modified buffer descriptor */ |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 338 | flush_dcache_range(desc_start, desc_end); |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 339 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 340 | /* Test the wrap-around condition. */ |
| 341 | if (++desc_num >= CONFIG_TX_DESCR_NUM) |
| 342 | desc_num = 0; |
| 343 | |
| 344 | priv->tx_currdescnum = desc_num; |
| 345 | |
| 346 | /* Start the transmission */ |
| 347 | writel(POLL_DATA, &dma_p->txpolldemand); |
| 348 | |
| 349 | return 0; |
| 350 | } |
| 351 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 352 | static int _dw_eth_recv(struct dw_eth_dev *priv, uchar **packetp) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 353 | { |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 354 | u32 status, desc_num = priv->rx_currdescnum; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 355 | struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num]; |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 356 | int length = -EAGAIN; |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 357 | uint32_t desc_start = (uint32_t)desc_p; |
| 358 | uint32_t desc_end = desc_start + |
| 359 | roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN); |
| 360 | uint32_t data_start = (uint32_t)desc_p->dmamac_addr; |
| 361 | uint32_t data_end; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 362 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 363 | /* Invalidate entire buffer descriptor */ |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 364 | invalidate_dcache_range(desc_start, desc_end); |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 365 | |
| 366 | status = desc_p->txrx_status; |
| 367 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 368 | /* Check if the owner is the CPU */ |
| 369 | if (!(status & DESC_RXSTS_OWNBYDMA)) { |
| 370 | |
| 371 | length = (status & DESC_RXSTS_FRMLENMSK) >> \ |
| 372 | DESC_RXSTS_FRMLENSHFT; |
| 373 | |
Alexey Brodkin | 50b0df8 | 2014-01-22 20:49:09 +0400 | [diff] [blame] | 374 | /* Invalidate received data */ |
Marek Vasut | 96cec17 | 2014-09-15 01:05:23 +0200 | [diff] [blame] | 375 | data_end = data_start + roundup(length, ARCH_DMA_MINALIGN); |
| 376 | invalidate_dcache_range(data_start, data_end); |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 377 | *packetp = desc_p->dmamac_addr; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 378 | } |
| 379 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 380 | return length; |
| 381 | } |
| 382 | |
| 383 | static int _dw_free_pkt(struct dw_eth_dev *priv) |
| 384 | { |
| 385 | u32 desc_num = priv->rx_currdescnum; |
| 386 | struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num]; |
| 387 | uint32_t desc_start = (uint32_t)desc_p; |
| 388 | uint32_t desc_end = desc_start + |
| 389 | roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN); |
| 390 | |
| 391 | /* |
| 392 | * Make the current descriptor valid again and go to |
| 393 | * the next one |
| 394 | */ |
| 395 | desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA; |
| 396 | |
| 397 | /* Flush only status field - others weren't changed */ |
| 398 | flush_dcache_range(desc_start, desc_end); |
| 399 | |
| 400 | /* Test the wrap-around condition. */ |
| 401 | if (++desc_num >= CONFIG_RX_DESCR_NUM) |
| 402 | desc_num = 0; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 403 | priv->rx_currdescnum = desc_num; |
| 404 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 405 | return 0; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 406 | } |
| 407 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 408 | static int dw_phy_init(struct dw_eth_dev *priv, void *dev) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 409 | { |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 410 | struct phy_device *phydev; |
| 411 | int mask = 0xffffffff; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 412 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 413 | #ifdef CONFIG_PHY_ADDR |
| 414 | mask = 1 << CONFIG_PHY_ADDR; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 415 | #endif |
| 416 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 417 | phydev = phy_find_by_mask(priv->bus, mask, priv->interface); |
| 418 | if (!phydev) |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 419 | return -ENODEV; |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 420 | |
Ian Campbell | 15e82e5 | 2014-04-28 20:14:05 +0100 | [diff] [blame] | 421 | phy_connect_dev(phydev, dev); |
| 422 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 423 | phydev->supported &= PHY_GBIT_FEATURES; |
| 424 | phydev->advertising = phydev->supported; |
| 425 | |
| 426 | priv->phydev = phydev; |
| 427 | phy_config(phydev); |
| 428 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 429 | return 0; |
| 430 | } |
| 431 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 432 | #ifndef CONFIG_DM_ETH |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 433 | static int dw_eth_init(struct eth_device *dev, bd_t *bis) |
| 434 | { |
| 435 | return _dw_eth_init(dev->priv, dev->enetaddr); |
| 436 | } |
| 437 | |
| 438 | static int dw_eth_send(struct eth_device *dev, void *packet, int length) |
| 439 | { |
| 440 | return _dw_eth_send(dev->priv, packet, length); |
| 441 | } |
| 442 | |
| 443 | static int dw_eth_recv(struct eth_device *dev) |
| 444 | { |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 445 | uchar *packet; |
| 446 | int length; |
| 447 | |
| 448 | length = _dw_eth_recv(dev->priv, &packet); |
| 449 | if (length == -EAGAIN) |
| 450 | return 0; |
| 451 | net_process_received_packet(packet, length); |
| 452 | |
| 453 | _dw_free_pkt(dev->priv); |
| 454 | |
| 455 | return 0; |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static void dw_eth_halt(struct eth_device *dev) |
| 459 | { |
| 460 | return _dw_eth_halt(dev->priv); |
| 461 | } |
| 462 | |
| 463 | static int dw_write_hwaddr(struct eth_device *dev) |
| 464 | { |
| 465 | return _dw_write_hwaddr(dev->priv, dev->enetaddr); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 466 | } |
| 467 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 468 | int designware_initialize(ulong base_addr, u32 interface) |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 469 | { |
| 470 | struct eth_device *dev; |
| 471 | struct dw_eth_dev *priv; |
| 472 | |
| 473 | dev = (struct eth_device *) malloc(sizeof(struct eth_device)); |
| 474 | if (!dev) |
| 475 | return -ENOMEM; |
| 476 | |
| 477 | /* |
| 478 | * Since the priv structure contains the descriptors which need a strict |
| 479 | * buswidth alignment, memalign is used to allocate memory |
| 480 | */ |
Ian Campbell | 1c848a2 | 2014-05-08 22:26:32 +0100 | [diff] [blame] | 481 | priv = (struct dw_eth_dev *) memalign(ARCH_DMA_MINALIGN, |
| 482 | sizeof(struct dw_eth_dev)); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 483 | if (!priv) { |
| 484 | free(dev); |
| 485 | return -ENOMEM; |
| 486 | } |
| 487 | |
| 488 | memset(dev, 0, sizeof(struct eth_device)); |
| 489 | memset(priv, 0, sizeof(struct dw_eth_dev)); |
| 490 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 491 | sprintf(dev->name, "dwmac.%lx", base_addr); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 492 | dev->iobase = (int)base_addr; |
| 493 | dev->priv = priv; |
| 494 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 495 | priv->dev = dev; |
| 496 | priv->mac_regs_p = (struct eth_mac_regs *)base_addr; |
| 497 | priv->dma_regs_p = (struct eth_dma_regs *)(base_addr + |
| 498 | DW_DMA_BASE_OFFSET); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 499 | |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 500 | dev->init = dw_eth_init; |
| 501 | dev->send = dw_eth_send; |
| 502 | dev->recv = dw_eth_recv; |
| 503 | dev->halt = dw_eth_halt; |
| 504 | dev->write_hwaddr = dw_write_hwaddr; |
| 505 | |
| 506 | eth_register(dev); |
| 507 | |
Alexey Brodkin | 92a190a | 2014-01-22 20:54:06 +0400 | [diff] [blame] | 508 | priv->interface = interface; |
| 509 | |
| 510 | dw_mdio_init(dev->name, priv->mac_regs_p); |
| 511 | priv->bus = miiphy_get_dev_by_name(dev->name); |
| 512 | |
Simon Glass | 64dcd25 | 2015-04-05 16:07:40 -0600 | [diff] [blame] | 513 | return dw_phy_init(priv, dev); |
Vipin KUMAR | 5b1b188 | 2010-06-29 10:53:34 +0530 | [diff] [blame] | 514 | } |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 515 | #endif |
| 516 | |
| 517 | #ifdef CONFIG_DM_ETH |
| 518 | static int designware_eth_start(struct udevice *dev) |
| 519 | { |
| 520 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 521 | |
| 522 | return _dw_eth_init(dev->priv, pdata->enetaddr); |
| 523 | } |
| 524 | |
| 525 | static int designware_eth_send(struct udevice *dev, void *packet, int length) |
| 526 | { |
| 527 | struct dw_eth_dev *priv = dev_get_priv(dev); |
| 528 | |
| 529 | return _dw_eth_send(priv, packet, length); |
| 530 | } |
| 531 | |
Simon Glass | a1ca92e | 2015-07-06 16:47:49 -0600 | [diff] [blame] | 532 | static int designware_eth_recv(struct udevice *dev, int flags, uchar **packetp) |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 533 | { |
| 534 | struct dw_eth_dev *priv = dev_get_priv(dev); |
| 535 | |
| 536 | return _dw_eth_recv(priv, packetp); |
| 537 | } |
| 538 | |
| 539 | static int designware_eth_free_pkt(struct udevice *dev, uchar *packet, |
| 540 | int length) |
| 541 | { |
| 542 | struct dw_eth_dev *priv = dev_get_priv(dev); |
| 543 | |
| 544 | return _dw_free_pkt(priv); |
| 545 | } |
| 546 | |
| 547 | static void designware_eth_stop(struct udevice *dev) |
| 548 | { |
| 549 | struct dw_eth_dev *priv = dev_get_priv(dev); |
| 550 | |
| 551 | return _dw_eth_halt(priv); |
| 552 | } |
| 553 | |
| 554 | static int designware_eth_write_hwaddr(struct udevice *dev) |
| 555 | { |
| 556 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 557 | struct dw_eth_dev *priv = dev_get_priv(dev); |
| 558 | |
| 559 | return _dw_write_hwaddr(priv, pdata->enetaddr); |
| 560 | } |
| 561 | |
Bin Meng | 8b7ee66 | 2015-09-11 03:24:35 -0700 | [diff] [blame^] | 562 | static int designware_eth_bind(struct udevice *dev) |
| 563 | { |
| 564 | #ifdef CONFIG_DM_PCI |
| 565 | static int num_cards; |
| 566 | char name[20]; |
| 567 | |
| 568 | /* Create a unique device name for PCI type devices */ |
| 569 | if (device_is_on_pci_bus(dev)) { |
| 570 | sprintf(name, "eth_designware#%u", num_cards++); |
| 571 | device_set_name(dev, name); |
| 572 | } |
| 573 | #endif |
| 574 | |
| 575 | return 0; |
| 576 | } |
| 577 | |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 578 | static int designware_eth_probe(struct udevice *dev) |
| 579 | { |
| 580 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 581 | struct dw_eth_dev *priv = dev_get_priv(dev); |
Bin Meng | f0dc73c | 2015-09-03 05:37:29 -0700 | [diff] [blame] | 582 | u32 iobase = pdata->iobase; |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 583 | int ret; |
| 584 | |
Bin Meng | 8b7ee66 | 2015-09-11 03:24:35 -0700 | [diff] [blame^] | 585 | #ifdef CONFIG_DM_PCI |
| 586 | /* |
| 587 | * If we are on PCI bus, either directly attached to a PCI root port, |
| 588 | * or via a PCI bridge, fill in platdata before we probe the hardware. |
| 589 | */ |
| 590 | if (device_is_on_pci_bus(dev)) { |
| 591 | pci_dev_t bdf = pci_get_bdf(dev); |
| 592 | |
| 593 | dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0, &iobase); |
| 594 | iobase &= PCI_BASE_ADDRESS_MEM_MASK; |
| 595 | iobase = pci_mem_to_phys(bdf, iobase); |
| 596 | |
| 597 | pdata->iobase = iobase; |
| 598 | pdata->phy_interface = PHY_INTERFACE_MODE_RMII; |
| 599 | } |
| 600 | #endif |
| 601 | |
Bin Meng | f0dc73c | 2015-09-03 05:37:29 -0700 | [diff] [blame] | 602 | debug("%s, iobase=%x, priv=%p\n", __func__, iobase, priv); |
| 603 | priv->mac_regs_p = (struct eth_mac_regs *)iobase; |
| 604 | priv->dma_regs_p = (struct eth_dma_regs *)(iobase + DW_DMA_BASE_OFFSET); |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 605 | priv->interface = pdata->phy_interface; |
| 606 | |
| 607 | dw_mdio_init(dev->name, priv->mac_regs_p); |
| 608 | priv->bus = miiphy_get_dev_by_name(dev->name); |
| 609 | |
| 610 | ret = dw_phy_init(priv, dev); |
| 611 | debug("%s, ret=%d\n", __func__, ret); |
| 612 | |
| 613 | return ret; |
| 614 | } |
| 615 | |
| 616 | static const struct eth_ops designware_eth_ops = { |
| 617 | .start = designware_eth_start, |
| 618 | .send = designware_eth_send, |
| 619 | .recv = designware_eth_recv, |
| 620 | .free_pkt = designware_eth_free_pkt, |
| 621 | .stop = designware_eth_stop, |
| 622 | .write_hwaddr = designware_eth_write_hwaddr, |
| 623 | }; |
| 624 | |
| 625 | static int designware_eth_ofdata_to_platdata(struct udevice *dev) |
| 626 | { |
| 627 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 628 | const char *phy_mode; |
| 629 | |
| 630 | pdata->iobase = dev_get_addr(dev); |
| 631 | pdata->phy_interface = -1; |
| 632 | phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); |
| 633 | if (phy_mode) |
| 634 | pdata->phy_interface = phy_get_interface_by_name(phy_mode); |
| 635 | if (pdata->phy_interface == -1) { |
| 636 | debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode); |
| 637 | return -EINVAL; |
| 638 | } |
| 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
| 643 | static const struct udevice_id designware_eth_ids[] = { |
| 644 | { .compatible = "allwinner,sun7i-a20-gmac" }, |
Marek Vasut | b962859 | 2015-07-25 18:38:44 +0200 | [diff] [blame] | 645 | { .compatible = "altr,socfpga-stmmac" }, |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 646 | { } |
| 647 | }; |
| 648 | |
Marek Vasut | 9f76f10 | 2015-07-25 18:42:34 +0200 | [diff] [blame] | 649 | U_BOOT_DRIVER(eth_designware) = { |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 650 | .name = "eth_designware", |
| 651 | .id = UCLASS_ETH, |
| 652 | .of_match = designware_eth_ids, |
| 653 | .ofdata_to_platdata = designware_eth_ofdata_to_platdata, |
Bin Meng | 8b7ee66 | 2015-09-11 03:24:35 -0700 | [diff] [blame^] | 654 | .bind = designware_eth_bind, |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 655 | .probe = designware_eth_probe, |
| 656 | .ops = &designware_eth_ops, |
| 657 | .priv_auto_alloc_size = sizeof(struct dw_eth_dev), |
| 658 | .platdata_auto_alloc_size = sizeof(struct eth_pdata), |
| 659 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 660 | }; |
Bin Meng | 8b7ee66 | 2015-09-11 03:24:35 -0700 | [diff] [blame^] | 661 | |
| 662 | static struct pci_device_id supported[] = { |
| 663 | { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_EMAC) }, |
| 664 | { } |
| 665 | }; |
| 666 | |
| 667 | U_BOOT_PCI_DEVICE(eth_designware, supported); |
Simon Glass | 75577ba | 2015-04-05 16:07:41 -0600 | [diff] [blame] | 668 | #endif |