summaryrefslogtreecommitdiffstats
path: root/sys/i4b/tina-dd
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-12-27 21:47:14 +0000
committerphk <phk@FreeBSD.org>1998-12-27 21:47:14 +0000
commitc7ecc129d72ba32b5d83c9a6019e93fd181d719c (patch)
tree8d5099bc7ef24151b4f6deb00d1d34a7e7ac694a /sys/i4b/tina-dd
parent3f431df8ec46b86090ad59ee153872c45d4d429d (diff)
downloadFreeBSD-src-c7ecc129d72ba32b5d83c9a6019e93fd181d719c.zip
FreeBSD-src-c7ecc129d72ba32b5d83c9a6019e93fd181d719c.tar.gz
Initial entry of ISDN4BSD into the FreeBSD tree.
ISDN4BSD is the work of our brand-new comitter: Hellmuth Michaelis, who has done a tremendous amount of work to bring us this far. There are still some outstanding issues and files to bring into the tree, and for now it will be needed to pick up all the extra docs from the isdn4bsd release. It is probably also a very good idea to subscribe to the isdn@freebsd.org mailing list before you try this out. These files correspond to release "beta Version 0.70.00 / December 1998" from Hellmuth.
Diffstat (limited to 'sys/i4b/tina-dd')
-rw-r--r--sys/i4b/tina-dd/README20
-rw-r--r--sys/i4b/tina-dd/i4b_tina_dd.c330
-rw-r--r--sys/i4b/tina-dd/i4b_tina_ioctl.h138
3 files changed, 488 insertions, 0 deletions
diff --git a/sys/i4b/tina-dd/README b/sys/i4b/tina-dd/README
new file mode 100644
index 0000000..6a2386f
--- /dev/null
+++ b/sys/i4b/tina-dd/README
@@ -0,0 +1,20 @@
+
+THIS DRIVER IS NOT YET WORKING !
+================================
+
+This adds support for the active ISDN card tina-dd manufactured by
+Stollmann E+V GmbH in Hamburg, Germany. This card was also sold by
+MIRO as the Miro P1.
+
+Christian Luehrs and Manfred Jung of Stollmann were very helpful
+giving out docs and sources to support the development of a driver
+for this card.
+
+The card supports many protocols. In order to make the card operable
+you'll need the downloadable firmware which also can be found on the
+www/ftp server, www.stollmann.de / ftp.stollmann.de.
+
+While developing this driver, i used fcdddss1.loc as of April 1994.
+
+The code is based in part on sources and header files written by
+Stollmann for their driver development kit for the tina-dd.
diff --git a/sys/i4b/tina-dd/i4b_tina_dd.c b/sys/i4b/tina-dd/i4b_tina_dd.c
new file mode 100644
index 0000000..7a5e010
--- /dev/null
+++ b/sys/i4b/tina-dd/i4b_tina_dd.c
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 1994, 1998 Hellmuth Michaelis. 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 AUTHOR 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 AUTHOR 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.
+ *
+ *---------------------------------------------------------------------------
+ *
+ * i4b_tina_dd.c - i4b Stollman Tina-dd control device driver
+ * ----------------------------------------------------------
+ *
+ * $Id: i4b_tina_dd.c,v 1.3 1998/12/05 18:06:19 hm Exp $
+ *
+ * last edit-date: [Sat Dec 5 18:41:38 1998]
+ *
+ *---------------------------------------------------------------------------*/
+
+#include "tina.h"
+
+#if NTINA > 0
+
+#include <sys/param.h>
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#include <sys/ioccom.h>
+#else
+#include <sys/ioctl.h>
+#endif
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/mbuf.h>
+#include <sys/proc.h>
+#include <sys/fcntl.h>
+#include <sys/socket.h>
+#include <net/if.h>
+
+#ifdef __FreeBSD__
+#include <machine/i4b_debug.h>
+#include <machine/i4b_ioctl.h>
+#include <i386/isa/isa_device.h>
+#else
+#include <machine/bus.h>
+#include <sys/device.h>
+#include <i4b/i4b_debug.h>
+#include <i4b/i4b_ioctl.h>
+#endif
+
+#include <i4b/include/i4b_mbuf.h>
+#include <i4b/tina-dd/i4b_tina_ioctl.h>
+
+static int openflag = 0;
+
+int tinaprobe(struct isa_device *dev);
+int tinaattach(struct isa_device *dev);
+
+struct isa_driver tinadriver = {
+ tinaprobe,
+ tinaattach,
+ "tina",
+ 0
+};
+
+static struct tina_softc {
+ int sc_unit;
+ int sc_iobase;
+} tina_sc[NTINA];
+
+static d_open_t tinaopen;
+static d_close_t tinaclose;
+static d_ioctl_t tinaioctl;
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+static d_poll_t tinapoll;
+#endif
+
+#define CDEV_MAJOR 54
+static struct cdevsw tina_cdevsw =
+ { tinaopen, tinaclose, noread, nowrite,
+ tinaioctl, nostop, nullreset, nodevtotty,
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+ tinapoll, nommap, NULL, "tina", NULL, -1 };
+#else
+ noselect, nommap, NULL, "tina", NULL, -1 };
+#endif
+
+static void setupaddr(unsigned short iobase, unsigned int addr);
+static void readblock(unsigned short iobase, unsigned int addr,
+ unsigned char *dst, unsigned int len);
+static void writeblock(unsigned short iobase, unsigned char *src,
+ unsigned long addr, int len);
+
+/*---------------------------------------------------------------------------*
+ * tina - device driver probe routine
+ *---------------------------------------------------------------------------*/
+int
+tinaprobe(struct isa_device *dev)
+{
+ struct tina_softc *sc = &tina_sc[dev->id_unit];
+ u_char byte;
+
+#define SETLOW 0x55
+#define SETMID 0xaa
+#define SETHIGH 0x06
+
+ outb((dev->id_iobase + ADDR_CNTL), SETLOW);
+
+ if((byte = inb(dev->id_iobase + ADDR_CNTL)) != SETLOW)
+ {
+ printf("tina%d: probe low failed, 0x%x != 0x%x\n",
+ dev->id_unit, byte, SETLOW);
+ return(0);
+ }
+
+ outb((dev->id_iobase + ADDR_CNTM), SETMID);
+ if((byte = inb(dev->id_iobase + ADDR_CNTM)) != SETMID)
+ {
+ printf("tina%d: probe mid failed, 0x%x != 0x%x\n",
+ dev->id_unit, byte, SETMID);
+ return(0);
+ }
+
+ outb((dev->id_iobase + ADDR_CNTH), SETHIGH);
+ if(((byte = inb(dev->id_iobase + ADDR_CNTH)) & 0x0f) != SETHIGH)
+ {
+ printf("tina%d: probe high failed, 0x%x != 0x%x\n",
+ dev->id_unit, byte, SETHIGH);
+ return(0);
+ }
+
+ printf("tina%d: status register = 0x%x\n",
+ dev->id_unit, inb(dev->id_iobase + CTRL_STAT));
+
+ return(1); /* board found */
+}
+#undef SETLOW
+#undef SETMID
+#undef SETHIGH
+
+/*---------------------------------------------------------------------------*
+ * tina - device driver attach routine
+ *---------------------------------------------------------------------------*/
+int
+tinaattach(struct isa_device *dev)
+{
+ struct tina_softc *sc = &tina_sc[dev->id_unit];
+
+ sc->sc_unit = dev->id_unit;
+ sc->sc_iobase = dev->id_iobase;
+
+ printf("tina%d: attaching Tina-dd\n", dev->id_unit);
+
+ return(1);
+}
+
+/*---------------------------------------------------------------------------*
+ * tina - device driver interrupt routine
+ *---------------------------------------------------------------------------*/
+void
+tinaintr(int unit)
+{
+ struct tina_softc *sc = &tina_sc[unit];
+}
+
+#if BSD > 199306 && defined(__FreeBSD__)
+/*---------------------------------------------------------------------------*
+ * initialization at kernel load time
+ *---------------------------------------------------------------------------*/
+static void
+tinainit(void *unused)
+{
+ dev_t dev;
+
+ dev = makedev(CDEV_MAJOR, 0);
+
+ cdevsw_add(&dev, &tina_cdevsw, NULL);
+}
+
+SYSINIT(tinadev, SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, &tinainit, NULL);
+
+#endif /* BSD > 199306 && defined(__FreeBSD__) */
+
+/*---------------------------------------------------------------------------*
+ * tinaopen - device driver open routine
+ *---------------------------------------------------------------------------*/
+static int
+tinaopen(dev_t dev, int flag, int fmt, struct proc *p)
+{
+ if(minor(dev))
+ return (ENXIO);
+
+ if(openflag)
+ return (EBUSY);
+
+ openflag = 1;
+
+ return(0);
+}
+
+/*---------------------------------------------------------------------------*
+ * tinaclose - device driver close routine
+ *---------------------------------------------------------------------------*/
+static int
+tinaclose(dev_t dev, int flag, int fmt, struct proc *p)
+{
+ openflag = 0;
+ return(0);
+}
+
+/*---------------------------------------------------------------------------*
+ * tinaioctl - device driver ioctl routine
+ *---------------------------------------------------------------------------*/
+static int
+tinaioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
+{
+ struct tina_softc *sc = &tina_sc[minor(dev)];
+ u_short iobase = sc->sc_iobase;
+ int error = 0;
+ char *ptr;
+ int s;
+
+ if(minor(dev))
+ return(ENODEV);
+
+ s = splimp();
+
+ switch(cmd)
+ {
+ /* hardware layer - control & status register */
+
+ case ISDN_GETCSR: /* return control register */
+ *(unsigned char *)data = inb(iobase + CTRL_STAT);
+ break;
+
+ case ISDN_SETCSR: /* set status register */
+ outb((iobase + CTRL_STAT), *(unsigned char *)data);
+ break;
+
+ /* hardware layer - dual ported memory */
+
+ case ISDN_GETBLK: /* get block from dual port mem */
+ readblock(iobase, (*(struct record *)data).addr,
+ (*(struct record *)data).data,
+ (*(struct record *)data).length);
+ break;
+
+ case ISDN_SETBLK: /* write block to dual port mem */
+ writeblock(iobase, (*(struct record *)data).data,
+ (*(struct record *)data).addr,
+ (*(struct record *)data).length);
+ break;
+
+ default:
+ error = ENOTTY;
+ break;
+ }
+ return(error);
+}
+
+/*---------------------------------------------------------------------------*
+ * tinapoll - device driver poll routine
+ *---------------------------------------------------------------------------*/
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+static int
+tinapoll (dev_t dev, int events, struct proc *p)
+{
+ return (ENODEV);
+}
+#endif
+
+/*===========================================================================*
+ * tina dual ported memory access
+ *===========================================================================*/
+
+/*---------------------------------------------------------------------------*
+ * setup address for accessing tina-dd ram
+ *---------------------------------------------------------------------------*/
+static void
+setupaddr(unsigned short iobase, unsigned int addr)
+{
+ outb((iobase + ADDR_CNTL), (unsigned char) addr & 0xff);
+ outb((iobase + ADDR_CNTM), (unsigned char) ((addr >> 8) & 0xff));
+ outb((iobase + ADDR_CNTH), (unsigned char) ((addr >> 16) & 0xff));
+}
+
+
+/*---------------------------------------------------------------------------*
+ * read block from tina-dd dual ported ram
+ *---------------------------------------------------------------------------*/
+static void
+readblock(unsigned short iobase, unsigned int addr,
+ unsigned char *dst, unsigned int len)
+{
+ setupaddr(iobase, addr); /* setup start address */
+
+ while(len--) /* tina-dd mem -> pc mem */
+ *dst++ = inb(iobase + DATA_LOW_INC);
+}
+
+/*---------------------------------------------------------------------------*
+ * write block to tina-dd dual ported ram
+ *---------------------------------------------------------------------------*/
+static void
+writeblock(unsigned short iobase, unsigned char *src,
+ unsigned long addr, int len)
+{
+ setupaddr(iobase, addr); /* setup start address */
+
+ while(len--) /* pc mem -> tina-dd mem */
+ outb((iobase + DATA_LOW_INC), *src++);
+}
+
+#endif /* NTINA > 0 */
diff --git a/sys/i4b/tina-dd/i4b_tina_ioctl.h b/sys/i4b/tina-dd/i4b_tina_ioctl.h
new file mode 100644
index 0000000..d51f16d
--- /dev/null
+++ b/sys/i4b/tina-dd/i4b_tina_ioctl.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 1994, 1998 Hellmuth Michaelis. All rights reserved.
+ *
+ * Based on code written by Stollmann GmbH, Hamburg. Many thanks to
+ * Christian Luehrs and Manfred Jung for docs, sources and answers!
+ *
+ * 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 AUTHOR 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 AUTHOR 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.
+ *
+ *---------------------------------------------------------------------------
+ *
+ * i4b_tina_ioctl.h - i4b Stollman Tina-dd ioctl header file
+ * ---------------------------------------------------------
+ *
+ * $Id: i4b_tina_ioctl.h,v 1.2 1998/12/05 18:06:20 hm Exp $
+ *
+ * last edit-date: [Sat Dec 5 18:41:51 1998]
+ *
+ *---------------------------------------------------------------------------*/
+
+#ifndef _I4B_TINA_IOCTL_H_
+#define _I4B_TINA_IOCTL_H_
+
+#define TINA_IOSIZE 8 /* 8 byte wide iospace occupied */
+
+/*---------------------------------------------------------------------------*
+ * register offsets in i/o address space
+ *---------------------------------------------------------------------------*/
+
+#define CTRL_STAT 0 /* control & status */
+
+#define ADDR_CNTL 1 /* address pointer low */
+#define ADDR_CNTM 2 /* address pointer mid */
+#define ADDR_CNTH 3 /* address pointer high */
+
+#define DATA_LOW 4 /* data register low */
+#define DATA_HIGH 5 /* data register high */
+
+#define DATA_LOW_INC 6 /* data register low, post inc */
+#define DATA_HIGH_INC 7 /* data register high, post inc */
+
+/*---------------------------------------------------------------------------*
+ * status register (CTRL_STAT read access)
+ *---------------------------------------------------------------------------*/
+
+#define CR_INTC 0x80 /* irq FROM tina-dd TO pc active */
+#define CR_INTP 0x40 /* irq FROM pc TO tina-dd active */
+#define CR_INTPA 0x20 /* irq FROM pc TO tina-dd active */
+#define CR_NMI 0x10 /* nmi FROM PC TO tina-dd active */
+#define CR_FLASHLD 0x08 /* read of the FLASHLD-bit (n/c) */
+#define CR_S2C 0x04 /* info bit */
+#define CR_S1C 0x02 /* info bit */
+#define CR_S0C 0x01 /* info bit */
+
+/*---------------------------------------------------------------------------*
+ * control register (CTRL_STAT write access)
+ *---------------------------------------------------------------------------*/
+
+#define CR_CLR_INTC 0x80 /* clear irq on tina-dd */
+#define CR_SET_INTP 0x40 /* trigger irq on tina-dd */
+#define CR_RESET 0x20 /* reset tina-dd */
+#define CR_SET_NMI 0x10 /* trigger nmi on tina-dd */
+#define CR_SET_FLASHLD 0x08 /* activates pin FLASHLD (n/c) */
+#define CR_S2P 0x04 /* info bit (not readable !) */
+#define CR_S1P 0x02 /* info bit (not readable !) */
+#define CR_S0P 0x01 /* info bit (not readable !) */
+
+/*---------------------------------------------------------------------------*
+ * misc definitions in dual-ported mem on board of tina-dd
+ *---------------------------------------------------------------------------*/
+
+#define FW_SYSCB 0x200 /* address of FW SYSCB / MJ 300392 */
+#define FW_SINFO_NAME 0x220 /* address of general info label */
+
+#define FW_HW_TYPE 0x224 /* address of hardware type byte: */
+#define FW_HW_UNDEF 0x00 /* undefined .. */
+#define FW_HW_TINA_DD 0x10 /* TINA-dd */
+#define FW_HW_TINA_DS 0x20 /* TINA-ds (B channel/ser ?) */
+#define FW_HW_TINA_D 0x30 /* TINA-d (one B channel ?) */
+#define FW_HW_TINA_DDM 0x40 /* TINA-dd with fax module */
+#define FW_HW_TINA_DDS 0x50 /* TINA-dd with fax/voice module */
+#define FW_HW_SICCE 0x80 /* X.25 board */
+#define FW_HW_ASIC 0x01 /* ASIC version bit */
+
+#define FW_STAT 0x228 /* address of firmware status byte */
+#define FW_READY 0x20 /* firmware ready bit */
+#define FW_BOOTPRM_RDY 0x02 /* boot PROM ready */
+#define FW_UNDEF_0 0x00 /* undefined */
+#define FW_UNDEF_1 0xFF /* undefined */
+
+#define FW_SINFO_ID "SYSI" /* general info label for FW > 2.13*/
+#define FW_SINFO_ID_LEN 4
+
+#define FW_ADDR_PROFPTR 0x260 /* addr of ptr to board profile */
+
+/*===========================================================================*
+ * Layer 0 - Hardware layer
+ *===========================================================================*/
+
+/* control and status register access */
+
+#define ISDN_GETCSR _IOR('I', 1, unsigned char) /* get csr */
+#define ISDN_SETCSR _IOW('I', 2, unsigned char) /* set csr */
+
+/* dual ported ram access */
+
+#define ISDN_GETBLK _IOWR('I', 3, struct record) /* get dpr record */
+#define ISDN_SETBLK _IOW('I', 4, struct record) /* set dpr record */
+
+/*---------------------------------------------------------------------------*
+ * record structure for dual ported ram block rd/wr
+ *---------------------------------------------------------------------------*/
+struct record {
+ unsigned int length; /* length of data block */
+ unsigned int addr; /* address of mem on tina-dd board */
+ unsigned char *data; /* pointer to the datablock itself */
+};
+
+#endif /* _I4B_TINA_IOCTL_H_ */
OpenPOWER on IntegriCloud