summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2016-03-21 12:00:33 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2016-03-21 12:00:33 +0000
commitb035e3d07c38fac27521c14f1565c4dc21ba3de4 (patch)
treed2dda57e20b00b84d3af2f0ff2bd32145ed12247 /sys/dev
parentf7d1892d42fcd9b4f7148fb10f4c4002b9157394 (diff)
The common part of rtwn(4) needs help from attachment drivers to determine
the chip type. Require chip type as a parameter to rtwn_attach(). ok mpi@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/rtwn.c45
-rw-r--r--sys/dev/ic/rtwnvar.h11
-rw-r--r--sys/dev/pci/if_rtwn.c4
3 files changed, 34 insertions, 26 deletions
diff --git a/sys/dev/ic/rtwn.c b/sys/dev/ic/rtwn.c
index f1c51414c6b..742f7fe68b9 100644
--- a/sys/dev/ic/rtwn.c
+++ b/sys/dev/ic/rtwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwn.c,v 1.5 2016/03/15 10:28:31 stsp Exp $ */
+/* $OpenBSD: rtwn.c,v 1.6 2016/03/21 12:00:32 stsp Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -84,7 +84,7 @@ uint32_t rtwn_rf_read(struct rtwn_softc *, int, uint8_t);
void rtwn_cam_write(struct rtwn_softc *, uint32_t, uint32_t);
uint8_t rtwn_efuse_read_1(struct rtwn_softc *, uint16_t);
void rtwn_efuse_read(struct rtwn_softc *);
-int rtwn_read_chipid(struct rtwn_softc *);
+int rtwn_read_chipid(struct rtwn_softc *, uint32_t);
void rtwn_read_rom(struct rtwn_softc *);
int rtwn_media_change(struct ifnet *);
int rtwn_ra_init(struct rtwn_softc *);
@@ -140,7 +140,7 @@ void rtwn_stop(struct ifnet *);
#define rtwn_bb_read rtwn_read_4
int
-rtwn_attach(struct device *pdev, struct rtwn_softc *sc)
+rtwn_attach(struct device *pdev, struct rtwn_softc *sc, uint32_t chip_type)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ifnet *ifp = &ic->ic_if;
@@ -150,17 +150,21 @@ rtwn_attach(struct device *pdev, struct rtwn_softc *sc)
task_set(&sc->init_task, rtwn_init_task, sc);
- error = rtwn_read_chipid(sc);
+ error = rtwn_read_chipid(sc, chip_type);
if (error != 0) {
printf("%s: unsupported test chip\n", sc->sc_pdev->dv_xname);
return (ENXIO);
}
+ if (sc->chip == 0) {
+ printf("%s: could not read chip ID\n", sc->sc_pdev->dv_xname);
+ return (ENXIO);
+ }
/* Determine number of Tx/Rx chains. */
if (sc->chip & RTWN_CHIP_92C) {
sc->ntxchains = (sc->chip & RTWN_CHIP_92C_1T2R) ? 1 : 2;
sc->nrxchains = 2;
- } else {
+ } else if (sc->chip & RTWN_CHIP_88C) {
sc->ntxchains = 1;
sc->nrxchains = 1;
}
@@ -475,9 +479,8 @@ rtwn_efuse_read(struct rtwn_softc *sc)
#endif
}
-/* rtwn_read_chipid: reg=0x40073b chipid=0x0 */
int
-rtwn_read_chipid(struct rtwn_softc *sc)
+rtwn_read_chipid(struct rtwn_softc *sc, uint32_t chip_type)
{
uint32_t reg;
@@ -486,18 +489,22 @@ rtwn_read_chipid(struct rtwn_softc *sc)
/* Unsupported test chip. */
return (EIO);
- if (reg & R92C_SYS_CFG_TYPE_92C) {
- sc->chip |= RTWN_CHIP_92C;
- /* Check if it is a castrated 8192C. */
- if (MS(rtwn_read_4(sc, R92C_HPON_FSM),
- R92C_HPON_FSM_CHIP_BONDING_ID) ==
- R92C_HPON_FSM_CHIP_BONDING_ID_92C_1T2R)
- sc->chip |= RTWN_CHIP_92C_1T2R;
- }
- if (reg & R92C_SYS_CFG_VENDOR_UMC) {
- sc->chip |= RTWN_CHIP_UMC;
- if (MS(reg, R92C_SYS_CFG_CHIP_VER_RTL) == 0)
- sc->chip |= RTWN_CHIP_UMC_A_CUT;
+ if ((chip_type & (RTWN_CHIP_92C | RTWN_CHIP_88C)) != 0) {
+ if (reg & R92C_SYS_CFG_TYPE_92C) {
+ sc->chip = RTWN_CHIP_92C;
+ /* Check if it is a castrated 8192C. */
+ if (MS(rtwn_read_4(sc, R92C_HPON_FSM),
+ R92C_HPON_FSM_CHIP_BONDING_ID) ==
+ R92C_HPON_FSM_CHIP_BONDING_ID_92C_1T2R)
+ sc->chip |= RTWN_CHIP_92C_1T2R;
+ } else
+ sc->chip = RTWN_CHIP_88C;
+
+ if (reg & R92C_SYS_CFG_VENDOR_UMC) {
+ sc->chip |= RTWN_CHIP_UMC;
+ if (MS(reg, R92C_SYS_CFG_CHIP_VER_RTL) == 0)
+ sc->chip |= RTWN_CHIP_UMC_A_CUT;
+ }
}
return (0);
}
diff --git a/sys/dev/ic/rtwnvar.h b/sys/dev/ic/rtwnvar.h
index fedfa8cca0b..8d47c37431b 100644
--- a/sys/dev/ic/rtwnvar.h
+++ b/sys/dev/ic/rtwnvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtwnvar.h,v 1.4 2016/03/15 10:28:31 stsp Exp $ */
+/* $OpenBSD: rtwnvar.h,v 1.5 2016/03/21 12:00:32 stsp Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -49,16 +49,17 @@ struct rtwn_softc {
enum ieee80211_state, int);
struct task init_task;
int ac2idx[EDCA_NUM_AC];
- u_int sc_flags;
+ uint32_t sc_flags;
#define RTWN_FLAG_CCK_HIPWR 0x01
#define RTWN_FLAG_BUSY 0x02
- u_int chip;
-#define RTWN_CHIP_88C 0x00
+ uint32_t chip;
#define RTWN_CHIP_92C 0x01
#define RTWN_CHIP_92C_1T2R 0x02
#define RTWN_CHIP_UMC 0x04
#define RTWN_CHIP_UMC_A_CUT 0x08
+#define RTWN_CHIP_88C 0x10
+#define RTWN_CHIP_88E 0x20
uint8_t board_type;
uint8_t regulatory;
@@ -77,7 +78,7 @@ struct rtwn_softc {
uint32_t rf_chnlbw[R92C_MAX_CHAINS];
};
-int rtwn_attach(struct device *, struct rtwn_softc *);
+int rtwn_attach(struct device *, struct rtwn_softc *, uint32_t);
int rtwn_detach(struct rtwn_softc *, int);
int rtwn_activate(struct rtwn_softc *, int);
int8_t rtwn_get_rssi(struct rtwn_softc *, int, void *);
diff --git a/sys/dev/pci/if_rtwn.c b/sys/dev/pci/if_rtwn.c
index 0981006d4a8..daf71ed99dd 100644
--- a/sys/dev/pci/if_rtwn.c
+++ b/sys/dev/pci/if_rtwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_rtwn.c,v 1.19 2016/03/15 10:28:32 stsp Exp $ */
+/* $OpenBSD: if_rtwn.c,v 1.20 2016/03/21 12:00:32 stsp Exp $ */
/*-
* Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -351,7 +351,7 @@ rtwn_pci_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sc.sc_ops.next_scan = rtwn_pci_next_scan;
sc->sc_sc.sc_ops.cancel_scan = rtwn_cancel_scan;
- error = rtwn_attach(&sc->sc_dev, &sc->sc_sc);
+ error = rtwn_attach(&sc->sc_dev, &sc->sc_sc, RTWN_CHIP_88C);
if (error != 0) {
rtwn_free_rx_list(sc);
for (i = 0; i < RTWN_NTXQUEUES; i++)