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