Source-Changes-HG archive

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

[src/trunk]: src TURBOchannel usb/gpio driver from Felix Deichmann



details:   https://anonhg.NetBSD.org/src/rev/051a56fec0d5
branches:  trunk
changeset: 347044:051a56fec0d5
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Aug 11 09:05:42 2016 +0000

description:
TURBOchannel usb/gpio driver from Felix Deichmann

diffstat:

 share/man/man4/Makefile |    4 +-
 share/man/man4/tcu.4    |   57 ++++++++++++
 sys/dev/tc/files.tc     |   10 +-
 sys/dev/tc/slhci_tcu.c  |  101 +++++++++++++++++++++
 sys/dev/tc/tcdevs       |    3 +-
 sys/dev/tc/tcu.c        |  221 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 392 insertions(+), 4 deletions(-)

diffs (truncated from 447 to 300 lines):

diff -r 08667e63757c -r 051a56fec0d5 share/man/man4/Makefile
--- a/share/man/man4/Makefile   Thu Aug 11 08:32:42 2016 +0000
+++ b/share/man/man4/Makefile   Thu Aug 11 09:05:42 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.628 2016/05/01 10:21:01 nonaka Exp $
+#      $NetBSD: Makefile,v 1.629 2016/08/11 09:06:20 christos Exp $
 #      @(#)Makefile    8.1 (Berkeley) 6/18/93
 
 MAN=   aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -61,7 +61,7 @@
        sm.4 smsh.4 sn.4 sony.4 spc.4 speaker.4 spif.4 sqphy.4 ss.4 \
        st.4 ste.4 stge.4 sti.4 stpcide.4 sv.4 strip.4 \
        svwsata.4 swsensor.4 swwdog.4 sysmon.4 \
-       tap.4 tc.4 tcds.4 tcp.4 tdvfb.4 termios.4 tfb.4 thinkpad.4 \
+       tap.4 tc.4 tcds.4 tcp.4 tcu.4 tdvfb.4 termios.4 tfb.4 thinkpad.4 \
        ti.4 tl.4 tlp.4 tlphy.4 tpm.4 tprof.4 tr.4 tra.4 \
        trm.4 tty.4 tun.4 tqphy.4 twa.4 twe.4 txp.4 \
        uark.4 ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 unix.4 userconf.4 \
diff -r 08667e63757c -r 051a56fec0d5 share/man/man4/tcu.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/tcu.4      Thu Aug 11 09:05:42 2016 +0000
@@ -0,0 +1,57 @@
+.\"     $NetBSD: tcu.4,v 1.1 2016/08/11 09:06:20 christos Exp $
+.\"
+.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry.
+.\"
+.\" 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.
+.\"
+.\" 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.
+.\"
+.Dd August 9, 2016
+.Dt TCU 4
+.Os
+.Sh NAME
+.Nm tcu
+.Nd TURBOchannel USB host options
+.Sh SYNOPSIS
+.Cd "tcu*    at tc? slot ? offset ?"
+.Pp
+.Cd "slhci*  at tcu?"
+.Cd "usb*    at slhci?"
+.Pp
+.Cd "gpio*   at gpiobus?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the flxd TC-USB TURBOchannel USB host options based
+upon a Cypress SL811HST USB 1.1 host controller and a glue logic CPLD. USB is
+handled by the
+.Xr slhci 4
+driver. Eight GPIO pins provided by the CPLD can be accessed through the
+.Xr gpio 4
+driver.
+.Sh SEE ALSO
+.Xr gpio 4 ,
+.Xr slhci 4 ,
+.Xr tc 4 ,
+.Xr usb 4
diff -r 08667e63757c -r 051a56fec0d5 sys/dev/tc/files.tc
--- a/sys/dev/tc/files.tc       Thu Aug 11 08:32:42 2016 +0000
+++ b/sys/dev/tc/files.tc       Thu Aug 11 09:05:42 2016 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.tc,v 1.33 2008/02/27 23:49:11 matt Exp $
+#      $NetBSD: files.tc,v 1.34 2016/08/11 09:05:42 christos Exp $
 #
 # Config file and device description for machine-independent
 # TURBOchannel code.  Included by ports that need it.
@@ -100,3 +100,11 @@
 device sfbp: wsemuldisplaydev, rasops32, rasops8
 attach sfbp at tc
 file   dev/tc/sfbplus.c                sfbp needs-flag
+
+# TC-USB
+device tcu { } : gpiobus
+attach tcu at tc
+file   dev/tc/tcu.c                    tcu
+
+attach slhci at tcu with slhci_tcu
+file   dev/tc/slhci_tcu.c              slhci_tcu needs-flag
diff -r 08667e63757c -r 051a56fec0d5 sys/dev/tc/slhci_tcu.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/tc/slhci_tcu.c    Thu Aug 11 09:05:42 2016 +0000
@@ -0,0 +1,101 @@
+/* $NetBSD: slhci_tcu.c,v 1.1 2016/08/11 09:05:42 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016, Felix Deichmann
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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.
+ */
+
+/*
+ * flxd TC-USB - TURBOchannel USB host option
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: slhci_tcu.c,v 1.1 2016/08/11 09:05:42 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <sys/bus.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 <dev/tc/tcvar.h>
+
+struct slhci_tcu_softc {
+       struct slhci_softc sc;
+};
+
+static int  slhci_tcu_match(device_t, cfdata_t, void *);
+static void slhci_tcu_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(slhci_tcu, sizeof(struct slhci_tcu_softc),
+    slhci_tcu_match, slhci_tcu_attach, NULL, slhci_activate);
+
+static int
+slhci_tcu_match(device_t parent, cfdata_t cf, void *aux)
+{
+
+       /* Always match. */
+       return 1;
+}
+
+#define SLHCI_TCU_STRIDE       4
+#define SLHCI_TCU_IMAX         500 /* mA */
+
+static void
+slhci_tcu_attach(device_t parent, device_t self, void *aux)
+{
+       struct slhci_tcu_softc *tsc = device_private(self);
+       struct slhci_softc *sc = &tsc->sc;
+       struct tc_attach_args *ta = aux;
+       bus_space_tag_t iot = ta->ta_memt;
+       bus_space_handle_t ioh;
+       int error;
+
+       sc->sc_dev = self;
+       sc->sc_bus.ub_hcpriv = sc;
+
+       aprint_normal("\n");
+
+       error = bus_space_map(iot, ta->ta_addr,
+           SLHCI_TCU_STRIDE * SL11_PORTSIZE, 0, &ioh);
+       if (error) {
+               aprint_error_dev(self, "bus_space_map() failed (%d)\n", error);
+               return;
+       }
+
+       slhci_preinit(sc, NULL, iot, ioh, SLHCI_TCU_IMAX, SLHCI_TCU_STRIDE);
+
+       tc_intr_establish(device_parent(parent), ta->ta_cookie, IPL_USB,
+           slhci_intr, sc);
+
+       if (slhci_attach(sc))
+               aprint_error_dev(self, "slhci_attach() failed\n");
+}
diff -r 08667e63757c -r 051a56fec0d5 sys/dev/tc/tcdevs
--- a/sys/dev/tc/tcdevs Thu Aug 11 08:32:42 2016 +0000
+++ b/sys/dev/tc/tcdevs Thu Aug 11 09:05:42 2016 +0000
@@ -1,4 +1,4 @@
-$NetBSD: tcdevs,v 1.21 2009/01/21 14:34:18 jnemeth Exp $
+$NetBSD: tcdevs,v 1.22 2016/08/11 09:05:42 christos Exp $
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou
@@ -83,6 +83,7 @@
 device PMTNV-AA        ???     Non-volatile RAM option card
 device T1D4PKT         ds      DECWRL Turbochannel T1
 device T3PKT           tt      DECWRL Turbochannel T3
+device TC-USB          tcu     flxd TC-USB
 
 # the following entries are unconfirmed
 #device        PMAF-CA         fza     DEC FDDIcontroller 700C (DEFZA; copper)
diff -r 08667e63757c -r 051a56fec0d5 sys/dev/tc/tcu.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/tc/tcu.c  Thu Aug 11 09:05:42 2016 +0000
@@ -0,0 +1,221 @@
+/* $NetBSD: tcu.c,v 1.1 2016/08/11 09:05:42 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016, Felix Deichmann
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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.
+ */
+
+/*
+ * flxd TC-USB - TURBOchannel USB host option
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: tcu.c,v 1.1 2016/08/11 09:05:42 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/gpio.h>
+
+#include <sys/bus.h>
+
+#include <dev/tc/tcvar.h>
+
+#include <dev/gpio/gpiovar.h>
+
+#include "gpio.h"
+#include "slhci_tcu.h"
+
+#define TCU_GPIO_NPINS 8
+#define TCU_GPIO_OFFS  0x80
+#define TCU_GPIO_SIZE  (3 * 4)
+#define TCU_GPIO_DIR   0x0
+#define TCU_GPIO_IN    0x4
+#define TCU_GPIO_OUT   0x8
+
+struct tcu_softc {
+#if NGPIO > 0
+       kmutex_t                sc_gpio_mtx;
+       struct gpio_chipset_tag sc_gpio_gc;
+       gpio_pin_t              sc_gpio_pins[TCU_GPIO_NPINS];
+       bus_space_tag_t         sc_gpio_iot;
+       bus_space_handle_t      sc_gpio_ioh;
+#endif /* NGPIO > 0 */
+};
+
+static int  tcu_match(device_t, cfdata_t, void *);
+static void tcu_attach(device_t, device_t, void *);
+
+#if NSLHCI_TCU > 0
+static int  tcu_print(void *, const char *);
+#endif /* NSLHCI_TCU > 0 */
+#if NGPIO > 0
+static void tcu_gpio_attach(device_t, device_t, void *);



Home | Main Index | Thread Index | Old Index