• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6.36/drivers/pcmcia/
1/*
2 * cs_internal.h -- definitions internal to the PCMCIA core modules
3 *
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.
7 *
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.
11 *
12 * (C) 1999		David A. Hinds
13 * (C) 2003 - 2010	Dominik Brodowski
14 *
15 *
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
18 * drivers.
19 */
20
21#ifndef _LINUX_CS_INTERNAL_H
22#define _LINUX_CS_INTERNAL_H
23
24#include <linux/kref.h>
25
26/* Flags in client state */
27#define CLIENT_WIN_REQ(i)	(0x1<<(i))
28
29/* Flag to access all functions */
30#define BIND_FN_ALL	0xff
31
32/* Each card function gets one of these guys */
33typedef struct config_t {
34	struct kref	ref;
35	unsigned int	state;
36	unsigned int	Attributes;
37	unsigned int	IntType;
38	unsigned int	ConfigBase;
39	unsigned char	Status, Pin, Copy, Option, ExtStatus;
40	unsigned int	CardValues;
41
42	struct resource io[MAX_IO_WIN]; /* io ports */
43	struct resource mem[MAX_WIN];   /* mem areas */
44
45	struct {
46		u_int	Attributes;
47	} irq;
48} config_t;
49
50
51struct cis_cache_entry {
52	struct list_head	node;
53	unsigned int		addr;
54	unsigned int		len;
55	unsigned int		attr;
56	unsigned char		cache[0];
57};
58
59struct pccard_resource_ops {
60	int	(*validate_mem)		(struct pcmcia_socket *s);
61	int	(*find_io)		(struct pcmcia_socket *s,
62					 unsigned int attr,
63					 unsigned int *base,
64					 unsigned int num,
65					 unsigned int align,
66					 struct resource **parent);
67	struct resource* (*find_mem)	(unsigned long base, unsigned long num,
68					 unsigned long align, int low,
69					 struct pcmcia_socket *s);
70	int	(*init)			(struct pcmcia_socket *s);
71	void	(*exit)			(struct pcmcia_socket *s);
72};
73
74/* Flags in config state */
75#define CONFIG_LOCKED		0x01
76#define CONFIG_IRQ_REQ		0x02
77#define CONFIG_IO_REQ		0x04
78
79/* Flags in socket state */
80#define SOCKET_PRESENT		0x0008
81#define SOCKET_INUSE		0x0010
82#define SOCKET_SUSPEND		0x0080
83#define SOCKET_WIN_REQ(i)	(0x0100<<(i))
84#define SOCKET_CARDBUS		0x8000
85#define SOCKET_CARDBUS_CONFIG	0x10000
86
87
88/*
89 * Stuff internal to module "pcmcia_rsrc":
90 */
91extern int static_init(struct pcmcia_socket *s);
92extern struct resource *pcmcia_make_resource(unsigned long start,
93					unsigned long end,
94					int flags, const char *name);
95
96/*
97 * Stuff internal to module "pcmcia_core":
98 */
99
100/* socket_sysfs.c */
101extern int pccard_sysfs_add_socket(struct device *dev);
102extern void pccard_sysfs_remove_socket(struct device *dev);
103
104/* cardbus.c */
105int cb_alloc(struct pcmcia_socket *s);
106void cb_free(struct pcmcia_socket *s);
107
108
109
110/*
111 * Stuff exported by module "pcmcia_core" to module "pcmcia"
112 */
113
114struct pcmcia_callback{
115	struct module	*owner;
116	int		(*add) (struct pcmcia_socket *s);
117	int		(*remove) (struct pcmcia_socket *s);
118	void		(*requery) (struct pcmcia_socket *s);
119	int		(*validate) (struct pcmcia_socket *s, unsigned int *i);
120	int		(*suspend) (struct pcmcia_socket *s);
121	int		(*early_resume) (struct pcmcia_socket *s);
122	int		(*resume) (struct pcmcia_socket *s);
123};
124
125/* cs.c */
126extern struct rw_semaphore pcmcia_socket_list_rwsem;
127extern struct list_head pcmcia_socket_list;
128extern struct class pcmcia_socket_class;
129
130int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
131struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
132
133void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events);
134#define PCMCIA_UEVENT_EJECT	0x0001
135#define PCMCIA_UEVENT_INSERT	0x0002
136#define PCMCIA_UEVENT_SUSPEND	0x0004
137#define PCMCIA_UEVENT_RESUME	0x0008
138#define PCMCIA_UEVENT_REQUERY	0x0010
139
140struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
141void pcmcia_put_socket(struct pcmcia_socket *skt);
142
143/*
144 * Stuff internal to module "pcmcia".
145 */
146/* ds.c */
147extern struct bus_type pcmcia_bus_type;
148
149struct pcmcia_device;
150
151/* pcmcia_resource.c */
152extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
153extern int pcmcia_validate_mem(struct pcmcia_socket *s);
154extern struct resource *pcmcia_find_mem_region(u_long base,
155					       u_long num,
156					       u_long align,
157					       int low,
158					       struct pcmcia_socket *s);
159
160void pcmcia_cleanup_irq(struct pcmcia_socket *s);
161int pcmcia_setup_irq(struct pcmcia_device *p_dev);
162
163/* cistpl.c */
164extern struct bin_attribute pccard_cis_attr;
165
166int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
167			u_int addr, u_int len, void *ptr);
168int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
169			u_int addr, u_int len, void *ptr);
170void release_cis_mem(struct pcmcia_socket *s);
171void destroy_cis_cache(struct pcmcia_socket *s);
172int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
173		      cisdata_t code, void *parse);
174int pcmcia_replace_cis(struct pcmcia_socket *s,
175		       const u8 *data, const size_t len);
176int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
177int verify_cis_cache(struct pcmcia_socket *s);
178
179int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
180		      cisdata_t code, cisparse_t *parse, void *priv_data,
181		      int (*loop_tuple) (tuple_t *tuple,
182					 cisparse_t *parse,
183					 void *priv_data));
184
185int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
186			tuple_t *tuple);
187
188int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
189			tuple_t *tuple);
190
191int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
192
193#endif /* _LINUX_CS_INTERNAL_H */
194