Subject: Testers for ral(4)
To: None <current-users@NetBSD.org>
From: Rui Paulo <rpaulo@fnop.net>
List: current-users
Date: 06/06/2006 14:12:37
Hi
The following patch completes the ral(4) updates I've been importing. I
need people to test cardbus cards and report any problems.
Also, don't forget to copy src/sys/dev/microcode/ral/ral-rt* to
/libdata/firmware/ral/.
Thanks.
Index: conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.777
diff -u -p -r1.777 files
--- conf/files 28 May 2006 08:57:53 -0000 1.777
+++ conf/files 6 Jun 2006 13:08:28 -0000
@@ -536,10 +536,10 @@ file dev/ic/rtw.c rtw
file dev/ic/rtwphy.c rtw
file dev/ic/rtwphyio.c rtw
-# Ralink RT2500 802.11
-device ral: arp, ether, ifnet, wlan
-define ralcommon
-file dev/ic/ral.c ralcommon
+# Ralink RT2500/RT2600 802.11
+device ral: arp, ether, ifnet, wlan, firmload
+file dev/ic/rt2560.c ral
+file dev/ic/rt2661.c ral
# 3Com Etherlink-III Ethernet controller
#
Index: dev/cardbus/files.cardbus
===================================================================
RCS file: /cvsroot/src/sys/dev/cardbus/files.cardbus,v
retrieving revision 1.32
diff -u -p -r1.32 files.cardbus
--- dev/cardbus/files.cardbus 11 Dec 2005 12:21:15 -0000 1.32
+++ dev/cardbus/files.cardbus 6 Jun 2006 13:08:28 -0000
@@ -47,9 +47,9 @@ attach rtw at cardbus with rtw_cardbus
file dev/cardbus/if_rtw_cardbus.c rtw_cardbus
#
-# Ralink RT2500
+# Ralink RT2500/RT2600
#
-attach ral at cardbus with ral_cardbus: ralcommon
+attach ral at cardbus with ral_cardbus
file dev/cardbus/if_ral_cardbus.c ral_cardbus
#
Index: dev/cardbus/if_ral_cardbus.c
===================================================================
RCS file: /cvsroot/src/sys/dev/cardbus/if_ral_cardbus.c,v
retrieving revision 1.4
diff -u -p -r1.4 if_ral_cardbus.c
--- dev/cardbus/if_ral_cardbus.c 29 Mar 2006 06:22:38 -0000 1.4
+++ dev/cardbus/if_ral_cardbus.c 6 Jun 2006 13:08:28 -0000
@@ -1,8 +1,8 @@
-/* $NetBSD: if_ral_cardbus.c,v 1.4 2006/03/29 06:22:38 thorpej Exp $ */
-/* $OpenBSD: if_ral_cardbus.c,v 1.5 2005/05/16 01:36:25 brad Exp $ */
+/* $NetBSD$ */
+/* $OpenBSD: if_ral_cardbus.c,v 1.6 2006/01/09 20:03:31 damien Exp $ */
/*-
- * Copyright (c) 2005
+ * Copyright (c) 2005, 2006
* Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -19,11 +19,10 @@
*/
/*
- * CardBus front-end for the Ralink RT2500 driver.
+ * CardBus front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
*/
-
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ral_cardbus.c,v 1.4 2006/03/29 06:22:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD$");
#include "bpfilter.h"
@@ -34,6 +33,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_cardb
#include <sys/socket.h>
#include <sys/systm.h>
#include <sys/malloc.h>
+#include <sys/callout.h>
#include <sys/device.h>
#include <machine/bus.h>
@@ -41,8 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_cardb
#include <net/if.h>
#include <net/if_dl.h>
-#include <net/if_ether.h>
#include <net/if_media.h>
+#include <net/if_ether.h>
#include <netinet/in.h>
@@ -50,7 +50,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_cardb
#include <net80211/ieee80211_rssadapt.h>
#include <net80211/ieee80211_radiotap.h>
-#include <dev/ic/ralvar.h>
+#include <dev/ic/rt2560var.h>
+#include <dev/ic/rt2661var.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
@@ -58,10 +59,31 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_cardb
#include <dev/cardbus/cardbusvar.h>
+static struct ral_opns {
+ int (*attach)(void *, int);
+ int (*detach)(void *);
+ int (*intr)(void *);
+
+} ral_rt2560_opns = {
+ rt2560_attach,
+ rt2560_detach,
+ rt2560_intr
+
+}, ral_rt2661_opns = {
+ rt2661_attach,
+ rt2661_detach,
+ rt2661_intr
+};
+
struct ral_cardbus_softc {
- struct ral_softc sc_sc;
+ union {
+ struct rt2560_softc sc_rt2560;
+ struct rt2661_softc sc_rt2661;
+ } u;
+#define sc_sc u.sc_rt2560
/* cardbus specific goo */
+ struct ral_opns *sc_opns;
cardbus_devfunc_t sc_ct;
cardbustag_t sc_tag;
void *sc_ih;
@@ -77,33 +99,45 @@ int ral_cardbus_detach(struct device *,
CFATTACH_DECL(ral_cardbus, sizeof (struct ral_cardbus_softc),
ral_cardbus_match, ral_cardbus_attach, ral_cardbus_detach, NULL);
-int ral_cardbus_enable(struct ral_softc *);
-void ral_cardbus_disable(struct ral_softc *);
-void ral_cardbus_power(struct ral_softc *, int);
+int ral_cardbus_enable(struct rt2560_softc *);
+void ral_cardbus_disable(struct rt2560_softc *);
+void ral_cardbus_power(struct rt2560_softc *, int);
void ral_cardbus_setup(struct ral_cardbus_softc *);
int
-ral_cardbus_match(struct device *parent, struct cfdata *match, void *aux)
+ral_cardbus_match(struct device *parent, struct cfdata *cfdata, void *aux)
{
- struct cardbus_attach_args *ca = aux;
+ struct cardbus_attach_args *ca = aux;
- if (CARDBUS_VENDOR(ca->ca_id) == PCI_VENDOR_RALINK &&
- CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_RALINK_RT2560)
- return 1;
+ if (PCI_VENDOR(ca->ca_id) == PCI_VENDOR_RALINK) {
+ switch (PCI_PRODUCT(ca->ca_id)) {
+ case PCI_PRODUCT_RALINK_RT2560:
+ case PCI_PRODUCT_RALINK_RT2561:
+ case PCI_PRODUCT_RALINK_RT2561S:
+ case PCI_PRODUCT_RALINK_RT2661:
+ return 1;
+ default:
+ return 0;
+ }
+ }
- return 0;
+ return 0;
}
void
ral_cardbus_attach(struct device *parent, struct device *self, void *aux)
{
- struct ral_cardbus_softc *csc = device_private(self);
- struct ral_softc *sc = &csc->sc_sc;
+ struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self;
+ struct rt2560_softc *sc = &csc->sc_sc;
struct cardbus_attach_args *ca = aux;
cardbus_devfunc_t ct = ca->ca_ct;
bus_addr_t base;
int error;
+ csc->sc_opns =
+ (CARDBUS_PRODUCT(ca->ca_id) == PCI_PRODUCT_RALINK_RT2560) ?
+ &ral_rt2560_opns : &ral_rt2661_opns;
+
sc->sc_dmat = ca->ca_dmat;
csc->sc_ct = ct;
csc->sc_tag = ca->ca_tag;
@@ -135,7 +169,7 @@ ral_cardbus_attach(struct device *parent
printf(": irq %d\n", csc->sc_intrline);
- ral_attach(sc);
+ (*csc->sc_opns->attach)(sc, CARDBUS_PRODUCT(ca->ca_id));
Cardbus_function_disable(ct);
}
@@ -143,14 +177,14 @@ ral_cardbus_attach(struct device *parent
int
ral_cardbus_detach(struct device *self, int flags)
{
- struct ral_cardbus_softc *csc = device_private(self);
- struct ral_softc *sc = &csc->sc_sc;
+ struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self;
+ struct rt2560_softc *sc = &csc->sc_sc;
cardbus_devfunc_t ct = csc->sc_ct;
cardbus_chipset_tag_t cc = ct->ct_cc;
cardbus_function_tag_t cf = ct->ct_cf;
int error;
- error = ral_detach(sc);
+ error = (*csc->sc_opns->detach)(sc);
if (error != 0)
return error;
@@ -168,7 +202,7 @@ ral_cardbus_detach(struct device *self,
}
int
-ral_cardbus_enable(struct ral_softc *sc)
+ral_cardbus_enable(struct rt2560_softc *sc)
{
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
cardbus_devfunc_t ct = csc->sc_ct;
@@ -183,7 +217,7 @@ ral_cardbus_enable(struct ral_softc *sc)
/* map and establish the interrupt handler */
csc->sc_ih = cardbus_intr_establish(cc, cf, csc->sc_intrline, IPL_NET,
- ral_intr, sc);
+ csc->sc_opns->intr, sc);
if (csc->sc_ih == NULL) {
printf("%s: could not establish interrupt at %d\n",
sc->sc_dev.dv_xname, csc->sc_intrline);
@@ -195,7 +229,7 @@ ral_cardbus_enable(struct ral_softc *sc)
}
void
-ral_cardbus_disable(struct ral_softc *sc)
+ral_cardbus_disable(struct rt2560_softc *sc)
{
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
cardbus_devfunc_t ct = csc->sc_ct;
@@ -211,7 +245,7 @@ ral_cardbus_disable(struct ral_softc *sc
}
void
-ral_cardbus_power(struct ral_softc *sc, int why)
+ral_cardbus_power(struct rt2560_softc *sc, int why)
{
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
Index: dev/pci/files.pci
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/files.pci,v
retrieving revision 1.255
diff -u -p -r1.255 files.pci
--- dev/pci/files.pci 28 May 2006 08:57:53 -0000 1.255
+++ dev/pci/files.pci 6 Jun 2006 13:08:29 -0000
@@ -692,8 +692,8 @@ file dev/pci/if_atw_pci.c atw_pci
attach rtw at pci with rtw_pci
file dev/pci/if_rtw_pci.c rtw_pci
-# Ralink RT2500 PCI/Mini-PCI
-attach ral at pci with ral_pci: ralcommon
+# Ralink RT2500/RT2600 PCI/Mini-PCI
+attach ral at pci with ral_pci
file dev/pci/if_ral_pci.c ral_pci
# Intersil Prism2.5 Mini-PCI
Index: dev/pci/if_ral_pci.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_ral_pci.c,v
retrieving revision 1.3
diff -u -p -r1.3 if_ral_pci.c
--- dev/pci/if_ral_pci.c 11 Dec 2005 12:22:49 -0000 1.3
+++ dev/pci/if_ral_pci.c 6 Jun 2006 13:08:29 -0000
@@ -1,8 +1,8 @@
-/* $NetBSD: if_ral_pci.c,v 1.3 2005/12/11 12:22:49 christos Exp $ */
-/* $OpenBSD: if_ral_pci.c,v 1.4 2005/02/22 10:41:30 damien Exp $ */
+/* $NetBSD$ */
+/* $OpenBSD: if_ral_pci.c,v 1.6 2006/01/09 20:03:43 damien Exp $ */
/*-
- * Copyright (c) 2005
+ * Copyright (c) 2005, 2006
* Damien Bergamini <damien.bergamini@free.fr>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -19,11 +19,10 @@
*/
/*
- * PCI front-end for the Ralink RT2500 driver.
+ * PCI front-end for the Ralink RT2560/RT2561/RT2561S/RT2661 driver.
*/
-
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c,v 1.3 2005/12/11 12:22:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD$");
#include "bpfilter.h"
@@ -41,8 +40,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c
#include <net/if.h>
#include <net/if_dl.h>
-#include <net/if_ether.h>
#include <net/if_media.h>
+#include <net/if_ether.h>
#include <netinet/in.h>
@@ -50,16 +49,38 @@ __KERNEL_RCSID(0, "$NetBSD: if_ral_pci.c
#include <net80211/ieee80211_rssadapt.h>
#include <net80211/ieee80211_radiotap.h>
-#include <dev/ic/ralvar.h>
+#include <dev/ic/rt2560var.h>
+#include <dev/ic/rt2661var.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
+static struct ral_opns {
+ int (*attach)(void *, int);
+ int (*detach)(void *);
+ int (*intr)(void *);
+
+} ral_rt2560_opns = {
+ rt2560_attach,
+ rt2560_detach,
+ rt2560_intr
+
+}, ral_rt2661_opns = {
+ rt2661_attach,
+ rt2661_detach,
+ rt2661_intr
+};
+
struct ral_pci_softc {
- struct ral_softc sc_sc;
+ union {
+ struct rt2560_softc sc_rt2560;
+ struct rt2661_softc sc_rt2661;
+ } u;
+#define sc_sc u.sc_rt2560
/* PCI specific goo */
+ struct ral_opns *sc_opns;
pci_chipset_tag_t sc_pc;
void *sc_ih;
bus_size_t sc_mapsize;
@@ -76,13 +97,21 @@ CFATTACH_DECL(ral_pci, sizeof (struct ra
ral_pci_match, ral_pci_attach, ral_pci_detach, NULL);
int
-ral_pci_match(struct device *parent, struct cfdata *match, void *aux)
+ral_pci_match(struct device *parent, struct cfdata *cfdata, void *aux)
{
struct pci_attach_args *pa = aux;
- if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RALINK &&
- PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RALINK_RT2560)
- return 1;
+ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_RALINK) {
+ switch (PCI_PRODUCT(pa->pa_id)) {
+ case PCI_PRODUCT_RALINK_RT2560:
+ case PCI_PRODUCT_RALINK_RT2561:
+ case PCI_PRODUCT_RALINK_RT2561S:
+ case PCI_PRODUCT_RALINK_RT2661:
+ return 1;
+ default:
+ return 0;
+ }
+ }
return 0;
}
@@ -91,14 +120,22 @@ void
ral_pci_attach(struct device *parent, struct device *self, void *aux)
{
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
- struct ral_softc *sc = &psc->sc_sc;
+ struct rt2560_softc *sc = &psc->sc_sc;
struct pci_attach_args *pa = aux;
const char *intrstr;
+ char devinfo[256];
bus_addr_t base;
pci_intr_handle_t ih;
pcireg_t reg;
- int error;
-
+ int error, revision;
+
+ pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
+ revision = PCI_REVISION(pa->pa_class);
+ aprint_normal(": %s (rev. 0x%02x)\n", devinfo, revision);
+
+ psc->sc_opns = (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_RALINK_RT2560) ?
+ &ral_rt2560_opns : &ral_rt2661_opns;
+
sc->sc_dmat = pa->pa_dmat;
psc->sc_pc = pa->pa_pc;
@@ -111,38 +148,42 @@ ral_pci_attach(struct device *parent, st
error = pci_mapreg_map(pa, RAL_PCI_BAR0, PCI_MAPREG_TYPE_MEM |
PCI_MAPREG_MEM_TYPE_32BIT, 0, &sc->sc_st, &sc->sc_sh, &base,
&psc->sc_mapsize);
+
if (error != 0) {
- printf(": could not map memory space\n");
+ aprint_error(": could not map memory space\n");
return;
}
if (pci_intr_map(pa, &ih) != 0) {
- printf(": could not map interrupt\n");
+ aprint_error(": could not map interrupt\n");
return;
}
intrstr = pci_intr_string(psc->sc_pc, ih);
- psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET, ral_intr, sc);
+ psc->sc_ih = pci_intr_establish(psc->sc_pc, ih, IPL_NET,
+ psc->sc_opns->intr, sc);
+
if (psc->sc_ih == NULL) {
- printf(": could not establish interrupt");
+ aprint_error(": could not establish interrupt");
if (intrstr != NULL)
printf(" at %s", intrstr);
- printf("\n");
+ aprint_error("\n");
return;
}
- printf(": %s\n", intrstr);
+ aprint_normal("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
- ral_attach(sc);
+ (*psc->sc_opns->attach)(sc, PCI_PRODUCT(pa->pa_id));
}
int
ral_pci_detach(struct device *self, int flags)
{
struct ral_pci_softc *psc = (struct ral_pci_softc *)self;
- struct ral_softc *sc = &psc->sc_sc;
+ struct rt2560_softc *sc = &psc->sc_sc;
- ral_detach(sc);
+ (*psc->sc_opns->detach)(sc);
pci_intr_disestablish(psc->sc_pc, psc->sc_ih);
return 0;
}
+
Index: dev/pci/pcidevs
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcidevs,v
retrieving revision 1.790
diff -u -p -r1.790 pcidevs
--- dev/pci/pcidevs 5 Jun 2006 21:08:18 -0000 1.790
+++ dev/pci/pcidevs 6 Jun 2006 13:08:30 -0000
@@ -2713,8 +2713,11 @@ product QUICKLOGIC PCWATCHDOG 0x5030 PC
product RAINBOW CS200 0x0200 CryptoSwift 200 PKI Accelerator
/* Ralink Technologies products */
-product RALINK RT2460 0x0101 RT2460 802.11b
-product RALINK RT2560 0x0201 RT2560 802.11b/g
+product RALINK RT2460A 0x0101 RT2460A 802.11b
+product RALINK RT2560 0x0201 RT2560 802.11b/g
+product RALINK RT2561S 0x0301 RT2561S 802.11b/g
+product RALINK RT2561 0x0302 RT2561 802.11b/g
+product RALINK RT2661 0x0401 RT2661 802.11b/g/n
/* RATOC Systems products */
product RATOC REXPCI31 0x0853 REX PCI-31/33 SCSI
Index: dev/pci/pcidevs.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcidevs.h,v
retrieving revision 1.791
diff -u -p -r1.791 pcidevs.h
--- dev/pci/pcidevs.h 5 Jun 2006 21:08:51 -0000 1.791
+++ dev/pci/pcidevs.h 6 Jun 2006 13:08:32 -0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcidevs.h,v 1.791 2006/06/05 21:08:51 martin Exp $ */
+/* $NetBSD$ */
/*
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
@@ -2720,8 +2720,11 @@
#define PCI_PRODUCT_RAINBOW_CS200 0x0200 /* CryptoSwift 200 PKI Accelerator */
/* Ralink Technologies products */
-#define PCI_PRODUCT_RALINK_RT2460 0x0101 /* RT2460 802.11b */
+#define PCI_PRODUCT_RALINK_RT2460A 0x0101 /* RT2460A 802.11b */
#define PCI_PRODUCT_RALINK_RT2560 0x0201 /* RT2560 802.11b/g */
+#define PCI_PRODUCT_RALINK_RT2561S 0x0301 /* RT2561S 802.11b/g */
+#define PCI_PRODUCT_RALINK_RT2561 0x0302 /* RT2561 802.11b/g */
+#define PCI_PRODUCT_RALINK_RT2661 0x0401 /* RT2661 802.11b/g/n */
/* RATOC Systems products */
#define PCI_PRODUCT_RATOC_REXPCI31 0x0853 /* REX PCI-31/33 SCSI */
Index: dev/pci/pcidevs_data.h
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/pcidevs_data.h,v
retrieving revision 1.790
diff -u -p -r1.790 pcidevs_data.h
--- dev/pci/pcidevs_data.h 5 Jun 2006 21:08:51 -0000 1.790
+++ dev/pci/pcidevs_data.h 6 Jun 2006 13:08:33 -0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcidevs_data.h,v 1.790 2006/06/05 21:08:51 martin Exp $ */
+/* $NetBSD$ */
/*
* THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
@@ -9228,14 +9228,26 @@ static const struct pci_product pci_prod
"CryptoSwift 200 PKI Accelerator",
},
{
- PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2460,
- "RT2460 802.11b",
+ PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2460A,
+ "RT2460A 802.11b",
},
{
PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2560,
"RT2560 802.11b/g",
},
{
+ PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2561S,
+ "RT2561S 802.11b/g",
+ },
+ {
+ PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2561,
+ "RT2561 802.11b/g",
+ },
+ {
+ PCI_VENDOR_RALINK, PCI_PRODUCT_RALINK_RT2661,
+ "RT2661 802.11b/g/n",
+ },
+ {
PCI_VENDOR_RATOC, PCI_PRODUCT_RATOC_REXPCI31,
"REX PCI-31/33 SCSI",
},
@@ -11500,4 +11512,4 @@ static const struct pci_product pci_prod
"Video Controller",
},
};
-const int pci_nproducts = 2284;
+const int pci_nproducts = 2287;