| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_rtw_cardbus.c,v 1.27 2008/06/24 19:44:52 drochner Exp $ */ | | 1 | /* $NetBSD: if_rtw_cardbus.c,v 1.28 2009/02/06 01:55:19 dyoung Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004, 2005 David Young. All rights reserved. | | 4 | * Copyright (c) 2004, 2005 David Young. All rights reserved. |
5 | * | | 5 | * |
6 | * Adapted for the RTL8180 by David Young. | | 6 | * Adapted for the RTL8180 by David Young. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -57,27 +57,27 @@ | | | @@ -57,27 +57,27 @@ |
57 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 57 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
58 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 58 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
60 | * POSSIBILITY OF SUCH DAMAGE. | | 60 | * POSSIBILITY OF SUCH DAMAGE. |
61 | */ | | 61 | */ |
62 | | | 62 | |
63 | /* | | 63 | /* |
64 | * Cardbus front-end for the Realtek RTL8180 802.11 MAC/BBP driver. | | 64 | * Cardbus front-end for the Realtek RTL8180 802.11 MAC/BBP driver. |
65 | * | | 65 | * |
66 | * TBD factor with atw, tlp Cardbus front-ends? | | 66 | * TBD factor with atw, tlp Cardbus front-ends? |
67 | */ | | 67 | */ |
68 | | | 68 | |
69 | #include <sys/cdefs.h> | | 69 | #include <sys/cdefs.h> |
70 | __KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.27 2008/06/24 19:44:52 drochner Exp $"); | | 70 | __KERNEL_RCSID(0, "$NetBSD: if_rtw_cardbus.c,v 1.28 2009/02/06 01:55:19 dyoung Exp $"); |
71 | | | 71 | |
72 | #include "opt_inet.h" | | 72 | #include "opt_inet.h" |
73 | #include "bpfilter.h" | | 73 | #include "bpfilter.h" |
74 | | | 74 | |
75 | #include <sys/param.h> | | 75 | #include <sys/param.h> |
76 | #include <sys/systm.h> | | 76 | #include <sys/systm.h> |
77 | #include <sys/mbuf.h> | | 77 | #include <sys/mbuf.h> |
78 | #include <sys/malloc.h> | | 78 | #include <sys/malloc.h> |
79 | #include <sys/kernel.h> | | 79 | #include <sys/kernel.h> |
80 | #include <sys/socket.h> | | 80 | #include <sys/socket.h> |
81 | #include <sys/ioctl.h> | | 81 | #include <sys/ioctl.h> |
82 | #include <sys/errno.h> | | 82 | #include <sys/errno.h> |
83 | #include <sys/device.h> | | 83 | #include <sys/device.h> |
| @@ -187,32 +187,26 @@ rtw_cardbus_lookup(const struct cardbus_ | | | @@ -187,32 +187,26 @@ rtw_cardbus_lookup(const struct cardbus_ |
187 | | | 187 | |
188 | int | | 188 | int |
189 | rtw_cardbus_match(device_t parent, struct cfdata *match, void *aux) | | 189 | rtw_cardbus_match(device_t parent, struct cfdata *match, void *aux) |
190 | { | | 190 | { |
191 | struct cardbus_attach_args *ca = aux; | | 191 | struct cardbus_attach_args *ca = aux; |
192 | | | 192 | |
193 | if (rtw_cardbus_lookup(ca) != NULL) | | 193 | if (rtw_cardbus_lookup(ca) != NULL) |
194 | return 1; | | 194 | return 1; |
195 | | | 195 | |
196 | return 0; | | 196 | return 0; |
197 | } | | 197 | } |
198 | | | 198 | |
199 | static void | | 199 | static void |
200 | rtw_cardbus_intr_ack(struct rtw_regs *regs) | | | |
201 | { | | | |
202 | RTW_WRITE(regs, RTW_FER, RTW_FER_INTR); | | | |
203 | } | | | |
204 | | | | |
205 | static void | | | |
206 | rtw_cardbus_funcregen(struct rtw_regs *regs, int enable) | | 200 | rtw_cardbus_funcregen(struct rtw_regs *regs, int enable) |
207 | { | | 201 | { |
208 | u_int32_t reg; | | 202 | u_int32_t reg; |
209 | rtw_config0123_enable(regs, 1); | | 203 | rtw_config0123_enable(regs, 1); |
210 | reg = RTW_READ(regs, RTW_CONFIG3); | | 204 | reg = RTW_READ(regs, RTW_CONFIG3); |
211 | if (enable) | | 205 | if (enable) |
212 | RTW_WRITE(regs, RTW_CONFIG3, reg | RTW_CONFIG3_FUNCREGEN); | | 206 | RTW_WRITE(regs, RTW_CONFIG3, reg | RTW_CONFIG3_FUNCREGEN); |
213 | else | | 207 | else |
214 | RTW_WRITE(regs, RTW_CONFIG3, reg & ~RTW_CONFIG3_FUNCREGEN); | | 208 | RTW_WRITE(regs, RTW_CONFIG3, reg & ~RTW_CONFIG3_FUNCREGEN); |
215 | rtw_config0123_enable(regs, 0); | | 209 | rtw_config0123_enable(regs, 0); |
216 | } | | 210 | } |
217 | | | 211 | |
218 | void | | 212 | void |
| @@ -228,28 +222,26 @@ rtw_cardbus_attach(device_t parent, devi | | | @@ -228,28 +222,26 @@ rtw_cardbus_attach(device_t parent, devi |
228 | int rev; | | 222 | int rev; |
229 | | | 223 | |
230 | sc->sc_dev = self; | | 224 | sc->sc_dev = self; |
231 | sc->sc_dmat = ca->ca_dmat; | | 225 | sc->sc_dmat = ca->ca_dmat; |
232 | csc->sc_ct = ct; | | 226 | csc->sc_ct = ct; |
233 | csc->sc_tag = ca->ca_tag; | | 227 | csc->sc_tag = ca->ca_tag; |
234 | | | 228 | |
235 | rcp = rtw_cardbus_lookup(ca); | | 229 | rcp = rtw_cardbus_lookup(ca); |
236 | if (rcp == NULL) { | | 230 | if (rcp == NULL) { |
237 | printf("\n"); | | 231 | printf("\n"); |
238 | panic("rtw_cardbus_attach: impossible"); | | 232 | panic("rtw_cardbus_attach: impossible"); |
239 | } | | 233 | } |
240 | | | 234 | |
241 | sc->sc_intr_ack = rtw_cardbus_intr_ack; | | | |
242 | | | | |
243 | /* Get revision info. */ | | 235 | /* Get revision info. */ |
244 | rev = PCI_REVISION(ca->ca_class); | | 236 | rev = PCI_REVISION(ca->ca_class); |
245 | | | 237 | |
246 | printf(": %s\n", rcp->rcp_product_name); | | 238 | printf(": %s\n", rcp->rcp_product_name); |
247 | | | 239 | |
248 | RTW_DPRINTF(RTW_DEBUG_ATTACH, | | 240 | RTW_DPRINTF(RTW_DEBUG_ATTACH, |
249 | ("%s: pass %d.%d signature %08x\n", device_xname(self), | | 241 | ("%s: pass %d.%d signature %08x\n", device_xname(self), |
250 | (rev >> 4) & 0xf, rev & 0xf, | | 242 | (rev >> 4) & 0xf, rev & 0xf, |
251 | cardbus_conf_read(ct->ct_cc, ct->ct_cf, csc->sc_tag, 0x80))); | | 243 | cardbus_conf_read(ct->ct_cc, ct->ct_cf, csc->sc_tag, 0x80))); |
252 | | | 244 | |
253 | /* | | 245 | /* |
254 | * Map the device. | | 246 | * Map the device. |
255 | */ | | 247 | */ |
| @@ -291,28 +283,28 @@ rtw_cardbus_attach(device_t parent, devi | | | @@ -291,28 +283,28 @@ rtw_cardbus_attach(device_t parent, devi |
291 | */ | | 283 | */ |
292 | rtw_cardbus_setup(csc); | | 284 | rtw_cardbus_setup(csc); |
293 | | | 285 | |
294 | /* Remember which interrupt line. */ | | 286 | /* Remember which interrupt line. */ |
295 | csc->sc_intrline = ca->ca_intrline; | | 287 | csc->sc_intrline = ca->ca_intrline; |
296 | | | 288 | |
297 | /* | | 289 | /* |
298 | * Finish off the attach. | | 290 | * Finish off the attach. |
299 | */ | | 291 | */ |
300 | rtw_attach(sc); | | 292 | rtw_attach(sc); |
301 | | | 293 | |
302 | rtw_cardbus_funcregen(regs, 1); | | 294 | rtw_cardbus_funcregen(regs, 1); |
303 | | | 295 | |
304 | RTW_WRITE(regs, RTW_FEMR, RTW_FEMR_INTR); | | 296 | RTW_WRITE(regs, RTW_FEMR, 0); |
305 | RTW_WRITE(regs, RTW_FER, RTW_FER_INTR); | | 297 | RTW_WRITE(regs, RTW_FER, RTW_READ(regs, RTW_FER)); |
306 | | | 298 | |
307 | if (!pmf_device_register(self, rtw_cardbus_suspend, rtw_cardbus_resume)) | | 299 | if (!pmf_device_register(self, rtw_cardbus_suspend, rtw_cardbus_resume)) |
308 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 300 | aprint_error_dev(self, "couldn't establish power handler\n"); |
309 | else { | | 301 | else { |
310 | pmf_class_network_register(self, &sc->sc_if); | | 302 | pmf_class_network_register(self, &sc->sc_if); |
311 | /* | | 303 | /* |
312 | * Power down the socket. | | 304 | * Power down the socket. |
313 | */ | | 305 | */ |
314 | pmf_device_suspend_self(self); | | 306 | pmf_device_suspend_self(self); |
315 | } | | 307 | } |
316 | } | | 308 | } |
317 | | | 309 | |
318 | int | | 310 | int |