xref: /freebsd/sys/dev/cardbus/cardbusvar.h (revision 5129159789cc9d7bc514e4546b88e3427695002d)
1 /*	$Id: cardbusvar.h,v 1.1.2.1 1999/02/16 16:46:08 haya Exp $	*/
2 
3 /*
4  * Copyright (c) 1998 HAYAKAWA Koichi.  All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *	This product includes software developed by the author.
17  * 4. The name of the author may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 /* $FreeBSD$ */
34 
35 #if !defined SYS_DEV_PCCARD_CARDBUSVAR_H
36 #define SYS_DEV_PCCARD_CARDBUSVAR_H
37 #include <pci/pcivar.h> /* XXX */
38 typedef pcitag_t cardbustag_t; /* XXX */
39 
40 typedef struct cardbus_functions {
41     int (*cardbus_ctrl) __P((cardbus_chipset_tag_t, int));
42     int (*cardbus_power) __P((cardbus_chipset_tag_t, int));
43     int (*cardbus_mem_open) __P((cardbus_chipset_tag_t, int, u_int32_t, u_int32_t));
44     int (*cardbus_mem_close) __P((cardbus_chipset_tag_t, int));
45     int (*cardbus_io_open) __P((cardbus_chipset_tag_t, int, u_int32_t, u_int32_t));
46     int (*cardbus_io_close) __P((cardbus_chipset_tag_t, int));
47     void *(*cardbus_intr_establish) __P((cardbus_chipset_tag_t, int irq, int level, int (*ih)(void *), void *sc));
48     void (*cardbus_intr_disestablish) __P((cardbus_chipset_tag_t ct, void *ih));
49     cardbustag_t (*cardbus_make_tag) __P((cardbus_chipset_tag_t, int, int, int));
50     void (*cardbus_free_tag) __P((cardbus_chipset_tag_t, cardbustag_t));
51     cardbusreg_t (*cardbus_conf_read) __P((cardbus_chipset_tag_t, cardbustag_t, int));
52     void (*cardbus_conf_write) __P((cardbus_chipset_tag_t, cardbustag_t, int, cardbusreg_t));
53 } cardbus_function_t, *cardbus_function_tag_t;
54 
55 /**********************************************************************
56 * struct cbslot_attach_args is the attach argument for cardbus slot.
57 **********************************************************************/
58 struct cbslot_attach_args {
59   char *cba_busname;
60   bus_space_tag_t cba_iot;	/* cardbus i/o space tag */
61   bus_space_tag_t cba_memt;	/* cardbus mem space tag */
62   bus_dma_tag_t cba_dmat;	/* DMA tag */
63 
64   int cba_bus;			/* cardbus bus number */
65   int cba_function;		/* slot number on this Host Bus Adaptor */
66 
67   cardbus_chipset_tag_t cba_cc;	/* cardbus chipset */
68   cardbus_function_tag_t cba_cf; /* cardbus functions */
69   int cba_intrline;		/* interrupt line */
70 };
71 
72 #define cbslotcf_slot  cf_loc[0]
73 #define CBSLOT_UNK_SLOT -1
74 
75 /**********************************************************************
76 * struct cardslot_if is the interface for cardslot.
77 **********************************************************************/
78 struct cardslot_if {
79     struct device *(*if_card_attach) __P((struct cardbus_softc*));
80 };
81 /**********************************************************************
82 * struct cardbus_softc is the softc for cardbus card.
83 **********************************************************************/
84 struct cardbus_softc {
85   struct device sc_dev;		/* fundamental device structure */
86 
87   int sc_bus;			/* cardbus bus number */
88   int sc_device;		/* cardbus device number */
89   int sc_intrline;		/* CardBus intrline */
90 
91   bus_space_tag_t sc_iot;	/* CardBus I/O space tag */
92   bus_space_tag_t sc_memt;	/* CardBus MEM space tag */
93   bus_dma_tag_t sc_dmat;	/* DMA tag */
94   cardbus_chipset_tag_t sc_cc;	/* CardBus chipset */
95   cardbus_function_tag_t sc_cf;	/* CardBus function */
96 
97   int sc_volt;			/* applied Vcc voltage */
98 #define PCCARD_33V  0x02
99 #define PCCARD_XXV  0x04
100 #define PCCARD_YYV  0x08
101   struct cardslot_if sc_if;
102 };
103 void
104 cardslot_if_setup __P((struct cardbus_softc*));
105 
106 /**********************************************************************
107 * struct cbslot_attach_args is the attach argument for cardbus card.
108 **********************************************************************/
109 struct cardbus_attach_args {
110   int ca_unit;
111   cardbus_chipset_tag_t ca_cc;
112   cardbus_function_tag_t ca_cf;
113 
114   bus_space_tag_t ca_iot;	/* CardBus I/O space tag */
115   bus_space_tag_t ca_memt;	/* CardBus MEM space tag */
116   bus_dma_tag_t ca_dmat;	/* DMA tag */
117 
118   u_int ca_device;
119   u_int ca_function;
120   cardbustag_t ca_tag;
121   cardbusreg_t ca_id;
122   cardbusreg_t ca_class;
123 
124   /* interrupt information */
125   cardbus_intr_line_t ca_intrline;
126 };
127 
128 
129 #define CARDBUS_ENABLE  1	/* enable the channel */
130 #define CARDBUS_DISABLE 2	/* disable the channel */
131 #define CARDBUS_RESET   4
132 #define CARDBUS_CD      7
133 #  define CARDBUS_NOCARD 0
134 #  define CARDBUS_5V_CARD 0x01	/* XXX: It must not exist */
135 #  define CARDBUS_3V_CARD 0x02
136 #  define CARDBUS_XV_CARD 0x04
137 #  define CARDBUS_YV_CARD 0x08
138 #define CARDBUS_IO_ENABLE    100
139 #define CARDBUS_IO_DISABLE   101
140 #define CARDBUS_MEM_ENABLE   102
141 #define CARDBUS_MEM_DISABLE  103
142 #define CARDBUS_BM_ENABLE    104 /* bus master */
143 #define CARDBUS_BM_DISABLE   105
144 
145 #define CARDBUS_VCC_UC  0x0000
146 #define CARDBUS_VCC_3V  0x0001
147 #define CARDBUS_VCC_XV  0x0002
148 #define CARDBUS_VCC_YV  0x0003
149 #define CARDBUS_VCC_0V  0x0004
150 #define CARDBUS_VCC_5V  0x0005	/* ??? */
151 #define CARDBUS_VCCMASK 0x000f
152 #define CARDBUS_VPP_UC  0x0000
153 #define CARDBUS_VPP_VCC 0x0010
154 #define CARDBUS_VPP_12V 0x0030
155 #define CARDBUS_VPP_0V  0x0040
156 #define CARDBUS_VPPMASK 0x00f0
157 
158 
159 /**********************************************************************
160 * Locators devies that attach to 'cardbus', as specified to config.
161 **********************************************************************/
162 #include "locators.h"
163 
164 #define cardbuscf_dev cf_loc[CARDBUSCF_DEV]
165 #define CARDBUS_UNK_DEV CARDBUSCF_DEV_DEFAULT
166 
167 #define cardbuscf_function cf_loc[CARDBUSCF_FUNC]
168 #define CARDBUS_UNK_FUNCTION CARDBUSCF_FUNC_DEFAULT
169 
170 struct device *cardbus_attach_card __P((struct cardbus_softc *));
171 void *cardbus_intr_establish __P((cardbus_chipset_tag_t, cardbus_function_tag_t, cardbus_intr_handle_t irq, int level, int (*func) (void *), void *arg));
172 void cardbus_intr_disestablish __P((cardbus_chipset_tag_t, cardbus_function_tag_t, void *handler));
173 
174 #define cardbus_conf_read(cc, cf, tag, offs) ((cf)->cardbus_conf_read)((cc), (tag), (offs))
175 #define cardbus_conf_write(cc, cf, tag, offs, val) ((cf)->cardbus_conf_write)((cc), (tag), (offs), (val))
176 #define cardbus_make_tag(cc, cf, bus, device, function) ((cf)->cardbus_make_tag)((cc), (bus), (device), (function))
177 #define cardbus_free_tag(cc, cf, tag) ((cf)->cardbus_free_tag)((cc), (tag))
178 
179 #endif /* SYS_DEV_PCCARD_CARDBUSVAR_H */
180 
181