Home | History | Annotate | Line # | Download | only in pcmcia
pcmciachip.h revision 1.1.2.10
      1 /*	$NetBSD: pcmciachip.h,v 1.1.2.10 1997/10/16 09:15:32 enami Exp $	*/
      2 
      3 #ifndef _PCMCIA_PCMCIACHIP_H_
      4 #define	_PCMCIA_PCMCIACHIP_H_
      5 
      6 #include <machine/bus.h>
      7 
      8 struct pcmcia_function;
      9 struct pcmcia_mem_handle;
     10 struct pcmcia_io_handle;
     11 
     12 /* interfaces for pcmcia to call the chipset */
     13 
     14 typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
     15 typedef void *pcmcia_chipset_handle_t;
     16 typedef int pcmcia_mem_handle_t;
     17 
     18 #define	PCMCIA_MEM_ATTR		1
     19 #define	PCMCIA_MEM_COMMON	2
     20 
     21 #define	PCMCIA_WIDTH_AUTO	0
     22 #define	PCMCIA_WIDTH_IO8	1
     23 #define	PCMCIA_WIDTH_IO16	2
     24 
     25 struct pcmcia_chip_functions {
     26 	/* memory space allocation */
     27 	int	(*mem_alloc) __P((pcmcia_chipset_handle_t, bus_size_t,
     28 		    struct pcmcia_mem_handle *));
     29 	void	(*mem_free) __P((pcmcia_chipset_handle_t,
     30 		    struct pcmcia_mem_handle *));
     31 
     32 	/* memory space window mapping */
     33 	int	(*mem_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
     34 		    bus_size_t, struct pcmcia_mem_handle *,
     35 		    bus_addr_t *, int *));
     36 	void	(*mem_unmap) __P((pcmcia_chipset_handle_t, int));
     37 
     38 	/* I/O space allocation */
     39 	int	(*io_alloc) __P((pcmcia_chipset_handle_t, bus_addr_t,
     40 		    bus_size_t, bus_size_t, struct pcmcia_io_handle *));
     41 	void	(*io_free) __P((pcmcia_chipset_handle_t,
     42 		    struct pcmcia_io_handle *));
     43 
     44 	/* I/O space window mapping */
     45 	int	(*io_map) __P((pcmcia_chipset_handle_t, int, bus_addr_t,
     46 		    bus_size_t, struct pcmcia_io_handle *, int *));
     47 	void	(*io_unmap) __P((pcmcia_chipset_handle_t, int));
     48 
     49 	/* interrupt glue */
     50 	void	*(*intr_establish) __P((pcmcia_chipset_handle_t,
     51 		    struct pcmcia_function *, int, int (*)(void *), void *));
     52 	void	(*intr_disestablish) __P((pcmcia_chipset_handle_t, void *));
     53 
     54 	/* card enable/disable */
     55 	void	(*socket_enable) __P((pcmcia_chipset_handle_t));
     56 	void	(*socket_disable) __P((pcmcia_chipset_handle_t));
     57 };
     58 
     59 /* Memory space functions. */
     60 #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp)			\
     61 	((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
     62 
     63 #define pcmcia_chip_mem_free(tag, handle, pcmhp)			\
     64 	((*(tag)->mem_free)((handle), (pcmhp)))
     65 
     66 #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp,	\
     67 	    offsetp, windowp)						\
     68 	((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
     69 	    (offsetp), (windowp)))
     70 
     71 #define pcmcia_chip_mem_unmap(tag, handle, window)			\
     72 	((*(tag)->mem_unmap)((handle), (window)))
     73 
     74 /* I/O space functions. */
     75 #define pcmcia_chip_io_alloc(tag, handle, start, size, align, pcihp)	\
     76 	((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
     77 
     78 #define pcmcia_chip_io_free(tag, handle, pcihp)				\
     79 	((*(tag)->io_free)((handle), (pcihp)))
     80 
     81 #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp,	\
     82 	    windowp) \
     83 	((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
     84 	    (windowp)))
     85 
     86 #define pcmcia_chip_io_unmap(tag, handle, window)			\
     87 	((*(tag)->io_unmap)((handle), (window)))
     88 
     89 /* Interrupt functions. */
     90 #define pcmcia_chip_intr_establish(tag, handle, pf, ipl, fct, arg)	\
     91 	((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg)))
     92 
     93 #define pcmcia_chip_intr_disestablish(tag, handle, ih)			\
     94 	((*(tag)->intr_disestablish)((handle), (ih)))
     95 
     96 /* Socket functions. */
     97 #define	pcmcia_chip_socket_enable(tag, handle)				\
     98 	((*(tag)->socket_enable)((handle)))
     99 #define	pcmcia_chip_socket_disable(tag, handle)				\
    100 	((*(tag)->socket_disable)((handle)))
    101 
    102 struct pcmciabus_attach_args {
    103 	pcmcia_chipset_tag_t pct;
    104 	pcmcia_chipset_handle_t pch;
    105 };
    106 
    107 /* interfaces for the chipset to call pcmcia */
    108 
    109 int	pcmcia_card_attach __P((struct device *));
    110 void	pcmcia_card_detach __P((struct device *));
    111 int	pcmcia_card_gettype __P((struct device *));
    112 
    113 #endif /* _PCMCIA_PCMCIACHIP_H_ */
    114