xref: /netbsd-src/sys/arch/hpcarm/dev/ipaq_saip.c (revision 7433666e375b3ac4cc764df5a6726be98bc1cdd5)
1 /*	$NetBSD: ipaq_saip.c,v 1.26 2023/12/20 14:50:02 thorpej Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001, The NetBSD Foundation, Inc.  All rights reserved.
5  *
6  * This code is derived from software contributed to The NetBSD Foundation
7  * by Ichiro FUKUHARA (ichiro@ichiro.org).
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: ipaq_saip.c,v 1.26 2023/12/20 14:50:02 thorpej Exp $");
33 
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/types.h>
37 #include <sys/conf.h>
38 #include <sys/device.h>
39 #include <sys/kernel.h>
40 #include <sys/uio.h>
41 #include <sys/bus.h>
42 
43 #include <machine/cpu.h>
44 
45 #include <arm/sa11x0/sa11x0_var.h>
46 #include <arm/sa11x0/sa11x0_reg.h>
47 #include <arm/sa11x0/sa11x0_dmacreg.h>
48 #include <arm/sa11x0/sa11x0_ppcreg.h>
49 #include <arm/sa11x0/sa11x0_gpioreg.h>
50 #include <arm/sa11x0/sa11x0_sspreg.h>
51 
52 #include <hpcarm/dev/ipaq_saipvar.h>
53 #include <hpcarm/dev/ipaq_gpioreg.h>
54 
55 /* prototypes */
56 static int	ipaq_match(device_t, cfdata_t, void *);
57 static void	ipaq_attach(device_t, device_t, void *);
58 static int 	ipaq_search(device_t, cfdata_t, const int *, void *);
59 static int	ipaq_print(void *, const char *);
60 
61 /* attach structures */
62 CFATTACH_DECL_NEW(ipaqbus, sizeof(struct ipaq_softc),
63     ipaq_match, ipaq_attach, NULL, NULL);
64 
65 static int
ipaq_print(void * aux,const char * name)66 ipaq_print(void *aux, const char *name)
67 {
68         return (UNCONF);
69 }
70 
71 int
ipaq_match(device_t parent,cfdata_t match,void * aux)72 ipaq_match(device_t parent, cfdata_t match, void *aux)
73 {
74 	return (1);
75 }
76 
77 void
ipaq_attach(device_t parent,device_t self,void * aux)78 ipaq_attach(device_t parent, device_t self, void *aux)
79 {
80 	struct ipaq_softc *sc = device_private(self);
81 	struct sa11x0_softc *psc = device_private(parent);
82 
83 	aprint_normal("\n");
84 
85 	sc->sc_dev = self;
86 	sc->sc_iot = psc->sc_iot;
87 	sc->sc_ioh = psc->sc_ioh;
88 	sc->sc_gpioh = psc->sc_gpioh;
89 
90 	/* Map the Extended GPIO registers */
91 	if (bus_space_map(sc->sc_iot, SAEGPIO_BASE, 1, 0, &sc->sc_egpioh))
92 		panic("%s: unable to map Extended GPIO registers",
93 			device_xname(self));
94 
95 	sc->ipaq_egpio = EGPIO_INIT;
96         bus_space_write_2(sc->sc_iot, sc->sc_egpioh, 0, sc->ipaq_egpio);
97 
98 	/* Map the SSP registers */
99 	if (bus_space_map(sc->sc_iot, SASSP_BASE, SASSP_NPORTS, 0, &sc->sc_ssph))
100 		panic("%s: unable to map SSP registers",
101 			device_xname(self));
102 
103 	sc->sc_ppch = psc->sc_ppch;
104 	sc->sc_dmach = psc->sc_dmach;
105 
106 	/*
107 	 *  Attach each devices
108 	 */
109 	config_search(self, NULL,
110 	    CFARGS(.search = ipaq_search));
111 }
112 
113 int
ipaq_search(device_t parent,cfdata_t cf,const int * ldesc,void * aux)114 ipaq_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
115 {
116 	if (config_probe(parent, cf, NULL))
117 		config_attach(parent, cf, NULL, ipaq_print, CFARGS_NONE);
118 
119         return 0;
120 }
121