lpt_pnpbios.c revision 1.6
11.6Sthorpej/* $NetBSD: lpt_pnpbios.c,v 1.6 2002/10/02 05:47:17 thorpej Exp $ */
21.1Sthorpej/*
31.1Sthorpej * Copyright (c) 1999
41.1Sthorpej * 	Matthias Drochner.  All rights reserved.
51.1Sthorpej *
61.1Sthorpej * Redistribution and use in source and binary forms, with or without
71.1Sthorpej * modification, are permitted provided that the following conditions
81.1Sthorpej * are met:
91.1Sthorpej * 1. Redistributions of source code must retain the above copyright
101.1Sthorpej *    notice, this list of conditions, and the following disclaimer.
111.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
121.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
131.1Sthorpej *    documentation and/or other materials provided with the distribution.
141.1Sthorpej *
151.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
161.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
171.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
181.1Sthorpej * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
191.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
201.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
211.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
221.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
231.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
241.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
251.1Sthorpej * SUCH DAMAGE.
261.1Sthorpej */
271.3Slukem
281.3Slukem#include <sys/cdefs.h>
291.6Sthorpej__KERNEL_RCSID(0, "$NetBSD: lpt_pnpbios.c,v 1.6 2002/10/02 05:47:17 thorpej Exp $");
301.1Sthorpej
311.1Sthorpej#include <sys/param.h>
321.1Sthorpej#include <sys/systm.h>
331.1Sthorpej#include <sys/errno.h>
341.1Sthorpej#include <sys/ioctl.h>
351.1Sthorpej#include <sys/syslog.h>
361.1Sthorpej#include <sys/device.h>
371.1Sthorpej#include <sys/proc.h>
381.1Sthorpej#include <sys/termios.h>
391.1Sthorpej
401.1Sthorpej#include <machine/bus.h>
411.1Sthorpej
421.1Sthorpej#include <dev/isa/isavar.h>
431.1Sthorpej#include <dev/isa/isadmavar.h>
441.1Sthorpej
451.1Sthorpej#include <i386/pnpbios/pnpbiosvar.h>
461.1Sthorpej
471.1Sthorpej#include <dev/ic/lptvar.h>
481.1Sthorpej
491.1Sthorpejstruct lpt_pnpbios_softc {
501.1Sthorpej	struct	lpt_softc sc_lpt;
511.1Sthorpej};
521.1Sthorpej
531.1Sthorpejint lpt_pnpbios_match __P((struct device *, struct cfdata *, void *));
541.1Sthorpejvoid lpt_pnpbios_attach __P((struct device *, struct device *, void *));
551.1Sthorpej
561.6SthorpejCFATTACH_DECL(lpt_pnpbios, sizeof(struct lpt_pnpbios_softc),
571.6Sthorpej    lpt_pnpbios_match, lpt_pnpbios_attach, NULL, NULL);
581.1Sthorpej
591.1Sthorpejint
601.1Sthorpejlpt_pnpbios_match(parent, match, aux)
611.1Sthorpej	struct device *parent;
621.1Sthorpej	struct cfdata *match;
631.1Sthorpej	void *aux;
641.1Sthorpej{
651.1Sthorpej	struct pnpbiosdev_attach_args *aa = aux;
661.1Sthorpej
671.2Ssoren	if (strcmp(aa->idstr, "PNP0400") &&
681.2Ssoren	    strcmp(aa->idstr, "PNP0401"))
691.1Sthorpej		return (0);
701.1Sthorpej
711.1Sthorpej	return (1);
721.1Sthorpej}
731.1Sthorpej
741.1Sthorpejvoid
751.1Sthorpejlpt_pnpbios_attach(parent, self, aux)
761.1Sthorpej	struct device *parent, *self;
771.1Sthorpej	void *aux;
781.1Sthorpej{
791.1Sthorpej	struct lpt_pnpbios_softc *psc = (void *)self;
801.1Sthorpej	struct lpt_softc *sc = &psc->sc_lpt;
811.1Sthorpej	struct pnpbiosdev_attach_args *aa = aux;
821.1Sthorpej
831.1Sthorpej	if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
841.1Sthorpej		printf(": can't map i/o space\n");
851.1Sthorpej		return;
861.1Sthorpej	}
871.1Sthorpej
881.1Sthorpej	printf("\n");
891.1Sthorpej	pnpbios_print_devres(self, aa);
901.1Sthorpej
911.1Sthorpej	lpt_attach_subr(sc);
921.1Sthorpej
931.1Sthorpej	sc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_TTY,
941.1Sthorpej					    lptintr, sc);
951.1Sthorpej}
96