diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/rtw.c | 65 | ||||
-rw-r--r-- | sys/dev/ic/rtwreg.h | 17 | ||||
-rw-r--r-- | sys/dev/ic/rtwvar.h | 12 |
3 files changed, 83 insertions, 11 deletions
diff --git a/sys/dev/ic/rtw.c b/sys/dev/ic/rtw.c index b7c88edd8e4..94986a68e65 100644 --- a/sys/dev/ic/rtw.c +++ b/sys/dev/ic/rtw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtw.c,v 1.41 2005/10/23 08:23:00 reyk Exp $ */ +/* $OpenBSD: rtw.c,v 1.42 2005/10/23 08:47:14 reyk Exp $ */ /* $NetBSD: rtw.c,v 1.29 2004/12/27 19:49:16 dyoung Exp $ */ /*- @@ -243,6 +243,14 @@ void rtw_rf_rtl8225_hostbangbits(struct rtw_regs *, u_int32_t, int, u_int); int rtw_rf_macbangbits(struct rtw_regs *, u_int32_t); const char *rtw_rfchipid_string(int); +u_int8_t rtw_read8(struct rtw_regs *, u_int32_t); +u_int16_t rtw_read16(struct rtw_regs *, u_int32_t); +u_int32_t rtw_read32(struct rtw_regs *, u_int32_t); +void rtw_write8(struct rtw_regs *, u_int32_t, u_int8_t); +void rtw_write16(struct rtw_regs *, u_int32_t, u_int16_t); +void rtw_write32(struct rtw_regs *, u_int32_t, u_int32_t); +void rtw_barrier(struct rtw_regs *, u_int32_t, u_int32_t, int); + #ifdef RTW_DEBUG void rtw_print_txdesc(struct rtw_softc *, const char *, struct rtw_txsoft *, struct rtw_txdesc_blk *, int); @@ -3557,6 +3565,17 @@ rtw_attach(struct rtw_softc *sc) NEXT_ATTACH_STATE(sc, DETACHED); + /* Use default DMA memory access */ + if (sc->sc_regs.r_read8 == NULL) { + sc->sc_regs.r_read8 = rtw_read8; + sc->sc_regs.r_read16 = rtw_read16; + sc->sc_regs.r_read32 = rtw_read32; + sc->sc_regs.r_write8 = rtw_write8; + sc->sc_regs.r_write16 = rtw_write16; + sc->sc_regs.r_write32 = rtw_write32; + sc->sc_regs.r_barrier = rtw_barrier; + } + sc->sc_hwverid = RTW_READ(&sc->sc_regs, RTW_TCR) & RTW_TCR_HWVERID_MASK; switch (sc->sc_hwverid) { case RTW_TCR_HWVERID_RTL8185: @@ -4782,3 +4801,47 @@ rtw_rf_macwrite(struct rtw_softc *sc, u_int addr, u_int32_t val) return rtw_rf_macbangbits(&sc->sc_regs, reg); } + + +u_int8_t +rtw_read8(struct rtw_regs *regs, u_int32_t off) +{ + return (bus_space_read_1(regs->r_bt, regs->r_bh, off)); +} + +u_int16_t +rtw_read16(struct rtw_regs *regs, u_int32_t off) +{ + return (bus_space_read_2(regs->r_bt, regs->r_bh, off)); +} + +u_int32_t +rtw_read32(struct rtw_regs *regs, u_int32_t off) +{ + return (bus_space_read_4(regs->r_bt, regs->r_bh, off)); +} + +void +rtw_write8(struct rtw_regs *regs, u_int32_t off, u_int8_t val) +{ + bus_space_write_1(regs->r_bt, regs->r_bh, off, val); +} + +void +rtw_write16(struct rtw_regs *regs, u_int32_t off, u_int16_t val) +{ + bus_space_write_2(regs->r_bt, regs->r_bh, off, val); +} + +void +rtw_write32(struct rtw_regs *regs, u_int32_t off, u_int32_t val) +{ + bus_space_write_4(regs->r_bt, regs->r_bh, off, val); +} + +void +rtw_barrier(struct rtw_regs *regs, u_int32_t reg0, u_int32_t reg1, int flags) +{ + bus_space_barrier(regs->r_bh, regs->r_bt, MIN(reg0, reg1), + MAX(reg0, reg1) - MIN(reg0, reg1) + 4, flags); +} diff --git a/sys/dev/ic/rtwreg.h b/sys/dev/ic/rtwreg.h index 444aca80bfd..65ad2ba47ba 100644 --- a/sys/dev/ic/rtwreg.h +++ b/sys/dev/ic/rtwreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtwreg.h,v 1.8 2005/10/23 08:14:37 jsg Exp $ */ +/* $OpenBSD: rtwreg.h,v 1.9 2005/10/23 08:47:14 reyk Exp $ */ /* $NetBSD: rtwreg.h,v 1.12 2005/01/16 11:50:43 dyoung Exp $ */ /*- * Copyright (c) 2004, 2005 David Young. All rights reserved. @@ -1118,22 +1118,22 @@ struct rtw_rxdesc { #define RTW_RXRSSI_SQ BITS(7,0) /* Barker code-lock quality */ #define RTW_READ8(regs, ofs) \ - bus_space_read_1((regs)->r_bt, (regs)->r_bh, (ofs)) + ((*(regs)->r_read8)(regs, ofs)) #define RTW_READ16(regs, ofs) \ - bus_space_read_2((regs)->r_bt, (regs)->r_bh, (ofs)) + ((*(regs)->r_read16)(regs, ofs)) #define RTW_READ(regs, ofs) \ - bus_space_read_4((regs)->r_bt, (regs)->r_bh, (ofs)) + ((*(regs)->r_read32)(regs, ofs)) #define RTW_WRITE8(regs, ofs, val) \ - bus_space_write_1((regs)->r_bt, (regs)->r_bh, (ofs), (val)) + ((*(regs)->r_write8)(regs, ofs, val)) #define RTW_WRITE16(regs, ofs, val) \ - bus_space_write_2((regs)->r_bt, (regs)->r_bh, (ofs), (val)) + ((*(regs)->r_write16)(regs, ofs, val)) #define RTW_WRITE(regs, ofs, val) \ - bus_space_write_4((regs)->r_bt, (regs)->r_bh, (ofs), (val)) + ((*(regs)->r_write32)(regs, ofs, val)) #define RTW_ISSET(regs, reg, mask) \ (RTW_READ((regs), (reg)) & (mask)) @@ -1170,8 +1170,7 @@ struct rtw_rxdesc { * acceptable bus_space_barrier(9) for the flag definitions. */ #define RTW_BARRIER(regs, reg0, reg1, flags) \ - bus_space_barrier((regs)->r_bh, (regs)->r_bt, \ - MIN(reg0, reg1), MAX(reg0, reg1) - MIN(reg0, reg1) + 4, flags) + ((*(regs)->r_barrier)(regs, reg0, reg1, flags)) /* * Barrier convenience macros. diff --git a/sys/dev/ic/rtwvar.h b/sys/dev/ic/rtwvar.h index f37206f4816..717b70c63f3 100644 --- a/sys/dev/ic/rtwvar.h +++ b/sys/dev/ic/rtwvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtwvar.h,v 1.15 2005/09/15 00:33:48 jsg Exp $ */ +/* $OpenBSD: rtwvar.h,v 1.16 2005/10/23 08:47:14 reyk Exp $ */ /* $NetBSD: rtwvar.h,v 1.10 2004/12/26 22:37:57 mycroft Exp $ */ /*- @@ -129,6 +129,16 @@ struct rtw_regs { bus_space_tag_t r_bt; bus_space_handle_t r_bh; enum rtw_access r_access; + void *r_priv; + + /* bus independent I/O callbacks */ + u_int8_t (*r_read8)(struct rtw_regs *, u_int32_t); + u_int16_t (*r_read16)(struct rtw_regs *, u_int32_t); + u_int32_t (*r_read32)(struct rtw_regs *, u_int32_t); + void (*r_write8)(struct rtw_regs *, u_int32_t, u_int8_t); + void (*r_write16)(struct rtw_regs *, u_int32_t, u_int16_t); + void (*r_write32)(struct rtw_regs *, u_int32_t, u_int32_t); + void (*r_barrier)(struct rtw_regs *, u_int32_t, u_int32_t, int); }; #define RTW_SR_GET(sr, ofs) \ |