summaryrefslogtreecommitdiffstats
path: root/sys/dev/ieee488/tnt4882.c
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>2010-02-01 21:21:10 +0000
committerjoerg <joerg@FreeBSD.org>2010-02-01 21:21:10 +0000
commitd67164f24c90020e7faa21f9a119342ba4c94eda (patch)
treed2b8cccc7e23ea72cbede5a0e58fb2d699312d6a /sys/dev/ieee488/tnt4882.c
parent8d6ed99eb05f2c34a558f53113a6c747f941be1a (diff)
downloadFreeBSD-src-d67164f24c90020e7faa21f9a119342ba4c94eda.zip
FreeBSD-src-d67164f24c90020e7faa21f9a119342ba4c94eda.tar.gz
GPIB overhaul, part #2: make the tnt4882 driver work with the newer
TNT5004 IC. This involved a major rewrite of a number of things, as this chip no longer supports the NAT7210 legacy mode but requires the host to use the (more modern) FIFO mode. In theory, this also ought to work on the older TNT4882C chip. I'll probably add this as optional support (perhaps by a device.hints flag) later on. By now, FIFO mode is *only* activates iff a TNT5004 chip has been detected (where the old code didn't work at all), while everything else is supposed to use the old code. MFC after: 2 weeks
Diffstat (limited to 'sys/dev/ieee488/tnt4882.c')
-rw-r--r--sys/dev/ieee488/tnt4882.c71
1 files changed, 21 insertions, 50 deletions
diff --git a/sys/dev/ieee488/tnt4882.c b/sys/dev/ieee488/tnt4882.c
index a4222a6..4b69d0d 100644
--- a/sys/dev/ieee488/tnt4882.c
+++ b/sys/dev/ieee488/tnt4882.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2005 Poul-Henning Kamp
+ * Copyright (c) 2010 Joerg Wunsch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -46,6 +47,7 @@
#define UPD7210_HW_DRIVER 1
#include <dev/ieee488/upd7210.h>
+#include <dev/ieee488/tnt4882.h>
struct tnt_softc {
int foo;
@@ -62,55 +64,6 @@ static struct resource_spec tnt_res_spec[] = {
{ -1, 0 }
};
-enum tnt4882reg {
- dir = 0x00,
- cdor = 0x00,
- isr1 = 0x02,
- imr1 = 0x02,
- isr2 = 0x04,
- imr2 = 0x04,
- accwr = 0x05,
- spsr = 0x06,
- spmr = 0x06,
- intr = 0x07,
- adsr = 0x08,
- admr = 0x08,
- cnt2 = 0x09,
- cptr = 0x0a,
- auxmr = 0x0a,
- tauxcr = 0x0a, /* 9914 mode register */
- cnt3 = 0x0b,
- adr0 = 0x0c,
- adr = 0x0c,
- hssel = 0x0d,
- adr1 = 0x0e,
- eosr = 0x0e,
- sts1 = 0x10,
- cfg = 0x10,
- dsr = 0x11,
- sh_cnt = 0x11,
- imr3 = 0x12,
- hier = 0x13,
- cnt0 = 0x14,
- misc = 0x15,
- cnt1 = 0x16,
- csr = 0x17,
- keyreg = 0x17,
- fifob = 0x18,
- fifoa = 0x19,
- isr3 = 0x1a,
- ccr = 0x1a,
- sasr = 0x1b,
- dcr = 0x1b,
- sts2 = 0x1c,
- cmdr = 0x1c,
- isr0 = 0x1d,
- imr0 = 0x1d,
- timer = 0x1e,
- bsr = 0x1f,
- bcr = 0x1f
-};
-
struct tst {
enum {RD, WT, xDELAY, END}
action;
@@ -276,6 +229,7 @@ tnt_attach(device_t dev)
{
struct tnt_softc *sc;
int error, i;
+ uint8_t version;
sc = device_get_softc(dev);
@@ -286,7 +240,7 @@ tnt_attach(device_t dev)
error = bus_setup_intr(dev, sc->res[2], INTR_TYPE_MISC | INTR_MPSAFE,
NULL, upd7210intr, &sc->upd7210, &sc->intr_handler);
- /* Necessary magic for MITE */
+ /* IO Device Window Base Size Register (IODWBSR) */
bus_write_4(sc->res[0], 0xc0, rman_get_start(sc->res[1]) | 0x80);
tst_exec(sc, tst_reset, "Reset");
@@ -298,6 +252,18 @@ tnt_attach(device_t dev)
tst_exec(sc, tst_count0_1, "COUNT0:1");
tst_exec(sc, tst_reset, "Reset");
+ version = bus_read_1(sc->res[1], csr);
+ version = (version >> 4) & 0x0f;
+ device_printf(dev, "Chip version 0x%02x (TNT%s)\n",
+ version,
+ version >= 4? "5004 or above": "4882");
+ if (version >= 4) {
+ device_printf(dev, "Forcing FIFO mode\n");
+ sc->upd7210.use_fifo = 1;
+ } else {
+ sc->upd7210.use_fifo = 0;
+ }
+
/* pass 7210 interrupts through */
bus_write_1(sc->res[1], imr3, 0x02);
@@ -313,6 +279,11 @@ tnt_attach(device_t dev)
sc->upd7210.irq_clear_res = NULL;
upd7210attach(&sc->upd7210);
+ device_printf(dev, "attached gpib%d\n", sc->upd7210.unit);
+
+ if (sc->upd7210.use_fifo)
+ bus_write_1(sc->res[0], hssel, 0x01); /* one-chip mode */
+
return (0);
}
OpenPOWER on IntegriCloud