xref: /netbsd/sys/arch/epoc32/epoc32/internal.c (revision beecddb6)
1 /*	$NetBSD: internal.c,v 1.3 2021/08/07 16:18:48 thorpej Exp $	*/
2 /*
3  * Copyright (c) 2012 KIYOHARA Takashi
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
24  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include <sys/cdefs.h>
29 __KERNEL_RCSID(0, "$NetBSD: internal.c,v 1.3 2021/08/07 16:18:48 thorpej Exp $");
30 
31 #include <sys/param.h>
32 #include <sys/device.h>
33 #include <sys/errno.h>
34 
35 static int internal_match(device_t, cfdata_t, void *);
36 static void internal_attach(device_t, device_t, void *);
37 
38 static int internal_search(device_t, cfdata_t, const int *, void *);
39 
40 CFATTACH_DECL_NEW(internal, 0, internal_match, internal_attach, NULL, NULL);
41 
42 /* ARGSUSED */
43 static int
internal_match(device_t parent,cfdata_t match,void * aux)44 internal_match(device_t parent, cfdata_t match, void *aux)
45 {
46 	/* always attach */
47 	return 1;
48 }
49 
50 /* ARGSUSED */
51 static void
internal_attach(device_t parent,device_t self,void * aux)52 internal_attach(device_t parent, device_t self, void *aux)
53 {
54 
55 	aprint_naive("\n");
56 	aprint_normal("\n");
57 
58 	config_search(self, aux,
59 	    CFARGS(.search = internal_search));
60 }
61 
62 static int
internal_search(device_t self,cfdata_t cf,const int * ldesc,void * aux)63 internal_search(device_t self, cfdata_t cf, const int *ldesc, void *aux)
64 {
65 	extern char epoc32_model[];
66 
67 	if (strcmp(epoc32_model, "SERIES5 R1") == 0) {
68 		if (strcmp(cf->cf_name, "clpssoc") != 0)
69 			return 0;
70 	} else if (strcmp(epoc32_model, "SERIES5mx") == 0) {
71 		if (strcmp(cf->cf_name, "windermere") != 0)
72 			return 0;
73 	} else if (strcmp(epoc32_model, "SERIES 7") == 0) {
74 		if (strcmp(cf->cf_name, "saip") != 0)
75 			return 0;
76 	} else
77 		return 0;
78 
79 	if (config_probe(self, cf, aux))
80 		config_attach(self, cf, aux, NULL, CFARGS_NONE);
81 
82 	return 0;
83 }
84