Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add driver for ScanLogic SL811HS/T USB Host Controller.



details:   https://anonhg.NetBSD.org/src/rev/9c7b65cd6a9a
branches:  trunk
changeset: 535169:9c7b65cd6a9a
user:      isaki <isaki%NetBSD.org@localhost>
date:      Sun Aug 11 13:17:52 2002 +0000

description:
Add driver for ScanLogic SL811HS/T USB Host Controller.
XXX It's experimental code yet.

For x68k: USB part of Nereid USB/Ethernet/memory board
For ISA:  ISA USB Host board from Morphy planning

diffstat:

 sys/arch/x68k/conf/files.x68k       |     9 +-
 sys/arch/x68k/dev/slhci_intio.c     |   206 ++++
 sys/arch/x68k/dev/slhci_intio_var.h |    59 +
 sys/conf/files                      |     7 +-
 sys/dev/DEVNAMES                    |     3 +-
 sys/dev/ic/sl811hs.c                |  1606 +++++++++++++++++++++++++++++++++++
 sys/dev/ic/sl811hsreg.h             |   124 ++
 sys/dev/ic/sl811hsvar.h             |   102 ++
 sys/dev/isa/files.isa               |     6 +-
 sys/dev/isa/slhci_isa.c             |   131 ++
 10 files changed, 2249 insertions(+), 4 deletions(-)

diffs (truncated from 2337 to 300 lines):

diff -r 31d93d3502d8 -r 9c7b65cd6a9a sys/arch/x68k/conf/files.x68k
--- a/sys/arch/x68k/conf/files.x68k     Sun Aug 11 13:17:35 2002 +0000
+++ b/sys/arch/x68k/conf/files.x68k     Sun Aug 11 13:17:52 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x68k,v 1.46 2002/04/22 09:41:21 augustss Exp $
+#      $NetBSD: files.x68k,v 1.47 2002/08/11 13:17:52 isaki Exp $
 #
 # new style config file for x68k architecture
 #
@@ -181,6 +181,10 @@
 attach ne at intio with ne_intio: rtl80x9
 file   arch/x68k/dev/if_ne_intio.c     ne_intio
 
+# Nereid USB
+attach slhci at intio with slhci_intio
+file   arch/x68k/dev/slhci_intio.c     slhci_intio
+
 # memory disk
 file   dev/md_root.c                   memory_disk_hooks
 major  {md = 8}
@@ -205,3 +209,6 @@
 
 # OSS audio driver compatibility
 include "compat/ossaudio/files.ossaudio"
+
+# USB support
+include "dev/usb/files.usb"
diff -r 31d93d3502d8 -r 9c7b65cd6a9a sys/arch/x68k/dev/slhci_intio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/dev/slhci_intio.c   Sun Aug 11 13:17:52 2002 +0000
@@ -0,0 +1,206 @@
+/*     $NetBSD: slhci_intio.c,v 1.1 2002/08/11 13:17:52 isaki Exp $    */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tetsuya Isaki.
+ *
+ * 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 the NetBSD
+ *      Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * USB part of Nereid Ethernet/USB/Memory board
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdivar.h>
+
+#include <dev/ic/sl811hsreg.h>
+#include <dev/ic/sl811hsvar.h>
+
+#include <arch/x68k/dev/intiovar.h>
+
+#include <arch/x68k/dev/slhci_intio_var.h>
+
+static int  slhci_intio_match(struct device *, struct cfdata *, void *);
+static void slhci_intio_attach(struct device *, struct device *, void *);
+static void slhci_intio_enable_power(void *, int);
+static void slhci_intio_enable_intr(void *, int);
+static int  slhci_intio_intr(void *);
+
+struct cfattach slhci_intio_ca = {
+       sizeof(struct slhci_intio_softc), slhci_intio_match, slhci_intio_attach
+};
+
+static int
+slhci_intio_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct intio_attach_args *ia = aux;
+       bus_space_tag_t iot = ia->ia_bst;
+       bus_space_handle_t ioh;
+       bus_space_handle_t nch;
+       int nc_addr;
+       int nc_size;
+
+       if (ia->ia_addr == INTIOCF_ADDR_DEFAULT)
+               ia->ia_addr = SLHCI_INTIO_ADDR1;
+       if (ia->ia_intr == INTIOCF_INTR_DEFAULT)
+               ia->ia_intr = SLHCI_INTIO_INTR1;
+
+       /* fixed parameters */
+       if ( !(ia->ia_addr == SLHCI_INTIO_ADDR1 &&
+              ia->ia_intr == SLHCI_INTIO_INTR1   ) &&
+            !(ia->ia_addr == SLHCI_INTIO_ADDR2 &&
+              ia->ia_intr == SLHCI_INTIO_INTR2   ) )
+               return 0;
+
+       /* Whether the control port is accessible or not */
+       nc_addr = ia->ia_addr + NEREID_ADDR_OFFSET;
+       nc_size = 0x02;
+       if (badbaddr((caddr_t)INTIO_ADDR(nc_addr)))
+               return 0;
+
+       /* Map two I/O spaces */
+       ia->ia_size = SL11_PORTSIZE * 2;
+       if (bus_space_map(iot, ia->ia_addr, ia->ia_size,
+                       BUS_SPACE_MAP_SHIFTED, &ioh))
+               return 0;
+
+       if (bus_space_map(iot, nc_addr, nc_size,
+                       BUS_SPACE_MAP_SHIFTED, &nch))
+               return 0;
+
+       bus_space_unmap(iot, ioh, ia->ia_size);
+       bus_space_unmap(iot, nch, nc_size);
+
+       return 1;
+}
+
+static void
+slhci_intio_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct slhci_intio_softc *sc = (struct slhci_intio_softc *)self;
+       struct intio_attach_args *ia = aux;
+       bus_space_tag_t iot = ia->ia_bst;
+       bus_space_handle_t ioh;
+       int nc_addr;
+       int nc_size;
+
+       printf(": Nereid USB\n");
+
+       /* Map I/O space */
+       if (bus_space_map(iot, ia->ia_addr, SL11_PORTSIZE * 2,
+                       BUS_SPACE_MAP_SHIFTED, &ioh)) {
+               printf("%s: can't map I/O space\n",
+                       sc->sc_sc.sc_bus.bdev.dv_xname);
+               return;
+       }
+
+       nc_addr = ia->ia_addr + NEREID_ADDR_OFFSET;
+       nc_size = 0x02;
+       if (bus_space_map(iot, nc_addr, nc_size,
+                       BUS_SPACE_MAP_SHIFTED, &sc->sc_nch)) {
+               printf("%s: can't map I/O control space\n",
+                       sc->sc_sc.sc_bus.bdev.dv_xname);
+               return;
+       }
+
+       /* Initialize sc */
+       sc->sc_sc.sc_iot = iot;
+       sc->sc_sc.sc_ioh = ioh;
+       sc->sc_sc.sc_dmat = ia->ia_dmat;
+       sc->sc_sc.sc_enable_power = slhci_intio_enable_power;
+       sc->sc_sc.sc_enable_intr  = slhci_intio_enable_intr;
+       sc->sc_sc.sc_arg = sc;
+
+       /* Establish the interrupt handler */
+       if (intio_intr_establish(ia->ia_intr, "slhci", slhci_intio_intr, sc)) {
+               printf("%s: can't establish interrupt\n",
+                       sc->sc_sc.sc_bus.bdev.dv_xname);
+               return;
+       }
+
+       /* Reset controller */
+       bus_space_write_1(iot, sc->sc_nch, NEREID_CTRL, NEREID_CTRL_RESET);
+       delay(40000);
+
+       /* Attach SL811HS/T */
+       if (slhci_attach(&sc->sc_sc, self))
+               return;
+}
+
+static void
+slhci_intio_enable_power(void *arg, int mode)
+{
+       struct slhci_intio_softc *sc = arg;
+       bus_space_tag_t iot = sc->sc_sc.sc_iot;
+       u_int8_t r;
+
+       r = bus_space_read_1(iot, sc->sc_nch, NEREID_CTRL);
+       if (mode == POWER_ON)
+               bus_space_write_1(iot, sc->sc_nch, NEREID_CTRL,
+                       r |  NEREID_CTRL_POWER);
+       else
+               bus_space_write_1(iot, sc->sc_nch, NEREID_CTRL,
+                       r & ~NEREID_CTRL_POWER);
+}
+
+static void
+slhci_intio_enable_intr(void *arg, int mode)
+{
+       struct slhci_intio_softc *sc = arg;
+       bus_space_tag_t iot = sc->sc_sc.sc_iot;
+       u_int8_t r;
+
+       r = bus_space_read_1(iot, sc->sc_nch, NEREID_CTRL);
+       if (mode == INTR_ON)
+               bus_space_write_1(iot, sc->sc_nch, NEREID_CTRL,
+                       r |  NEREID_CTRL_INTR);
+       else
+               bus_space_write_1(iot, sc->sc_nch, NEREID_CTRL,
+                       r & ~NEREID_CTRL_INTR);
+}
+
+static int
+slhci_intio_intr(void *arg)
+{
+       struct slhci_intio_softc *sc = arg;
+
+       return slhci_intr(&sc->sc_sc);
+}
diff -r 31d93d3502d8 -r 9c7b65cd6a9a sys/arch/x68k/dev/slhci_intio_var.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x68k/dev/slhci_intio_var.h       Sun Aug 11 13:17:52 2002 +0000
@@ -0,0 +1,59 @@
+/*     $NetBSD: slhci_intio_var.h,v 1.1 2002/08/11 13:17:52 isaki Exp $        */
+
+/*
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tetsuya Isaki.
+ *
+ * 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 the NetBSD
+ *      Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 THE FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+/*
+ * USB part of Nereid Ethernet/USB/Memory board
+ */
+
+#define SLHCI_INTIO_ADDR1      (0xece380)
+#define SLHCI_INTIO_ADDR2      (0xeceb80)
+#define SLHCI_INTIO_INTR1      (0xfb)
+#define SLHCI_INTIO_INTR2      (0xfa)
+
+#define NEREID_ADDR_OFFSET     (0xece3f0 - 0xece380)   /* Nereid control port */
+#define NEREID_CTRL            (0)
+#define NEREID_CTRL_RESET      (0x01)
+#define NEREID_CTRL_POWER      (0x02)
+#define NEREID_CTRL_INTR       (0x04)
+#define NEREID_CTRL_DIPSW      (0x08)
+
+struct slhci_intio_softc {
+       struct slhci_softc sc_sc;
+
+       bus_space_handle_t sc_nch;      /* Nereid control port handle */
+};



Home | Main Index | Thread Index | Old Index