1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 #include <sys/device.h>
34 #include <sys/timeout.h>
35
36 #include <dev/pcmcia/pcmciareg.h>
37 #include <dev/pcmcia/pcmciachip.h>
38
39 #include <dev/ic/i82365reg.h>
40
41 struct proc;
42
43 struct pcic_event {
44 SIMPLEQ_ENTRY(pcic_event) pe_q;
45 int pe_type;
46 };
47
48
49 #define PCIC_EVENT_INSERTION 0
50 #define PCIC_EVENT_REMOVAL 1
51
52 struct pcic_handle {
53 struct device *ph_parent;
54 bus_space_tag_t ph_bus_t;
55 bus_space_handle_t ph_bus_h;
56 u_int8_t (*ph_read)(struct pcic_handle *, int);
57 void (*ph_write)(struct pcic_handle *, int, int);
58
59 int vendor;
60 int sock;
61 int flags;
62 int laststate;
63 int memalloc;
64 struct {
65 bus_addr_t addr;
66 bus_size_t size;
67 long offset;
68 int kind;
69 } mem[PCIC_MEM_WINS];
70 int ioalloc;
71 struct {
72 bus_addr_t addr;
73 bus_size_t size;
74 int width;
75 } io[PCIC_IO_WINS];
76 int ih_irq;
77 struct device *pcmcia;
78
79 int shutdown;
80 struct proc *event_thread;
81 SIMPLEQ_HEAD(, pcic_event) events;
82 };
83
84 #define PCIC_FLAG_SOCKETP 0x0001
85 #define PCIC_FLAG_CARDP 0x0002
86
87 #define PCIC_LASTSTATE_PRESENT 0x0002
88 #define PCIC_LASTSTATE_HALF 0x0001
89 #define PCIC_LASTSTATE_EMPTY 0x0000
90
91 #define C0SA PCIC_CHIP0_BASE+PCIC_SOCKETA_INDEX
92 #define C0SB PCIC_CHIP0_BASE+PCIC_SOCKETB_INDEX
93 #define C1SA PCIC_CHIP1_BASE+PCIC_SOCKETA_INDEX
94 #define C1SB PCIC_CHIP1_BASE+PCIC_SOCKETB_INDEX
95
96
97
98
99
100
101 #define PCIC_MEM_PAGES 4
102 #define PCIC_MEMSIZE PCIC_MEM_PAGES*PCIC_MEM_PAGESIZE
103
104 #define PCIC_NSLOTS 4
105
106 struct pcic_ranges {
107 u_short start;
108 u_short len;
109 };
110
111 struct pcic_softc {
112 struct device dev;
113
114 bus_space_tag_t memt;
115 bus_space_handle_t memh;
116 bus_space_tag_t iot;
117 bus_space_handle_t ioh;
118
119
120 void *intr_est;
121
122 pcmcia_chipset_tag_t pct;
123
124
125 int subregionmask;
126 #define PCIC_MAX_MEM_PAGES (8 * sizeof(int))
127
128
129 bus_addr_t membase;
130
131
132
133
134
135
136
137
138 bus_addr_t iobase;
139 bus_addr_t iosize;
140 struct pcic_ranges *ranges;
141
142 int irq;
143 void *ih;
144
145
146 struct timeout poll_timeout;
147 int poll_established;
148
149 struct pcic_handle handle[PCIC_NSLOTS];
150 };
151
152
153 int pcic_ident_ok(int);
154 int pcic_vendor(struct pcic_handle *);
155
156 void pcic_attach(struct pcic_softc *);
157 void pcic_attach_sockets(struct pcic_softc *);
158 int pcic_intr(void *arg);
159 void pcic_poll_intr(void *arg);
160
161 int pcic_chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
162 struct pcmcia_mem_handle *);
163 void pcic_chip_mem_free(pcmcia_chipset_handle_t,
164 struct pcmcia_mem_handle *);
165 int pcic_chip_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t,
166 bus_size_t, struct pcmcia_mem_handle *, bus_size_t *, int *);
167 void pcic_chip_mem_unmap(pcmcia_chipset_handle_t, int);
168
169 int pcic_chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t,
170 bus_size_t, bus_size_t, struct pcmcia_io_handle *);
171 void pcic_chip_io_free(pcmcia_chipset_handle_t,
172 struct pcmcia_io_handle *);
173 int pcic_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t,
174 bus_size_t, struct pcmcia_io_handle *, int *);
175 void pcic_chip_io_unmap(pcmcia_chipset_handle_t, int);
176
177 void pcic_chip_socket_enable(pcmcia_chipset_handle_t);
178 void pcic_chip_socket_disable(pcmcia_chipset_handle_t);
179
180 void pcic_power(int, void *);
181
182 #define pcic_read(h, idx) \
183 (*(h)->ph_read)((h), (idx))
184
185 #define pcic_write(h, idx, data) \
186 (*(h)->ph_write)((h), (idx), (data))