lpt_jensenio.c revision 1.14
11.14Sthorpej/* $NetBSD: lpt_jensenio.c,v 1.14 2021/05/07 16:58:34 thorpej 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 *
191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sthorpej * POSSIBILITY OF SUCH DAMAGE.
301.1Sthorpej */
311.1Sthorpej
321.1Sthorpej#include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
331.1Sthorpej
341.14Sthorpej__KERNEL_RCSID(0, "$NetBSD: lpt_jensenio.c,v 1.14 2021/05/07 16:58:34 thorpej Exp $");
351.1Sthorpej
361.1Sthorpej#include <sys/param.h>
371.1Sthorpej#include <sys/systm.h>
381.1Sthorpej#include <sys/ioctl.h>
391.1Sthorpej#include <sys/select.h>
401.1Sthorpej#include <sys/tty.h>
411.1Sthorpej#include <sys/proc.h>
421.1Sthorpej#include <sys/conf.h>
431.1Sthorpej#include <sys/file.h>
441.1Sthorpej#include <sys/uio.h>
451.1Sthorpej#include <sys/kernel.h>
461.1Sthorpej#include <sys/syslog.h>
471.1Sthorpej#include <sys/types.h>
481.1Sthorpej#include <sys/device.h>
491.1Sthorpej
501.1Sthorpej#include <machine/intr.h>
511.11Sdyoung#include <sys/bus.h>
521.1Sthorpej
531.1Sthorpej#include <dev/ic/lptreg.h>
541.1Sthorpej#include <dev/ic/lptvar.h>
551.1Sthorpej
561.1Sthorpej#include <dev/eisa/eisavar.h>
571.1Sthorpej
581.1Sthorpej#include <dev/isa/isavar.h>
591.1Sthorpej
601.1Sthorpej#include <alpha/jensenio/jenseniovar.h>
611.1Sthorpej
621.1Sthorpejstruct lpt_jensenio_softc {
631.1Sthorpej	struct lpt_softc sc_lpt;	/* real "lpt" softc */
641.1Sthorpej
651.1Sthorpej	/* Jensen-specific goo. */
661.6Stsutsui	void	*sc_ih;			/* interrupt handler */
671.1Sthorpej};
681.1Sthorpej
691.14Sthorpejstatic int	lpt_jensenio_match(device_t, cfdata_t , void *);
701.14Sthorpejstatic void	lpt_jensenio_attach(device_t, device_t, void *);
711.1Sthorpej
721.8ScubeCFATTACH_DECL_NEW(lpt_jensenio, sizeof(struct lpt_jensenio_softc),
731.5Sthorpej    lpt_jensenio_match, lpt_jensenio_attach, NULL, NULL);
741.1Sthorpej
751.14Sthorpejstatic int
761.8Scubelpt_jensenio_match(device_t parent, cfdata_t match, void *aux)
771.1Sthorpej{
781.1Sthorpej	struct jensenio_attach_args *ja = aux;
791.1Sthorpej
801.1Sthorpej	/* Always present. */
811.3Sthorpej	if (strcmp(ja->ja_name, match->cf_name) == 0)
821.1Sthorpej		return (1);
831.1Sthorpej
841.1Sthorpej	return (0);
851.1Sthorpej}
861.1Sthorpej
871.14Sthorpejstatic void
881.8Scubelpt_jensenio_attach(device_t parent, device_t self, void *aux)
891.1Sthorpej{
901.8Scube	struct lpt_jensenio_softc *jsc = device_private(self);
911.1Sthorpej	struct lpt_softc *sc = &jsc->sc_lpt;
921.1Sthorpej	struct jensenio_attach_args *ja = aux;
931.6Stsutsui	const char *intrstr;
941.12Schristos	char buf[64];
951.1Sthorpej
961.8Scube	sc->sc_dev = self;
971.1Sthorpej	sc->sc_iot = ja->ja_iot;
981.1Sthorpej
991.1Sthorpej	if (bus_space_map(sc->sc_iot, ja->ja_ioaddr, LPT_NPORTS, 0,
1001.1Sthorpej	    &sc->sc_ioh) != 0) {
1011.8Scube		aprint_error(": can't map i/o space\n");
1021.1Sthorpej		return;
1031.1Sthorpej	}
1041.1Sthorpej
1051.8Scube	aprint_normal("\n");
1061.8Scube	aprint_naive("\n");
1071.1Sthorpej
1081.1Sthorpej	lpt_attach_subr(sc);
1091.1Sthorpej
1101.13Schristos	intrstr = eisa_intr_string(ja->ja_ec, ja->ja_irq[0],
1111.12Schristos	    buf, sizeof(buf));
1121.6Stsutsui	jsc->sc_ih = eisa_intr_establish(ja->ja_ec, ja->ja_irq[0],
1131.6Stsutsui	    IST_EDGE, IPL_TTY, lptintr, sc);
1141.6Stsutsui	if (jsc->sc_ih == NULL) {
1151.8Scube		aprint_error_dev(self, "unable to establish interrupt");
1161.6Stsutsui		if (intrstr != NULL)
1171.8Scube			aprint_error(" at %s", intrstr);
1181.8Scube		aprint_error("\n");
1191.6Stsutsui		return;
1201.6Stsutsui	}
1211.8Scube	aprint_normal_dev(self, "interrupting at %s\n", intrstr);
1221.1Sthorpej}
123