Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Faraday FTGMAC100 Ethernet |
| 4 | * |
| 5 | * (C) Copyright 2009 Faraday Technology |
| 6 | * Po-Yu Chuang <ratbert@faraday-tech.com> |
| 7 | * |
| 8 | * (C) Copyright 2010 Andes Technology |
| 9 | * Macpaul Lin <macpaul@andestech.com> |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 10 | * |
| 11 | * Copyright (C) 2018, IBM Corporation. |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 12 | */ |
| 13 | |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 14 | #include <clk.h> |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 15 | #include <dm.h> |
| 16 | #include <miiphy.h> |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 17 | #include <net.h> |
Cédric Le Goater | d0e0b84 | 2018-10-29 07:06:35 +0100 | [diff] [blame] | 18 | #include <wait_bit.h> |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 19 | #include <linux/io.h> |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 20 | #include <linux/iopoll.h> |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 21 | |
| 22 | #include "ftgmac100.h" |
| 23 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 24 | /* Min frame ethernet frame size without FCS */ |
| 25 | #define ETH_ZLEN 60 |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 26 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 27 | /* Receive Buffer Size Register - HW default is 0x640 */ |
| 28 | #define FTGMAC100_RBSR_DEFAULT 0x640 |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 29 | |
| 30 | /* PKTBUFSTX/PKTBUFSRX must both be power of 2 */ |
| 31 | #define PKTBUFSTX 4 /* must be power of 2 */ |
| 32 | |
Cédric Le Goater | d0e0b84 | 2018-10-29 07:06:35 +0100 | [diff] [blame] | 33 | /* Timeout for transmit */ |
| 34 | #define FTGMAC100_TX_TIMEOUT_MS 1000 |
| 35 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 36 | /* Timeout for a mdio read/write operation */ |
| 37 | #define FTGMAC100_MDIO_TIMEOUT_USEC 10000 |
| 38 | |
| 39 | /* |
| 40 | * MDC clock cycle threshold |
| 41 | * |
| 42 | * 20us * 100 = 2ms > (1 / 2.5Mhz) * 0x34 |
| 43 | */ |
| 44 | #define MDC_CYCTHR 0x34 |
| 45 | |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 46 | /* |
| 47 | * ftgmac100 model variants |
| 48 | */ |
| 49 | enum ftgmac100_model { |
| 50 | FTGMAC100_MODEL_FARADAY, |
| 51 | FTGMAC100_MODEL_ASPEED, |
| 52 | }; |
| 53 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 54 | /** |
| 55 | * struct ftgmac100_data - private data for the FTGMAC100 driver |
| 56 | * |
| 57 | * @iobase: The base address of the hardware registers |
| 58 | * @txdes: The array of transmit descriptors |
| 59 | * @rxdes: The array of receive descriptors |
| 60 | * @tx_index: Transmit descriptor index in @txdes |
| 61 | * @rx_index: Receive descriptor index in @rxdes |
| 62 | * @phy_addr: The PHY interface address to use |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 63 | * @phydev: The PHY device backing the MAC |
| 64 | * @bus: The mdio bus |
| 65 | * @phy_mode: The mode of the PHY interface (rgmii, rmii, ...) |
| 66 | * @max_speed: Maximum speed of Ethernet connection supported by MAC |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 67 | * @clks: The bulk of clocks assigned to the device in the DT |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 68 | * @rxdes0_edorr_mask: The bit number identifying the end of the RX ring buffer |
| 69 | * @txdes0_edotr_mask: The bit number identifying the end of the TX ring buffer |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 70 | */ |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 71 | struct ftgmac100_data { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 72 | struct ftgmac100 *iobase; |
| 73 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 74 | struct ftgmac100_txdes txdes[PKTBUFSTX]; |
| 75 | struct ftgmac100_rxdes rxdes[PKTBUFSRX]; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 76 | int tx_index; |
| 77 | int rx_index; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 78 | |
| 79 | u32 phy_addr; |
| 80 | struct phy_device *phydev; |
| 81 | struct mii_dev *bus; |
| 82 | u32 phy_mode; |
| 83 | u32 max_speed; |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 84 | |
| 85 | struct clk_bulk clks; |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 86 | |
| 87 | /* End of RX/TX ring buffer bits. Depend on model */ |
| 88 | u32 rxdes0_edorr_mask; |
| 89 | u32 txdes0_edotr_mask; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | /* |
| 93 | * struct mii_bus functions |
| 94 | */ |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 95 | static int ftgmac100_mdio_read(struct mii_dev *bus, int phy_addr, int dev_addr, |
| 96 | int reg_addr) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 97 | { |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 98 | struct ftgmac100_data *priv = bus->priv; |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 99 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 100 | int phycr; |
| 101 | int data; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 102 | int ret; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 103 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 104 | phycr = FTGMAC100_PHYCR_MDC_CYCTHR(MDC_CYCTHR) | |
| 105 | FTGMAC100_PHYCR_PHYAD(phy_addr) | |
| 106 | FTGMAC100_PHYCR_REGAD(reg_addr) | |
| 107 | FTGMAC100_PHYCR_MIIRD; |
| 108 | writel(phycr, &ftgmac100->phycr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 109 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 110 | ret = readl_poll_timeout(&ftgmac100->phycr, phycr, |
| 111 | !(phycr & FTGMAC100_PHYCR_MIIRD), |
| 112 | FTGMAC100_MDIO_TIMEOUT_USEC); |
| 113 | if (ret) { |
| 114 | pr_err("%s: mdio read failed (phy:%d reg:%x)\n", |
| 115 | priv->phydev->dev->name, phy_addr, reg_addr); |
| 116 | return ret; |
| 117 | } |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 118 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 119 | data = readl(&ftgmac100->phydata); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 120 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 121 | return FTGMAC100_PHYDATA_MIIRDATA(data); |
| 122 | } |
| 123 | |
| 124 | static int ftgmac100_mdio_write(struct mii_dev *bus, int phy_addr, int dev_addr, |
| 125 | int reg_addr, u16 value) |
| 126 | { |
| 127 | struct ftgmac100_data *priv = bus->priv; |
| 128 | struct ftgmac100 *ftgmac100 = priv->iobase; |
| 129 | int phycr; |
| 130 | int data; |
| 131 | int ret; |
| 132 | |
| 133 | phycr = FTGMAC100_PHYCR_MDC_CYCTHR(MDC_CYCTHR) | |
| 134 | FTGMAC100_PHYCR_PHYAD(phy_addr) | |
| 135 | FTGMAC100_PHYCR_REGAD(reg_addr) | |
| 136 | FTGMAC100_PHYCR_MIIWR; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 137 | data = FTGMAC100_PHYDATA_MIIWDATA(value); |
| 138 | |
| 139 | writel(data, &ftgmac100->phydata); |
| 140 | writel(phycr, &ftgmac100->phycr); |
| 141 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 142 | ret = readl_poll_timeout(&ftgmac100->phycr, phycr, |
| 143 | !(phycr & FTGMAC100_PHYCR_MIIWR), |
| 144 | FTGMAC100_MDIO_TIMEOUT_USEC); |
| 145 | if (ret) { |
| 146 | pr_err("%s: mdio write failed (phy:%d reg:%x)\n", |
| 147 | priv->phydev->dev->name, phy_addr, reg_addr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 148 | } |
| 149 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 150 | return ret; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 151 | } |
| 152 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 153 | static int ftgmac100_mdio_init(struct udevice *dev) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 154 | { |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 155 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 156 | struct mii_dev *bus; |
| 157 | int ret; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 158 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 159 | bus = mdio_alloc(); |
| 160 | if (!bus) |
| 161 | return -ENOMEM; |
| 162 | |
| 163 | bus->read = ftgmac100_mdio_read; |
| 164 | bus->write = ftgmac100_mdio_write; |
| 165 | bus->priv = priv; |
| 166 | |
| 167 | ret = mdio_register_seq(bus, dev->seq); |
| 168 | if (ret) { |
| 169 | free(bus); |
| 170 | return ret; |
| 171 | } |
| 172 | |
| 173 | priv->bus = bus; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 174 | |
| 175 | return 0; |
| 176 | } |
| 177 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 178 | static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 179 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 180 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 181 | struct phy_device *phydev = priv->phydev; |
| 182 | u32 maccr; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 183 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 184 | if (!phydev->link) { |
| 185 | dev_err(phydev->dev, "No link\n"); |
| 186 | return -EREMOTEIO; |
| 187 | } |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 188 | |
| 189 | /* read MAC control register and clear related bits */ |
| 190 | maccr = readl(&ftgmac100->maccr) & |
| 191 | ~(FTGMAC100_MACCR_GIGA_MODE | |
| 192 | FTGMAC100_MACCR_FAST_MODE | |
| 193 | FTGMAC100_MACCR_FULLDUP); |
| 194 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 195 | if (phy_interface_is_rgmii(phydev) && phydev->speed == 1000) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 196 | maccr |= FTGMAC100_MACCR_GIGA_MODE; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 197 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 198 | if (phydev->speed == 100) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 199 | maccr |= FTGMAC100_MACCR_FAST_MODE; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 200 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 201 | if (phydev->duplex) |
| 202 | maccr |= FTGMAC100_MACCR_FULLDUP; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 203 | |
| 204 | /* update MII config into maccr */ |
| 205 | writel(maccr, &ftgmac100->maccr); |
| 206 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 207 | return 0; |
| 208 | } |
| 209 | |
| 210 | static int ftgmac100_phy_init(struct udevice *dev) |
| 211 | { |
| 212 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 213 | struct phy_device *phydev; |
| 214 | int ret; |
| 215 | |
| 216 | phydev = phy_connect(priv->bus, priv->phy_addr, dev, priv->phy_mode); |
| 217 | if (!phydev) |
| 218 | return -ENODEV; |
| 219 | |
| 220 | phydev->supported &= PHY_GBIT_FEATURES; |
| 221 | if (priv->max_speed) { |
| 222 | ret = phy_set_supported(phydev, priv->max_speed); |
| 223 | if (ret) |
| 224 | return ret; |
| 225 | } |
| 226 | phydev->advertising = phydev->supported; |
| 227 | priv->phydev = phydev; |
| 228 | phy_config(phydev); |
| 229 | |
| 230 | return 0; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | /* |
| 234 | * Reset MAC |
| 235 | */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 236 | static void ftgmac100_reset(struct ftgmac100_data *priv) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 237 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 238 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 239 | |
| 240 | debug("%s()\n", __func__); |
| 241 | |
Cédric Le Goater | 591ffd9 | 2018-10-29 07:06:32 +0100 | [diff] [blame] | 242 | setbits_le32(&ftgmac100->maccr, FTGMAC100_MACCR_SW_RST); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 243 | |
| 244 | while (readl(&ftgmac100->maccr) & FTGMAC100_MACCR_SW_RST) |
| 245 | ; |
| 246 | } |
| 247 | |
| 248 | /* |
| 249 | * Set MAC address |
| 250 | */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 251 | static int ftgmac100_set_mac(struct ftgmac100_data *priv, |
| 252 | const unsigned char *mac) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 253 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 254 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 255 | unsigned int maddr = mac[0] << 8 | mac[1]; |
| 256 | unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5]; |
| 257 | |
| 258 | debug("%s(%x %x)\n", __func__, maddr, laddr); |
| 259 | |
| 260 | writel(maddr, &ftgmac100->mac_madr); |
| 261 | writel(laddr, &ftgmac100->mac_ladr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 262 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 263 | return 0; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /* |
| 267 | * disable transmitter, receiver |
| 268 | */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 269 | static void ftgmac100_stop(struct udevice *dev) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 270 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 271 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 272 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 273 | |
| 274 | debug("%s()\n", __func__); |
| 275 | |
| 276 | writel(0, &ftgmac100->maccr); |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 277 | |
| 278 | phy_shutdown(priv->phydev); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 279 | } |
| 280 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 281 | static int ftgmac100_start(struct udevice *dev) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 282 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 283 | struct eth_pdata *plat = dev_get_platdata(dev); |
| 284 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 285 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 286 | struct phy_device *phydev = priv->phydev; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 287 | unsigned int maccr; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 288 | ulong start, end; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 289 | int ret; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 290 | int i; |
| 291 | |
| 292 | debug("%s()\n", __func__); |
| 293 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 294 | ftgmac100_reset(priv); |
| 295 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 296 | /* set the ethernet address */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 297 | ftgmac100_set_mac(priv, plat->enetaddr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 298 | |
| 299 | /* disable all interrupts */ |
| 300 | writel(0, &ftgmac100->ier); |
| 301 | |
| 302 | /* initialize descriptors */ |
| 303 | priv->tx_index = 0; |
| 304 | priv->rx_index = 0; |
| 305 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 306 | for (i = 0; i < PKTBUFSTX; i++) { |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 307 | priv->txdes[i].txdes3 = 0; |
| 308 | priv->txdes[i].txdes0 = 0; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 309 | } |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 310 | priv->txdes[PKTBUFSTX - 1].txdes0 = priv->txdes0_edotr_mask; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 311 | |
| 312 | start = (ulong)&priv->txdes[0]; |
| 313 | end = start + roundup(sizeof(priv->txdes), ARCH_DMA_MINALIGN); |
| 314 | flush_dcache_range(start, end); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 315 | |
| 316 | for (i = 0; i < PKTBUFSRX; i++) { |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 317 | priv->rxdes[i].rxdes3 = (unsigned int)net_rx_packets[i]; |
| 318 | priv->rxdes[i].rxdes0 = 0; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 319 | } |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 320 | priv->rxdes[PKTBUFSRX - 1].rxdes0 = priv->rxdes0_edorr_mask; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 321 | |
| 322 | start = (ulong)&priv->rxdes[0]; |
| 323 | end = start + roundup(sizeof(priv->rxdes), ARCH_DMA_MINALIGN); |
| 324 | flush_dcache_range(start, end); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 325 | |
| 326 | /* transmit ring */ |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 327 | writel((u32)priv->txdes, &ftgmac100->txr_badr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 328 | |
| 329 | /* receive ring */ |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 330 | writel((u32)priv->rxdes, &ftgmac100->rxr_badr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 331 | |
| 332 | /* poll receive descriptor automatically */ |
| 333 | writel(FTGMAC100_APTC_RXPOLL_CNT(1), &ftgmac100->aptc); |
| 334 | |
| 335 | /* config receive buffer size register */ |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 336 | writel(FTGMAC100_RBSR_SIZE(FTGMAC100_RBSR_DEFAULT), &ftgmac100->rbsr); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 337 | |
| 338 | /* enable transmitter, receiver */ |
| 339 | maccr = FTGMAC100_MACCR_TXMAC_EN | |
| 340 | FTGMAC100_MACCR_RXMAC_EN | |
| 341 | FTGMAC100_MACCR_TXDMA_EN | |
| 342 | FTGMAC100_MACCR_RXDMA_EN | |
| 343 | FTGMAC100_MACCR_CRC_APD | |
| 344 | FTGMAC100_MACCR_FULLDUP | |
| 345 | FTGMAC100_MACCR_RX_RUNT | |
| 346 | FTGMAC100_MACCR_RX_BROADPKT; |
| 347 | |
| 348 | writel(maccr, &ftgmac100->maccr); |
| 349 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 350 | ret = phy_startup(phydev); |
| 351 | if (ret) { |
| 352 | dev_err(phydev->dev, "Could not start PHY\n"); |
| 353 | return ret; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 354 | } |
| 355 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 356 | ret = ftgmac100_phy_adjust_link(priv); |
| 357 | if (ret) { |
| 358 | dev_err(phydev->dev, "Could not adjust link\n"); |
| 359 | return ret; |
| 360 | } |
| 361 | |
| 362 | printf("%s: link up, %d Mbps %s-duplex mac:%pM\n", phydev->dev->name, |
| 363 | phydev->speed, phydev->duplex ? "full" : "half", plat->enetaddr); |
| 364 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 365 | return 0; |
| 366 | } |
| 367 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 368 | static int ftgmac100_free_pkt(struct udevice *dev, uchar *packet, int length) |
| 369 | { |
| 370 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 371 | struct ftgmac100_rxdes *curr_des = &priv->rxdes[priv->rx_index]; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 372 | ulong des_start = (ulong)curr_des; |
| 373 | ulong des_end = des_start + |
| 374 | roundup(sizeof(*curr_des), ARCH_DMA_MINALIGN); |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 375 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 376 | /* Release buffer to DMA and flush descriptor */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 377 | curr_des->rxdes0 &= ~FTGMAC100_RXDES0_RXPKT_RDY; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 378 | flush_dcache_range(des_start, des_end); |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 379 | |
| 380 | /* Move to next descriptor */ |
| 381 | priv->rx_index = (priv->rx_index + 1) % PKTBUFSRX; |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 386 | /* |
| 387 | * Get a data block via Ethernet |
| 388 | */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 389 | static int ftgmac100_recv(struct udevice *dev, int flags, uchar **packetp) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 390 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 391 | struct ftgmac100_data *priv = dev_get_priv(dev); |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 392 | struct ftgmac100_rxdes *curr_des = &priv->rxdes[priv->rx_index]; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 393 | unsigned short rxlen; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 394 | ulong des_start = (ulong)curr_des; |
| 395 | ulong des_end = des_start + |
| 396 | roundup(sizeof(*curr_des), ARCH_DMA_MINALIGN); |
| 397 | ulong data_start = curr_des->rxdes3; |
| 398 | ulong data_end; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 399 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 400 | invalidate_dcache_range(des_start, des_end); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 401 | |
| 402 | if (!(curr_des->rxdes0 & FTGMAC100_RXDES0_RXPKT_RDY)) |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 403 | return -EAGAIN; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 404 | |
| 405 | if (curr_des->rxdes0 & (FTGMAC100_RXDES0_RX_ERR | |
| 406 | FTGMAC100_RXDES0_CRC_ERR | |
| 407 | FTGMAC100_RXDES0_FTL | |
| 408 | FTGMAC100_RXDES0_RUNT | |
| 409 | FTGMAC100_RXDES0_RX_ODD_NB)) { |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 410 | return -EAGAIN; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | rxlen = FTGMAC100_RXDES0_VDBC(curr_des->rxdes0); |
| 414 | |
| 415 | debug("%s(): RX buffer %d, %x received\n", |
| 416 | __func__, priv->rx_index, rxlen); |
| 417 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 418 | /* Invalidate received data */ |
| 419 | data_end = data_start + roundup(rxlen, ARCH_DMA_MINALIGN); |
| 420 | invalidate_dcache_range(data_start, data_end); |
| 421 | *packetp = (uchar *)data_start; |
Kuo-Jung Su | a8f9cd1 | 2013-05-07 14:33:51 +0800 | [diff] [blame] | 422 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 423 | return rxlen; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 424 | } |
| 425 | |
Cédric Le Goater | d0e0b84 | 2018-10-29 07:06:35 +0100 | [diff] [blame] | 426 | static u32 ftgmac100_read_txdesc(const void *desc) |
| 427 | { |
| 428 | const struct ftgmac100_txdes *txdes = desc; |
| 429 | ulong des_start = (ulong)txdes; |
| 430 | ulong des_end = des_start + roundup(sizeof(*txdes), ARCH_DMA_MINALIGN); |
| 431 | |
| 432 | invalidate_dcache_range(des_start, des_end); |
| 433 | |
| 434 | return txdes->txdes0; |
| 435 | } |
| 436 | |
| 437 | BUILD_WAIT_FOR_BIT(ftgmac100_txdone, u32, ftgmac100_read_txdesc) |
| 438 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 439 | /* |
| 440 | * Send a data block via Ethernet |
| 441 | */ |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 442 | static int ftgmac100_send(struct udevice *dev, void *packet, int length) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 443 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 444 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 445 | struct ftgmac100 *ftgmac100 = priv->iobase; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 446 | struct ftgmac100_txdes *curr_des = &priv->txdes[priv->tx_index]; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 447 | ulong des_start = (ulong)curr_des; |
| 448 | ulong des_end = des_start + |
| 449 | roundup(sizeof(*curr_des), ARCH_DMA_MINALIGN); |
| 450 | ulong data_start; |
| 451 | ulong data_end; |
Cédric Le Goater | d0e0b84 | 2018-10-29 07:06:35 +0100 | [diff] [blame] | 452 | int rc; |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 453 | |
| 454 | invalidate_dcache_range(des_start, des_end); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 455 | |
| 456 | if (curr_des->txdes0 & FTGMAC100_TXDES0_TXDMA_OWN) { |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 457 | dev_err(dev, "no TX descriptor available\n"); |
| 458 | return -EPERM; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | debug("%s(%x, %x)\n", __func__, (int)packet, length); |
| 462 | |
| 463 | length = (length < ETH_ZLEN) ? ETH_ZLEN : length; |
| 464 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 465 | curr_des->txdes3 = (unsigned int)packet; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 466 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 467 | /* Flush data to be sent */ |
| 468 | data_start = curr_des->txdes3; |
| 469 | data_end = data_start + roundup(length, ARCH_DMA_MINALIGN); |
| 470 | flush_dcache_range(data_start, data_end); |
| 471 | |
| 472 | /* Only one segment on TXBUF */ |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 473 | curr_des->txdes0 &= priv->txdes0_edotr_mask; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 474 | curr_des->txdes0 |= FTGMAC100_TXDES0_FTS | |
| 475 | FTGMAC100_TXDES0_LTS | |
| 476 | FTGMAC100_TXDES0_TXBUF_SIZE(length) | |
| 477 | FTGMAC100_TXDES0_TXDMA_OWN ; |
| 478 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 479 | /* Flush modified buffer descriptor */ |
| 480 | flush_dcache_range(des_start, des_end); |
| 481 | |
| 482 | /* Start transmit */ |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 483 | writel(1, &ftgmac100->txpd); |
| 484 | |
Cédric Le Goater | d0e0b84 | 2018-10-29 07:06:35 +0100 | [diff] [blame] | 485 | rc = wait_for_bit_ftgmac100_txdone(curr_des, |
| 486 | FTGMAC100_TXDES0_TXDMA_OWN, false, |
| 487 | FTGMAC100_TX_TIMEOUT_MS, true); |
| 488 | if (rc) |
| 489 | return rc; |
| 490 | |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 491 | debug("%s(): packet sent\n", __func__); |
| 492 | |
Cédric Le Goater | e766849 | 2018-10-29 07:06:34 +0100 | [diff] [blame] | 493 | /* Move to next descriptor */ |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 494 | priv->tx_index = (priv->tx_index + 1) % PKTBUFSTX; |
| 495 | |
| 496 | return 0; |
| 497 | } |
| 498 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 499 | static int ftgmac100_write_hwaddr(struct udevice *dev) |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 500 | { |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 501 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 502 | struct ftgmac100_data *priv = dev_get_priv(dev); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 503 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 504 | return ftgmac100_set_mac(priv, pdata->enetaddr); |
| 505 | } |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 506 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 507 | static int ftgmac100_ofdata_to_platdata(struct udevice *dev) |
| 508 | { |
| 509 | struct eth_pdata *pdata = dev_get_platdata(dev); |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 510 | struct ftgmac100_data *priv = dev_get_priv(dev); |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 511 | const char *phy_mode; |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 512 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 513 | pdata->iobase = devfdt_get_addr(dev); |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 514 | pdata->phy_interface = -1; |
| 515 | phy_mode = dev_read_string(dev, "phy-mode"); |
| 516 | if (phy_mode) |
| 517 | pdata->phy_interface = phy_get_interface_by_name(phy_mode); |
| 518 | if (pdata->phy_interface == -1) { |
| 519 | dev_err(dev, "Invalid PHY interface '%s'\n", phy_mode); |
| 520 | return -EINVAL; |
| 521 | } |
| 522 | |
| 523 | pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0); |
| 524 | |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 525 | if (dev_get_driver_data(dev) == FTGMAC100_MODEL_ASPEED) { |
| 526 | priv->rxdes0_edorr_mask = BIT(30); |
| 527 | priv->txdes0_edotr_mask = BIT(30); |
| 528 | } else { |
| 529 | priv->rxdes0_edorr_mask = BIT(15); |
| 530 | priv->txdes0_edotr_mask = BIT(15); |
| 531 | } |
| 532 | |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 533 | return clk_get_bulk(dev, &priv->clks); |
Macpaul Lin | b3dbf4a5 | 2010-12-21 16:59:46 +0800 | [diff] [blame] | 534 | } |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 535 | |
| 536 | static int ftgmac100_probe(struct udevice *dev) |
| 537 | { |
| 538 | struct eth_pdata *pdata = dev_get_platdata(dev); |
| 539 | struct ftgmac100_data *priv = dev_get_priv(dev); |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 540 | int ret; |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 541 | |
| 542 | priv->iobase = (struct ftgmac100 *)pdata->iobase; |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 543 | priv->phy_mode = pdata->phy_interface; |
| 544 | priv->max_speed = pdata->max_speed; |
| 545 | priv->phy_addr = 0; |
| 546 | |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 547 | ret = clk_enable_bulk(&priv->clks); |
| 548 | if (ret) |
| 549 | goto out; |
| 550 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 551 | ret = ftgmac100_mdio_init(dev); |
| 552 | if (ret) { |
| 553 | dev_err(dev, "Failed to initialize mdiobus: %d\n", ret); |
| 554 | goto out; |
| 555 | } |
| 556 | |
| 557 | ret = ftgmac100_phy_init(dev); |
| 558 | if (ret) { |
| 559 | dev_err(dev, "Failed to initialize PHY: %d\n", ret); |
| 560 | goto out; |
| 561 | } |
| 562 | |
| 563 | out: |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 564 | if (ret) |
| 565 | clk_release_bulk(&priv->clks); |
| 566 | |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 567 | return ret; |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | static int ftgmac100_remove(struct udevice *dev) |
| 571 | { |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 572 | struct ftgmac100_data *priv = dev_get_priv(dev); |
| 573 | |
| 574 | free(priv->phydev); |
| 575 | mdio_unregister(priv->bus); |
| 576 | mdio_free(priv->bus); |
Cédric Le Goater | 1c0c61e | 2018-10-29 07:06:36 +0100 | [diff] [blame] | 577 | clk_release_bulk(&priv->clks); |
Cédric Le Goater | 538e75d | 2018-10-29 07:06:33 +0100 | [diff] [blame] | 578 | |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | static const struct eth_ops ftgmac100_ops = { |
| 583 | .start = ftgmac100_start, |
| 584 | .send = ftgmac100_send, |
| 585 | .recv = ftgmac100_recv, |
| 586 | .stop = ftgmac100_stop, |
| 587 | .free_pkt = ftgmac100_free_pkt, |
| 588 | .write_hwaddr = ftgmac100_write_hwaddr, |
| 589 | }; |
| 590 | |
| 591 | static const struct udevice_id ftgmac100_ids[] = { |
Cédric Le Goater | e6ddacc | 2018-10-29 07:06:38 +0100 | [diff] [blame] | 592 | { .compatible = "faraday,ftgmac100", .data = FTGMAC100_MODEL_FARADAY }, |
| 593 | { .compatible = "aspeed,ast2500-mac", .data = FTGMAC100_MODEL_ASPEED }, |
Cédric Le Goater | f95de0b | 2018-10-29 07:06:31 +0100 | [diff] [blame] | 594 | { } |
| 595 | }; |
| 596 | |
| 597 | U_BOOT_DRIVER(ftgmac100) = { |
| 598 | .name = "ftgmac100", |
| 599 | .id = UCLASS_ETH, |
| 600 | .of_match = ftgmac100_ids, |
| 601 | .ofdata_to_platdata = ftgmac100_ofdata_to_platdata, |
| 602 | .probe = ftgmac100_probe, |
| 603 | .remove = ftgmac100_remove, |
| 604 | .ops = &ftgmac100_ops, |
| 605 | .priv_auto_alloc_size = sizeof(struct ftgmac100_data), |
| 606 | .platdata_auto_alloc_size = sizeof(struct eth_pdata), |
| 607 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 608 | }; |