1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #ifndef _LINUX_CS_INTERNAL_H
18 #define _LINUX_CS_INTERNAL_H
19
20 #include <linux/kref.h>
21
22
23 #define CLIENT_WIN_REQ(i) (0x1<<(i))
24
25
26 #define BIND_FN_ALL 0xff
27
28
29 typedef struct config_t {
30 struct kref ref;
31 unsigned int state;
32
33 struct resource io[MAX_IO_WIN];
34 struct resource mem[MAX_WIN];
35 } config_t;
36
37
38 struct cis_cache_entry {
39 struct list_head node;
40 unsigned int addr;
41 unsigned int len;
42 unsigned int attr;
43 unsigned char cache[0];
44 };
45
46 struct pccard_resource_ops {
47 int (*validate_mem) (struct pcmcia_socket *s);
48 int (*find_io) (struct pcmcia_socket *s,
49 unsigned int attr,
50 unsigned int *base,
51 unsigned int num,
52 unsigned int align,
53 struct resource **parent);
54 struct resource* (*find_mem) (unsigned long base, unsigned long num,
55 unsigned long align, int low,
56 struct pcmcia_socket *s);
57 int (*init) (struct pcmcia_socket *s);
58 void (*exit) (struct pcmcia_socket *s);
59 };
60
61
62 #define CONFIG_LOCKED 0x01
63 #define CONFIG_IRQ_REQ 0x02
64 #define CONFIG_IO_REQ 0x04
65
66
67 #define SOCKET_PRESENT 0x0008
68 #define SOCKET_INUSE 0x0010
69 #define SOCKET_IN_RESUME 0x0040
70 #define SOCKET_SUSPEND 0x0080
71 #define SOCKET_WIN_REQ(i) (0x0100<<(i))
72 #define SOCKET_CARDBUS 0x8000
73 #define SOCKET_CARDBUS_CONFIG 0x10000
74
75
76
77
78
79 extern int static_init(struct pcmcia_socket *s);
80 extern struct resource *pcmcia_make_resource(resource_size_t start,
81 resource_size_t end,
82 unsigned long flags, const char *name);
83
84
85
86
87
88
89 extern int pccard_sysfs_add_socket(struct device *dev);
90 extern void pccard_sysfs_remove_socket(struct device *dev);
91
92
93 int cb_alloc(struct pcmcia_socket *s);
94 void cb_free(struct pcmcia_socket *s);
95
96
97
98
99
100
101
102 struct pcmcia_callback{
103 struct module *owner;
104 int (*add) (struct pcmcia_socket *s);
105 int (*remove) (struct pcmcia_socket *s);
106 void (*requery) (struct pcmcia_socket *s);
107 int (*validate) (struct pcmcia_socket *s, unsigned int *i);
108 int (*suspend) (struct pcmcia_socket *s);
109 int (*early_resume) (struct pcmcia_socket *s);
110 int (*resume) (struct pcmcia_socket *s);
111 };
112
113
114 extern struct rw_semaphore pcmcia_socket_list_rwsem;
115 extern struct list_head pcmcia_socket_list;
116 extern struct class pcmcia_socket_class;
117
118 int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
119 struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
120
121 void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events);
122 #define PCMCIA_UEVENT_EJECT 0x0001
123 #define PCMCIA_UEVENT_INSERT 0x0002
124 #define PCMCIA_UEVENT_SUSPEND 0x0004
125 #define PCMCIA_UEVENT_RESUME 0x0008
126 #define PCMCIA_UEVENT_REQUERY 0x0010
127
128 struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
129 void pcmcia_put_socket(struct pcmcia_socket *skt);
130
131
132
133
134
135 extern struct bus_type pcmcia_bus_type;
136
137 struct pcmcia_device;
138
139
140 extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
141 extern int pcmcia_validate_mem(struct pcmcia_socket *s);
142 extern struct resource *pcmcia_find_mem_region(u_long base,
143 u_long num,
144 u_long align,
145 int low,
146 struct pcmcia_socket *s);
147
148 void pcmcia_cleanup_irq(struct pcmcia_socket *s);
149 int pcmcia_setup_irq(struct pcmcia_device *p_dev);
150
151
152 extern const struct bin_attribute pccard_cis_attr;
153
154 int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
155 u_int addr, u_int len, void *ptr);
156 int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
157 u_int addr, u_int len, void *ptr);
158 void release_cis_mem(struct pcmcia_socket *s);
159 void destroy_cis_cache(struct pcmcia_socket *s);
160 int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
161 cisdata_t code, void *parse);
162 int pcmcia_replace_cis(struct pcmcia_socket *s,
163 const u8 *data, const size_t len);
164 int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
165 int verify_cis_cache(struct pcmcia_socket *s);
166
167 int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
168 cisdata_t code, cisparse_t *parse, void *priv_data,
169 int (*loop_tuple) (tuple_t *tuple,
170 cisparse_t *parse,
171 void *priv_data));
172
173 int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
174 tuple_t *tuple);
175
176 int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
177 tuple_t *tuple);
178
179 int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
180
181 #endif