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