cs_internal.h 5.5 KB
Newer Older
L
Linus Torvalds 已提交
1
/*
2
 * cs_internal.h -- definitions internal to the PCMCIA core modules
L
Linus Torvalds 已提交
3 4 5 6 7 8 9 10 11 12
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * The initial developer of the original code is David A. Hinds
 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
 *
 * (C) 1999		David A. Hinds
13
 * (C) 2003 - 2010	Dominik Brodowski
14 15 16 17 18
 *
 *
 * This file contains definitions _only_ needed by the PCMCIA core modules.
 * It must not be included by PCMCIA socket drivers or by PCMCIA device
 * drivers.
L
Linus Torvalds 已提交
19 20 21 22 23
 */

#ifndef _LINUX_CS_INTERNAL_H
#define _LINUX_CS_INTERNAL_H

24
#include <linux/kref.h>
L
Linus Torvalds 已提交
25 26

/* Flags in client state */
27
#define CLIENT_WIN_REQ(i)	(0x1<<(i))
L
Linus Torvalds 已提交
28

29 30 31
/* Flag to access all functions */
#define BIND_FN_ALL	0xff

L
Linus Torvalds 已提交
32 33
/* Each card function gets one of these guys */
typedef struct config_t {
34
	struct kref	ref;
35 36 37 38 39 40
	unsigned int	state;
	unsigned int	Attributes;
	unsigned int	IntType;
	unsigned int	ConfigBase;
	unsigned char	Status, Pin, Copy, Option, ExtStatus;
	unsigned int	CardValues;
41 42

	struct resource io[MAX_IO_WIN]; /* io ports */
43
	struct resource mem[MAX_WIN];   /* mem areas */
44

45 46 47
	struct {
		u_int	Attributes;
	} irq;
L
Linus Torvalds 已提交
48 49
} config_t;

50

L
Linus Torvalds 已提交
51 52 53 54 55 56 57 58
struct cis_cache_entry {
	struct list_head	node;
	unsigned int		addr;
	unsigned int		len;
	unsigned int		attr;
	unsigned char		cache[0];
};

59 60
struct pccard_resource_ops {
	int	(*validate_mem)		(struct pcmcia_socket *s);
61 62 63 64 65
	int	(*find_io)		(struct pcmcia_socket *s,
					 unsigned int attr,
					 unsigned int *base,
					 unsigned int num,
					 unsigned int align);
66 67 68 69 70 71 72
	struct resource* (*find_mem)	(unsigned long base, unsigned long num,
					 unsigned long align, int low,
					 struct pcmcia_socket *s);
	int	(*init)			(struct pcmcia_socket *s);
	void	(*exit)			(struct pcmcia_socket *s);
};

L
Linus Torvalds 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85
/* Flags in config state */
#define CONFIG_LOCKED		0x01
#define CONFIG_IRQ_REQ		0x02
#define CONFIG_IO_REQ		0x04

/* Flags in socket state */
#define SOCKET_PRESENT		0x0008
#define SOCKET_INUSE		0x0010
#define SOCKET_SUSPEND		0x0080
#define SOCKET_WIN_REQ(i)	(0x0100<<(i))
#define SOCKET_CARDBUS		0x8000
#define SOCKET_CARDBUS_CONFIG	0x10000

86

87 88 89 90 91 92 93 94
/*
 * Stuff internal to module "pcmcia_rsrc":
 */
extern int static_init(struct pcmcia_socket *s);
extern struct resource *pcmcia_make_resource(unsigned long start,
					unsigned long end,
					int flags, const char *name);

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
/*
 * Stuff internal to module "pcmcia_core":
 */

/* socket_sysfs.c */
extern int pccard_sysfs_add_socket(struct device *dev);
extern void pccard_sysfs_remove_socket(struct device *dev);

/* cardbus.c */
int cb_alloc(struct pcmcia_socket *s);
void cb_free(struct pcmcia_socket *s);



/*
 * Stuff exported by module "pcmcia_core" to module "pcmcia"
 */

struct pcmcia_callback{
	struct module	*owner;
115 116
	int		(*add) (struct pcmcia_socket *s);
	int		(*remove) (struct pcmcia_socket *s);
117
	void		(*requery) (struct pcmcia_socket *s);
118
	int		(*validate) (struct pcmcia_socket *s, unsigned int *i);
119
	int		(*suspend) (struct pcmcia_socket *s);
120
	int		(*early_resume) (struct pcmcia_socket *s);
121 122 123 124 125 126
	int		(*resume) (struct pcmcia_socket *s);
};

/* cs.c */
extern struct rw_semaphore pcmcia_socket_list_rwsem;
extern struct list_head pcmcia_socket_list;
127 128
extern struct class pcmcia_socket_class;

129
int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
130
struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
131

132 133 134 135 136
void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events);
#define PCMCIA_UEVENT_EJECT	0x0001
#define PCMCIA_UEVENT_INSERT	0x0002
#define PCMCIA_UEVENT_SUSPEND	0x0004
#define PCMCIA_UEVENT_RESUME	0x0008
137
#define PCMCIA_UEVENT_REQUERY	0x0010
138 139 140 141

struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
void pcmcia_put_socket(struct pcmcia_socket *skt);

142 143 144 145 146 147
/*
 * Stuff internal to module "pcmcia".
 */
/* ds.c */
extern struct bus_type pcmcia_bus_type;

148 149
struct pcmcia_device;

150 151
/* pcmcia_resource.c */
extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
152 153 154 155 156 157 158
extern int pcmcia_validate_mem(struct pcmcia_socket *s);
extern struct resource *pcmcia_find_mem_region(u_long base,
					       u_long num,
					       u_long align,
					       int low,
					       struct pcmcia_socket *s);

159 160
void pcmcia_cleanup_irq(struct pcmcia_socket *s);
int pcmcia_setup_irq(struct pcmcia_device *p_dev);
161

162
/* cistpl.c */
163 164
extern struct bin_attribute pccard_cis_attr;

165 166
int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
			u_int addr, u_int len, void *ptr);
167 168
int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
			u_int addr, u_int len, void *ptr);
169 170 171 172
void release_cis_mem(struct pcmcia_socket *s);
void destroy_cis_cache(struct pcmcia_socket *s);
int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
		      cisdata_t code, void *parse);
173 174
int pcmcia_replace_cis(struct pcmcia_socket *s,
		       const u8 *data, const size_t len);
175
int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
176
int verify_cis_cache(struct pcmcia_socket *s);
177

178 179 180 181 182 183
int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
		      cisdata_t code, cisparse_t *parse, void *priv_data,
		      int (*loop_tuple) (tuple_t *tuple,
					 cisparse_t *parse,
					 void *priv_data));

184 185 186 187 188 189 190 191
int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple);

int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
			tuple_t *tuple);

int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);

L
Linus Torvalds 已提交
192
#endif /* _LINUX_CS_INTERNAL_H */