lpt_jensenio.c revision 1.6
11.6Stsutsui/* $NetBSD: lpt_jensenio.c,v 1.6 2007/07/19 12:58:29 tsutsui Exp $ */
21.1Sthorpej
31.1Sthorpej/*-
41.1Sthorpej * Copyright (c) 1999 The NetBSD Foundation, Inc.
51.1Sthorpej * All rights reserved.
61.1Sthorpej *
71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation
81.1Sthorpej * by Jason R. Thorpe.
91.1Sthorpej *
101.1Sthorpej * Redistribution and use in source and binary forms, with or without
111.1Sthorpej * modification, are permitted provided that the following conditions
121.1Sthorpej * are met:
131.1Sthorpej * 1. Redistributions of source code must retain the above copyright
141.1Sthorpej *    notice, this list of conditions and the following disclaimer.
151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
161.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
171.1Sthorpej *    documentation and/or other materials provided with the distribution.
181.1Sthorpej * 3. All advertising materials mentioning features or use of this software
191.1Sthorpej *    must display the following acknowledgement:
201.1Sthorpej *	This product includes software developed by the NetBSD
211.1Sthorpej *	Foundation, Inc. and its contributors.
221.1Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
231.1Sthorpej *    contributors may be used to endorse or promote products derived
241.1Sthorpej *    from this software without specific prior written permission.
251.1Sthorpej *
261.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
271.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
281.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
291.1Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
301.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
311.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
321.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
331.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
341.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
351.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
361.1Sthorpej * POSSIBILITY OF SUCH DAMAGE.
371.1Sthorpej */
381.1Sthorpej
391.1Sthorpej#include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
401.1Sthorpej
411.6Stsutsui__KERNEL_RCSID(0, "$NetBSD: lpt_jensenio.c,v 1.6 2007/07/19 12:58:29 tsutsui Exp $");
421.1Sthorpej
431.1Sthorpej#include <sys/param.h>
441.1Sthorpej#include <sys/systm.h>
451.1Sthorpej#include <sys/ioctl.h>
461.1Sthorpej#include <sys/select.h>
471.1Sthorpej#include <sys/tty.h>
481.1Sthorpej#include <sys/proc.h>
491.1Sthorpej#include <sys/user.h>
501.1Sthorpej#include <sys/conf.h>
511.1Sthorpej#include <sys/file.h>
521.1Sthorpej#include <sys/uio.h>
531.1Sthorpej#include <sys/kernel.h>
541.1Sthorpej#include <sys/syslog.h>
551.1Sthorpej#include <sys/types.h>
561.1Sthorpej#include <sys/device.h>
571.1Sthorpej
581.1Sthorpej#include <machine/intr.h>
591.1Sthorpej#include <machine/bus.h>
601.1Sthorpej
611.1Sthorpej#include <dev/ic/lptreg.h>
621.1Sthorpej#include <dev/ic/lptvar.h>
631.1Sthorpej
641.1Sthorpej#include <dev/eisa/eisavar.h>
651.1Sthorpej
661.1Sthorpej#include <dev/isa/isavar.h>
671.1Sthorpej
681.1Sthorpej#include <alpha/jensenio/jenseniovar.h>
691.1Sthorpej
701.1Sthorpejstruct lpt_jensenio_softc {
711.1Sthorpej	struct lpt_softc sc_lpt;	/* real "lpt" softc */
721.1Sthorpej
731.1Sthorpej	/* Jensen-specific goo. */
741.6Stsutsui	void	*sc_ih;			/* interrupt handler */
751.1Sthorpej};
761.1Sthorpej
771.1Sthorpejint	lpt_jensenio_match(struct device *, struct cfdata *, void *);
781.1Sthorpejvoid	lpt_jensenio_attach(struct device *, struct device *, void *);
791.1Sthorpej
801.5SthorpejCFATTACH_DECL(lpt_jensenio, sizeof(struct lpt_jensenio_softc),
811.5Sthorpej    lpt_jensenio_match, lpt_jensenio_attach, NULL, NULL);
821.1Sthorpej
831.1Sthorpejint
841.1Sthorpejlpt_jensenio_match(struct device *parent, struct cfdata *match, void *aux)
851.1Sthorpej{
861.1Sthorpej	struct jensenio_attach_args *ja = aux;
871.1Sthorpej
881.1Sthorpej	/* Always present. */
891.3Sthorpej	if (strcmp(ja->ja_name, match->cf_name) == 0)
901.1Sthorpej		return (1);
911.1Sthorpej
921.1Sthorpej	return (0);
931.1Sthorpej}
941.1Sthorpej
951.1Sthorpejvoid
961.1Sthorpejlpt_jensenio_attach(struct device *parent, struct device *self, void *aux)
971.1Sthorpej{
981.1Sthorpej	struct lpt_jensenio_softc *jsc = (void *)self;
991.1Sthorpej	struct lpt_softc *sc = &jsc->sc_lpt;
1001.1Sthorpej	struct jensenio_attach_args *ja = aux;
1011.6Stsutsui	const char *intrstr;
1021.1Sthorpej
1031.1Sthorpej	sc->sc_iot = ja->ja_iot;
1041.1Sthorpej
1051.1Sthorpej	if (bus_space_map(sc->sc_iot, ja->ja_ioaddr, LPT_NPORTS, 0,
1061.1Sthorpej	    &sc->sc_ioh) != 0) {
1071.1Sthorpej		printf(": can't map i/o space\n");
1081.1Sthorpej		return;
1091.1Sthorpej	}
1101.1Sthorpej
1111.1Sthorpej	printf("\n");
1121.1Sthorpej
1131.1Sthorpej	lpt_attach_subr(sc);
1141.1Sthorpej
1151.6Stsutsui	intrstr = eisa_intr_string(ja->ja_ec, ja->ja_irq[0]);
1161.6Stsutsui	jsc->sc_ih = eisa_intr_establish(ja->ja_ec, ja->ja_irq[0],
1171.6Stsutsui	    IST_EDGE, IPL_TTY, lptintr, sc);
1181.6Stsutsui	if (jsc->sc_ih == NULL) {
1191.6Stsutsui		printf("%s: unable to establish interrupt",
1201.6Stsutsui		    sc->sc_dev.dv_xname);
1211.6Stsutsui		if (intrstr != NULL)
1221.6Stsutsui			printf(" at %s", intrstr);
1231.6Stsutsui		printf("\n");
1241.6Stsutsui		return;
1251.6Stsutsui	}
1261.6Stsutsui	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
1271.1Sthorpej}
128