excavar.h revision 100703
1/* $FreeBSD: head/sys/dev/exca/excavar.h 100703 2002-07-26 08:01:08Z 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#ifndef _SYS_DEV_EXCA_EXCAVAR_H 58#define _SYS_DEV_EXCA_EXCAVAR_H 59 60/* 61 * Structure to manage the ExCA part of the chip. 62 */ 63struct exca_softc; 64 65struct exca_softc 66{ 67 device_t dev; 68 int memalloc; 69 struct pccard_mem_handle mem[EXCA_MEM_WINS]; 70 int ioalloc; 71 struct pccard_io_handle io[EXCA_IO_WINS]; 72 bus_space_tag_t bst; 73 bus_space_handle_t bsh; 74 uint32_t flags; 75#define EXCA_SOCKET_PRESENT 0x00000001 76#define EXCA_HAS_MEMREG_WIN 0x00000002 77 uint32_t offset; 78}; 79 80void exca_init(struct exca_softc *sc, device_t dev, 81 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 *); 92void exca_reset(struct exca_softc *, device_t child); 93 94static __inline uint8_t 95exca_read(struct exca_softc *sc, int reg) 96{ 97 return (bus_space_read_1(sc->bst, sc->bsh, sc->offset + reg)); 98} 99 100static __inline void 101exca_write(struct exca_softc *sc, int reg, uint8_t val) 102{ 103 return (bus_space_write_1(sc->bst, sc->bsh, sc->offset + reg, val)); 104} 105 106static __inline void 107exca_setb(struct exca_softc *sc, int reg, uint8_t mask) 108{ 109 exca_write(sc, reg, exca_read(sc, reg) | mask); 110} 111 112static __inline void 113exca_clrb(struct exca_softc *sc, int reg, uint8_t mask) 114{ 115 exca_write(sc, reg, exca_read(sc, reg) & ~mask); 116} 117 118#endif /* !_SYS_DEV_EXCA_EXCAVAR_H */ 119