Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 2 | * cs_internal.h -- definitions internal to the PCMCIA core modules |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 13 | * (C) 2003 - 2008 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #ifndef _LINUX_CS_INTERNAL_H |
| 22 | #define _LINUX_CS_INTERNAL_H |
| 23 | |
Dominik Brodowski | 360b65b | 2006-01-10 20:50:39 +0100 | [diff] [blame] | 24 | #include <linux/kref.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | /* Flags in client state */ |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 27 | #define CLIENT_WIN_REQ(i) (0x1<<(i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | /* Each card function gets one of these guys */ |
| 30 | typedef struct config_t { |
Dominik Brodowski | 360b65b | 2006-01-10 20:50:39 +0100 | [diff] [blame] | 31 | struct kref ref; |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 32 | unsigned int state; |
| 33 | unsigned int Attributes; |
| 34 | unsigned int IntType; |
| 35 | unsigned int ConfigBase; |
| 36 | unsigned char Status, Pin, Copy, Option, ExtStatus; |
| 37 | unsigned int CardValues; |
| 38 | io_req_t io; |
| 39 | struct { |
| 40 | u_int Attributes; |
| 41 | } irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } config_t; |
| 43 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | struct cis_cache_entry { |
| 46 | struct list_head node; |
| 47 | unsigned int addr; |
| 48 | unsigned int len; |
| 49 | unsigned int attr; |
| 50 | unsigned char cache[0]; |
| 51 | }; |
| 52 | |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 53 | struct pccard_resource_ops { |
| 54 | int (*validate_mem) (struct pcmcia_socket *s); |
Dominik Brodowski | b19a727 | 2010-03-20 13:10:47 +0100 | [diff] [blame^] | 55 | int (*find_io) (struct pcmcia_socket *s, |
| 56 | unsigned int attr, |
| 57 | unsigned int *base, |
| 58 | unsigned int num, |
| 59 | unsigned int align); |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 60 | struct resource* (*find_mem) (unsigned long base, unsigned long num, |
| 61 | unsigned long align, int low, |
| 62 | struct pcmcia_socket *s); |
| 63 | int (*add_io) (struct pcmcia_socket *s, |
| 64 | unsigned int action, |
| 65 | unsigned long r_start, |
| 66 | unsigned long r_end); |
| 67 | int (*add_mem) (struct pcmcia_socket *s, |
| 68 | unsigned int action, |
| 69 | unsigned long r_start, |
| 70 | unsigned long r_end); |
| 71 | int (*init) (struct pcmcia_socket *s); |
| 72 | void (*exit) (struct pcmcia_socket *s); |
| 73 | }; |
| 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | /* Flags in config state */ |
| 76 | #define CONFIG_LOCKED 0x01 |
| 77 | #define CONFIG_IRQ_REQ 0x02 |
| 78 | #define CONFIG_IO_REQ 0x04 |
| 79 | |
| 80 | /* Flags in socket state */ |
| 81 | #define SOCKET_PRESENT 0x0008 |
| 82 | #define SOCKET_INUSE 0x0010 |
| 83 | #define SOCKET_SUSPEND 0x0080 |
| 84 | #define SOCKET_WIN_REQ(i) (0x0100<<(i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | #define SOCKET_CARDBUS 0x8000 |
| 86 | #define SOCKET_CARDBUS_CONFIG 0x10000 |
| 87 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 88 | |
| 89 | /* |
Dominik Brodowski | 49b1153 | 2010-03-07 16:41:57 +0100 | [diff] [blame] | 90 | * Stuff internal to module "pcmcia_rsrc": |
| 91 | */ |
| 92 | extern int static_init(struct pcmcia_socket *s); |
| 93 | extern struct resource *pcmcia_make_resource(unsigned long start, |
| 94 | unsigned long end, |
| 95 | int flags, const char *name); |
| 96 | |
| 97 | /* |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 98 | * Stuff internal to module "pcmcia_core": |
| 99 | */ |
| 100 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 101 | /* socket_sysfs.c */ |
| 102 | extern int pccard_sysfs_add_socket(struct device *dev); |
| 103 | extern void pccard_sysfs_remove_socket(struct device *dev); |
| 104 | |
| 105 | /* cardbus.c */ |
| 106 | int cb_alloc(struct pcmcia_socket *s); |
| 107 | void cb_free(struct pcmcia_socket *s); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 108 | |
| 109 | |
| 110 | |
| 111 | /* |
| 112 | * Stuff exported by module "pcmcia_core" to module "pcmcia" |
| 113 | */ |
| 114 | |
| 115 | struct pcmcia_callback{ |
| 116 | struct module *owner; |
| 117 | int (*event) (struct pcmcia_socket *s, |
| 118 | event_t event, int priority); |
Dominik Brodowski | af461fc | 2010-01-17 19:30:53 +0100 | [diff] [blame] | 119 | void (*requery) (struct pcmcia_socket *s); |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 120 | int (*validate) (struct pcmcia_socket *s, unsigned int *i); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 121 | int (*suspend) (struct pcmcia_socket *s); |
| 122 | int (*resume) (struct pcmcia_socket *s); |
| 123 | }; |
| 124 | |
| 125 | /* cs.c */ |
| 126 | extern struct rw_semaphore pcmcia_socket_list_rwsem; |
| 127 | extern struct list_head pcmcia_socket_list; |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 128 | extern struct class pcmcia_socket_class; |
| 129 | |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 130 | int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); |
Dominik Brodowski | c23889c | 2008-08-26 00:09:56 +0200 | [diff] [blame] | 131 | struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr); |
Dominik Brodowski | dc953e5 | 2008-08-25 23:18:20 +0200 | [diff] [blame] | 132 | |
Dominik Brodowski | f971dbd | 2010-01-17 18:13:31 +0100 | [diff] [blame] | 133 | void 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 |
Dominik Brodowski | af461fc | 2010-01-17 19:30:53 +0100 | [diff] [blame] | 138 | #define PCMCIA_UEVENT_REQUERY 0x0010 |
Dominik Brodowski | 994917f | 2008-08-31 15:20:26 +0200 | [diff] [blame] | 139 | |
| 140 | struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt); |
| 141 | void pcmcia_put_socket(struct pcmcia_socket *skt); |
| 142 | |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 143 | /* |
| 144 | * Stuff internal to module "pcmcia". |
| 145 | */ |
| 146 | /* ds.c */ |
| 147 | extern struct bus_type pcmcia_bus_type; |
| 148 | |
| 149 | /* pcmcia_resource.c */ |
| 150 | extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); |
Dominik Brodowski | a3ac9af | 2010-01-06 14:03:03 +0100 | [diff] [blame] | 151 | extern int pcmcia_validate_mem(struct pcmcia_socket *s); |
| 152 | extern struct resource *pcmcia_find_mem_region(u_long base, |
| 153 | u_long num, |
| 154 | u_long align, |
| 155 | int low, |
| 156 | struct pcmcia_socket *s); |
| 157 | |
Dominik Brodowski | 6f0f38c | 2010-04-08 20:33:16 +0200 | [diff] [blame] | 158 | void pcmcia_cleanup_irq(struct pcmcia_socket *s); |
| 159 | int pcmcia_setup_irq(struct pcmcia_device *p_dev); |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 160 | |
Dominik Brodowski | 6e7b51a | 2010-01-06 13:57:43 +0100 | [diff] [blame] | 161 | /* cistpl.c */ |
| 162 | extern struct bin_attribute pccard_cis_attr; |
| 163 | |
| 164 | int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, |
| 165 | u_int addr, u_int len, void *ptr); |
| 166 | void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, |
| 167 | u_int addr, u_int len, void *ptr); |
| 168 | void release_cis_mem(struct pcmcia_socket *s); |
| 169 | void destroy_cis_cache(struct pcmcia_socket *s); |
| 170 | int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, |
| 171 | cisdata_t code, void *parse); |
| 172 | int pcmcia_replace_cis(struct pcmcia_socket *s, |
| 173 | const u8 *data, const size_t len); |
| 174 | int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count); |
| 175 | int verify_cis_cache(struct pcmcia_socket *s); |
| 176 | |
| 177 | int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, |
| 178 | cisdata_t code, cisparse_t *parse, void *priv_data, |
| 179 | int (*loop_tuple) (tuple_t *tuple, |
| 180 | cisparse_t *parse, |
| 181 | void *priv_data)); |
| 182 | |
| 183 | int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, |
| 184 | tuple_t *tuple); |
| 185 | |
| 186 | int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, |
| 187 | tuple_t *tuple); |
| 188 | |
| 189 | int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); |
| 190 | |
| 191 | |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 192 | #ifdef CONFIG_PCMCIA_IOCTL |
| 193 | /* ds.c */ |
Dominik Brodowski | b60a5ed | 2008-08-25 23:32:37 +0200 | [diff] [blame] | 194 | extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev); |
| 195 | extern void pcmcia_put_dev(struct pcmcia_device *p_dev); |
| 196 | |
| 197 | struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, |
| 198 | unsigned int function); |
| 199 | |
| 200 | /* pcmcia_ioctl.c */ |
| 201 | extern void __init pcmcia_setup_ioctl(void); |
| 202 | extern void __exit pcmcia_cleanup_ioctl(void); |
| 203 | extern void handle_event(struct pcmcia_socket *s, event_t event); |
| 204 | extern int handle_request(struct pcmcia_socket *s, event_t event); |
| 205 | |
| 206 | #else /* CONFIG_PCMCIA_IOCTL */ |
| 207 | |
| 208 | static inline void __init pcmcia_setup_ioctl(void) { return; } |
| 209 | static inline void __exit pcmcia_cleanup_ioctl(void) { return; } |
| 210 | static inline void handle_event(struct pcmcia_socket *s, event_t event) |
| 211 | { |
| 212 | return; |
| 213 | } |
| 214 | static inline int handle_request(struct pcmcia_socket *s, event_t event) |
| 215 | { |
| 216 | return 0; |
| 217 | } |
| 218 | |
| 219 | #endif /* CONFIG_PCMCIA_IOCTL */ |
| 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | #endif /* _LINUX_CS_INTERNAL_H */ |