Index: conf/GENERIC =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/conf/GENERIC,v retrieving revision 1.95 diff -u -r1.95 GENERIC --- conf/GENERIC 22 Sep 2003 14:11:17 -0000 1.95 +++ conf/GENERIC 2 Nov 2003 16:32:56 -0000 @@ -174,7 +174,7 @@ # 8250-like serial ports found on Frodo ASIC #dnkbd0 at frodo? offset 0x0 # Domain keyboard flavor -apci* at frodo? offset ? # tty flavor +com* at frodo? offset ? # tty flavor dvbox* at intio? # Davinci framebuffer dvbox* at dio? scode ? @@ -199,8 +199,7 @@ ite* at grf? # Internal Terminal Emulator -dca0 at dio? scode 9 flags 1 # DCA serial interfaces -dca* at dio? scode ? +com* at dio? scode ? # DCA serial interfaces dcm* at dio? scode ? flags 0xe # DCM 4- or 8-port serial interfaces Index: conf/files.hp300 =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/conf/files.hp300,v retrieving revision 1.68 diff -u -r1.68 files.hp300 --- conf/files.hp300 1 Aug 2003 01:18:47 -0000 1.68 +++ conf/files.hp300 2 Nov 2003 16:32:56 -0000 @@ -68,9 +68,8 @@ file arch/hp300/dev/frodo.c frodo # Apollo APCI 8250-like UARTs -device apci: tty -attach apci at frodo -file arch/hp300/dev/apci.c apci needs-flag +attach com at frodo with com_frodo +file arch/hp300/dev/com_frodo.c com_frodo needs-flag # Frame buffer attribute define grfdev { } @@ -121,9 +120,8 @@ attach topcat at dio with topcat_dio # DCA serial interface -device dca: tty -attach dca at dio -file arch/hp300/dev/dca.c dca needs-flag +attach com at dio with com_dio +file arch/hp300/dev/com_dio.c com_dio needs-flag # DCM serial interface device dcm: tty Index: conf/majors.hp300 =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/conf/majors.hp300,v retrieving revision 1.12 diff -u -r1.12 majors.hp300 --- conf/majors.hp300 24 Oct 2003 08:09:53 -0000 1.12 +++ conf/majors.hp300 2 Nov 2003 16:32:56 -0000 @@ -15,7 +15,7 @@ device-major rd char 9 block 2 rd device-major grf char 10 grf device-major ppi char 11 ppi -device-major dca char 12 dca +device-major com char 12 com device-major ite char 13 ite device-major hil char 14 device-major dcm char 15 dcm @@ -29,7 +29,7 @@ device-major tun char 23 tun device-major lkm char 24 lkm -device-major apci char 31 apci +# device major 31 was apci (superseded by MI com) device-major md char 32 block 14 md device-major rnd char 33 rnd device-major scsibus char 34 scsibus Index: dev/frodo.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/dev/frodo.c,v retrieving revision 1.14 diff -u -r1.14 frodo.c --- dev/frodo.c 1 Jan 2003 01:34:45 -0000 1.14 +++ dev/frodo.c 2 Nov 2003 16:32:56 -0000 @@ -77,6 +77,7 @@ #include #include +#include #include #include #include @@ -102,6 +103,7 @@ int sc_ipl; void *sc_ih; /* out interrupt cookie */ int sc_refcnt; /* number of interrupt refs */ + struct bus_space_tag sc_tag; /* bus space tag */ }; int frodomatch __P((struct device *, struct cfdata *, void *)); @@ -117,7 +119,7 @@ CFATTACH_DECL(frodo, sizeof(struct frodo_softc), frodomatch, frodoattach, NULL, NULL); -struct frodo_attach_args frodo_subdevs[] = { +struct frodo_device frodo_subdevs[] = { { "dnkbd", FRODO_APCI_OFFSET(0), FRODO_INTR_APCI0 }, { "apci", FRODO_APCI_OFFSET(1), FRODO_INTR_APCI1 }, { "apci", FRODO_APCI_OFFSET(2), FRODO_INTR_APCI2 }, @@ -155,7 +157,9 @@ { struct frodo_softc *sc = (struct frodo_softc *)self; struct intio_attach_args *ia = aux; - int i; + bus_space_tag_t bst = &sc->sc_tag; + struct frodo_device *fd; + struct frodo_attach_args fa; sc->sc_regs = (volatile u_int8_t *)ia->ia_addr; sc->sc_ipl = ia->ia_ipl; @@ -164,6 +168,9 @@ printf(": service mode enabled"); printf("\n"); + /* Initialize bus_space_tag_t for frodo */ + frodo_init_bus_space(bst); + /* Clear all of the interrupt handlers. */ memset(sc->sc_intr, 0, sizeof(sc->sc_intr)); sc->sc_refcnt = 0; @@ -191,17 +198,21 @@ sc->sc_ih = NULL; /* ... and attach subdevices. */ - for (i = 0; frodo_subdevs[i].fa_name != NULL; i++) { + for (fd = frodo_subdevs; fd->fd_name != NULL; fd++) { /* * Skip the first serial port if we're not a 425e; * it's mapped to the DCA at select code 9 on all * other models. */ - if (frodo_subdevs[i].fa_offset == FRODO_APCI_OFFSET(1) && + if (fd->fd_offset == FRODO_APCI_OFFSET(1) && mmuid != MMUID_425_E) continue; - config_found_sm(self, &frodo_subdevs[i], - frodoprint, frodosubmatch); + fa.fa_name = fd->fd_name; + fa.fa_bst = bst; + fa.fa_base = FRODO_BASE; + fa.fa_offset = fd->fd_offset; + fa.fa_line = fd->fd_line; + config_found_sm(self, &fa, frodoprint, frodosubmatch); } } @@ -358,4 +369,202 @@ imask &= ~clear; FRODO_SETMASK(sc, imask); +} + +/* + * frodo chip specific bus_space(9) support functions. + */ +static u_int8_t frodo_bus_space_read_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t)); +static void frodo_bus_space_write_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, u_int8_t)); + +static void frodo_bus_space_read_multi_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t)); +static void frodo_bus_space_write_multi_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t)); + +static void frodo_bus_space_read_region_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t)); +static void frodo_bus_space_write_region_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t)); + +static void frodo_bus_space_set_multi_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t)); + +static void frodo_bus_space_set_region_sparse_1 __P((bus_space_tag_t, + bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t)); + +/* + * frodo_init_bus_space(): + * Initialize bus_space functions in bus_space_tag_t + * for frodo devices which have sparse address space. + */ +void +frodo_init_bus_space(bst) + bus_space_tag_t bst; +{ + + memset(bst, 0, sizeof(struct bus_space_tag)); + bst->bustype = HP300_BUS_SPACE_INTIO; + + bst->bsr1 = frodo_bus_space_read_sparse_1; + bst->bsw1 = frodo_bus_space_write_sparse_1; + + bst->bsrm1 = frodo_bus_space_read_multi_sparse_1; + bst->bswm1 = frodo_bus_space_write_multi_sparse_1; + + bst->bsrr1 = frodo_bus_space_read_region_sparse_1; + bst->bswr1 = frodo_bus_space_write_region_sparse_1; + + bst->bssm1 = frodo_bus_space_set_multi_sparse_1; + + bst->bssr1 = frodo_bus_space_set_region_sparse_1; +} + +static u_int8_t +frodo_bus_space_read_sparse_1(bst, bsh, offset) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; +{ + + return *(volatile u_int8_t *)(bsh + (offset << 2)); +} + +static void frodo_bus_space_write_sparse_1(bst, bsh, offset, val) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t val; +{ + + *(volatile u_int8_t *)(bsh + (offset << 2)) = val; +} + +static void +frodo_bus_space_read_multi_sparse_1(bst, bsh, offset, addr, len) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t *addr; + bus_size_t len; +{ + + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%a1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%a0@,%%a1@+ ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (addr), "g" (len) + : "%a0","%a1","%d0"); +} + +static void +frodo_bus_space_write_multi_sparse_1(bst, bsh, offset, addr, len) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + const u_int8_t *addr; + bus_size_t len; +{ + + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%a1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%a1@+,%%a0@ ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (addr), "g" (len) + : "%a0","%a1","%d0"); +} + +static void +frodo_bus_space_read_region_sparse_1(bst, bsh, offset, addr, len) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t *addr; + bus_size_t len; +{ + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%a1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%a0@,%%a1@+ ;\n" + " addql #4,%%a0 ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (addr), "g" (len) + : "%a0","%a1","%d0"); +} + +static void +frodo_bus_space_write_region_sparse_1(bst, bsh, offset, addr, len) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + const u_int8_t *addr; + bus_size_t len; +{ + + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%a1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%a1@+,%%a0@ ;\n" + " addql #4,%%a0 ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (addr), "g" (len) + : "%a0","%a1","%d0"); +} + +static void +frodo_bus_space_set_multi_sparse_1(bst, bsh, offset, val, count) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t val; + bus_size_t count; +{ + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%d1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%d1,%%a0@ ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (val), "g" (count) + : "%a0","%d0","%d1"); +} + +static void +frodo_bus_space_set_region_sparse_1(bst, bsh, offset, val, count) + bus_space_tag_t bst; + bus_space_handle_t bsh; + bus_size_t offset; + u_int8_t val; + bus_size_t count; +{ + + __asm __volatile ( + " movl %0,%%a0 ;\n" + " movl %1,%%d1 ;\n" + " movl %2,%%d0 ;\n" + "1: movb %%d1,%%a0@ ;\n" + " addql #4,%%a0 ;\n" + " subql #1,%%d0 ;\n" + " jne 1b" + : + : "r" (bsh + (offset << 2)), "g" (val), "g" (count) + : "%a0","%d0","%d1"); } Index: dev/frodovar.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/dev/frodovar.h,v retrieving revision 1.4 diff -u -r1.4 frodovar.h --- dev/frodovar.h 4 Oct 1997 09:59:53 -0000 1.4 +++ dev/frodovar.h 2 Nov 2003 16:32:56 -0000 @@ -71,10 +71,21 @@ */ struct frodo_attach_args { const char *fa_name; /* device name */ + bus_space_tag_t fa_bst; /* bus space tag */ + int fa_base; /* Frodo base address */ int fa_offset; /* offset from Frodo base */ int fa_line; /* Frodo interrupt line */ }; +/* + * Structure used to describe a device for autoconfiguration purposes. + */ +struct frodo_device { + const char *fd_name; /* device name */ + int fd_offset; /* offset from Frodo base */ + int fd_line; /* Frodo interrupt line */ +}; + #include "locators.h" #define frodocf_offset cf_loc[FRODOCF_OFFSET] #define FRODO_UNKNOWN_OFFSET FRODOCF_OFFSET_DEFAULT @@ -82,3 +93,4 @@ void frodo_intr_establish __P((struct device *, int (*func)(void *), void *, int, int)); void frodo_intr_disestablish __P((struct device *, int)); +void frodo_init_bus_space __P((bus_space_tag_t)); Index: hp300/autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/hp300/autoconf.c,v retrieving revision 1.66 diff -u -r1.66 autoconf.c --- hp300/autoconf.c 7 Aug 2003 16:27:35 -0000 1.66 +++ hp300/autoconf.c 2 Nov 2003 16:32:56 -0000 @@ -152,9 +152,9 @@ #include "rbox.h" #include "rbox.h" #include "topcat.h" -#include "dca.h" +#include "com_dio.h" +#include "com_frodo.h" #include "dcm.h" -#include "apci.h" #include "ite.h" #include @@ -198,11 +198,15 @@ #include +#if NCOM_DIO > 0 +#include +#endif +#if NCOM_FRODO > 0 +#include +#endif /* should go away with a cleanup */ -extern int dcacnattach(bus_space_tag_t, bus_addr_t, int); extern int dcmcnattach(bus_space_tag_t, bus_addr_t, int); -extern int apcicnattach(bus_space_tag_t, bus_addr_t, int); extern int dvboxcnattach(bus_space_tag_t, bus_addr_t, int); extern int gboxcnattach(bus_space_tag_t, bus_addr_t, int); extern int rboxcnattach(bus_space_tag_t, bus_addr_t, int); @@ -829,12 +833,12 @@ /* * Look for serial consoles first. */ -#if NAPCI > 0 - if (!apcicnattach(bst, 0x1c020, -1)) +#if NCOM_FRODO > 0 + if (!com_frodo_cnattach(bst, 0x1c020, -1)) return; #endif -#if NDCA > 0 - if (!dio_scan(dcacnattach)) +#if NCOM_DIO > 0 + if (!dio_scan(com_dio_cnattach)) return; #endif #if NDCM > 0 Index: include/intr.h =================================================================== RCS file: /cvsroot/src/sys/arch/hp300/include/intr.h,v retrieving revision 1.12 diff -u -r1.12 intr.h --- include/intr.h 8 Dec 2001 04:09:19 -0000 1.12 +++ include/intr.h 2 Nov 2003 16:32:57 -0000 @@ -109,6 +109,7 @@ #define splbio() _splraise(hp300_ipls[HP300_IPL_BIO]) #define splnet() _splraise(hp300_ipls[HP300_IPL_NET]) #define spltty() _splraise(hp300_ipls[HP300_IPL_TTY]) +#define splserial() _splraise(hp300_ipls[HP300_IPL_TTY]) #define splvm() _splraise(hp300_ipls[HP300_IPL_VM]) #define splclock() spl6() #define splstatclock() splclock() --- /dev/null 2003-11-03 00:07:10.000000000 +0900 +++ dev/com_dio.c 2003-08-30 01:31:00.000000000 +0900 @@ -0,0 +1,216 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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. + */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * 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. + * 3. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)com.c 7.5 (Berkeley) 5/16/91 + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +struct com_dio_softc { + struct com_softc sc_com; /* real "com" softc */ + + /* DIO-specific goo. */ + struct bus_space_tag sc_tag; /* device specific bus space tag */ + void *sc_ih; /* interrupt handler */ +}; + +int com_dio_match(struct device *, struct cfdata *, void *); +void com_dio_attach(struct device *, struct device *, void *); + +CFATTACH_DECL(com_dio, sizeof(struct com_dio_softc), + com_dio_match, com_dio_attach, NULL, NULL); + +static int com_dio_speed = TTYDEF_SPEED; +static struct bus_space_tag comcntag; + +#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ + +int +com_dio_match(struct device *parent, struct cfdata *match, void *aux) +{ + struct dio_attach_args *da = aux; + + switch (da->da_id) { + case DIO_DEVICE_ID_DCA0: + case DIO_DEVICE_ID_DCA0REM: + case DIO_DEVICE_ID_DCA1: + case DIO_DEVICE_ID_DCA1REM: + return 1; + } + + return 0; +} + +void +com_dio_attach(struct device *parent, struct device *self, void *aux) +{ + struct com_dio_softc *dsc = (struct com_dio_softc *)self; + struct com_softc *sc = &dsc->sc_com; + bus_space_tag_t iot; + bus_space_handle_t iohdca, iohcom; + struct dio_attach_args *da = aux; + int isconsole; + + isconsole = com_is_console(&comcntag, da->da_addr + DCA_COM_OFFSET, + &iohcom); + + if (isconsole) { + iot = &comcntag; + bus_space_unmap(iot, iohcom, COM_NPORTS); + } else { + iot = &dsc->sc_tag; + memcpy(iot, da->da_bst, sizeof(struct bus_space_tag)); + dio_set_bus_space_oddbyte(iot); + } + + if (bus_space_map(iot, da->da_addr, DCA_SIZE, 0, &iohdca) || + bus_space_subregion(iot, iohdca, DCA_COM_OFFSET, + COM_NPORTS << 1, &iohcom)) { + printf(": can't map i/o space\n"); + return; + } + + if (!isconsole) { + bus_space_write_1(iot, iohdca, DCA_RESET, 0xff); + DELAY(1000); + } + + sc->sc_iot = iot; + sc->sc_ioh = iohcom; + sc->sc_iobase = da->da_addr + DCA_COM_OFFSET; + sc->sc_frequency = COM_DIO_FREQ; + + com_attach_subr(sc); + + dsc->sc_ih = dio_intr_establish(comintr, sc, da->da_ipl, + ((sc->sc_hwflags & COM_HW_FIFO) != 0) ? IPL_TTY : IPL_TTYNOBUF); + + /* Enable interrupts. */ + bus_space_write_1(iot, iohdca, DCA_IC, IC_IE); +} + +int +com_dio_cnattach(bus_space_tag_t bst, bus_addr_t addr, int scode) +{ + bus_space_tag_t iot = &comcntag; + bus_space_handle_t iohdca; + u_int8_t id; + + memcpy(iot, bst, sizeof(struct bus_space_tag)); + dio_set_bus_space_oddbyte(iot); + + if (bus_space_map(iot, addr, DCA_SIZE, 0, &iohdca)) + return 1; + bus_space_write_1(iot, iohdca, DCA_RESET, 0xff); + DELAY(100); + bus_space_write_1(iot, iohdca, DCA_IC, IC_IE); + + id = bus_space_read_1(iot, iohdca, DCA_ID); + bus_space_unmap(iot, iohdca, DCA_SIZE); + + switch (id) { +#ifdef CONSCODE + case DCAID0: + case DCAID1: +#endif + case DCAREMID0: + case DCAREMID1: + break; + default: + return 1; + } + + comcnattach(iot, addr + DCA_COM_OFFSET, com_dio_speed, COM_DIO_FREQ, + COM_TYPE_NORMAL, CONMODE); + + return 0; +} --- /dev/null 2003-11-03 00:07:10.000000000 +0900 +++ dev/com_dioreg.h 2003-08-30 01:31:00.000000000 +0900 @@ -0,0 +1,58 @@ +/* $NetBSD$ */ + +/* + * Copyright (c) 1982, 1986, 1990, 1993 + * The Regents of the University of California. 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. + * 3. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)dcareg.h 8.1 (Berkeley) 6/10/93 + */ + + +/* interface reset/id */ +#define DCA_ID 0x00 /* read */ +#define DCAID0 0x02 +#define DCAREMID0 0x82 +#define DCAID1 0x42 +#define DCAREMID1 0xC2 + +#define DCA_RESET 0x00 /* write */ + +/* interrupt control */ +#define DCA_IC 0x01 +#define DCAIPL(x) ((((x) >> 4) & 3) + 3) +#define IC_IR 0x40 +#define IC_IE 0x80 + +#define DCA_OCBRC 0x02 + +#define DCA_LCSM 0x03 + +#define DCA_SIZE 0x20 /* XXX */ +#define DCA_COM_OFFSET 0x10 /* XXX */ + +/* clock frequency */ +#define COM_DIO_FREQ 2457600 --- /dev/null 2003-11-03 00:07:10.000000000 +0900 +++ dev/com_diovar.h 2003-08-30 01:31:00.000000000 +0900 @@ -0,0 +1,29 @@ +/* $NetBSD$ */ +/* + * Copyright (c) 2003 Izumi Tsutsui. + * 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. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + */ + +int com_dio_cnattach(bus_space_tag_t, bus_addr_t, int); --- /dev/null 2003-11-03 00:07:10.000000000 +0900 +++ dev/com_frodo.c 2003-08-30 01:31:00.000000000 +0900 @@ -0,0 +1,188 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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. + */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * 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. + * 3. Neither the name of the University 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 REGENTS 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 REGENTS 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. + * + * @(#)com.c 7.5 (Berkeley) 5/16/91 + */ + +#include +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include +#include +#include + +#include "ioconf.h" + +struct com_frodo_softc { + struct com_softc sc_com; /* real "com" softc */ +}; + +int com_frodo_match(struct device *, struct cfdata *, void *); +void com_frodo_attach(struct device *, struct device *, void *); + +CFATTACH_DECL(com_frodo, sizeof(struct com_frodo_softc), + com_frodo_match, com_frodo_attach, NULL, NULL); + +static int com_frodo_speed = TTYDEF_SPEED; +static struct bus_space_tag comcntag; + +#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ +#define COM_FRODO_FREQ 8006400 + +int +com_frodo_match(struct device *parent, struct cfdata *match, void *aux) +{ + struct frodo_attach_args *fa = aux; + + if (strcmp(fa->fa_name, com_cd.cd_name) != 0) + return 0; + + switch (fa->fa_offset) { + case FRODO_APCI_OFFSET(1): + case FRODO_APCI_OFFSET(2): + case FRODO_APCI_OFFSET(3): + return 1; + } + + return 0; +} + +void +com_frodo_attach(struct device *parent, struct device *self, void *aux) +{ + struct com_frodo_softc *fsc = (struct com_frodo_softc *)self; + struct com_softc *sc = &fsc->sc_com; + struct frodo_attach_args *fa = aux; + bus_space_tag_t iot; + bus_space_handle_t ioh; + int isconsole; + + isconsole = com_is_console(&comcntag, fa->fa_base + fa->fa_offset, + &ioh); + + if (isconsole) + iot = &comcntag; + else + iot = fa->fa_bst; + + if (!isconsole && + bus_space_map(iot, fa->fa_base + fa->fa_offset, COM_NPORTS << 2, + 0, &ioh)) { + printf(": can't map i/o space\n"); + return; + } + + sc->sc_iot = iot; + sc->sc_ioh = ioh; + sc->sc_iobase = fa->fa_base + fa->fa_offset; + sc->sc_frequency = COM_FRODO_FREQ; + + com_attach_subr(sc); + + frodo_intr_establish(parent, comintr, sc, fa->fa_line, + ((sc->sc_hwflags & COM_HW_FIFO) != 0) ? IPL_TTY : IPL_TTYNOBUF); +} + +int +com_frodo_cnattach(bus_space_tag_t bst, bus_addr_t addr, int scode) +{ + bus_space_tag_t iot = &comcntag; + bus_space_handle_t ioh; + + if (machineid != HP_425 || mmuid != MMUID_425_E) + return 1; + + frodo_init_bus_space(iot); + + if (bus_space_map(iot, addr, INTIO_DEVSIZE, BUS_SPACE_MAP_LINEAR, &ioh)) + return 1; + + comcnattach(iot, addr, com_frodo_speed, COM_FRODO_FREQ, + COM_TYPE_NORMAL, CONMODE); + + return 0; +} --- /dev/null 2003-11-03 00:07:10.000000000 +0900 +++ dev/com_frodovar.h 2003-08-30 01:31:00.000000000 +0900 @@ -0,0 +1,29 @@ +/* $NetBSD$ */ +/* + * Copyright (c) 2003 Izumi Tsutsui. + * 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. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. + */ + +int com_frodo_cnattach(bus_space_tag_t, bus_addr_t, int);