2001-05-16 07:32:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2001 M. Warner Losh. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Per-slot data table.
|
|
|
|
*/
|
|
|
|
struct pcic_slot {
|
|
|
|
int offset; /* Offset value for index */
|
|
|
|
char controller; /* Device type */
|
|
|
|
char revision; /* Device Revision */
|
|
|
|
struct slot *slt; /* Back ptr to slot */
|
2001-05-21 04:44:14 +00:00
|
|
|
struct pcic_softc *sc; /* Back pointer to softc */
|
2001-05-16 07:32:04 +00:00
|
|
|
u_char (*getb)(struct pcic_slot *, int);
|
|
|
|
void (*putb)(struct pcic_slot *, int, u_char);
|
2001-05-24 06:54:48 +00:00
|
|
|
bus_space_tag_t bst;
|
|
|
|
bus_space_handle_t bsh;
|
2001-07-01 23:41:43 +00:00
|
|
|
driver_intr_t *intr;
|
|
|
|
void *argp;
|
2001-05-16 07:32:04 +00:00
|
|
|
};
|
|
|
|
|
2001-05-28 02:53:02 +00:00
|
|
|
enum pcic_irq_type { isa_parallel, pci_parallel, isa_serial };
|
|
|
|
|
2001-05-16 07:32:04 +00:00
|
|
|
struct pcic_softc
|
|
|
|
{
|
2001-05-25 18:28:49 +00:00
|
|
|
u_int32_t slotmask;/* Mask of valid slots */
|
|
|
|
u_int32_t flags; /* Interesting flags */
|
2001-05-21 07:32:46 +00:00
|
|
|
#define PCIC_AB_POWER 0x00000001 /* Use old A/B step power */
|
|
|
|
#define PCIC_DF_POWER 0x00000002 /* Uses DF step regs */
|
|
|
|
#define PCIC_PD_POWER 0x00000004 /* Uses CL-PD regs */
|
|
|
|
#define PCIC_VG_POWER 0x00000008 /* Uses VG power regs */
|
|
|
|
#define PCIC_KING_POWER 0x00000010 /* Uses IBM KING regs */
|
2001-07-01 23:41:43 +00:00
|
|
|
#define PCIC_RICOH_POWER 0x0000020 /* Uses the ricoh power regs */
|
2001-05-28 02:53:02 +00:00
|
|
|
enum pcic_irq_type csc_route; /* How to route csc interrupts */
|
|
|
|
enum pcic_irq_type func_route; /* How to route function ints */
|
2001-05-25 18:28:49 +00:00
|
|
|
int iorid; /* Rid of I/O region */
|
|
|
|
struct resource *iores; /* resource for I/O region */
|
|
|
|
int memrid; /* Memory rid */
|
|
|
|
struct resource *memres;/* Resource for memory mapped regs */
|
|
|
|
int irqrid; /* Irq rid */
|
|
|
|
struct resource *irqres;/* Irq resource */
|
|
|
|
void *ih; /* Our interrupt handler. */
|
2001-06-04 03:29:06 +00:00
|
|
|
int irq;
|
2001-05-25 18:28:49 +00:00
|
|
|
device_t dev; /* Our device */
|
|
|
|
bus_space_tag_t bst; /* Bus tag for our regs */
|
|
|
|
bus_space_handle_t bsh; /* Bus handle for our regs */
|
2001-06-04 03:29:06 +00:00
|
|
|
void (*slot_poll)(void *);
|
2001-05-21 03:22:52 +00:00
|
|
|
struct callout_handle timeout_ch;
|
2001-05-16 07:32:04 +00:00
|
|
|
struct pcic_slot slots[PCIC_MAX_SLOTS];
|
2001-06-04 03:29:06 +00:00
|
|
|
int cd_pending;
|
2001-05-16 07:32:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern devclass_t pcic_devclass;
|
|
|
|
|
|
|
|
int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *r);
|
2001-05-28 02:53:02 +00:00
|
|
|
struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
|
|
|
|
int *rid, u_long start, u_long end, u_long count, u_int flags);
|
|
|
|
int pcic_attach(device_t dev);
|
|
|
|
void pcic_clrb(struct pcic_slot *sp, int reg, unsigned char mask);
|
2001-05-16 07:32:04 +00:00
|
|
|
int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
|
|
|
|
struct resource *r);
|
2001-05-28 02:53:02 +00:00
|
|
|
void pcic_dealloc(device_t dev);
|
2001-05-16 07:32:04 +00:00
|
|
|
int pcic_get_memory_offset(device_t bus, device_t child, int rid,
|
|
|
|
u_int32_t *offset);
|
2001-05-28 02:53:02 +00:00
|
|
|
int pcic_get_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long *value);
|
|
|
|
unsigned char pcic_getb_io(struct pcic_slot *sp, int reg);
|
|
|
|
void pcic_putb_io(struct pcic_slot *sp, int reg, unsigned char val);
|
2001-05-16 07:32:04 +00:00
|
|
|
int pcic_set_memory_offset(device_t bus, device_t child, int rid,
|
|
|
|
u_int32_t offset, u_int32_t *deltap);
|
2001-05-28 02:53:02 +00:00
|
|
|
int pcic_set_res_flags(device_t bus, device_t child, int restype, int rid,
|
|
|
|
u_long value);
|
2001-05-19 05:21:23 +00:00
|
|
|
void pcic_setb(struct pcic_slot *sp, int reg, unsigned char mask);
|
2001-05-28 02:53:02 +00:00
|
|
|
int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
|
|
|
|
int flags, driver_intr_t *intr, void *arg, void **cookiep);
|
|
|
|
int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
|
|
|
|
void *cookie);
|