excavar.h revision 115988
189948Simp/* $FreeBSD: head/sys/dev/exca/excavar.h 115988 2003-06-07 20:46:39Z imp $ */
289948Simp
389948Simp/*
489948Simp * Copyright (c) 2002 M Warner Losh.  All rights reserved.
589948Simp *
689948Simp * Redistribution and use in source and binary forms, with or without
789948Simp * modification, are permitted provided that the following conditions
889948Simp * are met:
989948Simp * 1. Redistributions of source code must retain the above copyright
1089948Simp *    notice, this list of conditions and the following disclaimer.
1189948Simp * 2. Redistributions in binary form must reproduce the above copyright
1289948Simp *    notice, this list of conditions and the following disclaimer in the
1389948Simp *    documentation and/or other materials provided with the distribution.
1489948Simp *
1589948Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1689948Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1789948Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1889948Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1989948Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2089948Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2189948Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2289948Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2389948Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2489948Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2589948Simp *
2689948Simp * This software may be derived from NetBSD i82365.c and other files with
2789948Simp * the following copyright:
2889948Simp *
2989948Simp * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
3089948Simp *
3189948Simp * Redistribution and use in source and binary forms, with or without
3289948Simp * modification, are permitted provided that the following conditions
3389948Simp * are met:
3489948Simp * 1. Redistributions of source code must retain the above copyright
3589948Simp *    notice, this list of conditions and the following disclaimer.
3689948Simp * 2. Redistributions in binary form must reproduce the above copyright
3789948Simp *    notice, this list of conditions and the following disclaimer in the
3889948Simp *    documentation and/or other materials provided with the distribution.
3989948Simp * 3. All advertising materials mentioning features or use of this software
4089948Simp *    must display the following acknowledgement:
4189948Simp *	This product includes software developed by Marc Horowitz.
4289948Simp * 4. The name of the author may not be used to endorse or promote products
4389948Simp *    derived from this software without specific prior written permission.
4489948Simp *
4589948Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4689948Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4789948Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4889948Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
4989948Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5089948Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5189948Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5289948Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5389948Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5489948Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5589948Simp */
5689948Simp
57100703Simp#ifndef _SYS_DEV_EXCA_EXCAVAR_H
58100703Simp#define _SYS_DEV_EXCA_EXCAVAR_H
59100703Simp
6089948Simp/*
6189948Simp * Structure to manage the ExCA part of the chip.
6289948Simp */
6389948Simpstruct exca_softc;
64110841Simptypedef uint8_t (exca_getb_fn)(struct exca_softc *, int);
65110841Simptypedef void (exca_putb_fn)(struct exca_softc *, int, uint8_t);
6689948Simp
6789948Simpstruct exca_softc
6889948Simp{
6989948Simp	device_t	dev;
7089948Simp	int		memalloc;
7189948Simp	struct		pccard_mem_handle mem[EXCA_MEM_WINS];
7289948Simp	int		ioalloc;
7389948Simp	struct		pccard_io_handle io[EXCA_IO_WINS];
7489948Simp	bus_space_tag_t	bst;
7589948Simp	bus_space_handle_t bsh;
7689948Simp	uint32_t	flags;
7789948Simp#define EXCA_SOCKET_PRESENT	0x00000001
78100703Simp#define EXCA_HAS_MEMREG_WIN	0x00000002
79115988Simp#define EXCA_CARD_OK		0x00000004
80115988Simp#define	EXCA_KTHREAD_RUNNING	0x00000008
81115988Simp#define	EXCA_KTHREAD_DONE	0x00000010
8289948Simp	uint32_t	offset;
83110841Simp	int		chipset;
84110841Simp#define EXCA_CARDBUS	0
85110841Simp#define	EXCA_I82365	1		/* Intel i82365SL-A/B or clone */
86110841Simp#define EXCA_I82365SL_DF 2		/* Intel i82365sl-DF step */
87110841Simp#define	EXCA_VLSI	3		/* VLSI chip */
88110841Simp#define	EXCA_PD6710	4		/* Cirrus logic PD6710 */
89110841Simp#define	EXCA_PD6722	5		/* Cirrus logic PD6722 */
90110841Simp#define EXCA_PD6729	6		/* Cirrus Logic PD6729 */
91110841Simp#define	EXCA_VG365	7		/* Vadem 365 */
92110841Simp#define	EXCA_VG465      8		/* Vadem 465 */
93110841Simp#define	EXCA_VG468	9		/* Vadem 468 */
94110841Simp#define	EXCA_VG469	10		/* Vadem 469 */
95110841Simp#define	EXCA_RF5C296	11		/* Ricoh RF5C296 */
96110841Simp#define	EXCA_RF5C396	12		/* Ricoh RF5C396 */
97110841Simp#define	EXCA_IBM	13		/* IBM clone */
98110841Simp#define	EXCA_IBM_KING	14		/* IBM KING PCMCIA Controller */
99115988Simp#define EXCA_BOGUS	-1		/* Invalid/not present/etc */
100110841Simp	exca_getb_fn	*getb;
101110841Simp	exca_putb_fn	*putb;
102115988Simp	struct proc	*event_thread;
103115988Simp	struct mtx	mtx;
104115988Simp	struct cv	cv;
105115988Simp	device_t	pccarddev;
10689948Simp};
10789948Simp
108100703Simpvoid exca_init(struct exca_softc *sc, device_t dev,
109100703Simp    bus_space_tag_t, bus_space_handle_t, uint32_t);
110115988Simpvoid exca_insert(struct exca_softc *sc);
11189948Simpint exca_io_map(struct exca_softc *sc, int width, struct resource *r);
11289948Simpint exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
11389948Simpint exca_is_pcic(struct exca_softc *sc);
11489948Simpint exca_mem_map(struct exca_softc *sc, int kind, struct resource *res);
11589948Simpint exca_mem_set_flags(struct exca_softc *sc, struct resource *res,
11689948Simp    uint32_t flags);
11789948Simpint exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
11889948Simp    uint32_t cardaddr, uint32_t *deltap);
11989948Simpint exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
120110841Simpint exca_probe_slots(device_t dev, struct exca_softc *exca,
121110841Simp    bus_space_tag_t iot, bus_space_handle_t ioh);
122115988Simpvoid exca_removal(struct exca_softc *);
12389948Simpvoid exca_reset(struct exca_softc *, device_t child);
12489948Simp
125115988Simp/* bus/device interfaces */
126115988Simpint exca_activate_resource(struct exca_softc *exca, device_t child, int type,
127115988Simp    int rid, struct resource *res);
128115988Simpint exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
129115988Simp    int rid, struct resource *res);
130115988Simp
13189948Simpstatic __inline uint8_t
132110841Simpexca_getb(struct exca_softc *sc, int reg)
13389948Simp{
134110841Simp	return (sc->getb(sc, reg));
13589948Simp}
13689948Simp
13789948Simpstatic __inline void
138110841Simpexca_putb(struct exca_softc *sc, int reg, uint8_t val)
13989948Simp{
140110841Simp	sc->putb(sc, reg, val);
14189948Simp}
14289948Simp
14389948Simpstatic __inline void
14489948Simpexca_setb(struct exca_softc *sc, int reg, uint8_t mask)
14589948Simp{
146110841Simp	exca_putb(sc, reg, exca_getb(sc, reg) | mask);
14789948Simp}
14889948Simp
14989948Simpstatic __inline void
15089948Simpexca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
15189948Simp{
152110841Simp	exca_putb(sc, reg, exca_getb(sc, reg) & ~mask);
15389948Simp}
154100703Simp
155100703Simp#endif /* !_SYS_DEV_EXCA_EXCAVAR_H */
156