Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / bus / pccard / pcicvar.h
1 /*
2  * Copyright (c) 2001 M. Warner Losh.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  * $FreeBSD: src/sys/pccard/pcicvar.h,v 1.15.2.11 2002/09/22 20:26:58 imp Exp $
25  * $DragonFly: src/sys/bus/pccard/Attic/pcicvar.h,v 1.2 2003/06/17 04:28:55 dillon Exp $
26  */
27
28 /*
29  *      Per-slot data table.
30  */
31 struct pcic_slot {
32         int offset;                     /* Offset value for index */
33         char controller;                /* Device type */
34         char revision;                  /* Device Revision */
35         struct slot *slt;               /* Back ptr to slot */
36         struct pcic_softc *sc;          /* Back pointer to softc */
37         u_int8_t (*getb)(struct pcic_slot *, int);
38         void   (*putb)(struct pcic_slot *, int, u_int8_t);
39         bus_space_tag_t bst;
40         bus_space_handle_t bsh;
41 };
42
43 enum pcic_intr_way { pcic_iw_isa = 1, pcic_iw_pci = 2 };
44
45 struct pcic_softc 
46 {
47         u_int32_t               slotmask;/* Mask of valid slots */
48         u_int32_t               flags;  /* Interesting flags */
49 #define PCIC_AB_POWER      0x00000001   /* Use old A/B step power */
50 #define PCIC_DF_POWER      0x00000002   /* Uses DF step regs  */
51 #define PCIC_PD_POWER      0x00000004   /* Uses CL-PD regs  */
52 #define PCIC_VG_POWER      0x00000008   /* Uses VG power regs */
53 #define PCIC_KING_POWER    0x00000010   /* Uses IBM KING regs  */
54 #define PCIC_RICOH_POWER   0x00000020   /* Uses the ricoh power regs */
55 #define PCIC_CARDBUS_POWER 0x00000040   /* Cardbus power regs */
56 #define PCIC_YENTA_HIGH_MEMORY 0x0080   /* Can do high memory mapping */
57
58         enum pcic_intr_way      csc_route; /* How to route csc interrupts */
59         enum pcic_intr_way      func_route; /* How to route function ints */
60         int                     iorid;  /* Rid of I/O region */
61         struct resource         *iores; /* resource for I/O region */
62         int                     memrid; /* Memory rid */
63         struct resource         *memres;/* Resource for memory mapped regs */
64         int                     irqrid; /* Irq rid */
65         struct resource         *irqres;/* Irq resource */
66         void                    *ih;    /* Our interrupt handler. */
67         int                     irq;
68         device_t                dev;    /* Our device */
69         void (*slot_poll)(void *);
70         struct callout_handle   timeout_ch;
71         struct pcic_slot        slots[PCIC_MAX_SLOTS];
72         int                     cd_pending; /* debounce timeout active */
73         int                     cd_present; /* debounced card-present state */
74         struct callout_handle   cd_ch;  /* handle for pcic_cd_insert */
75         struct pcic_chip        *chip;
76         driver_intr_t           *func_intr;
77         void                    *func_arg;
78 };
79
80 typedef int (pcic_intr_way_t)(struct pcic_slot *, enum pcic_intr_way);
81 typedef int (pcic_intr_mapirq_t)(struct pcic_slot *, int irq);
82 typedef void (pcic_init_t)(device_t);
83
84 struct pcic_chip
85 {
86         pcic_intr_way_t *func_intr_way;
87         pcic_intr_way_t *csc_intr_way;
88         pcic_intr_mapirq_t *map_irq;
89         pcic_init_t     *init;
90 };
91
92 extern devclass_t       pcic_devclass;
93 extern int              pcic_override_irq;
94
95 int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
96     struct resource *r);
97 struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
98     int *rid, u_long start, u_long end, u_long count, u_int flags);
99 int pcic_attach(device_t dev);
100 void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
101 int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
102     struct resource *r);
103 void pcic_dealloc(device_t dev);
104 void pcic_do_stat_delta(struct pcic_slot *sp);
105 int pcic_get_memory_offset(device_t bus, device_t child, int rid,
106     u_int32_t *offset);
107 int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
108     u_long *value);
109 unsigned char pcic_getb_io(struct pcic_slot *sp, int reg);
110 driver_intr_t   pcic_isa_intr;
111 int             pcic_isa_intr1(void *);
112 pcic_intr_mapirq_t pcic_isa_mapirq;
113 void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val);
114 int pcic_set_memory_offset(device_t bus, device_t child, int rid,
115     u_int32_t offset
116 #if __FreeBSD_version >= 500000
117     , u_int32_t *deltap
118 #endif
119     );
120 int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
121     u_long value);
122 void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask);
123 int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
124     int flags, driver_intr_t *intr, void *arg, void **cookiep);
125 int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
126     void *cookie);
127 timeout_t       pcic_timeout;