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