FreeBSD/Linux Kernel Cross Reference
sys/pccard/slot.h
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 *-------------------------------------------------------------------------
10 *
11 * Copyright (c) 1995 Andrew McRae. All rights reserved.
12 *
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.
23 *
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.
34 *
35 * $FreeBSD: releng/5.0/sys/pccard/slot.h 100484 2002-07-22 06:46:10Z imp $
36 */
37
38 #ifndef _PCCARD_SLOT_H
39 #define _PCCARD_SLOT_H
40
41 /*
42 * Normally we shouldn't include stuff here, but we're trying to be
43 * compatible with the long, dark hand of the past.
44 */
45 #include <sys/param.h>
46 #include <sys/bus.h>
47 #include <machine/bus.h>
48 #include <sys/rman.h>
49 #include <machine/resource.h>
50 #if __FreeBSD_version >= 500000
51 #include <sys/selinfo.h>
52 #else
53 #include <sys/select.h>
54 #endif
55
56 /*
57 * Controller data - Specific to each slot controller.
58 */
59 struct slot;
60 struct slot_ctrl {
61 void (*mapirq)(struct slot *, int);
62 /* Map irq */
63 int (*mapmem)(struct slot *, int);
64 /* Map memory */
65 int (*mapio)(struct slot *, int);
66 /* Map io */
67 void (*reset)(void *);
68 /* init */
69 void (*disable)(struct slot *);
70 /* Disable slot */
71 int (*power)(struct slot *);
72 /* Set power values */
73 int (*ioctl)(struct slot *, int, caddr_t);
74 /* ioctl to lower level */
75 void (*resume)(struct slot *);
76 /* suspend/resume support */
77 int maxmem; /* Number of allowed memory windows */
78 int maxio; /* Number of allowed I/O windows */
79 };
80
81 /*
82 * Device structure for cards. Each card may have one
83 * or more pccard drivers attached to it; each driver is assumed
84 * to require at most one interrupt handler, one I/O block
85 * and one memory block. This structure is used to link the different
86 * devices together.
87 */
88 struct pccard_devinfo {
89 uint8_t name[128];
90 int running; /* Current state of driver */
91 uint8_t misc[DEV_MISC_LEN]; /* For any random info */
92 uint8_t manufstr[DEV_MAX_CIS_LEN];
93 uint8_t versstr[DEV_MAX_CIS_LEN];
94 uint32_t manufacturer; /* Manufacturer ID */
95 uint32_t product; /* Product ID */
96 uint32_t prodext; /* Product ID (extended) */
97 struct slot *slt; /* Back pointer to slot */
98 struct resource_list resources;
99 };
100
101 /*
102 * Per-slot structure.
103 */
104 struct slot {
105 int slotnum; /* Slot number */
106 int flags; /* Slot flags (see below) */
107 int rwmem; /* Read/write flags */
108 int irq; /* IRQ allocated (0 = none) */
109
110 /*
111 * flags.
112 */
113 unsigned int insert_seq; /* Firing up under the card */
114 struct callout_handle insert_ch;/* Insert event timeout handle */
115 struct callout_handle poff_ch; /* Power Off timeout handle */
116
117 enum cardstate state, laststate; /* Current/last card states */
118 struct selinfo selp; /* Info for select */
119 struct mem_desc mem[NUM_MEM_WINDOWS]; /* Memory windows */
120 struct io_desc io[NUM_IO_WINDOWS]; /* I/O windows */
121 struct power pwr; /* Power values */
122 struct slot_ctrl *ctrl; /* Per-controller data */
123 void *cdata; /* Controller specific data */
124 int pwr_off_pending;/* Power status of slot */
125 device_t dev; /* Config system device. */
126 dev_t d; /* fs device */
127 };
128
129 #define PCCARD_DEVICE2SOFTC(d) ((struct slot *) device_get_softc(d))
130 #define PCCARD_DEV2SOFTC(d) ((struct slot *) (d)->si_drv1)
131
132 enum card_event { card_removed, card_inserted, card_deactivated };
133
134 struct slot *pccard_init_slot(device_t, struct slot_ctrl *);
135 void pccard_event(struct slot *, enum card_event);
136 int pccard_suspend(device_t);
137 int pccard_resume(device_t);
138
139 #endif /* !_PCCARD_SLOT_H */
Cache object: 39a1935b093b427c2cbc7c2d0c1064b2
|