11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * ds.h -- 16-bit PCMCIA core support 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify 51da177e4SLinus Torvalds * it under the terms of the GNU General Public License version 2 as 61da177e4SLinus Torvalds * published by the Free Software Foundation. 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * The initial developer of the original code is David A. Hinds 91da177e4SLinus Torvalds * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds 101da177e4SLinus Torvalds * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * (C) 1999 David A. Hinds 13a5835786SDominik Brodowski * (C) 2003 - 2008 Dominik Brodowski 141da177e4SLinus Torvalds */ 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds #ifndef _LINUX_DS_H 171da177e4SLinus Torvalds #define _LINUX_DS_H 181da177e4SLinus Torvalds 198e2f3b70SDominik Brodowski #ifdef __KERNEL__ 208e2f3b70SDominik Brodowski #include <linux/mod_devicetable.h> 218e2f3b70SDominik Brodowski #endif 228e2f3b70SDominik Brodowski 231ad275e3SDominik Brodowski #include <pcmcia/device_id.h> 241da177e4SLinus Torvalds 25a5835786SDominik Brodowski #ifdef __KERNEL__ 26a5835786SDominik Brodowski #include <linux/device.h> 27a5835786SDominik Brodowski #include <pcmcia/ss.h> 2804de0816SDominik Brodowski #include <asm/atomic.h> 29a5835786SDominik Brodowski 30a5835786SDominik Brodowski /* 31a5835786SDominik Brodowski * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus 32a5835786SDominik Brodowski * a.k.a. PCI drivers 33a5835786SDominik Brodowski */ 34a5835786SDominik Brodowski struct pcmcia_socket; 35a5835786SDominik Brodowski struct pcmcia_device; 36a5835786SDominik Brodowski struct config_t; 3791284224SDominik Brodowski struct net_device; 38a5835786SDominik Brodowski 39*ac8b4228SDominik Brodowski typedef unsigned long window_handle_t; 40*ac8b4228SDominik Brodowski 41a5835786SDominik Brodowski /* dynamic device IDs for PCMCIA device drivers. See 42a5835786SDominik Brodowski * Documentation/pcmcia/driver.txt for details. 43a5835786SDominik Brodowski */ 44a5835786SDominik Brodowski struct pcmcia_dynids { 453f565232SDominik Brodowski struct mutex lock; 46a5835786SDominik Brodowski struct list_head list; 47a5835786SDominik Brodowski }; 48a5835786SDominik Brodowski 49a5835786SDominik Brodowski struct pcmcia_driver { 50a5835786SDominik Brodowski int (*probe) (struct pcmcia_device *dev); 51a5835786SDominik Brodowski void (*remove) (struct pcmcia_device *dev); 52a5835786SDominik Brodowski 53a5835786SDominik Brodowski int (*suspend) (struct pcmcia_device *dev); 54a5835786SDominik Brodowski int (*resume) (struct pcmcia_device *dev); 55a5835786SDominik Brodowski 56a5835786SDominik Brodowski struct module *owner; 57a5835786SDominik Brodowski struct pcmcia_device_id *id_table; 58a5835786SDominik Brodowski struct device_driver drv; 59a5835786SDominik Brodowski struct pcmcia_dynids dynids; 60a5835786SDominik Brodowski }; 61a5835786SDominik Brodowski 62a5835786SDominik Brodowski /* driver registration */ 63a5835786SDominik Brodowski int pcmcia_register_driver(struct pcmcia_driver *driver); 64a5835786SDominik Brodowski void pcmcia_unregister_driver(struct pcmcia_driver *driver); 65a5835786SDominik Brodowski 66a5835786SDominik Brodowski struct pcmcia_device { 67a5835786SDominik Brodowski /* the socket and the device_no [for multifunction devices] 68a5835786SDominik Brodowski uniquely define a pcmcia_device */ 69a5835786SDominik Brodowski struct pcmcia_socket *socket; 70a5835786SDominik Brodowski 71a5835786SDominik Brodowski char *devname; 72a5835786SDominik Brodowski 73a5835786SDominik Brodowski u8 device_no; 74a5835786SDominik Brodowski 75a5835786SDominik Brodowski /* the hardware "function" device; certain subdevices can 76a5835786SDominik Brodowski * share one hardware "function" device. */ 77a5835786SDominik Brodowski u8 func; 78a5835786SDominik Brodowski struct config_t *function_config; 79a5835786SDominik Brodowski 80a5835786SDominik Brodowski struct list_head socket_device_list; 81a5835786SDominik Brodowski 82a5835786SDominik Brodowski /* deprecated, will be cleaned up soon */ 83a5835786SDominik Brodowski u_int open; 84a5835786SDominik Brodowski io_req_t io; 85a5835786SDominik Brodowski config_req_t conf; 86a5835786SDominik Brodowski window_handle_t win; 87a5835786SDominik Brodowski 886f0f38c4SDominik Brodowski /* device setup */ 89eb14120fSDominik Brodowski unsigned int irq; 906f0f38c4SDominik Brodowski 9104de0816SDominik Brodowski /* Is the device suspended? */ 92a5835786SDominik Brodowski u16 suspended:1; 93a5835786SDominik Brodowski 94a5835786SDominik Brodowski /* Flags whether io, irq, win configurations were 95a5835786SDominik Brodowski * requested, and whether the configuration is "locked" */ 96a5835786SDominik Brodowski u16 _irq:1; 97a5835786SDominik Brodowski u16 _io:1; 98a5835786SDominik Brodowski u16 _win:4; 99a5835786SDominik Brodowski u16 _locked:1; 100a5835786SDominik Brodowski 101a5835786SDominik Brodowski /* Flag whether a "fuzzy" func_id based match is 102a5835786SDominik Brodowski * allowed. */ 103a5835786SDominik Brodowski u16 allow_func_id_match:1; 104a5835786SDominik Brodowski 105a5835786SDominik Brodowski /* information about this device */ 106a5835786SDominik Brodowski u16 has_manf_id:1; 107a5835786SDominik Brodowski u16 has_card_id:1; 108a5835786SDominik Brodowski u16 has_func_id:1; 109a5835786SDominik Brodowski 11004de0816SDominik Brodowski u16 reserved:4; 111a5835786SDominik Brodowski 112a5835786SDominik Brodowski u8 func_id; 113a5835786SDominik Brodowski u16 manf_id; 114a5835786SDominik Brodowski u16 card_id; 115a5835786SDominik Brodowski 116a5835786SDominik Brodowski char *prod_id[4]; 117a5835786SDominik Brodowski 118a5835786SDominik Brodowski u64 dma_mask; 119a5835786SDominik Brodowski struct device dev; 120a5835786SDominik Brodowski 121a5835786SDominik Brodowski /* data private to drivers */ 122a5835786SDominik Brodowski void *priv; 123a5835786SDominik Brodowski }; 124a5835786SDominik Brodowski 125a5835786SDominik Brodowski #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) 126a5835786SDominik Brodowski #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) 127a5835786SDominik Brodowski 128a5835786SDominik Brodowski 12991284224SDominik Brodowski /* 13091284224SDominik Brodowski * CIS access. 13191284224SDominik Brodowski * 13291284224SDominik Brodowski * Please use the following functions to access CIS tuples: 13391284224SDominik Brodowski * - pcmcia_get_tuple() 13491284224SDominik Brodowski * - pcmcia_loop_tuple() 13591284224SDominik Brodowski * - pcmcia_get_mac_from_cis() 13691284224SDominik Brodowski * 13791284224SDominik Brodowski * To parse a tuple_t, pcmcia_parse_tuple() exists. Its interface 13891284224SDominik Brodowski * might change in future. 139272433e0SDominik Brodowski */ 14091284224SDominik Brodowski 14191284224SDominik Brodowski /* get the very first CIS entry of type @code. Note that buf is pointer 14291284224SDominik Brodowski * to u8 *buf; and that you need to kfree(buf) afterwards. */ 14391284224SDominik Brodowski size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code, 14491284224SDominik Brodowski u8 **buf); 14591284224SDominik Brodowski 14691284224SDominik Brodowski /* loop over CIS entries */ 14791284224SDominik Brodowski int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, 14891284224SDominik Brodowski int (*loop_tuple) (struct pcmcia_device *p_dev, 14991284224SDominik Brodowski tuple_t *tuple, 15091284224SDominik Brodowski void *priv_data), 15191284224SDominik Brodowski void *priv_data); 15291284224SDominik Brodowski 15391284224SDominik Brodowski /* get the MAC address from CISTPL_FUNCE */ 15491284224SDominik Brodowski int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev, 15591284224SDominik Brodowski struct net_device *dev); 15691284224SDominik Brodowski 15791284224SDominik Brodowski 15891284224SDominik Brodowski /* parse a tuple_t */ 159272433e0SDominik Brodowski int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse); 160272433e0SDominik Brodowski 161272433e0SDominik Brodowski /* loop CIS entries for valid configuration */ 162272433e0SDominik Brodowski int pcmcia_loop_config(struct pcmcia_device *p_dev, 163272433e0SDominik Brodowski int (*conf_check) (struct pcmcia_device *p_dev, 164272433e0SDominik Brodowski cistpl_cftable_entry_t *cf, 165272433e0SDominik Brodowski cistpl_cftable_entry_t *dflt, 166272433e0SDominik Brodowski unsigned int vcc, 167272433e0SDominik Brodowski void *priv_data), 168272433e0SDominik Brodowski void *priv_data); 169a5835786SDominik Brodowski 170994917f8SDominik Brodowski /* is the device still there? */ 171994917f8SDominik Brodowski struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev); 172994917f8SDominik Brodowski 173994917f8SDominik Brodowski /* low-level interface reset */ 174994917f8SDominik Brodowski int pcmcia_reset_card(struct pcmcia_socket *skt); 175994917f8SDominik Brodowski 176994917f8SDominik Brodowski /* CIS config */ 177994917f8SDominik Brodowski int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 178994917f8SDominik Brodowski conf_reg_t *reg); 179994917f8SDominik Brodowski 180994917f8SDominik Brodowski /* device configuration */ 181994917f8SDominik Brodowski int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); 182eb14120fSDominik Brodowski 183b19a7275SDominik Brodowski int __must_check 184b19a7275SDominik Brodowski __pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev, 185eb14120fSDominik Brodowski irq_handler_t handler); 186b19a7275SDominik Brodowski static inline __must_check __deprecated int 187b19a7275SDominik Brodowski pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev, 188b19a7275SDominik Brodowski irq_handler_t handler) 189b19a7275SDominik Brodowski { 190b19a7275SDominik Brodowski return __pcmcia_request_exclusive_irq(p_dev, handler); 191b19a7275SDominik Brodowski } 192b19a7275SDominik Brodowski 193eb14120fSDominik Brodowski int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev, 194eb14120fSDominik Brodowski irq_handler_t handler); 195eb14120fSDominik Brodowski 196994917f8SDominik Brodowski int pcmcia_request_configuration(struct pcmcia_device *p_dev, 197994917f8SDominik Brodowski config_req_t *req); 198994917f8SDominik Brodowski 1996838b03fSDominik Brodowski int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req, 200994917f8SDominik Brodowski window_handle_t *wh); 201f5560da5SMagnus Damm int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win); 202868575d1SMagnus Damm int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win, 203868575d1SMagnus Damm memreq_t *req); 204994917f8SDominik Brodowski 205994917f8SDominik Brodowski int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 206994917f8SDominik Brodowski void pcmcia_disable_device(struct pcmcia_device *p_dev); 207994917f8SDominik Brodowski 208a5835786SDominik Brodowski #endif /* __KERNEL__ */ 209a5835786SDominik Brodowski 2101da177e4SLinus Torvalds #endif /* _LINUX_DS_H */ 211