xref: /openbsd-src/sys/dev/pcmcia/pcmciachip.h (revision 60f78cd051b00f347af20ea848020710afc2c922)
1*60f78cd0Smickey /*	$OpenBSD: pcmciachip.h,v 1.8 2005/11/23 11:39:37 mickey Exp $ */
2e77beeccSaaron /*	$NetBSD: pcmciachip.h,v 1.5 2000/01/13 08:58:51 joda Exp $	*/
30720f62cSfgsch 
40720f62cSfgsch /*
50720f62cSfgsch  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
60720f62cSfgsch  *
70720f62cSfgsch  * Redistribution and use in source and binary forms, with or without
80720f62cSfgsch  * modification, are permitted provided that the following conditions
90720f62cSfgsch  * are met:
100720f62cSfgsch  * 1. Redistributions of source code must retain the above copyright
110720f62cSfgsch  *    notice, this list of conditions and the following disclaimer.
120720f62cSfgsch  * 2. Redistributions in binary form must reproduce the above copyright
130720f62cSfgsch  *    notice, this list of conditions and the following disclaimer in the
140720f62cSfgsch  *    documentation and/or other materials provided with the distribution.
150720f62cSfgsch  * 3. All advertising materials mentioning features or use of this software
160720f62cSfgsch  *    must display the following acknowledgement:
170720f62cSfgsch  *	This product includes software developed by Marc Horowitz.
180720f62cSfgsch  * 4. The name of the author may not be used to endorse or promote products
190720f62cSfgsch  *    derived from this software without specific prior written permission.
200720f62cSfgsch  *
210720f62cSfgsch  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
220720f62cSfgsch  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
230720f62cSfgsch  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
240720f62cSfgsch  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
250720f62cSfgsch  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
260720f62cSfgsch  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
270720f62cSfgsch  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
280720f62cSfgsch  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
290720f62cSfgsch  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
300720f62cSfgsch  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
310720f62cSfgsch  */
320720f62cSfgsch 
330720f62cSfgsch #ifndef _PCMCIA_PCMCIACHIP_H_
340720f62cSfgsch #define	_PCMCIA_PCMCIACHIP_H_
350720f62cSfgsch 
360720f62cSfgsch #include <machine/bus.h>
370720f62cSfgsch 
380720f62cSfgsch struct pcmcia_function;
390720f62cSfgsch struct pcmcia_mem_handle;
400720f62cSfgsch struct pcmcia_io_handle;
410720f62cSfgsch 
420720f62cSfgsch /* interfaces for pcmcia to call the chipset */
430720f62cSfgsch 
440720f62cSfgsch typedef struct pcmcia_chip_functions *pcmcia_chipset_tag_t;
450720f62cSfgsch typedef void *pcmcia_chipset_handle_t;
460720f62cSfgsch typedef int pcmcia_mem_handle_t;
470720f62cSfgsch 
480720f62cSfgsch #define	PCMCIA_MEM_ATTR		1
490720f62cSfgsch #define	PCMCIA_MEM_COMMON	2
500720f62cSfgsch 
51e77beeccSaaron #define	PCMCIA_WIDTH_MEM8	8
52e77beeccSaaron #define	PCMCIA_WIDTH_MEM16	16
53e77beeccSaaron 
54e77beeccSaaron #define	PCMCIA_WIDTH_MEM_MASK	24
55e77beeccSaaron 
560720f62cSfgsch #define	PCMCIA_WIDTH_AUTO	0
570720f62cSfgsch #define	PCMCIA_WIDTH_IO8	1
580720f62cSfgsch #define	PCMCIA_WIDTH_IO16	2
590720f62cSfgsch 
600720f62cSfgsch struct pcmcia_chip_functions {
610720f62cSfgsch 	/* memory space allocation */
62c4071fd1Smillert 	int	(*mem_alloc)(pcmcia_chipset_handle_t, bus_size_t,
63c4071fd1Smillert 		    struct pcmcia_mem_handle *);
64c4071fd1Smillert 	void	(*mem_free)(pcmcia_chipset_handle_t,
65c4071fd1Smillert 		    struct pcmcia_mem_handle *);
660720f62cSfgsch 
670720f62cSfgsch 	/* memory space window mapping */
68c4071fd1Smillert 	int	(*mem_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
690720f62cSfgsch 		    bus_size_t, struct pcmcia_mem_handle *,
70*60f78cd0Smickey 		    bus_size_t *, int *);
71c4071fd1Smillert 	void	(*mem_unmap)(pcmcia_chipset_handle_t, int);
720720f62cSfgsch 
730720f62cSfgsch 	/* I/O space allocation */
74c4071fd1Smillert 	int	(*io_alloc)(pcmcia_chipset_handle_t, bus_addr_t,
75c4071fd1Smillert 		    bus_size_t, bus_size_t, struct pcmcia_io_handle *);
76c4071fd1Smillert 	void	(*io_free)(pcmcia_chipset_handle_t,
77c4071fd1Smillert 		    struct pcmcia_io_handle *);
780720f62cSfgsch 
790720f62cSfgsch 	/* I/O space window mapping */
80c4071fd1Smillert 	int	(*io_map)(pcmcia_chipset_handle_t, int, bus_addr_t,
81c4071fd1Smillert 		    bus_size_t, struct pcmcia_io_handle *, int *);
82c4071fd1Smillert 	void	(*io_unmap)(pcmcia_chipset_handle_t, int);
830720f62cSfgsch 
840720f62cSfgsch 	/* interrupt glue */
854f9e30d0Smillert 	void	*(*intr_establish)(pcmcia_chipset_handle_t,
864f9e30d0Smillert 		    struct pcmcia_function *, int, int (*)(void *), void *, char *);
87c4071fd1Smillert 	void	(*intr_disestablish)(pcmcia_chipset_handle_t, void *);
8893704cdeSmillert 	const char *(*intr_string)(pcmcia_chipset_handle_t, void *);
890720f62cSfgsch 
900720f62cSfgsch 	/* card enable/disable */
91c4071fd1Smillert 	void	(*socket_enable)(pcmcia_chipset_handle_t);
92c4071fd1Smillert 	void	(*socket_disable)(pcmcia_chipset_handle_t);
93e77beeccSaaron 
94e77beeccSaaron 	/* card detection */
95c4071fd1Smillert 	int (*card_detect)(pcmcia_chipset_handle_t);
960720f62cSfgsch };
970720f62cSfgsch 
980720f62cSfgsch /* Memory space functions. */
990720f62cSfgsch #define pcmcia_chip_mem_alloc(tag, handle, size, pcmhp)			\
1000720f62cSfgsch 	((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
1010720f62cSfgsch 
1020720f62cSfgsch #define pcmcia_chip_mem_free(tag, handle, pcmhp)			\
1030720f62cSfgsch 	((*(tag)->mem_free)((handle), (pcmhp)))
1040720f62cSfgsch 
1050720f62cSfgsch #define pcmcia_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp,	\
1060720f62cSfgsch 	    offsetp, windowp)						\
1070720f62cSfgsch 	((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
1080720f62cSfgsch 	    (offsetp), (windowp)))
1090720f62cSfgsch 
1100720f62cSfgsch #define pcmcia_chip_mem_unmap(tag, handle, window)			\
1110720f62cSfgsch 	((*(tag)->mem_unmap)((handle), (window)))
1120720f62cSfgsch 
1130720f62cSfgsch /* I/O space functions. */
1140720f62cSfgsch #define pcmcia_chip_io_alloc(tag, handle, start, size, align, pcihp)	\
1150720f62cSfgsch 	((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
1160720f62cSfgsch 
1170720f62cSfgsch #define pcmcia_chip_io_free(tag, handle, pcihp)				\
1180720f62cSfgsch 	((*(tag)->io_free)((handle), (pcihp)))
1190720f62cSfgsch 
1200720f62cSfgsch #define pcmcia_chip_io_map(tag, handle, width, card_addr, size, pcihp,	\
1210720f62cSfgsch 	    windowp) \
1220720f62cSfgsch 	((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
1230720f62cSfgsch 	    (windowp)))
1240720f62cSfgsch 
1250720f62cSfgsch #define pcmcia_chip_io_unmap(tag, handle, window)			\
1260720f62cSfgsch 	((*(tag)->io_unmap)((handle), (window)))
1270720f62cSfgsch 
1280720f62cSfgsch /* Interrupt functions. */
129c59583c5Sderaadt #define pcmcia_chip_intr_establish(tag, handle, pf, ipl, fct, arg, xname)	\
130c59583c5Sderaadt 	((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg), (xname)))
1310720f62cSfgsch 
1320720f62cSfgsch #define pcmcia_chip_intr_disestablish(tag, handle, ih)			\
1330720f62cSfgsch 	((*(tag)->intr_disestablish)((handle), (ih)))
1340720f62cSfgsch 
13593704cdeSmillert #define pcmcia_chip_intr_string(tag, handle, ih)			\
13693704cdeSmillert 	((*(tag)->intr_string)((handle), (ih)))
13793704cdeSmillert 
1380720f62cSfgsch /* Socket functions. */
1390720f62cSfgsch #define	pcmcia_chip_socket_enable(tag, handle)				\
1400720f62cSfgsch 	((*(tag)->socket_enable)((handle)))
1410720f62cSfgsch #define	pcmcia_chip_socket_disable(tag, handle)				\
1420720f62cSfgsch 	((*(tag)->socket_disable)((handle)))
1430720f62cSfgsch 
1440720f62cSfgsch struct pcmciabus_attach_args {
145e77beeccSaaron 	char *paa_busname;	/* Bus name */
1460720f62cSfgsch 	pcmcia_chipset_tag_t pct;
1470720f62cSfgsch 	pcmcia_chipset_handle_t pch;
1480720f62cSfgsch 	bus_addr_t iobase;		/* start i/o space allocation here */
1490720f62cSfgsch 	bus_size_t iosize;		/* size of the i/o space range */
1500720f62cSfgsch };
1510720f62cSfgsch 
1520720f62cSfgsch /* interfaces for the chipset to call pcmcia */
1530720f62cSfgsch 
154c4071fd1Smillert int	pcmcia_card_attach(struct device *);
155c4071fd1Smillert void	pcmcia_card_detach(struct device *, int);
156c4071fd1Smillert void	pcmcia_card_deactivate(struct device *);
157c4071fd1Smillert int	pcmcia_card_gettype(struct device *);
1580720f62cSfgsch 
1590720f62cSfgsch #endif /* _PCMCIA_PCMCIACHIP_H_ */
160