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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302
  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. FILE_LICENCE ( GPL_ANY );
  21. /* Revision History */
  22. /*
  23. 07 Dec 2003 timlegge - Enabled Multicast Support
  24. 06 Dec 2003 timlegge - Fixed relocation issue in 5.2
  25. 04 Jan 2002 Chien-Yu Chen, Doug Ambrisko, Marty Connor Patch to Etherboot 5.0.5
  26. Added support for the SiS 630ET plus various bug fixes from linux kernel
  27. source 2.4.17.
  28. 01 March 2001 mdc 1.0
  29. Initial Release. Tested with PCI based sis900 card and ThinkNIC
  30. computer.
  31. 20 March 2001 P.Koegel
  32. added support for sis630e and PHY ICS1893 and RTL8201
  33. Testet with SIS730S chipset + ICS1893
  34. */
  35. /* Includes */
  36. #include "etherboot.h"
  37. #include <ipxe/pci.h>
  38. #include "nic.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. {NULL,0,0,NULL}
  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 __unused)
  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. return 0;
  229. }
  230. /**
  231. * sis630e_get_mac_addr: - Get MAC address for SiS630E model
  232. * @pci_dev: the sis900 pci device
  233. * @net_dev: the net device to get address for
  234. *
  235. * SiS630E model, use APC CMOS RAM to store MAC address.
  236. * APC CMOS RAM is accessed through ISA bridge.
  237. * MAC address is read into @net_dev->dev_addr.
  238. */
  239. static int sis635_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
  240. {
  241. u32 rfcrSave;
  242. u32 i;
  243. rfcrSave = inl(rfcr + ioaddr);
  244. outl(rfcrSave | RELOAD, ioaddr + cr);
  245. outl(0, ioaddr + cr);
  246. /* disable packet filtering before setting filter */
  247. outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  248. /* load MAC addr to filter data register */
  249. for (i = 0 ; i < 3 ; i++) {
  250. outl((i << RFADDR_shift), ioaddr + rfcr);
  251. *( ((u16 *)nic->node_addr) + i) = inw(ioaddr + rfdr);
  252. }
  253. /* enable packet filitering */
  254. outl(rfcrSave | RFEN, rfcr + ioaddr);
  255. return 1;
  256. }
  257. /*
  258. * Function: sis900_probe
  259. *
  260. * Description: initializes initializes the NIC, retrieves the
  261. * MAC address of the card, and sets up some globals required by
  262. * other routines.
  263. *
  264. * Side effects:
  265. * leaves the ioaddress of the sis900 chip in the variable ioaddr.
  266. * leaves the sis900 initialized, and ready to receive packets.
  267. *
  268. * Returns: struct nic *: pointer to NIC data structure
  269. */
  270. static int sis900_probe ( struct nic *nic, struct pci_device *pci ) {
  271. int i;
  272. int found=0;
  273. int phy_addr;
  274. u8 revision;
  275. int ret;
  276. if (pci->ioaddr == 0)
  277. return 0;
  278. nic->irqno = 0;
  279. nic->ioaddr = pci->ioaddr;
  280. ioaddr = pci->ioaddr;
  281. vendor = pci->vendor;
  282. dev_id = pci->device;
  283. /* wakeup chip */
  284. pci_write_config_dword(pci, 0x40, 0x00000000);
  285. adjust_pci_device(pci);
  286. /* get MAC address */
  287. ret = 0;
  288. pci_read_config_byte(pci, PCI_REVISION, &revision);
  289. /* save for use later in sis900_reset() */
  290. pci_revision = revision;
  291. if (revision == SIS630E_900_REV)
  292. ret = sis630e_get_mac_addr(pci, nic);
  293. else if ((revision > 0x81) && (revision <= 0x90))
  294. ret = sis635_get_mac_addr(pci, nic);
  295. else if (revision == SIS96x_900_REV)
  296. ret = sis96x_get_mac_addr(pci, nic);
  297. else
  298. ret = sis900_get_mac_addr(pci, nic);
  299. if (ret == 0)
  300. {
  301. printf ("sis900_probe: Error MAC address not found\n");
  302. return 0;
  303. }
  304. /* 630ET : set the mii access mode as software-mode */
  305. if (revision == SIS630ET_900_REV)
  306. outl(ACCESSMODE | inl(ioaddr + cr), ioaddr + cr);
  307. DBG( "sis900_probe: Vendor:%#hX Device:%#hX\n", vendor, dev_id );
  308. /* probe for mii transceiver */
  309. /* search for total of 32 possible mii phy addresses */
  310. found = 0;
  311. for (phy_addr = 0; phy_addr < 32; phy_addr++) {
  312. u16 mii_status;
  313. u16 phy_id0, phy_id1;
  314. mii_status = sis900_mdio_read(phy_addr, MII_STATUS);
  315. if (mii_status == 0xffff || mii_status == 0x0000)
  316. /* the mii is not accessible, try next one */
  317. continue;
  318. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  319. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  320. /* search our mii table for the current mii */
  321. for (i = 0; mii_chip_table[i].phy_id1; i++) {
  322. if ((phy_id0 == mii_chip_table[i].phy_id0) &&
  323. ((phy_id1 & 0xFFF0) == mii_chip_table[i].phy_id1)){
  324. printf("sis900_probe: %s transceiver found at address %d.\n",
  325. mii_chip_table[i].name, phy_addr);
  326. mii.chip_info = &mii_chip_table[i];
  327. mii.phy_addr = phy_addr;
  328. mii.status = sis900_mdio_read(phy_addr, MII_STATUS);
  329. mii.next = NULL;
  330. found=1;
  331. break;
  332. }
  333. }
  334. }
  335. if (found == 0) {
  336. printf("sis900_probe: No MII transceivers found!\n");
  337. return 0;
  338. }
  339. /* Arbitrarily select the last PHY found as current PHY */
  340. cur_phy = mii.phy_addr;
  341. printf("sis900_probe: Using %s as default\n", mii.chip_info->name);
  342. /* initialize device */
  343. sis900_init(nic);
  344. nic->nic_op = &sis900_operations;
  345. return 1;
  346. }
  347. /*
  348. * EEPROM Routines: These functions read and write to EEPROM for
  349. * retrieving the MAC address and other configuration information about
  350. * the card.
  351. */
  352. /* Delay between EEPROM clock transitions. */
  353. #define eeprom_delay() inl(ee_addr)
  354. /* Function: sis900_read_eeprom
  355. *
  356. * Description: reads and returns a given location from EEPROM
  357. *
  358. * Arguments: int location: requested EEPROM location
  359. *
  360. * Returns: u16: contents of requested EEPROM location
  361. *
  362. */
  363. /* Read Serial EEPROM through EEPROM Access Register, Note that location is
  364. in word (16 bits) unit */
  365. static u16 sis900_read_eeprom(int location)
  366. {
  367. int i;
  368. u16 retval = 0;
  369. long ee_addr = ioaddr + mear;
  370. u32 read_cmd = location | EEread;
  371. outl(0, ee_addr);
  372. eeprom_delay();
  373. outl(EECS, ee_addr);
  374. eeprom_delay();
  375. /* Shift the read command (9) bits out. */
  376. for (i = 8; i >= 0; i--) {
  377. u32 dataval = (read_cmd & (1 << i)) ? EEDI | EECS : EECS;
  378. outl(dataval, ee_addr);
  379. eeprom_delay();
  380. outl(dataval | EECLK, ee_addr);
  381. eeprom_delay();
  382. }
  383. outl(EECS, ee_addr);
  384. eeprom_delay();
  385. /* read the 16-bits data in */
  386. for (i = 16; i > 0; i--) {
  387. outl(EECS, ee_addr);
  388. eeprom_delay();
  389. outl(EECS | EECLK, ee_addr);
  390. eeprom_delay();
  391. retval = (retval << 1) | ((inl(ee_addr) & EEDO) ? 1 : 0);
  392. eeprom_delay();
  393. }
  394. /* Terminate the EEPROM access. */
  395. outl(0, ee_addr);
  396. eeprom_delay();
  397. // outl(EECLK, ee_addr);
  398. return (retval);
  399. }
  400. #define sis900_mdio_delay() inl(mdio_addr)
  401. /*
  402. Read and write the MII management registers using software-generated
  403. serial MDIO protocol. Note that the command bits and data bits are
  404. sent out separately
  405. */
  406. static void sis900_mdio_idle(long mdio_addr)
  407. {
  408. outl(MDIO | MDDIR, mdio_addr);
  409. sis900_mdio_delay();
  410. outl(MDIO | MDDIR | MDC, mdio_addr);
  411. }
  412. /* Syncronize the MII management interface by shifting 32 one bits out. */
  413. static void sis900_mdio_reset(long mdio_addr)
  414. {
  415. int i;
  416. for (i = 31; i >= 0; i--) {
  417. outl(MDDIR | MDIO, mdio_addr);
  418. sis900_mdio_delay();
  419. outl(MDDIR | MDIO | MDC, mdio_addr);
  420. sis900_mdio_delay();
  421. }
  422. return;
  423. }
  424. static u16 sis900_mdio_read(int phy_id, int location)
  425. {
  426. long mdio_addr = ioaddr + mear;
  427. int mii_cmd = MIIread|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
  428. u16 retval = 0;
  429. int i;
  430. sis900_mdio_reset(mdio_addr);
  431. sis900_mdio_idle(mdio_addr);
  432. for (i = 15; i >= 0; i--) {
  433. int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
  434. outl(dataval, mdio_addr);
  435. sis900_mdio_delay();
  436. outl(dataval | MDC, mdio_addr);
  437. sis900_mdio_delay();
  438. }
  439. /* Read the 16 data bits. */
  440. for (i = 16; i > 0; i--) {
  441. outl(0, mdio_addr);
  442. sis900_mdio_delay();
  443. retval = (retval << 1) | ((inl(mdio_addr) & MDIO) ? 1 : 0);
  444. outl(MDC, mdio_addr);
  445. sis900_mdio_delay();
  446. }
  447. outl(0x00, mdio_addr);
  448. return retval;
  449. }
  450. #if 0
  451. static void sis900_mdio_write(int phy_id, int location, int value)
  452. {
  453. long mdio_addr = ioaddr + mear;
  454. int mii_cmd = MIIwrite|(phy_id<<MIIpmdShift)|(location<<MIIregShift);
  455. int i;
  456. sis900_mdio_reset(mdio_addr);
  457. sis900_mdio_idle(mdio_addr);
  458. /* Shift the command bits out. */
  459. for (i = 15; i >= 0; i--) {
  460. int dataval = (mii_cmd & (1 << i)) ? MDDIR | MDIO : MDDIR;
  461. outb(dataval, mdio_addr);
  462. sis900_mdio_delay();
  463. outb(dataval | MDC, mdio_addr);
  464. sis900_mdio_delay();
  465. }
  466. sis900_mdio_delay();
  467. /* Shift the value bits out. */
  468. for (i = 15; i >= 0; i--) {
  469. int dataval = (value & (1 << i)) ? MDDIR | MDIO : MDDIR;
  470. outl(dataval, mdio_addr);
  471. sis900_mdio_delay();
  472. outl(dataval | MDC, mdio_addr);
  473. sis900_mdio_delay();
  474. }
  475. sis900_mdio_delay();
  476. /* Clear out extra bits. */
  477. for (i = 2; i > 0; i--) {
  478. outb(0, mdio_addr);
  479. sis900_mdio_delay();
  480. outb(MDC, mdio_addr);
  481. sis900_mdio_delay();
  482. }
  483. outl(0x00, mdio_addr);
  484. return;
  485. }
  486. #endif
  487. /* Function: sis900_init
  488. *
  489. * Description: resets the ethernet controller chip and various
  490. * data structures required for sending and receiving packets.
  491. *
  492. * Arguments: struct nic *nic: NIC data structure
  493. *
  494. * returns: void.
  495. */
  496. static void
  497. sis900_init(struct nic *nic)
  498. {
  499. /* Soft reset the chip. */
  500. sis900_reset(nic);
  501. sis900_init_rxfilter(nic);
  502. sis900_init_txd(nic);
  503. sis900_init_rxd(nic);
  504. sis900_set_rx_mode(nic);
  505. sis900_check_mode(nic);
  506. outl(RxENA| inl(ioaddr + cr), ioaddr + cr);
  507. }
  508. /*
  509. * Function: sis900_reset
  510. *
  511. * Description: disables interrupts and soft resets the controller chip
  512. *
  513. * Arguments: struct nic *nic: NIC data structure
  514. *
  515. * Returns: void.
  516. */
  517. static void
  518. sis900_reset(struct nic *nic __unused)
  519. {
  520. int i = 0;
  521. u32 status = TxRCMP | RxRCMP;
  522. outl(0, ioaddr + ier);
  523. outl(0, ioaddr + imr);
  524. outl(0, ioaddr + rfcr);
  525. outl(RxRESET | TxRESET | RESET | inl(ioaddr + cr), ioaddr + cr);
  526. /* Check that the chip has finished the reset. */
  527. while (status && (i++ < 1000)) {
  528. status ^= (inl(isr + ioaddr) & status);
  529. }
  530. if( (pci_revision >= SIS635A_900_REV) || (pci_revision == SIS900B_900_REV) )
  531. outl(PESEL | RND_CNT, ioaddr + cfg);
  532. else
  533. outl(PESEL, ioaddr + cfg);
  534. }
  535. /* Function: sis_init_rxfilter
  536. *
  537. * Description: sets receive filter address to our MAC address
  538. *
  539. * Arguments: struct nic *nic: NIC data structure
  540. *
  541. * returns: void.
  542. */
  543. static void
  544. sis900_init_rxfilter(struct nic *nic)
  545. {
  546. u32 rfcrSave;
  547. int i;
  548. rfcrSave = inl(rfcr + ioaddr);
  549. /* disable packet filtering before setting filter */
  550. outl(rfcrSave & ~RFEN, rfcr + ioaddr);
  551. /* load MAC addr to filter data register */
  552. for (i = 0 ; i < 3 ; i++) {
  553. u32 w;
  554. w = (u32) *((u16 *)(nic->node_addr)+i);
  555. outl((i << RFADDR_shift), ioaddr + rfcr);
  556. outl(w, ioaddr + rfdr);
  557. if (sis900_debug > 0)
  558. printf("sis900_init_rxfilter: Receive Filter Addrss[%d]=%X\n",
  559. i, inl(ioaddr + rfdr));
  560. }
  561. /* enable packet filitering */
  562. outl(rfcrSave | RFEN, rfcr + ioaddr);
  563. }
  564. /*
  565. * Function: sis_init_txd
  566. *
  567. * Description: initializes the Tx descriptor
  568. *
  569. * Arguments: struct nic *nic: NIC data structure
  570. *
  571. * returns: void.
  572. */
  573. static void
  574. sis900_init_txd(struct nic *nic __unused)
  575. {
  576. txd.link = (u32) 0;
  577. txd.cmdsts = (u32) 0;
  578. txd.bufptr = virt_to_bus(&txb[0]);
  579. /* load Transmit Descriptor Register */
  580. outl(virt_to_bus(&txd), ioaddr + txdp);
  581. if (sis900_debug > 0)
  582. printf("sis900_init_txd: TX descriptor register loaded with: %X\n",
  583. inl(ioaddr + txdp));
  584. }
  585. /* Function: sis_init_rxd
  586. *
  587. * Description: initializes the Rx descriptor ring
  588. *
  589. * Arguments: struct nic *nic: NIC data structure
  590. *
  591. * Returns: void.
  592. */
  593. static void
  594. sis900_init_rxd(struct nic *nic __unused)
  595. {
  596. int i;
  597. cur_rx = 0;
  598. /* init RX descriptor */
  599. for (i = 0; i < NUM_RX_DESC; i++) {
  600. rxd[i].link = virt_to_bus((i+1 < NUM_RX_DESC) ? &rxd[i+1] : &rxd[0]);
  601. rxd[i].cmdsts = (u32) RX_BUF_SIZE;
  602. rxd[i].bufptr = virt_to_bus(&rxb[i*RX_BUF_SIZE]);
  603. if (sis900_debug > 0)
  604. printf("sis900_init_rxd: rxd[%d]=%p link=%X cmdsts=%X bufptr=%X\n",
  605. i, &rxd[i], (unsigned int) rxd[i].link, (unsigned int) rxd[i].cmdsts,
  606. (unsigned int) rxd[i].bufptr);
  607. }
  608. /* load Receive Descriptor Register */
  609. outl(virt_to_bus(&rxd[0]), ioaddr + rxdp);
  610. if (sis900_debug > 0)
  611. printf("sis900_init_rxd: RX descriptor register loaded with: %X\n",
  612. inl(ioaddr + rxdp));
  613. }
  614. /* Function: sis_init_rxd
  615. *
  616. * Description:
  617. * sets the receive mode to accept all broadcast packets and packets
  618. * with our MAC address, and reject all multicast packets.
  619. *
  620. * Arguments: struct nic *nic: NIC data structure
  621. *
  622. * Returns: void.
  623. */
  624. static void sis900_set_rx_mode(struct nic *nic __unused)
  625. {
  626. int i, table_entries;
  627. u32 rx_mode;
  628. u16 mc_filter[16] = {0}; /* 256/128 bits multicast hash table */
  629. if((pci_revision == SIS635A_900_REV) || (pci_revision == SIS900B_900_REV))
  630. table_entries = 16;
  631. else
  632. table_entries = 8;
  633. /* accept all multicast packet */
  634. rx_mode = RFAAB | RFAAM;
  635. for (i = 0; i < table_entries; i++)
  636. mc_filter[i] = 0xffff;
  637. /* update Multicast Hash Table in Receive Filter */
  638. for (i = 0; i < table_entries; i++) {
  639. /* why plus 0x04? That makes the correct value for hash table. */
  640. outl((u32)(0x00000004+i) << RFADDR_shift, ioaddr + rfcr);
  641. outl(mc_filter[i], ioaddr + rfdr);
  642. }
  643. /* Accept Broadcast and multicast packets, destination addresses that match
  644. our MAC address */
  645. outl(RFEN | rx_mode, ioaddr + rfcr);
  646. return;
  647. }
  648. /* Function: sis900_check_mode
  649. *
  650. * Description: checks the state of transmit and receive
  651. * parameters on the NIC, and updates NIC registers to match
  652. *
  653. * Arguments: struct nic *nic: NIC data structure
  654. *
  655. * Returns: void.
  656. */
  657. static void
  658. sis900_check_mode(struct nic *nic)
  659. {
  660. int speed, duplex;
  661. u32 tx_flags = 0, rx_flags = 0;
  662. mii.chip_info->read_mode(nic, cur_phy, &speed, &duplex);
  663. if( inl(ioaddr + cfg) & EDB_MASTER_EN ) {
  664. tx_flags = TxATP | (DMA_BURST_64 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  665. rx_flags = DMA_BURST_64 << RxMXDMA_shift;
  666. }
  667. else {
  668. tx_flags = TxATP | (DMA_BURST_512 << TxMXDMA_shift) | (TX_FILL_THRESH << TxFILLT_shift);
  669. rx_flags = DMA_BURST_512 << RxMXDMA_shift;
  670. }
  671. if (speed == HW_SPEED_HOME || speed == HW_SPEED_10_MBPS) {
  672. rx_flags |= (RxDRNT_10 << RxDRNT_shift);
  673. tx_flags |= (TxDRNT_10 << TxDRNT_shift);
  674. }
  675. else {
  676. rx_flags |= (RxDRNT_100 << RxDRNT_shift);
  677. tx_flags |= (TxDRNT_100 << TxDRNT_shift);
  678. }
  679. if (duplex == FDX_CAPABLE_FULL_SELECTED) {
  680. tx_flags |= (TxCSI | TxHBI);
  681. rx_flags |= RxATX;
  682. }
  683. outl (tx_flags, ioaddr + txcfg);
  684. outl (rx_flags, ioaddr + rxcfg);
  685. }
  686. /* Function: sis900_read_mode
  687. *
  688. * Description: retrieves and displays speed and duplex
  689. * parameters from the NIC
  690. *
  691. * Arguments: struct nic *nic: NIC data structure
  692. *
  693. * Returns: void.
  694. */
  695. static void
  696. sis900_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  697. {
  698. int i = 0;
  699. u32 status;
  700. u16 phy_id0, phy_id1;
  701. /* STSOUT register is Latched on Transition, read operation updates it */
  702. do {
  703. status = sis900_mdio_read(phy_addr, MII_STSOUT);
  704. } while (i++ < 2);
  705. *speed = HW_SPEED_10_MBPS;
  706. *duplex = FDX_CAPABLE_HALF_SELECTED;
  707. if (status & (MII_NWAY_TX | MII_NWAY_TX_FDX))
  708. *speed = HW_SPEED_100_MBPS;
  709. if (status & ( MII_NWAY_TX_FDX | MII_NWAY_T_FDX))
  710. *duplex = FDX_CAPABLE_FULL_SELECTED;
  711. /* Workaround for Realtek RTL8201 PHY issue */
  712. phy_id0 = sis900_mdio_read(phy_addr, MII_PHY_ID0);
  713. phy_id1 = sis900_mdio_read(phy_addr, MII_PHY_ID1);
  714. if((phy_id0 == 0x0000) && ((phy_id1 & 0xFFF0) == 0x8200)){
  715. if(sis900_mdio_read(phy_addr, MII_CONTROL) & MII_CNTL_FDX)
  716. *duplex = FDX_CAPABLE_FULL_SELECTED;
  717. if(sis900_mdio_read(phy_addr, 0x0019) & 0x01)
  718. *speed = HW_SPEED_100_MBPS;
  719. }
  720. if (status & MII_STSOUT_LINK_FAIL)
  721. printf("sis900_read_mode: Media Link Off\n");
  722. else
  723. printf("sis900_read_mode: Media Link On %s %s-duplex \n",
  724. *speed == HW_SPEED_100_MBPS ?
  725. "100mbps" : "10mbps",
  726. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  727. "full" : "half");
  728. }
  729. /* Function: amd79c901_read_mode
  730. *
  731. * Description: retrieves and displays speed and duplex
  732. * parameters from the NIC
  733. *
  734. * Arguments: struct nic *nic: NIC data structure
  735. *
  736. * Returns: void.
  737. */
  738. static void
  739. amd79c901_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  740. {
  741. int i;
  742. u16 status;
  743. for (i = 0; i < 2; i++)
  744. status = sis900_mdio_read(phy_addr, MII_STATUS);
  745. if (status & MII_STAT_CAN_AUTO) {
  746. /* 10BASE-T PHY */
  747. for (i = 0; i < 2; i++)
  748. status = sis900_mdio_read(phy_addr, MII_STATUS_SUMMARY);
  749. if (status & MII_STSSUM_SPD)
  750. *speed = HW_SPEED_100_MBPS;
  751. else
  752. *speed = HW_SPEED_10_MBPS;
  753. if (status & MII_STSSUM_DPLX)
  754. *duplex = FDX_CAPABLE_FULL_SELECTED;
  755. else
  756. *duplex = FDX_CAPABLE_HALF_SELECTED;
  757. if (status & MII_STSSUM_LINK)
  758. printf("amd79c901_read_mode: Media Link On %s %s-duplex \n",
  759. *speed == HW_SPEED_100_MBPS ?
  760. "100mbps" : "10mbps",
  761. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  762. "full" : "half");
  763. else
  764. printf("amd79c901_read_mode: Media Link Off\n");
  765. }
  766. else {
  767. /* HomePNA */
  768. *speed = HW_SPEED_HOME;
  769. *duplex = FDX_CAPABLE_HALF_SELECTED;
  770. if (status & MII_STAT_LINK)
  771. printf("amd79c901_read_mode:Media Link On 1mbps half-duplex \n");
  772. else
  773. printf("amd79c901_read_mode: Media Link Off\n");
  774. }
  775. }
  776. /**
  777. * ics1893_read_mode: - read media mode for ICS1893 PHY
  778. * @net_dev: the net device to read mode for
  779. * @phy_addr: mii phy address
  780. * @speed: the transmit speed to be determined
  781. * @duplex: the duplex mode to be determined
  782. *
  783. * ICS1893 PHY use Quick Poll Detailed Status register
  784. * to determine the speed and duplex mode for sis900
  785. */
  786. static void ics1893_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  787. {
  788. int i = 0;
  789. u32 status;
  790. /* MII_QPDSTS is Latched, read twice in succession will reflect the current state */
  791. for (i = 0; i < 2; i++)
  792. status = sis900_mdio_read(phy_addr, MII_QPDSTS);
  793. if (status & MII_STSICS_SPD)
  794. *speed = HW_SPEED_100_MBPS;
  795. else
  796. *speed = HW_SPEED_10_MBPS;
  797. if (status & MII_STSICS_DPLX)
  798. *duplex = FDX_CAPABLE_FULL_SELECTED;
  799. else
  800. *duplex = FDX_CAPABLE_HALF_SELECTED;
  801. if (status & MII_STSICS_LINKSTS)
  802. printf("ics1893_read_mode: Media Link On %s %s-duplex \n",
  803. *speed == HW_SPEED_100_MBPS ?
  804. "100mbps" : "10mbps",
  805. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  806. "full" : "half");
  807. else
  808. printf("ics1893_read_mode: Media Link Off\n");
  809. }
  810. /**
  811. * rtl8201_read_mode: - read media mode for rtl8201 phy
  812. * @nic: the net device to read mode for
  813. * @phy_addr: mii phy address
  814. * @speed: the transmit speed to be determined
  815. * @duplex: the duplex mode to be determined
  816. *
  817. * read MII_STATUS register from rtl8201 phy
  818. * to determine the speed and duplex mode for sis900
  819. */
  820. static void rtl8201_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  821. {
  822. u32 status;
  823. status = sis900_mdio_read(phy_addr, MII_STATUS);
  824. if (status & MII_STAT_CAN_TX_FDX) {
  825. *speed = HW_SPEED_100_MBPS;
  826. *duplex = FDX_CAPABLE_FULL_SELECTED;
  827. }
  828. else if (status & MII_STAT_CAN_TX) {
  829. *speed = HW_SPEED_100_MBPS;
  830. *duplex = FDX_CAPABLE_HALF_SELECTED;
  831. }
  832. else if (status & MII_STAT_CAN_T_FDX) {
  833. *speed = HW_SPEED_10_MBPS;
  834. *duplex = FDX_CAPABLE_FULL_SELECTED;
  835. }
  836. else if (status & MII_STAT_CAN_T) {
  837. *speed = HW_SPEED_10_MBPS;
  838. *duplex = FDX_CAPABLE_HALF_SELECTED;
  839. }
  840. if (status & MII_STAT_LINK)
  841. printf("rtl8201_read_mode: Media Link On %s %s-duplex \n",
  842. *speed == HW_SPEED_100_MBPS ?
  843. "100mbps" : "10mbps",
  844. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  845. "full" : "half");
  846. else
  847. printf("rtl8201_read_config_mode: Media Link Off\n");
  848. }
  849. /**
  850. * vt6103_read_mode: - read media mode for vt6103 phy
  851. * @nic: the net device to read mode for
  852. * @phy_addr: mii phy address
  853. * @speed: the transmit speed to be determined
  854. * @duplex: the duplex mode to be determined
  855. *
  856. * read MII_STATUS register from rtl8201 phy
  857. * to determine the speed and duplex mode for sis900
  858. */
  859. static void vt6103_read_mode(struct nic *nic __unused, int phy_addr, int *speed, int *duplex)
  860. {
  861. u32 status;
  862. status = sis900_mdio_read(phy_addr, MII_STATUS);
  863. if (status & MII_STAT_CAN_TX_FDX) {
  864. *speed = HW_SPEED_100_MBPS;
  865. *duplex = FDX_CAPABLE_FULL_SELECTED;
  866. }
  867. else if (status & MII_STAT_CAN_TX) {
  868. *speed = HW_SPEED_100_MBPS;
  869. *duplex = FDX_CAPABLE_HALF_SELECTED;
  870. }
  871. else if (status & MII_STAT_CAN_T_FDX) {
  872. *speed = HW_SPEED_10_MBPS;
  873. *duplex = FDX_CAPABLE_FULL_SELECTED;
  874. }
  875. else if (status & MII_STAT_CAN_T) {
  876. *speed = HW_SPEED_10_MBPS;
  877. *duplex = FDX_CAPABLE_HALF_SELECTED;
  878. }
  879. if (status & MII_STAT_LINK)
  880. printf("vt6103_read_mode: Media Link On %s %s-duplex \n",
  881. *speed == HW_SPEED_100_MBPS ?
  882. "100mbps" : "10mbps",
  883. *duplex == FDX_CAPABLE_FULL_SELECTED ?
  884. "full" : "half");
  885. else
  886. printf("vt6103_read_config_mode: Media Link Off\n");
  887. }
  888. /* Function: sis900_transmit
  889. *
  890. * Description: transmits a packet and waits for completion or timeout.
  891. *
  892. * Arguments: char d[6]: destination ethernet address.
  893. * unsigned short t: ethernet protocol type.
  894. * unsigned short s: size of the data-part of the packet.
  895. * char *p: the data for the packet.
  896. *
  897. * Returns: void.
  898. */
  899. static void
  900. sis900_transmit(struct nic *nic,
  901. const char *d, /* Destination */
  902. unsigned int t, /* Type */
  903. unsigned int s, /* size */
  904. const char *p) /* Packet */
  905. {
  906. u32 to, nstype;
  907. volatile u32 tx_status;
  908. /* Stop the transmitter */
  909. outl(TxDIS | inl(ioaddr + cr), ioaddr + cr);
  910. /* load Transmit Descriptor Register */
  911. outl(virt_to_bus(&txd), ioaddr + txdp);
  912. if (sis900_debug > 1)
  913. printf("sis900_transmit: TX descriptor register loaded with: %X\n",
  914. inl(ioaddr + txdp));
  915. memcpy(txb, d, ETH_ALEN);
  916. memcpy(txb + ETH_ALEN, nic->node_addr, ETH_ALEN);
  917. nstype = htons(t);
  918. memcpy(txb + 2 * ETH_ALEN, (char*)&nstype, 2);
  919. memcpy(txb + ETH_HLEN, p, s);
  920. s += ETH_HLEN;
  921. s &= DSIZE;
  922. if (sis900_debug > 1)
  923. printf("sis900_transmit: sending %d bytes ethtype %hX\n", (int) s, t);
  924. /* pad to minimum packet size */
  925. while (s < ETH_ZLEN)
  926. txb[s++] = '\0';
  927. /* set the transmit buffer descriptor and enable Transmit State Machine */
  928. txd.bufptr = virt_to_bus(&txb[0]);
  929. txd.cmdsts = (u32) OWN | s;
  930. /* restart the transmitter */
  931. outl(TxENA | inl(ioaddr + cr), ioaddr + cr);
  932. if (sis900_debug > 1)
  933. printf("sis900_transmit: Queued Tx packet size %d.\n", (int) s);
  934. to = currticks() + TX_TIMEOUT;
  935. while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to))
  936. /* wait */ ;
  937. if (currticks() >= to) {
  938. printf("sis900_transmit: TX Timeout! Tx status %X.\n",
  939. (unsigned int) tx_status);
  940. }
  941. if (tx_status & (ABORT | UNDERRUN | OWCOLL)) {
  942. /* packet unsuccessfully transmited */
  943. printf("sis900_transmit: Transmit error, Tx status %X.\n",
  944. (unsigned int) tx_status);
  945. }
  946. /* Disable interrupts by clearing the interrupt mask. */
  947. outl(0, ioaddr + imr);
  948. }
  949. /* Function: sis900_poll
  950. *
  951. * Description: checks for a received packet and returns it if found.
  952. *
  953. * Arguments: struct nic *nic: NIC data structure
  954. *
  955. * Returns: 1 if a packet was received.
  956. * 0 if no packet was received.
  957. *
  958. * Side effects:
  959. * Returns (copies) the packet to the array nic->packet.
  960. * Returns the length of the packet in nic->packetlen.
  961. */
  962. static int
  963. sis900_poll(struct nic *nic, int retrieve)
  964. {
  965. u32 rx_status = rxd[cur_rx].cmdsts;
  966. int retstat = 0;
  967. /* acknowledge interrupts by reading interrupt status register */
  968. inl(ioaddr + isr);
  969. if (sis900_debug > 2)
  970. printf("sis900_poll: cur_rx:%d, status:%X\n", cur_rx,
  971. (unsigned int) rx_status);
  972. if (!(rx_status & OWN))
  973. return retstat;
  974. if (sis900_debug > 1)
  975. printf("sis900_poll: got a packet: cur_rx:%d, status:%X\n",
  976. cur_rx, (unsigned int) rx_status);
  977. if ( ! retrieve ) return 1;
  978. nic->packetlen = (rx_status & DSIZE) - CRC_SIZE;
  979. if (rx_status & (ABORT|OVERRUN|TOOLONG|RUNT|RXISERR|CRCERR|FAERR)) {
  980. /* corrupted packet received */
  981. printf("sis900_poll: Corrupted packet received, buffer status = %X\n",
  982. (unsigned int) rx_status);
  983. retstat = 0;
  984. } else {
  985. /* give packet to higher level routine */
  986. memcpy(nic->packet, (rxb + cur_rx*RX_BUF_SIZE), nic->packetlen);
  987. retstat = 1;
  988. }
  989. /* return the descriptor and buffer to receive ring */
  990. rxd[cur_rx].cmdsts = RX_BUF_SIZE;
  991. rxd[cur_rx].bufptr = virt_to_bus(&rxb[cur_rx*RX_BUF_SIZE]);
  992. if (++cur_rx == NUM_RX_DESC)
  993. cur_rx = 0;
  994. /* re-enable the potentially idle receive state machine */
  995. outl(RxENA | inl(ioaddr + cr), ioaddr + cr);
  996. return retstat;
  997. }
  998. /* Function: sis900_disable
  999. *
  1000. * Description: Turns off interrupts and stops Tx and Rx engines
  1001. *
  1002. * Arguments: struct nic *nic: NIC data structure
  1003. *
  1004. * Returns: void.
  1005. */
  1006. static void
  1007. sis900_disable ( struct nic *nic ) {
  1008. sis900_init(nic);
  1009. /* Disable interrupts by clearing the interrupt mask. */
  1010. outl(0, ioaddr + imr);
  1011. outl(0, ioaddr + ier);
  1012. /* Stop the chip's Tx and Rx Status Machine */
  1013. outl(RxDIS | TxDIS | inl(ioaddr + cr), ioaddr + cr);
  1014. }
  1015. /* Function: sis900_irq
  1016. *
  1017. * Description: Enable, Disable, or Force, interrupts
  1018. *
  1019. * Arguments: struct nic *nic: NIC data structure
  1020. * irq_action_t action: Requested action
  1021. *
  1022. * Returns: void.
  1023. */
  1024. static void
  1025. sis900_irq(struct nic *nic __unused, irq_action_t action __unused)
  1026. {
  1027. switch ( action ) {
  1028. case DISABLE :
  1029. outl(0, ioaddr + imr);
  1030. break;
  1031. case ENABLE :
  1032. outl((RxSOVR|RxORN|RxERR|RxOK|TxURN|TxERR|TxIDLE), ioaddr + imr);
  1033. break;
  1034. case FORCE :
  1035. break;
  1036. }
  1037. }
  1038. static struct nic_operations sis900_operations = {
  1039. .connect = dummy_connect,
  1040. .poll = sis900_poll,
  1041. .transmit = sis900_transmit,
  1042. .irq = sis900_irq,
  1043. };
  1044. static struct pci_device_id sis900_nics[] = {
  1045. PCI_ROM(0x1039, 0x0900, "sis900", "SIS900", 0),
  1046. PCI_ROM(0x1039, 0x7016, "sis7016", "SIS7016", 0),
  1047. };
  1048. PCI_DRIVER ( sis900_driver, sis900_nics, PCI_NO_CLASS );
  1049. DRIVER ( "SIS900", nic_driver, pci_driver, sis900_driver,
  1050. sis900_probe, sis900_disable );
  1051. /*
  1052. * Local variables:
  1053. * c-basic-offset: 8
  1054. * c-indent-level: 8
  1055. * tab-width: 8
  1056. * End:
  1057. */