wavelan_cs.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. /*
  2. * Wavelan Pcmcia driver
  3. *
  4. * Jean II - HPLB '96
  5. *
  6. * Reorganization and extension of the driver.
  7. * Original copyright follow. See wavelan_cs.h for details.
  8. *
  9. * This file contain the declarations of the Wavelan hardware. Note that
  10. * the Pcmcia Wavelan include a i82593 controller (see definitions in
  11. * file i82593.h).
  12. *
  13. * The main difference between the pcmcia hardware and the ISA one is
  14. * the Ethernet Controller (i82593 instead of i82586). The i82593 allow
  15. * only one send buffer. The PSA (Parameter Storage Area : EEprom for
  16. * permanent storage of various info) is memory mapped, but not the
  17. * MMI (Modem Management Interface).
  18. */
  19. /*
  20. * Definitions for the AT&T GIS (formerly NCR) WaveLAN PCMCIA card:
  21. * An Ethernet-like radio transceiver controlled by an Intel 82593
  22. * coprocessor.
  23. *
  24. *
  25. ****************************************************************************
  26. * Copyright 1995
  27. * Anthony D. Joseph
  28. * Massachusetts Institute of Technology
  29. *
  30. * Permission to use, copy, modify, and distribute this program
  31. * for any purpose and without fee is hereby granted, provided
  32. * that this copyright and permission notice appear on all copies
  33. * and supporting documentation, the name of M.I.T. not be used
  34. * in advertising or publicity pertaining to distribution of the
  35. * program without specific prior permission, and notice be given
  36. * in supporting documentation that copying and distribution is
  37. * by permission of M.I.T. M.I.T. makes no representations about
  38. * the suitability of this software for any purpose. It is pro-
  39. * vided "as is" without express or implied warranty.
  40. ****************************************************************************
  41. *
  42. *
  43. * Credits:
  44. * Special thanks to Jan Hoogendoorn of AT&T GIS Utrecht for
  45. * providing extremely useful information about WaveLAN PCMCIA hardware
  46. *
  47. * This driver is based upon several other drivers, in particular:
  48. * David Hinds' Linux driver for the PCMCIA 3c589 ethernet adapter
  49. * Bruce Janson's Linux driver for the AT-bus WaveLAN adapter
  50. * Anders Klemets' PCMCIA WaveLAN adapter driver
  51. * Robert Morris' BSDI driver for the PCMCIA WaveLAN adapter
  52. */
  53. #ifndef _WAVELAN_CS_H
  54. #define _WAVELAN_CS_H
  55. /************************** MAGIC NUMBERS ***************************/
  56. /* The detection of the wavelan card is made by reading the MAC address
  57. * from the card and checking it. If you have a non AT&T product (OEM,
  58. * like DEC RoamAbout, or Digital Ocean, Epson, ...), you must modify this
  59. * part to accommodate your hardware...
  60. */
  61. static const unsigned char MAC_ADDRESSES[][3] =
  62. {
  63. { 0x08, 0x00, 0x0E }, /* AT&T Wavelan (standard) & DEC RoamAbout */
  64. { 0x08, 0x00, 0x6A }, /* AT&T Wavelan (alternate) */
  65. { 0x00, 0x00, 0xE1 }, /* Hitachi Wavelan */
  66. { 0x00, 0x60, 0x1D } /* Lucent Wavelan (another one) */
  67. /* Add your card here and send me the patch ! */
  68. };
  69. /*
  70. * Constants used to convert channels to frequencies
  71. */
  72. /* Frequency available in the 2.0 modem, in units of 250 kHz
  73. * (as read in the offset register of the dac area).
  74. * Used to map channel numbers used by `wfreqsel' to frequencies
  75. */
  76. static const short channel_bands[] = { 0x30, 0x58, 0x64, 0x7A, 0x80, 0xA8,
  77. 0xD0, 0xF0, 0xF8, 0x150 };
  78. /* Frequencies of the 1.0 modem (fixed frequencies).
  79. * Use to map the PSA `subband' to a frequency
  80. * Note : all frequencies apart from the first one need to be multiplied by 10
  81. */
  82. static const int fixed_bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 };
  83. /*************************** PC INTERFACE ****************************/
  84. /* WaveLAN host interface definitions */
  85. #define LCCR(base) (base) /* LAN Controller Command Register */
  86. #define LCSR(base) (base) /* LAN Controller Status Register */
  87. #define HACR(base) (base+0x1) /* Host Adapter Command Register */
  88. #define HASR(base) (base+0x1) /* Host Adapter Status Register */
  89. #define PIORL(base) (base+0x2) /* Program I/O Register Low */
  90. #define RPLL(base) (base+0x2) /* Receive Pointer Latched Low */
  91. #define PIORH(base) (base+0x3) /* Program I/O Register High */
  92. #define RPLH(base) (base+0x3) /* Receive Pointer Latched High */
  93. #define PIOP(base) (base+0x4) /* Program I/O Port */
  94. #define MMR(base) (base+0x6) /* MMI Address Register */
  95. #define MMD(base) (base+0x7) /* MMI Data Register */
  96. /* Host Adaptor Command Register bit definitions */
  97. #define HACR_LOF (1 << 3) /* Lock Out Flag, toggle every 250ms */
  98. #define HACR_PWR_STAT (1 << 4) /* Power State, 1=active, 0=sleep */
  99. #define HACR_TX_DMA_RESET (1 << 5) /* Reset transmit DMA ptr on high */
  100. #define HACR_RX_DMA_RESET (1 << 6) /* Reset receive DMA ptr on high */
  101. #define HACR_ROM_WEN (1 << 7) /* EEPROM write enabled when true */
  102. #define HACR_RESET (HACR_TX_DMA_RESET | HACR_RX_DMA_RESET)
  103. #define HACR_DEFAULT (HACR_PWR_STAT)
  104. /* Host Adapter Status Register bit definitions */
  105. #define HASR_MMI_BUSY (1 << 2) /* MMI is busy when true */
  106. #define HASR_LOF (1 << 3) /* Lock out flag status */
  107. #define HASR_NO_CLK (1 << 4) /* active when modem not connected */
  108. /* Miscellaneous bit definitions */
  109. #define PIORH_SEL_TX (1 << 5) /* PIOR points to 0=rx/1=tx buffer */
  110. #define MMR_MMI_WR (1 << 0) /* Next MMI cycle is 0=read, 1=write */
  111. #define PIORH_MASK 0x1f /* only low 5 bits are significant */
  112. #define RPLH_MASK 0x1f /* only low 5 bits are significant */
  113. #define MMI_ADDR_MASK 0x7e /* Bits 1-6 of MMR are significant */
  114. /* Attribute Memory map */
  115. #define CIS_ADDR 0x0000 /* Card Information Status Register */
  116. #define PSA_ADDR 0x0e00 /* Parameter Storage Area address */
  117. #define EEPROM_ADDR 0x1000 /* EEPROM address (unused ?) */
  118. #define COR_ADDR 0x4000 /* Configuration Option Register */
  119. /* Configuration Option Register bit definitions */
  120. #define COR_CONFIG (1 << 0) /* Config Index, 0 when unconfigured */
  121. #define COR_SW_RESET (1 << 7) /* Software Reset on true */
  122. #define COR_LEVEL_IRQ (1 << 6) /* Level IRQ */
  123. /* Local Memory map */
  124. #define RX_BASE 0x0000 /* Receive memory, 8 kB */
  125. #define TX_BASE 0x2000 /* Transmit memory, 2 kB */
  126. #define UNUSED_BASE 0x2800 /* Unused, 22 kB */
  127. #define RX_SIZE (TX_BASE-RX_BASE) /* Size of receive area */
  128. #define RX_SIZE_SHIFT 6 /* Bits to shift in stop register */
  129. #define TRUE 1
  130. #define FALSE 0
  131. #define MOD_ENAL 1
  132. #define MOD_PROM 2
  133. /* Size of a MAC address */
  134. #define WAVELAN_ADDR_SIZE 6
  135. /* Maximum size of Wavelan packet */
  136. #define WAVELAN_MTU 1500
  137. #define MAXDATAZ (6 + 6 + 2 + WAVELAN_MTU)
  138. /********************** PARAMETER STORAGE AREA **********************/
  139. /*
  140. * Parameter Storage Area (PSA).
  141. */
  142. typedef struct psa_t psa_t;
  143. struct psa_t
  144. {
  145. /* For the PCMCIA Adapter, locations 0x00-0x0F are unused and fixed at 00 */
  146. unsigned char psa_io_base_addr_1; /* [0x00] Base address 1 ??? */
  147. unsigned char psa_io_base_addr_2; /* [0x01] Base address 2 */
  148. unsigned char psa_io_base_addr_3; /* [0x02] Base address 3 */
  149. unsigned char psa_io_base_addr_4; /* [0x03] Base address 4 */
  150. unsigned char psa_rem_boot_addr_1; /* [0x04] Remote Boot Address 1 */
  151. unsigned char psa_rem_boot_addr_2; /* [0x05] Remote Boot Address 2 */
  152. unsigned char psa_rem_boot_addr_3; /* [0x06] Remote Boot Address 3 */
  153. unsigned char psa_holi_params; /* [0x07] HOst Lan Interface (HOLI) Parameters */
  154. unsigned char psa_int_req_no; /* [0x08] Interrupt Request Line */
  155. unsigned char psa_unused0[7]; /* [0x09-0x0F] unused */
  156. unsigned char psa_univ_mac_addr[WAVELAN_ADDR_SIZE]; /* [0x10-0x15] Universal (factory) MAC Address */
  157. unsigned char psa_local_mac_addr[WAVELAN_ADDR_SIZE]; /* [0x16-1B] Local MAC Address */
  158. unsigned char psa_univ_local_sel; /* [0x1C] Universal Local Selection */
  159. #define PSA_UNIVERSAL 0 /* Universal (factory) */
  160. #define PSA_LOCAL 1 /* Local */
  161. unsigned char psa_comp_number; /* [0x1D] Compatability Number: */
  162. #define PSA_COMP_PC_AT_915 0 /* PC-AT 915 MHz */
  163. #define PSA_COMP_PC_MC_915 1 /* PC-MC 915 MHz */
  164. #define PSA_COMP_PC_AT_2400 2 /* PC-AT 2.4 GHz */
  165. #define PSA_COMP_PC_MC_2400 3 /* PC-MC 2.4 GHz */
  166. #define PSA_COMP_PCMCIA_915 4 /* PCMCIA 915 MHz or 2.0 */
  167. unsigned char psa_thr_pre_set; /* [0x1E] Modem Threshold Preset */
  168. unsigned char psa_feature_select; /* [0x1F] Call code required (1=on) */
  169. #define PSA_FEATURE_CALL_CODE 0x01 /* Call code required (Japan) */
  170. unsigned char psa_subband; /* [0x20] Subband */
  171. #define PSA_SUBBAND_915 0 /* 915 MHz or 2.0 */
  172. #define PSA_SUBBAND_2425 1 /* 2425 MHz */
  173. #define PSA_SUBBAND_2460 2 /* 2460 MHz */
  174. #define PSA_SUBBAND_2484 3 /* 2484 MHz */
  175. #define PSA_SUBBAND_2430_5 4 /* 2430.5 MHz */
  176. unsigned char psa_quality_thr; /* [0x21] Modem Quality Threshold */
  177. unsigned char psa_mod_delay; /* [0x22] Modem Delay ??? (reserved) */
  178. unsigned char psa_nwid[2]; /* [0x23-0x24] Network ID */
  179. unsigned char psa_nwid_select; /* [0x25] Network ID Select On Off */
  180. unsigned char psa_encryption_select; /* [0x26] Encryption On Off */
  181. unsigned char psa_encryption_key[8]; /* [0x27-0x2E] Encryption Key */
  182. unsigned char psa_databus_width; /* [0x2F] AT bus width select 8/16 */
  183. unsigned char psa_call_code[8]; /* [0x30-0x37] (Japan) Call Code */
  184. unsigned char psa_nwid_prefix[2]; /* [0x38-0x39] Roaming domain */
  185. unsigned char psa_reserved[2]; /* [0x3A-0x3B] Reserved - fixed 00 */
  186. unsigned char psa_conf_status; /* [0x3C] Conf Status, bit 0=1:config*/
  187. unsigned char psa_crc[2]; /* [0x3D] CRC-16 over PSA */
  188. unsigned char psa_crc_status; /* [0x3F] CRC Valid Flag */
  189. };
  190. /* Size for structure checking (if padding is correct) */
  191. #define PSA_SIZE 64
  192. /* Calculate offset of a field in the above structure
  193. * Warning : only even addresses are used */
  194. #define psaoff(p,f) ((unsigned short) ((void *)(&((psa_t *) ((void *) NULL + (p)))->f) - (void *) NULL))
  195. /******************** MODEM MANAGEMENT INTERFACE ********************/
  196. /*
  197. * Modem Management Controller (MMC) write structure.
  198. */
  199. typedef struct mmw_t mmw_t;
  200. struct mmw_t
  201. {
  202. unsigned char mmw_encr_key[8]; /* encryption key */
  203. unsigned char mmw_encr_enable; /* enable/disable encryption */
  204. #define MMW_ENCR_ENABLE_MODE 0x02 /* Mode of security option */
  205. #define MMW_ENCR_ENABLE_EN 0x01 /* Enable security option */
  206. unsigned char mmw_unused0[1]; /* unused */
  207. unsigned char mmw_des_io_invert; /* Encryption option */
  208. #define MMW_DES_IO_INVERT_RES 0x0F /* Reserved */
  209. #define MMW_DES_IO_INVERT_CTRL 0xF0 /* Control ??? (set to 0) */
  210. unsigned char mmw_unused1[5]; /* unused */
  211. unsigned char mmw_loopt_sel; /* looptest selection */
  212. #define MMW_LOOPT_SEL_DIS_NWID 0x40 /* disable NWID filtering */
  213. #define MMW_LOOPT_SEL_INT 0x20 /* activate Attention Request */
  214. #define MMW_LOOPT_SEL_LS 0x10 /* looptest w/o collision avoidance */
  215. #define MMW_LOOPT_SEL_LT3A 0x08 /* looptest 3a */
  216. #define MMW_LOOPT_SEL_LT3B 0x04 /* looptest 3b */
  217. #define MMW_LOOPT_SEL_LT3C 0x02 /* looptest 3c */
  218. #define MMW_LOOPT_SEL_LT3D 0x01 /* looptest 3d */
  219. unsigned char mmw_jabber_enable; /* jabber timer enable */
  220. /* Abort transmissions > 200 ms */
  221. unsigned char mmw_freeze; /* freeze / unfreeeze signal level */
  222. /* 0 : signal level & qual updated for every new message, 1 : frozen */
  223. unsigned char mmw_anten_sel; /* antenna selection */
  224. #define MMW_ANTEN_SEL_SEL 0x01 /* direct antenna selection */
  225. #define MMW_ANTEN_SEL_ALG_EN 0x02 /* antenna selection algo. enable */
  226. unsigned char mmw_ifs; /* inter frame spacing */
  227. /* min time between transmission in bit periods (.5 us) - bit 0 ignored */
  228. unsigned char mmw_mod_delay; /* modem delay (synchro) */
  229. unsigned char mmw_jam_time; /* jamming time (after collision) */
  230. unsigned char mmw_unused2[1]; /* unused */
  231. unsigned char mmw_thr_pre_set; /* level threshold preset */
  232. /* Discard all packet with signal < this value (4) */
  233. unsigned char mmw_decay_prm; /* decay parameters */
  234. unsigned char mmw_decay_updat_prm; /* decay update parameterz */
  235. unsigned char mmw_quality_thr; /* quality (z-quotient) threshold */
  236. /* Discard all packet with quality < this value (3) */
  237. unsigned char mmw_netw_id_l; /* NWID low order byte */
  238. unsigned char mmw_netw_id_h; /* NWID high order byte */
  239. /* Network ID or Domain : create virtual net on the air */
  240. /* 2.0 Hardware extension - frequency selection support */
  241. unsigned char mmw_mode_select; /* for analog tests (set to 0) */
  242. unsigned char mmw_unused3[1]; /* unused */
  243. unsigned char mmw_fee_ctrl; /* frequency eeprom control */
  244. #define MMW_FEE_CTRL_PRE 0x10 /* Enable protected instructions */
  245. #define MMW_FEE_CTRL_DWLD 0x08 /* Download eeprom to mmc */
  246. #define MMW_FEE_CTRL_CMD 0x07 /* EEprom commands : */
  247. #define MMW_FEE_CTRL_READ 0x06 /* Read */
  248. #define MMW_FEE_CTRL_WREN 0x04 /* Write enable */
  249. #define MMW_FEE_CTRL_WRITE 0x05 /* Write data to address */
  250. #define MMW_FEE_CTRL_WRALL 0x04 /* Write data to all addresses */
  251. #define MMW_FEE_CTRL_WDS 0x04 /* Write disable */
  252. #define MMW_FEE_CTRL_PRREAD 0x16 /* Read addr from protect register */
  253. #define MMW_FEE_CTRL_PREN 0x14 /* Protect register enable */
  254. #define MMW_FEE_CTRL_PRCLEAR 0x17 /* Unprotect all registers */
  255. #define MMW_FEE_CTRL_PRWRITE 0x15 /* Write addr in protect register */
  256. #define MMW_FEE_CTRL_PRDS 0x14 /* Protect register disable */
  257. /* Never issue this command (PRDS) : it's irreversible !!! */
  258. unsigned char mmw_fee_addr; /* EEprom address */
  259. #define MMW_FEE_ADDR_CHANNEL 0xF0 /* Select the channel */
  260. #define MMW_FEE_ADDR_OFFSET 0x0F /* Offset in channel data */
  261. #define MMW_FEE_ADDR_EN 0xC0 /* FEE_CTRL enable operations */
  262. #define MMW_FEE_ADDR_DS 0x00 /* FEE_CTRL disable operations */
  263. #define MMW_FEE_ADDR_ALL 0x40 /* FEE_CTRL all operations */
  264. #define MMW_FEE_ADDR_CLEAR 0xFF /* FEE_CTRL clear operations */
  265. unsigned char mmw_fee_data_l; /* Write data to EEprom */
  266. unsigned char mmw_fee_data_h; /* high octet */
  267. unsigned char mmw_ext_ant; /* Setting for external antenna */
  268. #define MMW_EXT_ANT_EXTANT 0x01 /* Select external antenna */
  269. #define MMW_EXT_ANT_POL 0x02 /* Polarity of the antenna */
  270. #define MMW_EXT_ANT_INTERNAL 0x00 /* Internal antenna */
  271. #define MMW_EXT_ANT_EXTERNAL 0x03 /* External antenna */
  272. #define MMW_EXT_ANT_IQ_TEST 0x1C /* IQ test pattern (set to 0) */
  273. } __attribute__((packed));
  274. /* Size for structure checking (if padding is correct) */
  275. #define MMW_SIZE 37
  276. /* Calculate offset of a field in the above structure */
  277. #define mmwoff(p,f) (unsigned short)((void *)(&((mmw_t *)((void *)0 + (p)))->f) - (void *)0)
  278. /*
  279. * Modem Management Controller (MMC) read structure.
  280. */
  281. typedef struct mmr_t mmr_t;
  282. struct mmr_t
  283. {
  284. unsigned char mmr_unused0[8]; /* unused */
  285. unsigned char mmr_des_status; /* encryption status */
  286. unsigned char mmr_des_avail; /* encryption available (0x55 read) */
  287. #define MMR_DES_AVAIL_DES 0x55 /* DES available */
  288. #define MMR_DES_AVAIL_AES 0x33 /* AES (AT&T) available */
  289. unsigned char mmr_des_io_invert; /* des I/O invert register */
  290. unsigned char mmr_unused1[5]; /* unused */
  291. unsigned char mmr_dce_status; /* DCE status */
  292. #define MMR_DCE_STATUS_RX_BUSY 0x01 /* receiver busy */
  293. #define MMR_DCE_STATUS_LOOPT_IND 0x02 /* loop test indicated */
  294. #define MMR_DCE_STATUS_TX_BUSY 0x04 /* transmitter on */
  295. #define MMR_DCE_STATUS_JBR_EXPIRED 0x08 /* jabber timer expired */
  296. #define MMR_DCE_STATUS 0x0F /* mask to get the bits */
  297. unsigned char mmr_dsp_id; /* DSP id (AA = Daedalus rev A) */
  298. unsigned char mmr_unused2[2]; /* unused */
  299. unsigned char mmr_correct_nwid_l; /* # of correct NWID's rxd (low) */
  300. unsigned char mmr_correct_nwid_h; /* # of correct NWID's rxd (high) */
  301. /* Warning : Read high order octet first !!! */
  302. unsigned char mmr_wrong_nwid_l; /* # of wrong NWID's rxd (low) */
  303. unsigned char mmr_wrong_nwid_h; /* # of wrong NWID's rxd (high) */
  304. unsigned char mmr_thr_pre_set; /* level threshold preset */
  305. #define MMR_THR_PRE_SET 0x3F /* level threshold preset */
  306. #define MMR_THR_PRE_SET_CUR 0x80 /* Current signal above it */
  307. unsigned char mmr_signal_lvl; /* signal level */
  308. #define MMR_SIGNAL_LVL 0x3F /* signal level */
  309. #define MMR_SIGNAL_LVL_VALID 0x80 /* Updated since last read */
  310. unsigned char mmr_silence_lvl; /* silence level (noise) */
  311. #define MMR_SILENCE_LVL 0x3F /* silence level */
  312. #define MMR_SILENCE_LVL_VALID 0x80 /* Updated since last read */
  313. unsigned char mmr_sgnl_qual; /* signal quality */
  314. #define MMR_SGNL_QUAL 0x0F /* signal quality */
  315. #define MMR_SGNL_QUAL_ANT 0x80 /* current antenna used */
  316. unsigned char mmr_netw_id_l; /* NWID low order byte ??? */
  317. unsigned char mmr_unused3[3]; /* unused */
  318. /* 2.0 Hardware extension - frequency selection support */
  319. unsigned char mmr_fee_status; /* Status of frequency eeprom */
  320. #define MMR_FEE_STATUS_ID 0xF0 /* Modem revision id */
  321. #define MMR_FEE_STATUS_DWLD 0x08 /* Download in progress */
  322. #define MMR_FEE_STATUS_BUSY 0x04 /* EEprom busy */
  323. unsigned char mmr_unused4[1]; /* unused */
  324. unsigned char mmr_fee_data_l; /* Read data from eeprom (low) */
  325. unsigned char mmr_fee_data_h; /* Read data from eeprom (high) */
  326. };
  327. /* Size for structure checking (if padding is correct) */
  328. #define MMR_SIZE 36
  329. /* Calculate offset of a field in the above structure */
  330. #define mmroff(p,f) (unsigned short)((void *)(&((mmr_t *)((void *)0 + (p)))->f) - (void *)0)
  331. /* Make the two above structures one */
  332. typedef union mm_t
  333. {
  334. struct mmw_t w; /* Write to the mmc */
  335. struct mmr_t r; /* Read from the mmc */
  336. } mm_t;
  337. #endif /* _WAVELAN_CS_H */