lpt_pnpbios.c revision 1.13
11.13Smsaitoh/* $NetBSD: lpt_pnpbios.c,v 1.13 2016/07/14 10:19:05 msaitoh 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.13Smsaitoh__KERNEL_RCSID(0, "$NetBSD: lpt_pnpbios.c,v 1.13 2016/07/14 10:19:05 msaitoh 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.12Sdyoung#include <sys/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.11Scubeint lpt_pnpbios_match(device_t, cfdata_t, void *);
541.11Scubevoid lpt_pnpbios_attach(device_t, device_t, void *);
551.1Sthorpej
561.11ScubeCFATTACH_DECL_NEW(lpt_pnpbios, sizeof(struct lpt_pnpbios_softc),
571.6Sthorpej    lpt_pnpbios_match, lpt_pnpbios_attach, NULL, NULL);
581.1Sthorpej
591.1Sthorpejint
601.11Scubelpt_pnpbios_match(device_t parent, cfdata_t match, void *aux)
611.1Sthorpej{
621.1Sthorpej	struct pnpbiosdev_attach_args *aa = aux;
631.1Sthorpej
641.2Ssoren	if (strcmp(aa->idstr, "PNP0400") &&
651.2Ssoren	    strcmp(aa->idstr, "PNP0401"))
661.1Sthorpej		return (0);
671.1Sthorpej
681.1Sthorpej	return (1);
691.1Sthorpej}
701.1Sthorpej
711.1Sthorpejvoid
721.11Scubelpt_pnpbios_attach(device_t parent, device_t self, void *aux)
731.1Sthorpej{
741.11Scube	struct lpt_pnpbios_softc *psc = device_private(self);
751.1Sthorpej	struct lpt_softc *sc = &psc->sc_lpt;
761.1Sthorpej	struct pnpbiosdev_attach_args *aa = aux;
771.1Sthorpej
781.11Scube	sc->sc_dev = self;
791.11Scube
801.13Smsaitoh	aprint_naive("\n");
811.13Smsaitoh	if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
821.13Smsaitoh		aprint_error(": can't map i/o space\n");
831.1Sthorpej		return;
841.1Sthorpej	}
851.1Sthorpej
861.13Smsaitoh	aprint_normal("\n");
871.1Sthorpej	pnpbios_print_devres(self, aa);
881.1Sthorpej
891.1Sthorpej	lpt_attach_subr(sc);
901.1Sthorpej
911.1Sthorpej	sc->sc_ih = pnpbios_intr_establish(aa->pbt, aa->resc, 0, IPL_TTY,
921.1Sthorpej					    lptintr, sc);
931.1Sthorpej}
94