if_ne_pcmcia.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  1. /* $OpenBSD: if_ne_pcmcia.c,v 1.98 2015/03/14 03:38:49 jsg Exp $ */
  2. /* $NetBSD: if_ne_pcmcia.c,v 1.17 1998/08/15 19:00:04 thorpej Exp $ */
  3. /*
  4. * Copyright (c) 1997 Marc Horowitz. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by Marc Horowitz.
  17. * 4. The name of the author may not be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  21. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  22. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include <sys/param.h>
  32. #include <sys/systm.h>
  33. #include <sys/selinfo.h>
  34. #include <sys/device.h>
  35. #include <sys/socket.h>
  36. #include <net/if_types.h>
  37. #include <net/if.h>
  38. #include <net/if_media.h>
  39. #include <netinet/in.h>
  40. #include <netinet/if_ether.h>
  41. #include <machine/bus.h>
  42. #include <dev/pcmcia/pcmciareg.h>
  43. #include <dev/pcmcia/pcmciavar.h>
  44. #include <dev/pcmcia/pcmciadevs.h>
  45. #include <dev/mii/miivar.h>
  46. #include <dev/mii/mii_bitbang.h>
  47. #include <dev/ic/dp8390reg.h>
  48. #include <dev/ic/dp8390var.h>
  49. #include <dev/ic/ne2000reg.h>
  50. #include <dev/ic/ne2000var.h>
  51. #include <dev/ic/dl10019var.h>
  52. #include <dev/ic/rtl80x9reg.h>
  53. #include <dev/ic/rtl80x9var.h>
  54. #include <dev/ic/ax88190reg.h>
  55. #include <dev/ic/ax88190var.h>
  56. int ne_pcmcia_match(struct device *, void *, void *);
  57. void ne_pcmcia_attach(struct device *, struct device *, void *);
  58. int ne_pcmcia_detach(struct device *, int);
  59. int ne_pcmcia_activate(struct device *, int);
  60. int ne_pcmcia_enable(struct dp8390_softc *);
  61. void ne_pcmcia_disable(struct dp8390_softc *);
  62. struct ne_pcmcia_softc {
  63. struct ne2000_softc sc_ne2000; /* real "ne2000" softc */
  64. /* PCMCIA-specific goo */
  65. struct pcmcia_io_handle sc_pcioh; /* PCMCIA i/o information */
  66. int sc_asic_io_window; /* i/o window for ASIC */
  67. int sc_nic_io_window; /* i/o window for NIC */
  68. struct pcmcia_function *sc_pf; /* our PCMCIA function */
  69. void *sc_ih; /* interrupt handle */
  70. };
  71. u_int8_t *
  72. ne_pcmcia_get_enaddr(struct ne_pcmcia_softc *, int,
  73. u_int8_t[ETHER_ADDR_LEN]);
  74. u_int8_t *
  75. ne_pcmcia_dl10019_get_enaddr(struct ne_pcmcia_softc *,
  76. u_int8_t[ETHER_ADDR_LEN]);
  77. int ne_pcmcia_ax88190_set_iobase(struct ne_pcmcia_softc *);
  78. struct cfattach ne_pcmcia_ca = {
  79. sizeof(struct ne_pcmcia_softc), ne_pcmcia_match, ne_pcmcia_attach,
  80. ne_pcmcia_detach, ne_pcmcia_activate
  81. };
  82. const struct ne2000dev {
  83. u_int16_t manufacturer;
  84. u_int16_t product;
  85. char *cis_info[4];
  86. int function;
  87. int enet_maddr;
  88. unsigned char enet_vendor[3];
  89. int flags;
  90. #define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */
  91. } ne2000devs[] = {
  92. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  93. PCMCIA_CIS_AMBICOM_AMB8002T,
  94. 0, -1, { 0x00, 0x10, 0x7a } },
  95. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  96. PCMCIA_CIS_PREMAX_PE200,
  97. 0, 0x07f0, { 0x00, 0x20, 0xe0 } },
  98. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  99. PCMCIA_CIS_DIGITAL_DEPCMXX,
  100. 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
  101. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  102. PCMCIA_CIS_PLANET_SMARTCOM2000,
  103. 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
  104. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  105. PCMCIA_CIS_DLINK_DE660,
  106. 0, -1, { 0x00, 0x80, 0xc8 } },
  107. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  108. PCMCIA_CIS_DLINK_DE660PLUS,
  109. 0, -1, { 0x00, 0x80, 0xc8 } },
  110. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  111. PCMCIA_CIS_RPTI_EP400,
  112. 0, -1, { 0x00, 0x40, 0x95 } },
  113. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  114. PCMCIA_CIS_RPTI_EP401,
  115. 0, -1, { 0x00, 0x40, 0x95 } },
  116. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  117. PCMCIA_CIS_ACCTON_EN2212,
  118. 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
  119. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  120. PCMCIA_CIS_ADDTRON_W89C926,
  121. 0, -1, { 0x00, 0x40, 0x33 } },
  122. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  123. PCMCIA_CIS_SVEC_COMBOCARD,
  124. 0, -1, { 0x00, 0xe0, 0x98 } },
  125. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  126. PCMCIA_CIS_SVEC_LANCARD,
  127. 0, 0x07f0, { 0x00, 0xc0, 0x6c } },
  128. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_EPSON_EEN10B,
  129. PCMCIA_CIS_EPSON_EEN10B,
  130. 0, 0x0ff0, { 0x00, 0x00, 0x48 } },
  131. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  132. PCMCIA_CIS_EDIMAX_NE2000,
  133. 0, -1, { 0x00, 0x00, 0xb4 } },
  134. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  135. PCMCIA_CIS_CNET_NE2000,
  136. 0, -1, { 0x00, 0x80, 0xad } },
  137. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_CNET_CNF301,
  138. PCMCIA_CIS_CNET_CNF301,
  139. 0, -1, { 0x00, 0x10, 0x60 } },
  140. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  141. PCMCIA_CIS_BILLIONTON_LNT10TN,
  142. 0, -1, { 0x00, 0x00, 0x00 } },
  143. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  144. PCMCIA_CIS_NDC_ND5100_E,
  145. 0, -1, { 0x00, 0x80, 0xc6 } },
  146. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  147. PCMCIA_CIS_SYNERGY21_S21810,
  148. 0, -1, { 0x00, 0x48, 0x54 } },
  149. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  150. PCMCIA_CIS_TAMARACK_NE2000,
  151. 0, -1, { 0x00, 0x47, 0x43 } },
  152. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  153. PCMCIA_CIS_GVC_NIC2000P,
  154. 0, 0x0ff0, { 0x00, 0x00, 0xe8 } },
  155. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  156. PCMCIA_CIS_WISECOM_T210CT,
  157. 0, -1, { 0x00, 0x20, 0x18 } },
  158. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  159. PCMCIA_CIS_WISECOM_IPORT,
  160. 0, -1, { 0x00, 0x02, 0xdd } },
  161. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  162. PCMCIA_CIS_AROWANA_FE,
  163. 0, -1, { 0x00, 0x48, 0x54 }, NE2000DVF_AX88190 },
  164. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  165. PCMCIA_CIS_GVC_NP0335,
  166. 0, -1, { 0x00, 0x40, 0x05 } },
  167. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  168. PCMCIA_CIS_RELIA_RE2408T,
  169. 0, -1, { 0x00, 0xc0, 0x0c } },
  170. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  171. PCMCIA_CIS_BILLIONTON_CFLT2,
  172. 0, -1, { 0x00, 0x10, 0x60 } },
  173. /*
  174. * You have to add new entries which contains
  175. * PCMCIA_VENDOR_INVALID and/or PCMCIA_PRODUCT_INVALID
  176. * in front of this comment.
  177. *
  178. * There are cards which use a generic vendor and product id but needs
  179. * a different handling depending on the cis_info, so ne2000_match
  180. * needs a table where the exceptions comes first and then the normal
  181. * product and vendor entries.
  182. */
  183. { PCMCIA_VENDOR_GREYCELL, PCMCIA_PRODUCT_GREYCELL_GCS2000,
  184. PCMCIA_CIS_GREYCELL_GCS2000,
  185. 0, -1, { 0x00, 0x47, 0x43 } },
  186. { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
  187. PCMCIA_CIS_IBM_INFOMOVER,
  188. 0, 0x0ff0, { 0x08, 0x00, 0x5a } },
  189. { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
  190. PCMCIA_CIS_IBM_INFOMOVER,
  191. 0, 0x0ff0, { 0x00, 0x04, 0xac } },
  192. { PCMCIA_VENDOR_IBM, PCMCIA_PRODUCT_IBM_INFOMOVER,
  193. PCMCIA_CIS_IBM_INFOMOVER,
  194. 0, 0x0ff0, { 0x00, 0x06, 0x29 } },
  195. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ECARD_1,
  196. PCMCIA_CIS_LINKSYS_ECARD_1,
  197. 0, -1, { 0x00, 0x80, 0xc8 } },
  198. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_PCM100,
  199. PCMCIA_CIS_LINKSYS_PCM100,
  200. 0, -1, { 0x00, 0x04, 0x5a } },
  201. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  202. PCMCIA_CIS_LINKSYS_COMBO_ECARD,
  203. 0, -1, { 0x00, 0x04, 0x5a }, NE2000DVF_AX88190 },
  204. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  205. PCMCIA_CIS_LINKSYS_COMBO_ECARD,
  206. 0, -1, { 0x00, 0x80, 0xc8 } },
  207. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  208. PCMCIA_CIS_PLANEX_FNW3600T,
  209. 0, -1, { 0x00, 0x90, 0xcc } },
  210. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  211. PCMCIA_CIS_SVEC_PN650TX,
  212. 0, -1, { 0x00, 0xe0, 0x98 } },
  213. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  214. PCMCIA_CIS_TRENDNET_TECF100,
  215. 0, -1, { 0x00, 0x12, 0x0e } },
  216. /*
  217. * This entry should be here so that above two cards doesn't
  218. * match with this. FNW-3700T won't match above entries due to
  219. * MAC address check.
  220. */
  221. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_COMBO_ECARD,
  222. PCMCIA_CIS_PLANEX_FNW3700T,
  223. 0, -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 },
  224. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
  225. PCMCIA_CIS_LINKSYS_ETHERFAST,
  226. 0, -1, { 0x00, 0x80, 0xc8 } },
  227. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
  228. PCMCIA_CIS_LINKSYS_ETHERFAST,
  229. 0, -1, { 0x00, 0x50, 0xba } },
  230. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
  231. PCMCIA_CIS_DLINK_DE650,
  232. 0, -1, { 0x00, 0xe0, 0x98 } },
  233. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_ETHERFAST,
  234. PCMCIA_CIS_IODATA_PCETTXR,
  235. 0, -1, { 0x00, 0xa0, 0xb0 } },
  236. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  237. PCMCIA_CIS_DLINK_DFE670TXD,
  238. 0, -1, { 0x00, 0x05, 0x5d } },
  239. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  240. PCMCIA_CIS_DLINK_DFE670TXD,
  241. 0, -1, { 0x00, 0x50, 0xba } },
  242. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  243. PCMCIA_CIS_DLINK_DFE670TXD,
  244. 0, -1, { 0x00, 0x0d, 0x88 } },
  245. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  246. PCMCIA_CIS_DLINK_DFE670TXD,
  247. 0, -1, { 0x00, 0x13, 0x46 } },
  248. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  249. PCMCIA_CIS_DLINK_DFE670TXD,
  250. 0, -1, { 0x00, 0x40, 0x05 } },
  251. { PCMCIA_VENDOR_LINKSYS, PCMCIA_PRODUCT_LINKSYS_TRUST_COMBO_ECARD,
  252. PCMCIA_CIS_LINKSYS_TRUST_COMBO_ECARD,
  253. 0, 0x0120, { 0x20, 0x04, 0x49 } },
  254. /* Although the comments above say to put VENDOR/PRODUCT INVALID IDs
  255. above this list, we need to keep this one below the ECARD_1, or else
  256. both will match the same more-generic entry rather than the more
  257. specific one above with proper vendor and product IDs. */
  258. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  259. PCMCIA_CIS_LINKSYS_ECARD_2,
  260. 0, -1, { 0x00, 0x80, 0xc8 } },
  261. /*
  262. * D-Link DE-650 has many minor versions:
  263. *
  264. * CIS information Manufacturer Product Note
  265. * 1 "D-Link, DE-650" INVALID INVALID white card
  266. * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal
  267. * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor change in look
  268. * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added
  269. *
  270. * While the 1st and the 2nd types should use the "D-Link DE-650" entry,
  271. * the 3rd and the 4th types should use the "Linksys EtherCard" entry.
  272. * Therefore, this entry must be below the LINKSYS_ECARD_1. --itohy
  273. */
  274. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  275. PCMCIA_CIS_DLINK_DE650,
  276. 0, 0x0040, { 0x00, 0x80, 0xc8 } },
  277. /*
  278. * IO-DATA PCLA/TE and later version of PCLA/T has valid
  279. * vendor/product ID and it is possible to read MAC address
  280. * using standard I/O ports. It also read from CIS offset 0x01c0.
  281. * On the other hand, earlier version of PCLA/T doesn't have valid
  282. * vendor/product ID and MAC address must be read from CIS offset
  283. * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work).
  284. * And CIS information of earlier and later version of PCLA/T are
  285. * same except fourth element. So, for now, we place the entry for
  286. * PCLA/TE (and later version of PCLA/T) followed by entry
  287. * for the earlier version of PCLA/T (or, modify to match all CIS
  288. * information and have three or more individual entries).
  289. */
  290. { PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_PCLATE,
  291. PCMCIA_CIS_IODATA_PCLATE,
  292. 0, -1, { 0x00, 0xa0, 0xb0 } },
  293. /*
  294. * This entry should be placed after above PCLA-TE entry.
  295. * See above comments for detail.
  296. */
  297. { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
  298. PCMCIA_CIS_IODATA_PCLAT,
  299. 0, 0x0ff0, { 0x00, 0xa0, 0xb0 } },
  300. { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_1,
  301. PCMCIA_CIS_DAYNA_COMMUNICARD_E_1,
  302. 0, 0x0110, { 0x00, 0x80, 0x19 } },
  303. { PCMCIA_VENDOR_DAYNA, PCMCIA_PRODUCT_DAYNA_COMMUNICARD_E_2,
  304. PCMCIA_CIS_DAYNA_COMMUNICARD_E_2,
  305. 0, -1, { 0x00, 0x80, 0x19 } },
  306. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_T,
  307. PCMCIA_CIS_COREGA_ETHER_PCC_T,
  308. 0, -1, { 0x00, 0x00, 0xf4 } },
  309. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_PCC_TD,
  310. PCMCIA_CIS_COREGA_ETHER_PCC_TD,
  311. 0, -1, { 0x00, 0x00, 0xf4 } },
  312. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_T,
  313. PCMCIA_CIS_COREGA_ETHER_II_PCC_T,
  314. 0, -1, { 0x00, 0x00, 0xf4 } },
  315. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_ETHER_II_PCC_TD,
  316. PCMCIA_CIS_COREGA_ETHER_II_PCC_TD,
  317. 0, -1, { 0x00, 0x00, 0xf4 } },
  318. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FAST_ETHER_PCC_TX,
  319. PCMCIA_CIS_COREGA_FAST_ETHER_PCC_TX,
  320. 0, -1, { 0x00, 0x00, 0xf4 } },
  321. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXF,
  322. PCMCIA_CIS_COREGA_FETHER_PCC_TXF,
  323. 0, -1, { 0x00, 0x90, 0x99 } },
  324. { PCMCIA_VENDOR_COREGA, PCMCIA_PRODUCT_COREGA_FETHER_PCC_TXD,
  325. PCMCIA_CIS_COREGA_FETHER_PCC_TXD,
  326. 0, -1, { 0x00, 0x90, 0x99 } },
  327. { PCMCIA_VENDOR_COMPEX, PCMCIA_PRODUCT_COMPEX_LINKPORT_ENET_B,
  328. PCMCIA_CIS_COMPEX_LINKPORT_ENET_B,
  329. 0, 0x01c0, { 0x00, 0xa0, 0x0c } },
  330. { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_EZCARD,
  331. PCMCIA_CIS_SMC_EZCARD,
  332. 0, 0x01c0, { 0x00, 0xe0, 0x29 } },
  333. { PCMCIA_VENDOR_IODATA, PCMCIA_PRODUCT_IODATA_8041TX,
  334. PCMCIA_CIS_IODATA_8041TX,
  335. 0, -1, { 0x00, 0x04, 0xe2 } },
  336. { PCMCIA_VENDOR_SMC, PCMCIA_PRODUCT_SMC_8041,
  337. PCMCIA_CIS_SMC_8041,
  338. 0, -1, { 0x00, 0x04, 0xe2 } },
  339. { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER_CF,
  340. PCMCIA_CIS_SOCKET_LP_ETHER_CF,
  341. 0, -1, { 0x00, 0xc0, 0x1b} },
  342. { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_LP_ETHER,
  343. PCMCIA_CIS_SOCKET_LP_ETHER,
  344. 0, -1, { 0x00, 0xc0, 0x1b } },
  345. { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_ETHER_CF_10_100,
  346. PCMCIA_CIS_SOCKET_ETHER_CF_10_100,
  347. 0, -1, { 0x00, 0x12, 0x0e } },
  348. { PCMCIA_VENDOR_SOCKET, PCMCIA_PRODUCT_SOCKET_ETHER_CF_10_100,
  349. PCMCIA_CIS_SOCKET_ETHER_CF_10_100,
  350. 0, -1, { 0x00, 0xe0, 0x98 } },
  351. { PCMCIA_VENDOR_XIRCOM, PCMCIA_PRODUCT_XIRCOM_CFE_10,
  352. PCMCIA_CIS_XIRCOM_CFE_10,
  353. 0, -1, { 0x00, 0x10, 0xa4 } },
  354. { PCMCIA_VENDOR_MELCO, PCMCIA_PRODUCT_MELCO_LPC3_TX,
  355. PCMCIA_CIS_MELCO_LPC3_TX,
  356. 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
  357. { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC_CF_CLT,
  358. PCMCIA_CIS_INVALID,
  359. 0, -1, { 0x00, 0x07, 0x40 } },
  360. { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC3_CLT,
  361. PCMCIA_CIS_INVALID,
  362. 0, -1, { 0x00, 0x07, 0x40 } },
  363. { PCMCIA_VENDOR_BUFFALO, PCMCIA_PRODUCT_BUFFALO_LPC4_CLX,
  364. PCMCIA_CIS_INVALID,
  365. 0, -1, { 0x00, 0x40, 0xfa }, NE2000DVF_AX88190 },
  366. { PCMCIA_VENDOR_DUAL, PCMCIA_PRODUCT_DUAL_NE2000,
  367. PCMCIA_CIS_DUAL_NE2000,
  368. 0, 0x0ff0, { 0x00, 0xa0, 0x0c } },
  369. { PCMCIA_VENDOR_ALLIEDTELESIS, PCMCIA_PRODUCT_ALLIEDTELESIS_LA_PCM,
  370. PCMCIA_CIS_ALLIEDTELESIS_LA_PCM,
  371. 0, 0x0ff0, { 0x00, 0x00, 0xf4 } },
  372. { PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE_PCM,
  373. PCMCIA_CIS_KINGSTON_KNE_PCM,
  374. 0, 0x0ff0, { 0xe2, 0x0c, 0x0f } },
  375. { PCMCIA_VENDOR_KINGSTON, PCMCIA_PRODUCT_KINGSTON_KNE_PC2,
  376. PCMCIA_CIS_KINGSTON_KNE_PC2,
  377. 0, 0x0180, { 0x00, 0xc0, 0xf0 } },
  378. { PCMCIA_VENDOR_TELECOMDEVICE, PCMCIA_PRODUCT_TELECOMDEVICE_TCD_HPC100,
  379. PCMCIA_CIS_TELECOMDEVICE_TCD_HPC100,
  380. 0, -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
  381. { PCMCIA_VENDOR_MACNICA, PCMCIA_PRODUCT_MACNICA_ME1_JEIDA,
  382. PCMCIA_CIS_MACNICA_ME1_JEIDA,
  383. 0, 0x00b8, { 0x08, 0x00, 0x42 } },
  384. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  385. PCMCIA_CIS_NETGEAR_FA410TXC,
  386. 0, -1, { 0x00, 0x40, 0xf4 } },
  387. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  388. PCMCIA_CIS_NETGEAR_FA410TXC,
  389. 0, -1, { 0x00, 0x48, 0x54 } },
  390. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  391. PCMCIA_CIS_DLINK_DFE670TXD,
  392. 0, -1, { 0x00, 0x40, 0x05 } },
  393. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  394. PCMCIA_CIS_DLINK_DFE670TXD,
  395. 0, -1, { 0x00, 0x11, 0x95 } },
  396. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA410TXC,
  397. PCMCIA_CIS_DLINK_DFE670TXD,
  398. 0, -1, { 0x00, 0x0d, 0x88 } },
  399. { PCMCIA_VENDOR_NETGEAR, PCMCIA_PRODUCT_NETGEAR_FA411,
  400. PCMCIA_CIS_NETGEAR_FA411,
  401. 0, -1, { 0x00, 0x40, 0xf4 } },
  402. { PCMCIA_VENDOR_BELKIN, PCMCIA_PRODUCT_BELKIN_F5D5020,
  403. PCMCIA_CIS_BELKIN_F5D5020,
  404. 0, -1, { 0x00, 0x30, 0xbd } },
  405. #if 0
  406. /* the rest of these are stolen from the linux pcnet pcmcia device
  407. driver. Since I don't know the manfid or cis info strings for
  408. any of them, they're not compiled in until I do. */
  409. { "APEX MultiCard",
  410. 0x0000, 0x0000, NULL, NULL, 0,
  411. 0x03f4, { 0x00, 0x20, 0xe5 } },
  412. { "ASANTE FriendlyNet",
  413. 0x0000, 0x0000, NULL, NULL, 0,
  414. 0x4910, { 0x00, 0x00, 0x94 } },
  415. { "Danpex EN-6200P2",
  416. 0x0000, 0x0000, NULL, NULL, 0,
  417. 0x0110, { 0x00, 0x40, 0xc7 } },
  418. { "DataTrek NetCard",
  419. 0x0000, 0x0000, NULL, NULL, 0,
  420. 0x0ff0, { 0x00, 0x20, 0xe8 } },
  421. { "EP-210 Ethernet",
  422. 0x0000, 0x0000, NULL, NULL, 0,
  423. 0x0110, { 0x00, 0x40, 0x33 } },
  424. { "ELECOM Laneed LD-CDWA",
  425. 0x0000, 0x0000, NULL, NULL, 0,
  426. 0x00b8, { 0x08, 0x00, 0x42 } },
  427. { "Grey Cell GCS2220",
  428. 0x0000, 0x0000, NULL, NULL, 0,
  429. 0x0000, { 0x00, 0x47, 0x43 } },
  430. { "Hypertec Ethernet",
  431. 0x0000, 0x0000, NULL, NULL, 0,
  432. 0x01c0, { 0x00, 0x40, 0x4c } },
  433. { "IBM FME",
  434. 0x0000, 0x0000, NULL, NULL, 0,
  435. 0x0374, { 0x00, 0x04, 0xac } },
  436. { "IBM FME",
  437. 0x0000, 0x0000, NULL, NULL, 0,
  438. 0x0374, { 0x08, 0x00, 0x5a } },
  439. { "Katron PE-520",
  440. 0x0000, 0x0000, NULL, NULL, 0,
  441. 0x0110, { 0x00, 0x40, 0xf6 } },
  442. { "Kingston KNE-PCM/x",
  443. 0x0000, 0x0000, NULL, NULL, 0,
  444. 0x0ff0, { 0x00, 0xc0, 0xf0 } },
  445. { "Longshine LCS-8534",
  446. 0x0000, 0x0000, NULL, NULL, 0,
  447. 0x0000, { 0x08, 0x00, 0x00 } },
  448. { "Maxtech PCN2000",
  449. 0x0000, 0x0000, NULL, NULL, 0,
  450. 0x5000, { 0x00, 0x00, 0xe8 } },
  451. { "NDC Instant-Link",
  452. 0x0000, 0x0000, NULL, NULL, 0,
  453. 0x003a, { 0x00, 0x80, 0xc6 } },
  454. { "Network General Sniffer",
  455. 0x0000, 0x0000, NULL, NULL, 0,
  456. 0x0ff0, { 0x00, 0x00, 0x65 } },
  457. { "Panasonic VEL211",
  458. 0x0000, 0x0000, NULL, NULL, 0,
  459. 0x0ff0, { 0x00, 0x80, 0x45 } },
  460. { "SCM Ethernet",
  461. 0x0000, 0x0000, NULL, NULL, 0,
  462. 0x0ff0, { 0x00, 0x20, 0xcb } },
  463. { "Socket EA",
  464. 0x0000, 0x0000, NULL, NULL, 0,
  465. 0x4000, { 0x00, 0xc0, 0x1b } },
  466. { "Volktek NPL-402CT",
  467. 0x0000, 0x0000, NULL, NULL, 0,
  468. 0x0060, { 0x00, 0x40, 0x05 } },
  469. #endif
  470. };
  471. #define NE2000_NDEVS (sizeof(ne2000devs) / sizeof(ne2000devs[0]))
  472. #define ne2000_match(card, fct, n) \
  473. ((((((card)->manufacturer != PCMCIA_VENDOR_INVALID) && \
  474. ((card)->manufacturer == ne2000devs[(n)].manufacturer) && \
  475. ((card)->product != PCMCIA_PRODUCT_INVALID) && \
  476. ((card)->product == ne2000devs[(n)].product)) || \
  477. ((ne2000devs[(n)].cis_info[0]) && (ne2000devs[(n)].cis_info[1]) && \
  478. ((card)->cis1_info[0]) && ((card)->cis1_info[1]) && \
  479. (strcmp((card)->cis1_info[0], ne2000devs[(n)].cis_info[0]) == 0) && \
  480. (strcmp((card)->cis1_info[1], ne2000devs[(n)].cis_info[1]) == 0))) && \
  481. ((fct) == ne2000devs[(n)].function))? \
  482. &ne2000devs[(n)]:NULL)
  483. int
  484. ne_pcmcia_match(parent, match, aux)
  485. struct device *parent;
  486. void *match, *aux;
  487. {
  488. struct pcmcia_attach_args *pa = aux;
  489. int i;
  490. for (i = 0; i < NE2000_NDEVS; i++) {
  491. if (ne2000_match(pa->card, pa->pf->number, i))
  492. return (1);
  493. }
  494. return (0);
  495. }
  496. void
  497. ne_pcmcia_attach(parent, self, aux)
  498. struct device *parent, *self;
  499. void *aux;
  500. {
  501. struct ne_pcmcia_softc *psc = (void *) self;
  502. struct ne2000_softc *nsc = &psc->sc_ne2000;
  503. struct dp8390_softc *dsc = &nsc->sc_dp8390;
  504. struct pcmcia_attach_args *pa = aux;
  505. struct pcmcia_config_entry *cfe;
  506. const struct ne2000dev *ne_dev;
  507. const char *intrstr;
  508. int i;
  509. u_int8_t myea[6], *enaddr;
  510. psc->sc_pf = pa->pf;
  511. for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
  512. cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
  513. #if 0
  514. /*
  515. * Some ne2000 driver's claim to have memory; others don't.
  516. * Since I don't care, I don't check.
  517. */
  518. if (cfe->num_memspace != 1) {
  519. printf(": unexpected number of memory spaces, "
  520. " %d should be 1\n", cfe->num_memspace);
  521. return;
  522. }
  523. #endif
  524. if (cfe->num_iospace == 1) {
  525. if (cfe->iospace[0].length != NE2000_NPORTS) {
  526. printf(": unexpected I/O space "
  527. "configuration\n");
  528. continue;
  529. }
  530. } else if (cfe->num_iospace == 2) {
  531. /*
  532. * Some cards report a separate space for NIC and ASIC.
  533. * This make some sense, but we must allocate a single
  534. * NE2000_NPORTS-sized chunk, due to brain damaged
  535. * address decoders on some of these cards.
  536. */
  537. if (cfe->iospace[0].length + cfe->iospace[1].length !=
  538. NE2000_NPORTS) {
  539. #ifdef DIAGNOSTIC
  540. printf(": unexpected I/O space "
  541. "configuration\n");
  542. #endif
  543. continue;
  544. }
  545. } else {
  546. #ifdef DIAGNOSTIC
  547. printf(": unexpected number of i/o spaces %d"
  548. " should be 1 or 2\n", cfe->num_iospace);
  549. #endif
  550. continue;
  551. }
  552. if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
  553. NE2000_NPORTS, NE2000_NPORTS, &psc->sc_pcioh)) {
  554. #ifdef DIAGNOSTIC
  555. printf(": can't allocate I/O space\n");
  556. #endif
  557. continue;
  558. }
  559. break;
  560. }
  561. if (cfe == NULL) {
  562. printf(": no suitable config entry\n");
  563. goto fail_1;
  564. }
  565. dsc->sc_regt = psc->sc_pcioh.iot;
  566. dsc->sc_regh = psc->sc_pcioh.ioh;
  567. nsc->sc_asict = psc->sc_pcioh.iot;
  568. if (bus_space_subregion(dsc->sc_regt, dsc->sc_regh,
  569. NE2000_ASIC_OFFSET, NE2000_ASIC_NPORTS, &nsc->sc_asich)) {
  570. printf(": can't get subregion for asic\n");
  571. goto fail_2;
  572. }
  573. #ifdef notyet
  574. /* Set up power management hooks. */
  575. dsc->sc_enable = ne_pcmcia_enable;
  576. dsc->sc_disable = ne_pcmcia_disable;
  577. #endif
  578. /* Enable the card. */
  579. pcmcia_function_init(pa->pf, cfe);
  580. if (pcmcia_function_enable(pa->pf)) {
  581. printf(": function enable failed\n");
  582. goto fail_2;
  583. }
  584. dsc->sc_enabled = 1;
  585. /* some cards claim to be io16, but they're lying. */
  586. if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO8, NE2000_NIC_OFFSET,
  587. NE2000_NIC_NPORTS, &psc->sc_pcioh, &psc->sc_nic_io_window)) {
  588. printf(": can't map NIC I/O space\n");
  589. goto fail_3;
  590. }
  591. if (pcmcia_io_map(pa->pf, PCMCIA_WIDTH_IO16, NE2000_ASIC_OFFSET,
  592. NE2000_ASIC_NPORTS, &psc->sc_pcioh, &psc->sc_asic_io_window)) {
  593. printf(": can't map ASIC I/O space\n");
  594. goto fail_4;
  595. }
  596. printf(" port 0x%lx/%d", psc->sc_pcioh.addr, NE2000_NPORTS);
  597. /*
  598. * Read the station address from the board.
  599. */
  600. i = 0;
  601. again:
  602. enaddr = NULL; /* Ask ASIC by default */
  603. for (; i < NE2000_NDEVS; i++) {
  604. ne_dev = ne2000_match(pa->card, pa->pf->number, i);
  605. if (ne_dev != NULL) {
  606. if (ne_dev->enet_maddr >= 0) {
  607. enaddr = ne_pcmcia_get_enaddr(psc,
  608. ne_dev->enet_maddr, myea);
  609. if (enaddr == NULL)
  610. continue;
  611. } else {
  612. enaddr = ne_pcmcia_dl10019_get_enaddr(psc,
  613. myea);
  614. }
  615. break;
  616. }
  617. }
  618. if (i == NE2000_NDEVS) {
  619. printf(": can't match ethernet vendor code\n");
  620. goto fail_5;
  621. }
  622. if (enaddr != NULL) {
  623. /*
  624. * Make sure this is what we expect.
  625. */
  626. if (enaddr[0] != ne_dev->enet_vendor[0] ||
  627. enaddr[1] != ne_dev->enet_vendor[1] ||
  628. enaddr[2] != ne_dev->enet_vendor[2]) {
  629. ++i;
  630. goto again;
  631. }
  632. }
  633. if ((ne_dev->flags & NE2000DVF_AX88190) != 0) {
  634. if (ne_pcmcia_ax88190_set_iobase(psc))
  635. goto fail_5;
  636. dsc->sc_mediachange = ax88190_mediachange;
  637. dsc->sc_mediastatus = ax88190_mediastatus;
  638. dsc->init_card = ax88190_init_card;
  639. dsc->stop_card = ax88190_stop_card;
  640. dsc->sc_media_init = ax88190_media_init;
  641. dsc->sc_media_fini = ax88190_media_fini;
  642. nsc->sc_type = NE2000_TYPE_AX88190;
  643. }
  644. /*
  645. * Check for a Realtek 8019.
  646. */
  647. bus_space_write_1(dsc->sc_regt, dsc->sc_regh, ED_P0_CR,
  648. ED_CR_PAGE_0 | ED_CR_STP);
  649. if (bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID0)
  650. == RTL0_8019ID0 &&
  651. bus_space_read_1(dsc->sc_regt, dsc->sc_regh, NERTL_RTL0_8019ID1)
  652. == RTL0_8019ID1) {
  653. dsc->sc_mediachange = rtl80x9_mediachange;
  654. dsc->sc_mediastatus = rtl80x9_mediastatus;
  655. dsc->init_card = rtl80x9_init_card;
  656. dsc->sc_media_init = rtl80x9_media_init;
  657. }
  658. if (nsc->sc_type == NE2000_TYPE_DL10019 ||
  659. nsc->sc_type == NE2000_TYPE_DL10022) {
  660. dsc->sc_mediachange = dl10019_mediachange;
  661. dsc->sc_mediastatus = dl10019_mediastatus;
  662. dsc->init_card = dl10019_init_card;
  663. dsc->stop_card = dl10019_stop_card;
  664. dsc->sc_media_init = dl10019_media_init;
  665. dsc->sc_media_fini = dl10019_media_fini;
  666. }
  667. /* set up the interrupt */
  668. psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
  669. dsc, dsc->sc_dev.dv_xname);
  670. intrstr = pcmcia_intr_string(psc->sc_pf, psc->sc_ih);
  671. if (*intrstr)
  672. printf(", %s", intrstr);
  673. if (ne2000_attach(nsc, enaddr))
  674. goto fail_5;
  675. #if notyet
  676. pcmcia_function_disable(pa->pf);
  677. #endif
  678. return;
  679. fail_5:
  680. /* Unmap ASIC I/O windows. */
  681. pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
  682. fail_4:
  683. /* Unmap NIC I/O windows. */
  684. pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
  685. fail_3:
  686. pcmcia_function_disable(pa->pf);
  687. fail_2:
  688. /* Free our I/O space. */
  689. pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
  690. fail_1:
  691. psc->sc_nic_io_window = -1;
  692. }
  693. int
  694. ne_pcmcia_detach(dev, flags)
  695. struct device *dev;
  696. int flags;
  697. {
  698. struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dev;
  699. int error;
  700. if (psc->sc_nic_io_window == -1)
  701. /* Nothing to detach. */
  702. return (0);
  703. error = ne2000_detach(&psc->sc_ne2000, flags);
  704. if (error != 0)
  705. return (error);
  706. /* Unmap our i/o windows. */
  707. pcmcia_io_unmap(psc->sc_pf, psc->sc_asic_io_window);
  708. pcmcia_io_unmap(psc->sc_pf, psc->sc_nic_io_window);
  709. /* Free our i/o space. */
  710. pcmcia_io_free(psc->sc_pf, &psc->sc_pcioh);
  711. return (0);
  712. }
  713. int
  714. ne_pcmcia_activate(dev, act)
  715. struct device *dev;
  716. int act;
  717. {
  718. struct ne_pcmcia_softc *sc = (struct ne_pcmcia_softc *)dev;
  719. struct dp8390_softc *esc = &sc->sc_ne2000.sc_dp8390;
  720. struct ifnet *ifp = &esc->sc_arpcom.ac_if;
  721. switch (act) {
  722. case DVACT_SUSPEND:
  723. ifp->if_timer = 0;
  724. if (ifp->if_flags & IFF_RUNNING) {
  725. dp8390_stop(esc);
  726. ifp->if_flags &= ~IFF_RUNNING;
  727. }
  728. if (sc->sc_ih != NULL)
  729. pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
  730. sc->sc_ih = NULL;
  731. pcmcia_function_disable(sc->sc_pf);
  732. break;
  733. case DVACT_RESUME:
  734. pcmcia_function_enable(sc->sc_pf);
  735. sc->sc_ih = pcmcia_intr_establish(sc->sc_pf, IPL_NET,
  736. dp8390_intr, sc, esc->sc_dev.dv_xname);
  737. dp8390_enable(esc);
  738. if (ifp->if_flags & IFF_UP)
  739. dp8390_init(esc);
  740. break;
  741. case DVACT_DEACTIVATE:
  742. ifp->if_timer = 0;
  743. if (ifp->if_flags & IFF_RUNNING) {
  744. dp8390_stop(esc);
  745. ifp->if_flags &= ~IFF_RUNNING;
  746. }
  747. if (sc->sc_ih != NULL)
  748. pcmcia_intr_disestablish(sc->sc_pf, sc->sc_ih);
  749. sc->sc_ih = NULL;
  750. pcmcia_function_disable(sc->sc_pf);
  751. break;
  752. }
  753. return (0);
  754. }
  755. #ifdef notyet
  756. int
  757. ne_pcmcia_enable(dsc)
  758. struct dp8390_softc *dsc;
  759. {
  760. struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
  761. /* set up the interrupt */
  762. psc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, dp8390_intr,
  763. dsc, dsc->sc_dev.dv_xname);
  764. if (psc->sc_ih == NULL) {
  765. printf("%s: couldn't establish interrupt\n",
  766. dsc->sc_dev.dv_xname);
  767. return (1);
  768. }
  769. return (pcmcia_function_enable(psc->sc_pf));
  770. }
  771. void
  772. ne_pcmcia_disable(dsc)
  773. struct dp8390_softc *dsc;
  774. {
  775. struct ne_pcmcia_softc *psc = (struct ne_pcmcia_softc *)dsc;
  776. pcmcia_intr_disestablish(psc->sc_pf, psc->sc_ih);
  777. pcmcia_function_disable(psc->sc_pf);
  778. }
  779. #endif
  780. u_int8_t *
  781. ne_pcmcia_get_enaddr(psc, maddr, myea)
  782. struct ne_pcmcia_softc *psc;
  783. int maddr;
  784. u_int8_t myea[ETHER_ADDR_LEN];
  785. {
  786. struct ne2000_softc *nsc = &psc->sc_ne2000;
  787. struct dp8390_softc *dsc = &nsc->sc_dp8390;
  788. struct pcmcia_mem_handle pcmh;
  789. bus_size_t offset;
  790. u_int8_t *enaddr = NULL;
  791. int j, mwindow;
  792. if (maddr < 0)
  793. return (NULL);
  794. if (pcmcia_mem_alloc(psc->sc_pf, ETHER_ADDR_LEN * 2, &pcmh)) {
  795. printf("%s: can't alloc mem for enet addr\n",
  796. dsc->sc_dev.dv_xname);
  797. goto fail_1;
  798. }
  799. if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR, maddr,
  800. ETHER_ADDR_LEN * 2, &pcmh, &offset, &mwindow)) {
  801. printf("%s: can't map mem for enet addr\n",
  802. dsc->sc_dev.dv_xname);
  803. goto fail_2;
  804. }
  805. for (j = 0; j < ETHER_ADDR_LEN; j++)
  806. myea[j] = bus_space_read_1(pcmh.memt, pcmh.memh,
  807. offset + (j * 2));
  808. enaddr = myea;
  809. pcmcia_mem_unmap(psc->sc_pf, mwindow);
  810. fail_2:
  811. pcmcia_mem_free(psc->sc_pf, &pcmh);
  812. fail_1:
  813. return (enaddr);
  814. }
  815. u_int8_t *
  816. ne_pcmcia_dl10019_get_enaddr(psc, myea)
  817. struct ne_pcmcia_softc *psc;
  818. u_int8_t myea[ETHER_ADDR_LEN];
  819. {
  820. struct ne2000_softc *nsc = &psc->sc_ne2000;
  821. u_int8_t sum;
  822. int j, type;
  823. for (j = 0, sum = 0; j < 8; j++) {
  824. sum += bus_space_read_1(nsc->sc_asict, nsc->sc_asich,
  825. 0x04 + j);
  826. }
  827. if (sum != 0xff)
  828. return (NULL);
  829. for (j = 0; j < ETHER_ADDR_LEN; j++) {
  830. myea[j] = bus_space_read_1(nsc->sc_asict,
  831. nsc->sc_asich, 0x04 + j);
  832. }
  833. /* XXX - magic values from Linux */
  834. type = bus_space_read_1(nsc->sc_asict, nsc->sc_asich, 0x0f);
  835. if (type == 0x91 || type == 0x99)
  836. nsc->sc_type = NE2000_TYPE_DL10022;
  837. else
  838. nsc->sc_type = NE2000_TYPE_DL10019;
  839. return (myea);
  840. }
  841. int
  842. ne_pcmcia_ax88190_set_iobase(psc)
  843. struct ne_pcmcia_softc *psc;
  844. {
  845. struct ne2000_softc *nsc = &psc->sc_ne2000;
  846. struct dp8390_softc *dsc = &nsc->sc_dp8390;
  847. struct pcmcia_mem_handle pcmh;
  848. bus_size_t offset;
  849. int rv = 1, mwindow;
  850. if (pcmcia_mem_alloc(psc->sc_pf, AX88190_LAN_IOSIZE, &pcmh)) {
  851. printf("%s: can't alloc mem for LAN iobase\n",
  852. dsc->sc_dev.dv_xname);
  853. goto fail_1;
  854. }
  855. if (pcmcia_mem_map(psc->sc_pf, PCMCIA_MEM_ATTR,
  856. AX88190_LAN_IOBASE, AX88190_LAN_IOSIZE, &pcmh, &offset,
  857. &mwindow)) {
  858. printf("%s: can't map mem for LAN iobase\n",
  859. dsc->sc_dev.dv_xname);
  860. goto fail_2;
  861. }
  862. #ifdef NE_DEBUG
  863. printf(": LAN iobase 0x%x (0x%x) ->",
  864. bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
  865. bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8,
  866. (u_int)psc->sc_pcioh.addr);
  867. #endif
  868. bus_space_write_1(pcmh.memt, pcmh.memh, offset,
  869. psc->sc_pcioh.addr & 0xff);
  870. bus_space_write_1(pcmh.memt, pcmh.memh, offset + 2,
  871. psc->sc_pcioh.addr >> 8);
  872. #ifdef NE_DEBUG
  873. printf(" 0x%x", bus_space_read_1(pcmh.memt, pcmh.memh, offset + 0) |
  874. bus_space_read_1(pcmh.memt, pcmh.memh, offset + 2) << 8);
  875. #endif
  876. rv = 0;
  877. pcmcia_mem_unmap(psc->sc_pf, mwindow);
  878. fail_2:
  879. pcmcia_mem_free(psc->sc_pf, &pcmh);
  880. fail_1:
  881. return (rv);
  882. }