diff options
author | jhibbits <jhibbits@FreeBSD.org> | 2013-07-31 01:13:29 +0000 |
---|---|---|
committer | jhibbits <jhibbits@FreeBSD.org> | 2013-07-31 01:13:29 +0000 |
commit | d40ca75d25d9597ff60073d78c1c5293d4c7be3a (patch) | |
tree | a9150636d74152d14f07175901c6221a35acc479 /sys/powerpc/powermac | |
parent | b9c4e3dc5895ffc3ca5d1d9a64953bc84d5a2f2b (diff) | |
download | FreeBSD-src-d40ca75d25d9597ff60073d78c1c5293d4c7be3a.zip FreeBSD-src-d40ca75d25d9597ff60073d78c1c5293d4c7be3a.tar.gz |
Add the macio attachment for wi(4). Partially obtained from NetBSD.
Reviewed by: adrian
Obtained from: NetBSD (partially)
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r-- | sys/powerpc/powermac/macio.c | 44 | ||||
-rw-r--r-- | sys/powerpc/powermac/maciovar.h | 7 |
2 files changed, 51 insertions, 0 deletions
diff --git a/sys/powerpc/powermac/macio.c b/sys/powerpc/powermac/macio.c index eae6386..b31cf15 100644 --- a/sys/powerpc/powermac/macio.c +++ b/sys/powerpc/powermac/macio.c @@ -605,3 +605,47 @@ macio_get_devinfo(device_t dev, device_t child) dinfo = device_get_ivars(child); return (&dinfo->mdi_obdinfo); } + +int +macio_enable_wireless(device_t dev, bool enable) +{ + struct macio_softc *sc = device_get_softc(dev); + uint32_t x; + + if (enable) { + x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); + x |= 0x4; + bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); + + /* Enable card slot. */ + bus_write_1(sc->sc_memr, KEYLARGO_GPIO_BASE + 0x0f, 5); + DELAY(1000); + bus_write_1(sc->sc_memr, KEYLARGO_GPIO_BASE + 0x0f, 4); + DELAY(1000); + x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); + x &= ~0x80000000; + + bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); + /* out8(gpio + 0x10, 4); */ + + bus_write_1(sc->sc_memr, KEYLARGO_EXTINT_GPIO_REG_BASE + 0x0b, 0); + bus_write_1(sc->sc_memr, KEYLARGO_EXTINT_GPIO_REG_BASE + 0x0a, 0x28); + bus_write_1(sc->sc_memr, KEYLARGO_EXTINT_GPIO_REG_BASE + 0x0d, 0x28); + bus_write_1(sc->sc_memr, KEYLARGO_GPIO_BASE + 0x0d, 0x28); + bus_write_1(sc->sc_memr, KEYLARGO_GPIO_BASE + 0x0e, 0x28); + bus_write_4(sc->sc_memr, 0x1c000, 0); + + /* Initialize the card. */ + bus_write_4(sc->sc_memr, 0x1a3e0, 0x41); + x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); + x |= 0x80000000; + bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); + } else { + x = bus_read_4(sc->sc_memr, KEYLARGO_FCR2); + x &= ~0x4; + bus_write_4(sc->sc_memr, KEYLARGO_FCR2, x); + /* out8(gpio + 0x10, 0); */ + } + + return (0); +} diff --git a/sys/powerpc/powermac/maciovar.h b/sys/powerpc/powermac/maciovar.h index ea0a029..61fac46 100644 --- a/sys/powerpc/powermac/maciovar.h +++ b/sys/powerpc/powermac/maciovar.h @@ -43,10 +43,15 @@ #define HEATHROW_FCR 0x38 #define KEYLARGO_FCR0 0x38 #define KEYLARGO_FCR1 0x3c +#define KEYLARGO_FCR2 0x40 #define FCR_ENET_ENABLE 0x60000000 #define FCR_ENET_RESET 0x80000000 +/* Used only by macio_enable_wireless() for now. */ +#define KEYLARGO_GPIO_BASE 0x6a +#define KEYLARGO_EXTINT_GPIO_REG_BASE 0x58 + /* * Format of a macio reg property entry. */ @@ -66,4 +71,6 @@ struct macio_devinfo { struct resource_list mdi_resources; }; +extern int macio_enable_wireless(device_t dev, bool enable); + #endif /* _MACIO_MACIOVAR_H_ */ |