Date: Tue, 20 Jun 2000 19:06:30 -0400 From: Mark Abene <phiber@radicalmedia.com> To: Doug Rabson <drabson@yahoo.co.uk> Cc: "Andrew M. Miklic" <miklic@ibm.net>, dfr@nlsystems.com, freebsd-alpha@freebsd.org Subject: Parallel Port/Printer diffs! Message-ID: <20000620190629.C23157@radicalmedia.com> In-Reply-To: <20000618154002.9598.qmail@web1001.mail.yahoo.com>; from Doug Rabson on Sun, Jun 18, 2000 at 04:40:02PM %2B0100 References: <20000618154002.9598.qmail@web1001.mail.yahoo.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
Good news everyone. Working with Andrew Miklic's patches, I've created diffs
to 4.0-RELEASE which add support for the parallel port. I've also written
the requisite ppc_smc37c935_detect routine for those of us with Super I/O
chips (EB/PC164, etc.), so we can use ECP/EPP. Even the parallel port ZIP
drive works! I'm using mine right now. The diffs include a patch to the
GENERIC kernel config to enable the ppc driver. This should work on all
alphas. If you have the Super I/O chip in your machine, add the option
PPC_PROBE_CHIPSET to your kernel config, and be sure to specify the io port
and flags to the "ppc" driver line. My detect routine will tell the Super
I/O chip to relocate the parallel port to the io address you specify, and
set the mode according to the flags (if there are any). The default setting
is port 0x3bc in centronics compatible mode, but using my Super I/O support
you can relocate it to 0x378 and take advantage of EPP or ECP mode.
The man page for ppc breaks down what the flags are. To get the vpo zip drive
driver working, I'm using:
device ppc0 at isa? port 0x378 irq 7 flags 0x17
for EPP 1.7 + PS2 + NIBBLE mode. Of course you'll also need to enable scsi
support. You'll also want to enable the scsi pass device, so you can use
camcontrol to eject zip disks.
That's all for now, you'll find the diffs attached to this message.
Any questions, feel free to ask.
Cheers,
-Mark
[-- Attachment #2 --]
--- /dev/null Tue Jun 20 18:04:47 2000
+++ /usr/include/machine/lpt.h Wed Jun 14 21:03:35 2000
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 1994 Geoffrey M. Rehmet
+ *
+ * This program is free software; you may redistribute it and/or
+ * modify it, provided that it retain the above copyright notice
+ * and the following disclaimer.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Geoff Rehmet, Rhodes University, South Africa <csgr@cs.ru.ac.za>
+ *
+ * $FreeBSD: src/sys/i386/include/lpt.h,v 1.7 1999/08/28 00:44:18 peter Exp $
+ */
+
+#ifndef _MACHINE_LPT_H_
+#define _MACHINE_LPT_H_
+
+#include <sys/ioccom.h>
+
+#define LPT_IRQ _IOW('p', 1, long) /* set interrupt status */
+
+#endif /* !_MACHINE_LPT_H_ */
--- /usr/include/machine/cpufunc.h.orig Fri Jun 16 07:02:11 2000
+++ /usr/include/machine/cpufunc.h Fri Jun 16 07:02:18 2000
@@ -61,6 +61,13 @@
/*
* Bulk i/o (for IDE driver).
*/
+static __inline void insb(u_int32_t port, void *buffer, size_t count)
+{
+ u_int8_t *p = (u_int8_t *) buffer;
+ while (count--)
+ *p++ = inb(port);
+}
+
static __inline void insw(u_int32_t port, void *buffer, size_t count)
{
u_int16_t *p = (u_int16_t *) buffer;
@@ -73,6 +80,13 @@
u_int32_t *p = (u_int32_t *) buffer;
while (count--)
*p++ = inl(port);
+}
+
+static __inline void outsb(u_int32_t port, const void *buffer, size_t count)
+{
+ const u_int8_t *p = (const u_int8_t *) buffer;
+ while (count--)
+ outb(port, *p++);
}
static __inline void outsw(u_int32_t port, const void *buffer, size_t count)
--- /sys/alpha/conf/GENERIC.orig Tue Jun 20 17:59:20 2000
+++ /sys/alpha/conf/GENERIC Tue Jun 20 18:01:40 2000
@@ -113,6 +113,14 @@
device sio0 at isa? port IO_COM1 irq 4
device sio1 at isa? port IO_COM2 irq 3 flags 0x50
+# Parallel port
+device ppc0 at isa? irq 7
+device ppbus # Parallel port bus (required)
+device lpt # Printer
+device plip # TCP/IP over parallel
+device ppi # Parallel port interface device
+#device vpo # Requires scbus and da
+
# PCI Ethernet NICs.
device de # DEC/Intel DC21x4x (``Tulip'')
device fxp # Intel EtherExpress PRO/100B (82557, 82558)
--- /sys/alpha/include/cpufunc.h.orig Wed Jun 14 21:30:22 2000
+++ /sys/alpha/include/cpufunc.h Wed Jun 14 21:36:22 2000
@@ -61,6 +61,13 @@
/*
* Bulk i/o (for IDE driver).
*/
+static __inline void insb(u_int32_t port, void *buffer, size_t count)
+{
+ u_int8_t *p = (u_int8_t *) buffer;
+ while (count--)
+ *p++ = inb(port);
+}
+
static __inline void insw(u_int32_t port, void *buffer, size_t count)
{
u_int16_t *p = (u_int16_t *) buffer;
@@ -73,6 +80,13 @@
u_int32_t *p = (u_int32_t *) buffer;
while (count--)
*p++ = inl(port);
+}
+
+static __inline void outsb(u_int32_t port, const void *buffer, size_t count)
+{
+ const u_int8_t *p = (const u_int8_t *) buffer;
+ while (count--)
+ outb(port, *p++);
}
static __inline void outsw(u_int32_t port, const void *buffer, size_t count)
--- /dev/null Tue Jun 20 18:04:47 2000
+++ /sys/alpha/include/lpt.h Wed Jun 14 21:08:32 2000
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 1994 Geoffrey M. Rehmet
+ *
+ * This program is free software; you may redistribute it and/or
+ * modify it, provided that it retain the above copyright notice
+ * and the following disclaimer.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Geoff Rehmet, Rhodes University, South Africa <csgr@cs.ru.ac.za>
+ *
+ * $FreeBSD: src/sys/i386/include/lpt.h,v 1.7 1999/08/28 00:44:18 peter Exp $
+ */
+
+#ifndef _MACHINE_LPT_H_
+#define _MACHINE_LPT_H_
+
+#include <sys/ioccom.h>
+
+#define LPT_IRQ _IOW('p', 1, long) /* set interrupt status */
+
+#endif /* !_MACHINE_LPT_H_ */
--- /sys/conf/options.alpha.orig Wed Jun 14 20:50:47 2000
+++ /sys/conf/options.alpha Wed Jun 14 20:51:54 2000
@@ -63,3 +63,7 @@
KBD_MAXWAIT opt_kbd.h
KBD_RESETDELAY opt_kbd.h
KBDIO_DEBUG opt_kbd.h
+
+# printer options
+PPC_PROBE_CHIPSET opt_ppc.h
+PPC_DEBUG opt_ppc.h
--- /sys/conf/files.alpha.orig Wed Jun 14 20:52:09 2000
+++ /sys/conf/files.alpha Wed Jun 14 20:52:35 2000
@@ -190,6 +190,7 @@
isa/sio.c optional sio
isa/syscons_isa.c optional sc
isa/vga_isa.c optional vga
+isa/ppc.c optional ppc
kern/subr_diskmbr.c standard
libkern/alpha/htonl.S standard
libkern/alpha/htons.S standard
--- /sys/isa/ppc.c.orig Wed Jun 14 23:15:13 2000
+++ /sys/isa/ppc.c Tue Jun 20 17:50:13 2000
@@ -112,7 +112,11 @@
static char *ppc_models[] = {
"SMC-like", "SMC FDC37C665GT", "SMC FDC37C666GT", "PC87332", "PC87306",
- "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334", 0
+ "82091AA", "Generic", "W83877F", "W83877AF", "Winbond", "PC87334",
+ #ifdef __alpha__
+ "SMC FDC37C935",
+ #endif
+ 0
};
/* list of available modes */
@@ -882,6 +886,94 @@
return (chipset_mode);
}
+#ifdef __alpha__
+/*
+ * SMC FDC37C935 configuration
+ * Found on many Alpha machines
+ */
+static int
+ppc_smc37c935_detect(struct ppc_data *ppc, int chipset_mode)
+{
+ int s;
+ int type = -1;
+
+ s = splhigh();
+ outb(SMC935_CFG, 0x55); /* enter config mode */
+ outb(SMC935_CFG, 0x55);
+ splx(s);
+
+ outb(SMC935_IND, SMC935_ID); /* check device id */
+ if (inb(SMC935_DAT) == 0x2)
+ type = SMC_37C935;
+
+ if (type == -1) {
+ outb(SMC935_CFG, 0xaa); /* exit config mode */
+ return (-1);
+ }
+
+ ppc->ppc_model = type;
+
+ outb(SMC935_IND, SMC935_LOGDEV); /* select parallel port, */
+ outb(SMC935_DAT, 3); /* which is logical device 3 */
+
+ /* set io port base */
+ outb(SMC935_IND, SMC935_PORTHI);
+ outb(SMC935_DAT, (u_char)((ppc->ppc_base & 0xff00) >> 8));
+ outb(SMC935_IND, SMC935_PORTLO);
+ outb(SMC935_DAT, (u_char)(ppc->ppc_base & 0xff));
+
+ if (!chipset_mode)
+ ppc->ppc_avm = PPB_COMPATIBLE; /* default mode */
+ else
+ {
+ ppc->ppc_avm = chipset_mode;
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_CENT); /* start in compatible mode */
+
+ /* SPP + EPP or just plain SPP */
+ if (chipset_mode & (PPB_SPP)) {
+ if (chipset_mode & PPB_EPP) {
+ if (ppc->ppc_epp == EPP_1_9) {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_EPP19SPP);
+ }
+ if (ppc->ppc_epp == EPP_1_7) {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_EPP17SPP);
+ }
+ } else {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_SPP);
+ }
+ }
+
+ /* ECP + EPP or just plain ECP */
+ if (chipset_mode & PPB_ECP) {
+ if (chipset_mode & PPB_EPP) {
+ if (ppc->ppc_epp == EPP_1_9) {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_ECPEPP19);
+ }
+ if (ppc->ppc_epp == EPP_1_7) {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_ECPEPP17);
+ }
+ } else {
+ outb(SMC935_IND, SMC935_PPMODE);
+ outb(SMC935_DAT, SMC935_ECP);
+ }
+ }
+ }
+
+ outb(SMC935_CFG, 0xaa); /* exit config mode */
+
+ ppc->ppc_type = PPC_TYPE_SMCLIKE;
+ ppc_smclike_setmode(ppc, chipset_mode);
+
+ return (chipset_mode);
+}
+#endif
+
/*
* Winbond W83877F stuff
*
@@ -1162,6 +1254,9 @@
ppc_pc873xx_detect,
ppc_smc37c66xgt_detect,
ppc_w83877f_detect,
+ #ifdef __alpha__
+ ppc_smc37c935_detect,
+ #endif
ppc_generic_detect,
NULL
};
@@ -1747,7 +1842,7 @@
* There isn't a bios list on alpha. Put it in the usual place.
*/
if (error) {
- bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x3bc, IO_LPTSIZE);
+ bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x3bc, IO_LPTSIZE - 4);
}
#endif
@@ -1755,10 +1850,19 @@
ppc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
&ppc->rid_ioport, 0, ~0,
IO_LPTSIZE, RF_ACTIVE);
+ /* failed? try small IO port range */
if (ppc->res_ioport == 0) {
- device_printf(dev, "cannot reserve I/O port range\n");
- goto error;
+ ppc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
+ &ppc->rid_ioport, 0, ~0,
+ IO_LPTSIZE - 4, RF_ACTIVE);
+ if (ppc->res_ioport) {
+ device_printf(dev, "using small I/O port range\n");
+ } else {
+ device_printf(dev, "cannot reserve I/O port range\n");
+ goto error;
+ }
}
+
ppc->ppc_base = rman_get_start(ppc->res_ioport);
ppc->ppc_flags = device_get_flags(dev);
--- /sys/isa/ppcreg.h.orig Wed Jun 14 23:49:16 2000
+++ /sys/isa/ppcreg.h Tue Jun 20 17:53:15 2000
@@ -43,6 +43,9 @@
#define WINB_W83877AF 8
#define WINB_UNKNOWN 9
#define NS_PC87334 10
+#ifdef __alpha__
+#define SMC_37C935 11
+#endif
/*
* Parallel Port Chipset Type. SMC versus GENERIC (others)
@@ -204,6 +207,34 @@
#define SMC_EPPSPP 0x1 /* EPP and SPP */
#define SMC_ECP 0x2 /* ECP */
#define SMC_ECPEPP 0x3 /* ECP and EPP */
+
+#ifdef __alpha__
+/*
+ * Register defines for the SMC FDC37C935 parts
+ */
+
+/* Configuration ports */
+#define SMC935_CFG 0x370
+#define SMC935_IND 0x370
+#define SMC935_DAT 0x371
+
+/* Registers */
+#define SMC935_LOGDEV 0x7
+#define SMC935_ID 0x20
+#define SMC935_PORTHI 0x60
+#define SMC935_PORTLO 0x61
+#define SMC935_PPMODE 0xf0
+
+/* Parallel port modes */
+#define SMC935_SPP 0x38 + 0
+#define SMC935_EPP19SPP 0x38 + 1
+#define SMC935_ECP 0x38 + 2
+#define SMC935_ECPEPP19 0x38 + 3
+#define SMC935_CENT 0x38 + 4
+#define SMC935_EPP17SPP 0x38 + 5
+#define SMC935_UNUSED 0x38 + 6
+#define SMC935_ECPEPP17 0x38 + 7
+#endif
/*
* Register defines for the Winbond W83877F parts
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000620190629.C23157>
