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