summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2006-07-02 01:04:59 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2006-07-02 01:04:59 +0000
commitec56596e6bf67bfa626970eda10269b573206055 (patch)
tree10f6aec4d000477646842bcdeb2dfdaef5feddbd /sys
parent75d7680db8e192dd5d8f459d17fc64f4a59ebd5a (diff)
Support for adapters with Airoha AL2230 radios from Florian.
This lets me see beacons on my device.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/if_zyd.c70
-rw-r--r--sys/dev/usb/if_zydreg.h94
2 files changed, 159 insertions, 5 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c
index 638d178c248..3f8b1341b9b 100644
--- a/sys/dev/usb/if_zyd.c
+++ b/sys/dev/usb/if_zyd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_zyd.c,v 1.14 2006/07/02 00:56:14 jsg Exp $ */
+/* $OpenBSD: if_zyd.c,v 1.15 2006/07/02 01:04:58 jsg Exp $ */
/*
* Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
@@ -221,6 +221,7 @@ void zyd_next_scan(void *);
void zyd_task(void *);
+/* Device, regardless of RF */
static const struct zyd_adpairs16 zyd_def_cr[] = {
ZYD_DEF_CR
};
@@ -229,6 +230,7 @@ static const struct zyd_adpairs32 zyd_def_mac[] = {
ZYD_DEF_MAC
};
+/* RF2959 */
static const struct zyd_adpairs16 zyd_rfmd_cr[] = {
ZYD_RFMD_CR
};
@@ -237,6 +239,16 @@ static const uint32_t zyd_rfmd_rf[] = {
ZYD_RFMD_RF
};
+/* AL2230 */
+static const struct zyd_adpairs16 zyd_al2230_cr[] = {
+ ZYD_AL2230_CR
+};
+
+static const uint32_t zyd_al2230_rf[] = {
+ ZYD_AL2230_RF
+};
+
+
/*
* Debug dump
*/
@@ -1809,7 +1821,20 @@ zyd_rf_rfmd_set_channel(struct zyd_softc *sc, struct zyd_rf *rf,
usbd_status
zyd_rf_al2230_switchradio(struct zyd_softc *sc, uint8_t onoff)
{
- return 0;
+ static const struct zyd_adpairs16 ir_on[] = {
+ ZYD_AL2230_RADIO_ON
+ };
+
+ static const struct zyd_adpairs16 ir_off[] = {
+ ZYD_AL2230_RADIO_OFF
+ };
+
+ if (onoff)
+ return zyd_batchwrite16(sc, ir_on,
+ (sizeof(ir_on) / sizeof(struct zyd_adpairs16)));
+
+ return zyd_batchwrite16(sc, ir_off, (sizeof(ir_off) /
+ sizeof(struct zyd_adpairs16)));
}
/*
@@ -1818,7 +1843,23 @@ zyd_rf_al2230_switchradio(struct zyd_softc *sc, uint8_t onoff)
usbd_status
zyd_rf_al2230_init(struct zyd_softc *sc, struct zyd_rf *rf)
{
- return 0;
+ int i;
+ usbd_status rv;
+
+ rv = zyd_batchwrite16(sc, zyd_al2230_cr, (sizeof(zyd_al2230_cr) /
+ sizeof(struct zyd_adpairs16)));
+
+ if (rv)
+ return rv;
+
+ for (i = 0; i < (sizeof(zyd_al2230_rf) / sizeof(uint32_t)); i++) {
+ rv = zyd_rfwrite(sc, zyd_al2230_rf[i], ZYD_RF_RV_BITS);
+
+ if (rv)
+ break;
+ }
+
+ return rv;
}
/*
@@ -1828,7 +1869,28 @@ usbd_status
zyd_rf_al2230_set_channel(struct zyd_softc *sc, struct zyd_rf *rf,
uint8_t channel)
{
- return 0;
+ static const struct zyd_adpairs16 sc_cmd[] = {
+ ZYD_AL2230_SETCHANNEL
+ };
+
+ static const uint32_t al2230_table[][3] = {
+ ZYD_AL2230_CHANTABLE
+ };
+
+ usbd_status rv;
+ int i;
+ const uint32_t *ptr = al2230_table[channel - 1];
+
+ for (i = 0; i < 3; i++) {
+ rv = zyd_rfwrite(sc, *ptr, ZYD_RF_RV_BITS);
+ ptr++;
+
+ if (rv)
+ return rv;
+ }
+
+ return zyd_batchwrite16(sc, sc_cmd, (sizeof(sc_cmd) /
+ sizeof(struct zyd_adpairs16)));
}
/*
diff --git a/sys/dev/usb/if_zydreg.h b/sys/dev/usb/if_zydreg.h
index c0d4f36ba9c..1a1f29daeab 100644
--- a/sys/dev/usb/if_zydreg.h
+++ b/sys/dev/usb/if_zydreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_zydreg.h,v 1.9 2006/07/01 04:47:48 jsg Exp $ */
+/* $OpenBSD: if_zydreg.h,v 1.10 2006/07/02 01:04:58 jsg Exp $ */
/*
* Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
@@ -764,6 +764,98 @@ enum zyd_ranges {
{ ZYD_CR10, 0x15 }, \
{ ZYD_CR11, 0x81 }
+#define ZYD_AL2230_CR \
+ { ZYD_CR15, 0x20 }, { ZYD_CR23, 0x40 }, { ZYD_CR24, 0x20 }, \
+ { ZYD_CR26, 0x11 }, { ZYD_CR28, 0x3e }, { ZYD_CR29, 0x00 }, \
+ { ZYD_CR44, 0x33 }, { ZYD_CR106, 0x2a }, { ZYD_CR107, 0x1a }, \
+ { ZYD_CR109, 0x09 }, { ZYD_CR110, 0x27 }, { ZYD_CR111, 0x2b }, \
+ { ZYD_CR112, 0x2b }, { ZYD_CR119, 0x0a }, { ZYD_CR10, 0x89 }, \
+ /* for newest (3rd cut) AL2300 */ \
+ { ZYD_CR17, 0x28 }, \
+ { ZYD_CR26, 0x93 }, { ZYD_CR34, 0x30 }, \
+ /* for newest (3rd cut) AL2300 */ \
+ { ZYD_CR35, 0x3e }, \
+ { ZYD_CR41, 0x24 }, { ZYD_CR44, 0x32 }, \
+ /* for newest (3rd cut) AL2300 */ \
+ { ZYD_CR46, 0x96 }, \
+ { ZYD_CR47, 0x1e }, { ZYD_CR79, 0x58 }, { ZYD_CR80, 0x30 }, \
+ { ZYD_CR81, 0x30 }, { ZYD_CR87, 0x0a }, { ZYD_CR89, 0x04 }, \
+ { ZYD_CR92, 0x0a }, { ZYD_CR99, 0x28 }, { ZYD_CR100, 0x00 }, \
+ { ZYD_CR101, 0x13 }, { ZYD_CR102, 0x27 }, { ZYD_CR106, 0x24 }, \
+ { ZYD_CR107, 0x2a }, { ZYD_CR109, 0x09 }, { ZYD_CR110, 0x13 }, \
+ { ZYD_CR111, 0x1f }, { ZYD_CR112, 0x1f }, { ZYD_CR113, 0x27 }, \
+ { ZYD_CR114, 0x27 }, \
+ /* for newest (3rd cut) AL2300 */ \
+ { ZYD_CR115, 0x24 }, \
+ { ZYD_CR116, 0x24 }, { ZYD_CR117, 0xf4 }, { ZYD_CR118, 0xfc }, \
+ { ZYD_CR119, 0x10 }, { ZYD_CR120, 0x4f }, { ZYD_CR121, 0x77 }, \
+ { ZYD_CR122, 0xe0 }, { ZYD_CR137, 0x88 }, { ZYD_CR252, 0xff }, \
+ { ZYD_CR253, 0xff }, \
+ /* These following happen separately in vendor drv */ \
+ { }, \
+ /* shdnb(PLL_ON)=0 */ \
+ { ZYD_CR251, 0x2f }, \
+ /* shdnb(PLL_ON)=1 */ \
+ { ZYD_CR251, 0x3f }, \
+ { ZYD_CR138, 0x28 }, { ZYD_CR203, 0x06 }
+
+#define ZYD_AL2230_RF \
+ /* Channel 1 */ \
+ 0x03f790, \
+ 0x033331, \
+ 0x00000d, \
+ \
+ 0x0b3331, \
+ 0x03b812, \
+ 0x00fff3, \
+ 0x000da4, \
+ 0x0f4dc5, /* fix freq shift, 0x04edc5 */ \
+ 0x0805b6, \
+ 0x011687, \
+ 0x000688, \
+ 0x0403b9, /* external control TX power (CR31) */ \
+ 0x00dbba, \
+ 0x00099b, \
+ 0x0bdffc, \
+ 0x00000d, \
+ 0x00500f, \
+ \
+ /* These writes happen separately in the vendor driver */ \
+ 0x00d00f, \
+ 0x004c0f, \
+ 0x00540f, \
+ 0x00700f, \
+ 0x00500f
+
+#define ZYD_AL2230_CHANTABLE \
+ { 0x03f790, 0x033331, 0x00000d }, \
+ { 0x03f790, 0x0b3331, 0x00000d }, \
+ { 0x03e790, 0x033331, 0x00000d }, \
+ { 0x03e790, 0x0b3331, 0x00000d }, \
+ { 0x03f7a0, 0x033331, 0x00000d }, \
+ { 0x03f7a0, 0x0b3331, 0x00000d }, \
+ { 0x03e7a0, 0x033331, 0x00000d }, \
+ { 0x03e7a0, 0x0b3331, 0x00000d }, \
+ { 0x03f7b0, 0x033331, 0x00000d }, \
+ { 0x03f7b0, 0x0b3331, 0x00000d }, \
+ { 0x03e7b0, 0x033331, 0x00000d }, \
+ { 0x03e7b0, 0x0b3331, 0x00000d }, \
+ { 0x03f7c0, 0x033331, 0x00000d }, \
+ { 0x03e7c0, 0x066661, 0x00000d }
+
+#define ZYD_AL2230_SETCHANNEL \
+ { ZYD_CR138, 0x28 }, \
+ { ZYD_CR203, 0x06 }
+
+#define ZYD_AL2230_RADIO_ON \
+ { ZYD_CR11, 0x00 }, \
+ { ZYD_CR251, 0x3f }
+
+#define ZYD_AL2230_RADIO_OFF \
+ { ZYD_CR11, 0x04 }, \
+ { ZYD_CR251, 0x2f }
+
+
/*
* Device configurations and types
*/