4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * The initial developer of the original code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
12 * (C) 1999 David A. Hinds
15 #ifndef _LINUX_CS_INTERNAL_H
16 #define _LINUX_CS_INTERNAL_H
18 #include <linux/config.h>
20 #define CLIENT_MAGIC 0x51E6
21 typedef struct client_t client_t
;
23 /* Flags in client state */
24 #define CLIENT_CONFIG_LOCKED 0x0001
25 #define CLIENT_IRQ_REQ 0x0002
26 #define CLIENT_IO_REQ 0x0004
27 #define CLIENT_UNBOUND 0x0008
28 #define CLIENT_STALE 0x0010
29 #define CLIENT_WIN_REQ(i) (0x20<<(i))
30 #define CLIENT_CARDBUS 0x8000
32 #define REGION_MAGIC 0xE3C9
33 typedef struct region_t
{
42 #define REGION_STALE 0x01
44 /* Each card function gets one of these guys */
45 typedef struct config_t
{
48 u_int Vcc
, Vpp1
, Vpp2
;
51 u_char Status
, Pin
, Copy
, Option
, ExtStatus
;
60 struct cis_cache_entry
{
61 struct list_head node
;
65 unsigned char cache
[0];
68 /* Flags in config state */
69 #define CONFIG_LOCKED 0x01
70 #define CONFIG_IRQ_REQ 0x02
71 #define CONFIG_IO_REQ 0x04
73 /* Flags in socket state */
74 #define SOCKET_PRESENT 0x0008
75 #define SOCKET_INUSE 0x0010
76 #define SOCKET_SUSPEND 0x0080
77 #define SOCKET_WIN_REQ(i) (0x0100<<(i))
78 #define SOCKET_REGION_INFO 0x4000
79 #define SOCKET_CARDBUS 0x8000
80 #define SOCKET_CARDBUS_CONFIG 0x10000
82 static inline int cs_socket_get(struct pcmcia_socket
*skt
)
86 WARN_ON(skt
->state
& SOCKET_INUSE
);
88 ret
= try_module_get(skt
->owner
);
90 skt
->state
|= SOCKET_INUSE
;
94 static inline void cs_socket_put(struct pcmcia_socket
*skt
)
96 if (skt
->state
& SOCKET_INUSE
) {
97 skt
->state
&= ~SOCKET_INUSE
;
98 module_put(skt
->owner
);
102 #define CHECK_SOCKET(s) \
103 (((s) >= sockets) || (socket_table[s]->ops == NULL))
105 #define SOCKET(h) (h->socket)
106 #define CONFIG(h) (&SOCKET(h)->config[(h)->func])
109 int cb_alloc(struct pcmcia_socket
*s
);
110 void cb_free(struct pcmcia_socket
*s
);
111 int read_cb_mem(struct pcmcia_socket
*s
, int space
, u_int addr
, u_int len
, void *ptr
);
114 int pcmcia_read_cis_mem(struct pcmcia_socket
*s
, int attr
,
115 u_int addr
, u_int len
, void *ptr
);
116 void pcmcia_write_cis_mem(struct pcmcia_socket
*s
, int attr
,
117 u_int addr
, u_int len
, void *ptr
);
118 void release_cis_mem(struct pcmcia_socket
*s
);
119 void destroy_cis_cache(struct pcmcia_socket
*s
);
120 int verify_cis_cache(struct pcmcia_socket
*s
);
121 int pccard_read_tuple(struct pcmcia_socket
*s
, unsigned int function
, cisdata_t code
, void *parse
);
124 void pcmcia_validate_mem(struct pcmcia_socket
*s
);
125 struct resource
*pcmcia_find_io_region(unsigned long base
, int num
, unsigned long align
,
126 struct pcmcia_socket
*s
);
127 int pcmcia_adjust_io_region(struct resource
*res
, unsigned long r_start
,
128 unsigned long r_end
, struct pcmcia_socket
*s
);
129 struct resource
*pcmcia_find_mem_region(u_long base
, u_long num
, u_long align
,
130 int low
, struct pcmcia_socket
*s
);
131 void release_resource_db(struct pcmcia_socket
*s
);
133 /* In socket_sysfs.c */
134 extern struct class_interface pccard_sysfs_interface
;
137 extern struct rw_semaphore pcmcia_socket_list_rwsem
;
138 extern struct list_head pcmcia_socket_list
;
139 int pcmcia_get_window(struct pcmcia_socket
*s
, window_handle_t
*handle
, int idx
, win_req_t
*req
);
140 int pccard_get_configuration_info(struct pcmcia_socket
*s
, unsigned int function
, config_info_t
*config
);
141 int pccard_reset_card(struct pcmcia_socket
*skt
);
142 int pccard_get_status(struct pcmcia_socket
*s
, unsigned int function
, cs_status_t
*status
);
143 int pccard_access_configuration_register(struct pcmcia_socket
*s
, unsigned int function
, conf_reg_t
*reg
);
146 struct pcmcia_callback
{
147 struct module
*owner
;
148 int (*event
) (struct pcmcia_socket
*s
, event_t event
, int priority
);
149 void (*requery
) (struct pcmcia_socket
*s
);
152 int pccard_register_pcmcia(struct pcmcia_socket
*s
, struct pcmcia_callback
*c
);
154 #define cs_socket_name(skt) ((skt)->dev.class_id)
157 extern int cs_debug_level(int);
159 #define cs_dbg(skt, lvl, fmt, arg...) do { \
160 if (cs_debug_level(lvl)) \
161 printk(KERN_DEBUG "cs: %s: " fmt, \
162 cs_socket_name(skt) , ## arg); \
166 #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0)
169 #define cs_err(skt, fmt, arg...) \
170 printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.class_id , ## arg)
172 #endif /* _LINUX_CS_INTERNAL_H */