0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef _LINUX_DS_H
0014 #define _LINUX_DS_H
0015
0016 #ifdef __KERNEL__
0017 #include <linux/mod_devicetable.h>
0018 #endif
0019
0020 #include <pcmcia/device_id.h>
0021
0022 #ifdef __KERNEL__
0023 #include <linux/device.h>
0024 #include <linux/interrupt.h>
0025 #include <pcmcia/ss.h>
0026 #include <linux/atomic.h>
0027
0028
0029
0030
0031
0032
0033 struct pcmcia_socket;
0034 struct pcmcia_device;
0035 struct config_t;
0036 struct net_device;
0037
0038
0039
0040
0041 struct pcmcia_dynids {
0042 struct mutex lock;
0043 struct list_head list;
0044 };
0045
0046 struct pcmcia_driver {
0047 const char *name;
0048
0049 int (*probe) (struct pcmcia_device *dev);
0050 void (*remove) (struct pcmcia_device *dev);
0051
0052 int (*suspend) (struct pcmcia_device *dev);
0053 int (*resume) (struct pcmcia_device *dev);
0054
0055 struct module *owner;
0056 const struct pcmcia_device_id *id_table;
0057 struct device_driver drv;
0058 struct pcmcia_dynids dynids;
0059 };
0060
0061
0062 int pcmcia_register_driver(struct pcmcia_driver *driver);
0063 void pcmcia_unregister_driver(struct pcmcia_driver *driver);
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 #define module_pcmcia_driver(__pcmcia_driver) \
0074 module_driver(__pcmcia_driver, pcmcia_register_driver, \
0075 pcmcia_unregister_driver)
0076
0077
0078 enum {
0079 PCMCIA_IOPORT_0,
0080 PCMCIA_IOPORT_1,
0081 PCMCIA_IOMEM_0,
0082 PCMCIA_IOMEM_1,
0083 PCMCIA_IOMEM_2,
0084 PCMCIA_IOMEM_3,
0085 PCMCIA_NUM_RESOURCES,
0086 };
0087
0088 struct pcmcia_device {
0089
0090
0091 struct pcmcia_socket *socket;
0092
0093 char *devname;
0094
0095 u8 device_no;
0096
0097
0098
0099 u8 func;
0100 struct config_t *function_config;
0101
0102 struct list_head socket_device_list;
0103
0104
0105 unsigned int irq;
0106 struct resource *resource[PCMCIA_NUM_RESOURCES];
0107 resource_size_t card_addr;
0108 unsigned int vpp;
0109
0110 unsigned int config_flags;
0111 unsigned int config_base;
0112 unsigned int config_index;
0113 unsigned int config_regs;
0114 unsigned int io_lines;
0115
0116
0117 u16 suspended:1;
0118
0119
0120
0121 u16 _irq:1;
0122 u16 _io:1;
0123 u16 _win:4;
0124 u16 _locked:1;
0125
0126
0127
0128 u16 allow_func_id_match:1;
0129
0130
0131 u16 has_manf_id:1;
0132 u16 has_card_id:1;
0133 u16 has_func_id:1;
0134
0135 u16 reserved:4;
0136
0137 u8 func_id;
0138 u16 manf_id;
0139 u16 card_id;
0140
0141 char *prod_id[4];
0142
0143 u64 dma_mask;
0144 struct device dev;
0145
0146
0147 void *priv;
0148 unsigned int open;
0149 };
0150
0151 #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
0152 #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
0170 u8 **buf);
0171
0172
0173 int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
0174 int (*loop_tuple) (struct pcmcia_device *p_dev,
0175 tuple_t *tuple,
0176 void *priv_data),
0177 void *priv_data);
0178
0179
0180 int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
0181 struct net_device *dev);
0182
0183
0184
0185 int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
0186
0187
0188 int pcmcia_loop_config(struct pcmcia_device *p_dev,
0189 int (*conf_check) (struct pcmcia_device *p_dev,
0190 void *priv_data),
0191 void *priv_data);
0192
0193
0194 struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);
0195
0196
0197 int pcmcia_reset_card(struct pcmcia_socket *skt);
0198
0199
0200 int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
0201 int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);
0202
0203
0204 int pcmcia_request_io(struct pcmcia_device *p_dev);
0205
0206 int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
0207 irq_handler_t handler);
0208
0209 int pcmcia_enable_device(struct pcmcia_device *p_dev);
0210
0211 int pcmcia_request_window(struct pcmcia_device *p_dev, struct resource *res,
0212 unsigned int speed);
0213 int pcmcia_release_window(struct pcmcia_device *p_dev, struct resource *res);
0214 int pcmcia_map_mem_page(struct pcmcia_device *p_dev, struct resource *res,
0215 unsigned int offset);
0216
0217 int pcmcia_fixup_vpp(struct pcmcia_device *p_dev, unsigned char new_vpp);
0218 int pcmcia_fixup_iowidth(struct pcmcia_device *p_dev);
0219
0220 void pcmcia_disable_device(struct pcmcia_device *p_dev);
0221
0222
0223 #define IO_DATA_PATH_WIDTH 0x18
0224 #define IO_DATA_PATH_WIDTH_8 0x00
0225 #define IO_DATA_PATH_WIDTH_16 0x08
0226 #define IO_DATA_PATH_WIDTH_AUTO 0x10
0227
0228
0229 #define WIN_MEMORY_TYPE_CM 0x00
0230 #define WIN_MEMORY_TYPE_AM 0x20
0231 #define WIN_DATA_WIDTH_8 0x00
0232 #define WIN_DATA_WIDTH_16 0x02
0233 #define WIN_ENABLE 0x01
0234 #define WIN_USE_WAIT 0x40
0235
0236 #define WIN_FLAGS_MAP 0x63
0237
0238 #define WIN_FLAGS_REQ 0x1c
0239
0240
0241
0242
0243
0244
0245 #define PRESENT_OPTION 0x001
0246 #define PRESENT_STATUS 0x002
0247 #define PRESENT_PIN_REPLACE 0x004
0248 #define PRESENT_COPY 0x008
0249 #define PRESENT_EXT_STATUS 0x010
0250 #define PRESENT_IOBASE_0 0x020
0251 #define PRESENT_IOBASE_1 0x040
0252 #define PRESENT_IOBASE_2 0x080
0253 #define PRESENT_IOBASE_3 0x100
0254 #define PRESENT_IOSIZE 0x200
0255
0256
0257 #define CONF_ENABLE_IRQ 0x0001
0258 #define CONF_ENABLE_SPKR 0x0002
0259 #define CONF_ENABLE_PULSE_IRQ 0x0004
0260 #define CONF_ENABLE_ESR 0x0008
0261 #define CONF_ENABLE_IOCARD 0x0010
0262
0263 #define CONF_ENABLE_ZVCARD 0x0020
0264
0265
0266 #define CONF_AUTO_CHECK_VCC 0x0100
0267 #define CONF_AUTO_SET_VPP 0x0200
0268 #define CONF_AUTO_AUDIO 0x0400
0269 #define CONF_AUTO_SET_IO 0x0800
0270 #define CONF_AUTO_SET_IOMEM 0x1000
0271
0272 #endif
0273
0274 #endif