]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/pccard/pcicvar.h
This commit was generated by cvs2svn to compensate for changes in r96364,
[FreeBSD/FreeBSD.git] / sys / 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$
25  */
26
27 /*
28  *      Per-slot data table.
29  */
30 struct pcic_slot {
31         int offset;                     /* Offset value for index */
32         char controller;                /* Device type */
33         char revision;                  /* Device Revision */
34         struct slot *slt;               /* Back ptr to slot */
35         struct pcic_softc *sc;          /* Back pointer to softc */
36         u_int8_t (*getb)(struct pcic_slot *, int);
37         void   (*putb)(struct pcic_slot *, int, u_int8_t);
38         bus_space_tag_t bst;
39         bus_space_handle_t bsh;
40 };
41
42 enum pcic_intr_way { pcic_iw_isa = 1, pcic_iw_pci = 2 };
43
44 struct pcic_softc 
45 {
46         u_int32_t               slotmask;/* Mask of valid slots */
47         u_int32_t               flags;  /* Interesting flags */
48 #define PCIC_AB_POWER      0x00000001   /* Use old A/B step power */
49 #define PCIC_DF_POWER      0x00000002   /* Uses DF step regs  */
50 #define PCIC_PD_POWER      0x00000004   /* Uses CL-PD regs  */
51 #define PCIC_VG_POWER      0x00000008   /* Uses VG power regs */
52 #define PCIC_KING_POWER    0x00000010   /* Uses IBM KING regs  */
53 #define PCIC_RICOH_POWER   0x00000020   /* Uses the ricoh power regs */
54 #define PCIC_CARDBUS_POWER 0x00000040   /* Cardbus power regs */
55
56         enum pcic_intr_way      csc_route; /* How to route csc interrupts */
57         enum pcic_intr_way      func_route; /* How to route function ints */
58         int                     iorid;  /* Rid of I/O region */
59         struct resource         *iores; /* resource for I/O region */
60         int                     memrid; /* Memory rid */
61         struct resource         *memres;/* Resource for memory mapped regs */
62         int                     irqrid; /* Irq rid */
63         struct resource         *irqres;/* Irq resource */
64         void                    *ih;    /* Our interrupt handler. */
65         int                     irq;
66         device_t                dev;    /* Our device */
67         void (*slot_poll)(void *);
68         struct callout_handle   timeout_ch;
69         struct pcic_slot        slots[PCIC_MAX_SLOTS];
70         int                     cd_pending; /* debounce timeout active */
71         int                     cd_present; /* debounced card-present state */
72         struct callout_handle   cd_ch;  /* handle for pcic_cd_insert */
73         struct pcic_chip        *chip;
74         driver_intr_t           *func_intr;
75         void                    *func_arg;
76 };
77
78 typedef int (pcic_intr_way_t)(struct pcic_slot *, enum pcic_intr_way);
79 typedef int (pcic_intr_mapirq_t)(struct pcic_slot *, int irq);
80 typedef void (pcic_init_t)(device_t);
81
82 struct pcic_chip
83 {
84         pcic_intr_way_t *func_intr_way;
85         pcic_intr_way_t *csc_intr_way;
86         pcic_intr_mapirq_t *map_irq;
87         pcic_init_t     *init;
88 };
89
90 extern devclass_t       pcic_devclass;
91 extern int              pcic_override_irq;
92
93 int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
94     struct resource *r);
95 struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
96     int *rid, u_long start, u_long end, u_long count, u_int flags);
97 int pcic_attach(device_t dev);
98 void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
99 int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
100     struct resource *r);
101 void pcic_dealloc(device_t dev);
102 void pcic_do_stat_delta(struct pcic_slot *sp);
103 int pcic_get_memory_offset(device_t bus, device_t child, int rid,
104     u_int32_t *offset);
105 int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
106     u_long *value);
107 unsigned char pcic_getb_io(struct pcic_slot *sp, int reg);
108 driver_intr_t   pcic_isa_intr;
109 int             pcic_isa_intr1(void *);
110 pcic_intr_mapirq_t pcic_isa_mapirq;
111 void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val);
112 int pcic_set_memory_offset(device_t bus, device_t child, int rid,
113     u_int32_t offset
114 #if __FreeBSD_version >= 500000
115     , u_int32_t *deltap
116 #endif
117     );
118 int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
119     u_long value);
120 void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask);
121 int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
122     int flags, driver_intr_t *intr, void *arg, void **cookiep);
123 int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
124     void *cookie);
125 timeout_t       pcic_timeout;