cs_internal.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * cs_internal.h -- definitions internal to the PCMCIA core modules
  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 - 2010 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.
  19. */
  20. #ifndef _LINUX_CS_INTERNAL_H
  21. #define _LINUX_CS_INTERNAL_H
  22. #include <linux/kref.h>
  23. /* Flags in client state */
  24. #define CLIENT_WIN_REQ(i) (0x1<<(i))
  25. /* Flag to access all functions */
  26. #define BIND_FN_ALL 0xff
  27. /* Each card function gets one of these guys */
  28. typedef struct config_t {
  29. struct kref ref;
  30. unsigned int state;
  31. unsigned int Attributes;
  32. unsigned int IntType;
  33. unsigned int ConfigBase;
  34. unsigned char Status, Pin, Copy, Option, ExtStatus;
  35. unsigned int CardValues;
  36. struct resource io[MAX_IO_WIN]; /* io ports */
  37. struct resource mem[MAX_WIN]; /* mem areas */
  38. struct {
  39. u_int Attributes;
  40. } irq;
  41. } config_t;
  42. struct cis_cache_entry {
  43. struct list_head node;
  44. unsigned int addr;
  45. unsigned int len;
  46. unsigned int attr;
  47. unsigned char cache[0];
  48. };
  49. struct pccard_resource_ops {
  50. int (*validate_mem) (struct pcmcia_socket *s);
  51. int (*find_io) (struct pcmcia_socket *s,
  52. unsigned int attr,
  53. unsigned int *base,
  54. unsigned int num,
  55. unsigned int align,
  56. struct resource **parent);
  57. struct resource* (*find_mem) (unsigned long base, unsigned long num,
  58. unsigned long align, int low,
  59. struct pcmcia_socket *s);
  60. int (*init) (struct pcmcia_socket *s);
  61. void (*exit) (struct pcmcia_socket *s);
  62. };
  63. /* Flags in config state */
  64. #define CONFIG_LOCKED 0x01
  65. #define CONFIG_IRQ_REQ 0x02
  66. #define CONFIG_IO_REQ 0x04
  67. /* Flags in socket state */
  68. #define SOCKET_PRESENT 0x0008
  69. #define SOCKET_INUSE 0x0010
  70. #define SOCKET_SUSPEND 0x0080
  71. #define SOCKET_WIN_REQ(i) (0x0100<<(i))
  72. #define SOCKET_CARDBUS 0x8000
  73. #define SOCKET_CARDBUS_CONFIG 0x10000
  74. /*
  75. * Stuff internal to module "pcmcia_rsrc":
  76. */
  77. extern int static_init(struct pcmcia_socket *s);
  78. extern struct resource *pcmcia_make_resource(unsigned long start,
  79. unsigned long end,
  80. int flags, const char *name);
  81. /*
  82. * Stuff internal to module "pcmcia_core":
  83. */
  84. /* socket_sysfs.c */
  85. extern int pccard_sysfs_add_socket(struct device *dev);
  86. extern void pccard_sysfs_remove_socket(struct device *dev);
  87. /* cardbus.c */
  88. int cb_alloc(struct pcmcia_socket *s);
  89. void cb_free(struct pcmcia_socket *s);
  90. /*
  91. * Stuff exported by module "pcmcia_core" to module "pcmcia"
  92. */
  93. struct pcmcia_callback{
  94. struct module *owner;
  95. int (*add) (struct pcmcia_socket *s);
  96. int (*remove) (struct pcmcia_socket *s);
  97. void (*requery) (struct pcmcia_socket *s);
  98. int (*validate) (struct pcmcia_socket *s, unsigned int *i);
  99. int (*suspend) (struct pcmcia_socket *s);
  100. int (*early_resume) (struct pcmcia_socket *s);
  101. int (*resume) (struct pcmcia_socket *s);
  102. };
  103. /* cs.c */
  104. extern struct rw_semaphore pcmcia_socket_list_rwsem;
  105. extern struct list_head pcmcia_socket_list;
  106. extern struct class pcmcia_socket_class;
  107. int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
  108. struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
  109. void pcmcia_parse_uevents(struct pcmcia_socket *socket, unsigned int events);
  110. #define PCMCIA_UEVENT_EJECT 0x0001
  111. #define PCMCIA_UEVENT_INSERT 0x0002
  112. #define PCMCIA_UEVENT_SUSPEND 0x0004
  113. #define PCMCIA_UEVENT_RESUME 0x0008
  114. #define PCMCIA_UEVENT_REQUERY 0x0010
  115. struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
  116. void pcmcia_put_socket(struct pcmcia_socket *skt);
  117. /*
  118. * Stuff internal to module "pcmcia".
  119. */
  120. /* ds.c */
  121. extern struct bus_type pcmcia_bus_type;
  122. struct pcmcia_device;
  123. /* pcmcia_resource.c */
  124. extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
  125. extern int pcmcia_validate_mem(struct pcmcia_socket *s);
  126. extern struct resource *pcmcia_find_mem_region(u_long base,
  127. u_long num,
  128. u_long align,
  129. int low,
  130. struct pcmcia_socket *s);
  131. void pcmcia_cleanup_irq(struct pcmcia_socket *s);
  132. int pcmcia_setup_irq(struct pcmcia_device *p_dev);
  133. /* cistpl.c */
  134. extern struct bin_attribute pccard_cis_attr;
  135. int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
  136. u_int addr, u_int len, void *ptr);
  137. int pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
  138. u_int addr, u_int len, void *ptr);
  139. void release_cis_mem(struct pcmcia_socket *s);
  140. void destroy_cis_cache(struct pcmcia_socket *s);
  141. int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
  142. cisdata_t code, void *parse);
  143. int pcmcia_replace_cis(struct pcmcia_socket *s,
  144. const u8 *data, const size_t len);
  145. int pccard_validate_cis(struct pcmcia_socket *s, unsigned int *count);
  146. int verify_cis_cache(struct pcmcia_socket *s);
  147. int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function,
  148. cisdata_t code, cisparse_t *parse, void *priv_data,
  149. int (*loop_tuple) (tuple_t *tuple,
  150. cisparse_t *parse,
  151. void *priv_data));
  152. int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function,
  153. tuple_t *tuple);
  154. int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function,
  155. tuple_t *tuple);
  156. int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
  157. #endif /* _LINUX_CS_INTERNAL_H */