2 * ss.h 1.28 2000/06/12 21:55:40
4 * The contents of this file are subject to the Mozilla Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License
7 * at http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific language governing rights and
12 * limitations under the License.
14 * The initial developer of the original code is David A. Hinds
15 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
16 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
18 * Alternatively, the contents of this file may be used under the
19 * terms of the GNU General Public License version 2 (the "GPL"), in which
20 * case the provisions of the GPL are applicable instead of the
21 * above. If you wish to allow the use of your version of this file
22 * only under the terms of the GPL and not to allow others to use
23 * your version of this file under the MPL, indicate your decision by
24 * deleting the provisions above and replace them with the notice and
25 * other provisions required by the GPL. If you do not delete the
26 * provisions above, a recipient may use your version of this file
27 * under either the MPL or the GPL.
33 #include <pcmcia/cs_types.h>
34 #include <pcmcia/cs.h>
35 #include <pcmcia/bulkmem.h>
36 #include <linux/device.h>
38 /* Definitions for card status flags for GetStatus */
39 #define SS_WRPROT 0x0001
40 #define SS_CARDLOCK 0x0002
41 #define SS_EJECTION 0x0004
42 #define SS_INSERTION 0x0008
43 #define SS_BATDEAD 0x0010
44 #define SS_BATWARN 0x0020
45 #define SS_READY 0x0040
46 #define SS_DETECT 0x0080
47 #define SS_POWERON 0x0100
49 #define SS_STSCHG 0x0400
50 #define SS_CARDBUS 0x0800
51 #define SS_3VCARD 0x1000
52 #define SS_XVCARD 0x2000
53 #define SS_PENDING 0x4000
55 /* InquireSocket capabilities */
56 #define SS_CAP_PAGE_REGS 0x0001
57 #define SS_CAP_VIRTUAL_BUS 0x0002
58 #define SS_CAP_MEM_ALIGN 0x0004
59 #define SS_CAP_STATIC_MAP 0x0008
60 #define SS_CAP_PCCARD 0x4000
61 #define SS_CAP_CARDBUS 0x8000
63 /* for GetSocket, SetSocket */
64 typedef struct socket_state_t
{
71 extern socket_state_t dead_socket
;
73 /* Socket configuration flags */
74 #define SS_PWR_AUTO 0x0010
75 #define SS_IOCARD 0x0020
76 #define SS_RESET 0x0040
77 #define SS_DMA_MODE 0x0080
78 #define SS_SPKR_ENA 0x0100
79 #define SS_OUTPUT_ENA 0x0200
80 #define SS_DEBOUNCED 0x0400 /* Tell driver that the debounce delay has ended */
82 /* Flags for I/O port and memory windows */
83 #define MAP_ACTIVE 0x01
84 #define MAP_16BIT 0x02
85 #define MAP_AUTOSZ 0x04
87 #define MAP_WRPROT 0x10
88 #define MAP_ATTRIB 0x20
89 #define MAP_USE_WAIT 0x40
90 #define MAP_PREFETCH 0x80
92 /* Use this just for bridge windows */
93 #define MAP_IOSPACE 0x20
95 typedef struct pccard_io_map
{
102 typedef struct pccard_mem_map
{
106 u_long sys_start
, sys_stop
;
110 typedef struct cb_bridge_map
{
119 struct pcmcia_socket
;
121 struct pccard_operations
{
122 int (*init
)(struct pcmcia_socket
*sock
);
123 int (*suspend
)(struct pcmcia_socket
*sock
);
124 int (*register_callback
)(struct pcmcia_socket
*sock
, void (*handler
)(void *, unsigned int), void * info
);
125 int (*get_status
)(struct pcmcia_socket
*sock
, u_int
*value
);
126 int (*get_socket
)(struct pcmcia_socket
*sock
, socket_state_t
*state
);
127 int (*set_socket
)(struct pcmcia_socket
*sock
, socket_state_t
*state
);
128 int (*set_io_map
)(struct pcmcia_socket
*sock
, struct pccard_io_map
*io
);
129 int (*set_mem_map
)(struct pcmcia_socket
*sock
, struct pccard_mem_map
*mem
);
133 * Calls to set up low-level "Socket Services" drivers
135 struct pcmcia_socket
;
137 typedef struct erase_busy_t
{
138 eraseq_entry_t
*erase
;
139 client_handle_t client
;
140 struct timer_list timeout
;
141 struct erase_busy_t
*prev
, *next
;
144 typedef struct io_window_t
{
146 ioaddr_t BasePort
, NumPorts
;
147 ioaddr_t InUse
, Config
;
150 #define WINDOW_MAGIC 0xB35C
151 typedef struct window_t
{
154 client_handle_t handle
;
155 struct pcmcia_socket
*sock
;
161 /* Maximum number of IO windows per socket */
164 /* Maximum number of memory windows per socket */
170 struct pcmcia_socket
{
171 struct module
*owner
;
173 struct pccard_operations
* ss_entry
;
174 socket_state_t socket
;
178 client_handle_t clients
;
180 pccard_mem_map cis_mem
;
182 struct config_t
*config
;
187 io_window_t io
[MAX_IO_WIN
];
188 window_t win
[MAX_WIN
];
189 struct region_t
*c_region
, *a_region
;
190 erase_busy_t erase_busy
;
191 struct list_head cis_cache
;
195 struct list_head socket_list
;
196 struct completion socket_released
;
199 unsigned int sock
; /* socket number */
202 /* socket capabilities */
208 struct pci_dev
* cb_dev
;
211 struct semaphore skt_sem
; /* protects socket h/w state */
213 struct task_struct
*thread
;
214 struct completion thread_done
;
215 wait_queue_head_t thread_wait
;
216 spinlock_t thread_lock
; /* protects thread_events */
217 unsigned int thread_events
;
219 /* pcmcia (16-bit) */
220 struct pcmcia_bus_socket
*pcmcia
;
222 /* cardbus (32-bit) */
223 #ifdef CONFIG_CARDBUS
224 struct resource
* cb_cis_res
;
229 struct class_device dev
;
230 void *driver_data
; /* data internal to the socket driver */
234 struct pcmcia_socket
* pcmcia_get_socket_by_nr(unsigned int nr
);
238 extern void pcmcia_parse_events(struct pcmcia_socket
*socket
, unsigned int events
);
239 extern int pcmcia_register_socket(struct pcmcia_socket
*socket
);
240 extern void pcmcia_unregister_socket(struct pcmcia_socket
*socket
);
242 extern struct class pcmcia_socket_class
;
244 /* socket drivers are expected to use these callbacks in their .drv struct */
245 extern int pcmcia_socket_dev_suspend(struct device
*dev
, u32 state
, u32 level
);
246 extern int pcmcia_socket_dev_resume(struct device
*dev
, u32 level
);
248 #endif /* _LINUX_SS_H */