Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Faraday FTMAC100 Ethernet |
| 4 | * |
| 5 | * (C) Copyright 2009 Faraday Technology |
| 6 | * Po-Yu Chuang <ratbert@faraday-tech.com> |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <config.h> |
| 10 | #include <common.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 11 | #include <cpu_func.h> |
Simon Glass | 0af6e2d | 2019-08-01 09:46:52 -0600 | [diff] [blame] | 12 | #include <env.h> |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 13 | #include <malloc.h> |
| 14 | #include <net.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 15 | #include <asm/global_data.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 16 | #include <linux/delay.h> |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 17 | #include <linux/io.h> |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 18 | |
| 19 | #include "ftmac100.h" |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 20 | #include <dm.h> |
Tom Rini | c8c4c56 | 2022-11-19 18:45:40 -0500 | [diff] [blame] | 21 | |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 22 | DECLARE_GLOBAL_DATA_PTR; |
Tom Rini | c8c4c56 | 2022-11-19 18:45:40 -0500 | [diff] [blame] | 23 | |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 24 | #define ETH_ZLEN 60 |
| 25 | |
| 26 | struct ftmac100_data { |
Po-Yu Chuang | 767ba6f | 2011-01-21 15:50:37 +0800 | [diff] [blame] | 27 | struct ftmac100_txdes txdes[1]; |
| 28 | struct ftmac100_rxdes rxdes[PKTBUFSRX]; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 29 | int rx_index; |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 30 | const char *name; |
| 31 | phys_addr_t iobase; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /* |
| 35 | * Reset MAC |
| 36 | */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 37 | static void ftmac100_reset(struct ftmac100_data *priv) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 38 | { |
Bin Meng | ff7607c | 2021-01-31 20:36:02 +0800 | [diff] [blame] | 39 | struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 40 | |
| 41 | debug ("%s()\n", __func__); |
| 42 | |
| 43 | writel (FTMAC100_MACCR_SW_RST, &ftmac100->maccr); |
| 44 | |
| 45 | while (readl (&ftmac100->maccr) & FTMAC100_MACCR_SW_RST) |
rick | 5496661 | 2017-08-29 10:15:05 +0800 | [diff] [blame] | 46 | mdelay(1); |
| 47 | /* |
| 48 | * When soft reset complete, write mac address immediately maybe fail somehow |
| 49 | * Wait for a while can avoid this problem |
| 50 | */ |
| 51 | mdelay(1); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /* |
| 55 | * Set MAC address |
| 56 | */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 57 | static void ftmac100_set_mac(struct ftmac100_data *priv , |
| 58 | const unsigned char *mac) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 59 | { |
Bin Meng | ff7607c | 2021-01-31 20:36:02 +0800 | [diff] [blame] | 60 | struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 61 | unsigned int maddr = mac[0] << 8 | mac[1]; |
| 62 | unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5]; |
| 63 | |
| 64 | debug ("%s(%x %x)\n", __func__, maddr, laddr); |
| 65 | |
| 66 | writel (maddr, &ftmac100->mac_madr); |
| 67 | writel (laddr, &ftmac100->mac_ladr); |
| 68 | } |
| 69 | |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 70 | /* |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 71 | * Disable MAC |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 72 | */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 73 | static void _ftmac100_halt(struct ftmac100_data *priv) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 74 | { |
Bin Meng | ff7607c | 2021-01-31 20:36:02 +0800 | [diff] [blame] | 75 | struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 76 | debug ("%s()\n", __func__); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 77 | writel (0, &ftmac100->maccr); |
| 78 | } |
| 79 | |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 80 | /* |
| 81 | * Initialize MAC |
| 82 | */ |
| 83 | static int _ftmac100_init(struct ftmac100_data *priv, unsigned char enetaddr[6]) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 84 | { |
Bin Meng | ff7607c | 2021-01-31 20:36:02 +0800 | [diff] [blame] | 85 | struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; |
Po-Yu Chuang | 767ba6f | 2011-01-21 15:50:37 +0800 | [diff] [blame] | 86 | struct ftmac100_txdes *txdes = priv->txdes; |
| 87 | struct ftmac100_rxdes *rxdes = priv->rxdes; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 88 | unsigned int maccr; |
| 89 | int i; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 90 | debug ("%s()\n", __func__); |
| 91 | |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 92 | ftmac100_reset(priv); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 93 | |
| 94 | /* set the ethernet address */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 95 | ftmac100_set_mac(priv, enetaddr); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 96 | |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 97 | |
| 98 | /* disable all interrupts */ |
| 99 | |
| 100 | writel (0, &ftmac100->imr); |
| 101 | |
| 102 | /* initialize descriptors */ |
| 103 | |
| 104 | priv->rx_index = 0; |
| 105 | |
| 106 | txdes[0].txdes1 = FTMAC100_TXDES1_EDOTR; |
| 107 | rxdes[PKTBUFSRX - 1].rxdes1 = FTMAC100_RXDES1_EDORR; |
| 108 | |
| 109 | for (i = 0; i < PKTBUFSRX; i++) { |
| 110 | /* RXBUF_BADR */ |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 111 | rxdes[i].rxdes2 = (unsigned int)(unsigned long)net_rx_packets[i]; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 112 | rxdes[i].rxdes1 |= FTMAC100_RXDES1_RXBUF_SIZE (PKTSIZE_ALIGN); |
| 113 | rxdes[i].rxdes0 = FTMAC100_RXDES0_RXDMA_OWN; |
| 114 | } |
| 115 | |
| 116 | /* transmit ring */ |
| 117 | |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 118 | writel ((unsigned long)txdes, &ftmac100->txr_badr); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 119 | |
| 120 | /* receive ring */ |
| 121 | |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 122 | writel ((unsigned long)rxdes, &ftmac100->rxr_badr); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 123 | |
| 124 | /* poll receive descriptor automatically */ |
| 125 | |
| 126 | writel (FTMAC100_APTC_RXPOLL_CNT (1), &ftmac100->aptc); |
| 127 | |
| 128 | /* enable transmitter, receiver */ |
| 129 | |
| 130 | maccr = FTMAC100_MACCR_XMT_EN | |
| 131 | FTMAC100_MACCR_RCV_EN | |
| 132 | FTMAC100_MACCR_XDMA_EN | |
| 133 | FTMAC100_MACCR_RDMA_EN | |
| 134 | FTMAC100_MACCR_CRC_APD | |
| 135 | FTMAC100_MACCR_ENRX_IN_HALFTX | |
| 136 | FTMAC100_MACCR_RX_RUNT | |
| 137 | FTMAC100_MACCR_RX_BROADPKT; |
| 138 | |
| 139 | writel (maccr, &ftmac100->maccr); |
| 140 | |
| 141 | return 0; |
| 142 | } |
| 143 | |
| 144 | /* |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 145 | * Free receiving buffer |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 146 | */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 147 | static int _ftmac100_free_pkt(struct ftmac100_data *priv) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 148 | { |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 149 | struct ftmac100_rxdes *curr_des; |
| 150 | curr_des = &priv->rxdes[priv->rx_index]; |
| 151 | /* release buffer to DMA */ |
| 152 | curr_des->rxdes0 |= FTMAC100_RXDES0_RXDMA_OWN; |
| 153 | priv->rx_index = (priv->rx_index + 1) % PKTBUFSRX; |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | /* |
| 158 | * Receive a data block via Ethernet |
| 159 | */ |
| 160 | static int __ftmac100_recv(struct ftmac100_data *priv) |
| 161 | { |
Po-Yu Chuang | 767ba6f | 2011-01-21 15:50:37 +0800 | [diff] [blame] | 162 | struct ftmac100_rxdes *curr_des; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 163 | unsigned short rxlen; |
| 164 | |
| 165 | curr_des = &priv->rxdes[priv->rx_index]; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 166 | if (curr_des->rxdes0 & FTMAC100_RXDES0_RXDMA_OWN) |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 167 | return 0; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 168 | |
| 169 | if (curr_des->rxdes0 & (FTMAC100_RXDES0_RX_ERR | |
| 170 | FTMAC100_RXDES0_CRC_ERR | |
| 171 | FTMAC100_RXDES0_FTL | |
| 172 | FTMAC100_RXDES0_RUNT | |
| 173 | FTMAC100_RXDES0_RX_ODD_NB)) { |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 174 | return 0; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | rxlen = FTMAC100_RXDES0_RFL (curr_des->rxdes0); |
rick | b0ce182 | 2017-08-29 10:09:00 +0800 | [diff] [blame] | 178 | invalidate_dcache_range(curr_des->rxdes2,curr_des->rxdes2+rxlen); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 179 | debug ("%s(): RX buffer %d, %x received\n", |
| 180 | __func__, priv->rx_index, rxlen); |
| 181 | |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 182 | return rxlen; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Send a data block via Ethernet |
| 187 | */ |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 188 | static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length) |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 189 | { |
Bin Meng | ff7607c | 2021-01-31 20:36:02 +0800 | [diff] [blame] | 190 | struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; |
Po-Yu Chuang | 767ba6f | 2011-01-21 15:50:37 +0800 | [diff] [blame] | 191 | struct ftmac100_txdes *curr_des = priv->txdes; |
Po-Yu Chuang | 0bed917 | 2011-01-21 15:51:25 +0800 | [diff] [blame] | 192 | ulong start; |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 193 | |
| 194 | if (curr_des->txdes0 & FTMAC100_TXDES0_TXDMA_OWN) { |
| 195 | debug ("%s(): no TX descriptor available\n", __func__); |
| 196 | return -1; |
| 197 | } |
| 198 | |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 199 | debug ("%s(%lx, %x)\n", __func__, (unsigned long)packet, length); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 200 | |
| 201 | length = (length < ETH_ZLEN) ? ETH_ZLEN : length; |
| 202 | |
| 203 | /* initiate a transmit sequence */ |
| 204 | |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 205 | flush_dcache_range((unsigned long)packet,(unsigned long)packet+length); |
| 206 | curr_des->txdes2 = (unsigned int)(unsigned long)packet; /* TXBUF_BADR */ |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 207 | |
| 208 | curr_des->txdes1 &= FTMAC100_TXDES1_EDOTR; |
| 209 | curr_des->txdes1 |= FTMAC100_TXDES1_FTS | |
| 210 | FTMAC100_TXDES1_LTS | |
| 211 | FTMAC100_TXDES1_TXBUF_SIZE (length); |
| 212 | |
| 213 | curr_des->txdes0 = FTMAC100_TXDES0_TXDMA_OWN; |
| 214 | |
| 215 | /* start transmit */ |
| 216 | |
| 217 | writel (1, &ftmac100->txpd); |
| 218 | |
| 219 | /* wait for transfer to succeed */ |
| 220 | |
Po-Yu Chuang | 0bed917 | 2011-01-21 15:51:25 +0800 | [diff] [blame] | 221 | start = get_timer(0); |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 222 | while (curr_des->txdes0 & FTMAC100_TXDES0_TXDMA_OWN) { |
Po-Yu Chuang | 0bed917 | 2011-01-21 15:51:25 +0800 | [diff] [blame] | 223 | if (get_timer(start) >= 5) { |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 224 | debug ("%s(): timed out\n", __func__); |
| 225 | return -1; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | debug ("%s(): packet sent\n", __func__); |
| 230 | |
Po-Yu Chuang | 50253b8 | 2009-08-10 11:00:00 +0800 | [diff] [blame] | 231 | return 0; |
| 232 | } |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 233 | |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 234 | static int ftmac100_start(struct udevice *dev) |
| 235 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 236 | struct eth_pdata *plat = dev_get_plat(dev); |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 237 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 238 | |
| 239 | return _ftmac100_init(priv, plat->enetaddr); |
| 240 | } |
| 241 | |
| 242 | static void ftmac100_stop(struct udevice *dev) |
| 243 | { |
| 244 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 245 | _ftmac100_halt(priv); |
| 246 | } |
| 247 | |
| 248 | static int ftmac100_send(struct udevice *dev, void *packet, int length) |
| 249 | { |
| 250 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 251 | int ret; |
| 252 | ret = _ftmac100_send(priv , packet , length); |
| 253 | return ret ? 0 : -ETIMEDOUT; |
| 254 | } |
| 255 | |
| 256 | static int ftmac100_recv(struct udevice *dev, int flags, uchar **packetp) |
| 257 | { |
| 258 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 259 | struct ftmac100_rxdes *curr_des; |
| 260 | curr_des = &priv->rxdes[priv->rx_index]; |
| 261 | int len; |
| 262 | len = __ftmac100_recv(priv); |
| 263 | if (len) |
Rick Chen | 59d1526 | 2018-05-29 10:42:19 +0800 | [diff] [blame] | 264 | *packetp = (uchar *)(unsigned long)curr_des->rxdes2; |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 265 | |
| 266 | return len ? len : -EAGAIN; |
| 267 | } |
| 268 | |
| 269 | static int ftmac100_free_pkt(struct udevice *dev, uchar *packet, int length) |
| 270 | { |
| 271 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 272 | _ftmac100_free_pkt(priv); |
| 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | int ftmac100_read_rom_hwaddr(struct udevice *dev) |
| 277 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 278 | struct eth_pdata *pdata = dev_get_plat(dev); |
Simon Glass | 399a9ce | 2017-08-03 12:22:14 -0600 | [diff] [blame] | 279 | eth_env_get_enetaddr("ethaddr", pdata->enetaddr); |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 280 | return 0; |
| 281 | } |
| 282 | |
| 283 | static const char *dtbmacaddr(u32 ifno) |
| 284 | { |
| 285 | int node, len; |
| 286 | char enet[16]; |
| 287 | const char *mac; |
| 288 | const char *path; |
| 289 | if (gd->fdt_blob == NULL) { |
| 290 | printf("%s: don't have a valid gd->fdt_blob!\n", __func__); |
| 291 | return NULL; |
| 292 | } |
| 293 | node = fdt_path_offset(gd->fdt_blob, "/aliases"); |
| 294 | if (node < 0) |
| 295 | return NULL; |
| 296 | |
| 297 | sprintf(enet, "ethernet%d", ifno); |
| 298 | path = fdt_getprop(gd->fdt_blob, node, enet, NULL); |
| 299 | if (!path) { |
| 300 | printf("no alias for %s\n", enet); |
| 301 | return NULL; |
| 302 | } |
| 303 | node = fdt_path_offset(gd->fdt_blob, path); |
| 304 | mac = fdt_getprop(gd->fdt_blob, node, "mac-address", &len); |
| 305 | if (mac && is_valid_ethaddr((u8 *)mac)) |
| 306 | return mac; |
| 307 | |
| 308 | return NULL; |
| 309 | } |
| 310 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 311 | static int ftmac100_of_to_plat(struct udevice *dev) |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 312 | { |
| 313 | struct ftmac100_data *priv = dev_get_priv(dev); |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 314 | struct eth_pdata *pdata = dev_get_plat(dev); |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 315 | const char *mac; |
Masahiro Yamada | a89b4de | 2020-07-17 14:36:48 +0900 | [diff] [blame] | 316 | pdata->iobase = dev_read_addr(dev); |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 317 | priv->iobase = pdata->iobase; |
| 318 | mac = dtbmacaddr(0); |
| 319 | if (mac) |
| 320 | memcpy(pdata->enetaddr , mac , 6); |
| 321 | |
| 322 | return 0; |
| 323 | } |
| 324 | |
| 325 | static int ftmac100_probe(struct udevice *dev) |
| 326 | { |
| 327 | struct ftmac100_data *priv = dev_get_priv(dev); |
| 328 | priv->name = dev->name; |
| 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | static int ftmac100_bind(struct udevice *dev) |
| 333 | { |
| 334 | return device_set_name(dev, dev->name); |
| 335 | } |
| 336 | |
| 337 | static const struct eth_ops ftmac100_ops = { |
| 338 | .start = ftmac100_start, |
| 339 | .send = ftmac100_send, |
| 340 | .recv = ftmac100_recv, |
| 341 | .stop = ftmac100_stop, |
| 342 | .free_pkt = ftmac100_free_pkt, |
| 343 | }; |
| 344 | |
| 345 | static const struct udevice_id ftmac100_ids[] = { |
| 346 | { .compatible = "andestech,atmac100" }, |
| 347 | { } |
| 348 | }; |
| 349 | |
| 350 | U_BOOT_DRIVER(ftmac100) = { |
Sergei Antonov | 0e15edb | 2023-02-03 22:09:02 +0300 | [diff] [blame^] | 351 | .name = "ftmac100", |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 352 | .id = UCLASS_ETH, |
| 353 | .of_match = ftmac100_ids, |
| 354 | .bind = ftmac100_bind, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 355 | .of_to_plat = ftmac100_of_to_plat, |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 356 | .probe = ftmac100_probe, |
| 357 | .ops = &ftmac100_ops, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 358 | .priv_auto = sizeof(struct ftmac100_data), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 359 | .plat_auto = sizeof(struct eth_pdata), |
rick | dc24dac | 2017-05-23 13:48:27 +0800 | [diff] [blame] | 360 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 361 | }; |