pcmciachip.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /* $OpenBSD: pcmciachip.h,v 1.8 2005/11/23 11:39:37 mickey Exp $ */
  2. /* $NetBSD: pcmciachip.h,v 1.5 2000/01/13 08:58:51 joda Exp $ */
  3. /*
  4. * Copyright (c) 1997 Marc Horowitz. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by Marc Horowitz.
  17. * 4. The name of the author may not be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  21. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  22. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef _PCMCIA_PCMCIACHIP_H_
  32. #define _PCMCIA_PCMCIACHIP_H_
  33. #include <machine/bus.h>
  34. struct pcmcia_function;
  35. struct pcmcia_mem_handle;
  36. struct pcmcia_io_handle;
  37. /* interfaces for pcmcia to call the chipset */
  38. typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
  39. typedef void *pcmcia_chipset_handle_t;
  40. typedef int pcmcia_mem_handle_t;
  41. #define PCMCIA_MEM_ATTR 1
  42. #define PCMCIA_MEM_COMMON 2
  43. #define PCMCIA_WIDTH_MEM8 8
  44. #define PCMCIA_WIDTH_MEM16 16
  45. #define PCMCIA_WIDTH_MEM_MASK 24
  46. #define PCMCIA_WIDTH_AUTO 0
  47. #define PCMCIA_WIDTH_IO8 1
  48. #define PCMCIA_WIDTH_IO16 2
  49. struct pcmcia_chip_functions {
  50. /* memory space allocation */
  51. int (*mem_alloc)(pcmcia_chipset_handle_t, bus_size_t,
  52. struct pcmcia_mem_handle *);
  53. void (*mem_free)(pcmcia_chipset_handle_t,
  54. struct pcmcia_mem_handle *);
  55. /* memory space window mapping */
  56. int (*mem_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
  57. bus_size_t, struct pcmcia_mem_handle *,
  58. bus_size_t *, int *);
  59. void (*mem_unmap)(pcmcia_chipset_handle_t, int);
  60. /* I/O space allocation */
  61. int (*io_alloc)(pcmcia_chipset_handle_t, bus_addr_t,
  62. bus_size_t, bus_size_t, struct pcmcia_io_handle *);
  63. void (*io_free)(pcmcia_chipset_handle_t,
  64. struct pcmcia_io_handle *);
  65. /* I/O space window mapping */
  66. int (*io_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
  67. bus_size_t, struct pcmcia_io_handle *, int *);
  68. void (*io_unmap)(pcmcia_chipset_handle_t, int);
  69. /* interrupt glue */
  70. void *(*intr_establish)(pcmcia_chipset_handle_t,
  71. struct pcmcia_function *, int, int (*)(void *), void *, char *);
  72. void (*intr_disestablish)(pcmcia_chipset_handle_t, void *);
  73. const char *(*intr_string)(pcmcia_chipset_handle_t, void *);
  74. /* card enable/disable */
  75. void (*socket_enable)(pcmcia_chipset_handle_t);
  76. void (*socket_disable)(pcmcia_chipset_handle_t);
  77. /* card detection */
  78. int (*card_detect)(pcmcia_chipset_handle_t);
  79. };
  80. /* Memory space functions. */
  81. #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp) \
  82. ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
  83. #define pcmcia_chip_mem_free(tag, handle, pcmhp) \
  84. ((*(tag)->mem_free)((handle), (pcmhp)))
  85. #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \
  86. offsetp, windowp) \
  87. ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
  88. (offsetp), (windowp)))
  89. #define pcmcia_chip_mem_unmap(tag, handle, window) \
  90. ((*(tag)->mem_unmap)((handle), (window)))
  91. /* I/O space functions. */
  92. #define pcmcia_chip_io_alloc(tag, handle, start, size, align, pcihp) \
  93. ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
  94. #define pcmcia_chip_io_free(tag, handle, pcihp) \
  95. ((*(tag)->io_free)((handle), (pcihp)))
  96. #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp, \
  97. windowp) \
  98. ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
  99. (windowp)))
  100. #define pcmcia_chip_io_unmap(tag, handle, window) \
  101. ((*(tag)->io_unmap)((handle), (window)))
  102. /* Interrupt functions. */
  103. #define pcmcia_chip_intr_establish(tag, handle, pf, ipl, fct, arg, xname) \
  104. ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg), (xname)))
  105. #define pcmcia_chip_intr_disestablish(tag, handle, ih) \
  106. ((*(tag)->intr_disestablish)((handle), (ih)))
  107. #define pcmcia_chip_intr_string(tag, handle, ih) \
  108. ((*(tag)->intr_string)((handle), (ih)))
  109. /* Socket functions. */
  110. #define pcmcia_chip_socket_enable(tag, handle) \
  111. ((*(tag)->socket_enable)((handle)))
  112. #define pcmcia_chip_socket_disable(tag, handle) \
  113. ((*(tag)->socket_disable)((handle)))
  114. struct pcmciabus_attach_args {
  115. char *paa_busname; /* Bus name */
  116. pcmcia_chipset_tag_t pct;
  117. pcmcia_chipset_handle_t pch;
  118. bus_addr_t iobase; /* start i/o space allocation here */
  119. bus_size_t iosize; /* size of the i/o space range */
  120. };
  121. /* interfaces for the chipset to call pcmcia */
  122. int pcmcia_card_attach(struct device *);
  123. void pcmcia_card_detach(struct device *, int);
  124. void pcmcia_card_deactivate(struct device *);
  125. int pcmcia_card_gettype(struct device *);
  126. #endif /* _PCMCIA_PCMCIACHIP_H_ */