imx31_aips.c revision 1.1.20.1 1 1.1.20.1 mjf /* $Id: imx31_aips.c,v 1.1.20.1 2008/06/02 13:21:53 mjf Exp $ */
2 1.1.20.1 mjf
3 1.1.20.1 mjf /* derived from: */
4 1.1.20.1 mjf /* $NetBSD: imx31_aips.c,v 1.1.20.1 2008/06/02 13:21:53 mjf Exp $ */
5 1.1.20.1 mjf
6 1.1.20.1 mjf /*
7 1.1.20.1 mjf * Copyright (c) 2002, 2005 Genetec Corporation. All rights reserved.
8 1.1.20.1 mjf * Written by Hiroyuki Bessho for Genetec Corporation.
9 1.1.20.1 mjf *
10 1.1.20.1 mjf * Redistribution and use in source and binary forms, with or without
11 1.1.20.1 mjf * modification, are permitted provided that the following conditions
12 1.1.20.1 mjf * are met:
13 1.1.20.1 mjf * 1. Redistributions of source code must retain the above copyright
14 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer.
15 1.1.20.1 mjf * 2. Redistributions in binary form must reproduce the above copyright
16 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer in the
17 1.1.20.1 mjf * documentation and/or other materials provided with the distribution.
18 1.1.20.1 mjf * 3. All advertising materials mentioning features or use of this software
19 1.1.20.1 mjf * must display the following acknowledgement:
20 1.1.20.1 mjf * This product includes software developed for the NetBSD Project by
21 1.1.20.1 mjf * Genetec Corporation.
22 1.1.20.1 mjf * 4. The name of Genetec Corporation may not be used to endorse or
23 1.1.20.1 mjf * promote products derived from this software without specific prior
24 1.1.20.1 mjf * written permission.
25 1.1.20.1 mjf *
26 1.1.20.1 mjf * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
27 1.1.20.1 mjf * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1.20.1 mjf * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1.20.1 mjf * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
30 1.1.20.1 mjf * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1.20.1 mjf * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1.20.1 mjf * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1.20.1 mjf * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1.20.1 mjf * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1.20.1 mjf * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1.20.1 mjf * POSSIBILITY OF SUCH DAMAGE.
37 1.1.20.1 mjf *
38 1.1.20.1 mjf *
39 1.1.20.1 mjf * Autoconfiguration support for the Intel PXA2[15]0 application
40 1.1.20.1 mjf * processor. This code is derived from arm/sa11x0/sa11x0.c
41 1.1.20.1 mjf */
42 1.1.20.1 mjf
43 1.1.20.1 mjf /*-
44 1.1.20.1 mjf * Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved.
45 1.1.20.1 mjf *
46 1.1.20.1 mjf * This code is derived from software contributed to The NetBSD Foundation
47 1.1.20.1 mjf * by IWAMOTO Toshihiro and Ichiro FUKUHARA.
48 1.1.20.1 mjf *
49 1.1.20.1 mjf * Redistribution and use in source and binary forms, with or without
50 1.1.20.1 mjf * modification, are permitted provided that the following conditions
51 1.1.20.1 mjf * are met:
52 1.1.20.1 mjf * 1. Redistributions of source code must retain the above copyright
53 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer.
54 1.1.20.1 mjf * 2. Redistributions in binary form must reproduce the above copyright
55 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer in the
56 1.1.20.1 mjf * documentation and/or other materials provided with the distribution.
57 1.1.20.1 mjf *
58 1.1.20.1 mjf * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
59 1.1.20.1 mjf * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
60 1.1.20.1 mjf * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
61 1.1.20.1 mjf * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
62 1.1.20.1 mjf * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 1.1.20.1 mjf * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 1.1.20.1 mjf * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
65 1.1.20.1 mjf * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
66 1.1.20.1 mjf * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 1.1.20.1 mjf * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
68 1.1.20.1 mjf * POSSIBILITY OF SUCH DAMAGE.
69 1.1.20.1 mjf */
70 1.1.20.1 mjf /*-
71 1.1.20.1 mjf * Copyright (c) 1999
72 1.1.20.1 mjf * Shin Takemura and PocketBSD Project. All rights reserved.
73 1.1.20.1 mjf *
74 1.1.20.1 mjf * Redistribution and use in source and binary forms, with or without
75 1.1.20.1 mjf * modification, are permitted provided that the following conditions
76 1.1.20.1 mjf * are met:
77 1.1.20.1 mjf * 1. Redistributions of source code must retain the above copyright
78 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer.
79 1.1.20.1 mjf * 2. Redistributions in binary form must reproduce the above copyright
80 1.1.20.1 mjf * notice, this list of conditions and the following disclaimer in the
81 1.1.20.1 mjf * documentation and/or other materials provided with the distribution.
82 1.1.20.1 mjf * 3. All advertising materials mentioning features or use of this software
83 1.1.20.1 mjf * must display the following acknowledgement:
84 1.1.20.1 mjf * This product includes software developed by the PocketBSD project
85 1.1.20.1 mjf * and its contributors.
86 1.1.20.1 mjf * 4. Neither the name of the project nor the names of its contributors
87 1.1.20.1 mjf * may be used to endorse or promote products derived from this software
88 1.1.20.1 mjf * without specific prior written permission.
89 1.1.20.1 mjf *
90 1.1.20.1 mjf * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
91 1.1.20.1 mjf * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
92 1.1.20.1 mjf * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
93 1.1.20.1 mjf * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
94 1.1.20.1 mjf * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
95 1.1.20.1 mjf * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
96 1.1.20.1 mjf * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
97 1.1.20.1 mjf * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 1.1.20.1 mjf * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 1.1.20.1 mjf * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 1.1.20.1 mjf * SUCH DAMAGE.
101 1.1.20.1 mjf *
102 1.1.20.1 mjf */
103 1.1.20.1 mjf
104 1.1.20.1 mjf #include <sys/cdefs.h>
105 1.1.20.1 mjf __KERNEL_RCSID(0, "$Id: imx31_aips.c,v 1.1.20.1 2008/06/02 13:21:53 mjf Exp $");
106 1.1.20.1 mjf
107 1.1.20.1 mjf #include "locators.h"
108 1.1.20.1 mjf
109 1.1.20.1 mjf #include <sys/param.h>
110 1.1.20.1 mjf #include <sys/systm.h>
111 1.1.20.1 mjf #include <sys/device.h>
112 1.1.20.1 mjf #include <sys/kernel.h>
113 1.1.20.1 mjf #include <sys/reboot.h>
114 1.1.20.1 mjf
115 1.1.20.1 mjf #include <machine/cpu.h>
116 1.1.20.1 mjf #include <machine/bus.h>
117 1.1.20.1 mjf
118 1.1.20.1 mjf #include <arm/cpufunc.h>
119 1.1.20.1 mjf #include <arm/mainbus/mainbus.h>
120 1.1.20.1 mjf
121 1.1.20.1 mjf #include <machine/intr.h>
122 1.1.20.1 mjf
123 1.1.20.1 mjf #include <arm/imx/imx31var.h>
124 1.1.20.1 mjf #include <arm/imx/imxuartreg.h>
125 1.1.20.1 mjf #include <arm/imx/imxuartvar.h>
126 1.1.20.1 mjf
127 1.1.20.1 mjf struct imxaips_softc {
128 1.1.20.1 mjf struct device sc_dev;
129 1.1.20.1 mjf bus_space_tag_t sc_bust;
130 1.1.20.1 mjf };
131 1.1.20.1 mjf
132 1.1.20.1 mjf /* prototypes */
133 1.1.20.1 mjf static int imxaips_match(device_t , cfdata_t, void *);
134 1.1.20.1 mjf static void imxaips_attach(device_t , device_t , void *);
135 1.1.20.1 mjf static int imxaips_search(device_t , cfdata_t, const int *, void *);
136 1.1.20.1 mjf static int imxaips_print(void *, const char *);
137 1.1.20.1 mjf
138 1.1.20.1 mjf /* attach structures */
139 1.1.20.1 mjf CFATTACH_DECL(aips, sizeof(struct imxaips_softc),
140 1.1.20.1 mjf imxaips_match, imxaips_attach, NULL, NULL);
141 1.1.20.1 mjf
142 1.1.20.1 mjf static int
143 1.1.20.1 mjf imxaips_match(device_t parent, cfdata_t match, void *aux)
144 1.1.20.1 mjf {
145 1.1.20.1 mjf return 1;
146 1.1.20.1 mjf }
147 1.1.20.1 mjf
148 1.1.20.1 mjf static void
149 1.1.20.1 mjf imxaips_attach(device_t parent, device_t self, void *aux)
150 1.1.20.1 mjf {
151 1.1.20.1 mjf struct imxaips_softc * const sc = (struct imxaips_softc *)self;
152 1.1.20.1 mjf struct ahb_attach_args * const ahba = aux;
153 1.1.20.1 mjf
154 1.1.20.1 mjf sc->sc_bust = ahba->ahba_memt;
155 1.1.20.1 mjf
156 1.1.20.1 mjf aprint_normal(": imx31 AHB-Lite 2.v6 to IP bus interface\n");
157 1.1.20.1 mjf
158 1.1.20.1 mjf /*
159 1.1.20.1 mjf * Attach all other devices
160 1.1.20.1 mjf */
161 1.1.20.1 mjf config_search_ia(imxaips_search, self, "aips", sc);
162 1.1.20.1 mjf }
163 1.1.20.1 mjf
164 1.1.20.1 mjf static int
165 1.1.20.1 mjf imxaips_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
166 1.1.20.1 mjf {
167 1.1.20.1 mjf struct imxaips_softc * const sc = aux;
168 1.1.20.1 mjf struct aips_attach_args aipsa;
169 1.1.20.1 mjf
170 1.1.20.1 mjf aipsa.aipsa_name = "aisp";
171 1.1.20.1 mjf aipsa.aipsa_memt = sc->sc_bust;
172 1.1.20.1 mjf aipsa.aipsa_addr = cf->cf_loc[AIPSCF_ADDR];
173 1.1.20.1 mjf aipsa.aipsa_size = cf->cf_loc[AIPSCF_SIZE];
174 1.1.20.1 mjf aipsa.aipsa_intr = cf->cf_loc[AIPSCF_INTR];
175 1.1.20.1 mjf
176 1.1.20.1 mjf if (config_match(parent, cf, &aipsa))
177 1.1.20.1 mjf config_attach(parent, cf, &aipsa, imxaips_print);
178 1.1.20.1 mjf
179 1.1.20.1 mjf return 0;
180 1.1.20.1 mjf }
181 1.1.20.1 mjf
182 1.1.20.1 mjf static int
183 1.1.20.1 mjf imxaips_print(void *aux, const char *name)
184 1.1.20.1 mjf {
185 1.1.20.1 mjf struct aips_attach_args *aipsa = aux;
186 1.1.20.1 mjf
187 1.1.20.1 mjf if (aipsa->aipsa_addr != AIPSCF_ADDR_DEFAULT) {
188 1.1.20.1 mjf aprint_normal(" addr 0x%lx", aipsa->aipsa_addr);
189 1.1.20.1 mjf if (aipsa->aipsa_size > AIPSCF_SIZE_DEFAULT)
190 1.1.20.1 mjf aprint_normal("-0x%lx",
191 1.1.20.1 mjf aipsa->aipsa_addr + aipsa->aipsa_size-1);
192 1.1.20.1 mjf }
193 1.1.20.1 mjf if (aipsa->aipsa_intr != AIPSCF_INTR_DEFAULT)
194 1.1.20.1 mjf aprint_normal(" intr %d", aipsa->aipsa_intr);
195 1.1.20.1 mjf
196 1.1.20.1 mjf return (UNCONF);
197 1.1.20.1 mjf }
198