wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Adam Kowalczyk, ACK Software Controls Inc. akowalczyk@cogeco.ca |
| 4 | * |
| 5 | * Some portions taken from 3c59x.c Written 1996-1999 by Donald Becker. |
| 6 | * |
| 7 | * Outline of the program based on eepro100.c which is |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License as |
| 14 | * published by the Free Software Foundation; either version 2 of |
| 15 | * the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This program is distributed in the hope that it will be useful, |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | * GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program; if not, write to the Free Software |
| 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 25 | * MA 02111-1307 USA |
| 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <malloc.h> |
| 30 | #include <net.h> |
Ben Warren | 164846e | 2008-08-31 10:15:26 -0700 | [diff] [blame] | 31 | #include <netdev.h> |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 32 | #include <asm/io.h> |
| 33 | #include <pci.h> |
| 34 | |
| 35 | #include "articiaS.h" |
| 36 | #include "memio.h" |
| 37 | |
| 38 | /* 3Com Ethernet PCI definitions*/ |
| 39 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 40 | /* #define PCI_VENDOR_ID_3COM 0x10B7 */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 41 | #define PCI_DEVICE_ID_3COM_3C905C 0x9200 |
| 42 | |
| 43 | /* 3Com Commands, top 5 bits are command and bottom 11 bits are parameters */ |
| 44 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 45 | #define TotalReset (0<<11) |
| 46 | #define SelectWindow (1<<11) |
| 47 | #define StartCoax (2<<11) |
| 48 | #define RxDisable (3<<11) |
| 49 | #define RxEnable (4<<11) |
| 50 | #define RxReset (5<<11) |
| 51 | #define UpStall (6<<11) |
| 52 | #define UpUnstall (6<<11)+1 |
| 53 | #define DownStall (6<<11)+2 |
| 54 | #define DownUnstall (6<<11)+3 |
| 55 | #define RxDiscard (8<<11) |
| 56 | #define TxEnable (9<<11) |
| 57 | #define TxDisable (10<<11) |
| 58 | #define TxReset (11<<11) |
| 59 | #define FakeIntr (12<<11) |
| 60 | #define AckIntr (13<<11) |
| 61 | #define SetIntrEnb (14<<11) |
| 62 | #define SetStatusEnb (15<<11) |
| 63 | #define SetRxFilter (16<<11) |
| 64 | #define SetRxThreshold (17<<11) |
| 65 | #define SetTxThreshold (18<<11) |
| 66 | #define SetTxStart (19<<11) |
| 67 | #define StartDMAUp (20<<11) |
| 68 | #define StartDMADown (20<<11)+1 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 69 | #define StatsEnable (21<<11) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 70 | #define StatsDisable (22<<11) |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 71 | #define StopCoax (23<<11) |
| 72 | #define SetFilterBit (25<<11) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 73 | |
| 74 | /* The SetRxFilter command accepts the following classes */ |
| 75 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 76 | #define RxStation 1 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 77 | #define RxMulticast 2 |
| 78 | #define RxBroadcast 4 |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 79 | #define RxProm 8 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 80 | |
| 81 | /* 3Com status word defnitions */ |
| 82 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 83 | #define IntLatch 0x0001 |
| 84 | #define HostError 0x0002 |
| 85 | #define TxComplete 0x0004 |
| 86 | #define TxAvailable 0x0008 |
| 87 | #define RxComplete 0x0010 |
| 88 | #define RxEarly 0x0020 |
| 89 | #define IntReq 0x0040 |
| 90 | #define StatsFull 0x0080 |
| 91 | #define DMADone (1<<8) |
| 92 | #define DownComplete (1<<9) |
| 93 | #define UpComplete (1<<10) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 94 | #define DMAInProgress (1<<11) /* DMA controller is still busy.*/ |
| 95 | #define CmdInProgress (1<<12) /* EL3_CMD is still busy.*/ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 96 | |
| 97 | /* Polling Registers */ |
| 98 | |
| 99 | #define DnPoll 0x2d |
| 100 | #define UpPoll 0x3d |
| 101 | |
| 102 | /* Register window 0 offets */ |
| 103 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 104 | #define Wn0EepromCmd 10 /* Window 0: EEPROM command register. */ |
| 105 | #define Wn0EepromData 12 /* Window 0: EEPROM results register. */ |
| 106 | #define IntrStatus 0x0E /* Valid in all windows. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 107 | |
| 108 | /* Register window 0 EEPROM bits */ |
| 109 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 110 | #define EEPROM_Read 0x80 |
| 111 | #define EEPROM_WRITE 0x40 |
| 112 | #define EEPROM_ERASE 0xC0 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 113 | #define EEPROM_EWENB 0x30 /* Enable erasing/writing for 10 msec. */ |
| 114 | #define EEPROM_EWDIS 0x00 /* Disable EWENB before 10 msec timeout. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 115 | |
| 116 | /* EEPROM locations. */ |
| 117 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 118 | #define PhysAddr01 0 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 119 | #define PhysAddr23 1 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 120 | #define PhysAddr45 2 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 121 | #define ModelID 3 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 122 | #define EtherLink3ID 7 |
| 123 | #define IFXcvrIO 8 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 124 | #define IRQLine 9 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 125 | #define NodeAddr01 10 |
| 126 | #define NodeAddr23 11 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 127 | #define NodeAddr45 12 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 128 | #define DriverTune 13 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 129 | #define Checksum 15 |
| 130 | |
| 131 | /* Register window 1 offsets, the window used in normal operation */ |
| 132 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 133 | #define TX_FIFO 0x10 |
| 134 | #define RX_FIFOa 0x10 |
| 135 | #define RxErrors 0x14 |
| 136 | #define RxStatus 0x18 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 137 | #define Timer 0x1A |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 138 | #define TxStatus 0x1B |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 139 | #define TxFree 0x1C /* Remaining free bytes in Tx buffer. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 140 | |
| 141 | /* Register Window 2 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 142 | |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 143 | #define Wn2_ResetOptions 12 |
| 144 | |
| 145 | /* Register Window 3: MAC/config bits */ |
| 146 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 147 | #define Wn3_Config 0 /* Internal Configuration */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 148 | #define Wn3_MAC_Ctrl 6 |
| 149 | #define Wn3_Options 8 |
| 150 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 151 | #define BFEXT(value, offset, bitcount) \ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 152 | ((((unsigned long)(value)) >> (offset)) & ((1 << (bitcount)) - 1)) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 153 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 154 | #define BFINS(lhs, rhs, offset, bitcount) \ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 155 | (((lhs) & ~((((1 << (bitcount)) - 1)) << (offset))) | \ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 156 | (((rhs) & ((1 << (bitcount)) - 1)) << (offset))) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 157 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 158 | #define RAM_SIZE(v) BFEXT(v, 0, 3) |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 159 | #define RAM_WIDTH(v) BFEXT(v, 3, 1) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 160 | #define RAM_SPEED(v) BFEXT(v, 4, 2) |
| 161 | #define ROM_SIZE(v) BFEXT(v, 6, 2) |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 162 | #define RAM_SPLIT(v) BFEXT(v, 16, 2) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 163 | #define XCVR(v) BFEXT(v, 20, 4) |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 164 | #define AUTOSELECT(v) BFEXT(v, 24, 1) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 165 | |
| 166 | /* Register Window 4: Xcvr/media bits */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 167 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 168 | #define Wn4_FIFODiag 4 |
| 169 | #define Wn4_NetDiag 6 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 170 | #define Wn4_PhysicalMgmt 8 |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 171 | #define Wn4_Media 10 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 172 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 173 | #define Media_SQE 0x0008 /* Enable SQE error counting for AUI. */ |
| 174 | #define Media_10TP 0x00C0 /* Enable link beat and jabber for 10baseT. */ |
| 175 | #define Media_Lnk 0x0080 /* Enable just link beat for 100TX/100FX. */ |
| 176 | #define Media_LnkBeat 0x0800 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 177 | |
| 178 | /* Register Window 7: Bus Master control */ |
| 179 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 180 | #define Wn7_MasterAddr 0 |
| 181 | #define Wn7_MasterLen 6 |
| 182 | #define Wn7_MasterStatus 12 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 183 | |
| 184 | /* Boomerang bus master control registers. */ |
| 185 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 186 | #define PktStatus 0x20 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 187 | #define DownListPtr 0x24 |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 188 | #define FragAddr 0x28 |
| 189 | #define FragLen 0x2c |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 190 | #define TxFreeThreshold 0x2f |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 191 | #define UpPktStatus 0x30 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 192 | #define UpListPtr 0x38 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 193 | |
| 194 | /* The Rx and Tx descriptor lists. */ |
| 195 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 196 | #define LAST_FRAG 0x80000000 /* Last Addr/Len pair in descriptor. */ |
| 197 | #define DN_COMPLETE 0x00010000 /* This packet has been downloaded */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 198 | |
| 199 | struct rx_desc_3com { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 200 | u32 next; /* Last entry points to 0 */ |
| 201 | u32 status; /* FSH -> Frame Start Header */ |
| 202 | u32 addr; /* Up to 63 addr/len pairs possible */ |
| 203 | u32 length; /* Set LAST_FRAG to indicate last pair */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | /* Values for the Rx status entry. */ |
| 207 | |
| 208 | #define RxDComplete 0x00008000 |
| 209 | #define RxDError 0x4000 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 210 | #define IPChksumErr (1<<25) |
| 211 | #define TCPChksumErr (1<<26) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 212 | #define UDPChksumErr (1<<27) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 213 | #define IPChksumValid (1<<29) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 214 | #define TCPChksumValid (1<<30) |
| 215 | #define UDPChksumValid (1<<31) |
| 216 | |
| 217 | struct tx_desc_3com { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 218 | u32 next; /* Last entry points to 0 */ |
| 219 | u32 status; /* bits 0:12 length, others see below */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 220 | u32 addr; |
| 221 | u32 length; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
| 224 | /* Values for the Tx status entry. */ |
| 225 | |
| 226 | #define CRCDisable 0x2000 |
| 227 | #define TxDComplete 0x8000 |
| 228 | #define AddIPChksum 0x02000000 |
| 229 | #define AddTCPChksum 0x04000000 |
| 230 | #define AddUDPChksum 0x08000000 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 231 | #define TxIntrUploaded 0x80000000 /* IRQ when in FIFO, but maybe not sent. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 232 | |
| 233 | /* XCVR Types */ |
| 234 | |
| 235 | #define XCVR_10baseT 0 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 236 | #define XCVR_AUI 1 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 237 | #define XCVR_10baseTOnly 2 |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 238 | #define XCVR_10base2 3 |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 239 | #define XCVR_100baseTx 4 |
| 240 | #define XCVR_100baseFx 5 |
| 241 | #define XCVR_MII 6 |
| 242 | #define XCVR_NWAY 8 |
| 243 | #define XCVR_ExtMII 9 |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 244 | #define XCVR_Default 10 /* I don't think this is correct -> should have been 0x10 if Auto Negotiate */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 245 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 246 | struct descriptor { /* A generic descriptor. */ |
| 247 | u32 next; /* Last entry points to 0 */ |
| 248 | u32 status; /* FSH -> Frame Start Header */ |
| 249 | u32 addr; /* Up to 63 addr/len pairs possible */ |
| 250 | u32 length; /* Set LAST_FRAG to indicate last pair */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | /* Misc. definitions */ |
| 254 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 255 | #define NUM_RX_DESC PKTBUFSRX * 10 |
| 256 | #define NUM_TX_DESC 1 /* Number of TX descriptors */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 257 | |
| 258 | #define TOUT_LOOP 1000000 |
| 259 | |
| 260 | #define ETH_ALEN 6 |
| 261 | |
| 262 | #define EL3WINDOW(dev, win_num) ETH_OUTW(dev, SelectWindow + (win_num), EL3_CMD) |
| 263 | #define EL3_CMD 0x0e |
| 264 | #define EL3_STATUS 0x0e |
| 265 | |
| 266 | |
| 267 | #undef ETH_DEBUG |
| 268 | |
| 269 | #ifdef ETH_DEBUG |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 270 | #define PRINTF(fmt,args...) printf (fmt ,##args) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 271 | #else |
| 272 | #define PRINTF(fmt,args...) |
| 273 | #endif |
| 274 | |
| 275 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 276 | static struct rx_desc_3com *rx_ring; /* RX descriptor ring */ |
| 277 | static struct tx_desc_3com *tx_ring; /* TX descriptor ring */ |
| 278 | static u8 rx_buffer[NUM_RX_DESC][PKTSIZE_ALIGN];/* storage for the incoming messages */ |
| 279 | static int rx_next = 0; /* RX descriptor ring pointer */ |
| 280 | static int tx_next = 0; /* TX descriptor ring pointer */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 281 | static int tx_threshold; |
| 282 | |
| 283 | static void init_rx_ring(struct eth_device* dev); |
| 284 | static void purge_tx_ring(struct eth_device* dev); |
| 285 | |
| 286 | static void read_hw_addr(struct eth_device* dev, bd_t * bis); |
| 287 | |
| 288 | static int eth_3com_init(struct eth_device* dev, bd_t *bis); |
| 289 | static int eth_3com_send(struct eth_device* dev, volatile void *packet, int length); |
| 290 | static int eth_3com_recv(struct eth_device* dev); |
| 291 | static void eth_3com_halt(struct eth_device* dev); |
| 292 | |
| 293 | #define io_to_phys(a) pci_io_to_phys((pci_dev_t)dev->priv, a) |
| 294 | #define phys_to_io(a) pci_phys_to_io((pci_dev_t)dev->priv, a) |
| 295 | #define mem_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, a) |
| 296 | #define phys_to_mem(a) pci_phys_to_mem((pci_dev_t)dev->priv, a) |
| 297 | |
| 298 | static inline int ETH_INL(struct eth_device* dev, u_long addr) |
| 299 | { |
| 300 | __asm volatile ("eieio"); |
| 301 | return le32_to_cpu(*(volatile u32 *)io_to_phys(addr + dev->iobase)); |
| 302 | } |
| 303 | |
| 304 | static inline int ETH_INW(struct eth_device* dev, u_long addr) |
| 305 | { |
| 306 | __asm volatile ("eieio"); |
| 307 | return le16_to_cpu(*(volatile u16 *)io_to_phys(addr + dev->iobase)); |
| 308 | } |
| 309 | |
| 310 | static inline int ETH_INB(struct eth_device* dev, u_long addr) |
| 311 | { |
| 312 | __asm volatile ("eieio"); |
| 313 | return *(volatile u8 *)io_to_phys(addr + dev->iobase); |
| 314 | } |
| 315 | |
| 316 | static inline void ETH_OUTB(struct eth_device* dev, int command, u_long addr) |
| 317 | { |
| 318 | *(volatile u8 *)io_to_phys(addr + dev->iobase) = command; |
| 319 | __asm volatile ("eieio"); |
| 320 | } |
| 321 | |
| 322 | static inline void ETH_OUTW(struct eth_device* dev, int command, u_long addr) |
| 323 | { |
| 324 | *(volatile u16 *)io_to_phys(addr + dev->iobase) = cpu_to_le16(command); |
| 325 | __asm volatile ("eieio"); |
| 326 | } |
| 327 | |
| 328 | static inline void ETH_OUTL(struct eth_device* dev, int command, u_long addr) |
| 329 | { |
| 330 | *(volatile u32 *)io_to_phys(addr + dev->iobase) = cpu_to_le32(command); |
| 331 | __asm volatile ("eieio"); |
| 332 | } |
| 333 | |
| 334 | static inline int ETH_STATUS(struct eth_device* dev) |
| 335 | { |
| 336 | __asm volatile ("eieio"); |
| 337 | return le16_to_cpu(*(volatile u16 *)io_to_phys(EL3_STATUS + dev->iobase)); |
| 338 | } |
| 339 | |
| 340 | static inline void ETH_CMD(struct eth_device* dev, int command) |
| 341 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 342 | *(volatile u16 *)io_to_phys(EL3_CMD + dev->iobase) = cpu_to_le16(command); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 343 | __asm volatile ("eieio"); |
| 344 | } |
| 345 | |
| 346 | /* Command register is always in the same spot in all the register windows */ |
| 347 | /* This function issues a command and waits for it so complete by checking the CmdInProgress bit */ |
| 348 | |
| 349 | static int issue_and_wait(struct eth_device* dev, int command) |
| 350 | { |
| 351 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 352 | int i, status; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 353 | |
| 354 | ETH_CMD(dev, command); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 355 | for (i = 0; i < 2000; i++) { |
| 356 | status = ETH_STATUS(dev); |
| 357 | /*printf ("Issue: status 0x%4x.\n", status); */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 358 | if (!(status & CmdInProgress)) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 359 | return 1; |
| 360 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 361 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 362 | /* OK, that didn't work. Do it the slow way. One second */ |
| 363 | for (i = 0; i < 100000; i++) { |
| 364 | status = ETH_STATUS(dev); |
| 365 | /*printf ("Issue: status 0x%4x.\n", status); */ |
| 366 | return 1; |
| 367 | udelay(10); |
| 368 | } |
| 369 | PRINTF("Ethernet command: 0x%4x did not complete! Status: 0x%4x\n", command, ETH_STATUS(dev) ); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 370 | return 0; |
| 371 | } |
| 372 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 373 | /* Determine network media type and set up 3com accordingly */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 374 | /* I think I'm going to start with something known first like 10baseT */ |
| 375 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 376 | static int auto_negotiate (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 377 | { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 378 | int i; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 379 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 380 | EL3WINDOW (dev, 1); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 381 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 382 | /* Wait for Auto negotiation to complete */ |
| 383 | for (i = 0; i <= 1000; i++) { |
| 384 | if (ETH_INW (dev, 2) & 0x04) |
| 385 | break; |
| 386 | udelay (100); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 387 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 388 | if (i == 1000) { |
| 389 | PRINTF ("Error: Auto negotiation failed\n"); |
| 390 | return 0; |
| 391 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 392 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 393 | |
| 394 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 395 | return 1; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 396 | } |
| 397 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 398 | void eth_interrupt (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 399 | { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 400 | u16 status = ETH_STATUS (dev); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 401 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 402 | printf ("eth0: status = 0x%04x\n", status); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 403 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 404 | if (!(status & IntLatch)) |
| 405 | return; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 406 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 407 | if (status & (1 << 6)) { |
| 408 | ETH_CMD (dev, AckIntr | (1 << 6)); |
| 409 | printf ("Acknowledged Interrupt command\n"); |
| 410 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 411 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 412 | if (status & DownComplete) { |
| 413 | ETH_CMD (dev, AckIntr | DownComplete); |
| 414 | printf ("Acknowledged DownComplete\n"); |
| 415 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 416 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 417 | if (status & UpComplete) { |
| 418 | ETH_CMD (dev, AckIntr | UpComplete); |
| 419 | printf ("Acknowledged UpComplete\n"); |
| 420 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 421 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 422 | ETH_CMD (dev, AckIntr | IntLatch); |
| 423 | printf ("Acknowledged IntLatch\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 424 | } |
| 425 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 426 | int eth_3com_initialize (bd_t * bis) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 427 | { |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 428 | u32 eth_iobase = 0, status; |
| 429 | int card_number = 0, ret; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 430 | struct eth_device *dev; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 431 | pci_dev_t devno; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 432 | char *s; |
| 433 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 434 | s = getenv ("3com_base"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 435 | |
| 436 | /* Find ethernet controller on the PCI bus */ |
| 437 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 438 | if ((devno = |
| 439 | pci_find_device (PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C, |
| 440 | 0)) < 0) { |
| 441 | PRINTF ("Error: Cannot find the ethernet device on the PCI bus\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 442 | goto Done; |
| 443 | } |
| 444 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 445 | if (s) { |
| 446 | unsigned long base = atoi (s); |
| 447 | |
| 448 | pci_write_config_dword (devno, PCI_BASE_ADDRESS_0, |
| 449 | base | 0x01); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 452 | ret = pci_read_config_dword (devno, PCI_BASE_ADDRESS_0, ð_iobase); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 453 | eth_iobase &= ~0xf; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 454 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 455 | PRINTF ("eth: 3Com Found at Address: 0x%x\n", eth_iobase); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 456 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 457 | pci_write_config_dword (devno, PCI_COMMAND, |
| 458 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY | |
| 459 | PCI_COMMAND_MASTER); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 460 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 461 | /* Check if I/O accesses and Bus Mastering are enabled */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 462 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 463 | ret = pci_read_config_dword (devno, PCI_COMMAND, &status); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 464 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 465 | if (!(status & PCI_COMMAND_IO)) { |
| 466 | printf ("Error: Cannot enable IO access.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 467 | goto Done; |
| 468 | } |
| 469 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 470 | if (!(status & PCI_COMMAND_MEMORY)) { |
| 471 | printf ("Error: Cannot enable MEMORY access.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 472 | goto Done; |
| 473 | } |
| 474 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 475 | if (!(status & PCI_COMMAND_MASTER)) { |
| 476 | printf ("Error: Cannot enable Bus Mastering.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 477 | goto Done; |
| 478 | } |
| 479 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 480 | dev = (struct eth_device *) malloc (sizeof (*dev)); /*struct eth_device)); */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 481 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 482 | sprintf (dev->name, "3Com 3c920c#%d", card_number); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 483 | dev->iobase = eth_iobase; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 484 | dev->priv = (void *) devno; |
| 485 | dev->init = eth_3com_init; |
| 486 | dev->halt = eth_3com_halt; |
| 487 | dev->send = eth_3com_send; |
| 488 | dev->recv = eth_3com_recv; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 489 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 490 | eth_register (dev); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 491 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 492 | /* { */ |
| 493 | /* char interrupt; */ |
| 494 | /* devno = pci_find_device(PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3C905C, 0); */ |
| 495 | /* pci_read_config_byte(devno, PCI_INTERRUPT_LINE, &interrupt); */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 496 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 497 | /* printf("Installing eth0 interrupt handler to %d\n", interrupt); */ |
| 498 | /* irq_install_handler(interrupt, eth_interrupt, dev); */ |
| 499 | /* } */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 500 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 501 | card_number++; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 502 | |
| 503 | /* Set the latency timer for value */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 504 | s = getenv ("3com_latency"); |
| 505 | if (s) { |
| 506 | ret = pci_write_config_byte (devno, PCI_LATENCY_TIMER, |
| 507 | (unsigned char) atoi (s)); |
| 508 | } else |
| 509 | ret = pci_write_config_byte (devno, PCI_LATENCY_TIMER, 0x0a); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 510 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 511 | read_hw_addr (dev, bis); /* get the MAC address from Window 2 */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 512 | |
| 513 | /* Reset the ethernet controller */ |
| 514 | |
| 515 | PRINTF ("Issuing reset command....\n"); |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 516 | if (!issue_and_wait (dev, TotalReset)) { |
| 517 | printf ("Error: Cannot reset ethernet controller.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 518 | goto Done; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 519 | } else |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 520 | PRINTF ("Ethernet controller reset.\n"); |
| 521 | |
| 522 | /* allocate memory for rx and tx rings */ |
| 523 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 524 | if (!(rx_ring = memalign (sizeof (struct rx_desc_3com) * NUM_RX_DESC, 16))) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 525 | PRINTF ("Cannot allocate memory for RX_RING.....\n"); |
| 526 | goto Done; |
| 527 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 528 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 529 | if (!(tx_ring = memalign (sizeof (struct tx_desc_3com) * NUM_TX_DESC, 16))) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 530 | PRINTF ("Cannot allocate memory for TX_RING.....\n"); |
| 531 | goto Done; |
| 532 | } |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 533 | |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 534 | Done: |
| 535 | return status; |
| 536 | } |
| 537 | |
| 538 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 539 | static int eth_3com_init (struct eth_device *dev, bd_t * bis) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 540 | { |
| 541 | int i, status = 0; |
| 542 | int tx_cur, loop; |
| 543 | u16 status_enable, intr_enable; |
| 544 | struct descriptor *ias_cmd; |
| 545 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 546 | /* Determine what type of network the machine is connected to */ |
| 547 | /* presently drops the connect to 10Mbps */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 548 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 549 | if (!auto_negotiate (dev)) { |
| 550 | printf ("Error: Cannot determine network media.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 551 | goto Done; |
| 552 | } |
| 553 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 554 | issue_and_wait (dev, TxReset); |
| 555 | issue_and_wait (dev, RxReset | 0x04); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 556 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 557 | /* Switch to register set 7 for normal use. */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 558 | EL3WINDOW (dev, 7); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 559 | |
| 560 | /* Initialize Rx and Tx rings */ |
| 561 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 562 | init_rx_ring (dev); |
| 563 | purge_tx_ring (dev); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 564 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 565 | ETH_CMD (dev, SetRxFilter | RxStation | RxBroadcast | RxProm); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 566 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 567 | issue_and_wait (dev, SetTxStart | 0x07ff); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 568 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 569 | /* Below sets which indication bits to be seen. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 570 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 571 | status_enable = |
| 572 | SetStatusEnb | HostError | DownComplete | UpComplete | (1 << |
| 573 | 6); |
| 574 | ETH_CMD (dev, status_enable); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 575 | |
| 576 | /* Below sets no bits are to cause an interrupt since this is just polling */ |
| 577 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 578 | intr_enable = SetIntrEnb; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 579 | /* intr_enable = SetIntrEnb | (1<<9) | (1<<10) | (1<<6); */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 580 | ETH_CMD (dev, intr_enable); |
| 581 | ETH_OUTB (dev, 127, UpPoll); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 582 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 583 | /* Ack all pending events, and set active indicator mask */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 584 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 585 | ETH_CMD (dev, AckIntr | IntLatch | TxAvailable | RxEarly | IntReq); |
| 586 | ETH_CMD (dev, intr_enable); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 587 | |
| 588 | /* Tell the adapter where the RX ring is located */ |
| 589 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 590 | issue_and_wait (dev, UpStall); /* Stall and set the UplistPtr */ |
| 591 | ETH_OUTL (dev, (u32) & rx_ring[rx_next], UpListPtr); |
| 592 | ETH_CMD (dev, RxEnable); /* Enable the receiver. */ |
| 593 | issue_and_wait (dev, UpUnstall); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 594 | |
| 595 | /* Send the Individual Address Setup frame */ |
| 596 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 597 | tx_cur = tx_next; |
| 598 | tx_next = ((tx_next + 1) % NUM_TX_DESC); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 599 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 600 | ias_cmd = (struct descriptor *) &tx_ring[tx_cur]; |
| 601 | ias_cmd->status = cpu_to_le32 (1 << 31); /* set DnIndicate bit. */ |
| 602 | ias_cmd->next = 0; |
| 603 | ias_cmd->addr = cpu_to_le32 ((u32) & bis->bi_enetaddr[0]); |
| 604 | ias_cmd->length = cpu_to_le32 (6 | LAST_FRAG); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 605 | |
| 606 | /* Tell the adapter where the TX ring is located */ |
| 607 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 608 | ETH_CMD (dev, TxEnable); /* Enable transmitter. */ |
| 609 | issue_and_wait (dev, DownStall); /* Stall and set the DownListPtr. */ |
| 610 | ETH_OUTL (dev, (u32) & tx_ring[tx_cur], DownListPtr); |
| 611 | issue_and_wait (dev, DownUnstall); |
| 612 | for (i = 0; !(ETH_STATUS (dev) & DownComplete); i++) { |
| 613 | if (i >= TOUT_LOOP) { |
| 614 | PRINTF ("TX Ring status (Init): 0x%4x\n", |
| 615 | le32_to_cpu (tx_ring[tx_cur].status)); |
| 616 | PRINTF ("ETH_STATUS: 0x%x\n", ETH_STATUS (dev)); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 617 | goto Done; |
| 618 | } |
| 619 | } |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 620 | if (ETH_STATUS (dev) & DownComplete) { /* If DownLoad Complete ACK the bit */ |
| 621 | ETH_CMD (dev, AckIntr | DownComplete); /* acknowledge the indication bit */ |
| 622 | issue_and_wait (dev, DownStall); /* stall and clear DownListPtr */ |
| 623 | ETH_OUTL (dev, 0, DownListPtr); |
| 624 | issue_and_wait (dev, DownUnstall); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 625 | } |
| 626 | status = 1; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 627 | Done: |
| 628 | return status; |
| 629 | } |
| 630 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 631 | int eth_3com_send (struct eth_device *dev, volatile void *packet, int length) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 632 | { |
| 633 | int i, status = 0; |
| 634 | int tx_cur; |
| 635 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 636 | if (length <= 0) { |
| 637 | PRINTF ("eth: bad packet size: %d\n", length); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 638 | goto Done; |
| 639 | } |
| 640 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 641 | tx_cur = tx_next; |
| 642 | tx_next = (tx_next + 1) % NUM_TX_DESC; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 643 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 644 | tx_ring[tx_cur].status = cpu_to_le32 (1 << 31); /* set DnIndicate bit */ |
| 645 | tx_ring[tx_cur].next = 0; |
| 646 | tx_ring[tx_cur].addr = cpu_to_le32 (((u32) packet)); |
| 647 | tx_ring[tx_cur].length = cpu_to_le32 (length | LAST_FRAG); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 648 | |
| 649 | /* Send the packet */ |
| 650 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 651 | issue_and_wait (dev, DownStall); /* stall and set the DownListPtr */ |
| 652 | ETH_OUTL (dev, (u32) & tx_ring[tx_cur], DownListPtr); |
| 653 | issue_and_wait (dev, DownUnstall); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 654 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 655 | for (i = 0; !(ETH_STATUS (dev) & DownComplete); i++) { |
| 656 | if (i >= TOUT_LOOP) { |
| 657 | PRINTF ("TX Ring status (send): 0x%4x\n", |
| 658 | le32_to_cpu (tx_ring[tx_cur].status)); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 659 | goto Done; |
| 660 | } |
| 661 | } |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 662 | if (ETH_STATUS (dev) & DownComplete) { /* If DownLoad Complete ACK the bit */ |
| 663 | ETH_CMD (dev, AckIntr | DownComplete); /* acknowledge the indication bit */ |
| 664 | issue_and_wait (dev, DownStall); /* stall and clear DownListPtr */ |
| 665 | ETH_OUTL (dev, 0, DownListPtr); |
| 666 | issue_and_wait (dev, DownUnstall); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 667 | } |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 668 | status = 1; |
| 669 | Done: |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 670 | return status; |
| 671 | } |
| 672 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 673 | void PrintPacket (uchar * packet, int length) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 674 | { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 675 | int loop; |
| 676 | uchar *ptr; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 677 | |
| 678 | printf ("Printing packet of length %x.\n\n", length); |
| 679 | ptr = packet; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 680 | for (loop = 1; loop <= length; loop++) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 681 | printf ("%2x ", *ptr++); |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 682 | if ((loop % 40) == 0) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 683 | printf ("\n"); |
| 684 | } |
| 685 | } |
| 686 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 687 | int eth_3com_recv (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 688 | { |
| 689 | u16 stat = 0; |
| 690 | u32 status; |
| 691 | int rx_prev, length = 0; |
| 692 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 693 | while (!(ETH_STATUS (dev) & UpComplete)) /* wait on receipt of packet */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 694 | ; |
| 695 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 696 | status = le32_to_cpu (rx_ring[rx_next].status); /* packet status */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 697 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 698 | while (status & (1 << 15)) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 699 | /* A packet has been received */ |
| 700 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 701 | if (status & (1 << 15)) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 702 | /* A valid frame received */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 703 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 704 | length = le32_to_cpu (rx_ring[rx_next].status) & 0x1fff; /* length is in bits 0 - 12 */ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 705 | |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 706 | /* Pass the packet up to the protocol layers */ |
| 707 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 708 | NetReceive ((uchar *) |
| 709 | le32_to_cpu (rx_ring[rx_next].addr), |
| 710 | length); |
| 711 | rx_ring[rx_next].status = 0; /* clear the status word */ |
| 712 | ETH_CMD (dev, AckIntr | UpComplete); |
| 713 | issue_and_wait (dev, UpUnstall); |
| 714 | } else if (stat & HostError) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 715 | /* There was an error */ |
| 716 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 717 | printf ("Rx error status: 0x%4x\n", stat); |
| 718 | init_rx_ring (dev); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 719 | goto Done; |
| 720 | } |
| 721 | |
| 722 | rx_prev = rx_next; |
| 723 | rx_next = (rx_next + 1) % NUM_RX_DESC; |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 724 | stat = ETH_STATUS (dev); /* register status */ |
| 725 | status = le32_to_cpu (rx_ring[rx_next].status); /* packet status */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 726 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 727 | Done: |
| 728 | return length; |
| 729 | } |
| 730 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 731 | void eth_3com_halt (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 732 | { |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 733 | if (!(dev->iobase)) { |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 734 | goto Done; |
| 735 | } |
| 736 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 737 | issue_and_wait (dev, DownStall); /* shut down transmit and receive */ |
| 738 | issue_and_wait (dev, UpStall); |
| 739 | issue_and_wait (dev, RxDisable); |
| 740 | issue_and_wait (dev, TxDisable); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 741 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 742 | /* free(tx_ring); /###* release memory allocated to the DPD and UPD rings */ |
| 743 | /* free(rx_ring); */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 744 | |
| 745 | Done: |
| 746 | return; |
| 747 | } |
| 748 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 749 | static void init_rx_ring (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 750 | { |
| 751 | int i; |
| 752 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 753 | PRINTF ("Initializing rx_ring. rx_buffer = %p\n", rx_buffer); |
| 754 | issue_and_wait (dev, UpStall); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 755 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 756 | for (i = 0; i < NUM_RX_DESC; i++) { |
| 757 | rx_ring[i].next = |
| 758 | cpu_to_le32 (((u32) & |
| 759 | rx_ring[(i + 1) % NUM_RX_DESC])); |
| 760 | rx_ring[i].status = 0; |
| 761 | rx_ring[i].addr = cpu_to_le32 (((u32) & rx_buffer[i][0])); |
| 762 | rx_ring[i].length = cpu_to_le32 (PKTSIZE_ALIGN | LAST_FRAG); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 763 | } |
| 764 | rx_next = 0; |
| 765 | } |
| 766 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 767 | static void purge_tx_ring (struct eth_device *dev) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 768 | { |
| 769 | int i; |
| 770 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 771 | PRINTF ("Purging tx_ring.\n"); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 772 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 773 | tx_next = 0; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 774 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 775 | for (i = 0; i < NUM_TX_DESC; i++) { |
| 776 | tx_ring[i].next = 0; |
| 777 | tx_ring[i].status = 0; |
| 778 | tx_ring[i].addr = 0; |
| 779 | tx_ring[i].length = 0; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 780 | } |
| 781 | } |
| 782 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 783 | static void read_hw_addr (struct eth_device *dev, bd_t * bis) |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 784 | { |
| 785 | u8 hw_addr[ETH_ALEN]; |
| 786 | unsigned int eeprom[0x40]; |
| 787 | unsigned int checksum = 0; |
| 788 | int i, j, timer; |
| 789 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 790 | /* Read the station address from the EEPROM. */ |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 791 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 792 | EL3WINDOW (dev, 0); |
| 793 | for (i = 0; i < 0x40; i++) { |
| 794 | ETH_OUTW (dev, EEPROM_Read + i, Wn0EepromCmd); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 795 | /* Pause for at least 162 us. for the read to take place. */ |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 796 | for (timer = 10; timer >= 0; timer--) { |
| 797 | udelay (162); |
| 798 | if ((ETH_INW (dev, Wn0EepromCmd) & 0x8000) == 0) |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 799 | break; |
| 800 | } |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 801 | eeprom[i] = ETH_INW (dev, Wn0EepromData); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 802 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 803 | |
| 804 | /* Checksum calculation. I'm not sure about this part and there seems to be a bug on the 3com side of things */ |
| 805 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 806 | for (i = 0; i < 0x21; i++) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 807 | checksum ^= eeprom[i]; |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 808 | checksum = (checksum ^ (checksum >> 8)) & 0xff; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 809 | |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 810 | if (checksum != 0xbb) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 811 | printf (" *** INVALID EEPROM CHECKSUM %4.4x *** \n", |
| 812 | checksum); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 813 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 814 | for (i = 0, j = 0; i < 3; i++) { |
| 815 | hw_addr[j++] = (u8) ((eeprom[i + 10] >> 8) & 0xff); |
| 816 | hw_addr[j++] = (u8) (eeprom[i + 10] & 0xff); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 817 | } |
| 818 | |
| 819 | /* MAC Address is in window 2, write value from EEPROM to window 2 */ |
| 820 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 821 | EL3WINDOW (dev, 2); |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 822 | for (i = 0; i < 6; i++) |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 823 | ETH_OUTB (dev, hw_addr[i], i); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 824 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 825 | for (j = 0; j < ETH_ALEN; j += 2) { |
| 826 | hw_addr[j] = (u8) (ETH_INW (dev, j) & 0xff); |
| 827 | hw_addr[j + 1] = (u8) ((ETH_INW (dev, j) >> 8) & 0xff); |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 830 | for (i = 0; i < ETH_ALEN; i++) { |
| 831 | if (hw_addr[i] != bis->bi_enetaddr[i]) { |
| 832 | /* printf("Warning: HW address don't match:\n"); */ |
| 833 | /* printf("Address in 3Com Window 2 is " */ |
| 834 | /* "%02X:%02X:%02X:%02X:%02X:%02X\n", */ |
| 835 | /* hw_addr[0], hw_addr[1], hw_addr[2], */ |
| 836 | /* hw_addr[3], hw_addr[4], hw_addr[5]); */ |
| 837 | /* printf("Address used by U-Boot is " */ |
| 838 | /* "%02X:%02X:%02X:%02X:%02X:%02X\n", */ |
| 839 | /* bis->bi_enetaddr[0], bis->bi_enetaddr[1], */ |
| 840 | /* bis->bi_enetaddr[2], bis->bi_enetaddr[3], */ |
| 841 | /* bis->bi_enetaddr[4], bis->bi_enetaddr[5]); */ |
| 842 | /* goto Done; */ |
| 843 | char buffer[256]; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 844 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 845 | if (bis->bi_enetaddr[0] == 0 |
| 846 | && bis->bi_enetaddr[1] == 0 |
| 847 | && bis->bi_enetaddr[2] == 0 |
| 848 | && bis->bi_enetaddr[3] == 0 |
| 849 | && bis->bi_enetaddr[4] == 0 |
| 850 | && bis->bi_enetaddr[5] == 0) { |
| 851 | |
| 852 | sprintf (buffer, |
| 853 | "%02X:%02X:%02X:%02X:%02X:%02X", |
| 854 | hw_addr[0], hw_addr[1], hw_addr[2], |
| 855 | hw_addr[3], hw_addr[4], hw_addr[5]); |
| 856 | setenv ("ethaddr", buffer); |
| 857 | } |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 858 | } |
| 859 | } |
| 860 | |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 861 | for (i = 0; i < ETH_ALEN; i++) |
| 862 | dev->enetaddr[i] = hw_addr[i]; |
wdenk | c7de829 | 2002-11-19 11:04:11 +0000 | [diff] [blame] | 863 | |
| 864 | Done: |
| 865 | return; |
| 866 | } |