You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sis900.c 35KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. /* -*- Mode:C; c-basic-offset:4; -*- */
  2. /*
  3. sis900.c: An SiS 900/7016 PCI Fast Ethernet driver for Etherboot
  4. Copyright (C) 2001 Entity Cyber, Inc.
  5. Revision: 1.0 March 1, 2001
  6. Author: Marty Connor (mdc@etherboot.org)
  7. Adapted from a Linux driver which was written by Donald Becker
  8. and modified by Ollie Lho and Chin-Shan Li of SiS Corporation.
  9. Rewritten for Etherboot by Marty Connor.
  10. This software may be used and distributed according to the terms
  11. of the GNU Public License (GPL), incorporated herein by reference.
  12. References:
  13. SiS 7016 Fast Ethernet PCI Bus 10/100 Mbps LAN Controller with OnNow Support,
  14. preliminary Rev. 1.0 Jan. 14, 1998
  15. SiS 900 Fast Ethernet PCI Bus 10/100 Mbps LAN Single Chip with OnNow Support,
  16. preliminary Rev. 1.0 Nov. 10, 1998
  17. SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
  18. preliminary Rev. 1.0 Jan. 18, 1998
  19. http://www.sis.com.tw/support/databook.htm */
  20. /* Revision History */
  21. /*
  22. 07 Dec 2003 timlegge - Enabled Multicast Support
  23. 06 Dec 2003 timlegge - Fixed relocation issue in 5.2
  24. 04 Jan 2002 Chien-Yu Chen, Doug Ambrisko, Marty Connor Patch to Etherboot 5.0.5
  25. Added support for the SiS 630ET plus various bug fixes from linux kernel
  26. source 2.4.17.
  27. 01 March 2001 mdc 1.0
  28. Initial Release. Tested with PCI based sis900 card and ThinkNIC
  29. computer.
  30. 20 March 2001 P.Koegel
  31. added support for sis630e and PHY ICS1893 and RTL8201
  32. Testet with SIS730S chipset + ICS1893
  33. */
  34. /* Includes */
  35. #include "etherboot.h"
  36. #include <gpxe/pci.h>
  37. #include "nic.h"
  38. #include "timer.h"
  39. #include "sis900.h"
  40. /* Globals */
  41. static struct nic_operations sis900_operations;
  42. static int sis900_debug = 0;
  43. static unsigned short vendor, dev_id;
  44. static unsigned long ioaddr;
  45. static u8 pci_revision;
  46. static unsigned int cur_phy;
  47. static unsigned int cur_rx;
  48. struct {
  49. BufferDesc txd;
  50. BufferDesc rxd[NUM_RX_DESC];
  51. unsigned char txb[TX_BUF_SIZE];
  52. unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE];
  53. } sis900_bufs __shared;
  54. #define txd sis900_bufs.txd
  55. #define rxd sis900_bufs.rxd
  56. #define txb sis900_bufs.txb
  57. #define rxb sis900_bufs.rxb
  58. #if 0
  59. static struct mac_chip_info {
  60. const char *name;
  61. u16 vendor_id, device_id, flags;
  62. int io_size;
  63. } mac_chip_table[] = {
  64. { "SiS 900 PCI Fast Ethernet", PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS900,
  65. PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE},
  66. { "SiS 7016 PCI Fast Ethernet",PCI_VENDOR_ID_SIS, PCI_DEVICE_ID_SIS7016,
  67. PCI_COMMAND_IO|PCI_COMMAND_MASTER, SIS900_TOTAL_SIZE},
  68. {0,0,0,0,0} /* 0 terminated list. */
  69. };
  70. #endif
  71. static void sis900_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  72. static void amd79c901_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  73. static void ics1893_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  74. static void rtl8201_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  75. static void vt6103_read_mode(struct nic *nic, int phy_addr, int *speed, int *duplex);
  76. static struct mii_chip_info {
  77. const char * name;
  78. u16 phy_id0;
  79. u16 phy_id1;
  80. void (*read_mode) (struct nic *nic, int phy_addr, int *speed, int *duplex);
  81. } mii_chip_table[] = {
  82. {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode},
  83. {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode},
  84. {"SiS 900 on Foxconn 661 7MI", 0x0143, 0xBC70, sis900_read_mode},
  85. {"AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, amd79c901_read_mode},
  86. {"AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, amd79c901_read_mode},
  87. {"ICS 1893 Integrated PHYceiver" , 0x0015, 0xf440,ics1893_read_mode},
  88. // {"NS 83851 PHY",0x2000, 0x5C20, MIX },
  89. {"RTL 8201 10/100Mbps Phyceiver" , 0x0000, 0x8200,rtl8201_read_mode},
  90. {"VIA 6103 10/100Mbps Phyceiver", 0x0101, 0x8f20,vt6103_read_mode},
  91. {0,0,0,0}
  92. };
  93. static struct mii_phy {
  94. struct mii_phy * next;
  95. struct mii_chip_info * chip_info;
  96. int phy_addr;
  97. u16 status;
  98. } mii;
  99. #if 0
  100. // PCI to ISA bridge for SIS640E access
  101. static struct pci_device_id pci_isa_bridge_list[] = {
  102. { .vendor = 0x1039, .device = 0x0008,
  103. .name = "SIS 85C503/5513 PCI to ISA bridge"},
  104. };
  105. PCI_DRIVER( sis_bridge_pci_driver, pci_isa_bridge_list, PCI_NO_CLASS );
  106. static struct device_driver sis_bridge_driver = {
  107. .name = "SIS ISA bridge",
  108. .bus_driver = &pci_driver,
  109. .bus_driver_info = ( struct bus_driver_info * ) &sis_bridge_pci_driver,
  110. };
  111. #endif
  112. /* Function Prototypes */
  113. static int sis900_probe(struct nic *nic,struct pci_device *pci);
  114. static u16 sis900_read_eeprom(int location);
  115. static void sis900_mdio_reset(long mdio_addr);
  116. static void sis900_mdio_idle(long mdio_addr);
  117. static u16 sis900_mdio_read(int phy_id, int location);
  118. #if 0
  119. static void sis900_mdio_write(int phy_id, int location, int val);
  120. #endif
  121. static void sis900_init(struct nic *nic);
  122. static void sis900_reset(struct nic *nic);
  123. static void sis900_init_rxfilter(struct nic *nic);
  124. static void sis900_init_txd(struct nic *nic);
  125. static void sis900_init_rxd(struct nic *nic);
  126. static void sis900_set_rx_mode(struct nic *nic);
  127. static void sis900_check_mode(struct nic *nic);
  128. static void sis900_transmit(struct nic *nic, const char *d,
  129. unsigned int t, unsigned int s, const char *p);
  130. static int sis900_poll(struct nic *nic, int retrieve);
  131. static void sis900_disable(struct nic *nic);
  132. static void sis900_irq(struct nic *nic, irq_action_t action);
  133. /**
  134. * sis900_get_mac_addr: - Get MAC address for stand alone SiS900 model
  135. * @pci_dev: the sis900 pci device
  136. * @net_dev: the net device to get address for
  137. *
  138. * Older SiS900 and friends, use EEPROM to store MAC address.
  139. * MAC address is read from read_eeprom() into @net_dev->dev_addr.
  140. */
  141. static int sis900_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  142. {
  143. u16 signature;
  144. int i;
  145. /* check to see if we have sane EEPROM */
  146. signature = (u16) sis900_read_eeprom( EEPROMSignature);
  147. if (signature == 0xffff || signature == 0x0000) {
  148. printf ("sis900_probe: Error EERPOM read %hX\n", signature);
  149. return 0;
  150. }
  151. /* get MAC address from EEPROM */
  152. for (i = 0; i < 3; i++)
  153. ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr);
  154. return 1;
  155. }
  156. /**
  157. * sis96x_get_mac_addr: - Get MAC address for SiS962 or SiS963 model
  158. * @pci_dev: the sis900 pci device
  159. * @net_dev: the net device to get address for
  160. *
  161. * SiS962 or SiS963 model, use EEPROM to store MAC address. And EEPROM
  162. * is shared by
  163. * LAN and 1394. When access EEPROM, send EEREQ signal to hardware first
  164. * and wait for EEGNT. If EEGNT is ON, EEPROM is permitted to be access
  165. * by LAN, otherwise is not. After MAC address is read from EEPROM, send
  166. * EEDONE signal to refuse EEPROM access by LAN.
  167. * The EEPROM map of SiS962 or SiS963 is different to SiS900.
  168. * The signature field in SiS962 or SiS963 spec is meaningless.
  169. * MAC address is read into @net_dev->dev_addr.
  170. */
  171. static int sis96x_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  172. {
  173. /* long ioaddr = net_dev->base_addr; */
  174. long ee_addr = ioaddr + mear;
  175. u32 waittime = 0;
  176. int i;
  177. printf("Alternate function\n");
  178. outl(EEREQ, ee_addr);
  179. while(waittime < 2000) {
  180. if(inl(ee_addr) & EEGNT) {
  181. /* get MAC address from EEPROM */
  182. for (i = 0; i < 3; i++)
  183. ((u16 *)(nic->node_addr))[i] = sis900_read_eeprom(i+EEPROMMACAddr);
  184. outl(EEDONE, ee_addr);
  185. return 1;
  186. } else {
  187. udelay(1);
  188. waittime ++;
  189. }
  190. }
  191. outl(EEDONE, ee_addr);
  192. return 0;
  193. }
  194. /**
  195. * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  196. * @pci_dev: the sis900 pci device
  197. * @net_dev: the net device to get address for
  198. *
  199. * SiS630E model, use APC CMOS RAM to store MAC address.
  200. * APC CMOS RAM is accessed through ISA bridge.
  201. * MAC address is read into @net_dev->dev_addr.
  202. */
  203. static int sis630e_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  204. {
  205. #if 0
  206. u8 reg;
  207. int i;
  208. struct bus_loc bus_loc;
  209. union {
  210. struct bus_dev bus_dev;
  211. struct pci_device isa_bridge;
  212. } u;
  213. /* find PCI to ISA bridge */
  214. memset(&bus_loc, 0, sizeof(bus_loc));
  215. if ( ! find_by_driver ( &bus_loc, &u.bus_dev, &sis_bridge_driver, 0 ) )
  216. return 0;
  217. pci_read_config_byte(&u.isa_bridge, 0x48, &reg);
  218. pci_write_config_byte(&u.isa_bridge, 0x48, reg | 0x40);
  219. for (i = 0; i < ETH_ALEN; i++)
  220. {
  221. outb(0x09 + i, 0x70);
  222. ((u8 *)(nic->node_addr))[i] = inb(0x71);
  223. }
  224. pci_write_config_byte(&u.isa_bridge, 0x48, reg & ~0x40);
  225. return 1;
  226. #endif
  227. /* Does not work with current bus/device model */
  228. memset ( nic->node_addr, 0, sizeof ( nic->node_addr ) );
  229. return 0;
  230. }
  231. /**
  232. * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  233. * @pci_dev: the sis900 pci device
  234. * @net_dev: the net device to get address for
  235. *
  236. * SiS630E model, use APC CMOS RAM to store MAC address.
  237. * APC CMOS RAM is accessed through ISA bridge.
  238. * MAC address is read into @net_dev->dev_addr.
  239. */
  240. static int sis635_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  241. {
  242. u32 rfcrSave;
  243. u32 i;
  244. rfcrSave = inl(rfcr + ioaddr);
  245. outl(rfcrSave | RELOAD, ioaddr + cr);
  246. outl(0, ioaddr + cr);
  247. /* disable packet filtering before setting filter */
  248. outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  249. /* load MAC addr to filter data register */
  250. for (i = 0 ; i < 3 ; i++) {
  251. outl((i << RFADDR_shift), ioaddr + rfcr);
  252. *( ((u16 *)nic->node_addr) + i) = inw(ioaddr + rfdr);
  253. }
  254. /* enable packet filitering */
  255. outl(rfcrSave | RFEN, rfcr + ioaddr);
  256. return 1;
  257. }
  258. /*
  259. * Function: sis900_probe
  260. *
  261. * Description: initializes initializes the NIC, retrieves the
  262. * MAC address of the card, and sets up some globals required by
  263. * other routines.
  264. *
  265. * Side effects:
  266. * leaves the ioaddress of the sis900 chip in the variable ioaddr.
  267. * leaves the sis900 initialized, and ready to recieve packets.
  268. *
  269. * Returns: struct nic *: pointer to NIC data structure
  270. */
  271. static int sis900_probe ( struct nic *nic, struct pci_device *pci ) {
  272. int i;
  273. int found=0;
  274. int phy_addr;
  275. u8 revision;
  276. int ret;
  277. if (pci->ioaddr == 0)
  278. return 0;
  279. nic->irqno = 0;
  280. nic->ioaddr = pci->ioaddr;
  281. ioaddr = pci->ioaddr;
  282. vendor = pci->vendor;
  283. dev_id = pci->device;
  284. /* wakeup chip */
  285. pci_write_config_dword(pci, 0x40, 0x00000000);
  286. adjust_pci_device(pci);
  287. /* get MAC address */
  288. ret = 0;
  289. pci_read_config_byte(pci, PCI_REVISION, &revision);
  290. /* save for use later in sis900_reset() */
  291. pci_revision = revision;
  292. if (revision == SIS630E_900_REV)
  293. ret = sis630e_get_mac_addr(pci, nic);
  294. else if ((revision > 0x81) && (revision <= 0x90))
  295. ret = sis635_get_mac_addr(pci, nic);
  296. else if (revision == SIS96x_900_REV)
  297. ret = sis96x_get_mac_addr(pci, nic);
  298. else
  299. ret = sis900_get_mac_addr(pci, nic);
  300. if (ret == 0)
  301. {
  302. printf ("sis900_probe: Error MAC address not found\n");
  303. return 0;
  304. }
  305. /* 630ET : set the mii access mode as software-mode */
  306. if (revision == SIS630ET_900_REV)
  307. outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr);
  308. DBG( "sis900_probe: Vendor:%#hX Device:%#hX\n", vendor, dev_id );
  309. /* probe for mii transceiver */
  310. /* search for total of 32 possible mii phy addresses */
  311. found = 0;
  312. for (phy_addr = 0; phy_addr < 32; phy_addr++) {
  313. u16 mii_status;
  314. u16 phy_id0, phy_id1;
  315. mii_status = sis900_mdio_read(phy_addr, MII_STATUS);
  316. if (mii_status == 0xffff || mii_status == 0x0000)
  317. /* the mii is not accessable, try next one */
  318. continue;
  319. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  320. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  321. /* search our mii table for the current mii */
  322. for (i = 0; mii_chip_table[i].phy_id1; i++) {
  323. if ((phy_id0 == mii_chip_table[i].phy_id0) &&
  324. ((phy_id1 & 0xFFF0) == mii_chip_table[i].phy_id1)){
  325. printf("sis900_probe: %s transceiver found at address %d.\n",
  326. mii_chip_table[i].name, phy_addr);
  327. mii.chip_info = &mii_chip_table[i];
  328. mii.phy_addr = phy_addr;
  329. mii.status = sis900_mdio_read(phy_addr, MII_STATUS);
  330. mii.next = NULL;
  331. found=1;
  332. break;
  333. }
  334. }
  335. }
  336. if (found == 0) {
  337. printf("sis900_probe: No MII transceivers found!\n");
  338. return 0;
  339. }
  340. /* Arbitrarily select the last PHY found as current PHY */
  341. cur_phy = mii.phy_addr;
  342. printf("sis900_probe: Using %s as default\n", mii.chip_info->name);
  343. /* initialize device */
  344. sis900_init(nic);
  345. nic->nic_op = &sis900_operations;
  346. return 1;
  347. }
  348. /*
  349. * EEPROM Routines: These functions read and write to EEPROM for
  350. * retrieving the MAC address and other configuration information about
  351. * the card.
  352. */
  353. /* Delay between EEPROM clock transitions. */
  354. #define eeprom_delay() inl(ee_addr)
  355. /* Function: sis900_read_eeprom
  356. *
  357. * Description: reads and returns a given location from EEPROM
  358. *
  359. * Arguments: int location: requested EEPROM location
  360. *
  361. * Returns: u16: contents of requested EEPROM location
  362. *
  363. */
  364. /* Read Serial EEPROM through EEPROM Access Register, Note that location is
  365. in word (16 bits) unit */
  366. static u16 sis900_read_eeprom(int location)
  367. {
  368. int i;
  369. u16 retval = 0;
  370. long ee_addr = ioaddr + mear;
  371. u32 read_cmd = location | EEread;
  372. outl(0, ee_addr);
  373. eeprom_delay();
  374. outl(EECS, ee_addr);
  375. eeprom_delay();
  376. /* Shift the read command (9) bits out. */
  377. for (i = 8; i >= 0; i--) {
  378. u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS;
  379. outl(dataval, ee_addr);
  380. eeprom_delay();
  381. outl(dataval | EECLK, ee_addr);
  382. eeprom_delay();
  383. }
  384. outl(EECS, ee_addr);
  385. eeprom_delay();
  386. /* read the 16-bits data in */
  387. for (i = 16; i > 0; i--) {
  388. outl(EECS, ee_addr);
  389. eeprom_delay();
  390. outl(EECS | EECLK, ee_addr);
  391. eeprom_delay();
  392. retval = (retval << 1) | ((inl(ee_addr) & EEDO) ? 1 : 0);
  393. eeprom_delay();
  394. }
  395. /* Terminate the EEPROM access. */
  396. outl(0, ee_addr);
  397. eeprom_delay();
  398. // outl(EECLK, ee_addr);
  399. return (retval);
  400. }
  401. #define sis900_mdio_delay() inl(mdio_addr)
  402. /*
  403. Read and write the MII management registers using software-generated
  404. serial MDIO protocol. Note that the command bits and data bits are
  405. send out seperately
  406. */
  407. static void sis900_mdio_idle(long mdio_addr)
  408. {
  409. outl(MDIO | MDDIR, mdio_addr);
  410. sis900_mdio_delay();
  411. outl(MDIO | MDDIR | MDC, mdio_addr);
  412. }
  413. /* Syncronize the MII management interface by shifting 32 one bits out. */
  414. static void sis900_mdio_reset(long mdio_addr)
  415. {
  416. int i;
  417. for (i = 31; i >= 0; i--) {
  418. outl(MDDIR | MDIO, mdio_addr);
  419. sis900_mdio_delay();
  420. outl(MDDIR | MDIO | MDC, mdio_addr);
  421. sis900_mdio_delay();
  422. }
  423. return;
  424. }
  425. static u16 sis900_mdio_read(int phy_id, int location)
  426. {
  427. long mdio_addr = ioaddr + mear;
  428. int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
  429. u16 retval = 0;
  430. int i;
  431. sis900_mdio_reset(mdio_addr);
  432. sis900_mdio_idle(mdio_addr);
  433. for (i = 15; i >= 0; i--) {
  434. int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
  435. outl(dataval, mdio_addr);
  436. sis900_mdio_delay();
  437. outl(dataval | MDC, mdio_addr);
  438. sis900_mdio_delay();
  439. }
  440. /* Read the 16 data bits. */
  441. for (i = 16; i > 0; i--) {
  442. outl(0, mdio_addr);
  443. sis900_mdio_delay();
  444. retval = (retval << 1) | ((inl(mdio_addr) & MDIO) ? 1 : 0);
  445. outl(MDC, mdio_addr);
  446. sis900_mdio_delay();
  447. }
  448. outl(0x00, mdio_addr);
  449. return retval;
  450. }
  451. #if 0
  452. static void sis900_mdio_write(int phy_id, int location, int value)
  453. {
  454. long mdio_addr = ioaddr + mear;
  455. int mii_cmd = MIIwrite|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
  456. int i;
  457. sis900_mdio_reset(mdio_addr);
  458. sis900_mdio_idle(mdio_addr);
  459. /* Shift the command bits out. */
  460. for (i = 15; i >= 0; i--) {
  461. int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
  462. outb(dataval, mdio_addr);
  463. sis900_mdio_delay();
  464. outb(dataval | MDC, mdio_addr);
  465. sis900_mdio_delay();
  466. }
  467. sis900_mdio_delay();
  468. /* Shift the value bits out. */
  469. for (i = 15; i >= 0; i--) {
  470. int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR;
  471. outl(dataval, mdio_addr);
  472. sis900_mdio_delay();
  473. outl(dataval | MDC, mdio_addr);
  474. sis900_mdio_delay();
  475. }
  476. sis900_mdio_delay();
  477. /* Clear out extra bits. */
  478. for (i = 2; i > 0; i--) {
  479. outb(0, mdio_addr);
  480. sis900_mdio_delay();
  481. outb(MDC, mdio_addr);
  482. sis900_mdio_delay();
  483. }
  484. outl(0x00, mdio_addr);
  485. return;
  486. }
  487. #endif
  488. /* Function: sis900_init
  489. *
  490. * Description: resets the ethernet controller chip and various
  491. * data structures required for sending and receiving packets.
  492. *
  493. * Arguments: struct nic *nic: NIC data structure
  494. *
  495. * returns: void.
  496. */
  497. static void
  498. sis900_init(struct nic *nic)
  499. {
  500. /* Soft reset the chip. */
  501. sis900_reset(nic);
  502. sis900_init_rxfilter(nic);
  503. sis900_init_txd(nic);
  504. sis900_init_rxd(nic);
  505. sis900_set_rx_mode(nic);
  506. sis900_check_mode(nic);
  507. outl(RxENA| inl(ioaddr + cr), ioaddr + cr);
  508. }
  509. /*
  510. * Function: sis900_reset
  511. *
  512. * Description: disables interrupts and soft resets the controller chip
  513. *
  514. * Arguments: struct nic *nic: NIC data structure
  515. *
  516. * Returns: void.
  517. */
  518. static void
  519. sis900_reset(struct nic *nic __unused)
  520. {
  521. int i = 0;
  522. u32 status = TxRCMP | RxRCMP;
  523. outl(0, ioaddr + ier);
  524. outl(0, ioaddr + imr);
  525. outl(0, ioaddr + rfcr);
  526. outl(RxRESET | TxRESET | RESET | inl(ioaddr + cr), ioaddr + cr);
  527. /* Check that the chip has finished the reset. */
  528. while (status && (i++ < 1000)) {
  529. status ^= (inl(isr + ioaddr) & status);
  530. }
  531. if( (pci_revision >= SIS635A_900_REV) || (pci_revision == SIS900B_900_REV) )
  532. outl(PESEL | RND_CNT, ioaddr + cfg);
  533. else
  534. outl(PESEL, ioaddr + cfg);
  535. }
  536. /* Function: sis_init_rxfilter
  537. *
  538. * Description: sets receive filter address to our MAC address
  539. *
  540. * Arguments: struct nic *nic: NIC data structure
  541. *
  542. * returns: void.
  543. */
  544. static void
  545. sis900_init_rxfilter(struct nic *nic)
  546. {
  547. u32 rfcrSave;
  548. int i;
  549. rfcrSave = inl(rfcr + ioaddr);
  550. /* disable packet filtering before setting filter */
  551. outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  552. /* load MAC addr to filter data register */
  553. for (i = 0 ; i < 3 ; i++) {
  554. u32 w;
  555. w = (u32) *((u16 *)(nic->node_addr)+i);
  556. outl((i << RFADDR_shift), ioaddr + rfcr);
  557. outl(w, ioaddr + rfdr);
  558. if (sis900_debug > 0)
  559. printf("sis900_init_rxfilter: Receive Filter Addrss[%d]=%lX\n",
  560. i, inl(ioaddr + rfdr));
  561. }
  562. /* enable packet filitering */
  563. outl(rfcrSave | RFEN, rfcr + ioaddr);
  564. }
  565. /*
  566. * Function: sis_init_txd
  567. *
  568. * Description: initializes the Tx descriptor
  569. *
  570. * Arguments: struct nic *nic: NIC data structure
  571. *
  572. * returns: void.
  573. */
  574. static void
  575. sis900_init_txd(struct nic *nic __unused)
  576. {
  577. txd.link = (u32) 0;
  578. txd.cmdsts = (u32) 0;
  579. txd.bufptr = virt_to_bus(&txb[0]);
  580. /* load Transmit Descriptor Register */
  581. outl(virt_to_bus(&txd), ioaddr + txdp);
  582. if (sis900_debug > 0)
  583. printf("sis900_init_txd: TX descriptor register loaded with: %lX\n",
  584. inl(ioaddr + txdp));
  585. }
  586. /* Function: sis_init_rxd
  587. *
  588. * Description: initializes the Rx descriptor ring
  589. *
  590. * Arguments: struct nic *nic: NIC data structure
  591. *
  592. * Returns: void.
  593. */
  594. static void
  595. sis900_init_rxd(struct nic *nic __unused)
  596. {
  597. int i;
  598. cur_rx = 0;
  599. /* init RX descriptor */
  600. for (i = 0; i < NUM_RX_DESC; i++) {
  601. rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  602. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  603. rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  604. if (sis900_debug > 0)
  605. printf("sis900_init_rxd: rxd[%d]=%p link=%X cmdsts=%X bufptr=%X\n",
  606. i, &rxd[i], (unsigned int) rxd[i].link, (unsigned int) rxd[i].cmdsts,
  607. (unsigned int) rxd[i].bufptr);
  608. }
  609. /* load Receive Descriptor Register */
  610. outl(virt_to_bus(&rxd[0]), ioaddr + rxdp);
  611. if (sis900_debug > 0)
  612. printf("sis900_init_rxd: RX descriptor register loaded with: %lX\n",
  613. inl(ioaddr + rxdp));
  614. }
  615. /* Function: sis_init_rxd
  616. *
  617. * Description:
  618. * sets the receive mode to accept all broadcast packets and packets
  619. * with our MAC address, and reject all multicast packets.
  620. *
  621. * Arguments: struct nic *nic: NIC data structure
  622. *
  623. * Returns: void.
  624. */
  625. static void sis900_set_rx_mode(struct nic *nic __unused)
  626. {
  627. int i, table_entries;
  628. u32 rx_mode;
  629. u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
  630. if((pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV))
  631. table_entries = 16;
  632. else
  633. table_entries = 8;
  634. /* accept all multicast packet */
  635. rx_mode = RFAAB | RFAAM;
  636. for (i = 0; i < table_entries; i++)
  637. mc_filter[i] = 0xffff;
  638. /* update Multicast Hash Table in Receive Filter */
  639. for (i = 0; i < table_entries; i++) {
  640. /* why plus 0x04? That makes the correct value for hash table. */
  641. outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr);
  642. outl(mc_filter[i], ioaddr + rfdr);
  643. }
  644. /* Accept Broadcast and multicast packets, destination addresses that match
  645. our MAC address */
  646. outl(RFEN | rx_mode, ioaddr + rfcr);
  647. return;
  648. }
  649. /* Function: sis900_check_mode
  650. *
  651. * Description: checks the state of transmit and receive
  652. * parameters on the NIC, and updates NIC registers to match
  653. *
  654. * Arguments: struct nic *nic: NIC data structure
  655. *
  656. * Returns: void.
  657. */
  658. static void
  659. sis900_check_mode(struct nic *nic)
  660. {
  661. int speed, duplex;
  662. u32 tx_flags = 0, rx_flags = 0;
  663. mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex);
  664. if( inl(ioaddr + cfg) & EDB_MASTER_EN ) {
  665. tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  666. rx_flags = DMA_BURST_64 << RxMXDMA_shift;
  667. }
  668. else {
  669. tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  670. rx_flags = DMA_BURST_512 << RxMXDMA_shift;
  671. }
  672. if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) {
  673. rx_flags |= (RxDRNT_10 << RxDRNT_shift);
  674. tx_flags |= (TxDRNT_10 << TxDRNT_shift);
  675. }
  676. else {
  677. rx_flags |= (RxDRNT_100 << RxDRNT_shift);
  678. tx_flags |= (TxDRNT_100 << TxDRNT_shift);
  679. }
  680. if (duplex == FDX_CAPABLE_FULL_SELECTED) {
  681. tx_flags |= (TxCSI | TxHBI);
  682. rx_flags |= RxATX;
  683. }
  684. outl (tx_flags, ioaddr + txcfg);
  685. outl (rx_flags, ioaddr + rxcfg);
  686. }
  687. /* Function: sis900_read_mode
  688. *
  689. * Description: retrieves and displays speed and duplex
  690. * parameters from the NIC
  691. *
  692. * Arguments: struct nic *nic: NIC data structure
  693. *
  694. * Returns: void.
  695. */
  696. static void
  697. sis900_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  698. {
  699. int i = 0;
  700. u32 status;
  701. u16 phy_id0, phy_id1;
  702. /* STSOUT register is Latched on Transition, read operation updates it */
  703. do {
  704. status = sis900_mdio_read(phy_addr, MII_STSOUT);
  705. } while (i++ < 2);
  706. *speed = HW_SPEED_10_MBPS;
  707. *duplex = FDX_CAPABLE_HALF_SELECTED;
  708. if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX))
  709. *speed = HW_SPEED_100_MBPS;
  710. if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX))
  711. *duplex = FDX_CAPABLE_FULL_SELECTED;
  712. /* Workaround for Realtek RTL8201 PHY issue */
  713. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  714. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  715. if((phy_id0 == 0x0000) && ((phy_id1 & 0xFFF0) == 0x8200)){
  716. if(sis900_mdio_read(phy_addr, MII_CONTROL) & MII_CNTL_FDX)
  717. *duplex = FDX_CAPABLE_FULL_SELECTED;
  718. if(sis900_mdio_read(phy_addr, 0x0019) & 0x01)
  719. *speed = HW_SPEED_100_MBPS;
  720. }
  721. if (status & MII_STSOUT_LINK_FAIL)
  722. printf("sis900_read_mode: Media Link Off\n");
  723. else
  724. printf("sis900_read_mode: Media Link On %s %s-duplex \n",
  725. *speed == HW_SPEED_100_MBPS ?
  726. "100mbps" : "10mbps",
  727. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  728. "full" : "half");
  729. }
  730. /* Function: amd79c901_read_mode
  731. *
  732. * Description: retrieves and displays speed and duplex
  733. * parameters from the NIC
  734. *
  735. * Arguments: struct nic *nic: NIC data structure
  736. *
  737. * Returns: void.
  738. */
  739. static void
  740. amd79c901_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  741. {
  742. int i;
  743. u16 status;
  744. for (i = 0; i < 2; i++)
  745. status = sis900_mdio_read(phy_addr, MII_STATUS);
  746. if (status & MII_STAT_CAN_AUTO) {
  747. /* 10BASE-T PHY */
  748. for (i = 0; i < 2; i++)
  749. status = sis900_mdio_read(phy_addr, MII_STATUS_SUMMARY);
  750. if (status & MII_STSSUM_SPD)
  751. *speed = HW_SPEED_100_MBPS;
  752. else
  753. *speed = HW_SPEED_10_MBPS;
  754. if (status & MII_STSSUM_DPLX)
  755. *duplex = FDX_CAPABLE_FULL_SELECTED;
  756. else
  757. *duplex = FDX_CAPABLE_HALF_SELECTED;
  758. if (status & MII_STSSUM_LINK)
  759. printf("amd79c901_read_mode: Media Link On %s %s-duplex \n",
  760. *speed == HW_SPEED_100_MBPS ?
  761. "100mbps" : "10mbps",
  762. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  763. "full" : "half");
  764. else
  765. printf("amd79c901_read_mode: Media Link Off\n");
  766. }
  767. else {
  768. /* HomePNA */
  769. *speed = HW_SPEED_HOME;
  770. *duplex = FDX_CAPABLE_HALF_SELECTED;
  771. if (status & MII_STAT_LINK)
  772. printf("amd79c901_read_mode:Media Link On 1mbps half-duplex \n");
  773. else
  774. printf("amd79c901_read_mode: Media Link Off\n");
  775. }
  776. }
  777. /**
  778. * ics1893_read_mode: - read media mode for ICS1893 PHY
  779. * @net_dev: the net device to read mode for
  780. * @phy_addr: mii phy address
  781. * @speed: the transmit speed to be determined
  782. * @duplex: the duplex mode to be determined
  783. *
  784. * ICS1893 PHY use Quick Poll Detailed Status register
  785. * to determine the speed and duplex mode for sis900
  786. */
  787. static void ics1893_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  788. {
  789. int i = 0;
  790. u32 status;
  791. /* MII_QPDSTS is Latched, read twice in succession will reflect the current state */
  792. for (i = 0; i < 2; i++)
  793. status = sis900_mdio_read(phy_addr, MII_QPDSTS);
  794. if (status & MII_STSICS_SPD)
  795. *speed = HW_SPEED_100_MBPS;
  796. else
  797. *speed = HW_SPEED_10_MBPS;
  798. if (status & MII_STSICS_DPLX)
  799. *duplex = FDX_CAPABLE_FULL_SELECTED;
  800. else
  801. *duplex = FDX_CAPABLE_HALF_SELECTED;
  802. if (status & MII_STSICS_LINKSTS)
  803. printf("ics1893_read_mode: Media Link On %s %s-duplex \n",
  804. *speed == HW_SPEED_100_MBPS ?
  805. "100mbps" : "10mbps",
  806. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  807. "full" : "half");
  808. else
  809. printf("ics1893_read_mode: Media Link Off\n");
  810. }
  811. /**
  812. * rtl8201_read_mode: - read media mode for rtl8201 phy
  813. * @nic: the net device to read mode for
  814. * @phy_addr: mii phy address
  815. * @speed: the transmit speed to be determined
  816. * @duplex: the duplex mode to be determined
  817. *
  818. * read MII_STATUS register from rtl8201 phy
  819. * to determine the speed and duplex mode for sis900
  820. */
  821. static void rtl8201_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  822. {
  823. u32 status;
  824. status = sis900_mdio_read(phy_addr, MII_STATUS);
  825. if (status & MII_STAT_CAN_TX_FDX) {
  826. *speed = HW_SPEED_100_MBPS;
  827. *duplex = FDX_CAPABLE_FULL_SELECTED;
  828. }
  829. else if (status & MII_STAT_CAN_TX) {
  830. *speed = HW_SPEED_100_MBPS;
  831. *duplex = FDX_CAPABLE_HALF_SELECTED;
  832. }
  833. else if (status & MII_STAT_CAN_T_FDX) {
  834. *speed = HW_SPEED_10_MBPS;
  835. *duplex = FDX_CAPABLE_FULL_SELECTED;
  836. }
  837. else if (status & MII_STAT_CAN_T) {
  838. *speed = HW_SPEED_10_MBPS;
  839. *duplex = FDX_CAPABLE_HALF_SELECTED;
  840. }
  841. if (status & MII_STAT_LINK)
  842. printf("rtl8201_read_mode: Media Link On %s %s-duplex \n",
  843. *speed == HW_SPEED_100_MBPS ?
  844. "100mbps" : "10mbps",
  845. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  846. "full" : "half");
  847. else
  848. printf("rtl8201_read_config_mode: Media Link Off\n");
  849. }
  850. /**
  851. * vt6103_read_mode: - read media mode for vt6103 phy
  852. * @nic: the net device to read mode for
  853. * @phy_addr: mii phy address
  854. * @speed: the transmit speed to be determined
  855. * @duplex: the duplex mode to be determined
  856. *
  857. * read MII_STATUS register from rtl8201 phy
  858. * to determine the speed and duplex mode for sis900
  859. */
  860. static void vt6103_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  861. {
  862. u32 status;
  863. status = sis900_mdio_read(phy_addr, MII_STATUS);
  864. if (status & MII_STAT_CAN_TX_FDX) {
  865. *speed = HW_SPEED_100_MBPS;
  866. *duplex = FDX_CAPABLE_FULL_SELECTED;
  867. }
  868. else if (status & MII_STAT_CAN_TX) {
  869. *speed = HW_SPEED_100_MBPS;
  870. *duplex = FDX_CAPABLE_HALF_SELECTED;
  871. }
  872. else if (status & MII_STAT_CAN_T_FDX) {
  873. *speed = HW_SPEED_10_MBPS;
  874. *duplex = FDX_CAPABLE_FULL_SELECTED;
  875. }
  876. else if (status & MII_STAT_CAN_T) {
  877. *speed = HW_SPEED_10_MBPS;
  878. *duplex = FDX_CAPABLE_HALF_SELECTED;
  879. }
  880. if (status & MII_STAT_LINK)
  881. printf("vt6103_read_mode: Media Link On %s %s-duplex \n",
  882. *speed == HW_SPEED_100_MBPS ?
  883. "100mbps" : "10mbps",
  884. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  885. "full" : "half");
  886. else
  887. printf("vt6103_read_config_mode: Media Link Off\n");
  888. }
  889. /* Function: sis900_transmit
  890. *
  891. * Description: transmits a packet and waits for completion or timeout.
  892. *
  893. * Arguments: char d[6]: destination ethernet address.
  894. * unsigned short t: ethernet protocol type.
  895. * unsigned short s: size of the data-part of the packet.
  896. * char *p: the data for the packet.
  897. *
  898. * Returns: void.
  899. */
  900. static void
  901. sis900_transmit(struct nic *nic,
  902. const char *d, /* Destination */
  903. unsigned int t, /* Type */
  904. unsigned int s, /* size */
  905. const char *p) /* Packet */
  906. {
  907. u32 to, nstype;
  908. volatile u32 tx_status;
  909. /* Stop the transmitter */
  910. outl(TxDIS | inl(ioaddr + cr), ioaddr + cr);
  911. /* load Transmit Descriptor Register */
  912. outl(virt_to_bus(&txd), ioaddr + txdp);
  913. if (sis900_debug > 1)
  914. printf("sis900_transmit: TX descriptor register loaded with: %lX\n",
  915. inl(ioaddr + txdp));
  916. memcpy(txb, d, ETH_ALEN);
  917. memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  918. nstype = htons(t);
  919. memcpy(txb + 2 * ETH_ALEN, (char*)&nstype, 2);
  920. memcpy(txb + ETH_HLEN, p, s);
  921. s += ETH_HLEN;
  922. s &= DSIZE;
  923. if (sis900_debug > 1)
  924. printf("sis900_transmit: sending %d bytes ethtype %hX\n", (int) s, t);
  925. /* pad to minimum packet size */
  926. while (s < ETH_ZLEN)
  927. txb[s++] = '\0';
  928. /* set the transmit buffer descriptor and enable Transmit State Machine */
  929. txd.bufptr = virt_to_bus(&txb[0]);
  930. txd.cmdsts = (u32) OWN | s;
  931. /* restart the transmitter */
  932. outl(TxENA | inl(ioaddr + cr), ioaddr + cr);
  933. if (sis900_debug > 1)
  934. printf("sis900_transmit: Queued Tx packet size %d.\n", (int) s);
  935. to = currticks() + TX_TIMEOUT;
  936. while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  937. /* wait */ ;
  938. if (currticks() >= to) {
  939. printf("sis900_transmit: TX Timeout! Tx status %X.\n",
  940. (unsigned int) tx_status);
  941. }
  942. if (tx_status & (ABORT | UNDERRUN | OWCOLL)) {
  943. /* packet unsuccessfully transmited */
  944. printf("sis900_transmit: Transmit error, Tx status %X.\n",
  945. (unsigned int) tx_status);
  946. }
  947. /* Disable interrupts by clearing the interrupt mask. */
  948. outl(0, ioaddr + imr);
  949. }
  950. /* Function: sis900_poll
  951. *
  952. * Description: checks for a received packet and returns it if found.
  953. *
  954. * Arguments: struct nic *nic: NIC data structure
  955. *
  956. * Returns: 1 if a packet was recieved.
  957. * 0 if no pacet was recieved.
  958. *
  959. * Side effects:
  960. * Returns (copies) the packet to the array nic->packet.
  961. * Returns the length of the packet in nic->packetlen.
  962. */
  963. static int
  964. sis900_poll(struct nic *nic, int retrieve)
  965. {
  966. u32 rx_status = rxd[cur_rx].cmdsts;
  967. int retstat = 0;
  968. if (sis900_debug > 2)
  969. printf("sis900_poll: cur_rx:%d, status:%X\n", cur_rx,
  970. (unsigned int) rx_status);
  971. if (!(rx_status & OWN))
  972. return retstat;
  973. if (sis900_debug > 1)
  974. printf("sis900_poll: got a packet: cur_rx:%d, status:%X\n",
  975. cur_rx, (unsigned int) rx_status);
  976. if ( ! retrieve ) return 1;
  977. nic->packetlen = (rx_status & DSIZE) - CRC_SIZE;
  978. if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
  979. /* corrupted packet received */
  980. printf("sis900_poll: Corrupted packet received, buffer status = %X\n",
  981. (unsigned int) rx_status);
  982. retstat = 0;
  983. } else {
  984. /* give packet to higher level routine */
  985. memcpy(nic->packet, (rxb + cur_rx*RX_BUF_SIZE), nic->packetlen);
  986. retstat = 1;
  987. }
  988. /* return the descriptor and buffer to receive ring */
  989. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  990. rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  991. if (++cur_rx == NUM_RX_DESC)
  992. cur_rx = 0;
  993. /* re-enable the potentially idle receive state machine */
  994. outl(RxENA | inl(ioaddr + cr), ioaddr + cr);
  995. return retstat;
  996. }
  997. /* Function: sis900_disable
  998. *
  999. * Description: Turns off interrupts and stops Tx and Rx engines
  1000. *
  1001. * Arguments: struct nic *nic: NIC data structure
  1002. *
  1003. * Returns: void.
  1004. */
  1005. static void
  1006. sis900_disable ( struct nic *nic ) {
  1007. sis900_init(nic);
  1008. /* Disable interrupts by clearing the interrupt mask. */
  1009. outl(0, ioaddr + imr);
  1010. outl(0, ioaddr + ier);
  1011. /* Stop the chip's Tx and Rx Status Machine */
  1012. outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr);
  1013. }
  1014. /* Function: sis900_irq
  1015. *
  1016. * Description: Enable, Disable, or Force, interrupts
  1017. *
  1018. * Arguments: struct nic *nic: NIC data structure
  1019. * irq_action_t action: Requested action
  1020. *
  1021. * Returns: void.
  1022. */
  1023. static void
  1024. sis900_irq(struct nic *nic __unused, irq_action_t action __unused)
  1025. {
  1026. switch ( action ) {
  1027. case DISABLE :
  1028. break;
  1029. case ENABLE :
  1030. break;
  1031. case FORCE :
  1032. break;
  1033. }
  1034. }
  1035. static struct nic_operations sis900_operations = {
  1036. .connect = dummy_connect,
  1037. .poll = sis900_poll,
  1038. .transmit = sis900_transmit,
  1039. .irq = sis900_irq,
  1040. };
  1041. static struct pci_device_id sis900_nics[] = {
  1042. PCI_ROM(0x1039, 0x0900, "sis900", "SIS900"),
  1043. PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016"),
  1044. };
  1045. PCI_DRIVER ( sis900_driver, sis900_nics, PCI_NO_CLASS );
  1046. DRIVER ( "SIS900", nic_driver, pci_driver, sis900_driver,
  1047. sis900_probe, sis900_disable );
  1048. /*
  1049. * Local variables:
  1050. * c-basic-offset: 8
  1051. * c-indent-level: 8
  1052. * tab-width: 8
  1053. * End:
  1054. */