cardslotvar.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /* $OpenBSD: cardslotvar.h,v 1.6 2013/10/30 08:47:20 mpi Exp $ */
  2. /* $NetBSD: cardslotvar.h,v 1.5 2000/03/13 23:52:38 soren Exp $ */
  3. /*
  4. * Copyright (c) 1999
  5. * HAYAKAWA Koichi. All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  20. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  21. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  25. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  26. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. * POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. #ifndef _DEV_CARDBUS_CARDSLOTVAR_H_
  30. #define _DEV_CARDBUS_CARDSLOTVAR_H_
  31. /* require sys/device.h */
  32. /* require sys/queue.h */
  33. struct cardslot_event;
  34. /*
  35. * The data structure cardslot_attach_args is the attach argument for
  36. * PCMCIA (including CardBus and 16-bit card) slot.
  37. */
  38. struct cardslot_attach_args {
  39. char *caa_busname;
  40. int caa_slot;
  41. /* for cardbus... */
  42. struct cbslot_attach_args *caa_cb_attach;
  43. /* for 16-bit pcmcia */
  44. struct pcmciabus_attach_args *caa_16_attach;
  45. /* XXX: for 16-bit pcmcia. dirty!
  46. * This should be removed to achieve MI.
  47. */
  48. struct pcic_handle *caa_ph;
  49. };
  50. /*
  51. * The data structure cardslot_attach_args is the attach argument for
  52. * PCMCIA (including CardBus and 16-bit card) slot.
  53. */
  54. struct cardslot_softc {
  55. struct device sc_dev;
  56. int sc_slot; /* slot number */
  57. int sc_status; /* the status of slot */
  58. struct cardbus_softc *sc_cb_softc;
  59. struct pcmcia_softc *sc_16_softc;
  60. /* An event queue for the thread which processes slot state events. */
  61. SIMPLEQ_HEAD(, cardslot_event) sc_events;
  62. struct task sc_event_task;
  63. };
  64. #define CARDSLOT_STATUS_CARD_MASK 0x07
  65. #define CARDSLOT_STATUS_CARD_NONE 0x00 /* NO card inserted */
  66. #define CARDSLOT_STATUS_CARD_16 0x01 /* 16-bit pcmcia card inserted */
  67. #define CARDSLOT_STATUS_CARD_CB 0x02 /* CardBus pcmcia card inserted */
  68. #define CARDSLOT_STATUS_UNKNOWN 0x07 /* Unknown card inserted */
  69. #define CARDSLOT_CARDTYPE(x) ((x) & CARDSLOT_STATUS_CARD_MASK)
  70. #define CARDSLOT_SET_CARDTYPE(x, type) \
  71. do {(x) &= ~CARDSLOT_STATUS_CARD_MASK;\
  72. (x) |= (CARDSLOT_STATUS_CARD_MASK & (type));} while(0)
  73. #define CARDSLOT_STATUS_WORK_MASK 0x08
  74. #define CARDSLOT_STATUS_WORKING 0x08 /* at least one function works */
  75. #define CARDSLOT_STATUS_NOTWORK 0x00 /* no functions are working */
  76. #define CARDSLOT_WORK(x) ((x) & CARDSLOT_STATUS_WORK_MASK)
  77. #define CARDSLOT_SET_WORK(x, type) \
  78. do {(x) &= ~CARDSLOT_STATUS_WORK_MASK;\
  79. (x) |= (CARDSLOT_STATUS_WORK_MASK & (type));} while(0)
  80. struct cardslot_event {
  81. SIMPLEQ_ENTRY(cardslot_event) ce_q;
  82. int ce_type;
  83. };
  84. typedef struct cardslot_softc *cardslot_t;
  85. /* ce_type */
  86. #define CARDSLOT_EVENT_INSERTION_16 0
  87. #define CARDSLOT_EVENT_REMOVAL_16 1
  88. #define CARDSLOT_EVENT_INSERTION_CB 2
  89. #define CARDSLOT_EVENT_REMOVAL_CB 3
  90. #define IS_CARDSLOT_INSERT_REMOVE_EV(x) (0 <= (x) && (x) <= 3)
  91. void cardslot_event_throw(cardslot_t, int);
  92. #endif /* !_DEV_CARDBUS_CARDSLOTVAR_H_ */