2 * Copyright (c) 2001 M. Warner Losh. All Rights Reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 * Per-slot data table.
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);
39 bus_space_handle_t bsh;
42 enum pcic_intr_way { pcic_iw_isa = 1, pcic_iw_pci = 2 };
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 */
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. */
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;
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);
84 pcic_intr_way_t *func_intr_way;
85 pcic_intr_way_t *csc_intr_way;
86 pcic_intr_mapirq_t *map_irq;
90 extern devclass_t pcic_devclass;
91 extern int pcic_override_irq;
93 int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
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,
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,
105 int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
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,
114 #if __FreeBSD_version >= 500000
118 int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
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,
125 timeout_t pcic_timeout;