From owner-svn-src-head@FreeBSD.ORG Wed Jul 31 01:13:31 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6A989875; Wed, 31 Jul 2013 01:13:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 47B8022CD; Wed, 31 Jul 2013 01:13:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6V1DVOA044881; Wed, 31 Jul 2013 01:13:31 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6V1DUKY044876; Wed, 31 Jul 2013 01:13:30 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201307310113.r6V1DUKY044876@svn.freebsd.org> From: Justin Hibbits Date: Wed, 31 Jul 2013 01:13:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253825 - in head/sys: dev/wi modules modules/wi powerpc/powermac X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jul 2013 01:13:31 -0000 Author: jhibbits Date: Wed Jul 31 01:13:29 2013 New Revision: 253825 URL: http://svnweb.freebsd.org/changeset/base/253825 Log: Add the macio attachment for wi(4). Partially obtained from NetBSD. Reviewed by: adrian Obtained from: NetBSD (partially) Added: head/sys/dev/wi/if_wi_macio.c (contents, props changed) Modified: head/sys/modules/Makefile head/sys/modules/wi/Makefile head/sys/powerpc/powermac/macio.c head/sys/powerpc/powermac/maciovar.h Added: head/sys/dev/wi/if_wi_macio.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/wi/if_wi_macio.c Wed Jul 31 01:13:29 2013 (r253825) @@ -0,0 +1,141 @@ +/*- + * Copyright (c) 2013 Justin Hibbits + * All rights reserved. + * Copyright (c) 1997, 1998, 1999 + * Bill Paul . All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Bill Paul. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Lucent WaveLAN/IEEE 802.11 MacIO attachment for FreeBSD. + * + * Based on the PCMCIA driver + * Written by Bill Paul + * Electrical Engineering Department + * Columbia University, New York City + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +static int wi_macio_probe(device_t); +static int wi_macio_attach(device_t); + +static device_method_t wi_macio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, wi_macio_probe), + DEVMETHOD(device_attach, wi_macio_attach), + DEVMETHOD(device_detach, wi_detach), + DEVMETHOD(device_shutdown, wi_shutdown), + + { 0, 0 } +}; + +static driver_t wi_macio_driver = { + "wi", + wi_macio_methods, + sizeof(struct wi_softc) +}; + +DRIVER_MODULE(wi, macio, wi_macio_driver, wi_devclass, 0, 0); +MODULE_DEPEND(wi, wlan, 1, 1, 1); + +static int +wi_macio_probe(device_t dev) +{ + const char *name, *compat; + + /* Make sure we're a network driver */ + name = ofw_bus_get_name(dev); + if (name == NULL) + return (ENXIO); + + if (strcmp(name, "radio") != 0) { + return ENXIO; + } + compat = ofw_bus_get_compat(dev); + if (strcmp(compat, "wireless") != 0) { + return ENXIO; + } + + device_set_desc(dev, "Apple Airport"); + return 0; +} + +static int +wi_macio_attach(device_t dev) +{ + struct wi_softc *sc; + int error; + + sc = device_get_softc(dev); + sc->wi_gone = 0; + sc->wi_bus_type = 0; + + error = wi_alloc(dev, 0); + if (error == 0) { + /* Make sure interrupts are disabled. */ + CSR_WRITE_2(sc, WI_INT_EN, 0); + CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF); + + error = wi_attach(dev); + if (error != 0) + wi_free(dev); + } + return error; +} Modified: head/sys/modules/Makefile ============================================================================== --- head/sys/modules/Makefile Tue Jul 30 23:50:09 2013 (r253824) +++ head/sys/modules/Makefile Wed Jul 31 01:13:29 2013 (r253825) @@ -826,6 +826,7 @@ _sound= sound .if ${MK_CDDL} != "no" || defined(ALL_MODULES) _opensolaris= opensolaris .endif +_wi= wi .endif .if ${MACHINE_ARCH} == "powerpc64" Modified: head/sys/modules/wi/Makefile ============================================================================== --- head/sys/modules/wi/Makefile Tue Jul 30 23:50:09 2013 (r253824) +++ head/sys/modules/wi/Makefile Wed Jul 31 01:13:29 2013 (r253825) @@ -6,5 +6,15 @@ KMOD= if_wi SRCS= if_wi.c if_wi_pccard.c if_wi_pci.c \ card_if.h device_if.h bus_if.h pci_if.h pccarddevs.h \ opt_wlan.h +.if ${MACHINE_CPUARCH} == "powerpc" +SRCS+= if_wi_macio.c +SRCS+= ofw_bus_if.h +.endif + + +.if ${MACHINE_CPUARCH} == "powerpc" +SRCS+= if_wi_macio.c +SRCS+= ofw_bus_if.h +.endif .include Modified: head/sys/powerpc/powermac/macio.c ============================================================================== --- head/sys/powerpc/powermac/macio.c Tue Jul 30 23:50:09 2013 (r253824) +++ head/sys/powerpc/powermac/macio.c Wed Jul 31 01:13:29 2013 (r253825) @@ -605,3 +605,47 @@ macio_get_devinfo(device_t dev, device_t 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); +} Modified: head/sys/powerpc/powermac/maciovar.h ============================================================================== --- head/sys/powerpc/powermac/maciovar.h Tue Jul 30 23:50:09 2013 (r253824) +++ head/sys/powerpc/powermac/maciovar.h Wed Jul 31 01:13:29 2013 (r253825) @@ -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_ */