pccbbvar.h revision 1.7 1 /* $NetBSD: pccbbvar.h,v 1.7 2000/03/01 23:40:26 thorpej Exp $ */
2 /*
3 * Copyright (c) 1999 HAYAKAWA Koichi. 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 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by HAYAKAWA Koichi.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /* require sys/device.h */
32 /* require sys/queue.h */
33 /* require dev/ic/i82365reg.h */
34 /* require dev/ic/i82365var.h */
35
36 #ifndef _DEV_PCI_PCCBBVAR_H_
37 #define _DEV_PCI_PCCBBVAR_H_
38
39 #define PCIC_FLAG_SOCKETP 0x0001
40 #define PCIC_FLAG_CARDP 0x0002
41
42 /* Chipset ID */
43 #define CB_UNKNOWN 0 /* NOT Cardbus-PCI bridge */
44 #define CB_TI113X 1 /* TI PCI1130/1131 */
45 #define CB_TI12XX 2 /* TI PCI1250/1220 */
46 #define CB_RX5C47X 3 /* RICOH RX5C475/476/477 */
47 #define CB_RX5C46X 4 /* RICOH RX5C465/466/467 */
48 #define CB_TOPIC95 5 /* Toshiba ToPIC95 */
49 #define CB_TOPIC95B 6 /* Toshiba ToPIC95B */
50 #define CB_TOPIC97 7 /* Toshiba ToPIC97 */
51 #define CB_CIRRUS 8 /* Cirrus Logic CL-PD683X */
52 #define CB_CHIPS_LAST 9 /* Sentinel */
53
54 #if 0
55 static char *cb_chipset_name[CB_CHIPS_LAST] = {
56 "unknown", "TI 113X", "TI 12XX", "RF5C47X", "RF5C46X", "ToPIC95",
57 "ToPIC95B", "ToPIC97", "CL-PD 683X",
58 };
59 #endif
60
61 struct pccbb_softc;
62 struct pccbb_intrhand_list;
63
64 #if pccard
65 struct cbb_pcmcia_softc {
66 pccard_chipset_t cpc_ct;
67 struct pccard_softc *cpc_csc;
68 struct pccbb_softc *cpc_parent;
69 u_int8_t cpc_statreg; /* status register */
70 u_int32_t cpc_regbase; /* base index of the slot */
71 u_int16_t cpc_flags;
72 bus_space_tag_t cpc_iot;
73 bus_space_handle_t cpc_ioh;
74 };
75 #endif /* pccard */
76
77 struct cbb_pcic_handle {
78 struct device *ph_parent;
79 bus_space_tag_t ph_base_t;
80 bus_space_handle_t ph_base_h;
81 u_int8_t (*ph_read) __P((struct cbb_pcic_handle *, int));
82 void (*ph_write) __P((struct cbb_pcic_handle *, int, u_int8_t));
83 int sock;
84
85 int vendor;
86 int flags;
87 int memalloc;
88 struct {
89 bus_addr_t addr;
90 bus_size_t size;
91 long offset;
92 int kind;
93 } mem[PCIC_MEM_WINS];
94 int ioalloc;
95 struct {
96 bus_addr_t addr;
97 bus_size_t size;
98 int width;
99 } io[PCIC_IO_WINS];
100 int ih_irq;
101 struct device *pcmcia;
102
103 int shutdown;
104 };
105
106 struct pccbb_win_chain {
107 bus_addr_t wc_start; /* Caution: region [start, end], */
108 bus_addr_t wc_end; /* instead of [start, end). */
109 int wc_flags;
110 bus_space_handle_t wc_handle;
111 TAILQ_ENTRY(pccbb_win_chain) wc_list;
112 };
113 #define PCCBB_MEM_CACHABLE 1
114
115 TAILQ_HEAD(pccbb_win_chain_head, pccbb_win_chain);
116
117 struct pccbb_softc {
118 struct device sc_dev;
119 bus_space_tag_t sc_iot;
120 bus_space_tag_t sc_memt;
121 bus_dma_tag_t sc_dmat;
122
123 #if rbus
124 rbus_tag_t sc_rbus_iot; /* rbus for i/o donated from parent */
125 rbus_tag_t sc_rbus_memt; /* rbus for mem donated from parent */
126 #endif
127
128 bus_space_tag_t sc_base_memt;
129 bus_space_handle_t sc_base_memh;
130
131 void *sc_ih; /* interrupt handler */
132 int sc_intrline; /* interrupt line */
133 pcitag_t sc_intrtag; /* copy of pa->pa_intrtag */
134 pci_intr_pin_t sc_intrpin; /* copy of pa->pa_intrpin */
135 int sc_function;
136 u_int32_t sc_flags;
137 #define CBB_CARDEXIST 0x01
138 #define CBB_INSERTING 0x01000000
139 #define CBB_16BITCARD 0x04
140 #define CBB_32BITCARD 0x08
141
142 #if pccard
143 struct cbb_pcmcia_softc sc_pcmcia;
144 #endif /* pccard */
145 pci_chipset_tag_t sc_pc;
146 pcitag_t sc_tag;
147 int sc_chipset; /* chipset id */
148
149 bus_addr_t sc_mem_start; /* CardBus/PCMCIA memory start */
150 bus_addr_t sc_mem_end; /* CardBus/PCMCIA memory end */
151 bus_addr_t sc_io_start; /* CardBus/PCMCIA io start */
152 bus_addr_t sc_io_end; /* CardBus/PCMCIA io end */
153
154 /* CardBus stuff */
155 struct cardslot_softc *sc_csc;
156
157 struct pccbb_win_chain_head sc_memwindow;
158 struct pccbb_win_chain_head sc_iowindow;
159
160 /* pcmcia stuff */
161 struct pcic_handle sc_pcmcia_h;
162 pcmcia_chipset_tag_t sc_pct;
163 int sc_pcmcia_flags;
164 #define PCCBB_PCMCIA_IO_RELOC 0x01 /* IO addr relocatable stuff exists */
165 #define PCCBB_PCMCIA_MEM_32 0x02 /* 32-bit memory address ready */
166 #define PCCBB_PCMCIA_16BITONLY 0x04 /* 32-bit mode disable */
167
168 struct proc *sc_event_thread;
169 SIMPLEQ_HEAD(, pcic_event) sc_events;
170
171 /* interrupt handler list on the bridge */
172 struct pccbb_intrhand_list *sc_pil;
173 };
174
175 /*
176 * struct pccbb_intrhand_list holds interrupt handler and argument for
177 * child devices.
178 */
179
180 struct pccbb_intrhand_list {
181 int (*pil_func) __P((void *));
182 void *pil_arg;
183 struct pccbb_intrhand_list *pil_next;
184 };
185
186 #endif /* _DEV_PCI_PCCBBREG_H_ */
187