Correction to my commit from yesterday:
[dragonfly/port-amd64.git] / sys / bus / pccard / slot.h
blob3d2ee4988acfc457f843b714d4fdd8be2673011f
1 /*
2 * Slot structures for PC-CARD interface.
3 * Each slot has a controller specific structure
4 * attached to it. A slot number allows
5 * mapping from the character device to the
6 * slot structure. This is separate to the
7 * controller slot number to allow multiple controllers
8 * to be accessed.
9 *-------------------------------------------------------------------------
11 * Copyright (c) 1995 Andrew McRae. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. The name of the author may not be used to endorse or promote products
22 * derived from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 * $FreeBSD: src/sys/pccard/slot.h,v 1.25.2.5 2002/09/22 20:26:58 imp Exp $
36 * $DragonFly: src/sys/bus/pccard/Attic/slot.h,v 1.7 2006/10/25 20:55:51 dillon Exp $
39 #ifndef _PCCARD_SLOT_H
40 #define _PCCARD_SLOT_H
43 * Normally we shouldn't include stuff here, but we're trying to be
44 * compatible with the long, dark hand of the past.
46 #include <sys/param.h>
47 #include <sys/bus.h>
48 #include <sys/rman.h>
49 #include <sys/selinfo.h>
52 * Controller data - Specific to each slot controller.
54 struct slot;
55 struct slot_ctrl {
56 void (*mapirq)(struct slot *, int);
57 /* Map irq */
58 int (*mapmem)(struct slot *, int);
59 /* Map memory */
60 int (*mapio)(struct slot *, int);
61 /* Map io */
62 void (*reset)(void *);
63 /* init */
64 void (*disable)(struct slot *);
65 /* Disable slot */
66 int (*power)(struct slot *);
67 /* Set power values */
68 int (*ioctl)(struct slot *, int, caddr_t);
69 /* ioctl to lower level */
70 void (*resume)(struct slot *);
71 /* suspend/resume support */
72 int maxmem; /* Number of allowed memory windows */
73 int maxio; /* Number of allowed I/O windows */
77 * Device structure for cards. Each card may have one
78 * or more pccard drivers attached to it; each driver is assumed
79 * to require at most one interrupt handler, one I/O block
80 * and one memory block. This structure is used to link the different
81 * devices together.
83 struct pccard_devinfo {
84 uint8_t name[128];
85 int running; /* Current state of driver */
86 uint8_t misc[DEV_MISC_LEN]; /* For any random info */
87 uint8_t manufstr[DEV_MAX_CIS_LEN];
88 uint8_t versstr[DEV_MAX_CIS_LEN];
89 uint32_t manufacturer; /* Manufacturer ID */
90 uint32_t product; /* Product ID */
91 uint32_t prodext; /* Product ID (extended) */
92 struct slot *slt; /* Back pointer to slot */
93 struct resource_list resources;
97 * Per-slot structure.
99 struct slot {
100 int slotnum; /* Slot number */
101 int flags; /* Slot flags (see below) */
102 int rwmem; /* Read/write flags */
103 int irq; /* IRQ allocated (0 = none) */
106 * flags.
108 unsigned int insert_seq; /* Firing up under the card */
109 #if 0
110 struct callout insert_ch; /* Insert event timeout handle */
111 struct callout poff_ch; /* Power Off timeout handle */
112 #endif
114 enum cardstate state, laststate; /* Current/last card states */
115 struct selinfo selp; /* Info for select */
116 struct mem_desc mem[NUM_MEM_WINDOWS]; /* Memory windows */
117 struct io_desc io[NUM_IO_WINDOWS]; /* I/O windows */
118 struct power pwr; /* Power values */
119 struct slot_ctrl *ctrl; /* Per-controller data */
120 void *cdata; /* Controller specific data */
121 int pwr_off_pending;/* Power status of slot */
122 device_t dev; /* Config system device. */
123 cdev_t d; /* fs device */
126 #define PCCARD_DEVICE2SOFTC(d) ((struct slot *) device_get_softc(d))
127 #define PCCARD_DEV2SOFTC(d) ((struct slot *) (d)->si_drv1)
129 enum card_event { card_removed, card_inserted, card_deactivated };
131 struct slot *pccard_init_slot(device_t, struct slot_ctrl *);
132 void pccard_event(struct slot *, enum card_event);
133 int pccard_suspend(device_t);
134 int pccard_resume(device_t);
136 #endif /* !_PCCARD_SLOT_H */