xref: /dragonfly/sys/dev/misc/ppc/ppcreg.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1 /*-
2  * Copyright (c) 2001 Alcove - Nicolas Souchu
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/isa/ppcreg.h,v 1.10.2.4 2001/10/02 05:21:45 nsouch Exp $
27  * $DragonFly: src/sys/dev/misc/ppc/ppcreg.h,v 1.2 2003/06/17 04:28:40 dillon Exp $
28  *
29  */
30 #ifndef __PPCREG_H
31 #define __PPCREG_H
32 
33 /*
34  * Parallel Port Chipset type.
35  */
36 #define SMC_LIKE    0
37 #define SMC_37C665GT          1
38 #define SMC_37C666GT          2
39 #define NS_PC87332  3
40 #define NS_PC87306  4
41 #define INTEL_820191AA        5         /* XXX not implemented */
42 #define GENERIC               6
43 #define WINB_W83877F          7
44 #define WINB_W83877AF         8
45 #define WINB_UNKNOWN          9
46 #define NS_PC87334  10
47 #define SMC_37C935  11
48 #define NS_PC87303  12
49 
50 /*
51  * Parallel Port Chipset Type. SMC versus GENERIC (others)
52  */
53 #define PPC_TYPE_SMCLIKE 0
54 #define PPC_TYPE_GENERIC 1
55 
56 /*
57  * Generic structure to hold parallel port chipset info.
58  */
59 struct ppc_data {
60 
61           int ppc_unit;
62           int ppc_model;                /* chipset model if detected */
63           int ppc_type;                 /* generic or smclike chipset type */
64 
65           int ppc_mode;                 /* chipset current mode */
66           int ppc_avm;                  /* chipset available modes */
67           int ppc_dtm;                  /* chipset detected modes */
68 
69 #define PPC_IRQ_NONE                    0x0
70 #define PPC_IRQ_nACK                    0x1
71 #define PPC_IRQ_DMA           0x2
72 #define PPC_IRQ_FIFO                    0x4
73 #define PPC_IRQ_nFAULT                  0x8
74           int ppc_irqstat;    /* remind irq settings */
75 
76 #define PPC_DMA_INIT                    0x01
77 #define PPC_DMA_STARTED                 0x02
78 #define PPC_DMA_COMPLETE      0x03
79 #define PPC_DMA_INTERRUPTED   0x04
80 #define PPC_DMA_ERROR                   0x05
81           int ppc_dmastat;    /* dma state */
82           int ppc_dmachan;    /* dma channel */
83           int ppc_dmaflags;   /* dma transfer flags */
84           caddr_t ppc_dmaddr; /* buffer address */
85           u_int ppc_dmacnt;   /* count of bytes sent with dma */
86 
87 #define PPC_PWORD_MASK        0x30
88 #define PPC_PWORD_16          0x00
89 #define PPC_PWORD_8 0x10
90 #define PPC_PWORD_32          0x20
91           char ppc_pword;               /* PWord size */
92           short ppc_fifo;               /* FIFO threshold */
93 
94           short ppc_wthr;               /* writeIntrThresold */
95           short ppc_rthr;               /* readIntrThresold */
96 
97           char *ppc_ptr;                /* microseq current pointer */
98           int ppc_accum;                /* microseq accumulator */
99           int ppc_base;                 /* parallel port base address */
100           int ppc_epp;                  /* EPP mode (1.7 or 1.9) */
101           int ppc_irq;
102 
103           unsigned char ppc_flags;
104 
105           device_t ppbus;               /* parallel port chipset corresponding ppbus */
106 
107           int rid_irq, rid_drq, rid_ioport;
108           struct resource *res_irq, *res_drq, *res_ioport;
109 
110           bus_space_handle_t bsh;
111           bus_space_tag_t bst;
112 
113           void *intr_cookie;
114 
115           int ppc_registered; /* 1 if ppcintr() is the registered interrupt */
116 };
117 
118 /*
119  * Parallel Port Chipset registers.
120  */
121 #define PPC_SPP_DTR 0         /* SPP data register */
122 #define PPC_ECP_A_FIFO        0         /* ECP Address fifo register */
123 #define PPC_SPP_STR 1         /* SPP status register */
124 #define PPC_SPP_CTR 2         /* SPP control register */
125 #define PPC_EPP_ADDR          3         /* EPP address register (8 bit) */
126 #define PPC_EPP_DATA          4         /* EPP data register (8, 16 or 32 bit) */
127 #define PPC_ECP_D_FIFO        0x400     /* ECP Data fifo register */
128 #define PPC_ECP_CNFGA         0x400     /* Configuration register A */
129 #define PPC_ECP_CNFGB         0x401     /* Configuration register B */
130 #define PPC_ECP_ECR 0x402     /* ECP extended control register */
131 
132 #define PPC_FIFO_EMPTY        0x1       /* ecr register - bit 0 */
133 #define PPC_FIFO_FULL         0x2       /* ecr register - bit 1 */
134 #define PPC_SERVICE_INTR 0x4  /* ecr register - bit 2 */
135 #define PPC_ENABLE_DMA        0x8       /* ecr register - bit 3 */
136 #define PPC_nFAULT_INTR       0x10      /* ecr register - bit 4 */
137 #define PPC_ECR_STD 0x0
138 #define PPC_ECR_PS2 0x20
139 #define PPC_ECR_FIFO          0x40
140 #define PPC_ECR_ECP 0x60
141 #define PPC_ECR_EPP 0x80
142 
143 #define PPC_DISABLE_INTR      (PPC_SERVICE_INTR | PPC_nFAULT_INTR)
144 #define PPC_ECR_RESET                   (PPC_ECR_PS2 | PPC_DISABLE_INTR)
145 
146 #define r_dtr(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_SPP_DTR))
147 #define r_str(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_SPP_STR))
148 #define r_ctr(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_SPP_CTR))
149 
150 #define r_epp_A(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_EPP_ADDR))
151 #define r_epp_D(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_EPP_DATA))
152 #define r_cnfgA(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_ECP_CNFGA))
153 #define r_cnfgB(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_ECP_CNFGB))
154 #define r_ecr(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_ECP_ECR))
155 #define r_fifo(ppc) (bus_space_read_1((ppc)->bst, (ppc)->bsh, PPC_ECP_D_FIFO))
156 
157 #define w_dtr(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_SPP_DTR, byte))
158 #define w_str(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_SPP_STR, byte))
159 #define w_ctr(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_SPP_CTR, byte))
160 
161 #define w_epp_A(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_EPP_ADDR, byte))
162 #define w_epp_D(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_EPP_DATA, byte))
163 #define w_ecr(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_ECP_ECR, byte))
164 #define w_fifo(ppc, byte) (bus_space_write_1((ppc)->bst, (ppc)->bsh, PPC_ECP_D_FIFO, byte))
165 
166 /*
167  * Register defines for the PC873xx parts
168  */
169 
170 #define PC873_FER   0x00
171 #define PC873_PPENABLE        (1<<0)
172 #define PC873_FAR   0x01
173 #define PC873_PTR   0x02
174 #define PC873_CFGLOCK         (1<<6)
175 #define PC873_EPPRDIR         (1<<7)
176 #define PC873_EXTENDED        (1<<7)
177 #define PC873_LPTBIRQ7        (1<<3)
178 #define PC873_FCR   0x03
179 #define PC873_ZWS   (1<<5)
180 #define PC873_ZWSPWDN         (1<<6)
181 #define PC873_PCR   0x04
182 #define PC873_EPPEN (1<<0)
183 #define PC873_EPP19 (1<<1)
184 #define PC873_ECPEN (1<<2)
185 #define PC873_ECPCLK          (1<<3)
186 #define PC873_PMC   0x06
187 #define PC873_TUP   0x07
188 #define PC873_SID   0x08
189 #define PC873_PNP0  0x1b
190 #define PC873_PNP1  0x1c
191 #define PC873_LPTBA 0x19
192 
193 /*
194  * Register defines for the SMC FDC37C66xGT parts
195  */
196 
197 /* Init codes */
198 #define SMC665_iCODE          0x55
199 #define SMC666_iCODE          0x44
200 
201 /* Base configuration ports */
202 #define SMC66x_CSR  0x3F0
203 #define SMC666_CSR  0x370               /* hard-configured value for 666 */
204 
205 /* Bits */
206 #define SMC_CR1_ADDR          0x3                 /* bit 0 and 1 */
207 #define SMC_CR1_MODE          (1<<3)              /* bit 3 */
208 #define SMC_CR4_EMODE         0x3                 /* bits 0 and 1 */
209 #define SMC_CR4_EPPTYPE       (1<<6)              /* bit 6 */
210 
211 /* Extended modes */
212 #define SMC_SPP               0x0                 /* SPP */
213 #define SMC_EPPSPP  0x1                 /* EPP and SPP */
214 #define SMC_ECP               0x2                 /* ECP */
215 #define SMC_ECPEPP  0x3                 /* ECP and EPP */
216 
217 /*
218  * Register defines for the SMC FDC37C935 parts
219  */
220 
221 /* Configuration ports */
222 #define SMC935_CFG  0x370
223 #define SMC935_IND  0x370
224 #define SMC935_DAT  0x371
225 
226 /* Registers */
227 #define SMC935_LOGDEV         0x7
228 #define SMC935_ID   0x20
229 #define SMC935_PORTHI         0x60
230 #define SMC935_PORTLO         0x61
231 #define SMC935_PPMODE         0xf0
232 
233 /* Parallel port modes */
234 #define SMC935_SPP  0x38 + 0
235 #define SMC935_EPP19SPP       0x38 + 1
236 #define SMC935_ECP  0x38 + 2
237 #define SMC935_ECPEPP19       0x38 + 3
238 #define SMC935_CENT 0x38 + 4
239 #define SMC935_EPP17SPP       0x38 + 5
240 #define SMC935_UNUSED         0x38 + 6
241 #define SMC935_ECPEPP17       0x38 + 7
242 
243 /*
244  * Register defines for the Winbond W83877F parts
245  */
246 
247 #define WINB_W83877F_ID                 0xa
248 #define WINB_W83877AF_ID      0xb
249 
250 /* Configuration bits */
251 #define WINB_HEFERE (1<<5)              /* CROC bit 5 */
252 #define WINB_HEFRAS (1<<0)              /* CR16 bit 0 */
253 
254 #define WINB_PNPCVS (1<<2)              /* CR16 bit 2 */
255 #define WINB_CHIPID 0xf                 /* CR9 bits 0-3 */
256 
257 #define WINB_PRTMODS0         (1<<2)              /* CR0 bit 2 */
258 #define WINB_PRTMODS1         (1<<3)              /* CR0 bit 3 */
259 #define WINB_PRTMODS2         (1<<7)              /* CR9 bit 7 */
260 
261 /* W83877F modes: CR9/bit7 | CR0/bit3 | CR0/bit2 */
262 #define WINB_W83757 0x0
263 #define WINB_EXTFDC 0x4
264 #define WINB_EXTADP 0x8
265 #define WINB_EXT2FDD          0xc
266 #define WINB_JOYSTICK         0x80
267 
268 #define WINB_PARALLEL         0x80
269 #define WINB_EPP_SPP          0x4
270 #define WINB_ECP    0x8
271 #define WINB_ECP_EPP          0xc
272 
273 #endif
274