smc91111.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390
  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. /* FIXME: the ALLOC_INT bit never gets set *
  409. * so the following will always give a *
  410. * memory allocation error. *
  411. * same code works in armboot though *
  412. * -ro
  413. */
  414. again:
  415. try++;
  416. time_out = MEMORY_WAIT_TIME;
  417. do {
  418. status = SMC_inb( SMC91111_INT_REG );
  419. if ( status & IM_ALLOC_INT ) {
  420. /* acknowledge the interrupt */
  421. SMC_outb( IM_ALLOC_INT, SMC91111_INT_REG );
  422. break;
  423. }
  424. } while ( -- time_out );
  425. if ( !time_out ) {
  426. PRINTK2("%s: memory allocation, try %d failed ...\n",
  427. SMC_DEV_NAME, try);
  428. if (try < SMC_ALLOC_MAX_TRY)
  429. goto again;
  430. else
  431. return 0;
  432. }
  433. PRINTK2("%s: memory allocation, try %d succeeded ...\n",
  434. SMC_DEV_NAME,
  435. try);
  436. /* I can send the packet now.. */
  437. ioaddr = SMC_BASE_ADDRESS;
  438. buf = (byte *)packet;
  439. /* If I get here, I _know_ there is a packet slot waiting for me */
  440. packet_no = SMC_inb( AR_REG );
  441. if ( packet_no & AR_FAILED ) {
  442. /* or isn't there? BAD CHIP! */
  443. printf("%s: Memory allocation failed. \n",
  444. SMC_DEV_NAME);
  445. return 0;
  446. }
  447. /* we have a packet address, so tell the card to use it */
  448. SMC_outb( packet_no, PN_REG );
  449. /* point to the beginning of the packet */
  450. SMC_outw( PTR_AUTOINC , PTR_REG );
  451. PRINTK3("%s: Trying to xmit packet of length %x\n",
  452. SMC_DEV_NAME, length);
  453. #if SMC_DEBUG > 2
  454. printf("Transmitting Packet\n");
  455. print_packet( buf, length );
  456. #endif
  457. /* send the packet length ( +6 for status, length and ctl byte )
  458. and the status word ( set to zeros ) */
  459. #ifdef USE_32_BIT
  460. SMC_outl( (length +6 ) << 16 , SMC91111_DATA_REG );
  461. #else
  462. SMC_outw( 0, SMC91111_DATA_REG );
  463. /* send the packet length ( +6 for status words, length, and ctl*/
  464. SMC_outw( (length+6), SMC91111_DATA_REG );
  465. #endif
  466. /* send the actual data
  467. . I _think_ it's faster to send the longs first, and then
  468. . mop up by sending the last word. It depends heavily
  469. . on alignment, at least on the 486. Maybe it would be
  470. . a good idea to check which is optimal? But that could take
  471. . almost as much time as is saved?
  472. */
  473. #ifdef USE_32_BIT
  474. SMC_outsl(SMC91111_DATA_REG, buf, length >> 2 );
  475. if ( length & 0x2 )
  476. SMC_outw(*((word *)(buf + (length & 0xFFFFFFFC))), SMC91111_DATA_REG);
  477. #else
  478. SMC_outsw(SMC91111_DATA_REG , buf, (length ) >> 1);
  479. #endif /* USE_32_BIT */
  480. /* Send the last byte, if there is one. */
  481. if ( (length & 1) == 0 ) {
  482. SMC_outw( 0, SMC91111_DATA_REG );
  483. } else {
  484. SMC_outw( buf[length -1 ] | 0x2000, SMC91111_DATA_REG );
  485. }
  486. /* and let the chipset deal with it */
  487. SMC_outw( MC_ENQUEUE , MMU_CMD_REG );
  488. /* poll for TX INT */
  489. if (poll4int(IM_TX_INT, SMC_TX_TIMEOUT)) {
  490. /* sending failed */
  491. PRINTK2("%s: TX timeout, sending failed...\n",
  492. SMC_DEV_NAME);
  493. /* release packet */
  494. SMC_outw(MC_FREEPKT, MMU_CMD_REG);
  495. /* wait for MMU getting ready (low) */
  496. while (SMC_inw(MMU_CMD_REG) & MC_BUSY)
  497. {
  498. udelay(10);
  499. }
  500. PRINTK2("MMU ready\n");
  501. return 0;
  502. } else {
  503. /* ack. int */
  504. SMC_outw(IM_TX_INT, SMC91111_INT_REG);
  505. PRINTK2("%s: Sent packet of length %d \n", SMC_DEV_NAME, length);
  506. /* release packet */
  507. SMC_outw(MC_FREEPKT, MMU_CMD_REG);
  508. /* wait for MMU getting ready (low) */
  509. while (SMC_inw(MMU_CMD_REG) & MC_BUSY)
  510. {
  511. udelay(10);
  512. }
  513. PRINTK2("MMU ready\n");
  514. }
  515. return length;
  516. }
  517. /*-------------------------------------------------------------------------
  518. |
  519. | smc_destructor( struct net_device * dev )
  520. | Input parameters:
  521. | dev, pointer to the device structure
  522. |
  523. | Output:
  524. | None.
  525. |
  526. ---------------------------------------------------------------------------
  527. */
  528. void smc_destructor()
  529. {
  530. PRINTK2(CARDNAME ":smc_destructor\n");
  531. }
  532. /*
  533. * Open and Initialize the board
  534. *
  535. * Set up everything, reset the card, etc ..
  536. *
  537. */
  538. static int smc_open()
  539. {
  540. int i; /* used to set hw ethernet address */
  541. PRINTK2("%s:smc_open\n", SMC_DEV_NAME);
  542. /* reset the hardware */
  543. smc_reset();
  544. smc_enable();
  545. /* Configure the PHY */
  546. #ifndef CONFIG_SMC91111_EXT_PHY
  547. smc_phy_configure();
  548. #endif
  549. /* conservative setting (10Mbps, HalfDuplex, no AutoNeg.) */
  550. /* SMC_SELECT_BANK(0); */
  551. /* SMC_outw(0, RPC_REG); */
  552. #ifdef USE_32_BIT
  553. for ( i = 0; i < 6; i += 2 ) {
  554. word address;
  555. address = smc_mac_addr[ i + 1 ] << 8 ;
  556. address |= smc_mac_addr[ i ];
  557. SMC_outw( address, ADDR0_REG + i );
  558. }
  559. #else
  560. for ( i = 0; i < 6; i ++ )
  561. SMC_outb( smc_mac_addr[i], ADDR0_REG + i );
  562. #endif
  563. return 0;
  564. }
  565. #if 0 /* dead code? -- wd */
  566. #ifdef USE_32_BIT
  567. void
  568. insl32(r,b,l)
  569. {
  570. int __i ;
  571. dword *__b2;
  572. __b2 = (dword *) b;
  573. for (__i = 0; __i < l; __i++) {
  574. *(__b2 + __i) = *(dword *)(r+0x10000300);
  575. }
  576. }
  577. #endif
  578. #endif
  579. /*-------------------------------------------------------------
  580. .
  581. . smc_rcv - receive a packet from the card
  582. .
  583. . There is ( at least ) a packet waiting to be read from
  584. . chip-memory.
  585. .
  586. . o Read the status
  587. . o If an error, record it
  588. . o otherwise, read in the packet
  589. --------------------------------------------------------------
  590. */
  591. static int smc_rcv()
  592. {
  593. int packet_number;
  594. word status;
  595. word packet_length;
  596. int is_error = 0;
  597. #ifdef USE_32_BIT
  598. dword stat_len;
  599. #endif
  600. SMC_SELECT_BANK(2);
  601. packet_number = SMC_inw( RXFIFO_REG );
  602. if ( packet_number & RXFIFO_REMPTY ) {
  603. return 0;
  604. }
  605. PRINTK3("%s:smc_rcv\n", SMC_DEV_NAME);
  606. /* start reading from the start of the packet */
  607. SMC_outw( PTR_READ | PTR_RCV | PTR_AUTOINC, PTR_REG );
  608. /* First two words are status and packet_length */
  609. #ifdef USE_32_BIT
  610. stat_len = SMC_inl(SMC91111_DATA_REG);
  611. status = stat_len & 0xffff;
  612. packet_length = stat_len >> 16;
  613. #else
  614. status = SMC_inw( SMC91111_DATA_REG );
  615. packet_length = SMC_inw( SMC91111_DATA_REG );
  616. #endif
  617. packet_length &= 0x07ff; /* mask off top bits */
  618. PRINTK2("RCV: STATUS %4x LENGTH %4x\n", status, packet_length );
  619. if ( !(status & RS_ERRORS ) ){
  620. /* Adjust for having already read the first two words */
  621. packet_length -= 4; /*4; */
  622. /* set odd length for bug in LAN91C111, */
  623. /* which never sets RS_ODDFRAME */
  624. /* TODO ? */
  625. #ifdef USE_32_BIT
  626. PRINTK3(" Reading %d dwords (and %d bytes) \n",
  627. packet_length >> 2, packet_length & 3 );
  628. /* QUESTION: Like in the TX routine, do I want
  629. to send the DWORDs or the bytes first, or some
  630. mixture. A mixture might improve already slow PIO
  631. performance */
  632. SMC_insl( SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 2 );
  633. /* read the left over bytes */
  634. if (packet_length & 3) {
  635. int i;
  636. byte *tail = (byte *)(NetRxPackets[0] + (packet_length & ~3));
  637. dword leftover = SMC_inl(SMC91111_DATA_REG);
  638. for (i=0; i<(packet_length & 3); i++)
  639. *tail++ = (byte) (leftover >> (8*i)) & 0xff;
  640. }
  641. #else
  642. PRINTK3(" Reading %d words and %d byte(s) \n",
  643. (packet_length >> 1 ), packet_length & 1 );
  644. SMC_insw(SMC91111_DATA_REG , NetRxPackets[0], packet_length >> 1);
  645. #endif /* USE_32_BIT */
  646. #if SMC_DEBUG > 2
  647. printf("Receiving Packet\n");
  648. print_packet( NetRxPackets[0], packet_length );
  649. #endif
  650. } else {
  651. /* error ... */
  652. /* TODO ? */
  653. is_error = 1;
  654. }
  655. while ( SMC_inw( MMU_CMD_REG ) & MC_BUSY )
  656. udelay(1); /* Wait until not busy */
  657. /* error or good, tell the card to get rid of this packet */
  658. SMC_outw( MC_RELEASE, MMU_CMD_REG );
  659. while ( SMC_inw( MMU_CMD_REG ) & MC_BUSY )
  660. udelay(1); /* Wait until not busy */
  661. if (!is_error) {
  662. /* Pass the packet up to the protocol layers. */
  663. NetReceive(NetRxPackets[0], packet_length);
  664. return packet_length;
  665. } else {
  666. return 0;
  667. }
  668. }
  669. /*----------------------------------------------------
  670. . smc_close
  671. .
  672. . this makes the board clean up everything that it can
  673. . and not talk to the outside world. Caused by
  674. . an 'ifconfig ethX down'
  675. .
  676. -----------------------------------------------------*/
  677. static int smc_close()
  678. {
  679. PRINTK2("%s:smc_close\n", SMC_DEV_NAME);
  680. /* clear everything */
  681. smc_shutdown();
  682. return 0;
  683. }
  684. #if 0
  685. /*------------------------------------------------------------
  686. . Modify a bit in the LAN91C111 register set
  687. .-------------------------------------------------------------*/
  688. static word smc_modify_regbit(int bank, int ioaddr, int reg,
  689. unsigned int bit, int val)
  690. {
  691. word regval;
  692. SMC_SELECT_BANK( bank );
  693. regval = SMC_inw( reg );
  694. if (val)
  695. regval |= bit;
  696. else
  697. regval &= ~bit;
  698. SMC_outw( regval, 0 );
  699. return(regval);
  700. }
  701. /*------------------------------------------------------------
  702. . Retrieve a bit in the LAN91C111 register set
  703. .-------------------------------------------------------------*/
  704. static int smc_get_regbit(int bank, int ioaddr, int reg, unsigned int bit)
  705. {
  706. SMC_SELECT_BANK( bank );
  707. if ( SMC_inw( reg ) & bit)
  708. return(1);
  709. else
  710. return(0);
  711. }
  712. /*------------------------------------------------------------
  713. . Modify a LAN91C111 register (word access only)
  714. .-------------------------------------------------------------*/
  715. static void smc_modify_reg(int bank, int ioaddr, int reg, word val)
  716. {
  717. SMC_SELECT_BANK( bank );
  718. SMC_outw( val, reg );
  719. }
  720. /*------------------------------------------------------------
  721. . Retrieve a LAN91C111 register (word access only)
  722. .-------------------------------------------------------------*/
  723. static int smc_get_reg(int bank, int ioaddr, int reg)
  724. {
  725. SMC_SELECT_BANK( bank );
  726. return(SMC_inw( reg ));
  727. }
  728. #endif /* 0 */
  729. /*---PHY CONTROL AND CONFIGURATION----------------------------------------- */
  730. #if (SMC_DEBUG > 2 )
  731. /*------------------------------------------------------------
  732. . Debugging function for viewing MII Management serial bitstream
  733. .-------------------------------------------------------------*/
  734. static void smc_dump_mii_stream(byte* bits, int size)
  735. {
  736. int i;
  737. printf("BIT#:");
  738. for (i = 0; i < size; ++i)
  739. {
  740. printf("%d", i%10);
  741. }
  742. printf("\nMDOE:");
  743. for (i = 0; i < size; ++i)
  744. {
  745. if (bits[i] & MII_MDOE)
  746. printf("1");
  747. else
  748. printf("0");
  749. }
  750. printf("\nMDO :");
  751. for (i = 0; i < size; ++i)
  752. {
  753. if (bits[i] & MII_MDO)
  754. printf("1");
  755. else
  756. printf("0");
  757. }
  758. printf("\nMDI :");
  759. for (i = 0; i < size; ++i)
  760. {
  761. if (bits[i] & MII_MDI)
  762. printf("1");
  763. else
  764. printf("0");
  765. }
  766. printf("\n");
  767. }
  768. #endif
  769. /*------------------------------------------------------------
  770. . Reads a register from the MII Management serial interface
  771. .-------------------------------------------------------------*/
  772. #ifndef CONFIG_SMC91111_EXT_PHY
  773. static word smc_read_phy_register(byte phyreg)
  774. {
  775. int oldBank;
  776. int i;
  777. byte mask;
  778. word mii_reg;
  779. byte bits[64];
  780. int clk_idx = 0;
  781. int input_idx;
  782. word phydata;
  783. byte phyaddr = SMC_PHY_ADDR;
  784. /* 32 consecutive ones on MDO to establish sync */
  785. for (i = 0; i < 32; ++i)
  786. bits[clk_idx++] = MII_MDOE | MII_MDO;
  787. /* Start code <01> */
  788. bits[clk_idx++] = MII_MDOE;
  789. bits[clk_idx++] = MII_MDOE | MII_MDO;
  790. /* Read command <10> */
  791. bits[clk_idx++] = MII_MDOE | MII_MDO;
  792. bits[clk_idx++] = MII_MDOE;
  793. /* Output the PHY address, msb first */
  794. mask = (byte)0x10;
  795. for (i = 0; i < 5; ++i)
  796. {
  797. if (phyaddr & mask)
  798. bits[clk_idx++] = MII_MDOE | MII_MDO;
  799. else
  800. bits[clk_idx++] = MII_MDOE;
  801. /* Shift to next lowest bit */
  802. mask >>= 1;
  803. }
  804. /* Output the phy register number, msb first */
  805. mask = (byte)0x10;
  806. for (i = 0; i < 5; ++i)
  807. {
  808. if (phyreg & mask)
  809. bits[clk_idx++] = MII_MDOE | MII_MDO;
  810. else
  811. bits[clk_idx++] = MII_MDOE;
  812. /* Shift to next lowest bit */
  813. mask >>= 1;
  814. }
  815. /* Tristate and turnaround (2 bit times) */
  816. bits[clk_idx++] = 0;
  817. /*bits[clk_idx++] = 0; */
  818. /* Input starts at this bit time */
  819. input_idx = clk_idx;
  820. /* Will input 16 bits */
  821. for (i = 0; i < 16; ++i)
  822. bits[clk_idx++] = 0;
  823. /* Final clock bit */
  824. bits[clk_idx++] = 0;
  825. /* Save the current bank */
  826. oldBank = SMC_inw( BANK_SELECT );
  827. /* Select bank 3 */
  828. SMC_SELECT_BANK( 3 );
  829. /* Get the current MII register value */
  830. mii_reg = SMC_inw( MII_REG );
  831. /* Turn off all MII Interface bits */
  832. mii_reg &= ~(MII_MDOE|MII_MCLK|MII_MDI|MII_MDO);
  833. /* Clock all 64 cycles */
  834. for (i = 0; i < sizeof bits; ++i)
  835. {
  836. /* Clock Low - output data */
  837. SMC_outw( mii_reg | bits[i], MII_REG );
  838. udelay(SMC_PHY_CLOCK_DELAY);
  839. /* Clock Hi - input data */
  840. SMC_outw( mii_reg | bits[i] | MII_MCLK, MII_REG );
  841. udelay(SMC_PHY_CLOCK_DELAY);
  842. bits[i] |= SMC_inw( MII_REG ) & MII_MDI;
  843. }
  844. /* Return to idle state */
  845. /* Set clock to low, data to low, and output tristated */
  846. SMC_outw( mii_reg, MII_REG );
  847. udelay(SMC_PHY_CLOCK_DELAY);
  848. /* Restore original bank select */
  849. SMC_SELECT_BANK( oldBank );
  850. /* Recover input data */
  851. phydata = 0;
  852. for (i = 0; i < 16; ++i)
  853. {
  854. phydata <<= 1;
  855. if (bits[input_idx++] & MII_MDI)
  856. phydata |= 0x0001;
  857. }
  858. #if (SMC_DEBUG > 2 )
  859. printf("smc_read_phy_register(): phyaddr=%x,phyreg=%x,phydata=%x\n",
  860. phyaddr, phyreg, phydata);
  861. smc_dump_mii_stream(bits, sizeof bits);
  862. #endif
  863. return(phydata);
  864. }
  865. /*------------------------------------------------------------
  866. . Writes a register to the MII Management serial interface
  867. .-------------------------------------------------------------*/
  868. static void smc_write_phy_register(byte phyreg, word phydata)
  869. {
  870. int oldBank;
  871. int i;
  872. word mask;
  873. word mii_reg;
  874. byte bits[65];
  875. int clk_idx = 0;
  876. byte phyaddr = SMC_PHY_ADDR;
  877. /* 32 consecutive ones on MDO to establish sync */
  878. for (i = 0; i < 32; ++i)
  879. bits[clk_idx++] = MII_MDOE | MII_MDO;
  880. /* Start code <01> */
  881. bits[clk_idx++] = MII_MDOE;
  882. bits[clk_idx++] = MII_MDOE | MII_MDO;
  883. /* Write command <01> */
  884. bits[clk_idx++] = MII_MDOE;
  885. bits[clk_idx++] = MII_MDOE | MII_MDO;
  886. /* Output the PHY address, msb first */
  887. mask = (byte)0x10;
  888. for (i = 0; i < 5; ++i)
  889. {
  890. if (phyaddr & mask)
  891. bits[clk_idx++] = MII_MDOE | MII_MDO;
  892. else
  893. bits[clk_idx++] = MII_MDOE;
  894. /* Shift to next lowest bit */
  895. mask >>= 1;
  896. }
  897. /* Output the phy register number, msb first */
  898. mask = (byte)0x10;
  899. for (i = 0; i < 5; ++i)
  900. {
  901. if (phyreg & mask)
  902. bits[clk_idx++] = MII_MDOE | MII_MDO;
  903. else
  904. bits[clk_idx++] = MII_MDOE;
  905. /* Shift to next lowest bit */
  906. mask >>= 1;
  907. }
  908. /* Tristate and turnaround (2 bit times) */
  909. bits[clk_idx++] = 0;
  910. bits[clk_idx++] = 0;
  911. /* Write out 16 bits of data, msb first */
  912. mask = 0x8000;
  913. for (i = 0; i < 16; ++i)
  914. {
  915. if (phydata & mask)
  916. bits[clk_idx++] = MII_MDOE | MII_MDO;
  917. else
  918. bits[clk_idx++] = MII_MDOE;
  919. /* Shift to next lowest bit */
  920. mask >>= 1;
  921. }
  922. /* Final clock bit (tristate) */
  923. bits[clk_idx++] = 0;
  924. /* Save the current bank */
  925. oldBank = SMC_inw( BANK_SELECT );
  926. /* Select bank 3 */
  927. SMC_SELECT_BANK( 3 );
  928. /* Get the current MII register value */
  929. mii_reg = SMC_inw( MII_REG );
  930. /* Turn off all MII Interface bits */
  931. mii_reg &= ~(MII_MDOE|MII_MCLK|MII_MDI|MII_MDO);
  932. /* Clock all cycles */
  933. for (i = 0; i < sizeof bits; ++i)
  934. {
  935. /* Clock Low - output data */
  936. SMC_outw( mii_reg | bits[i], MII_REG );
  937. udelay(SMC_PHY_CLOCK_DELAY);
  938. /* Clock Hi - input data */
  939. SMC_outw( mii_reg | bits[i] | MII_MCLK, MII_REG );
  940. udelay(SMC_PHY_CLOCK_DELAY);
  941. bits[i] |= SMC_inw( MII_REG ) & MII_MDI;
  942. }
  943. /* Return to idle state */
  944. /* Set clock to low, data to low, and output tristated */
  945. SMC_outw( mii_reg, MII_REG );
  946. udelay(SMC_PHY_CLOCK_DELAY);
  947. /* Restore original bank select */
  948. SMC_SELECT_BANK( oldBank );
  949. #if (SMC_DEBUG > 2 )
  950. printf("smc_write_phy_register(): phyaddr=%x,phyreg=%x,phydata=%x\n",
  951. phyaddr, phyreg, phydata);
  952. smc_dump_mii_stream(bits, sizeof bits);
  953. #endif
  954. }
  955. #endif /* !CONFIG_SMC91111_EXT_PHY */
  956. /*------------------------------------------------------------
  957. . Waits the specified number of milliseconds - kernel friendly
  958. .-------------------------------------------------------------*/
  959. #ifndef CONFIG_SMC91111_EXT_PHY
  960. static void smc_wait_ms(unsigned int ms)
  961. {
  962. udelay(ms*1000);
  963. }
  964. #endif /* !CONFIG_SMC91111_EXT_PHY */
  965. /*------------------------------------------------------------
  966. . Configures the specified PHY using Autonegotiation. Calls
  967. . smc_phy_fixed() if the user has requested a certain config.
  968. .-------------------------------------------------------------*/
  969. #ifndef CONFIG_SMC91111_EXT_PHY
  970. static void smc_phy_configure()
  971. {
  972. int timeout;
  973. byte phyaddr;
  974. word my_phy_caps; /* My PHY capabilities */
  975. word my_ad_caps; /* My Advertised capabilities */
  976. word status = 0; /*;my status = 0 */
  977. int failed = 0;
  978. PRINTK3("%s:smc_program_phy()\n", SMC_DEV_NAME);
  979. /* Get the detected phy address */
  980. phyaddr = SMC_PHY_ADDR;
  981. /* Reset the PHY, setting all other bits to zero */
  982. smc_write_phy_register(PHY_CNTL_REG, PHY_CNTL_RST);
  983. /* Wait for the reset to complete, or time out */
  984. timeout = 6; /* Wait up to 3 seconds */
  985. while (timeout--)
  986. {
  987. if (!(smc_read_phy_register(PHY_CNTL_REG)
  988. & PHY_CNTL_RST))
  989. {
  990. /* reset complete */
  991. break;
  992. }
  993. smc_wait_ms(500); /* wait 500 millisecs */
  994. }
  995. if (timeout < 1)
  996. {
  997. printf("%s:PHY reset timed out\n", SMC_DEV_NAME);
  998. goto smc_phy_configure_exit;
  999. }
  1000. /* Read PHY Register 18, Status Output */
  1001. /* lp->lastPhy18 = smc_read_phy_register(PHY_INT_REG); */
  1002. /* Enable PHY Interrupts (for register 18) */
  1003. /* Interrupts listed here are disabled */
  1004. smc_write_phy_register(PHY_INT_REG, 0xffff);
  1005. /* Configure the Receive/Phy Control register */
  1006. SMC_SELECT_BANK( 0 );
  1007. SMC_outw( RPC_DEFAULT, RPC_REG );
  1008. /* Copy our capabilities from PHY_STAT_REG to PHY_AD_REG */
  1009. my_phy_caps = smc_read_phy_register(PHY_STAT_REG);
  1010. my_ad_caps = PHY_AD_CSMA; /* I am CSMA capable */
  1011. if (my_phy_caps & PHY_STAT_CAP_T4)
  1012. my_ad_caps |= PHY_AD_T4;
  1013. if (my_phy_caps & PHY_STAT_CAP_TXF)
  1014. my_ad_caps |= PHY_AD_TX_FDX;
  1015. if (my_phy_caps & PHY_STAT_CAP_TXH)
  1016. my_ad_caps |= PHY_AD_TX_HDX;
  1017. if (my_phy_caps & PHY_STAT_CAP_TF)
  1018. my_ad_caps |= PHY_AD_10_FDX;
  1019. if (my_phy_caps & PHY_STAT_CAP_TH)
  1020. my_ad_caps |= PHY_AD_10_HDX;
  1021. /* Update our Auto-Neg Advertisement Register */
  1022. smc_write_phy_register( PHY_AD_REG, my_ad_caps);
  1023. PRINTK2("%s:phy caps=%x\n", SMC_DEV_NAME, my_phy_caps);
  1024. PRINTK2("%s:phy advertised caps=%x\n", SMC_DEV_NAME, my_ad_caps);
  1025. /* Restart auto-negotiation process in order to advertise my caps */
  1026. smc_write_phy_register( PHY_CNTL_REG,
  1027. PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST );
  1028. /* Wait for the auto-negotiation to complete. This may take from */
  1029. /* 2 to 3 seconds. */
  1030. /* Wait for the reset to complete, or time out */
  1031. timeout = 20; /* Wait up to 10 seconds */
  1032. while (timeout--)
  1033. {
  1034. status = smc_read_phy_register( PHY_STAT_REG);
  1035. if (status & PHY_STAT_ANEG_ACK)
  1036. {
  1037. /* auto-negotiate complete */
  1038. break;
  1039. }
  1040. smc_wait_ms(500); /* wait 500 millisecs */
  1041. /* Restart auto-negotiation if remote fault */
  1042. if (status & PHY_STAT_REM_FLT)
  1043. {
  1044. printf("%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1045. /* Restart auto-negotiation */
  1046. printf("%s:PHY restarting auto-negotiation\n",
  1047. SMC_DEV_NAME);
  1048. smc_write_phy_register( PHY_CNTL_REG,
  1049. PHY_CNTL_ANEG_EN | PHY_CNTL_ANEG_RST |
  1050. PHY_CNTL_SPEED | PHY_CNTL_DPLX);
  1051. }
  1052. }
  1053. if (timeout < 1)
  1054. {
  1055. printf("%s:PHY auto-negotiate timed out\n",
  1056. SMC_DEV_NAME);
  1057. printf("%s:PHY auto-negotiate timed out\n", SMC_DEV_NAME);
  1058. failed = 1;
  1059. }
  1060. /* Fail if we detected an auto-negotiate remote fault */
  1061. if (status & PHY_STAT_REM_FLT)
  1062. {
  1063. printf( "%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1064. printf("%s:PHY remote fault detected\n", SMC_DEV_NAME);
  1065. failed = 1;
  1066. }
  1067. /* Re-Configure the Receive/Phy Control register */
  1068. SMC_outw( RPC_DEFAULT, RPC_REG );
  1069. smc_phy_configure_exit:
  1070. }
  1071. #endif /* !CONFIG_SMC91111_EXT_PHY */
  1072. #if SMC_DEBUG > 2
  1073. static void print_packet( byte * buf, int length )
  1074. {
  1075. #if 0
  1076. int i;
  1077. int remainder;
  1078. int lines;
  1079. printf("Packet of length %d \n", length );
  1080. #if SMC_DEBUG > 3
  1081. lines = length / 16;
  1082. remainder = length % 16;
  1083. for ( i = 0; i < lines ; i ++ ) {
  1084. int cur;
  1085. for ( cur = 0; cur < 8; cur ++ ) {
  1086. byte a, b;
  1087. a = *(buf ++ );
  1088. b = *(buf ++ );
  1089. printf("%02x%02x ", a, b );
  1090. }
  1091. printf("\n");
  1092. }
  1093. for ( i = 0; i < remainder/2 ; i++ ) {
  1094. byte a, b;
  1095. a = *(buf ++ );
  1096. b = *(buf ++ );
  1097. printf("%02x%02x ", a, b );
  1098. }
  1099. printf("\n");
  1100. #endif
  1101. #endif
  1102. }
  1103. #endif
  1104. int eth_init(bd_t *bd) {
  1105. smc_open();
  1106. return 0;
  1107. }
  1108. void eth_halt() {
  1109. smc_close();
  1110. }
  1111. int eth_rx() {
  1112. return smc_rcv();
  1113. }
  1114. int eth_send(volatile void *packet, int length) {
  1115. return smc_send_packet(packet, length);
  1116. }
  1117. #endif /* CONFIG_DRIVER_SMC91111 */