1*c7fb772bSthorpej /* $Id: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $ */
2825088edSmatt
3825088edSmatt /* derived from: */
4*c7fb772bSthorpej /* $NetBSD: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $ */
5825088edSmatt
6825088edSmatt /*
7825088edSmatt * Copyright (c) 2002, 2005 Genetec Corporation. All rights reserved.
8825088edSmatt * Written by Hiroyuki Bessho for Genetec Corporation.
9825088edSmatt *
10825088edSmatt * Redistribution and use in source and binary forms, with or without
11825088edSmatt * modification, are permitted provided that the following conditions
12825088edSmatt * are met:
13825088edSmatt * 1. Redistributions of source code must retain the above copyright
14825088edSmatt * notice, this list of conditions and the following disclaimer.
15825088edSmatt * 2. Redistributions in binary form must reproduce the above copyright
16825088edSmatt * notice, this list of conditions and the following disclaimer in the
17825088edSmatt * documentation and/or other materials provided with the distribution.
18825088edSmatt * 3. All advertising materials mentioning features or use of this software
19825088edSmatt * must display the following acknowledgement:
20825088edSmatt * This product includes software developed for the NetBSD Project by
21825088edSmatt * Genetec Corporation.
22825088edSmatt * 4. The name of Genetec Corporation may not be used to endorse or
23825088edSmatt * promote products derived from this software without specific prior
24825088edSmatt * written permission.
25825088edSmatt *
26825088edSmatt * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
27825088edSmatt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28825088edSmatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29825088edSmatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
30825088edSmatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31825088edSmatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32825088edSmatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33825088edSmatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34825088edSmatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35825088edSmatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36825088edSmatt * POSSIBILITY OF SUCH DAMAGE.
37825088edSmatt *
38825088edSmatt *
39825088edSmatt * Autoconfiguration support for the Intel PXA2[15]0 application
40825088edSmatt * processor. This code is derived from arm/sa11x0/sa11x0.c
41825088edSmatt */
42825088edSmatt
43825088edSmatt /*-
44825088edSmatt * Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved.
45825088edSmatt *
46825088edSmatt * This code is derived from software contributed to The NetBSD Foundation
47825088edSmatt * by IWAMOTO Toshihiro and Ichiro FUKUHARA.
48825088edSmatt *
49825088edSmatt * Redistribution and use in source and binary forms, with or without
50825088edSmatt * modification, are permitted provided that the following conditions
51825088edSmatt * are met:
52825088edSmatt * 1. Redistributions of source code must retain the above copyright
53825088edSmatt * notice, this list of conditions and the following disclaimer.
54825088edSmatt * 2. Redistributions in binary form must reproduce the above copyright
55825088edSmatt * notice, this list of conditions and the following disclaimer in the
56825088edSmatt * documentation and/or other materials provided with the distribution.
5704bdb2abSmartin *
5804bdb2abSmartin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
5904bdb2abSmartin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
6004bdb2abSmartin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
6104bdb2abSmartin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
6204bdb2abSmartin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
6304bdb2abSmartin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
6404bdb2abSmartin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
6504bdb2abSmartin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
6604bdb2abSmartin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
6704bdb2abSmartin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
6804bdb2abSmartin * POSSIBILITY OF SUCH DAMAGE.
69825088edSmatt */
70825088edSmatt /*-
71825088edSmatt * Copyright (c) 1999
72825088edSmatt * Shin Takemura and PocketBSD Project. All rights reserved.
73825088edSmatt *
74825088edSmatt * Redistribution and use in source and binary forms, with or without
75825088edSmatt * modification, are permitted provided that the following conditions
76825088edSmatt * are met:
77825088edSmatt * 1. Redistributions of source code must retain the above copyright
78825088edSmatt * notice, this list of conditions and the following disclaimer.
79825088edSmatt * 2. Redistributions in binary form must reproduce the above copyright
80825088edSmatt * notice, this list of conditions and the following disclaimer in the
81825088edSmatt * documentation and/or other materials provided with the distribution.
82825088edSmatt * 3. All advertising materials mentioning features or use of this software
83825088edSmatt * must display the following acknowledgement:
84825088edSmatt * This product includes software developed by the PocketBSD project
85825088edSmatt * and its contributors.
86825088edSmatt * 4. Neither the name of the project nor the names of its contributors
87825088edSmatt * may be used to endorse or promote products derived from this software
88825088edSmatt * without specific prior written permission.
89825088edSmatt *
90825088edSmatt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
91825088edSmatt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92825088edSmatt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93825088edSmatt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
94825088edSmatt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95825088edSmatt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96825088edSmatt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97825088edSmatt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98825088edSmatt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99825088edSmatt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100825088edSmatt * SUCH DAMAGE.
101825088edSmatt *
102825088edSmatt */
103825088edSmatt
104825088edSmatt #include <sys/cdefs.h>
105*c7fb772bSthorpej __KERNEL_RCSID(0, "$Id: imx31_aips.c,v 1.7 2021/08/07 16:18:44 thorpej Exp $");
106825088edSmatt
107825088edSmatt #include "locators.h"
108825088edSmatt
109825088edSmatt #include <sys/param.h>
110825088edSmatt #include <sys/systm.h>
111825088edSmatt #include <sys/device.h>
112825088edSmatt #include <sys/kernel.h>
113825088edSmatt #include <sys/reboot.h>
114825088edSmatt
115825088edSmatt #include <machine/cpu.h>
116ed9977b1Sdyoung #include <sys/bus.h>
117825088edSmatt
118825088edSmatt #include <arm/cpufunc.h>
119825088edSmatt #include <arm/mainbus/mainbus.h>
120825088edSmatt
121825088edSmatt #include <machine/intr.h>
122825088edSmatt
123825088edSmatt #include <arm/imx/imx31var.h>
124825088edSmatt #include <arm/imx/imxuartreg.h>
125825088edSmatt #include <arm/imx/imxuartvar.h>
126825088edSmatt
127825088edSmatt struct imxaips_softc {
128825088edSmatt bus_space_tag_t sc_bust;
129825088edSmatt };
130825088edSmatt
131825088edSmatt /* prototypes */
132825088edSmatt static int imxaips_match(device_t , cfdata_t, void *);
133825088edSmatt static void imxaips_attach(device_t , device_t , void *);
134825088edSmatt static int imxaips_search(device_t , cfdata_t, const int *, void *);
135825088edSmatt static int imxaips_print(void *, const char *);
136825088edSmatt
137825088edSmatt /* attach structures */
138cbab9cadSchs CFATTACH_DECL_NEW(aips, sizeof(struct imxaips_softc),
139825088edSmatt imxaips_match, imxaips_attach, NULL, NULL);
140825088edSmatt
141825088edSmatt static int
imxaips_match(device_t parent,cfdata_t match,void * aux)142825088edSmatt imxaips_match(device_t parent, cfdata_t match, void *aux)
143825088edSmatt {
144825088edSmatt return 1;
145825088edSmatt }
146825088edSmatt
147825088edSmatt static void
imxaips_attach(device_t parent,device_t self,void * aux)148825088edSmatt imxaips_attach(device_t parent, device_t self, void *aux)
149825088edSmatt {
150cbab9cadSchs struct imxaips_softc * const sc = device_private(self);
151825088edSmatt struct ahb_attach_args * const ahba = aux;
152825088edSmatt
153825088edSmatt sc->sc_bust = ahba->ahba_memt;
154825088edSmatt
155825088edSmatt aprint_normal(": imx31 AHB-Lite 2.v6 to IP bus interface\n");
156825088edSmatt
157825088edSmatt /*
158825088edSmatt * Attach all other devices
159825088edSmatt */
1602685996bSthorpej config_search(self, sc,
161*c7fb772bSthorpej CFARGS(.search = imxaips_search));
162825088edSmatt }
163825088edSmatt
164825088edSmatt static int
imxaips_search(device_t parent,cfdata_t cf,const int * ldesc,void * aux)165825088edSmatt imxaips_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
166825088edSmatt {
167825088edSmatt struct imxaips_softc * const sc = aux;
168825088edSmatt struct aips_attach_args aipsa;
169825088edSmatt
170825088edSmatt aipsa.aipsa_name = "aisp";
171825088edSmatt aipsa.aipsa_memt = sc->sc_bust;
172825088edSmatt aipsa.aipsa_addr = cf->cf_loc[AIPSCF_ADDR];
173825088edSmatt aipsa.aipsa_size = cf->cf_loc[AIPSCF_SIZE];
174825088edSmatt aipsa.aipsa_intr = cf->cf_loc[AIPSCF_INTR];
175825088edSmatt
1762685996bSthorpej if (config_probe(parent, cf, &aipsa))
177*c7fb772bSthorpej config_attach(parent, cf, &aipsa, imxaips_print, CFARGS_NONE);
178825088edSmatt
179825088edSmatt return 0;
180825088edSmatt }
181825088edSmatt
182825088edSmatt static int
imxaips_print(void * aux,const char * name)183825088edSmatt imxaips_print(void *aux, const char *name)
184825088edSmatt {
185825088edSmatt struct aips_attach_args *aipsa = aux;
186825088edSmatt
187825088edSmatt if (aipsa->aipsa_addr != AIPSCF_ADDR_DEFAULT) {
188825088edSmatt aprint_normal(" addr 0x%lx", aipsa->aipsa_addr);
189825088edSmatt if (aipsa->aipsa_size > AIPSCF_SIZE_DEFAULT)
190825088edSmatt aprint_normal("-0x%lx",
191825088edSmatt aipsa->aipsa_addr + aipsa->aipsa_size-1);
192825088edSmatt }
193825088edSmatt if (aipsa->aipsa_intr != AIPSCF_INTR_DEFAULT)
194825088edSmatt aprint_normal(" intr %d", aipsa->aipsa_intr);
195825088edSmatt
196825088edSmatt return (UNCONF);
197825088edSmatt }
198