2 * cs_internal.h -- definitions internal to the PCMCIA core modules
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
13 * (C) 2003 - 2008 Dominik Brodowski
16 * This file contains definitions _only_ needed by the PCMCIA core modules.
17 * It must not be included by PCMCIA socket drivers or by PCMCIA device
21 #ifndef _LINUX_CS_INTERNAL_H
22 #define _LINUX_CS_INTERNAL_H
24 #include <linux/kref.h>
26 /* Flags in client state */
27 #define CLIENT_WIN_REQ(i) (0x1<<(i))
29 /* Each card function gets one of these guys */
30 typedef struct config_t {
33 unsigned int Attributes;
35 unsigned int ConfigBase;
36 unsigned char Status, Pin, Copy, Option, ExtStatus;
37 unsigned int CardValues;
45 struct cis_cache_entry {
46 struct list_head node;
50 unsigned char cache[0];
53 /* Flags in config state */
54 #define CONFIG_LOCKED 0x01
55 #define CONFIG_IRQ_REQ 0x02
56 #define CONFIG_IO_REQ 0x04
58 /* Flags in socket state */
59 #define SOCKET_PRESENT 0x0008
60 #define SOCKET_INUSE 0x0010
61 #define SOCKET_SUSPEND 0x0080
62 #define SOCKET_WIN_REQ(i) (0x0100<<(i))
63 #define SOCKET_CARDBUS 0x8000
64 #define SOCKET_CARDBUS_CONFIG 0x10000
66 static inline int cs_socket_get(struct pcmcia_socket *skt)
70 WARN_ON(skt->state & SOCKET_INUSE);
72 ret = try_module_get(skt->owner);
74 skt->state |= SOCKET_INUSE;
78 static inline void cs_socket_put(struct pcmcia_socket *skt)
80 if (skt->state & SOCKET_INUSE) {
81 skt->state &= ~SOCKET_INUSE;
82 module_put(skt->owner);
86 #ifdef CONFIG_PCMCIA_DEBUG
87 extern int cs_debug_level(int);
89 #define cs_dbg(skt, lvl, fmt, arg...) do { \
90 if (cs_debug_level(lvl)) \
91 dev_printk(KERN_DEBUG, &skt->dev, \
92 "cs: " fmt, ## arg); \
94 #define __cs_dbg(lvl, fmt, arg...) do { \
95 if (cs_debug_level(lvl)) \
97 "cs: " fmt, ## arg); \
101 #define cs_dbg(skt, lvl, fmt, arg...) do { } while (0)
102 #define __cs_dbg(lvl, fmt, arg...) do { } while (0)
105 #define cs_err(skt, fmt, arg...) \
106 dev_printk(KERN_ERR, &skt->dev, "cs: " fmt, ## arg)
110 * Stuff internal to module "pcmcia_core":
114 int verify_cis_cache(struct pcmcia_socket *s);
117 void release_resource_db(struct pcmcia_socket *s);
120 extern int pccard_sysfs_add_socket(struct device *dev);
121 extern void pccard_sysfs_remove_socket(struct device *dev);
124 int cb_alloc(struct pcmcia_socket *s);
125 void cb_free(struct pcmcia_socket *s);
126 int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len,
132 * Stuff exported by module "pcmcia_core" to module "pcmcia"
135 struct pcmcia_callback{
136 struct module *owner;
137 int (*event) (struct pcmcia_socket *s,
138 event_t event, int priority);
139 void (*requery) (struct pcmcia_socket *s, int new_cis);
140 int (*suspend) (struct pcmcia_socket *s);
141 int (*resume) (struct pcmcia_socket *s);
145 extern struct rw_semaphore pcmcia_socket_list_rwsem;
146 extern struct list_head pcmcia_socket_list;
147 int pcmcia_get_window(struct pcmcia_socket *s,
148 window_handle_t *handle,
151 int pccard_reset_card(struct pcmcia_socket *skt);
152 int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
155 int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
156 u_int addr, u_int len, void *ptr);
157 void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
158 u_int addr, u_int len, void *ptr);
159 void release_cis_mem(struct pcmcia_socket *s);
160 void destroy_cis_cache(struct pcmcia_socket *s);
161 int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
162 cisdata_t code, void *parse);
165 int pcmcia_validate_mem(struct pcmcia_socket *s);
166 struct resource *pcmcia_find_io_region(unsigned long base,
169 struct pcmcia_socket *s);
170 int pcmcia_adjust_io_region(struct resource *res,
171 unsigned long r_start,
173 struct pcmcia_socket *s);
174 struct resource *pcmcia_find_mem_region(u_long base,
178 struct pcmcia_socket *s);
180 #endif /* _LINUX_CS_INTERNAL_H */