From owner-freebsd-wireless@FreeBSD.ORG Sun Sep 25 12:54:48 2011 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 40C95106564A; Sun, 25 Sep 2011 12:54:48 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id DB0A98FC08; Sun, 25 Sep 2011 12:54:47 +0000 (UTC) Received: by gxk26 with SMTP id 26so3665978gxk.13 for ; Sun, 25 Sep 2011 05:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:from:to:content-type:mime-version:subject:date:cc :x-mailer; bh=c0+7TD7mBtUy0soq0fv6XlZD9SdaxRbTTZA0Dd5W51w=; b=nhTgIzG247dNBWrN3Z66mFBMNVZ072FLTgbyy04DSLhMde1VKtOkcqZ5dUF59jt1lG CsiEiy7qL0WDFL2WEdruqnqQTI+sgkr5KSxYHKedbXegvjeUFR4tIdn+uu96itvbIsEK U+lAWyoxNlj2qJlxHTdN80WB1xl2tbArVVJ4s= Received: by 10.150.2.20 with SMTP id 20mr3604535ybb.31.1316955287042; Sun, 25 Sep 2011 05:54:47 -0700 (PDT) Received: from triad.knownspace (216-15-41-8.c3-0.gth-ubr1.lnh-gth.md.cable.rcn.com. [216.15.41.8]) by mx.google.com with ESMTPS id o4sm4009197ybc.15.2011.09.25.05.54.45 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Sep 2011 05:54:45 -0700 (PDT) Message-Id: <54FFB452-534A-46C6-950B-880EB36F61C1@gmail.com> From: Justin Hibbits To: FreeBSD PowerPC ML Content-Type: multipart/mixed; boundary=Apple-Mail-15--654334916 Mime-Version: 1.0 (Apple Message framework v936) Date: Sun, 25 Sep 2011 08:54:41 -0400 X-Mailer: Apple Mail (2.936) Cc: freebsd-wireless@freebsd.org Subject: CFT: macio attachment for if_wi X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Sep 2011 12:54:48 -0000 --Apple-Mail-15--654334916 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Attached is a patch adding the macio attachment for the if_wi driver, to support the airport card in PowerPC macs. To do this I needed to modify the wi_read_bap and wi_write_bap functions to use the bus space stream functions instead of regular functions, like NetBSD and OpenBSD do. I currently get a 'no carrier' status from ifconfig, so I can't fully test connections, only the attachment. Testing wanted and needed to make sure I didn't break anything. - Justin --Apple-Mail-15--654334916 Content-Disposition: attachment; filename=airport_attach.diff Content-Type: application/octet-stream; x-unix-mode=0644; name="airport_attach.diff" Content-Transfer-Encoding: 7bit Index: modules/wi/Makefile =================================================================== --- modules/wi/Makefile (revision 225715) +++ modules/wi/Makefile (working copy) @@ -6,4 +6,9 @@ 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 +.if ${MACHINE_CPUARCH} == "powerpc" +SRCS+= if_wi_macio.c +SRCS+= ofw_bus_if.h +.endif + .include Index: dev/wi/if_wi_macio.c =================================================================== --- dev/wi/if_wi_macio.c (revision 0) +++ dev/wi/if_wi_macio.c (revision 0) @@ -0,0 +1,138 @@ +/*- + * 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 PCMCIA driver for FreeBSD. + * + * Written by Bill Paul + * Electrical Engineering Department + * Columbia University, New York City + */ + +#include +__FBSDID("$FreeBSD: head/sys/dev/wi/if_wi_macio.c 182250 2008-08-27 05:39:44Z imp $"); + +#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; +} Index: dev/wi/if_wi.c =================================================================== --- dev/wi/if_wi.c (revision 225715) +++ dev/wi/if_wi.c (working copy) @@ -1897,8 +1897,7 @@ static int wi_read_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1907,9 +1906,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - *ptr++ = CSR_READ_2(sc, WI_DATA0); + CSR_READ_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; } @@ -1917,8 +1914,7 @@ static int wi_write_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1928,9 +1924,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - CSR_WRITE_2(sc, WI_DATA0, ptr[i]); + CSR_WRITE_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; --Apple-Mail-15--654334916 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit --Apple-Mail-15--654334916--