]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/pccard/i82365.h
Rip out the nastiness I cribbed from the EISA bus code and actually
[FreeBSD/FreeBSD.git] / sys / pccard / i82365.h
1 /*
2  *      i82365.h - Definitions for Intel 82365 PCIC
3  *      PCMCIA Card Interface Controller
4  *
5  * originally by Barry Jaspan; hacked over by Keith Moore
6  * hacked to unrecognisability by Andrew McRae (andrew@mega.com.au)
7  *
8  * Updated 3/3/95 to include Cirrus Logic stuff.
9  *-------------------------------------------------------------------------
10  *
11  * Copyright (c) 1995 Andrew McRae.  All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. The name of the author may not be used to endorse or promote products
22  *    derived from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 #define PCIC_I82365     0               /* Intel chip */
37 #define PCIC_IBM        1               /* IBM clone */
38 #define PCIC_VLSI       2               /* VLSI chip */
39 #define PCIC_PD672X     3               /* Cirrus logic 627x */
40 #define PCIC_PD6710     4               /* Cirrus logic 6710 */
41 #define PCIC_CL6729     5               /* Cirrus logic 6729 */
42 #define PCIC_VG365      6               /* Vadem 365 */
43 #define PCIC_VG465      7               /* Vadem 465 */
44 #define PCIC_VG468      8               /* Vadem 468 */
45 #define PCIC_VG469      9               /* Vadem 469 */
46 #define PCIC_RF5C396    10              /* Ricoh RF5C396 */
47 #define PCIC_IBM_KING   11              /* IBM KING PCMCIA Controller */
48 #define PCIC_PC98       12              /* NEC PC98 PCMCIA Controller */
49 #define PCIC_TI1130     13              /* TI PCI1130 CardBus */
50
51 /*
52  *      Address of the controllers. Each controller can manage
53  *      two PCMCIA slots. Up to 8 slots are supported in total.
54  *      The PCIC controller is accessed via an index port and a
55  *      data port. The index port has the 8 bit address of the
56  *      register accessed via the data port. How I long for
57  *      real memory mapped I/O!
58  *      The top two bits of the index address are used to
59  *      identify the port number, and the lower 6 bits
60  *      select one of the 64 possible data registers.
61  */
62 #define PCIC_INDEX_0    0x3E0                   /* index reg, chips 0 and 1 */
63 #define PCIC_DATA_0     (PCIC_INDEX_0 + 1)      /* data reg, chips 0 and 1 */
64 #define PCIC_INDEX_1    (PCIC_INDEX_0 + 2)      /* index reg, chips 2 and 3 */
65 #define PCIC_DATA_1     (PCIC_INDEX_1 + 1)      /* data reg, chips 2 and 3 */
66 /*
67  *      Register index addresses.
68  */
69 #define PCIC_ID_REV     0x00    /* Identification and Revision */
70 #define PCIC_STATUS     0x01    /* Interface Status */
71 #define PCIC_POWER      0x02    /* Power and RESETDRV control */
72 #define PCIC_INT_GEN    0x03    /* Interrupt and General Control */
73 #define PCIC_STAT_CHG   0x04    /* Card Status Change */
74 #define PCIC_STAT_INT   0x05    /* Card Status Change Interrupt Config */
75 #define PCIC_ADDRWINE   0x06    /* Address Window Enable */
76 #define PCIC_IOCTL      0x07    /* I/O Control */
77 #define PCIC_IO0        0x08    /* I/O Address 0 */
78 #define PCIC_IO1        0x0c    /* I/O Address 1 */
79 #define PCIC_MEMBASE    0x10    /* Base of memory window registers */
80 #define PCIC_CDGC       0x16    /* Card Detect and General Control */
81 #define PCIC_MISC1      0x16    /* PD672x: Misc control register 1 per slot */
82 #define PCIC_GLO_CTRL   0x1e    /* Global Control Register */
83 #define PCIC_MISC2      0x1e    /* PD672x: Misc control register 2 per chip */
84
85 #define PCIC_TIME_SETUP0        0x3a
86 #define PCIC_TIME_CMD0          0x3b
87 #define PCIC_TIME_RECOV0        0x3c
88 #define PCIC_TIME_SETUP1        0x3d
89 #define PCIC_TIME_CMD1          0x3e
90 #define PCIC_TIME_RECOV1        0x3f
91
92 #define PCIC_SLOT_SIZE  0x40    /* Size of register set for one slot */
93
94 /* Now register bits, ordered by reg # */
95
96 /* For Identification and Revision (PCIC_ID_REV) */
97 #define PCIC_INTEL0     0x82    /* Intel 82365SL Rev. 0; Both Memory and I/O */
98 #define PCIC_INTEL1     0x83    /* Intel 82365SL Rev. 1; Both Memory and I/O */
99 #define PCIC_IBM1       0x88    /* IBM PCIC clone; Both Memory and I/O */
100 #define PCIC_IBM2       0x89    /* IBM PCIC clone; Both Memory and I/O */
101 #define PCIC_IBM3       0x8a    /* IBM KING PCIC clone; Both Memory and I/O */
102
103 /* For Interface Status register (PCIC_STATUS) */
104 #define PCIC_VPPV       0x80    /* Vpp_valid */
105 #define PCIC_POW        0x40    /* PC Card power active */
106 #define PCIC_READY      0x20    /* Ready/~Busy */
107 #define PCIC_MWP        0x10    /* Memory Write Protect */
108 #define PCIC_CD         0x0C    /* Both card detect bits */
109 #define PCIC_BVD        0x03    /* Both Battery Voltage Detect bits */
110
111 /* For the Power and RESETDRV register (PCIC_POWER) */
112 #define PCIC_OUTENA     0x80    /* Output Enable */
113 #define PCIC_DISRST     0x40    /* Disable RESETDRV */
114 #define PCIC_APSENA     0x20    /* Auto Pwer Switch Enable */
115 #define PCIC_PCPWRE     0x10    /* PC Card Power Enable */
116 #define PCIC_VCC        0x18    /* Vcc control bits */
117 #define PCIC_VCC_5V     0x10    /* 5 volts */
118 #define PCIC_VCC_3V     0x18    /* 3 volts */
119 #define PCIC_VCC_5V_KING        0x14    /* 5 volts for KING PCIC */
120 #define PCIC_VPP        0x0C    /* Vpp control bits */
121 #define PCIC_VPP_5V     0x01    /* 5 volts */
122 #define PCIC_VPP_12V    0x02    /* 12 volts */
123
124 /* For the Interrupt and General Control register (PCIC_INT_GEN) */
125 #define PCIC_CARDTYPE   0x20    /* Card Type 0 = memory, 1 = I/O */
126 #define         PCIC_IOCARD     0x20
127 #define         PCIC_MEMCARD    0x00
128 #define PCIC_CARDRESET  0x40    /* Card reset 0 = Reset, 1 = Normal */
129 #define PCIC_INTR_ENA   0x10    /* Interrupt enable */
130
131 /* For the Card Status Change register (PCIC_STAT_CHG) */
132 #define PCIC_CDTCH      0x08    /* Card Detect Change */
133 #define PCIC_RDYCH      0x04    /* Ready Change */
134 #define PCIC_BATWRN     0x02    /* Battery Warning */
135 #define PCIC_BATDED     0x01    /* Battery Dead */
136
137 /*
138  * For the Address Window Enable Register (PCIC_ADDRWINE)
139  * The lower 6 bits contain enable bits for the memory
140  * windows (LSB = memory window 0).
141  */
142 #define PCIC_MEMCS16    0x20    /* ~MEMCS16 Decode A23-A12 */
143 #define PCIC_IO0_EN     0x40    /* I/O Window 0 Enable */
144 #define PCIC_IO1_EN     0x80    /* I/O Window 1 Enable */
145
146 /*
147  * For the I/O Control Register (PCIC_IOCTL)
148  * The lower nybble is the flags for I/O window 0
149  * The upper nybble is the flags for I/O window 1
150  */
151 #define PCIC_IO_16BIT   0x01    /* I/O to this segment is 16 bit */
152 #define PCIC_IO_CS16    0x02    /* I/O cs16 source is the card */
153 #define PCIC_IO_0WS     0x04    /* zero wait states added on 8 bit cycles */
154 #define PCIC_IO_WS      0x08    /* Wait states added for 16 bit cycles */
155
156 /*
157  *      The memory window registers contain the start and end
158  *      physical host address that the PCIC maps to the card,
159  *      and an offset calculated from the card memory address.
160  *      All values are shifted down 12 bits, so allocation is
161  *      done in 4Kb blocks. Only 12 bits of each value is
162  *      stored, limiting the range to the ISA address size of
163  *      24 bits. The upper 4 bits of the most significant byte
164  *      within the values are used for various flags.
165  *
166  *      The layout is:
167  *
168  *      base+0 : lower 8 bits of system memory start address
169  *      base+1 : upper 4 bits of system memory start address + flags
170  *      base+2 : lower 8 bits of system memory end address
171  *      base+3 : upper 4 bits of system memory end address + flags
172  *      base+4 : lower 8 bits of offset to card address
173  *      base+5 : upper 4 bits of offset to card address + flags
174  *
175  *      The following two bytes are reserved for other use.
176  */
177 #define PCIC_MEMSIZE    8
178 /*
179  *      Flags for system memory start address upper byte
180  */
181 #define PCIC_ZEROWS     0x40    /* Zero wait states */
182 #define PCIC_DATA16     0x80    /* Data width is 16 bits */
183
184 /*
185  *      Flags for system memory end address upper byte
186  */
187 #define PCIC_MW0        0x40    /* Wait state bit 0 */
188 #define PCIC_MW1        0x80    /* Wait state bit 1 */
189
190 /*
191  *      Flags for card offset upper byte
192  */
193 #define PCIC_REG        0x40    /* Attribute/Common select (why called Reg?) */
194 #define PCIC_WP         0x80    /* Write-protect this window */
195
196 /* For Card Detect and General Control register (PCIC_CDGC) */
197 #define PCIC_16_DL_INH  0x01    /* 16-bit memory delay inhibit */
198 #define PCIC_CNFG_RST_EN 0x02   /* configuration reset enable */
199 #define PCIC_GPI_EN     0x04    /* GPI Enable */
200 #define PCIC_GPI_TRANS  0x08    /* GPI Transition Control */
201 #define PCIC_CDRES_EN   0x10    /* card detect resume enable */
202 #define PCIC_SW_CD_INT  0x20    /* s/w card detect interrupt */
203
204 /* For Misc. Control Register 1 */
205 #define PCIC_SPKR_EN    0x10    /* Cirrus PD672x: speaker enable */
206
207 /* For Global Control register (PCIC_GLO_CTRL) */
208 #define PCIC_PWR_DOWN   0x01    /* power down */
209 #define PCIC_LVL_MODE   0x02    /* level mode interrupt enable */
210 #define PCIC_WB_CSCINT  0x04    /* explicit write-back csc intr */
211 #define PCIC_IRQ0_LEVEL 0x08    /* irq 14 pulse mode enable */
212 #define PCIC_IRQ1_LEVEL 0x10
213
214 /* For Misc. Control Register 2 */
215 #define PCIC_LPDM_EN    0x02    /* Cirrus PD672x: low power dynamic mode */
216
217 /*
218  *      Mask of allowable interrupts.
219  *      Ints are 3,4,5,7,9,10,11,12,14,15
220  */
221 #define PCIC_INT_MASK_ALLOWED   0xDEB8
222
223 #define PCIC_IO_WIN     2
224 #define PCIC_MEM_WIN    5
225
226 #define PCIC_MAX_SLOTS  8