smc91111.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  1. /*------------------------------------------------------------------------
  2. . smc91111.c
  3. . This is a driver for SMSC's 91C111 single-chip Ethernet device.
  4. .
  5. . (C) Copyright 2002
  6. . Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  7. . Rolf Offermanns <rof@sysgo.de>
  8. .
  9. . Copyright (C) 2001 Standard Microsystems Corporation (SMSC)
  10. . Developed by Simple Network Magic Corporation (SNMC)
  11. . Copyright (C) 1996 by Erik Stahlman (ES)
  12. .
  13. . This program is free software; you can redistribute it and/or modify
  14. . it under the terms of the GNU General Public License as published by
  15. . the Free Software Foundation; either version 2 of the License, or
  16. . (at your option) any later version.
  17. .
  18. . This program is distributed in the hope that it will be useful,
  19. . but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. . MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. . GNU General Public License for more details.
  22. .
  23. . You should have received a copy of the GNU General Public License
  24. . along with this program; if not, write to the Free Software
  25. . Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. .
  27. . Information contained in this file was obtained from the LAN91C111
  28. . manual from SMC. To get a copy, if you really want one, you can find
  29. . information under www.smsc.com.
  30. .
  31. .
  32. . "Features" of the SMC chip:
  33. . Integrated PHY/MAC for 10/100BaseT Operation
  34. . Supports internal and external MII
  35. . Integrated 8K packet memory
  36. . EEPROM interface for configuration
  37. .
  38. . Arguments:
  39. . io = for the base address
  40. . irq = for the IRQ
  41. .
  42. . author:
  43. . Erik Stahlman ( erik@vt.edu )
  44. . Daris A Nevil ( dnevil@snmc.com )
  45. .
  46. .
  47. . Hardware multicast code from Peter Cammaert ( pc@denkart.be )
  48. .
  49. . Sources:
  50. . o SMSC LAN91C111 databook (www.smsc.com)
  51. . o smc9194.c by Erik Stahlman
  52. . o skeleton.c by Donald Becker ( becker@cesdis.gsfc.nasa.gov )
  53. .
  54. . History:
  55. . 10/17/01 Marco Hasewinkel Modify for DNP/1110
  56. . 07/25/01 Woojung Huh Modify for ADS Bitsy
  57. . 04/25/01 Daris A Nevil Initial public release through SMSC
  58. . 03/16/01 Daris A Nevil Modified smc9194.c for use with LAN91C111
  59. ----------------------------------------------------------------------------*/
  60. #include <common.h>
  61. #include <command.h>
  62. #include "smc91111.h"
  63. #include <net.h>
  64. #ifdef CONFIG_DRIVER_SMC91111
  65. /* Use power-down feature of the chip */
  66. #define POWER_DOWN 0
  67. #define NO_AUTOPROBE
  68. static const char version[] =
  69. "smc91111.c:v1.0 04/25/01 by Daris A Nevil (dnevil@snmc.com)\n";
  70. #define SMC_DEBUG 0
  71. /*------------------------------------------------------------------------
  72. .
  73. . Configuration options, for the experienced user to change.
  74. .
  75. -------------------------------------------------------------------------*/
  76. /*
  77. . Wait time for memory to be free. This probably shouldn't be
  78. . tuned that much, as waiting for this means nothing else happens
  79. . in the system
  80. */
  81. #define MEMORY_WAIT_TIME 16
  82. #if (SMC_DEBUG > 2 )
  83. #define PRINTK3(args...) printf(args)
  84. #else
  85. #define PRINTK3(args...)
  86. #endif
  87. #if SMC_DEBUG > 1
  88. #define PRINTK2(args...) printf(args)
  89. #else
  90. #define PRINTK2(args...)
  91. #endif
  92. #ifdef SMC_DEBUG
  93. #define PRINTK(args...) printf(args)
  94. #else
  95. #define PRINTK(args...)
  96. #endif
  97. /*------------------------------------------------------------------------
  98. .
  99. . The internal workings of the driver. If you are changing anything
  100. . here with the SMC stuff, you should have the datasheet and know
  101. . what you are doing.
  102. .
  103. -------------------------------------------------------------------------*/
  104. #define CARDNAME "LAN91C111"
  105. /* Memory sizing constant */
  106. #define LAN91C111_MEMORY_MULTIPLIER (1024*2)
  107. #ifndef CONFIG_SMC91111_BASE
  108. #define CONFIG_SMC91111_BASE 0x20000300
  109. #endif
  110. #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE
  111. #define SMC_DEV_NAME "SMC91111"
  112. #define SMC_PHY_ADDR 0x0000
  113. #define SMC_ALLOC_MAX_TRY 5
  114. #define SMC_TX_TIMEOUT 30
  115. #define SMC_PHY_CLOCK_DELAY 1000
  116. #define ETH_ZLEN 60
  117. #ifdef CONFIG_SMC_USE_32_BIT
  118. #define USE_32_BIT 1
  119. #else
  120. #undef USE_32_BIT
  121. #endif
  122. /*-----------------------------------------------------------------
  123. .
  124. . The driver can be entered at any of the following entry points.
  125. .
  126. .------------------------------------------------------------------ */
  127. extern int eth_init(bd_t *bd);
  128. extern void eth_halt(void);
  129. extern int eth_rx(void);
  130. extern int eth_send(volatile void *packet, int length);
  131. /*
  132. . This is called by register_netdev(). It is responsible for
  133. . checking the portlist for the SMC9000 series chipset. If it finds
  134. . one, then it will initialize the device, find the hardware information,
  135. . and sets up the appropriate device parameters.
  136. . NOTE: Interrupts are *OFF* when this procedure is called.
  137. .
  138. . NB:This shouldn't be static since it is referred to externally.
  139. */
  140. int smc_init(void);
  141. /*
  142. . This is called by unregister_netdev(). It is responsible for
  143. . cleaning up before the driver is finally unregistered and discarded.
  144. */
  145. void smc_destructor(void);
  146. /*
  147. . The kernel calls this function when someone wants to use the device,
  148. . typically 'ifconfig ethX up'.
  149. */
  150. static int smc_open(void);
  151. /*
  152. . This is called by the kernel in response to 'ifconfig ethX down'. It
  153. . is responsible for cleaning up everything that the open routine
  154. . does, and maybe putting the card into a powerdown state.
  155. */
  156. static int smc_close(void);
  157. /*
  158. . Configures the PHY through the MII Management interface
  159. */
  160. #ifndef CONFIG_SMC91111_EXT_PHY
  161. static void smc_phy_configure(void);
  162. #endif /* !CONFIG_SMC91111_EXT_PHY */
  163. /*
  164. . This is a separate procedure to handle the receipt of a packet, to
  165. . leave the interrupt code looking slightly cleaner
  166. */
  167. static int smc_rcv(void);
  168. /*
  169. ------------------------------------------------------------
  170. .
  171. . Internal routines
  172. .
  173. ------------------------------------------------------------
  174. */
  175. static char smc_mac_addr[] = {0x02, 0x80, 0xad, 0x20, 0x31, 0xb8};
  176. /*
  177. * This function must be called before smc_open() if you want to override
  178. * the default mac address.
  179. */
  180. void smc_set_mac_addr(const char *addr) {
  181. int i;
  182. for (i=0; i < sizeof(smc_mac_addr); i++){
  183. smc_mac_addr[i] = addr[i];
  184. }
  185. }
  186. /*
  187. * smc_get_macaddr is no longer used. If you want to override the default
  188. * mac address, call smc_get_mac_addr as a part of the board initialisation.
  189. */
  190. #if 0
  191. void smc_get_macaddr( byte *addr ) {
  192. /* MAC ADDRESS AT FLASHBLOCK 1 / OFFSET 0x10 */
  193. unsigned char *dnp1110_mac = (unsigned char *) (0xE8000000 + 0x20010);
  194. int i;
  195. for (i=0; i<6; i++) {
  196. addr[0] = *(dnp1110_mac+0);
  197. addr[1] = *(dnp1110_mac+1);
  198. addr[2] = *(dnp1110_mac+2);
  199. addr[3] = *(dnp1110_mac+3);
  200. addr[4] = *(dnp1110_mac+4);
  201. addr[5] = *(dnp1110_mac+5);
  202. }
  203. }
  204. #endif /* 0 */
  205. /***********************************************
  206. * Show available memory *
  207. ***********************************************/
  208. void dump_memory_info(void)
  209. {
  210. word mem_info;
  211. word old_bank;
  212. old_bank = SMC_inw(BANK_SELECT)&0xF;
  213. SMC_SELECT_BANK(0);
  214. mem_info = SMC_inw( MIR_REG );
  215. PRINTK2("Memory: %4d available\n", (mem_info >> 8)*2048);
  216. SMC_SELECT_BANK(old_bank);
  217. }
  218. /*
  219. . A rather simple routine to print out a packet for debugging purposes.
  220. */
  221. #if SMC_DEBUG > 2
  222. static void print_packet( byte *, int );
  223. #endif
  224. #define tx_done(dev) 1
  225. /* this does a soft reset on the device */
  226. static void smc_reset( void );
  227. /* Enable Interrupts, Receive, and Transmit */
  228. static void smc_enable( void );
  229. /* this puts the device in an inactive state */
  230. static void smc_shutdown( void );
  231. /* Routines to Read and Write the PHY Registers across the
  232. MII Management Interface
  233. */
  234. #ifndef CONFIG_SMC91111_EXT_PHY
  235. static word smc_read_phy_register(byte phyreg);
  236. static void smc_write_phy_register(byte phyreg, word phydata);
  237. #endif /* !CONFIG_SMC91111_EXT_PHY */
  238. static int poll4int( byte mask, int timeout ) {
  239. int tmo = get_timer(0) + timeout * CFG_HZ;
  240. int is_timeout = 0;
  241. word old_bank = SMC_inw(BSR_REG);
  242. PRINTK2("Polling...\n");
  243. SMC_SELECT_BANK(2);
  244. while((SMC_inw(SMC91111_INT_REG) & mask) == 0)
  245. {
  246. if (get_timer(0) >= tmo) {
  247. is_timeout = 1;
  248. break;
  249. }
  250. }
  251. /* restore old bank selection */
  252. SMC_SELECT_BANK(old_bank);
  253. if (is_timeout)
  254. return 1;
  255. else
  256. return 0;
  257. }
  258. /*
  259. . Function: smc_reset( void )
  260. . Purpose:
  261. . This sets the SMC91111 chip to its normal state, hopefully from whatever
  262. . mess that any other DOS driver has put it in.
  263. .
  264. . Maybe I should reset more registers to defaults in here? SOFTRST should
  265. . do that for me.
  266. .
  267. . Method:
  268. . 1. send a SOFT RESET
  269. . 2. wait for it to finish
  270. . 3. enable autorelease mode
  271. . 4. reset the memory management unit
  272. . 5. clear all interrupts
  273. .
  274. */
  275. static void smc_reset( void )
  276. {
  277. PRINTK2("%s:smc_reset\n", SMC_DEV_NAME);
  278. /* This resets the registers mostly to defaults, but doesn't
  279. affect EEPROM. That seems unnecessary */
  280. SMC_SELECT_BANK( 0 );
  281. SMC_outw( RCR_SOFTRST, RCR_REG );
  282. /* Setup the Configuration Register */
  283. /* This is necessary because the CONFIG_REG is not affected */
  284. /* by a soft reset */
  285. SMC_SELECT_BANK( 1 );
  286. #if defined(CONFIG_SMC91111_EXT_PHY)
  287. SMC_outw( CONFIG_DEFAULT | CONFIG_EXT_PHY, CONFIG_REG);
  288. #else
  289. SMC_outw( CONFIG_DEFAULT, CONFIG_REG);
  290. #endif
  291. /* Release from possible power-down state */
  292. /* Configuration register is not affected by Soft Reset */
  293. SMC_outw( SMC_inw( CONFIG_REG ) | CONFIG_EPH_POWER_EN, CONFIG_REG );
  294. SMC_SELECT_BANK( 0 );
  295. /* this should pause enough for the chip to be happy */
  296. udelay(10);
  297. /* Disable transmit and receive functionality */
  298. SMC_outw( RCR_CLEAR, RCR_REG );
  299. SMC_outw( TCR_CLEAR, TCR_REG );
  300. /* set the control register */
  301. SMC_SELECT_BANK( 1 );
  302. SMC_outw( CTL_DEFAULT, CTL_REG );
  303. /* Reset the MMU */
  304. SMC_SELECT_BANK( 2 );
  305. SMC_outw( MC_RESET, MMU_CMD_REG );
  306. while ( SMC_inw( MMU_CMD_REG ) & MC_BUSY )
  307. udelay(1); /* Wait until not busy */
  308. /* Note: It doesn't seem that waiting for the MMU busy is needed here,
  309. but this is a place where future chipsets _COULD_ break. Be wary
  310. of issuing another MMU command right after this */
  311. /* Disable all interrupts */
  312. SMC_outb( 0, IM_REG );
  313. }
  314. /*
  315. . Function: smc_enable
  316. . Purpose: let the chip talk to the outside work
  317. . Method:
  318. . 1. Enable the transmitter
  319. . 2. Enable the receiver
  320. . 3. Enable interrupts
  321. */
  322. static void smc_enable()
  323. {
  324. PRINTK2("%s:smc_enable\n", SMC_DEV_NAME);
  325. SMC_SELECT_BANK( 0 );
  326. /* see the header file for options in TCR/RCR DEFAULT*/
  327. SMC_outw( TCR_DEFAULT, TCR_REG );
  328. SMC_outw( RCR_DEFAULT, RCR_REG );
  329. /* clear MII_DIS */
  330. /* smc_write_phy_register(PHY_CNTL_REG, 0x0000); */
  331. }
  332. /*
  333. . Function: smc_shutdown
  334. . Purpose: closes down the SMC91xxx chip.
  335. . Method:
  336. . 1. zero the interrupt mask
  337. . 2. clear the enable receive flag
  338. . 3. clear the enable xmit flags
  339. .
  340. . TODO:
  341. . (1) maybe utilize power down mode.
  342. . Why not yet? Because while the chip will go into power down mode,
  343. . the manual says that it will wake up in response to any I/O requests
  344. . in the register space. Empirical results do not show this working.
  345. */
  346. static void smc_shutdown()
  347. {
  348. PRINTK2(CARDNAME ":smc_shutdown\n");
  349. /* no more interrupts for me */
  350. SMC_SELECT_BANK( 2 );
  351. SMC_outb( 0, IM_REG );
  352. /* and tell the card to stay away from that nasty outside world */
  353. SMC_SELECT_BANK( 0 );
  354. SMC_outb( RCR_CLEAR, RCR_REG );
  355. SMC_outb( TCR_CLEAR, TCR_REG );
  356. }
  357. /*
  358. . Function: smc_hardware_send_packet(struct net_device * )
  359. . Purpose:
  360. . This sends the actual packet to the SMC9xxx chip.
  361. .
  362. . Algorithm:
  363. . First, see if a saved_skb is available.
  364. . ( this should NOT be called if there is no 'saved_skb'
  365. . Now, find the packet number that the chip allocated
  366. . Point the data pointers at it in memory
  367. . Set the length word in the chip's memory
  368. . Dump the packet to chip memory
  369. . Check if a last byte is needed ( odd length packet )
  370. . if so, set the control flag right
  371. . Tell the card to send it
  372. . Enable the transmit interrupt, so I know if it failed
  373. . Free the kernel data if I actually sent it.
  374. */
  375. static int smc_send_packet(volatile void *packet, int packet_length)
  376. {
  377. byte packet_no;
  378. unsigned long ioaddr;
  379. byte * buf;
  380. int length;
  381. int numPages;
  382. int try = 0;
  383. int time_out;
  384. byte status;
  385. PRINTK3("%s:smc_hardware_send_packet\n", SMC_DEV_NAME);
  386. length = ETH_ZLEN < packet_length ? packet_length : ETH_ZLEN;
  387. /* allocate memory
  388. ** The MMU wants the number of pages to be the number of 256 bytes
  389. ** 'pages', minus 1 ( since a packet can't ever have 0 pages :) )
  390. **
  391. ** The 91C111 ignores the size bits, but the code is left intact
  392. ** for backwards and future compatibility.
  393. **
  394. ** Pkt size for allocating is data length +6 (for additional status
  395. ** words, length and ctl!)
  396. **
  397. ** If odd size then last byte is included in this header.
  398. */
  399. numPages = ((length & 0xfffe) + 6);
  400. numPages >>= 8; /* Divide by 256 */
  401. if (numPages > 7 ) {
  402. printf("%s: Far too big packet error. \n", SMC_DEV_NAME);
  403. return 0;
  404. }
  405. /* now, try to allocate the memory */
  406. SMC_SELECT_BANK( 2 );
  407. SMC_outw( MC_ALLOC | numPages, MMU_CMD_REG );
  408. again:
  409. try++;
  410. time_out = MEMORY_WAIT_TIME;
  411. do {
  412. status = SMC_inb( SMC91111_INT_REG );
  413. if ( status & IM_ALLOC_INT ) {
  414. /* acknowledge the interrupt */
  415. SMC_outb( IM_ALLOC_INT, SMC91111_INT_REG );
  416. break;
  417. }
  418. } while ( -- time_out );
  419. if ( !time_out ) {
  420. PRINTK2("%s: memory allocation, try %d failed ...\n",
  421. SMC_DEV_NAME, try);
  422. if (try < SMC_ALLOC_MAX_TRY)
  423. goto again;
  424. else
  425. return 0;
  426. }
  427. PRINTK2("%s: memory allocation, try %d succeeded ...\n",
  428. SMC_DEV_NAME,
  429. try);
  430. /* I can send the packet now.. */
  431. ioaddr = SMC_BASE_ADDRESS;
  432. buf = (byte *)packet;
  433. /* If I get here, I _know_ there is a packet slot waiting for me */
  434. packet_no = SMC_inb( AR_REG );
  435. if ( packet_no & AR_FAILED ) {
  436. /* or isn't there? BAD CHIP! */
  437. printf("%s: Memory allocation failed. \n",
  438. SMC_DEV_NAME);
  439. return 0;
  440. }
  441. /* we have a packet address, so tell the card to use it */
  442. SMC_outb( packet_no, PN_REG );
  443. /* point to the beginning of the packet */
  444. SMC_outw( PTR_AUTOINC , PTR_REG );
  445. PRINTK3("%s: Trying to xmit packet of length %x\n",
  446. SMC_DEV_NAME, length);
  447. #if SMC_DEBUG > 2
  448. printf("Transmitting Packet\n");
  449. print_packet( buf, length );
  450. #endif
  451. /* send the packet length ( +6 for status, length and ctl byte )
  452. and the status word ( set to zeros ) */
  453. #ifdef USE_32_BIT
  454. SMC_outl( (length +6 ) << 16 , SMC91111_DATA_REG );
  455. #else
  456. SMC_outw( 0, SMC91111_DATA_REG );
  457. /* send the packet length ( +6 for status words, length, and ctl*/
  458. SMC_outw( (length+6), SMC91111_DATA_REG );
  459. #endif
  460. /* send the actual data
  461. . I _think_ it's faster to send the longs first, and then
  462. . mop up by sending the last word. It depends heavily
  463. . on alignment, at least on the 486. Maybe it would be
  464. . a good idea to check which is optimal? But that could take
  465. . almost as much time as is saved?
  466. */
  467. #ifdef USE_32_BIT
  468. SMC_outsl(SMC91111_DATA_REG, buf, length >> 2 );
  469. if ( length & 0x2 )
  470. SMC_outw(*((word *)(buf + (length & 0xFFFFFFFC))), SMC91111_DATA_REG);
  471. #else
  472. SMC_outsw(SMC91111_DATA_REG , buf, (length ) >> 1);
  473. #endif /* USE_32_BIT */
  474. /* Send the last byte, if there is one. */
  475. if ( (length & 1) == 0 ) {
  476. SMC_outw( 0, SMC91111_DATA_REG );
  477. } else {
  478. SMC_outw( buf[length -1 ] | 0x2000, SMC91111_DATA_REG );
  479. }
  480. /* and let the chipset deal with it */
  481. SMC_outw( MC_ENQUEUE , MMU_CMD_REG );
  482. /* poll for TX INT */
  483. if (poll4int(IM_TX_INT, SMC_TX_TIMEOUT)) {
  484. /* sending failed */
  485. PRINTK2("%s: TX timeout, sending failed...\n",
  486. SMC_DEV_NAME);
  487. /* release packet */
  488. SMC_outw(MC_FREEPKT, MMU_CMD_REG);
  489. /* wait for MMU getting ready (low) */
  490. while (SMC_inw(MMU_CMD_REG) & MC_BUSY)
  491. {
  492. udelay(10);
  493. }
  494. PRINTK2("MMU ready\n");
  495. return 0;
  496. } else {
  497. /* ack. int */
  498. SMC_outw(IM_TX_INT, SMC91111_INT_REG);
  499. PRINTK2("%s: Sent packet of length %d \n", SMC_DEV_NAME, length);
  500. /* release packet */
  501. SMC_outw(MC_FREEPKT, MMU_CMD_REG);
  502. /* wait for MMU getting ready (low) */
  503. while (SMC_inw(MMU_CMD_REG) & MC_BUSY)
  504. {
  505. udelay(10);
  506. }
  507. PRINTK2("MMU ready\n");
  508. }
  509. return length;
  510. }
  511. /*-------------------------------------------------------------------------
  512. |
  513. | smc_destructor( struct net_device * dev )
  514. | Input parameters:
  515. | dev, pointer to the device structure
  516. |
  517. | Output:
  518. | None.
  519. |
  520. ---------------------------------------------------------------------------
  521. */
  522. void smc_destructor()
  523. {
  524. PRINTK2(CARDNAME ":smc_destructor\n");
  525. }
  526. /*
  527. * Open and Initialize the board
  528. *
  529. * Set up everything, reset the card, etc ..
  530. *
  531. */
  532. static int smc_open()
  533. {
  534. int i; /* used to set hw ethernet address */
  535. PRINTK2("%s:smc_open\n", SMC_DEV_NAME);
  536. /* reset the hardware */
  537. smc_reset();
  538. smc_enable();
  539. /* Configure the PHY */
  540. #ifndef CONFIG_SMC91111_EXT_PHY
  541. smc_phy_configure();
  542. #endif
  543. /* conservative setting (10Mbps, HalfDuplex, no AutoNeg.) */
  544. /* SMC_SELECT_BANK(0); */
  545. /* SMC_outw(0, RPC_REG); */
  546. #ifdef USE_32_BIT
  547. for ( i = 0; i < 6; i += 2 ) {
  548. word address;
  549. address = smc_mac_addr[ i + 1 ] << 8 ;
  550. address |= smc_mac_addr[ i ];
  551. SMC_outw( address, ADDR0_REG + i );
  552. }
  553. #else
  554. for ( i = 0; i < 6; i ++ )
  555. SMC_outb( smc_mac_addr[i], ADDR0_REG + i );
  556. #endif
  557. return 0;
  558. }
  559. #if 0 /* dead code? -- wd */
  560. #ifdef USE_32_BIT
  561. void
  562. insl32(r,b,l)
  563. {
  564. int __i ;
  565. dword *__b2;
  566. __b2 = (dword *) b;
  567. for (__i = 0; __i < l; __i++) {
  568. *(__b2 + __i) = *(dword *)(r+0x10000300);
  569. }
  570. }
  571. #endif
  572. #endif
  573. /*-------------------------------------------------------------
  574. .
  575. . smc_rcv - receive a packet from the card
  576. .
  577. . There is ( at least ) a packet waiting to be read from
  578. . chip-memory.
  579. .
  580. . o Read the status
  581. . o If an error, record it
  582. . o otherwise, read in the packet
  583. --------------------------------------------------------------
  584. */
  585. static int smc_rcv()
  586. {
  587. int packet_number;
  588. word status;
  589. word packet_length;
  590. int is_error = 0;
  591. #ifdef USE_32_BIT
  592. dword stat_len;
  593. #endif
  594. SMC_SELECT_BANK(2);
  595. packet_number = SMC_inw( RXFIFO_REG );
  596. if ( packet_number & RXFIFO_REMPTY ) {
  597. return 0;
  598. }
  599. PRINTK3("%s:smc_rcv\n", SMC_DEV_NAME);
  600. /* start reading from the start of the packet */
  601. SMC_outw( PTR_READ | PTR_RCV | PTR_AUTOINC, PTR_REG );
  602. /* First two words are status and packet_length */
  603. #ifdef USE_32_BIT
  604. stat_len = SMC_inl(SMC91111_DATA_REG);
  605. status = stat_len & 0xffff;
  606. packet_length = stat_len >> 16;
  607. #else
  608. status = SMC_inw( SMC91111_DATA_REG );
  609. packet_length = SMC_inw( SMC91111_DATA_REG );
  610. #endif
  611. packet_length &= 0x07ff; /* mask off top bits */
  612. PRINTK2("RCV: STATUS %4x LENGTH %4x\n", status, packet_length );
  613. if ( !(status & RS_ERRORS ) ){
  614. /* Adjust for having already read the first two words */
  615. packet_length -= 4; /*4; */
  616. /* set odd length for bug in LAN91C111, */
  617. /* which never sets RS_ODDFRAME */
  618. /* TODO ? */
  619. #ifdef USE_32_BIT
  620. PRINTK3(" Reading %d dwords (and %d bytes) \n",
  621. packet_length >> 2, packet_length & 3 );
  622. /* QUESTION: Like in the TX routine, do I want
  623. to send the DWORDs or the bytes first, or some
  624. mixture. A mixture might improve already slow PIO
  625. performance */
  626. SMC_insl( SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 2 );
  627. /* read the left over bytes */
  628. if (packet_length & 3) {
  629. int i;
  630. byte *tail = NetRxPackets[0] + (packet_length & ~3);
  631. dword leftover = SMC_inl(SMC91111_DATA_REG);
  632. for (i=0; i<(packet_length & 3); i++)
  633. *tail++ = (byte) (leftover >> (8*i)) & 0xff;
  634. }
  635. #else
  636. PRINTK3(" Reading %d words and %d byte(s) \n",
  637. (packet_length >> 1 ), packet_length & 1 );
  638. SMC_insw(SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 1);
  639. #endif /* USE_32_BIT */
  640. #if SMC_DEBUG > 2
  641. printf("Receiving Packet\n");
  642. print_packet( NetRxPackets[0], packet_length );
  643. #endif
  644. } else {
  645. /* error ... */
  646. /* TODO ? */
  647. is_error = 1;
  648. }
  649. while ( SMC_inw( MMU_CMD_REG ) & MC_BUSY )
  650. udelay(1); /* Wait until not busy */
  651. /* error or good, tell the card to get rid of this packet */
  652. SMC_outw( MC_RELEASE, MMU_CMD_REG );
  653. while ( SMC_inw( MMU_CMD_REG ) & MC_BUSY )
  654. udelay(1); /* Wait until not busy */
  655. if (!is_error) {
  656. /* Pass the packet up to the protocol layers. */
  657. NetReceive(NetRxPackets[0], packet_length);
  658. return packet_length;
  659. } else {
  660. return 0;
  661. }
  662. }
  663. /*----------------------------------------------------
  664. . smc_close
  665. .
  666. . this makes the board clean up everything that it can
  667. . and not talk to the outside world. Caused by
  668. . an 'ifconfig ethX down'
  669. .
  670. -----------------------------------------------------*/
  671. static int smc_close()
  672. {
  673. PRINTK2("%s:smc_close\n", SMC_DEV_NAME);
  674. /* clear everything */
  675. smc_shutdown();
  676. return 0;
  677. }
  678. #if 0
  679. /*------------------------------------------------------------
  680. . Modify a bit in the LAN91C111 register set
  681. .-------------------------------------------------------------*/
  682. static word smc_modify_regbit(int bank, int ioaddr, int reg,
  683. unsigned int bit, int val)
  684. {
  685. word regval;
  686. SMC_SELECT_BANK( bank );
  687. regval = SMC_inw( reg );
  688. if (val)
  689. regval |= bit;
  690. else
  691. regval &= ~bit;
  692. SMC_outw( regval, 0 );
  693. return(regval);
  694. }
  695. /*------------------------------------------------------------
  696. . Retrieve a bit in the LAN91C111 register set
  697. .-------------------------------------------------------------*/
  698. static int smc_get_regbit(int bank, int ioaddr, int reg, unsigned int bit)
  699. {
  700. SMC_SELECT_BANK( bank );
  701. if ( SMC_inw( reg ) & bit)
  702. return(1);
  703. else
  704. return(0);
  705. }
  706. /*------------------------------------------------------------
  707. . Modify a LAN91C111 register (word access only)
  708. .-------------------------------------------------------------*/
  709. static void smc_modify_reg(int bank, int ioaddr, int reg, word val)
  710. {
  711. SMC_SELECT_BANK( bank );
  712. SMC_outw( val, reg );
  713. }
  714. /*------------------------------------------------------------
  715. . Retrieve a LAN91C111 register (word access only)
  716. .-------------------------------------------------------------*/
  717. static int smc_get_reg(int bank, int ioaddr, int reg)
  718. {
  719. SMC_SELECT_BANK( bank );
  720. return(SMC_inw( reg ));
  721. }
  722. #endif /* 0 */
  723. /*---PHY CONTROL AND CONFIGURATION----------------------------------------- */
  724. #if (SMC_DEBUG > 2 )
  725. /*------------------------------------------------------------
  726. . Debugging function for viewing MII Management serial bitstream
  727. .-------------------------------------------------------------*/
  728. static void smc_dump_mii_stream(byte* bits, int size)
  729. {
  730. int i;
  731. printf("BIT#:");
  732. for (i = 0; i < size; ++i)
  733. {
  734. printf("%d", i%10);
  735. }
  736. printf("\nMDOE:");
  737. for (i = 0; i < size; ++i)
  738. {
  739. if (bits[i] & MII_MDOE)
  740. printf("1");
  741. else
  742. printf("0");
  743. }
  744. printf("\nMDO :");
  745. for (i = 0; i < size; ++i)
  746. {
  747. if (bits[i] & MII_MDO)
  748. printf("1");
  749. else
  750. printf("0");
  751. }
  752. printf("\nMDI :");
  753. for (i = 0; i < size; ++i)
  754. {
  755. if (bits[i] & MII_MDI)
  756. printf("1");
  757. else
  758. printf("0");
  759. }
  760. printf("\n");
  761. }
  762. #endif
  763. /*------------------------------------------------------------
  764. . Reads a register from the MII Management serial interface
  765. .-------------------------------------------------------------*/
  766. #ifndef CONFIG_SMC91111_EXT_PHY
  767. static word smc_read_phy_register(byte phyreg)
  768. {
  769. int oldBank;
  770. int i;
  771. byte mask;
  772. word mii_reg;
  773. byte bits[64];
  774. int clk_idx = 0;
  775. int input_idx;
  776. word phydata;
  777. byte phyaddr = SMC_PHY_ADDR;
  778. /* 32 consecutive ones on MDO to establish sync */
  779. for (i = 0; i < 32; ++i)
  780. bits[clk_idx++] = MII_MDOE | MII_MDO;
  781. /* Start code <01> */
  782. bits[clk_idx++] = MII_MDOE;
  783. bits[clk_idx++] = MII_MDOE | MII_MDO;
  784. /* Read command <10> */
  785. bits[clk_idx++] = MII_MDOE | MII_MDO;
  786. bits[clk_idx++] = MII_MDOE;
  787. /* Output the PHY address, msb first */
  788. mask = (byte)0x10;
  789. for (i = 0; i < 5; ++i)
  790. {
  791. if (phyaddr & mask)
  792. bits[clk_idx++] = MII_MDOE | MII_MDO;
  793. else
  794. bits[clk_idx++] = MII_MDOE;
  795. /* Shift to next lowest bit */
  796. mask >>= 1;
  797. }
  798. /* Output the phy register number, msb first */
  799. mask = (byte)0x10;
  800. for (i = 0; i < 5; ++i)
  801. {
  802. if (phyreg & mask)
  803. bits[clk_idx++] = MII_MDOE | MII_MDO;
  804. else
  805. bits[clk_idx++] = MII_MDOE;
  806. /* Shift to next lowest bit */
  807. mask >>= 1;
  808. }
  809. /* Tristate and turnaround (2 bit times) */
  810. bits[clk_idx++] = 0;
  811. /*bits[clk_idx++] = 0; */
  812. /* Input starts at this bit time */
  813. input_idx = clk_idx;
  814. /* Will input 16 bits */
  815. for (i = 0; i < 16; ++i)
  816. bits[clk_idx++] = 0;
  817. /* Final clock bit */
  818. bits[clk_idx++] = 0;
  819. /* Save the current bank */
  820. oldBank = SMC_inw( BANK_SELECT );
  821. /* Select bank 3 */
  822. SMC_SELECT_BANK( 3 );
  823. /* Get the current MII register value */
  824. mii_reg = SMC_inw( MII_REG );
  825. /* Turn off all MII Interface bits */
  826. mii_reg &= ~(MII_MDOE|MII_MCLK|MII_MDI|MII_MDO);
  827. /* Clock all 64 cycles */
  828. for (i = 0; i < sizeof bits; ++i)
  829. {
  830. /* Clock Low - output data */
  831. SMC_outw( mii_reg | bits[i], MII_REG );
  832. udelay(SMC_PHY_CLOCK_DELAY);
  833. /* Clock Hi - input data */
  834. SMC_outw( mii_reg | bits[i] | MII_MCLK, MII_REG );
  835. udelay(SMC_PHY_CLOCK_DELAY);
  836. bits[i] |= SMC_inw( MII_REG ) & MII_MDI;
  837. }
  838. /* Return to idle state */
  839. /* Set clock to low, data to low, and output tristated */
  840. SMC_outw( mii_reg, MII_REG );
  841. udelay(SMC_PHY_CLOCK_DELAY);
  842. /* Restore original bank select */
  843. SMC_SELECT_BANK( oldBank );
  844. /* Recover input data */
  845. phydata = 0;
  846. for (i = 0; i < 16; ++i)
  847. {
  848. phydata <<= 1;
  849. if (bits[input_idx++] & MII_MDI)
  850. phydata |= 0x0001;
  851. }
  852. #if (SMC_DEBUG > 2 )
  853. printf("smc_read_phy_register(): phyaddr=%x,phyreg=%x,phydata=%x\n",
  854. phyaddr, phyreg, phydata);
  855. smc_dump_mii_stream(bits, sizeof bits);
  856. #endif
  857. return(phydata);
  858. }
  859. /*------------------------------------------------------------
  860. . Writes a register to the MII Management serial interface
  861. .-------------------------------------------------------------*/
  862. static void smc_write_phy_register(byte phyreg, word phydata)
  863. {
  864. int oldBank;
  865. int i;
  866. word mask;
  867. word mii_reg;
  868. byte bits[65];
  869. int clk_idx = 0;
  870. byte phyaddr = SMC_PHY_ADDR;
  871. /* 32 consecutive ones on MDO to establish sync */
  872. for (i = 0; i < 32; ++i)
  873. bits[clk_idx++] = MII_MDOE | MII_MDO;
  874. /* Start code <01> */
  875. bits[clk_idx++] = MII_MDOE;
  876. bits[clk_idx++] = MII_MDOE | MII_MDO;
  877. /* Write command <01> */
  878. bits[clk_idx++] = MII_MDOE;
  879. bits[clk_idx++] = MII_MDOE | MII_MDO;
  880. /* Output the PHY address, msb first */
  881. mask = (byte)0x10;
  882. for (i = 0; i < 5; ++i)
  883. {
  884. if (phyaddr & mask)
  885. bits[clk_idx++] = MII_MDOE | MII_MDO;
  886. else
  887. bits[clk_idx++] = MII_MDOE;
  888. /* Shift to next lowest bit */
  889. mask >>= 1;
  890. }
  891. /* Output the phy register number, msb first */
  892. mask = (byte)0x10;
  893. for (i = 0; i < 5; ++i)
  894. {
  895. if (phyreg & mask)
  896. bits[clk_idx++] = MII_MDOE | MII_MDO;
  897. else
  898. bits[clk_idx++] = MII_MDOE;
  899. /* Shift to next lowest bit */
  900. mask >>= 1;
  901. }
  902. /* Tristate and turnaround (2 bit times) */
  903. bits[clk_idx++] = 0;
  904. bits[clk_idx++] = 0;
  905. /* Write out 16 bits of data, msb first */
  906. mask = 0x8000;
  907. for (i = 0; i < 16; ++i)
  908. {
  909. if (phydata & mask)
  910. bits[clk_idx++] = MII_MDOE | MII_MDO;
  911. else
  912. bits[clk_idx++] = MII_MDOE;
  913. /* Shift to next lowest bit */
  914. mask >>= 1;
  915. }
  916. /* Final clock bit (tristate) */
  917. bits[clk_idx++] = 0;
  918. /* Save the current bank */
  919. oldBank = SMC_inw( BANK_SELECT );
  920. /* Select bank 3 */
  921. SMC_SELECT_BANK( 3 );
  922. /* Get the current MII register value */
  923. mii_reg = SMC_inw( MII_REG );
  924. /* Turn off all MII Interface bits */
  925. mii_reg &= ~(MII_MDOE|MII_MCLK|MII_MDI|MII_MDO);
  926. /* Clock all cycles */
  927. for (i = 0; i < sizeof bits; ++i)
  928. {
  929. /* Clock Low - output data */
  930. SMC_outw( mii_reg | bits[i], MII_REG );
  931. udelay(SMC_PHY_CLOCK_DELAY);
  932. /* Clock Hi - input data */
  933. SMC_outw( mii_reg | bits[i] | MII_MCLK, MII_REG );
  934. udelay(SMC_PHY_CLOCK_DELAY);
  935. bits[i] |= SMC_inw( MII_REG ) & MII_MDI;
  936. }
  937. /* Return to idle state */
  938. /* Set clock to low, data to low, and output tristated */
  939. SMC_outw( mii_reg, MII_REG );
  940. udelay(SMC_PHY_CLOCK_DELAY);
  941. /* Restore original bank select */
  942. SMC_SELECT_BANK( oldBank );
  943. #if (SMC_DEBUG > 2 )
  944. printf("smc_write_phy_register(): phyaddr=%x,phyreg=%x,phydata=%x\n",
  945. phyaddr, phyreg, phydata);
  946. smc_dump_mii_stream(bits, sizeof bits);
  947. #endif
  948. }
  949. #endif /* !CONFIG_SMC91111_EXT_PHY */
  950. /*------------------------------------------------------------
  951. . Waits the specified number of milliseconds - kernel friendly
  952. .-------------------------------------------------------------*/
  953. #ifndef CONFIG_SMC91111_EXT_PHY
  954. static void smc_wait_ms(unsigned int ms)
  955. {
  956. udelay(ms*1000);
  957. }
  958. #endif /* !CONFIG_SMC91111_EXT_PHY */
  959. /*------------------------------------------------------------
  960. . Configures the specified PHY using Autonegotiation. Calls
  961. . smc_phy_fixed() if the user has requested a certain config.
  962. .-------------------------------------------------------------*/
  963. #ifndef CONFIG_SMC91111_EXT_PHY
  964. static void smc_phy_configure()
  965. {
  966. int timeout;
  967. byte phyaddr;
  968. word my_phy_caps; /* My PHY capabilities */
  969. word my_ad_caps; /* My Advertised capabilities */
  970. word status = 0; /*;my status = 0 */
  971. int failed = 0;
  972. PRINTK3("%s:smc_program_phy()\n", SMC_DEV_NAME);
  973. /* Get the detected phy address */
  974. phyaddr = SMC_PHY_ADDR;
  975. /* Reset the PHY, setting all other bits to zero */
  976. smc_write_phy_register(PHY_CNTL_REG, PHY_CNTL_RST);
  977. /* Wait for the reset to complete, or time out */
  978. timeout = 6; /* Wait up to 3 seconds */
  979. while (timeout--)
  980. {
  981. if (!(smc_read_phy_register(PHY_CNTL_REG)
  982. & PHY_CNTL_RST))
  983. {
  984. /* reset complete */
  985. break;
  986. }
  987. smc_wait_ms(500); /* wait 500 millisecs */
  988. }
  989. if (timeout < 1)
  990. {
  991. printf("%s:PHY reset timed out\n", SMC_DEV_NAME);
  992. goto smc_phy_configure_exit;
  993. }
  994. /* Read PHY Register 18, Status Output */
  995. /* lp->lastPhy18 = smc_read_phy_register(PHY_INT_REG); */
  996. /* Enable PHY Interrupts (for register 18) */
  997. /* Interrupts listed here are disabled */
  998. smc_write_phy_register(PHY_INT_REG, 0xffff);
  999. /* Configure the Receive/Phy Control register */
  1000. SMC_SELECT_BANK( 0 );
  1001. SMC_outw( RPC_DEFAULT, RPC_REG );
  1002. /* Copy our capabilities from PHY_STAT_REG to PHY_AD_REG */
  1003. my_phy_caps = smc_read_phy_register(PHY_STAT_REG);
  1004. my_ad_caps = PHY_AD_CSMA; /* I am CSMA capable */
  1005. if (my_phy_caps & PHY_STAT_CAP_T4)
  1006. my_ad_caps |= PHY_AD_T4;
  1007. if (my_phy_caps & PHY_STAT_CAP_TXF)
  1008. my_ad_caps |= PHY_AD_TX_FDX;
  1009. if (my_phy_caps & PHY_STAT_CAP_TXH)
  1010. my_ad_caps |= PHY_AD_TX_HDX;
  1011. if (my_phy_caps & PHY_STAT_CAP_TF)
  1012. my_ad_caps |= PHY_AD_10_FDX;
  1013. if (my_phy_caps & PHY_STAT_CAP_TH)
  1014. my_ad_caps |= PHY_AD_10_HDX;
  1015. /* Update our Auto-Neg Advertisement Register */
  1016. smc_write_phy_register( PHY_AD_REG, my_ad_caps);
  1017. PRINTK2("%s:phy caps=%x\n", SMC_DEV_NAME, my_phy_caps);
  1018. PRINTK2("%s:phy advertised caps=%x\n", SMC_DEV_NAME, my_ad_caps);
  1019. /* Restart auto-negotiation process in order to advertise my caps */
  1020. smc_write_phy_register( PHY_CNTL_REG,
  1021. PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST );
  1022. /* Wait for the auto-negotiation to complete. This may take from */
  1023. /* 2 to 3 seconds. */
  1024. /* Wait for the reset to complete, or time out */
  1025. timeout = 20; /* Wait up to 10 seconds */
  1026. while (timeout--)
  1027. {
  1028. status = smc_read_phy_register( PHY_STAT_REG);
  1029. if (status & PHY_STAT_ANEG_ACK)
  1030. {
  1031. /* auto-negotiate complete */
  1032. break;
  1033. }
  1034. smc_wait_ms(500); /* wait 500 millisecs */
  1035. /* Restart auto-negotiation if remote fault */
  1036. if (status & PHY_STAT_REM_FLT)
  1037. {
  1038. printf("%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1039. /* Restart auto-negotiation */
  1040. printf("%s:PHY restarting auto-negotiation\n",
  1041. SMC_DEV_NAME);
  1042. smc_write_phy_register( PHY_CNTL_REG,
  1043. PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST |
  1044. PHY_CNTL_SPEED | PHY_CNTL_DPLX);
  1045. }
  1046. }
  1047. if (timeout < 1)
  1048. {
  1049. printf("%s:PHY auto-negotiate timed out\n",
  1050. SMC_DEV_NAME);
  1051. printf("%s:PHY auto-negotiate timed out\n", SMC_DEV_NAME);
  1052. failed = 1;
  1053. }
  1054. /* Fail if we detected an auto-negotiate remote fault */
  1055. if (status & PHY_STAT_REM_FLT)
  1056. {
  1057. printf( "%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1058. printf("%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1059. failed = 1;
  1060. }
  1061. /* Re-Configure the Receive/Phy Control register */
  1062. SMC_outw( RPC_DEFAULT, RPC_REG );
  1063. smc_phy_configure_exit:
  1064. }
  1065. #endif /* !CONFIG_SMC91111_EXT_PHY */
  1066. #if SMC_DEBUG > 2
  1067. static void print_packet( byte * buf, int length )
  1068. {
  1069. #if 0
  1070. int i;
  1071. int remainder;
  1072. int lines;
  1073. printf("Packet of length %d \n", length );
  1074. #if SMC_DEBUG > 3
  1075. lines = length / 16;
  1076. remainder = length % 16;
  1077. for ( i = 0; i < lines ; i ++ ) {
  1078. int cur;
  1079. for ( cur = 0; cur < 8; cur ++ ) {
  1080. byte a, b;
  1081. a = *(buf ++ );
  1082. b = *(buf ++ );
  1083. printf("%02x%02x ", a, b );
  1084. }
  1085. printf("\n");
  1086. }
  1087. for ( i = 0; i < remainder/2 ; i++ ) {
  1088. byte a, b;
  1089. a = *(buf ++ );
  1090. b = *(buf ++ );
  1091. printf("%02x%02x ", a, b );
  1092. }
  1093. printf("\n");
  1094. #endif
  1095. #endif
  1096. }
  1097. #endif
  1098. int eth_init(bd_t *bd) {
  1099. smc_open();
  1100. return 0;
  1101. }
  1102. void eth_halt() {
  1103. smc_close();
  1104. }
  1105. int eth_rx() {
  1106. return smc_rcv();
  1107. }
  1108. int eth_send(volatile void *packet, int length) {
  1109. return smc_send_packet(packet, length);
  1110. }
  1111. #endif /* CONFIG_DRIVER_SMC91111 */