xref: /netbsd-src/sys/dev/hpc/apm_apmdevif.c (revision ea06597b8002d1b5d8c6ef79bd3f7e0a2cc1e6b3)
1*ea06597bSuwe /*	$NetBSD: apm_apmdevif.c,v 1.1 2009/04/03 04:17:03 uwe Exp $ */
2*ea06597bSuwe 
3*ea06597bSuwe /*
4*ea06597bSuwe  * Copyright (c) 2009 Valeriy E. Ushakov
5*ea06597bSuwe  * All rights reserved.
6*ea06597bSuwe  *
7*ea06597bSuwe  * Redistribution and use in source and binary forms, with or without
8*ea06597bSuwe  * modification, are permitted provided that the following conditions
9*ea06597bSuwe  * are met:
10*ea06597bSuwe  * 1. Redistributions of source code must retain the above copyright
11*ea06597bSuwe  *    notice, this list of conditions and the following disclaimer.
12*ea06597bSuwe  * 2. The name of the author may not be used to endorse or promote products
13*ea06597bSuwe  *    derived from this software without specific prior written permission
14*ea06597bSuwe  *
15*ea06597bSuwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*ea06597bSuwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*ea06597bSuwe  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*ea06597bSuwe  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*ea06597bSuwe  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*ea06597bSuwe  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*ea06597bSuwe  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*ea06597bSuwe  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*ea06597bSuwe  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*ea06597bSuwe  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*ea06597bSuwe  */
26*ea06597bSuwe 
27*ea06597bSuwe #include <sys/cdefs.h>
28*ea06597bSuwe __KERNEL_RCSID(0, "$NetBSD: apm_apmdevif.c,v 1.1 2009/04/03 04:17:03 uwe Exp $");
29*ea06597bSuwe 
30*ea06597bSuwe #include <sys/param.h>
31*ea06597bSuwe #include <sys/systm.h>
32*ea06597bSuwe #include <sys/device.h>
33*ea06597bSuwe #include <sys/selinfo.h> /* XXX: for apm_softc that is exposed here */
34*ea06597bSuwe 
35*ea06597bSuwe #include <dev/hpc/apm/apmvar.h>
36*ea06597bSuwe 
37*ea06597bSuwe static void	apm_apmdevif_attach(device_t, device_t, void *);
38*ea06597bSuwe static int	apm_apmdevif_match(device_t, cfdata_t, void *);
39*ea06597bSuwe 
40*ea06597bSuwe CFATTACH_DECL_NEW(apm_apmdevif, sizeof(struct apm_softc),
41*ea06597bSuwe     apm_apmdevif_match, apm_apmdevif_attach, NULL, NULL);
42*ea06597bSuwe 
43*ea06597bSuwe 
44*ea06597bSuwe static int
apm_apmdevif_match(device_t parent,cfdata_t match,void * aux)45*ea06597bSuwe apm_apmdevif_match(device_t parent, cfdata_t match, void *aux)
46*ea06597bSuwe {
47*ea06597bSuwe 
48*ea06597bSuwe 	return apm_match();
49*ea06597bSuwe }
50*ea06597bSuwe 
51*ea06597bSuwe static void
apm_apmdevif_attach(device_t parent,device_t self,void * aux)52*ea06597bSuwe apm_apmdevif_attach(device_t parent, device_t self, void *aux)
53*ea06597bSuwe {
54*ea06597bSuwe 	struct apm_softc *sc;
55*ea06597bSuwe 	struct apmdev_attach_args *aaa = aux;
56*ea06597bSuwe 
57*ea06597bSuwe 	sc = device_private(self);
58*ea06597bSuwe 	sc->sc_dev = self;
59*ea06597bSuwe 
60*ea06597bSuwe 	sc->sc_detail = aaa->apm_detail;
61*ea06597bSuwe 	sc->sc_vers = aaa->apm_detail & 0xffff; /* XXX: magic */
62*ea06597bSuwe 
63*ea06597bSuwe 	sc->sc_ops = aaa->accessops;
64*ea06597bSuwe 	sc->sc_cookie = aaa->accesscookie;
65*ea06597bSuwe 
66*ea06597bSuwe 	apm_attach(sc);
67*ea06597bSuwe }
68*ea06597bSuwe 
69*ea06597bSuwe int
apmprint(void * aux,const char * pnp)70*ea06597bSuwe apmprint(void *aux, const char *pnp)
71*ea06597bSuwe {
72*ea06597bSuwe 	if (pnp)
73*ea06597bSuwe 		aprint_normal("apm at %s", pnp);
74*ea06597bSuwe 
75*ea06597bSuwe 	return (UNCONF);
76*ea06597bSuwe }
77