ds.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. /*
  2. * ds.h -- 16-bit PCMCIA core support
  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 - 2008 Dominik Brodowski
  14. */
  15. #ifndef _LINUX_DS_H
  16. #define _LINUX_DS_H
  17. #ifdef __KERNEL__
  18. #include <linux/mod_devicetable.h>
  19. #endif
  20. #include <pcmcia/device_id.h>
  21. #ifdef __KERNEL__
  22. #include <linux/device.h>
  23. #include <pcmcia/ss.h>
  24. #include <asm/atomic.h>
  25. /*
  26. * PCMCIA device drivers (16-bit cards only; 32-bit cards require CardBus
  27. * a.k.a. PCI drivers
  28. */
  29. struct pcmcia_socket;
  30. struct pcmcia_device;
  31. struct config_t;
  32. struct net_device;
  33. typedef unsigned long window_handle_t;
  34. /* dynamic device IDs for PCMCIA device drivers. See
  35. * Documentation/pcmcia/driver.txt for details.
  36. */
  37. struct pcmcia_dynids {
  38. struct mutex lock;
  39. struct list_head list;
  40. };
  41. struct pcmcia_driver {
  42. int (*probe) (struct pcmcia_device *dev);
  43. void (*remove) (struct pcmcia_device *dev);
  44. int (*suspend) (struct pcmcia_device *dev);
  45. int (*resume) (struct pcmcia_device *dev);
  46. struct module *owner;
  47. struct pcmcia_device_id *id_table;
  48. struct device_driver drv;
  49. struct pcmcia_dynids dynids;
  50. };
  51. /* driver registration */
  52. int pcmcia_register_driver(struct pcmcia_driver *driver);
  53. void pcmcia_unregister_driver(struct pcmcia_driver *driver);
  54. struct pcmcia_device {
  55. /* the socket and the device_no [for multifunction devices]
  56. uniquely define a pcmcia_device */
  57. struct pcmcia_socket *socket;
  58. char *devname;
  59. u8 device_no;
  60. /* the hardware "function" device; certain subdevices can
  61. * share one hardware "function" device. */
  62. u8 func;
  63. struct config_t *function_config;
  64. struct list_head socket_device_list;
  65. /* deprecated, will be cleaned up soon */
  66. io_req_t io;
  67. config_req_t conf;
  68. window_handle_t win;
  69. /* device setup */
  70. unsigned int irq;
  71. struct resource *resource[MAX_IO_WIN];
  72. /* Is the device suspended? */
  73. u16 suspended:1;
  74. /* Flags whether io, irq, win configurations were
  75. * requested, and whether the configuration is "locked" */
  76. u16 _irq:1;
  77. u16 _io:1;
  78. u16 _win:4;
  79. u16 _locked:1;
  80. /* Flag whether a "fuzzy" func_id based match is
  81. * allowed. */
  82. u16 allow_func_id_match:1;
  83. /* information about this device */
  84. u16 has_manf_id:1;
  85. u16 has_card_id:1;
  86. u16 has_func_id:1;
  87. u16 reserved:4;
  88. u8 func_id;
  89. u16 manf_id;
  90. u16 card_id;
  91. char *prod_id[4];
  92. u64 dma_mask;
  93. struct device dev;
  94. /* data private to drivers */
  95. void *priv;
  96. unsigned int open;
  97. };
  98. #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev)
  99. #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv)
  100. /*
  101. * CIS access.
  102. *
  103. * Please use the following functions to access CIS tuples:
  104. * - pcmcia_get_tuple()
  105. * - pcmcia_loop_tuple()
  106. * - pcmcia_get_mac_from_cis()
  107. *
  108. * To parse a tuple_t, pcmcia_parse_tuple() exists. Its interface
  109. * might change in future.
  110. */
  111. /* get the very first CIS entry of type @code. Note that buf is pointer
  112. * to u8 *buf; and that you need to kfree(buf) afterwards. */
  113. size_t pcmcia_get_tuple(struct pcmcia_device *p_dev, cisdata_t code,
  114. u8 **buf);
  115. /* loop over CIS entries */
  116. int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code,
  117. int (*loop_tuple) (struct pcmcia_device *p_dev,
  118. tuple_t *tuple,
  119. void *priv_data),
  120. void *priv_data);
  121. /* get the MAC address from CISTPL_FUNCE */
  122. int pcmcia_get_mac_from_cis(struct pcmcia_device *p_dev,
  123. struct net_device *dev);
  124. /* parse a tuple_t */
  125. int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse);
  126. /* loop CIS entries for valid configuration */
  127. int pcmcia_loop_config(struct pcmcia_device *p_dev,
  128. int (*conf_check) (struct pcmcia_device *p_dev,
  129. cistpl_cftable_entry_t *cf,
  130. cistpl_cftable_entry_t *dflt,
  131. unsigned int vcc,
  132. void *priv_data),
  133. void *priv_data);
  134. /* is the device still there? */
  135. struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *p_dev);
  136. /* low-level interface reset */
  137. int pcmcia_reset_card(struct pcmcia_socket *skt);
  138. /* CIS config */
  139. int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val);
  140. int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val);
  141. /* device configuration */
  142. int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);
  143. int __must_check
  144. __pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
  145. irq_handler_t handler);
  146. static inline __must_check __deprecated int
  147. pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
  148. irq_handler_t handler)
  149. {
  150. return __pcmcia_request_exclusive_irq(p_dev, handler);
  151. }
  152. int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
  153. irq_handler_t handler);
  154. int pcmcia_request_configuration(struct pcmcia_device *p_dev,
  155. config_req_t *req);
  156. int pcmcia_request_window(struct pcmcia_device *p_dev, win_req_t *req,
  157. window_handle_t *wh);
  158. int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t win);
  159. int pcmcia_map_mem_page(struct pcmcia_device *p_dev, window_handle_t win,
  160. memreq_t *req);
  161. int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod);
  162. void pcmcia_disable_device(struct pcmcia_device *p_dev);
  163. #endif /* __KERNEL__ */
  164. #endif /* _LINUX_DS_H */