1*c7fb772bSthorpej /* $NetBSD: shb.c,v 1.16 2021/08/07 16:19:05 thorpej Exp $ */
2049c8419Such
3049c8419Such /*-
4049c8419Such * Copyright (c) 2002 The NetBSD Foundation, Inc.
5049c8419Such * All rights reserved.
6049c8419Such *
7049c8419Such * Redistribution and use in source and binary forms, with or without
8049c8419Such * modification, are permitted provided that the following conditions
9049c8419Such * are met:
10049c8419Such * 1. Redistributions of source code must retain the above copyright
11049c8419Such * notice, this list of conditions and the following disclaimer.
12049c8419Such * 2. Redistributions in binary form must reproduce the above copyright
13049c8419Such * notice, this list of conditions and the following disclaimer in the
14049c8419Such * documentation and/or other materials provided with the distribution.
15049c8419Such *
16049c8419Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17049c8419Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18049c8419Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19049c8419Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20049c8419Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21049c8419Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22049c8419Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23049c8419Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24049c8419Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25049c8419Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26049c8419Such * POSSIBILITY OF SUCH DAMAGE.
27049c8419Such */
28049c8419Such
29ed517291Slukem #include <sys/cdefs.h>
30*c7fb772bSthorpej __KERNEL_RCSID(0, "$NetBSD: shb.c,v 1.16 2021/08/07 16:19:05 thorpej Exp $");
31ed517291Slukem
32049c8419Such #include <sys/param.h>
33049c8419Such #include <sys/systm.h>
34049c8419Such #include <sys/device.h>
35049c8419Such
36049c8419Such #include <machine/autoconf.h>
37049c8419Such
38ba0408a7Suwe extern struct cfdriver shb_cd;
39ba0408a7Suwe
408e76b333Suwe static int shb_match(device_t, cfdata_t, void *);
418e76b333Suwe static void shb_attach(device_t, device_t, void *);
42ba0408a7Suwe static int shb_print(void *, const char *);
438e76b333Suwe static int shb_search(device_t, cfdata_t, const int *, void *);
44049c8419Such
458e76b333Suwe CFATTACH_DECL_NEW(shb, 0,
4689bf5a8fSthorpej shb_match, shb_attach, NULL, NULL);
47049c8419Such
48ba0408a7Suwe
49ba0408a7Suwe static int
shb_match(device_t parent,cfdata_t cf,void * aux)508e76b333Suwe shb_match(device_t parent, cfdata_t cf, void *aux)
51049c8419Such {
52049c8419Such struct mainbus_attach_args *ma = aux;
53049c8419Such
54049c8419Such if (strcmp(ma->ma_name, shb_cd.cd_name) != 0)
55049c8419Such return (0);
56049c8419Such
57049c8419Such return (1);
58049c8419Such }
59049c8419Such
60ba0408a7Suwe static void
shb_attach(device_t parent,device_t self,void * aux)618e76b333Suwe shb_attach(device_t parent, device_t self, void *aux)
62049c8419Such {
63049c8419Such
648e76b333Suwe aprint_naive("\n");
658e76b333Suwe aprint_normal("\n");
66049c8419Such
672685996bSthorpej config_search(self, NULL,
68*c7fb772bSthorpej CFARGS(.search = shb_search));
69375ebd8cSuwe
70375ebd8cSuwe /*
71375ebd8cSuwe * XXX: TODO: provide hooks to manage on-chip modules. For
72375ebd8cSuwe * now register null hooks which is no worse than before.
73375ebd8cSuwe */
74375ebd8cSuwe if (!pmf_device_register(self, NULL, NULL))
75375ebd8cSuwe aprint_error_dev(self, "unable to establish power handler\n");
76049c8419Such }
77049c8419Such
78ba0408a7Suwe static int
shb_search(device_t parent,cfdata_t cf,const int * ldesc,void * aux)798e76b333Suwe shb_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
80049c8419Such {
81049c8419Such
822685996bSthorpej if (config_probe(parent, cf, NULL))
83*c7fb772bSthorpej config_attach(parent, cf, NULL, shb_print, CFARGS_NONE);
84049c8419Such
85049c8419Such return (0);
86049c8419Such }
87049c8419Such
88ba0408a7Suwe static int
shb_print(void * aux,const char * pnp)89049c8419Such shb_print(void *aux, const char *pnp)
90049c8419Such {
91049c8419Such
92049c8419Such return (pnp ? QUIET : UNCONF);
93049c8419Such }
94