Home | History | Annotate | Line # | Download | only in dev
      1 /*	$NetBSD: phantomas.c,v 1.3 2021/08/07 16:18:55 thorpej Exp $	*/
      2 /*	$OpenBSD: phantomas.c,v 1.1 2002/12/18 23:52:45 mickey Exp $	*/
      3 
      4 /*
      5  * Copyright (c) 2002 Michael Shalayeff
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  *
     17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
     21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     23  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     25  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     26  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     27  * THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #include <sys/param.h>
     31 #include <sys/systm.h>
     32 #include <sys/device.h>
     33 
     34 #include <machine/iomod.h>
     35 #include <machine/autoconf.h>
     36 
     37 #include <hppa/dev/cpudevs.h>
     38 
     39 struct phantomas_softc {
     40 	device_t sc_dev;
     41 };
     42 
     43 int	phantomasmatch(device_t, cfdata_t, void *);
     44 void	phantomasattach(device_t, device_t, void *);
     45 static device_t phantomas_callback(device_t self, struct confargs *ca);
     46 
     47 CFATTACH_DECL_NEW(phantomas, sizeof(struct phantomas_softc),
     48     phantomasmatch, phantomasattach, NULL, NULL);
     49 
     50 int
     51 phantomasmatch(device_t parent, cfdata_t cfdata, void *aux)
     52 {
     53 	struct confargs *ca = aux;
     54 
     55 	if (ca->ca_type.iodc_type != HPPA_TYPE_BCPORT ||
     56 	    ca->ca_type.iodc_sv_model != HPPA_BCPORT_PHANTOM) {
     57 		return (0);
     58 	}
     59 	return (1);
     60 }
     61 
     62 void
     63 phantomasattach(device_t parent, device_t self, void *aux)
     64 {
     65 	struct phantomas_softc *sc = device_private(self);
     66 	struct confargs *ca = aux, nca;
     67 
     68 	sc->sc_dev = self;
     69 	nca = *ca;
     70 	nca.ca_hpabase = 0;
     71 	nca.ca_nmodules = MAXMODBUS;
     72 
     73 	aprint_normal("\n");
     74 	pdc_scanbus(self, &nca, phantomas_callback);
     75 }
     76 
     77 static device_t
     78 phantomas_callback(device_t self, struct confargs *ca)
     79 {
     80 
     81 	return config_found(self, ca, mbprint,
     82 	    CFARGS(.submatch = mbsubmatch));
     83 }
     84