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