Home | History | Annotate | Line # | Download | only in cardbus
cardslotvar.h revision 1.13
      1  1.13  drochner /*	$NetBSD: cardslotvar.h,v 1.13 2008/06/25 11:42:32 drochner 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.4    kleink #ifndef _DEV_CARDBUS_CARDSLOTVAR_H_
     36   1.4    kleink #define _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.6      haya 	/* for cardbus... */
     49   1.6      haya 	struct cbslot_attach_args *caa_cb_attach;
     50   1.1      haya 
     51   1.6      haya 	/* for 16-bit pcmcia */
     52   1.6      haya 	struct pcmciabus_attach_args *caa_16_attach;
     53   1.1      haya 
     54   1.6      haya 	/*
     55   1.6      haya 	 * XXX: for 16-bit pcmcia.  dirty!  This should be removed to
     56   1.6      haya          * achieve MI.
     57   1.6      haya 	 */
     58   1.6      haya 	struct pcic_handle *caa_ph;
     59   1.1      haya };
     60   1.1      haya 
     61   1.1      haya 
     62   1.1      haya /*
     63   1.1      haya  * The data structure cardslot_attach_args is the attach argument for
     64   1.1      haya  * PCMCIA (including CardBus and 16-bit card) slot.
     65   1.1      haya  */
     66   1.1      haya struct cardslot_softc {
     67  1.13  drochner 	device_t sc_dev;
     68   1.1      haya 
     69   1.6      haya 	int sc_status;		/* the status of slot */
     70   1.1      haya 
     71   1.6      haya 	struct cardbus_softc *sc_cb_softc;
     72   1.6      haya 	struct pcmcia_softc *sc_16_softc;
     73   1.1      haya 
     74  1.11        ad 	struct lwp *sc_event_thread;
     75   1.6      haya 	int sc_th_enable;	/* true if the thread is enabled */
     76   1.1      haya 
     77   1.6      haya 	/* An event queue for the thread which processes slot state events. */
     78   1.1      haya 
     79   1.6      haya 	SIMPLEQ_HEAD(, cardslot_event) sc_events;
     80   1.1      haya };
     81   1.1      haya 
     82   1.1      haya #define CARDSLOT_STATUS_CARD_MASK     0x07
     83   1.1      haya #define CARDSLOT_STATUS_CARD_NONE     0x00  /* NO card inserted */
     84   1.1      haya #define CARDSLOT_STATUS_CARD_16	      0x01  /* 16-bit pcmcia card inserted */
     85   1.1      haya #define CARDSLOT_STATUS_CARD_CB	      0x02  /* CardBus pcmcia card inserted */
     86   1.1      haya #define CARDSLOT_STATUS_UNKNOWN	      0x07  /* Unknown card inserted */
     87   1.1      haya 
     88   1.1      haya #define CARDSLOT_CARDTYPE(x) ((x) & CARDSLOT_STATUS_CARD_MASK)
     89   1.1      haya #define CARDSLOT_SET_CARDTYPE(x, type) \
     90   1.1      haya 	do {(x) &= ~CARDSLOT_STATUS_CARD_MASK;\
     91   1.1      haya 	    (x) |= (CARDSLOT_STATUS_CARD_MASK & (type));} while(0)
     92   1.1      haya 
     93   1.1      haya #define CARDSLOT_STATUS_WORK_MASK     0x08
     94   1.1      haya #define CARDSLOT_STATUS_WORKING	      0x08  /* at least one function works */
     95   1.1      haya #define CARDSLOT_STATUS_NOTWORK	      0x00  /* no functions are working */
     96   1.3      haya 
     97   1.3      haya #define CARDSLOT_WORK(x) ((x) & CARDSLOT_STATUS_WORK_MASK)
     98   1.3      haya #define CARDSLOT_SET_WORK(x, type) \
     99   1.3      haya 	do {(x) &= ~CARDSLOT_STATUS_WORK_MASK;\
    100   1.3      haya 	    (x) |= (CARDSLOT_STATUS_WORK_MASK & (type));} while(0)
    101   1.1      haya 
    102   1.1      haya 
    103   1.1      haya struct cardslot_event {
    104   1.6      haya 	SIMPLEQ_ENTRY(cardslot_event) ce_q;
    105   1.1      haya 
    106   1.6      haya 	int ce_type;
    107   1.1      haya };
    108   1.1      haya 
    109   1.1      haya /* ce_type */
    110   1.1      haya #define	CARDSLOT_EVENT_INSERTION_16	0
    111   1.1      haya #define	CARDSLOT_EVENT_REMOVAL_16	1
    112   1.1      haya 
    113   1.1      haya #define	CARDSLOT_EVENT_INSERTION_CB	2
    114   1.1      haya #define	CARDSLOT_EVENT_REMOVAL_CB	3
    115   1.1      haya 
    116   1.1      haya #define IS_CARDSLOT_INSERT_REMOVE_EV(x) (0 <= (x) && (x) <= 3)
    117   1.1      haya 
    118  1.13  drochner void cardslot_event_throw(struct cardslot_softc *, int);
    119   1.1      haya 
    120   1.4    kleink #endif /* !_DEV_CARDBUS_CARDSLOTVAR_H_ */
    121