excavar.h revision 89948
1/* $FreeBSD: head/sys/dev/exca/excavar.h 89948 2002-01-29 06:48:38Z imp $ */
2
3/*
4 * Copyright (c) 2002 M Warner Losh.  All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * This software may be derived from NetBSD i82365.c and other files with
27 * the following copyright:
28 *
29 * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
30 *
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
33 * are met:
34 * 1. Redistributions of source code must retain the above copyright
35 *    notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 *    notice, this list of conditions and the following disclaimer in the
38 *    documentation and/or other materials provided with the distribution.
39 * 3. All advertising materials mentioning features or use of this software
40 *    must display the following acknowledgement:
41 *	This product includes software developed by Marc Horowitz.
42 * 4. The name of the author may not be used to endorse or promote products
43 *    derived from this software without specific prior written permission.
44 *
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
46 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
48 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
49 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
50 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
51 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
52 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
53 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
54 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57/*
58 * Structure to manage the ExCA part of the chip.
59 */
60struct exca_softc;
61typedef uint8_t (exca_read_t)(struct exca_softc *, int);
62typedef void (exca_write_t)(struct exca_softc *, int, uint8_t);
63
64struct exca_softc
65{
66	device_t	dev;
67	exca_read_t	*read_exca;
68	exca_write_t	*write_exca;
69	int		memalloc;
70	struct		pccard_mem_handle mem[EXCA_MEM_WINS];
71	int		ioalloc;
72	struct		pccard_io_handle io[EXCA_IO_WINS];
73	bus_space_tag_t	bst;
74	bus_space_handle_t bsh;
75	uint32_t	flags;
76#define EXCA_SOCKET_PRESENT	0x00000001
77	uint32_t	offset;
78};
79
80void exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn,
81    exca_read_t *rdfn, bus_space_tag_t, bus_space_handle_t, uint32_t);
82int exca_io_map(struct exca_softc *sc, int width, struct resource *r);
83int exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
84int exca_is_pcic(struct exca_softc *sc);
85int exca_mem_map(struct exca_softc *sc, int kind, struct resource *res);
86int exca_mem_set_flags(struct exca_softc *sc, struct resource *res,
87    uint32_t flags);
88int exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
89    uint32_t cardaddr, uint32_t *deltap);
90int exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
91int exca_probe_slots(device_t dev, struct exca_softc *, exca_write_t *,
92    exca_read_t *);
93void exca_reset(struct exca_softc *, device_t child);
94
95static __inline uint8_t
96exca_read(struct exca_softc *sc, int reg)
97{
98	return (sc->read_exca(sc, reg));
99}
100
101static __inline void
102exca_write(struct exca_softc *sc, int reg, uint8_t val)
103{
104	sc->write_exca(sc, reg, val);
105}
106
107static __inline void
108exca_setb(struct exca_softc *sc, int reg, uint8_t mask)
109{
110	exca_write(sc, reg, exca_read(sc, reg) | mask);
111}
112
113static __inline void
114exca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
115{
116	exca_write(sc, reg, exca_read(sc, reg) & ~mask);
117}
118