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