186d7f5d3SJohn Marino /* $FreeBSD: src/sys/dev/exca/excavar.h,v 1.7 2005/01/06 01:42:40 imp Exp $ */
286d7f5d3SJohn Marino /* $DragonFly: src/sys/dev/pccard/exca/excavar.h,v 1.2 2007/07/05 12:08:54 sephe Exp $ */
386d7f5d3SJohn Marino
486d7f5d3SJohn Marino /*-
586d7f5d3SJohn Marino * Copyright (c) 2002 M Warner Losh. All rights reserved.
686d7f5d3SJohn Marino *
786d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without
886d7f5d3SJohn Marino * modification, are permitted provided that the following conditions
986d7f5d3SJohn Marino * are met:
1086d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright
1186d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer.
1286d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright
1386d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the
1486d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution.
1586d7f5d3SJohn Marino *
1686d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1786d7f5d3SJohn Marino * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1886d7f5d3SJohn Marino * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1986d7f5d3SJohn Marino * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2086d7f5d3SJohn Marino * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2186d7f5d3SJohn Marino * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2286d7f5d3SJohn Marino * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2386d7f5d3SJohn Marino * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2486d7f5d3SJohn Marino * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2586d7f5d3SJohn Marino * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2686d7f5d3SJohn Marino *
2786d7f5d3SJohn Marino * This software may be derived from NetBSD i82365.c and other files with
2886d7f5d3SJohn Marino * the following copyright:
2986d7f5d3SJohn Marino *
3086d7f5d3SJohn Marino * Copyright (c) 1997 Marc Horowitz. All rights reserved.
3186d7f5d3SJohn Marino *
3286d7f5d3SJohn Marino * Redistribution and use in source and binary forms, with or without
3386d7f5d3SJohn Marino * modification, are permitted provided that the following conditions
3486d7f5d3SJohn Marino * are met:
3586d7f5d3SJohn Marino * 1. Redistributions of source code must retain the above copyright
3686d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer.
3786d7f5d3SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright
3886d7f5d3SJohn Marino * notice, this list of conditions and the following disclaimer in the
3986d7f5d3SJohn Marino * documentation and/or other materials provided with the distribution.
4086d7f5d3SJohn Marino * 3. All advertising materials mentioning features or use of this software
4186d7f5d3SJohn Marino * must display the following acknowledgement:
4286d7f5d3SJohn Marino * This product includes software developed by Marc Horowitz.
4386d7f5d3SJohn Marino * 4. The name of the author may not be used to endorse or promote products
4486d7f5d3SJohn Marino * derived from this software without specific prior written permission.
4586d7f5d3SJohn Marino *
4686d7f5d3SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
4786d7f5d3SJohn Marino * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
4886d7f5d3SJohn Marino * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
4986d7f5d3SJohn Marino * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5086d7f5d3SJohn Marino * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5186d7f5d3SJohn Marino * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5286d7f5d3SJohn Marino * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5386d7f5d3SJohn Marino * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5486d7f5d3SJohn Marino * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5586d7f5d3SJohn Marino * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5686d7f5d3SJohn Marino */
5786d7f5d3SJohn Marino
5886d7f5d3SJohn Marino #ifndef _SYS_DEV_EXCA_EXCAVAR_H
5986d7f5d3SJohn Marino #define _SYS_DEV_EXCA_EXCAVAR_H
6086d7f5d3SJohn Marino
6186d7f5d3SJohn Marino /*
6286d7f5d3SJohn Marino * Structure to manage the ExCA part of the chip.
6386d7f5d3SJohn Marino */
6486d7f5d3SJohn Marino struct exca_softc;
6586d7f5d3SJohn Marino typedef uint8_t (exca_getb_fn)(struct exca_softc *, int);
6686d7f5d3SJohn Marino typedef void (exca_putb_fn)(struct exca_softc *, int, uint8_t);
6786d7f5d3SJohn Marino
6886d7f5d3SJohn Marino struct exca_softc
6986d7f5d3SJohn Marino {
7086d7f5d3SJohn Marino device_t dev;
7186d7f5d3SJohn Marino int memalloc;
7286d7f5d3SJohn Marino struct pccard_mem_handle mem[EXCA_MEM_WINS];
7386d7f5d3SJohn Marino int ioalloc;
7486d7f5d3SJohn Marino struct pccard_io_handle io[EXCA_IO_WINS];
7586d7f5d3SJohn Marino bus_space_tag_t bst;
7686d7f5d3SJohn Marino bus_space_handle_t bsh;
7786d7f5d3SJohn Marino uint32_t flags;
7886d7f5d3SJohn Marino #define EXCA_SOCKET_PRESENT 0x00000001
7986d7f5d3SJohn Marino #define EXCA_HAS_MEMREG_WIN 0x00000002
8086d7f5d3SJohn Marino #define EXCA_CARD_OK 0x00000004
8186d7f5d3SJohn Marino #define EXCA_EVENT 0x80000000
8286d7f5d3SJohn Marino uint32_t offset;
8386d7f5d3SJohn Marino int chipset;
8486d7f5d3SJohn Marino #define EXCA_CARDBUS 0
8586d7f5d3SJohn Marino #define EXCA_I82365 1 /* Intel i82365SL-A/B or clone */
8686d7f5d3SJohn Marino #define EXCA_I82365SL_DF 2 /* Intel i82365sl-DF step */
8786d7f5d3SJohn Marino #define EXCA_VLSI 3 /* VLSI chip */
8886d7f5d3SJohn Marino #define EXCA_PD6710 4 /* Cirrus logic PD6710 */
8986d7f5d3SJohn Marino #define EXCA_PD6722 5 /* Cirrus logic PD6722 */
9086d7f5d3SJohn Marino #define EXCA_PD6729 6 /* Cirrus Logic PD6729 */
9186d7f5d3SJohn Marino #define EXCA_VG365 7 /* Vadem 365 */
9286d7f5d3SJohn Marino #define EXCA_VG465 8 /* Vadem 465 */
9386d7f5d3SJohn Marino #define EXCA_VG468 9 /* Vadem 468 */
9486d7f5d3SJohn Marino #define EXCA_VG469 10 /* Vadem 469 */
9586d7f5d3SJohn Marino #define EXCA_RF5C296 11 /* Ricoh RF5C296 */
9686d7f5d3SJohn Marino #define EXCA_RF5C396 12 /* Ricoh RF5C396 */
9786d7f5d3SJohn Marino #define EXCA_IBM 13 /* IBM clone */
9886d7f5d3SJohn Marino #define EXCA_IBM_KING 14 /* IBM KING PCMCIA Controller */
9986d7f5d3SJohn Marino #define EXCA_BOGUS -1 /* Invalid/not present/etc */
10086d7f5d3SJohn Marino exca_getb_fn *getb;
10186d7f5d3SJohn Marino exca_putb_fn *putb;
10286d7f5d3SJohn Marino device_t pccarddev;
10386d7f5d3SJohn Marino uint32_t status; /* status, hw dependent */
10486d7f5d3SJohn Marino };
10586d7f5d3SJohn Marino
10686d7f5d3SJohn Marino void exca_init(struct exca_softc *sc, device_t dev,
10786d7f5d3SJohn Marino bus_space_tag_t, bus_space_handle_t, uint32_t);
10886d7f5d3SJohn Marino void exca_insert(struct exca_softc *sc);
10986d7f5d3SJohn Marino int exca_io_map(struct exca_softc *sc, int width, struct resource *r);
11086d7f5d3SJohn Marino int exca_io_unmap_res(struct exca_softc *sc, struct resource *res);
11186d7f5d3SJohn Marino int exca_is_pcic(struct exca_softc *sc);
11286d7f5d3SJohn Marino int exca_mem_map(struct exca_softc *sc, int kind, struct resource *res);
11386d7f5d3SJohn Marino int exca_mem_set_flags(struct exca_softc *sc, struct resource *res,
11486d7f5d3SJohn Marino uint32_t flags);
11586d7f5d3SJohn Marino int exca_mem_set_offset(struct exca_softc *sc, struct resource *res,
11686d7f5d3SJohn Marino uint32_t cardaddr, uint32_t *deltap);
11786d7f5d3SJohn Marino int exca_mem_unmap_res(struct exca_softc *sc, struct resource *res);
11886d7f5d3SJohn Marino int exca_probe_slots(device_t dev, struct exca_softc *exca,
11986d7f5d3SJohn Marino bus_space_tag_t iot, bus_space_handle_t ioh);
12086d7f5d3SJohn Marino void exca_removal(struct exca_softc *);
12186d7f5d3SJohn Marino void exca_reset(struct exca_softc *, device_t child);
12286d7f5d3SJohn Marino
12386d7f5d3SJohn Marino /* bus/device interfaces */
12486d7f5d3SJohn Marino int exca_activate_resource(struct exca_softc *exca, device_t child, int type,
12586d7f5d3SJohn Marino int rid, struct resource *res);
12686d7f5d3SJohn Marino int exca_deactivate_resource(struct exca_softc *exca, device_t child, int type,
12786d7f5d3SJohn Marino int rid, struct resource *res);
12886d7f5d3SJohn Marino
12986d7f5d3SJohn Marino static __inline uint8_t
exca_getb(struct exca_softc * sc,int reg)13086d7f5d3SJohn Marino exca_getb(struct exca_softc *sc, int reg)
13186d7f5d3SJohn Marino {
13286d7f5d3SJohn Marino return (sc->getb(sc, reg));
13386d7f5d3SJohn Marino }
13486d7f5d3SJohn Marino
13586d7f5d3SJohn Marino static __inline void
exca_putb(struct exca_softc * sc,int reg,uint8_t val)13686d7f5d3SJohn Marino exca_putb(struct exca_softc *sc, int reg, uint8_t val)
13786d7f5d3SJohn Marino {
13886d7f5d3SJohn Marino sc->putb(sc, reg, val);
13986d7f5d3SJohn Marino }
14086d7f5d3SJohn Marino
14186d7f5d3SJohn Marino static __inline void
exca_setb(struct exca_softc * sc,int reg,uint8_t mask)14286d7f5d3SJohn Marino exca_setb(struct exca_softc *sc, int reg, uint8_t mask)
14386d7f5d3SJohn Marino {
14486d7f5d3SJohn Marino exca_putb(sc, reg, exca_getb(sc, reg) | mask);
14586d7f5d3SJohn Marino }
14686d7f5d3SJohn Marino
14786d7f5d3SJohn Marino static __inline void
exca_clrb(struct exca_softc * sc,int reg,uint8_t mask)14886d7f5d3SJohn Marino exca_clrb(struct exca_softc *sc, int reg, uint8_t mask)
14986d7f5d3SJohn Marino {
15086d7f5d3SJohn Marino exca_putb(sc, reg, exca_getb(sc, reg) & ~mask);
15186d7f5d3SJohn Marino }
15286d7f5d3SJohn Marino
15386d7f5d3SJohn Marino #endif /* !_SYS_DEV_EXCA_EXCAVAR_H */
154