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