excavar.h revision 89948
189948Simp/* $FreeBSD: head/sys/dev/exca/excavar.h 89948 2002-01-29 06:48:38Z 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
5789948Simp/*
5889948Simp * Structure to manage the ExCA part of the chip.
5989948Simp */
6089948Simpstruct exca_softc;
6189948Simptypedef uint8_t (exca_read_t)(struct exca_softc *, int);
6289948Simptypedef void (exca_write_t)(struct exca_softc *, int, uint8_t);
6389948Simp
6489948Simpstruct exca_softc
6589948Simp{
6689948Simp	device_t	dev;
6789948Simp	exca_read_t	*read_exca;
6889948Simp	exca_write_t	*write_exca;
6989948Simp	int		memalloc;
7089948Simp	struct		pccard_mem_handle mem[EXCA_MEM_WINS];
7189948Simp	int		ioalloc;
7289948Simp	struct		pccard_io_handle io[EXCA_IO_WINS];
7389948Simp	bus_space_tag_t	bst;
7489948Simp	bus_space_handle_t bsh;
7589948Simp	uint32_t	flags;
7689948Simp#define EXCA_SOCKET_PRESENT	0x00000001
7789948Simp	uint32_t	offset;
7889948Simp};
7989948Simp
8089948Simpvoid exca_init(struct exca_softc *sc, device_t dev, exca_write_t *wrfn,
8189948Simp    exca_read_t *rdfn, bus_space_tag_t, bus_space_handle_t, uint32_t);
8289948Simpint exca_io_map(struct exca_softc *sc, int width, struct resource *r);
8389948Simpint exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
8489948Simpint exca_is_pcic(struct exca_softc *sc);
8589948Simpint exca_mem_map(struct exca_softc *sc, int kind, struct resource *res);
8689948Simpint exca_mem_set_flags(struct exca_softc *sc, struct resource *res,
8789948Simp    uint32_t flags);
8889948Simpint exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
8989948Simp    uint32_t cardaddr, uint32_t *deltap);
9089948Simpint exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
9189948Simpint exca_probe_slots(device_t dev, struct exca_softc *, exca_write_t *,
9289948Simp    exca_read_t *);
9389948Simpvoid exca_reset(struct exca_softc *, device_t child);
9489948Simp
9589948Simpstatic __inline uint8_t
9689948Simpexca_read(struct exca_softc *sc, int reg)
9789948Simp{
9889948Simp	return (sc->read_exca(sc, reg));
9989948Simp}
10089948Simp
10189948Simpstatic __inline void
10289948Simpexca_write(struct exca_softc *sc, int reg, uint8_t val)
10389948Simp{
10489948Simp	sc->write_exca(sc, reg, val);
10589948Simp}
10689948Simp
10789948Simpstatic __inline void
10889948Simpexca_setb(struct exca_softc *sc, int reg, uint8_t mask)
10989948Simp{
11089948Simp	exca_write(sc, reg, exca_read(sc, reg) | mask);
11189948Simp}
11289948Simp
11389948Simpstatic __inline void
11489948Simpexca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
11589948Simp{
11689948Simp	exca_write(sc, reg, exca_read(sc, reg) & ~mask);
11789948Simp}
118